Mesa (main): radv: fix assertion for the count of xfb output

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 5b2756ec2c79ea467d1f399657a2c8f7cd8db1b8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b2756ec2c79ea467d1f399657a2c8f7cd8db1b8

Author: Hyunjun Ko 
Date:   Fri May 20 01:29:31 2022 +

radv: fix assertion for the count of xfb output

It's an counter, not an index.

Signed-off-by: Hyunjun Ko 
Part-of: 

---

 src/amd/vulkan/radv_shader_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_shader_info.c 
b/src/amd/vulkan/radv_shader_info.c
index e56c300daf9..6fcd773b4df 100644
--- a/src/amd/vulkan/radv_shader_info.c
+++ b/src/amd/vulkan/radv_shader_info.c
@@ -405,7 +405,7 @@ gather_xfb_info(const nir_shader *nir, struct 
radv_shader_info *info)
if (!xfb)
   return;
 
-   assert(xfb->output_count < MAX_SO_OUTPUTS);
+   assert(xfb->output_count <= MAX_SO_OUTPUTS);
so->num_outputs = xfb->output_count;
 
for (unsigned i = 0; i < xfb->output_count; i++) {



Mesa (main): radeonsi/tests: use a smaller tests-per-group value

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: e87135c55202e8b51439cbbc331e7b8aea92b255
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e87135c55202e8b51439cbbc331e7b8aea92b255

Author: Pierre-Eric Pelloux-Prayer 
Date:   Wed May 18 13:00:35 2022 +0200

radeonsi/tests: use a smaller tests-per-group value

Faster glcts runs (44 -> 34 sec).

Reviewed-by: Marek Olšák 
Part-of: 

---

 src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py 
b/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py
index 6fb56aa0b33..694e80d4fe9 100755
--- a/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py
+++ b/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py
@@ -419,6 +419,8 @@ if args.glcts:
 cmd = [
 "deqp-runner",
 "run",
+"--tests-per-group",
+"100",
 "--deqp",
 "{}/external/openglcts/modules/glcts".format(glcts_path),
 "--caselist",



Mesa (main): radeonsi/tests: add a --slow option

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: c2892b811a2513c56ada7ae68e919235096bf956
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c2892b811a2513c56ada7ae68e919235096bf956

Author: Pierre-Eric Pelloux-Prayer 
Date:   Wed May 18 12:55:58 2022 +0200

radeonsi/tests: add a --slow option

Some glcts tests implement tons of tests because they verify
every possible combination of format/swizzle/target/...

They take a long time to execute and aren't possible to run
using multiple processes.

The proper way to fix it would be to split them in vk-gl-cts,
as is already done for some of them (eg es31fTextureGatherTests.cpp).

In the meantime, not running them makes glcts run almost
10 times faster.

Reviewed-by: Marek Olšák 
Part-of: 

---

 src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py 
b/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py
index 086bbd02f5d..6fb56aa0b33 100755
--- a/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py
+++ b/src/gallium/drivers/radeonsi/ci/radeonsi-run-tests.py
@@ -97,6 +97,9 @@ parser.add_argument(
 parser.add_argument(
 "--no-deqp", dest="deqp", help="Disable dEQP tests", action="store_false"
 )
+parser.add_argument(
+"--slow", dest="slow", help="Include slowest glcts tests", 
action="store_true"
+)
 parser.add_argument(
 "--no-deqp-egl",
 dest="deqp_egl",
@@ -128,6 +131,7 @@ parser.set_defaults(deqp_egl=True)
 parser.set_defaults(deqp_gles2=True)
 parser.set_defaults(deqp_gles3=True)
 parser.set_defaults(deqp_gles31=True)
+parser.set_defaults(slow=False)
 
 parser.add_argument(
 "output_folder",
@@ -250,6 +254,18 @@ logfile = open(os.path.join(output_folder, 
"{}-run-tests.log".format(gpu_name)),
 
 spin = itertools.cycle("-\\|/")
 
+shutil.copy(skips, output_folder)
+skips = os.path.join(output_folder, "skips.csv")
+if not args.slow:
+# Exclude these 3 tests slow tests
+with open(skips, "a") as f:
+print("KHR-GL46.copy_image.functional", file=f)
+print("KHR-GL46.texture_swizzle.smoke", file=f)
+print(
+
"KHR-GL46.tessellation_shader.tessellation_control_to_tessellation_evaluation.gl_MaxPatchVertices_Position_PointSize",
+file=f,
+)
+
 
 def gfx_level_to_str(cl):
 supported = ["gfx6", "gfx7", "gfx8", "gfx9", "gfx10", "gfx10_3", "gfx11"]



Mesa (main): winsys: Do not use Display type when X11 is not present in build

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: cbb81e09ee9cd210cd90c8d388994568dc3a9a10
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbb81e09ee9cd210cd90c8d388994568dc3a9a10

Author: Sil Vilerino 
Date:   Thu May 19 06:43:33 2022 -0700

winsys: Do not use Display type when X11 is not present in build

Reviewed-by: Adam Jackson 

Closes: mesa/mesa#6520
Part-of: 

---

 src/gallium/auxiliary/vl/vl_winsys.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys.h 
b/src/gallium/auxiliary/vl/vl_winsys.h
index 387bc42b7b3..7528eaae453 100644
--- a/src/gallium/auxiliary/vl/vl_winsys.h
+++ b/src/gallium/auxiliary/vl/vl_winsys.h
@@ -105,7 +105,7 @@ vl_vgem_drm_screen_create(int fd) { return NULL; }
 struct vl_screen *
 vl_vgem_drm_screen_create(int fd);
 static inline struct vl_screen *
-vl_xlib_swrast_screen_create(Display *display, int screen) { return NULL; }
+vl_xlib_swrast_screen_create(void *display, int screen) { return NULL; }
 #endif
 
 #endif



Mesa (main): etnaviv: add linear PE support

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 53445284a427f79e94607dc4ca2f8bd8ac293356
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53445284a427f79e94607dc4ca2f8bd8ac293356

Author: Lucas Stach 
Date:   Thu May 19 20:29:38 2022 +0200

etnaviv: add linear PE support

GPUs with the LINEAR_PE feature bit have the ability to render into linear
buffers. While this decreases PE cache effectiveness and is thus slower than
rendering into a (super-)tiled buffer, it's still preferable for cases where
we would need a blit to get into linear otherwise, i.e. when importing a
linear buffer or when linear is forced on allocation by usage flags or
modifiers.

Signed-off-by: Lucas Stach 
Reviewed-by: Christian Gmeiner 
Part-of: 

---

 src/gallium/drivers/etnaviv/etnaviv_state.c   | 11 +--
 src/gallium/drivers/etnaviv/etnaviv_surface.c |  7 ---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c 
b/src/gallium/drivers/etnaviv/etnaviv_state.c
index 6b2f9bcdd17..66aaabd289f 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_state.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
@@ -136,6 +136,7 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
int nr_samples_color = -1;
int nr_samples_depth = -1;
bool target_16bpp = false;
+   bool target_linear = false;
 
/* Set up TS as well. Warning: this state is used by both the RS and PE */
uint32_t ts_mem_config = 0;
@@ -148,9 +149,13 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
   bool color_supertiled = (res->layout & ETNA_LAYOUT_BIT_SUPER) != 0;
   uint32_t fmt = translate_pe_format(cbuf->base.format);
 
-  assert(res->layout & ETNA_LAYOUT_BIT_TILE); /* Cannot render to linear 
surfaces */
+  assert((res->layout & ETNA_LAYOUT_BIT_TILE) ||
+ VIV_FEATURE(screen, chipMinorFeatures2, LINEAR_PE));
   etna_update_render_resource(pctx, etna_resource(cbuf->prsc));
 
+  if (res->layout == ETNA_LAYOUT_LINEAR)
+ target_linear = true;
+
   if (fmt >= PE_FORMAT_R16F)
   cs->PE_COLOR_FORMAT = VIVS_PE_COLOR_FORMAT_FORMAT_EXT(fmt) |
 VIVS_PE_COLOR_FORMAT_FORMAT_MASK;
@@ -366,7 +371,9 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
 * one per color buffer / depth buffer. To keep the logic simple always use
 * single buffer when this feature is available.
 */
-   if (screen->specs.single_buffer)
+   if (unlikely(target_linear))
+  pe_logic_op |= VIVS_PE_LOGIC_OP_SINGLE_BUFFER(1);
+   else if (screen->specs.single_buffer)
   pe_logic_op |= VIVS_PE_LOGIC_OP_SINGLE_BUFFER(target_16bpp ? 3 : 2);
cs->PE_LOGIC_OP = pe_logic_op;
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_surface.c 
b/src/gallium/drivers/etnaviv/etnaviv_surface.c
index 52a937652d2..0850f44613d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_surface.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_surface.c
@@ -48,10 +48,11 @@ etna_render_handle_incompatible(struct pipe_context *pctx, 
struct pipe_resource
bool need_multitiled = screen->specs.pixel_pipes > 1 && 
!screen->specs.single_buffer;
bool want_supertiled = screen->specs.can_supertile;
 
-   /* Resource is compatible if it is tiled and has multi tiling when required
-* TODO: LINEAR_PE feature means render to linear is possible ?
+   /* Resource is compatible if it is tiled or PE is able to render to linear
+* and has multi tiling when required.
 */
-   if (res->layout != ETNA_LAYOUT_LINEAR &&
+   if ((res->layout != ETNA_LAYOUT_LINEAR ||
+VIV_FEATURE(screen, chipMinorFeatures2, LINEAR_PE)) &&
(!need_multitiled || (res->layout & ETNA_LAYOUT_BIT_MULTI)))
   return res;
 



Mesa (main): etnaviv: improve single buffer setup

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 8452bd798425d9e5577a998ca89dd4943a92b064
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8452bd798425d9e5577a998ca89dd4943a92b064

Author: Lucas Stach 
Date:   Thu May 19 19:18:29 2022 +0200

etnaviv: improve single buffer setup

The blob only switches to the 3 single buffer state when required, which seems
to be the case when any color or ZS target is <= 16bpp. Using 2 as the single
buffer state gives a very small 1-2% performance improvement on fillrate
constrained rendering, so it likely affects some PE cache setting.

Signed-off-by: Lucas Stach 
Reviewed-by: Christian Gmeiner 
Part-of: 

---

 src/gallium/drivers/etnaviv/etnaviv_state.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c 
b/src/gallium/drivers/etnaviv/etnaviv_state.c
index ffc9b741368..6b2f9bcdd17 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_state.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
@@ -135,6 +135,7 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
struct compiled_framebuffer_state *cs = &ctx->framebuffer;
int nr_samples_color = -1;
int nr_samples_depth = -1;
+   bool target_16bpp = false;
 
/* Set up TS as well. Warning: this state is used by both the RS and PE */
uint32_t ts_mem_config = 0;
@@ -156,6 +157,9 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
   else
   cs->PE_COLOR_FORMAT = VIVS_PE_COLOR_FORMAT_FORMAT(fmt);
 
+  if (util_format_get_blocksize(cbuf->base.format) <= 2)
+ target_16bpp = true;
+
   cs->PE_COLOR_FORMAT |=
  VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK |
  VIVS_PE_COLOR_FORMAT_OVERWRITE |
@@ -251,6 +255,9 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
  depth_format == VIVS_PE_DEPTH_CONFIG_DEPTH_FORMAT_D16 ? 16 : 24;
   bool depth_supertiled = (res->layout & ETNA_LAYOUT_BIT_SUPER) != 0;
 
+  if (depth_bits == 16)
+ target_16bpp = true;
+
   cs->PE_DEPTH_CONFIG =
  depth_format |
  COND(depth_supertiled, VIVS_PE_DEPTH_CONFIG_SUPER_TILED) |
@@ -358,9 +365,9 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
/* Single buffer setup. There is only one switch for this, not a separate
 * one per color buffer / depth buffer. To keep the logic simple always use
 * single buffer when this feature is available.
-* note: the blob will use 2 in some situations, figure out why?
 */
-   pe_logic_op |= VIVS_PE_LOGIC_OP_SINGLE_BUFFER(screen->specs.single_buffer ? 
3 : 0);
+   if (screen->specs.single_buffer)
+  pe_logic_op |= VIVS_PE_LOGIC_OP_SINGLE_BUFFER(target_16bpp ? 3 : 2);
cs->PE_LOGIC_OP = pe_logic_op;
 
/* keep copy of original structure */



Mesa (main): turnip: add an assertion for max descriptor set count.

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: f2635ca47b0724a39682cf3699badb46fce0c653
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2635ca47b0724a39682cf3699badb46fce0c653

Author: Hyunjun Ko 
Date:   Fri May 20 01:37:38 2022 +

turnip: add an assertion for max descriptor set count.

Signed-off-by: Hyunjun Ko 
Part-of: 

---

 src/freedreno/vulkan/tu_descriptor_set.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/freedreno/vulkan/tu_descriptor_set.c 
b/src/freedreno/vulkan/tu_descriptor_set.c
index cb706dca2f8..d3e32241469 100644
--- a/src/freedreno/vulkan/tu_descriptor_set.c
+++ b/src/freedreno/vulkan/tu_descriptor_set.c
@@ -455,6 +455,8 @@ tu_CreatePipelineLayout(VkDevice _device,
for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) {
   TU_FROM_HANDLE(tu_descriptor_set_layout, set_layout,
  pCreateInfo->pSetLayouts[set]);
+
+  assert(set < MAX_SETS);
   layout->set[set].layout = set_layout;
   layout->set[set].dynamic_offset_start = dynamic_offset_size;
   tu_descriptor_set_layout_ref(set_layout);



Mesa (main): v3dv: expose VK_KHR_vulkan_memory_model

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 2c420fcf4061b6cb8d4046c913ae10c1c8d9991d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c420fcf4061b6cb8d4046c913ae10c1c8d9991d

Author: Iago Toral Quiroga 
Date:   Wed May 18 13:59:24 2022 +0200

v3dv: expose VK_KHR_vulkan_memory_model

Reviewed-by: Alejandro Piñeiro 
Part-of: 

---

 docs/features.txt   | 2 +-
 src/broadcom/vulkan/v3dv_device.c   | 5 +
 src/broadcom/vulkan/v3dv_pipeline.c | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/docs/features.txt b/docs/features.txt
index d9e67c87abe..ba9d5778ac0 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -462,7 +462,7 @@ Vulkan 1.2 -- all DONE: anv, vn
   VK_KHR_spirv_1_4  DONE (anv, lvp, radv, 
tu, v3dv, vn)
   VK_KHR_timeline_semaphore DONE (anv, lvp, radv, 
tu, v3dv, vn)
   VK_KHR_uniform_buffer_standard_layout DONE (anv, lvp, radv, 
tu, v3dv, vn)
-  VK_KHR_vulkan_memory_modelDONE (anv, lvp, radv, 
tu, vn)
+  VK_KHR_vulkan_memory_modelDONE (anv, lvp, radv, 
tu, v3dv, vn)
   VK_EXT_descriptor_indexingDONE (anv/gen9+, radv, 
tu, vn)
   VK_EXT_host_query_reset   DONE (anv, lvp, radv, 
tu, v3dv, vn)
   VK_EXT_sampler_filter_minmax  DONE (anv/gen9+, lvp, 
radv, tu, vn)
diff --git a/src/broadcom/vulkan/v3dv_device.c 
b/src/broadcom/vulkan/v3dv_device.c
index d6a7df84a62..b783a28da92 100644
--- a/src/broadcom/vulkan/v3dv_device.c
+++ b/src/broadcom/vulkan/v3dv_device.c
@@ -152,6 +152,7 @@ get_device_extensions(const struct v3dv_physical_device 
*device,
   .KHR_incremental_present = true,
 #endif
   .KHR_variable_pointers   = true,
+  .KHR_vulkan_memory_model = true,
   .EXT__formats= true,
   .EXT_color_write_enable  = true,
   .EXT_custom_border_color = true,
@@ -1192,6 +1193,10 @@ v3dv_GetPhysicalDeviceFeatures2(VkPhysicalDevice 
physicalDevice,
   .storagePushConstant8 = true,
   .imagelessFramebuffer = true,
   .timelineSemaphore = true,
+
+  .vulkanMemoryModel = true,
+  .vulkanMemoryModelDeviceScope = true,
+  .vulkanMemoryModelAvailabilityVisibilityChains = true,
};
 
VkPhysicalDeviceVulkan11Features vk11 = {
diff --git a/src/broadcom/vulkan/v3dv_pipeline.c 
b/src/broadcom/vulkan/v3dv_pipeline.c
index 3cba7834680..63a8efe984d 100644
--- a/src/broadcom/vulkan/v3dv_pipeline.c
+++ b/src/broadcom/vulkan/v3dv_pipeline.c
@@ -191,6 +191,8 @@ static const struct spirv_to_nir_options 
default_spirv_options =  {
   .storage_16bit = true,
   .subgroup_basic = true,
   .variable_pointers = true,
+  .vk_memory_model = true,
+  .vk_memory_model_device_scope = true,
 },
.ubo_addr_format = nir_address_format_32bit_index_offset,
.ssbo_addr_format = nir_address_format_32bit_index_offset,



Mesa (main): v3dv: fix format usage checks when extended usage flag is set

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: a987167ebd75c002f8f5d3724ffbafb6086c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a987167ebd75c002f8f5d3724ffbafb6086c

Author: Iago Toral Quiroga 
Date:   Fri May 20 08:46:51 2022 +0200

v3dv: fix format usage checks when extended usage flag is set

Fixes:
dEQP-VK.image.extended_usage_bit_compatibility.*

Reviewed-by: Alejandro Piñeiro 
Part-of: 

---

 src/broadcom/vulkan/v3dv_formats.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_formats.c 
b/src/broadcom/vulkan/v3dv_formats.c
index 581ad8d5a6e..cc48ccf61de 100644
--- a/src/broadcom/vulkan/v3dv_formats.c
+++ b/src/broadcom/vulkan/v3dv_formats.c
@@ -350,10 +350,20 @@ get_image_format_properties(
const VkImageStencilUsageCreateInfo *stencil_usage_info =
   vk_find_struct_const(info->pNext, IMAGE_STENCIL_USAGE_CREATE_INFO);
 
-   VkImageUsageFlags usage =
+   VkImageUsageFlags image_usage =
   info->usage | (stencil_usage_info ? stencil_usage_info->stencilUsage : 
0);
 
-   if (usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
+   /* If VK_IMAGE_CREATE_EXTENDED_USAGE_BIT is set it means the usage flags may
+* not be be supported for the image format but are supported for at least
+* one compatible format from which an image view can be created for the
+* image. This means we should not report the format as unsupported based
+* on the usage flags when usage refers to how an image view may be used
+* (i.e. as a framebuffer attachment, for sampling, etc).
+*/
+   VkImageUsageFlags view_usage =
+  info->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT ? 0 : image_usage;
+
+   if (image_usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
   if (!(format_feature_flags & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT)) {
  goto unsupported;
   }
@@ -369,14 +379,14 @@ get_image_format_properties(
   }
}
 
-   if (usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) {
+   if (image_usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) {
   if (!(format_feature_flags & VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) {
  goto unsupported;
   }
}
 
-   if (usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
-VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) {
+   if (view_usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
+ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) {
   if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
  goto unsupported;
   }
@@ -391,19 +401,19 @@ get_image_format_properties(
   }
}
 
-   if (usage & VK_IMAGE_USAGE_STORAGE_BIT) {
+   if (view_usage & VK_IMAGE_USAGE_STORAGE_BIT) {
   if (!(format_feature_flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) {
  goto unsupported;
   }
}
 
-   if (usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
+   if (view_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
   if (!(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
  goto unsupported;
   }
}
 
-   if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+   if (view_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
   if (!(format_feature_flags &
 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
  goto unsupported;



Mesa (main): broadcom/compiler: don't promote early fragment tests when writing sample mask

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: b90d7b9b38b92114532553db01d72b20cbc43d4d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b90d7b9b38b92114532553db01d72b20cbc43d4d

Author: Iago Toral Quiroga 
Date:   Fri May 20 09:44:45 2022 +0200

broadcom/compiler: don't promote early fragment tests when writing sample mask

If the sample mask is being written it means we want to discard some of the
samples generated so we should not be promoting the fragment shader to
do early tests, since that would not take into account the sample mask
written from the shader.

Fixes:
dEQP-VK.fragment_operations.early_fragment.sample_count_early_fragment_tests_depth_samples_4

Reviewed-by: Alejandro Piñeiro 
Part-of: 

---

 src/broadcom/compiler/nir_to_vir.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index 1f9c2fa5bf5..a1561d418c5 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1931,6 +1931,7 @@ emit_frag_end(struct v3d_compile *c)
 !(c->s->info.num_images || c->s->info.num_ssbos) &&
 !c->s->info.fs.uses_discard &&
 !c->fs_key->sample_alpha_to_coverage &&
+c->output_sample_mask_index == -1 &&
 has_any_tlb_color_write) {
 c->s->info.fs.early_fragment_tests = true;
 }



Mesa (main): radv: determine if shaders use NGG before linking

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: d711e9813cf2990e881eb8f6497f9ed8c74abecb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d711e9813cf2990e881eb8f6497f9ed8c74abecb

Author: Samuel Pitoiset 
Date:   Fri May 13 17:40:42 2022 +0200

radv: determine if shaders use NGG before linking

This would be needed by some NIR pass during linking. Given that NGG
settings are currently dispatched in many places, I don't think this
should hurt but it should be refactored at some point.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Timur Kristóf 
Part-of: 

---

 src/amd/vulkan/radv_pipeline.c | 55 +-
 1 file changed, 33 insertions(+), 22 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index e8db770eede..73b84153cbd 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -3314,30 +3314,11 @@ radv_determine_ngg_settings(struct radv_pipeline 
*pipeline,
 }
 
 static void
-radv_fill_shader_info(struct radv_pipeline *pipeline,
-  struct radv_pipeline_layout *pipeline_layout,
-  const struct radv_pipeline_key *pipeline_key,
-  struct radv_pipeline_stage *stages)
+radv_fill_shader_info_ngg(struct radv_pipeline *pipeline,
+  const struct radv_pipeline_key *pipeline_key,
+  struct radv_pipeline_stage *stages)
 {
struct radv_device *device = pipeline->device;
-   unsigned active_stages = 0;
-   unsigned filled_stages = 0;
-
-   for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) {
-  if (stages[i].nir)
- active_stages |= (1 << i);
-   }
-
-   if (stages[MESA_SHADER_TESS_CTRL].nir) {
-  stages[MESA_SHADER_VERTEX].info.vs.as_ls = true;
-   }
-
-   if (stages[MESA_SHADER_GEOMETRY].nir) {
-  if (stages[MESA_SHADER_TESS_CTRL].nir)
- stages[MESA_SHADER_TESS_EVAL].info.tes.as_es = true;
-  else
- stages[MESA_SHADER_VERTEX].info.vs.as_es = true;
-   }
 
if (pipeline_key->use_ngg) {
   if (stages[MESA_SHADER_TESS_CTRL].nir) {
@@ -3396,6 +3377,33 @@ radv_fill_shader_info(struct radv_pipeline *pipeline,
  }
   }
}
+}
+
+static void
+radv_fill_shader_info(struct radv_pipeline *pipeline,
+  struct radv_pipeline_layout *pipeline_layout,
+  const struct radv_pipeline_key *pipeline_key,
+  struct radv_pipeline_stage *stages)
+{
+   struct radv_device *device = pipeline->device;
+   unsigned active_stages = 0;
+   unsigned filled_stages = 0;
+
+   for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) {
+  if (stages[i].nir)
+ active_stages |= (1 << i);
+   }
+
+   if (stages[MESA_SHADER_TESS_CTRL].nir) {
+  stages[MESA_SHADER_VERTEX].info.vs.as_ls = true;
+   }
+
+   if (stages[MESA_SHADER_GEOMETRY].nir) {
+  if (stages[MESA_SHADER_TESS_CTRL].nir)
+ stages[MESA_SHADER_TESS_EVAL].info.tes.as_es = true;
+  else
+ stages[MESA_SHADER_VERTEX].info.vs.as_es = true;
+   }
 
if (stages[MESA_SHADER_FRAGMENT].nir) {
   radv_nir_shader_info_init(&stages[MESA_SHADER_FRAGMENT].info);
@@ -4536,6 +4544,9 @@ radv_create_shaders(struct radv_pipeline *pipeline, 
struct radv_pipeline_layout
 
bool optimize_conservatively = pipeline_key->optimisations_disabled;
 
+   /* Determine if shaders uses NGG before linking because it's needed for 
some NIR pass. */
+   radv_fill_shader_info_ngg(pipeline, pipeline_key, stages);
+
radv_link_shaders(pipeline, pipeline_key, stages, optimize_conservatively);
radv_set_driver_locations(pipeline, stages);
 



Mesa (main): radv: export implicit primitive ID in NIR for legacy VS or TES

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 95d4e5435bf63239105a50370edeb7fed2f8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=95d4e5435bf63239105a50370edeb7fed2f8

Author: Samuel Pitoiset 
Date:   Tue May 10 19:48:32 2022 +0200

radv: export implicit primitive ID in NIR for legacy VS or TES

It's implicit for VS or TES, while it's required for GS or MS.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Timur Kristóf 
Part-of: 

---

 src/amd/compiler/aco_instruction_selection.cpp | 13 +++---
 src/amd/llvm/ac_nir_to_llvm.c  |  2 ++
 src/amd/vulkan/radv_nir_to_llvm.c  | 16 +---
 src/amd/vulkan/radv_pipeline.c | 36 ++
 4 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/src/amd/compiler/aco_instruction_selection.cpp 
b/src/amd/compiler/aco_instruction_selection.cpp
index 745c9cd9ad5..c63a5e0255d 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -8872,6 +8872,9 @@ visit_intrinsic(isel_context* ctx, nir_intrinsic_instr* 
instr)
  * even if there is no SW GS. */
 bld.copy(Definition(dst), get_arg(ctx, ctx->args->ac.gs_prim_id));
 break;
+ } else if (ctx->shader->info.stage == MESA_SHADER_VERTEX) {
+bld.copy(Definition(dst), get_arg(ctx, ctx->args->ac.vs_prim_id));
+break;
  }
  unreachable("Unimplemented shader stage for 
nir_intrinsic_load_primitive_id");
   }
@@ -10632,16 +10635,6 @@ create_vs_exports(isel_context* ctx)
assert(outinfo);
ctx->block->kind |= block_kind_export_end;
 
-   if (outinfo->export_prim_id && ctx->stage.hw != HWStage::NGG) {
-  ctx->outputs.mask[VARYING_SLOT_PRIMITIVE_ID] |= 0x1;
-  if (ctx->stage.has(SWStage::TES))
- ctx->outputs.temps[VARYING_SLOT_PRIMITIVE_ID * 4u] =
-get_arg(ctx, ctx->args->ac.tes_patch_id);
-  else
- ctx->outputs.temps[VARYING_SLOT_PRIMITIVE_ID * 4u] =
-get_arg(ctx, ctx->args->ac.vs_prim_id);
-   }
-
/* Hardware requires position data to always be exported, even if the
 * application did not write gl_Position.
 */
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 875708ca9ef..9f61aa29484 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -3684,6 +3684,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx, 
nir_intrinsic_instr *ins
   } else if (ctx->stage == MESA_SHADER_TESS_EVAL) {
  result = ctx->tes_patch_id_replaced ? ctx->tes_patch_id_replaced
  : ac_get_arg(&ctx->ac, 
ctx->args->tes_patch_id);
+  } else if (ctx->stage == MESA_SHADER_VERTEX) {
+ result = ac_get_arg(&ctx->ac, ctx->args->vs_prim_id);
   } else
  fprintf(stderr, "Unknown primitive id intrinsic: %d", ctx->stage);
   break;
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c 
b/src/amd/vulkan/radv_nir_to_llvm.c
index ed7a3ec7a73..6c6fd1c685b 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -1046,7 +1046,7 @@ handle_vs_outputs_post(struct radv_shader_context *ctx, 
bool export_prim_id, boo
}
 
/* Allocate a temporary array for the output values. */
-   unsigned num_outputs = util_bitcount64(ctx->output_mask) + export_prim_id;
+   unsigned num_outputs = util_bitcount64(ctx->output_mask);
outputs = malloc(num_outputs * sizeof(outputs[0]));
 
for (unsigned i = 0; i < AC_LLVM_MAX_OUTPUTS; ++i) {
@@ -1072,20 +1072,6 @@ handle_vs_outputs_post(struct radv_shader_context *ctx, 
bool export_prim_id, boo
   noutput++;
}
 
-   /* Export PrimitiveID. */
-   if (export_prim_id) {
-  outputs[noutput].slot_name = VARYING_SLOT_PRIMITIVE_ID;
-  outputs[noutput].slot_index = 0;
-  outputs[noutput].usage_mask = 0x1;
-  if (ctx->stage == MESA_SHADER_TESS_EVAL)
- outputs[noutput].values[0] = ac_get_arg(&ctx->ac, 
ctx->args->ac.tes_patch_id);
-  else
- outputs[noutput].values[0] = ac_get_arg(&ctx->ac, 
ctx->args->ac.vs_prim_id);
-  for (unsigned j = 1; j < 4; j++)
- outputs[noutput].values[j] = ctx->ac.f32_0;
-  noutput++;
-   }
-
radv_llvm_export_vs(ctx, outputs, noutput, outinfo, export_clip_dists);
 
free(outputs);
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 73b84153cbd..770f9724b3c 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -2769,6 +2769,29 @@ radv_lower_multiview(nir_shader *nir)
return progress;
 }
 
+static bool
+radv_export_implicit_primitive_id(nir_shader *nir)
+{
+   nir_function_impl *impl = nir_shader_get_entrypoint(nir);
+   nir_builder b;
+   nir_builder_init(&b, impl);
+
+   b.cursor = nir_after_cf_list(&impl->body);
+
+   nir_variable *var = nir_variable_create(nir, nir_var

Mesa (staging/22.0): r300: keep negation if w is an inline constant

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: c5ed7faa6c03c36d6b50030aa6297cbfca9a6699
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5ed7faa6c03c36d6b50030aa6297cbfca9a6699

Author: Filip Gawin 
Date:   Tue May 17 18:10:21 2022 +0200

r300: keep negation if w is an inline constant

(in dataflow swizzles pass)

helps with:
dEQP-GLES2.functional.shaders.random.conditionals.combined.73
on r300 and r400

Cc: mesa-stable
Part-of: 
(cherry picked from commit fb2426db7a1eec78121609c0fb744c8f9cf885e9)

stable changes:
  - add `#include `, required to compile

---

 .pick_status.json|  2 +-
 src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c | 11 ---
 src/gallium/drivers/r300/compiler/radeon_program_constants.h |  5 +
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 0cf7443bde1..d112d534b31 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -748,7 +748,7 @@
 "description": "r300: keep negation if w is an inline constant",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c 
b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
index a16f4715c70..9113b005a59 100644
--- a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
+++ b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
@@ -29,6 +29,8 @@
  * Tom Stellard 
  */
 
+#include 
+
 #include "radeon_dataflow.h"
 
 #include "radeon_code.h"
@@ -97,6 +99,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler 
*c,
 {
unsigned new_swizzle, chan, swz0, swz1, swz2, swz3, found_swizzle, swz;
unsigned all_inline = 0;
+   bool w_inline_constant = false;
float imms[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
if (!rc_src_reg_is_immediate(c, reg->File, reg->Index)) {
@@ -321,7 +324,9 @@ static unsigned try_rewrite_constant(struct radeon_compiler 
*c,
swz3 = GET_SWZ(reg->Swizzle, 3);
 
/* We can skip this if the swizzle in channel w is an inline constant. 
*/
-   if (swz3 <= RC_SWIZZLE_W) {
+   if (is_swizzle_inline_constant(swz3)) {
+   w_inline_constant = true;
+   } else {
for (chan = 0; chan < 3; chan++) {
unsigned old_swz = GET_SWZ(reg->Swizzle, chan);
unsigned new_swz = GET_SWZ(new_swizzle, chan);
@@ -372,7 +377,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler 
*c,
 *
 * Swizzles with a value > RC_SWIZZLE_W are inline constants.
 */
-   if (chan == 3 && old_swz > RC_SWIZZLE_W) {
+   if (chan == 3 && w_inline_constant) {
continue;
}
 
@@ -409,7 +414,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler 
*c,
 * ONE, ZERO, HALF).
 */
reg->File = RC_FILE_CONSTANT;
-   reg->Negate = 0;
+   reg->Negate = w_inline_constant ? reg->Negate & (1 << 3) : 0;
return 1;
 }
 
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_constants.h 
b/src/gallium/drivers/r300/compiler/radeon_program_constants.h
index e54c6a892dc..6a8cbe333bf 100644
--- a/src/gallium/drivers/r300/compiler/radeon_program_constants.h
+++ b/src/gallium/drivers/r300/compiler/radeon_program_constants.h
@@ -115,6 +115,11 @@ typedef enum {
RC_SWIZZLE_UNUSED
 } rc_swizzle;
 
+static inline int is_swizzle_inline_constant(rc_swizzle swizzle){
+   return swizzle >= RC_SWIZZLE_ZERO;
+
+}
+
 #define RC_MAKE_SWIZZLE(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
 #define RC_MAKE_SWIZZLE_SMEAR(a) RC_MAKE_SWIZZLE((a),(a),(a),(a))
 #define GET_SWZ(swz, idx)  (((swz) >> ((idx)*3)) & 0x7)



Mesa (staging/22.0): .pick_status.json: Update to 95d4e5435bf63239105a50370ebbbbdeb7fed2f8

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: cdb79116c2758910c4d1f19e2ba12f1807006c68
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cdb79116c2758910c4d1f19e2ba12f1807006c68

Author: Dylan Baker 
Date:   Fri May 20 09:01:11 2022 -0700

.pick_status.json: Update to 95d4e5435bf63239105a50370edeb7fed2f8

---

 .pick_status.json | 2240 +
 1 file changed, 2240 insertions(+)

Diff:   
http://cgit.freedesktop.org/mesa/mesa/diff/?id=cdb79116c2758910c4d1f19e2ba12f1807006c68


Mesa (staging/22.0): radeonsi: lower nir_intrinsic_sparse_residency_code_and

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: cf45931c8766219b403bf9d1f2ee0b9ee3b93c9d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf45931c8766219b403bf9d1f2ee0b9ee3b93c9d

Author: Qiang Yu 
Date:   Wed May 18 11:17:20 2022 +0800

radeonsi: lower nir_intrinsic_sparse_residency_code_and

This is required by lower_tg4_offsets which split one
sparseTextureGatherOffsetsARB call to four sparseTextureGatherOffsetARB
calls and merge their resisident results into one.

Fixes: ee040a6b639 ("radeonsi: enable ARB_sparse_texture2")

Reviewed-by: Marek Olšák 
Signed-off-by: Qiang Yu 
Part-of: 
(cherry picked from commit cc4d5b16661a156e6b3aa4170f7d8f7919efc270)

---

 .pick_status.json| 2 +-
 src/gallium/drivers/radeonsi/si_shader_nir.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index d112d534b31..fff240e2b15 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -140,7 +140,7 @@
 "description": "radeonsi: lower 
nir_intrinsic_sparse_residency_code_and",
 "nominated": true,
 "nomination_type": 1,
-"resolution": 0,
+"resolution": 1,
 "because_sha": "ee040a6b6393c8a4726db070a708233e3b5ed44c"
 },
 {
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index f17b4f17fb2..27028552146 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -325,6 +325,8 @@ lower_intrinsic_instr(nir_builder *b, nir_instr *instr, 
void *dummy)
case nir_intrinsic_is_sparse_texels_resident:
   /* code==0 means sparse texels are resident */
   return nir_ieq_imm(b, intrin->src[0].ssa, 0);
+   case nir_intrinsic_sparse_residency_code_and:
+  return nir_ior(b, intrin->src[0].ssa, intrin->src[1].ssa);
default:
   return NULL;
}



Mesa (staging/22.0): zink: fix non-dynamic vertex stride update flagging

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: 12b9b7edf9585503832f7ab41b0e23d51c5e1dab
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=12b9b7edf9585503832f7ab41b0e23d51c5e1dab

Author: Mike Blumenkrantz 
Date:   Tue Apr 26 09:02:57 2022 -0400

zink: fix non-dynamic vertex stride update flagging

without dynamic vertex input, pipeline vertex state must be recalculated
if buffer strides change or the enabled buffer mask changes in order
to accurately handle dynamic state stride VUs

cc: mesa-stable

fixes:
spec@!opengl 1.1@array-stride

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit b18448e7acfc765ee95505c7cd5e2ce6e6fc36cc)

---

 .pick_status.json   |  2 +-
 src/gallium/drivers/zink/zink_context.c | 13 -
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 05107c43574..810602ba047 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -980,7 +980,7 @@
 "description": "zink: fix non-dynamic vertex stride update flagging",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index e3264d1cc0b..6a792dee8e9 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -962,18 +962,19 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
 const struct pipe_vertex_buffer *buffers)
 {
struct zink_context *ctx = zink_context(pctx);
+   const bool have_input_state = 
zink_screen(pctx->screen)->info.have_EXT_vertex_input_dynamic_state;
const bool need_state_change = 
!zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state &&
-  
!zink_screen(pctx->screen)->info.have_EXT_vertex_input_dynamic_state;
+  !have_input_state;
uint32_t enabled_buffers = 
ctx->gfx_pipeline_state.vertex_buffers_enabled_mask;
enabled_buffers |= u_bit_consecutive(start_slot, num_buffers);
enabled_buffers &= ~u_bit_consecutive(start_slot + num_buffers, 
unbind_num_trailing_slots);
+   bool stride_changed = false;
 
if (buffers) {
-  if (need_state_change)
- ctx->vertex_state_changed = true;
   for (unsigned i = 0; i < num_buffers; ++i) {
  const struct pipe_vertex_buffer *vb = buffers + i;
  struct pipe_vertex_buffer *ctx_vb = &ctx->vertex_buffers[start_slot + 
i];
+ stride_changed |= ctx_vb->stride != vb->stride;
  update_existing_vbo(ctx, start_slot + i);
  if (!take_ownership)
 pipe_resource_reference(&ctx_vb->buffer.resource, 
vb->buffer.resource);
@@ -995,8 +996,6 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
  }
   }
} else {
-  if (need_state_change)
- ctx->vertex_state_changed = true;
   for (unsigned i = 0; i < num_buffers; ++i) {
  update_existing_vbo(ctx, start_slot + i);
  pipe_resource_reference(&ctx->vertex_buffers[start_slot + 
i].buffer.resource, NULL);
@@ -1006,6 +1005,10 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
   update_existing_vbo(ctx, start_slot + i);
   pipe_resource_reference(&ctx->vertex_buffers[start_slot + 
i].buffer.resource, NULL);
}
+   if (need_state_change)
+  ctx->vertex_state_changed = true;
+   else if (!have_input_state && (stride_changed || 
ctx->gfx_pipeline_state.vertex_buffers_enabled_mask != enabled_buffers))
+  ctx->vertex_state_changed = true;
ctx->gfx_pipeline_state.vertex_buffers_enabled_mask = enabled_buffers;
ctx->vertex_buffers_dirty = num_buffers > 0;
 #ifndef NDEBUG



Mesa (staging/22.0): zink: only reject non-blittable resource creation if it has no other binds

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: f365d0ffb90bc33baefd637c84b328211cb74729
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f365d0ffb90bc33baefd637c84b328211cb74729

Author: Mike Blumenkrantz 
Date:   Wed Apr 20 09:45:51 2022 -0400

zink: only reject non-blittable resource creation if it has no other binds

the idea here is that if a resource is intended to be used solely as a 
rendertarget
and can't be blitted to or drawn to, then resource creation should fail

but if the resource might be e.g., a texture, then it can probably hit the 
subdata
path and be fine

Fixes: 37ac8647fca ("zink: reject resource creation if format features don't 
match attachment")

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit 07efe6f129956d0cce0fb167d08b5f8af25d0c95)

---

 .pick_status.json| 2 +-
 src/gallium/drivers/zink/zink_resource.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index fa284383371..3e432644118 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1052,7 +1052,7 @@
 "description": "zink: only reject non-blittable resource creation if 
it has no other binds",
 "nominated": true,
 "nomination_type": 1,
-"resolution": 0,
+"resolution": 1,
 "because_sha": "37ac8647fca4ab8aa1be6879fa810def7404449c"
 },
 {
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index cb6b1e0e077..6ca1040560c 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -254,7 +254,7 @@ get_image_usage_for_feats(struct zink_screen *screen, 
VkFormatFeatureFlags feats
  usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
  if ((bind & (PIPE_BIND_LINEAR | PIPE_BIND_SHARED)) != 
(PIPE_BIND_LINEAR | PIPE_BIND_SHARED))
 usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
-  } else if (templ->nr_samples || !(feats & 
VK_FORMAT_FEATURE_BLIT_DST_BIT))
+  } else if (templ->nr_samples || (bind == PIPE_BIND_RENDER_TARGET && 
!(feats & VK_FORMAT_FEATURE_BLIT_DST_BIT)))
  /* this can't be populated, so we can't do it */
  return 0;
}



Mesa (staging/22.0): radv: Fix RTPSO hashing of pGroups.

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: a369ad3a9ad8beb256105431d25e471daf358fa6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a369ad3a9ad8beb256105431d25e471daf358fa6

Author: Hans-Kristian Arntzen 
Date:   Wed May 18 15:44:30 2022 +0200

radv: Fix RTPSO hashing of pGroups.

There are padding bytes here. Only hash relevant members.

Fixes: ca2d96db51e ("radv: Add caching for RT pipelines.")
Signed-off-by: Hans-Kristian Arntzen 
Reviewed-by: Georg Lehmann 
Reviewed-by: Samuel Pitoiset 
Part-of: 
(cherry picked from commit 04459c82874b648a9c3ed4c9384b831772bb07e6)

---

 .pick_status.json|  2 +-
 src/amd/vulkan/radv_pipeline_cache.c | 14 --
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index fff240e2b15..73973e9983d 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -100,7 +100,7 @@
 "description": "radv: Fix RTPSO hashing of pGroups.",
 "nominated": true,
 "nomination_type": 1,
-"resolution": 0,
+"resolution": 1,
 "because_sha": "ca2d96db51e5a47044ee02f8613bc463605c2bf8"
 },
 {
diff --git a/src/amd/vulkan/radv_pipeline_cache.c 
b/src/amd/vulkan/radv_pipeline_cache.c
index b7fb11614dc..42d01ebbaee 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -172,8 +172,18 @@ radv_hash_rt_shaders(unsigned char *hash, const 
VkRayTracingPipelineCreateInfoKH
   }
}
 
-   _mesa_sha1_update(&ctx, pCreateInfo->pGroups,
- pCreateInfo->groupCount * sizeof(*pCreateInfo->pGroups));
+   for (uint32_t i = 0; i < pCreateInfo->groupCount; i++) {
+  _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].type,
+sizeof(pCreateInfo->pGroups[i].type));
+  _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].generalShader,
+sizeof(pCreateInfo->pGroups[i].generalShader));
+  _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].anyHitShader,
+sizeof(pCreateInfo->pGroups[i].anyHitShader));
+  _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].closestHitShader,
+sizeof(pCreateInfo->pGroups[i].closestHitShader));
+  _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].intersectionShader,
+sizeof(pCreateInfo->pGroups[i].intersectionShader));
+   }
 
if (!radv_rt_pipeline_has_dynamic_stack_size(pCreateInfo))
   _mesa_sha1_update(&ctx, &pCreateInfo->maxPipelineRayRecursionDepth, 4);



Mesa (staging/22.0): meson: add build-id to pipe libraries

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: adab4ef2af5d82738e6157ca79ccc753a5ca7dd6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=adab4ef2af5d82738e6157ca79ccc753a5ca7dd6

Author: Dave Airlie 
Date:   Thu May  5 12:43:25 2022 +1000

meson: add build-id to pipe libraries

Without this the cache setup was crashing with CL and the dynamic
pipe libraries.

Reported and debugged on irc by consolers

Cc: mesa-stable
Acked-by: Karol Herbst 
Part-of: 
(cherry picked from commit 74976640b3803d2ac7dab91e7d57d7b6383e06c4)

---

 .pick_status.json   | 2 +-
 src/gallium/targets/pipe-loader/meson.build | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6ad7553f776..9f61694da1c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1460,7 +1460,7 @@
 "description": "meson: add build-id to pipe libraries",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/targets/pipe-loader/meson.build 
b/src/gallium/targets/pipe-loader/meson.build
index 1d38c1a5b1b..291c4844906 100644
--- a/src/gallium/targets/pipe-loader/meson.build
+++ b/src/gallium/targets/pipe-loader/meson.build
@@ -18,7 +18,7 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-pipe_loader_link_args = [ld_args_gc_sections]
+pipe_loader_link_args = [ld_args_gc_sections, ld_args_build_id]
 pipe_loader_link_deps = []
 pipe_loader_link_with = [libgallium]
 pipe_loader_comp_args = []



Mesa (staging/22.0): zink: add extra validation for resource creation

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: 220a0578e7afa5c696d773666e4c7c1aad0b5b55
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=220a0578e7afa5c696d773666e4c7c1aad0b5b55

Author: Mike Blumenkrantz 
Date:   Wed Apr 20 12:57:47 2022 -0400

zink: add extra validation for resource creation

check image params against driver's returned limits to avoid
failing later

cc: mesa-stable

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit 1c17502ab38a238efe5d9aa4bc0ff07c967adb80)

---

 .pick_status.json|  2 +-
 src/gallium/drivers/zink/zink_resource.c | 12 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 3e432644118..e0fe88496d5 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1036,7 +1036,7 @@
 "description": "zink: add extra validation for resource creation",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index 6ca1040560c..2a887bef570 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -223,7 +223,17 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo 
*ici, uint64_t modifier)
} else
   ret = VKSCR(GetPhysicalDeviceImageFormatProperties)(screen->pdev, 
ici->format, ici->imageType,
ici->tiling, ici->usage, 
ici->flags, &image_props);
-   return ret == VK_SUCCESS;
+   if (ret != VK_SUCCESS)
+  return false;
+   if (ici->extent.depth > image_props.maxExtent.depth ||
+   ici->extent.height > image_props.maxExtent.height ||
+   ici->extent.width > image_props.maxExtent.width)
+  return false;
+   if (ici->mipLevels > image_props.maxMipLevels)
+  return false;
+   if (ici->arrayLayers > image_props.maxArrayLayers)
+  return false;
+   return true;
 }
 
 static VkImageUsageFlags



Mesa (staging/22.0): glx: set max values for pbuffer width / height

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: b0ee07a6ace7c1ebd64ccba5a5a0cc7061830325
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0ee07a6ace7c1ebd64ccba5a5a0cc7061830325

Author: Pierre-Eric Pelloux-Prayer 
Date:   Fri May 13 14:31:53 2022 +0200

glx: set max values for pbuffer width / height

Without this change the values are always 0. This breaks
Maya which uses this value to create a pbuffer (and then
fails).

This commit is based on b91e1e38e87 which does the same
for EGL.

Cc: mesa-stable
Reviewed-by: Marek Olšák 
Reviewed-by: Adam Jackson 
Part-of: 
(cherry picked from commit 8779a5b84cefba11a8644be295973150ab3d630f)

---

 .pick_status.json   | 2 +-
 src/glx/glxconfig.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 73973e9983d..6ad7553f776 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1948,7 +1948,7 @@
 "description": "glx: set max values for pbuffer width / height",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/glx/glxconfig.c b/src/glx/glxconfig.c
index f8dc3ce6086..e67d5fadf41 100644
--- a/src/glx/glxconfig.c
+++ b/src/glx/glxconfig.c
@@ -145,10 +145,10 @@ glx_config_get(struct glx_config * mode, int attribute, 
int *value_return)
   *value_return = mode->fbconfigID;
   return 0;
case GLX_MAX_PBUFFER_WIDTH:
-  *value_return = mode->maxPbufferWidth;
+  *value_return = 4096; /* _EGL_MAX_PBUFFER_WIDTH */
   return 0;
case GLX_MAX_PBUFFER_HEIGHT:
-  *value_return = mode->maxPbufferHeight;
+  *value_return = 4096; /* _EGL_MAX_PBUFFER_HEIGHT */
   return 0;
case GLX_MAX_PBUFFER_PIXELS:
   *value_return = mode->maxPbufferPixels;



Mesa (staging/22.0): zink: remove input attachment usage when pruning surface usage

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: a0bc096aef53793b9696d44baf371bd5fd7aeecb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0bc096aef53793b9696d44baf371bd5fd7aeecb

Author: Mike Blumenkrantz 
Date:   Wed Apr 20 13:28:09 2022 -0400

zink: remove input attachment usage when pruning surface usage

if the format doesn't support color attachment, it doesn't need to
be an input attachment

cc: mesa-stable

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit b6eec12327b65038dd56742dbe272c21c63a3844)

---

 .pick_status.json   | 2 +-
 src/gallium/drivers/zink/zink_surface.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e0fe88496d5..aa288d5b865 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1028,7 +1028,7 @@
 "description": "zink: remove input attachment usage when pruning 
surface usage",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/zink/zink_surface.c 
b/src/gallium/drivers/zink/zink_surface.c
index 8c95aacc218..0308ae73213 100644
--- a/src/gallium/drivers/zink/zink_surface.c
+++ b/src/gallium/drivers/zink/zink_surface.c
@@ -136,7 +136,7 @@ create_surface(struct pipe_context *pctx,
VkFormatFeatureFlags feats = res->optimal_tiling ?
 
screen->format_props[templ->format].optimalTilingFeatures :
 
screen->format_props[templ->format].linearTilingFeatures;
-   VkImageUsageFlags attachment = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | 
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
+   VkImageUsageFlags attachment = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | 
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | 
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
usage_info.usage = res->obj->vkusage & ~attachment;
if ((res->obj->vkusage & attachment) &&
!(feats & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | 
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))) {



Mesa (staging/22.0): zink: force render target usage for sampler-only resources

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: c626362907b860f8c7559f2b13018d8c929e085e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c626362907b860f8c7559f2b13018d8c929e085e

Author: Mike Blumenkrantz 
Date:   Wed Apr 20 13:51:13 2022 -0400

zink: force render target usage for sampler-only resources

these might hit u_blitter later, which will require rt usage
to handle texture views, so add rt usage now to avoid failing later

cc: mesa-stable

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit 7aee9f12b9c1f17ae2662c8043c8679ce698b731)

---

 .pick_status.json|  2 +-
 src/gallium/drivers/zink/zink_resource.c | 29 -
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 0cdb43e0a4e..05107c43574 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1004,7 +1004,7 @@
 "description": "zink: force render target usage for sampler-only 
resources",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index cd55921f5d5..f8fdfb0c35f 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -243,10 +243,11 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo 
*ici, uint64_t modifier)
 }
 
 static VkImageUsageFlags
-get_image_usage_for_feats(struct zink_screen *screen, VkFormatFeatureFlags 
feats, const struct pipe_resource *templ, unsigned bind)
+get_image_usage_for_feats(struct zink_screen *screen, VkFormatFeatureFlags 
feats, const struct pipe_resource *templ, unsigned bind, bool *need_extended)
 {
VkImageUsageFlags usage = 0;
bool is_planar = util_format_get_num_planes(templ->format) > 1;
+   *need_extended = false;
 
if (bind & ZINK_BIND_TRANSIENT)
   usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
@@ -270,8 +271,18 @@ get_image_usage_for_feats(struct zink_screen *screen, 
VkFormatFeatureFlags feats
  usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
  if ((bind & (PIPE_BIND_LINEAR | PIPE_BIND_SHARED)) != 
(PIPE_BIND_LINEAR | PIPE_BIND_SHARED))
 usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
-  } else
+  } else {
+ /* trust that gallium isn't going to give us anything wild */
+ *need_extended = true;
+ return 0;
+  }
+   } else if ((bind & PIPE_BIND_SAMPLER_VIEW) && 
!util_format_is_depth_or_stencil(templ->format)) {
+  if (!(feats & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
+ /* ensure we can u_blitter this later */
+ *need_extended = true;
  return 0;
+  }
+  usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
}
 
if (bind & PIPE_BIND_DEPTH_STENCIL) {
@@ -309,6 +320,7 @@ static VkImageUsageFlags
 get_image_usage(struct zink_screen *screen, VkImageCreateInfo *ici, const 
struct pipe_resource *templ, unsigned bind, unsigned modifiers_count, const 
uint64_t *modifiers, uint64_t *mod)
 {
VkImageTiling tiling = ici->tiling;
+   bool need_extended = false;
*mod = DRM_FORMAT_MOD_INVALID;
if (modifiers_count) {
   bool have_linear = false;
@@ -323,7 +335,8 @@ get_image_usage(struct zink_screen *screen, 
VkImageCreateInfo *ici, const struct
  }
  VkFormatFeatureFlags feats = find_modifier_feats(prop, modifiers[i], 
mod);
  if (feats) {
-VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, 
templ, bind);
+VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, 
templ, bind, &need_extended);
+assert(!need_extended);
 if (usage) {
ici->usage = usage;
if (check_ici(screen, ici, *mod))
@@ -335,7 +348,8 @@ get_image_usage(struct zink_screen *screen, 
VkImageCreateInfo *ici, const struct
   if (have_linear) {
  VkFormatFeatureFlags feats = find_modifier_feats(prop, 
DRM_FORMAT_MOD_LINEAR, mod);
  if (feats) {
-VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, 
templ, bind);
+VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, 
templ, bind, &need_extended);
+assert(!need_extended);
 if (usage) {
ici->usage = usage;
if (check_ici(screen, ici, *mod))
@@ -349,7 +363,12 @@ get_image_usage(struct zink_screen *screen, 
VkImageCreateInfo *ici, const struct
   VkFormatFeatureFlags feats = tiling == VK_IMAGE_TILING_LINEAR ? 
props.linearTilingFeatures : props.optimalTilingFeatures;
   if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)
  feats = UINT32_MAX;
-  VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, 
templ, bind);
+  VkImageUsageFlags usage = get_image

Mesa (staging/22.0): zink: add extended usage and retry if resource creation fails

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: e05e02e34078da38a674048ad21defdcb3eaa295
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e05e02e34078da38a674048ad21defdcb3eaa295

Author: Mike Blumenkrantz 
Date:   Wed Apr 20 13:29:52 2022 -0400

zink: add extended usage and retry if resource creation fails

this is one of those cases where some bizarro format is being created
for sampling only, but gallium blasts out all the bind flags at once

trust that we're not going to do anything too crazy and let surface
usage pruning handle the rest

cc: mesa-stable

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit 7057a363591279c3f65a3c4af41687e6f8142649)

---

 .pick_status.json|  2 +-
 src/gallium/drivers/zink/zink_resource.c | 15 ---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index aa288d5b865..bac861054e3 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1020,7 +1020,7 @@
 "description": "zink: add extended usage and retry if resource 
creation fails",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index 2a887bef570..2c6f7995882 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -264,8 +264,7 @@ get_image_usage_for_feats(struct zink_screen *screen, 
VkFormatFeatureFlags feats
  usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
  if ((bind & (PIPE_BIND_LINEAR | PIPE_BIND_SHARED)) != 
(PIPE_BIND_LINEAR | PIPE_BIND_SHARED))
 usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
-  } else if (templ->nr_samples || (bind == PIPE_BIND_RENDER_TARGET && 
!(feats & VK_FORMAT_FEATURE_BLIT_DST_BIT)))
- /* this can't be populated, so we can't do it */
+  } else
  return 0;
}
 
@@ -342,6 +341,8 @@ get_image_usage(struct zink_screen *screen, 
VkImageCreateInfo *ici, const struct
{
   VkFormatProperties props = screen->format_props[templ->format];
   VkFormatFeatureFlags feats = tiling == VK_IMAGE_TILING_LINEAR ? 
props.linearTilingFeatures : props.optimalTilingFeatures;
+  if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)
+ feats = UINT32_MAX;
   VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, 
templ, bind);
   if (usage) {
  ici->usage = usage;
@@ -437,6 +438,7 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo 
*ici, const struct pipe
bool first = true;
bool tried[2] = {0};
uint64_t mod = DRM_FORMAT_MOD_INVALID;
+retry:
while (!ici->usage) {
   if (!first) {
  switch (ici->tiling) {
@@ -458,8 +460,15 @@ create_ici(struct zink_screen *screen, VkImageCreateInfo 
*ici, const struct pipe
 unreachable("unhandled tiling mode");
  }
  if (tried[ici->tiling]) {
-*success = false;
+if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) {
+   *success = false;
return DRM_FORMAT_MOD_INVALID;
+}
+ici->flags |= VK_IMAGE_CREATE_EXTENDED_USAGE_BIT;
+tried[0] = false;
+tried[1] = false;
+first = true;
+goto retry;
  }
   }
   ici->usage = get_image_usage(screen, ici, templ, bind, modifiers_count, 
modifiers, &mod);



Mesa (staging/22.0): spirv: fix barrier scope assert

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: dfc1e844a462319da8936cad62f6290cfe5acdc5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfc1e844a462319da8936cad62f6290cfe5acdc5

Author: Mike Blumenkrantz 
Date:   Wed May 11 16:01:48 2022 -0400

spirv: fix barrier scope assert

glslang generates barriers with QueueFamily, so this is totally legal

cc: mesa-stable

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit 8c8e6e953f0ecb2e7e71a2311e5fc76860a57be8)

---

 .pick_status.json | 2 +-
 src/compiler/spirv/spirv_to_nir.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 9f61694da1c..fa284383371 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2028,7 +2028,7 @@
 "description": "spirv: fix barrier scope assert",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 79e176a2218..5be3c0e4496 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -4128,8 +4128,8 @@ vtn_emit_memory_barrier(struct vtn_builder *b, SpvScope 
scope,
   return;
}
 
-   /* There's only two scopes thing left */
-   vtn_assert(scope == SpvScopeInvocation || scope == SpvScopeDevice);
+   /* There's only three scopes left */
+   vtn_assert(scope == SpvScopeInvocation || scope == SpvScopeDevice || scope 
== SpvScopeQueueFamily);
 
/* Map the GLSL memoryBarrier() construct and any barriers with more than 
one
 * semantic to the corresponding NIR one.



Mesa (staging/22.0): zink: fix surface/bufferview cache comparisons

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: staging/22.0
Commit: 700fded17455b469708907ab32ce9d2d6f0df470
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=700fded17455b469708907ab32ce9d2d6f0df470

Author: Mike Blumenkrantz 
Date:   Wed Apr 20 15:07:03 2022 -0400

zink: fix surface/bufferview cache comparisons

these caches ignore pNext from the create info since the pNext cannot
affect the eventual object that is created, so comparing it will break
the hash table

cc: mesa-stable

Reviewed-by: Dave Airlie 
Part-of: 
(cherry picked from commit 9924fecee6412f1cad65d7d7347681856e3a525c)

---

 .pick_status.json|  2 +-
 src/gallium/drivers/zink/zink_resource.c | 10 --
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index bac861054e3..0cdb43e0a4e 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1012,7 +1012,7 @@
 "description": "zink: fix surface/bufferview cache comparisons",
 "nominated": true,
 "nomination_type": 0,
-"resolution": 0,
+"resolution": 1,
 "because_sha": null
 },
 {
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index 2c6f7995882..cd55921f5d5 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -69,13 +69,19 @@
 static bool
 equals_ivci(const void *a, const void *b)
 {
-   return memcmp(a, b, sizeof(VkImageViewCreateInfo)) == 0;
+   const uint8_t *pa = a;
+   const uint8_t *pb = b;
+   size_t offset = offsetof(VkImageViewCreateInfo, flags);
+   return memcmp(pa + offset, pb + offset, sizeof(VkImageViewCreateInfo) - 
offset) == 0;
 }
 
 static bool
 equals_bvci(const void *a, const void *b)
 {
-   return memcmp(a, b, sizeof(VkBufferViewCreateInfo)) == 0;
+   const uint8_t *pa = a;
+   const uint8_t *pb = b;
+   size_t offset = offsetof(VkBufferViewCreateInfo, flags);
+   return memcmp(pa + offset, pb + offset, sizeof(VkBufferViewCreateInfo) - 
offset) == 0;
 }
 
 static void



Mesa (main): zink: remove renderpass state flag for swapchain

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 079b95fc6abebd0887afcee6abfed965155bce0e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=079b95fc6abebd0887afcee6abfed965155bce0e

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:20:33 2022 -0400

zink: remove renderpass state flag for swapchain

this is redundant and can be merged onto the rt attrib

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_render_pass.c | 9 -
 src/gallium/drivers/zink/zink_render_pass.h | 3 +--
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index 16b07e261b4..b714010b1a3 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -59,8 +59,8 @@ create_render_pass2(struct zink_screen *screen, struct 
zink_render_pass_state *s
   pstate->attachments[i].samples = attachments[i].samples = rt->samples;
   attachments[i].loadOp = rt->clear_color ? VK_ATTACHMENT_LOAD_OP_CLEAR :
 /* TODO: need replicate EXT */
-//rt->resolve || 
(state->swapchain_init && rt->swapchain) ?
-state->swapchain_init && 
rt->swapchain ?
+//rt->resolve || rt->swapchain 
?
+rt->swapchain ?
 
VK_ATTACHMENT_LOAD_OP_DONT_CARE :
 VK_ATTACHMENT_LOAD_OP_LOAD;
 
@@ -251,7 +251,7 @@ zink_render_pass_attachment_get_barrier_info(const struct 
zink_render_pass *rp,
if (idx < rp->state.num_cbufs) {
   *pipeline = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
   *access |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
-  if (!rt->clear_color && (!rp->state.swapchain_init || !rt->swapchain))
+  if (!rt->clear_color && !rt->swapchain)
  *access |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
   return rt->fbfetch ? VK_IMAGE_LAYOUT_GENERAL : 
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
}
@@ -314,7 +314,6 @@ get_render_pass(struct zink_context *ctx)
const struct pipe_framebuffer_state *fb = &ctx->fb_state;
struct zink_render_pass_state state = {0};
uint32_t clears = 0;
-   state.swapchain_init = ctx->new_swapchain;
state.samples = fb->samples > 0;
 
u_foreach_bit(i, ctx->fbfetch_outputs)
@@ -328,7 +327,7 @@ get_render_pass(struct zink_context *ctx)
  state.rts[i].samples = MAX3(transient ? transient->base.nr_samples : 
0, surf->texture->nr_samples, 1);
  state.rts[i].clear_color = zink_fb_clear_enabled(ctx, i) && 
!zink_fb_clear_first_needs_explicit(&ctx->fb_clears[i]);
  clears |= !!state.rts[i].clear_color ? PIPE_CLEAR_COLOR0 << i : 0;
- state.rts[i].swapchain = surf->texture->bind & 
PIPE_BIND_DISPLAY_TARGET;
+ state.rts[i].swapchain = ctx->new_swapchain && (surf->texture->bind & 
PIPE_BIND_DISPLAY_TARGET);
  if (transient) {
 state.num_cresolves++;
 state.rts[i].resolve = true;
diff --git a/src/gallium/drivers/zink/zink_render_pass.h 
b/src/gallium/drivers/zink/zink_render_pass.h
index a7579a776f5..65d48ad89ef 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -51,9 +51,8 @@ struct zink_render_pass_state {
uint8_t num_cbufs : 5; /* PIPE_MAX_COLOR_BUFS = 8 */
uint8_t have_zsbuf : 1;
uint8_t samples:1; //for fs samplemask
-   uint8_t swapchain_init:1;
uint32_t num_zsresolves : 1;
-   uint32_t num_cresolves : 23; /* PIPE_MAX_COLOR_BUFS, but this is a struct 
hole */
+   uint32_t num_cresolves : 24; /* PIPE_MAX_COLOR_BUFS, but this is a struct 
hole */
struct zink_rt_attrib rts[PIPE_MAX_COLOR_BUFS + 1];
unsigned num_rts;
uint32_t clears; //for extra verification and update flagging



Mesa (main): zink: use zink_batch_no_rp to end renderpasses

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 4457a9388a3ea390c03e020f7a72f6b82dfcc8f8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4457a9388a3ea390c03e020f7a72f6b82dfcc8f8

Author: Mike Blumenkrantz 
Date:   Mon May  9 11:21:55 2022 -0400

zink: use zink_batch_no_rp to end renderpasses

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index c92a0d9ac91..dbe883a3c10 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2602,7 +2602,7 @@ flush_batch(struct zink_context *ctx, bool sync)
   zink_batch_rp(ctx);
bool conditional_render_active = ctx->render_condition.active;
zink_stop_conditional_render(ctx);
-   zink_end_render_pass(ctx);
+   zink_batch_no_rp(ctx);
zink_end_batch(ctx, batch);
ctx->deferred_fence = NULL;
 
@@ -2705,7 +2705,7 @@ zink_set_color_write_enables(struct zink_context *ctx)
ctx->disable_color_writes = disable_color_writes;
if (zink_screen(ctx->base.screen)->driver_workarounds.color_write_missing) {
   /* use dummy color buffers instead of the more sane option */
-  zink_end_render_pass(ctx);
+  zink_batch_no_rp(ctx);
   ctx->rp_changed = true;
   zink_update_framebuffer_state(ctx, ctx->fb_state.width, 
ctx->fb_state.height);
} else {
@@ -3421,7 +3421,7 @@ mem_barrier(struct zink_context *ctx, 
VkPipelineStageFlags src_stage, VkPipeline
mb.pNext = NULL;
mb.srcAccessMask = src;
mb.dstAccessMask = dst;
-   zink_end_render_pass(ctx);
+   zink_batch_no_rp(ctx);
VKCTX(CmdPipelineBarrier)(batch->state->cmdbuf, src_stage, dst_stage, 0, 1, 
&mb, 0, NULL, 0, NULL);
 }
 



Mesa (main): zink: always use zink_batch_rp to init renderpass

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 3e1cd9f6233a5d38e04ab9b488ffa60f1c4fc9f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e1cd9f6233a5d38e04ab9b488ffa60f1c4fc9f6

Author: Mike Blumenkrantz 
Date:   Mon May  9 11:20:13 2022 -0400

zink: always use zink_batch_rp to init renderpass

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index b63e242668a..c92a0d9ac91 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2599,7 +2599,7 @@ flush_batch(struct zink_context *ctx, bool sync)
struct zink_batch *batch = &ctx->batch;
if (ctx->clears_enabled)
   /* start rp to do all the clears */
-  zink_begin_render_pass(ctx);
+  zink_batch_rp(ctx);
bool conditional_render_active = ctx->render_condition.active;
zink_stop_conditional_render(ctx);
zink_end_render_pass(ctx);
@@ -3237,7 +3237,7 @@ zink_flush(struct pipe_context *pctx,
/* triggering clears will force has_work */
if (!deferred && ctx->clears_enabled)
   /* start rp to do all the clears */
-  zink_begin_render_pass(ctx);
+  zink_batch_rp(ctx);
 
if (ctx->needs_present && (flags & PIPE_FLUSH_END_OF_FRAME)) {
   if (ctx->needs_present->obj->image)



Mesa (main): zink: rename a fb surface variables

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 9a03beb2e9cdca4ff73c2469ba078c7c8fc8b631
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a03beb2e9cdca4ff73c2469ba078c7c8fc8b631

Author: Mike Blumenkrantz 
Date:   Thu Apr  7 15:23:58 2022 -0400

zink: rename a fb surface variables

no functional changes, just being more consistent

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 40 -
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index ebbf85af847..b63e242668a 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2721,20 +2721,20 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
unsigned samples = state->nr_cbufs || state->zsbuf ? 0 : state->samples;
 
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
-  struct pipe_surface *surf = ctx->fb_state.cbufs[i];
+  struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
   if (i < state->nr_cbufs)
- ctx->rp_changed |= !!zink_transient_surface(surf) != 
!!zink_transient_surface(state->cbufs[i]);
-  unbind_fb_surface(ctx, surf, i, i >= state->nr_cbufs || surf != 
state->cbufs[i]);
-  if (surf && ctx->needs_present == zink_resource(surf->texture))
+ ctx->rp_changed |= !!zink_transient_surface(psurf) != 
!!zink_transient_surface(state->cbufs[i]);
+  unbind_fb_surface(ctx, psurf, i, i >= state->nr_cbufs || psurf != 
state->cbufs[i]);
+  if (psurf && ctx->needs_present == zink_resource(psurf->texture))
  ctx->needs_present = NULL;
}
if (ctx->fb_state.zsbuf) {
-  struct pipe_surface *surf = ctx->fb_state.zsbuf;
-  struct zink_resource *res = zink_resource(surf->texture);
-  bool changed = surf != state->zsbuf;
-  unbind_fb_surface(ctx, surf, PIPE_MAX_COLOR_BUFS, changed);
+  struct pipe_surface *psurf = ctx->fb_state.zsbuf;
+  struct zink_resource *res = zink_resource(psurf->texture);
+  bool changed = psurf != state->zsbuf;
+  unbind_fb_surface(ctx, psurf, PIPE_MAX_COLOR_BUFS, changed);
   if (!changed)
- ctx->rp_changed |= !!zink_transient_surface(surf) != 
!!zink_transient_surface(state->zsbuf);
+ ctx->rp_changed |= !!zink_transient_surface(psurf) != 
!!zink_transient_surface(state->zsbuf);
   if (changed && unlikely(res->obj->needs_zs_evaluate))
  /* have to flush zs eval while the sample location data still exists,
   * so just throw some random barrier */
@@ -2753,12 +2753,12 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
unsigned prev_void_alpha_attachments = 
ctx->gfx_pipeline_state.void_alpha_attachments;
ctx->gfx_pipeline_state.void_alpha_attachments = 0;
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
-  struct pipe_surface *surf = ctx->fb_state.cbufs[i];
-  if (surf) {
- struct zink_surface *transient = zink_transient_surface(surf);
+  struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
+  if (psurf) {
+ struct zink_surface *transient = zink_transient_surface(psurf);
  if (!samples)
-samples = MAX3(transient ? transient->base.nr_samples : 1, 
surf->texture->nr_samples, 1);
- struct zink_resource *res = zink_resource(surf->texture);
+samples = MAX3(transient ? transient->base.nr_samples : 1, 
psurf->texture->nr_samples, 1);
+ struct zink_resource *res = zink_resource(psurf->texture);
  if (res->modifiers) {
 assert(!ctx->needs_present || ctx->needs_present == res);
 ctx->needs_present = res;
@@ -2766,21 +2766,21 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
  if (res->obj->dt) {
 /* #6274 */
 if 
(!zink_screen(ctx->base.screen)->info.have_KHR_swapchain_mutable_format &&
-surf->format != res->base.b.format)
+psurf->format != res->base.b.format)
mesa_loge("zink: SRGB framebuffer unsupported without 
KHR_swapchain_mutable_format");
  }
  res->fb_binds++;
- ctx->gfx_pipeline_state.void_alpha_attachments |= 
util_format_has_alpha1(surf->format) ? BITFIELD_BIT(i) : 0;
+ ctx->gfx_pipeline_state.void_alpha_attachments |= 
util_format_has_alpha1(psurf->format) ? BITFIELD_BIT(i) : 0;
   }
}
if (ctx->gfx_pipeline_state.void_alpha_attachments != 
prev_void_alpha_attachments)
   ctx->gfx_pipeline_state.dirty = true;
if (ctx->fb_state.zsbuf) {
-  struct pipe_surface *surf = ctx->fb_state.zsbuf;
-  struct zink_surface *transient = zink_transient_surface(surf);
+  struct pipe_surface *psurf = ctx->fb_state.zsbuf;
+  struct zink_surface *transient = zink_transient_surface(psurf);
   if (!samples)
- samples = MAX3(transient ? transient->base.nr_samples : 1,

Mesa (main): zink: use local variable for getting rt barrier info

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 3ef8cdbab2202d0aaceca52d60baf103207121fd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ef8cdbab2202d0aaceca52d60baf103207121fd

Author: Mike Blumenkrantz 
Date:   Tue May 10 11:42:14 2022 -0400

zink: use local variable for getting rt barrier info

no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_render_pass.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index 51152d18a28..bb5b5ef8ec1 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -258,13 +258,13 @@ zink_render_pass_attachment_get_barrier_info(const struct 
zink_render_pass *rp,
 
assert(rp->state.have_zsbuf);
*pipeline = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | 
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
-   if (rp->state.rts[idx].mixed_zs) {
+   if (rt->mixed_zs) {
   *access |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | 
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
   return VK_IMAGE_LAYOUT_GENERAL;
}
-   if (!rp->state.rts[idx].clear_color && !rp->state.rts[idx].clear_stencil)
+   if (!rt->clear_color && !rt->clear_stencil)
   *access |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
-   if (!rp->state.rts[idx].clear_color && !rp->state.rts[idx].clear_stencil && 
!rp->state.rts[idx].needs_write)
+   if (!rt->clear_color && !rt->clear_stencil && !rt->needs_write)
   return VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
*access |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;



Mesa (main): zink: split out scissor flagging from framebuffer updating

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: b25b8027e5e38217c4fa23fc3dfd5ca2a058fd96
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b25b8027e5e38217c4fa23fc3dfd5ca2a058fd96

Author: Mike Blumenkrantz 
Date:   Wed May 11 10:54:33 2022 -0400

zink: split out scissor flagging from framebuffer updating

this is kinda similar but not actually the same thing

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_clear.c   | 4 ++--
 src/gallium/drivers/zink/zink_context.c | 6 --
 src/gallium/drivers/zink/zink_framebuffer.c | 4 +---
 src/gallium/drivers/zink/zink_framebuffer.h | 2 +-
 src/gallium/drivers/zink/zink_render_pass.c | 5 -
 5 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_clear.c 
b/src/gallium/drivers/zink/zink_clear.c
index 97d2baeb70a..c1fa0106431 100644
--- a/src/gallium/drivers/zink/zink_clear.c
+++ b/src/gallium/drivers/zink/zink_clear.c
@@ -533,7 +533,7 @@ zink_clear_depth_stencil(struct pipe_context *pctx, struct 
pipe_surface *dst,
   if (fb_changed) {
  ctx->fb_state.width = dstx + width;
  ctx->fb_state.height = dsty + height;
- zink_update_framebuffer_state(ctx, orig_width, orig_height);
+ ctx->fb_changed = true;
  zink_batch_no_rp(ctx);
   }
   zink_clear(pctx, clear_flags, &scissor, NULL, depth, stencil);
@@ -541,7 +541,7 @@ zink_clear_depth_stencil(struct pipe_context *pctx, struct 
pipe_surface *dst,
   if (fb_changed) {
  ctx->fb_state.width = orig_width;
  ctx->fb_state.height = orig_height;
- zink_update_framebuffer_state(ctx, dstx + width, dsty + height);
+ ctx->fb_changed = true;
  zink_batch_no_rp(ctx);
   }
} else {
diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index bdc28793902..260a6da7ac6 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2351,7 +2351,7 @@ zink_set_color_write_enables(struct zink_context *ctx)
   /* use dummy color buffers instead of the more sane option */
   zink_batch_no_rp(ctx);
   ctx->rp_changed = true;
-  zink_update_framebuffer_state(ctx, ctx->fb_state.width, 
ctx->fb_state.height);
+  zink_update_framebuffer_state(ctx);
} else {
   reapply_color_write(ctx);
}
@@ -2434,7 +2434,9 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
}
rebind_fb_state(ctx, NULL, true);
ctx->fb_state.samples = MAX2(samples, 1);
-   zink_update_framebuffer_state(ctx, w, h);
+   zink_update_framebuffer_state(ctx);
+   if (ctx->fb_state.width != w || ctx->fb_state.height != h)
+  ctx->scissor_changed = true;
 
uint8_t rast_samples = ctx->fb_state.samples - 1;
if (rast_samples != ctx->gfx_pipeline_state.rast_samples)
diff --git a/src/gallium/drivers/zink/zink_framebuffer.c 
b/src/gallium/drivers/zink/zink_framebuffer.c
index ec83d3e26fc..852c99bcb69 100644
--- a/src/gallium/drivers/zink/zink_framebuffer.c
+++ b/src/gallium/drivers/zink/zink_framebuffer.c
@@ -209,10 +209,8 @@ debug_describe_zink_framebuffer(char* buf, const struct 
zink_framebuffer *ptr)
 }
 
 void
-zink_update_framebuffer_state(struct zink_context *ctx, int old_w, int old_h)
+zink_update_framebuffer_state(struct zink_context *ctx)
 {
-   if (ctx->fb_state.width != old_w || ctx->fb_state.height != old_h)
-  ctx->scissor_changed = true;
/* get_framebuffer adds a ref if the fb is reused or created;
 * always do get_framebuffer first to avoid deleting the same fb
 * we're about to use
diff --git a/src/gallium/drivers/zink/zink_framebuffer.h 
b/src/gallium/drivers/zink/zink_framebuffer.h
index 24d0dbf46d7..7544074e89b 100644
--- a/src/gallium/drivers/zink/zink_framebuffer.h
+++ b/src/gallium/drivers/zink/zink_framebuffer.h
@@ -86,5 +86,5 @@ struct zink_framebuffer *
 zink_get_framebuffer(struct zink_context *ctx);
 
 void
-zink_update_framebuffer_state(struct zink_context *ctx, int old_w, int old_h);
+zink_update_framebuffer_state(struct zink_context *ctx);
 #endif
diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index 6e330cb59c8..fecb93f345a 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -453,6 +453,7 @@ setup_framebuffer(struct zink_context *ctx)
if (!ctx->fb_changed)
   return;
 
+   zink_update_framebuffer_state(ctx);
zink_init_framebuffer(screen, ctx->framebuffer, rp);
ctx->fb_changed = false;
ctx->gfx_pipeline_state.render_pass = rp;
@@ -677,7 +678,9 @@ zink_render_update_swapchain(struct zink_context *ctx)
   ctx->fb_state.width = ctx->swapchain_size.width;
   ctx->fb_state.height = ctx->swapchain_size.height;
   zink_kopper_fixup_depth_buffer(ctx);
-  zink_update_framebuffer_state(ctx, old_w, old_h);
+  if (ctx->fb_state.width != ol

Mesa (main): zink: break out color rt attrib analysis into util function

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 728fa3606a5d8a93d6d4ff80e2e40a515742d5ea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=728fa3606a5d8a93d6d4ff80e2e40a515742d5ea

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:24:15 2022 -0400

zink: break out color rt attrib analysis into util function

(should be) no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_render_pass.c | 35 -
 src/gallium/drivers/zink/zink_render_pass.h |  2 ++
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index befe57e6e45..ae9906a765e 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -304,6 +304,26 @@ equals_render_pass_state(const void *a, const void *b)
return memcmp(a, b, offsetof(struct zink_render_pass_state, rts) + 
sizeof(s_a->rts[0]) * s_a->num_rts) == 0;
 }
 
+void
+zink_init_color_attachment(struct zink_context *ctx, unsigned i, struct 
zink_rt_attrib *rt)
+{
+   const struct pipe_framebuffer_state *fb = &ctx->fb_state;
+   struct pipe_surface *psurf = fb->cbufs[i];
+   if (psurf && !zink_use_dummy_attachments(ctx)) {
+  struct zink_surface *surf = zink_csurface(psurf);
+  struct zink_surface *transient = zink_transient_surface(psurf);
+  rt->format = surf->info.format[0];
+  rt->samples = MAX3(transient ? transient->base.nr_samples : 0, 
psurf->texture->nr_samples, 1);
+  rt->clear_color = zink_fb_clear_enabled(ctx, i) && 
!zink_fb_clear_first_needs_explicit(&ctx->fb_clears[i]);
+  rt->swapchain = ctx->new_swapchain && (psurf->texture->bind & 
PIPE_BIND_DISPLAY_TARGET);
+  rt->fbfetch = (ctx->fbfetch_outputs & BITFIELD_BIT(i)) > 0;
+   } else {
+  memset(rt, 0, sizeof(struct zink_rt_attrib));
+  rt->format = VK_FORMAT_R8G8B8A8_UNORM;
+  rt->samples = fb->samples;
+   }
+}
+
 static struct zink_render_pass *
 get_render_pass(struct zink_context *ctx)
 {
@@ -313,27 +333,20 @@ get_render_pass(struct zink_context *ctx)
uint32_t clears = 0;
state.samples = fb->samples > 0;
 
-   u_foreach_bit(i, ctx->fbfetch_outputs)
-  state.rts[i].fbfetch = true;
-
for (int i = 0; i < fb->nr_cbufs; i++) {
+  zink_init_color_attachment(ctx, i, &state.rts[i]);
   struct pipe_surface *surf = fb->cbufs[i];
   if (surf && !zink_use_dummy_attachments(ctx)) {
- struct zink_surface *transient = zink_transient_surface(surf);
- state.rts[i].format = zink_get_format(screen, surf->format);
- state.rts[i].samples = MAX3(transient ? transient->base.nr_samples : 
0, surf->texture->nr_samples, 1);
- state.rts[i].clear_color = zink_fb_clear_enabled(ctx, i) && 
!zink_fb_clear_first_needs_explicit(&ctx->fb_clears[i]);
  clears |= !!state.rts[i].clear_color ? PIPE_CLEAR_COLOR0 << i : 0;
- state.rts[i].swapchain = ctx->new_swapchain && (surf->texture->bind & 
PIPE_BIND_DISPLAY_TARGET);
+ struct zink_surface *transient = zink_transient_surface(surf);
  if (transient) {
 state.num_cresolves++;
 state.rts[i].resolve = true;
 if (!state.rts[i].clear_color)
state.msaa_expand_mask |= BITFIELD_BIT(i);
+ } else {
+state.rts[i].resolve = false;
  }
-  } else {
- state.rts[i].format = VK_FORMAT_R8G8B8A8_UNORM;
- state.rts[i].samples = fb->samples;
   }
   state.num_rts++;
}
diff --git a/src/gallium/drivers/zink/zink_render_pass.h 
b/src/gallium/drivers/zink/zink_render_pass.h
index aaf09fa04c6..65803a5ce48 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -101,4 +101,6 @@ bool
 zink_init_render_pass(struct zink_context *ctx);
 void
 zink_render_update_swapchain(struct zink_context *ctx);
+void
+zink_init_color_attachment(struct zink_context *ctx, unsigned i, struct 
zink_rt_attrib *rt);
 #endif



Mesa (main): zink: break out zs rt attrib analysis into util function

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: b2a33d364e4cd430310a3ab0865124ed462318d8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2a33d364e4cd430310a3ab0865124ed462318d8

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:24:15 2022 -0400

zink: break out zs rt attrib analysis into util function

(should be) no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_render_pass.c | 56 -
 src/gallium/drivers/zink/zink_render_pass.h |  2 ++
 2 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index ae9906a765e..f4331b1aafa 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -304,6 +304,37 @@ equals_render_pass_state(const void *a, const void *b)
return memcmp(a, b, offsetof(struct zink_render_pass_state, rts) + 
sizeof(s_a->rts[0]) * s_a->num_rts) == 0;
 }
 
+void
+zink_init_zs_attachment(struct zink_context *ctx, struct zink_rt_attrib *rt)
+{
+   const struct pipe_framebuffer_state *fb = &ctx->fb_state;
+   struct zink_resource *zsbuf = zink_resource(fb->zsbuf->texture);
+   struct zink_framebuffer_clear *fb_clear = 
&ctx->fb_clears[PIPE_MAX_COLOR_BUFS];
+   struct zink_surface *transient = zink_transient_surface(fb->zsbuf);
+   rt->format = zsbuf->format;
+   rt->samples = MAX3(transient ? transient->base.nr_samples : 0, 
fb->zsbuf->texture->nr_samples, 1);
+   rt->clear_color = zink_fb_clear_enabled(ctx, PIPE_MAX_COLOR_BUFS) &&
+ 
!zink_fb_clear_first_needs_explicit(fb_clear) &&
+ (zink_fb_clear_element(fb_clear, 
0)->zs.bits & PIPE_CLEAR_DEPTH);
+   rt->clear_stencil = zink_fb_clear_enabled(ctx, PIPE_MAX_COLOR_BUFS) &&
+   
!zink_fb_clear_first_needs_explicit(fb_clear) &&
+   (zink_fb_clear_element(fb_clear, 
0)->zs.bits & PIPE_CLEAR_STENCIL);
+   const uint64_t outputs_written = ctx->gfx_stages[PIPE_SHADER_FRAGMENT] ?
+
ctx->gfx_stages[PIPE_SHADER_FRAGMENT]->nir->info.outputs_written : 0;
+   bool needs_write_z = (ctx->dsa_state && 
ctx->dsa_state->hw_state.depth_write) ||
+   outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH);
+   needs_write_z |= transient || rt->clear_color;
+
+   bool needs_write_s = rt->clear_stencil || outputs_written & 
BITFIELD64_BIT(FRAG_RESULT_STENCIL);
+   if (!needs_write_z && (!ctx->dsa_state || 
!ctx->dsa_state->base.depth_enabled))
+  /* depth sample, stencil write */
+  rt->mixed_zs = needs_write_s && zsbuf->bind_count[0];
+   else
+  /* depth write + sample */
+  rt->mixed_zs = needs_write_z && zsbuf->bind_count[0];
+   rt->needs_write = needs_write_z | needs_write_s;
+}
+
 void
 zink_init_color_attachment(struct zink_context *ctx, unsigned i, struct 
zink_rt_attrib *rt)
 {
@@ -354,39 +385,16 @@ get_render_pass(struct zink_context *ctx)
assert(!state.num_cresolves || state.num_cbufs == state.num_cresolves);
 
if (fb->zsbuf) {
-  struct zink_resource *zsbuf = zink_resource(fb->zsbuf->texture);
-  struct zink_framebuffer_clear *fb_clear = 
&ctx->fb_clears[PIPE_MAX_COLOR_BUFS];
+  zink_init_zs_attachment(ctx, &state.rts[fb->nr_cbufs]);
   struct zink_surface *transient = zink_transient_surface(fb->zsbuf);
-  state.rts[fb->nr_cbufs].format = zsbuf->format;
-  state.rts[fb->nr_cbufs].samples = MAX3(transient ? 
transient->base.nr_samples : 0, fb->zsbuf->texture->nr_samples, 1);
   if (transient) {
  state.num_zsresolves = 1;
  state.rts[fb->nr_cbufs].resolve = true;
   }
-  state.rts[fb->nr_cbufs].clear_color = zink_fb_clear_enabled(ctx, 
PIPE_MAX_COLOR_BUFS) &&
-
!zink_fb_clear_first_needs_explicit(fb_clear) &&
-(zink_fb_clear_element(fb_clear, 
0)->zs.bits & PIPE_CLEAR_DEPTH);
-  state.rts[fb->nr_cbufs].clear_stencil = zink_fb_clear_enabled(ctx, 
PIPE_MAX_COLOR_BUFS) &&
-  
!zink_fb_clear_first_needs_explicit(fb_clear) &&
-  (zink_fb_clear_element(fb_clear, 
0)->zs.bits & PIPE_CLEAR_STENCIL);
   if (state.rts[fb->nr_cbufs].clear_color)
  clears |= PIPE_CLEAR_DEPTH;
   if (state.rts[fb->nr_cbufs].clear_stencil)
  clears |= PIPE_CLEAR_STENCIL;
-  const uint64_t outputs_written = ctx->gfx_stages[PIPE_SHADER_FRAGMENT] ?
-   
ctx->gfx_stages[PIPE_SHADER_FRAGMENT]->nir->info.outputs_written : 0;
-  bool needs_write_z = (ctx->dsa_state && 
ctx->dsa_state->hw_state.depth_write) ||
-  outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH)

Mesa (main): zink: track whether there's any transient attachments bound

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: ec3a7323daf4aee536b552c16e4138bb1ac2d2a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec3a7323daf4aee536b552c16e4138bb1ac2d2a5

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:25:43 2022 -0400

zink: track whether there's any transient attachments bound

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 6 ++
 src/gallium/drivers/zink/zink_context.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index d49461e587b..541e7bc91c1 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2384,10 +2384,14 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
zink_update_fbfetch(ctx);
unsigned prev_void_alpha_attachments = 
ctx->gfx_pipeline_state.void_alpha_attachments;
ctx->gfx_pipeline_state.void_alpha_attachments = 0;
+   ctx->transient_attachments = 0;
+
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
   struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
   if (psurf) {
  struct zink_surface *transient = zink_transient_surface(psurf);
+ if (transient)
+ctx->transient_attachments |= BITFIELD_BIT(i);
  if (!samples)
 samples = MAX3(transient ? transient->base.nr_samples : 1, 
psurf->texture->nr_samples, 1);
  struct zink_resource *res = zink_resource(psurf->texture);
@@ -2410,6 +2414,8 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
if (ctx->fb_state.zsbuf) {
   struct pipe_surface *psurf = ctx->fb_state.zsbuf;
   struct zink_surface *transient = zink_transient_surface(psurf);
+  if (transient)
+ ctx->transient_attachments |= BITFIELD_BIT(PIPE_MAX_COLOR_BUFS);
   if (!samples)
  samples = MAX3(transient ? transient->base.nr_samples : 1, 
psurf->texture->nr_samples, 1);
   zink_resource(psurf->texture)->fb_binds++;
diff --git a/src/gallium/drivers/zink/zink_context.h 
b/src/gallium/drivers/zink/zink_context.h
index fcf3d036933..895687098df 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -214,6 +214,7 @@ struct zink_context {
uint32_t writable_ssbos[PIPE_SHADER_TYPES];
struct zink_image_view 
image_views[PIPE_SHADER_TYPES][ZINK_MAX_SHADER_IMAGES];
 
+   uint32_t transient_attachments;
struct pipe_framebuffer_state fb_state;
struct hash_table framebuffer_cache;
 



Mesa (main): zink: fix indentation

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 4769b4e61071d1b81ce93c9d0b4dbe81c33f6624
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4769b4e61071d1b81ce93c9d0b4dbe81c33f6624

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:22:40 2022 -0400

zink: fix indentation

no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index e1ea094dbb4..d49461e587b 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2035,16 +2035,16 @@ zink_prep_fb_attachment(struct zink_context *ctx, 
struct zink_surface *surf, uns
VkImageLayout layout = 
zink_render_pass_attachment_get_barrier_info(&ctx->gfx_pipeline_state.render_pass->state.rts[i],
i < 
ctx->fb_state.nr_cbufs, &pipeline, &access);
zink_resource_image_barrier(ctx, res, layout, access, pipeline);
-if (i == ctx->fb_state.nr_cbufs && res->bind_count[0] && 
res->bind_count[0] != res->image_bind_count[0]) {
-   unsigned find = res->bind_count[0] - res->image_bind_count[0];
-   for (unsigned i = 0; i < PIPE_SHADER_COMPUTE; i++) {
-  u_foreach_bit(slot, res->sampler_binds[i]) {
- update_descriptor_state_sampler(ctx, i, slot, res);
- find--;
- if (!find) break;
-  }
-   }
-}
+   if (i == ctx->fb_state.nr_cbufs && res->bind_count[0] && res->bind_count[0] 
!= res->image_bind_count[0]) {
+  unsigned find = res->bind_count[0] - res->image_bind_count[0];
+  for (unsigned i = 0; i < PIPE_SHADER_COMPUTE; i++) {
+ u_foreach_bit(slot, res->sampler_binds[i]) {
+update_descriptor_state_sampler(ctx, i, slot, res);
+find--;
+if (!find) break;
+ }
+  }
+   }
return surf->image_view;
 }
 



Mesa (main): zink: pass rt attrib to zink_render_pass_attachment_get_barrier_info()

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 69efe357b32f4600b8907f3295aa85037902ac87
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=69efe357b32f4600b8907f3295aa85037902ac87

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:22:25 2022 -0400

zink: pass rt attrib to zink_render_pass_attachment_get_barrier_info()

no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 4 ++--
 src/gallium/drivers/zink/zink_render_pass.c | 7 ++-
 src/gallium/drivers/zink/zink_render_pass.h | 2 +-
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 5230be4cb6b..e1ea094dbb4 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2032,8 +2032,8 @@ zink_prep_fb_attachment(struct zink_context *ctx, struct 
zink_surface *surf, uns
   if (!i)
  zink_update_fbfetch(ctx);
}
-   VkImageLayout layout = 
zink_render_pass_attachment_get_barrier_info(ctx->gfx_pipeline_state.render_pass,
-   i, 
&pipeline, &access);
+   VkImageLayout layout = 
zink_render_pass_attachment_get_barrier_info(&ctx->gfx_pipeline_state.render_pass->state.rts[i],
+   i < 
ctx->fb_state.nr_cbufs, &pipeline, &access);
zink_resource_image_barrier(ctx, res, layout, access, pipeline);
 if (i == ctx->fb_state.nr_cbufs && res->bind_count[0] && 
res->bind_count[0] != res->image_bind_count[0]) {
unsigned find = res->bind_count[0] - res->image_bind_count[0];
diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index b714010b1a3..befe57e6e45 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -242,13 +242,11 @@ zink_destroy_render_pass(struct zink_screen *screen,
 }
 
 VkImageLayout
-zink_render_pass_attachment_get_barrier_info(const struct zink_render_pass 
*rp, unsigned idx,
+zink_render_pass_attachment_get_barrier_info(const struct zink_rt_attrib *rt, 
bool color,
  VkPipelineStageFlags *pipeline, 
VkAccessFlags *access)
 {
*access = 0;
-   assert(idx < rp->state.num_rts);
-   const struct zink_rt_attrib *rt = &rp->state.rts[idx];
-   if (idx < rp->state.num_cbufs) {
+   if (color) {
   *pipeline = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
   *access |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
   if (!rt->clear_color && !rt->swapchain)
@@ -256,7 +254,6 @@ zink_render_pass_attachment_get_barrier_info(const struct 
zink_render_pass *rp,
   return rt->fbfetch ? VK_IMAGE_LAYOUT_GENERAL : 
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
}
 
-   assert(rp->state.have_zsbuf);
*pipeline = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | 
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
if (rt->mixed_zs) {
   *access |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | 
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
diff --git a/src/gallium/drivers/zink/zink_render_pass.h 
b/src/gallium/drivers/zink/zink_render_pass.h
index 65d48ad89ef..aaf09fa04c6 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -95,7 +95,7 @@ void
 zink_end_render_pass(struct zink_context *ctx);
 
 VkImageLayout
-zink_render_pass_attachment_get_barrier_info(const struct zink_render_pass 
*rp, unsigned idx, VkPipelineStageFlags *pipeline, VkAccessFlags *access);
+zink_render_pass_attachment_get_barrier_info(const struct zink_rt_attrib *rt, 
bool color, VkPipelineStageFlags *pipeline, VkAccessFlags *access);
 
 bool
 zink_init_render_pass(struct zink_context *ctx);



Mesa (main): zink: use global image rebind counter for dmabuf export

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 3d145ec7f1eaee0a3b77f41414df07271054da39
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d145ec7f1eaee0a3b77f41414df07271054da39

Author: Mike Blumenkrantz 
Date:   Mon May  9 12:23:26 2022 -0400

zink: use global image rebind counter for dmabuf export

this is a bit less flimsy and handles more than just framebuffer rebinds

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c  | 30 ++
 src/gallium/drivers/zink/zink_context.h  |  3 +++
 src/gallium/drivers/zink/zink_draw.cpp   |  5 +
 src/gallium/drivers/zink/zink_resource.c |  1 +
 src/gallium/drivers/zink/zink_screen.h   |  1 +
 5 files changed, 40 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 2ca6f6407ca..e92de9f476c 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3749,6 +3749,36 @@ zink_rebind_all_buffers(struct zink_context *ctx)
}
 }
 
+void
+zink_rebind_all_images(struct zink_context *ctx)
+{
+   rebind_fb_state(ctx, NULL, false);
+for (unsigned i = 0; i < PIPE_SHADER_TYPES; i++) {
+  for (unsigned j = 0; j < ctx->di.num_sampler_views[i]; j++) {
+ struct zink_sampler_view *sv = 
zink_sampler_view(ctx->sampler_views[i][j]);
+ struct zink_resource *res = 
zink_resource(sv->image_view->base.texture);
+ if (res->obj != sv->image_view->obj) {
+ struct pipe_surface *psurf = &sv->image_view->base;
+ zink_rebind_surface(ctx, &psurf);
+ sv->image_view = zink_surface(psurf);
+ 
zink_screen(ctx->base.screen)->context_invalidate_descriptor_state(ctx, i, 
ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, j, 1);
+ update_descriptor_state_sampler(ctx, i, j, res);
+ }
+  }
+  for (unsigned j = 0; j < ctx->di.num_images[i]; j++) {
+ struct zink_image_view *image_view = &ctx->image_views[i][j];
+ struct zink_resource *res = zink_resource(image_view->base.resource);
+ if (ctx->image_views[i][j].surface->obj != res->obj) {
+zink_surface_reference(zink_screen(ctx->base.screen), 
&image_view->surface, NULL);
+image_view->surface = create_image_surface(ctx, &image_view->base, 
i == PIPE_SHADER_COMPUTE);
+
zink_screen(ctx->base.screen)->context_invalidate_descriptor_state(ctx, i, 
ZINK_DESCRIPTOR_TYPE_IMAGE, j, 1);
+update_descriptor_state_image(ctx, i, j, res);
+_mesa_set_add(ctx->need_barriers[i == PIPE_SHADER_COMPUTE], res);
+ }
+  }
+   }
+}
+
 static void
 zink_context_replace_buffer_storage(struct pipe_context *pctx, struct 
pipe_resource *dst,
 struct pipe_resource *src, unsigned 
num_rebinds,
diff --git a/src/gallium/drivers/zink/zink_context.h 
b/src/gallium/drivers/zink/zink_context.h
index 7fbfcb38b54..76394ff141b 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -309,6 +309,7 @@ struct zink_context {
struct zink_buffer_view *dummy_bufferview;
 
unsigned buffer_rebind_counter;
+   unsigned image_rebind_counter;
 
struct {
   /* descriptor info */
@@ -453,6 +454,8 @@ zink_pipeline_flags_from_pipe_stage(enum pipe_shader_type 
pstage)
 
 void
 zink_rebind_all_buffers(struct zink_context *ctx);
+void
+zink_rebind_all_images(struct zink_context *ctx);
 
 void
 zink_flush_memory_barrier(struct zink_context *ctx, bool is_compute);
diff --git a/src/gallium/drivers/zink/zink_draw.cpp 
b/src/gallium/drivers/zink/zink_draw.cpp
index 4aebcbe667e..1e53cc808ed 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -491,6 +491,11 @@ zink_draw(struct pipe_context *pctx,
   zink_rebind_all_buffers(ctx);
}
 
+   if (unlikely(ctx->image_rebind_counter < screen->image_rebind_counter)) {
+  ctx->image_rebind_counter = screen->image_rebind_counter;
+  zink_rebind_all_images(ctx);
+   }
+
unsigned index_offset = 0;
unsigned index_size = dinfo->index_size;
struct pipe_resource *index_buffer = NULL;
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index fb926f41fcc..770b225e2ae 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -1305,6 +1305,7 @@ zink_resource_get_handle(struct pipe_screen *pscreen,
 assert(!zink_resource_usage_is_unflushed(res));
 if (!add_resource_bind(screen->copy_context, res, ZINK_BIND_DMABUF 
| PIPE_BIND_SHARED))
return false;
+p_atomic_inc(&screen->image_rebind_counter);
 screen->copy_context->base.flush(&screen->copy_context->base, 
NULL, 0);
 obj = res->obj;
  }
diff --git a/src/gallium/drivers/zink/zink_screen.h 
b/src/ga

Mesa (main): zink: use dynamic rendering (most of the time)

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: c81cd989c857a5b7384f534407b0ec1e9ddedf12
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c81cd989c857a5b7384f534407b0ec1e9ddedf12

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:38:01 2022 -0400

zink: use dynamic rendering (most of the time)

this is a simplified version of the renderpass infrastructure which
tracks rendering info on the context and updates it incrementally to
try and reduce cpu overhead

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c  | 213 ++-
 src/gallium/drivers/zink/zink_context.h  |  10 ++
 src/gallium/drivers/zink/zink_device_info.py |   3 +
 src/gallium/drivers/zink/zink_pipeline.c |  11 +-
 src/gallium/drivers/zink/zink_pipeline.h |   2 +
 src/gallium/drivers/zink/zink_program.c  |   3 +
 6 files changed, 236 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 260a6da7ac6..e1e7c9ccb98 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1996,13 +1996,155 @@ zink_update_vk_sample_locations(struct zink_context 
*ctx)
}
 }
 
+static unsigned
+find_rp_state(struct zink_context *ctx)
+{
+   bool found = false;
+   struct set_entry *he = _mesa_set_search_or_add(&ctx->rendering_state_cache, 
&ctx->gfx_pipeline_state.rendering_info, &found);
+   struct zink_rendering_info *info;
+   if (found) {
+  info = (void*)he->key;
+  return info->id;
+   }
+   info = ralloc(ctx, struct zink_rendering_info);
+   memcpy(info, &ctx->gfx_pipeline_state.rendering_info, 
sizeof(VkPipelineRenderingCreateInfo));
+   info->id = ctx->rendering_state_cache.entries;
+   he->key = info;
+   return info->id;
+}
+
+static unsigned
+begin_rendering(struct zink_context *ctx)
+{
+   unsigned clear_buffers = 0;
+   ctx->gfx_pipeline_state.render_pass = NULL;
+   zink_update_vk_sample_locations(ctx);
+   zink_render_update_swapchain(ctx);
+   bool has_depth = false;
+   bool has_stencil = false;
+   if (ctx->rp_changed) {
+  /* init imageviews, base loadOp, formats */
+  for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
+ struct zink_surface *surf = zink_csurface(ctx->fb_state.cbufs[i]);
+ VkImageView iv = zink_prep_fb_attachment(ctx, surf, i);
+ if (!iv)
+/* dead swapchain */
+return 0;
+ ctx->dynamic_fb.attachments[i].imageView = iv;
+ ctx->dynamic_fb.attachments[i].loadOp = !surf || (surf->is_swapchain 
&& ctx->new_swapchain) ?
+ 
VK_ATTACHMENT_LOAD_OP_DONT_CARE :
+ VK_ATTACHMENT_LOAD_OP_LOAD;
+ ctx->gfx_pipeline_state.rendering_formats[i] = surf ? 
surf->info.format[0] : VK_FORMAT_R8G8B8A8_UNORM;
+  }
+
+  /* unset depth and stencil info: reset below */
+  ctx->dynamic_fb.info.pDepthAttachment = NULL;
+  ctx->gfx_pipeline_state.rendering_info.depthAttachmentFormat = 
VK_FORMAT_UNDEFINED;
+  ctx->dynamic_fb.info.pStencilAttachment = NULL;
+  ctx->gfx_pipeline_state.rendering_info.stencilAttachmentFormat = 
VK_FORMAT_UNDEFINED;
+
+  if (ctx->fb_state.zsbuf) {
+ struct zink_surface *surf = zink_csurface(ctx->fb_state.zsbuf);
+ has_depth = 
util_format_has_depth(util_format_description(ctx->fb_state.zsbuf->format));
+ has_stencil = 
util_format_has_stencil(util_format_description(ctx->fb_state.zsbuf->format));
+ VkImageView iv = zink_prep_fb_attachment(ctx, surf, 
ctx->fb_state.nr_cbufs);
+
+ /* depth may or may not be used but init it anyway */
+ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].imageView = iv;
+ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].imageLayout = 
zink_resource(surf->base.texture)->layout;
+ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS].loadOp = 
VK_ATTACHMENT_LOAD_OP_LOAD;
+
+ /* stencil may or may not be used but init it anyway */
+ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].imageView = iv;
+ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].imageLayout = 
zink_resource(surf->base.texture)->layout;
+ ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS+1].loadOp = 
VK_ATTACHMENT_LOAD_OP_LOAD;
+
+ if (has_depth) {
+ctx->dynamic_fb.info.pDepthAttachment = 
&ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS];
+ctx->gfx_pipeline_state.rendering_info.depthAttachmentFormat = 
surf->info.format[0];
+/* stencil info only set for clears below */
+ }
+ if (has_stencil) {
+/* must be stencil-only */
+ctx->dynamic_fb.info.pStencilAttachment = 
&ctx->dynamic_fb.attachments[PIPE_MAX_COLOR_BUFS + 1];
+ctx->gfx_pipeline_state.rendering_info.stencilAttachmentFormat = 
surf->info.fo

Mesa (main): zink: break up swapchain renderpass update to util function

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: e107fa386bdafc03944d38c7ec56edb475e3784b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e107fa386bdafc03944d38c7ec56edb475e3784b

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:18:19 2022 -0400

zink: break up swapchain renderpass update to util function

no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_render_pass.c | 46 -
 src/gallium/drivers/zink/zink_render_pass.h |  2 ++
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index f51623cf74e..16b07e261b4 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -431,26 +431,7 @@ setup_framebuffer(struct zink_context *ctx)
}
 
ctx->rp_changed = false;
-   bool has_swapchain = false;
-   for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
-  if (!ctx->fb_state.cbufs[i])
- continue;
-  struct zink_resource *res = 
zink_resource(ctx->fb_state.cbufs[i]->texture);
-  if (zink_is_swapchain(res)) {
- has_swapchain = true;
- if (zink_kopper_acquire(ctx, res, UINT64_MAX))
-zink_surface_swapchain_update(ctx, 
zink_csurface(ctx->fb_state.cbufs[i]));
-  }
-   }
-   if (has_swapchain && (ctx->swapchain_size.width || 
ctx->swapchain_size.height)) {
-  unsigned old_w = ctx->fb_state.width;
-  unsigned old_h = ctx->fb_state.height;
-  ctx->fb_state.width = ctx->swapchain_size.width;
-  ctx->fb_state.height = ctx->swapchain_size.height;
-  zink_kopper_fixup_depth_buffer(ctx);
-  zink_update_framebuffer_state(ctx, old_w, old_h);
-  ctx->swapchain_size.width = ctx->swapchain_size.height = 0;
-   }
+   zink_render_update_swapchain(ctx);
 
if (!ctx->fb_changed)
   return;
@@ -664,3 +645,28 @@ zink_init_render_pass(struct zink_context *ctx)
 equals_render_pass_state);
return !!ctx->render_pass_cache;
 }
+
+void
+zink_render_update_swapchain(struct zink_context *ctx)
+{
+   bool has_swapchain = false;
+   for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
+  if (!ctx->fb_state.cbufs[i])
+ continue;
+  struct zink_resource *res = 
zink_resource(ctx->fb_state.cbufs[i]->texture);
+  if (zink_is_swapchain(res)) {
+ has_swapchain = true;
+ if (zink_kopper_acquire(ctx, res, UINT64_MAX))
+zink_surface_swapchain_update(ctx, 
zink_csurface(ctx->fb_state.cbufs[i]));
+  }
+   }
+   if (has_swapchain && (ctx->swapchain_size.width || 
ctx->swapchain_size.height)) {
+  unsigned old_w = ctx->fb_state.width;
+  unsigned old_h = ctx->fb_state.height;
+  ctx->fb_state.width = ctx->swapchain_size.width;
+  ctx->fb_state.height = ctx->swapchain_size.height;
+  zink_kopper_fixup_depth_buffer(ctx);
+  zink_update_framebuffer_state(ctx, old_w, old_h);
+  ctx->swapchain_size.width = ctx->swapchain_size.height = 0;
+   }
+}
diff --git a/src/gallium/drivers/zink/zink_render_pass.h 
b/src/gallium/drivers/zink/zink_render_pass.h
index f98d066ea64..a7579a776f5 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -100,4 +100,6 @@ zink_render_pass_attachment_get_barrier_info(const struct 
zink_render_pass *rp,
 
 bool
 zink_init_render_pass(struct zink_context *ctx);
+void
+zink_render_update_swapchain(struct zink_context *ctx);
 #endif



Mesa (main): zink: move renderpass handling to zink_render_pass.c

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: b181080d9f5ff0a9d95e86ad7514f90b88a8d3f9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b181080d9f5ff0a9d95e86ad7514f90b88a8d3f9

Author: Mike Blumenkrantz 
Date:   Mon May  9 11:32:32 2022 -0400

zink: move renderpass handling to zink_render_pass.c

no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 432 ++--
 src/gallium/drivers/zink/zink_context.h |  20 +-
 src/gallium/drivers/zink/zink_render_pass.c | 422 ++-
 src/gallium/drivers/zink/zink_render_pass.h |   9 +
 4 files changed, 454 insertions(+), 429 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index dbe883a3c10..2ca6f6407ca 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1974,227 +1974,22 @@ zink_update_fbfetch(struct zink_context *ctx)
}
 }
 
-static size_t
-rp_state_size(const struct zink_render_pass_pipeline_state *pstate)
-{
-   return offsetof(struct zink_render_pass_pipeline_state, attachments) +
-   sizeof(pstate->attachments[0]) * pstate->num_attachments;
-}
-
-static uint32_t
-hash_rp_state(const void *key)
-{
-   const struct zink_render_pass_pipeline_state *s = key;
-   return _mesa_hash_data(key, rp_state_size(s));
-}
-
-static bool
-equals_rp_state(const void *a, const void *b)
-{
-   return !memcmp(a, b, rp_state_size(a));
-}
-
-static uint32_t
-hash_render_pass_state(const void *key)
-{
-   struct zink_render_pass_state* s = (struct zink_render_pass_state*)key;
-   return _mesa_hash_data(key, offsetof(struct zink_render_pass_state, rts) + 
sizeof(s->rts[0]) * s->num_rts);
-}
-
-static bool
-equals_render_pass_state(const void *a, const void *b)
-{
-   const struct zink_render_pass_state *s_a = a, *s_b = b;
-   if (s_a->num_rts != s_b->num_rts)
-  return false;
-   return memcmp(a, b, offsetof(struct zink_render_pass_state, rts) + 
sizeof(s_a->rts[0]) * s_a->num_rts) == 0;
-}
-
-static struct zink_render_pass *
-get_render_pass(struct zink_context *ctx)
-{
-   struct zink_screen *screen = zink_screen(ctx->base.screen);
-   const struct pipe_framebuffer_state *fb = &ctx->fb_state;
-   struct zink_render_pass_state state = {0};
-   uint32_t clears = 0;
-   state.swapchain_init = ctx->new_swapchain;
-   state.samples = fb->samples > 0;
-
-   u_foreach_bit(i, ctx->fbfetch_outputs)
-  state.rts[i].fbfetch = true;
-
-   for (int i = 0; i < fb->nr_cbufs; i++) {
-  struct pipe_surface *surf = fb->cbufs[i];
-  if (surf && !zink_use_dummy_attachments(ctx)) {
- struct zink_surface *transient = zink_transient_surface(surf);
- state.rts[i].format = zink_get_format(screen, surf->format);
- state.rts[i].samples = MAX3(transient ? transient->base.nr_samples : 
0, surf->texture->nr_samples, 1);
- state.rts[i].clear_color = zink_fb_clear_enabled(ctx, i) && 
!zink_fb_clear_first_needs_explicit(&ctx->fb_clears[i]);
- clears |= !!state.rts[i].clear_color ? PIPE_CLEAR_COLOR0 << i : 0;
- state.rts[i].swapchain = surf->texture->bind & 
PIPE_BIND_DISPLAY_TARGET;
- if (transient) {
-state.num_cresolves++;
-state.rts[i].resolve = true;
-if (!state.rts[i].clear_color)
-   state.msaa_expand_mask |= BITFIELD_BIT(i);
- }
-  } else {
- state.rts[i].format = VK_FORMAT_R8G8B8A8_UNORM;
- state.rts[i].samples = fb->samples;
-  }
-  state.num_rts++;
-   }
-   state.num_cbufs = fb->nr_cbufs;
-   assert(!state.num_cresolves || state.num_cbufs == state.num_cresolves);
-
-   if (fb->zsbuf) {
-  struct zink_resource *zsbuf = zink_resource(fb->zsbuf->texture);
-  struct zink_framebuffer_clear *fb_clear = 
&ctx->fb_clears[PIPE_MAX_COLOR_BUFS];
-  struct zink_surface *transient = zink_transient_surface(fb->zsbuf);
-  state.rts[fb->nr_cbufs].format = zsbuf->format;
-  state.rts[fb->nr_cbufs].samples = MAX3(transient ? 
transient->base.nr_samples : 0, fb->zsbuf->texture->nr_samples, 1);
-  if (transient) {
- state.num_zsresolves = 1;
- state.rts[fb->nr_cbufs].resolve = true;
-  }
-  state.rts[fb->nr_cbufs].clear_color = zink_fb_clear_enabled(ctx, 
PIPE_MAX_COLOR_BUFS) &&
-
!zink_fb_clear_first_needs_explicit(fb_clear) &&
-(zink_fb_clear_element(fb_clear, 
0)->zs.bits & PIPE_CLEAR_DEPTH);
-  state.rts[fb->nr_cbufs].clear_stencil = zink_fb_clear_enabled(ctx, 
PIPE_MAX_COLOR_BUFS) &&
-  
!zink_fb_clear_first_needs_explicit(fb_clear) &&
-  (zink_fb_clear_element(fb_clear, 
0)->zs.bits & PIPE_CLEAR_STENCIL);
-  if (state.rts[fb->nr_cbufs].clear_color)

Mesa (main): zink: lift some renderpass mechanics up a level in the api

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 91a9676a0c5d339c551836b608dc866fd3867a3c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=91a9676a0c5d339c551836b608dc866fd3867a3c

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:28:34 2022 -0400

zink: lift some renderpass mechanics up a level in the api

(should be) no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 16 ++--
 src/gallium/drivers/zink/zink_render_pass.c | 10 ++
 src/gallium/drivers/zink/zink_render_pass.h |  2 +-
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 541e7bc91c1..bdc28793902 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1999,14 +1999,26 @@ zink_update_vk_sample_locations(struct zink_context 
*ctx)
 void
 zink_batch_rp(struct zink_context *ctx)
 {
+   if (ctx->batch.in_rp)
+  return;
+   unsigned clear_buffers;
+   clear_buffers = zink_begin_render_pass(ctx);
if (!ctx->batch.in_rp)
-  zink_begin_render_pass(ctx);
+  return; //dead swapchain
+   if (ctx->render_condition.query)
+  zink_start_conditional_render(ctx);
+   zink_clear_framebuffer(ctx, clear_buffers);
 }
 
 void
 zink_batch_no_rp(struct zink_context *ctx)
 {
-   zink_end_render_pass(ctx);
+   if (!ctx->batch.in_rp)
+  return;
+   if (ctx->render_condition.query)
+  zink_stop_conditional_render(ctx);
+   if (ctx->gfx_pipeline_state.render_pass)
+  zink_end_render_pass(ctx);
assert(!ctx->batch.in_rp);
 }
 
diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index f4331b1aafa..6e330cb59c8 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -591,7 +591,7 @@ begin_render_pass(struct zink_context *ctx)
return clear_buffers;
 }
 
-void
+unsigned
 zink_begin_render_pass(struct zink_context *ctx)
 {
setup_framebuffer(ctx);
@@ -630,19 +630,13 @@ zink_begin_render_pass(struct zink_context *ctx)
   ctx->gfx_pipeline_state.render_pass = rp;
}
assert(ctx->gfx_pipeline_state.render_pass);
-   unsigned clear_buffers = begin_render_pass(ctx);
-
-   if (ctx->render_condition.query)
-  zink_start_conditional_render(ctx);
-   zink_clear_framebuffer(ctx, clear_buffers);
+   return begin_render_pass(ctx);
 }
 
 void
 zink_end_render_pass(struct zink_context *ctx)
 {
if (ctx->batch.in_rp) {
-  if (ctx->render_condition.query)
- zink_stop_conditional_render(ctx);
   VKCTX(CmdEndRenderPass)(ctx->batch.state->cmdbuf);
   for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++) {
  struct zink_ctx_surface *csurf = (struct 
zink_ctx_surface*)ctx->fb_state.cbufs[i];
diff --git a/src/gallium/drivers/zink/zink_render_pass.h 
b/src/gallium/drivers/zink/zink_render_pass.h
index 65499ff29c3..2cf90c0de3a 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -89,7 +89,7 @@ zink_destroy_render_pass(struct zink_screen *screen,
  struct zink_render_pass *rp);
 
 
-void
+unsigned
 zink_begin_render_pass(struct zink_context *ctx);
 void
 zink_end_render_pass(struct zink_context *ctx);



Mesa (main): zink: break out sample location updating to separate function

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 190ccf3324c97406de122f79cf62ff5477b12a64
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=190ccf3324c97406de122f79cf62ff5477b12a64

Author: Mike Blumenkrantz 
Date:   Tue May 10 12:17:37 2022 -0400

zink: break out sample location updating to separate function

no functional changes

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_context.c | 22 ++
 src/gallium/drivers/zink/zink_context.h |  2 ++
 src/gallium/drivers/zink/zink_render_pass.c | 18 +-
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index e92de9f476c..5230be4cb6b 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1974,6 +1974,28 @@ zink_update_fbfetch(struct zink_context *ctx)
}
 }
 
+void
+zink_update_vk_sample_locations(struct zink_context *ctx)
+{
+   if (ctx->gfx_pipeline_state.sample_locations_enabled && 
ctx->sample_locations_changed) {
+  unsigned samples = ctx->gfx_pipeline_state.rast_samples + 1;
+  unsigned idx = util_logbase2_ceil(MAX2(samples, 1));
+  VkExtent2D grid_size = 
zink_screen(ctx->base.screen)->maxSampleLocationGridSize[idx];
+ 
+  for (unsigned pixel = 0; pixel < grid_size.width * grid_size.height; 
pixel++) {
+ for (unsigned sample = 0; sample < samples; sample++) {
+unsigned pixel_x = pixel % grid_size.width;
+unsigned pixel_y = pixel / grid_size.width;
+unsigned wi = pixel * samples + sample;
+unsigned ri = (pixel_y * grid_size.width + pixel_x % 
grid_size.width);
+ri = ri * samples + sample;
+ctx->vk_sample_locations[wi].x = (ctx->sample_locations[ri] & 0xf) 
/ 16.0f;
+ctx->vk_sample_locations[wi].y = (16 - (ctx->sample_locations[ri] 
>> 4)) / 16.0f;
+ }
+  }
+   }
+}
+
 void
 zink_batch_rp(struct zink_context *ctx)
 {
diff --git a/src/gallium/drivers/zink/zink_context.h 
b/src/gallium/drivers/zink/zink_context.h
index 76394ff141b..fcf3d036933 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -430,6 +430,8 @@ zink_batch_no_rp(struct zink_context *ctx);
 
 VkImageView
 zink_prep_fb_attachment(struct zink_context *ctx, struct zink_surface *surf, 
unsigned i);
+void
+zink_update_vk_sample_locations(struct zink_context *ctx);
 
 static inline VkPipelineStageFlags
 zink_pipeline_flags_from_pipe_stage(enum pipe_shader_type pstage)
diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index bb5b5ef8ec1..f51623cf74e 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -417,23 +417,7 @@ setup_framebuffer(struct zink_context *ctx)
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_render_pass *rp = ctx->gfx_pipeline_state.render_pass;
 
-   if (ctx->gfx_pipeline_state.sample_locations_enabled && 
ctx->sample_locations_changed) {
-  unsigned samples = ctx->gfx_pipeline_state.rast_samples + 1;
-  unsigned idx = util_logbase2_ceil(MAX2(samples, 1));
-  VkExtent2D grid_size = screen->maxSampleLocationGridSize[idx];
- 
-  for (unsigned pixel = 0; pixel < grid_size.width * grid_size.height; 
pixel++) {
- for (unsigned sample = 0; sample < samples; sample++) {
-unsigned pixel_x = pixel % grid_size.width;
-unsigned pixel_y = pixel / grid_size.width;
-unsigned wi = pixel * samples + sample;
-unsigned ri = (pixel_y * grid_size.width + pixel_x % 
grid_size.width);
-ri = ri * samples + sample;
-ctx->vk_sample_locations[wi].x = (ctx->sample_locations[ri] & 0xf) 
/ 16.0f;
-ctx->vk_sample_locations[wi].y = (16 - (ctx->sample_locations[ri] 
>> 4)) / 16.0f;
- }
-  }
-   }
+   zink_update_vk_sample_locations(ctx);
 
if (rp)
   ctx->rp_changed |= ctx->rp_clears_enabled != rp->state.clears;



Mesa (main): zink: remove fb rebind check during renderpass begin

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 37f9b8ef9b65aa9cb48120711694c3a93a25f693
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=37f9b8ef9b65aa9cb48120711694c3a93a25f693

Author: Mike Blumenkrantz 
Date:   Mon May  9 12:24:04 2022 -0400

zink: remove fb rebind check during renderpass begin

Reviewed-by: Dave Airlie 
Part-of: 

---

 src/gallium/drivers/zink/zink_render_pass.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_render_pass.c 
b/src/gallium/drivers/zink/zink_render_pass.c
index e01314402e0..51152d18a28 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -484,10 +484,6 @@ prep_fb_attachments(struct zink_context *ctx, VkImageView 
*att)
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
   struct zink_surface *surf = zink_csurface(ctx->fb_state.cbufs[i]);
   struct zink_surface *transient = 
zink_transient_surface(ctx->fb_state.cbufs[i]);
-  if (surf && zink_resource(surf->base.texture)->obj != surf->obj) {
- zink_resource_rebind(ctx, zink_resource(surf->base.texture));
- surf = zink_csurface(ctx->fb_state.cbufs[i]);
-  }
   if (transient) {
  att[i] = zink_prep_fb_attachment(ctx, transient, i);
  att[i + cresolve_offset] = zink_prep_fb_attachment(ctx, surf, i);



Mesa: tag mesa-22.0.4: mesa-22.0.4

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: refs/tags/mesa-22.0.4
Tag:fbff8cd57d4767e938aaa1412609285c9e34e43c
URL:
http://cgit.freedesktop.org/mesa/mesa/tag/?id=fbff8cd57d4767e938aaa1412609285c9e34e43c

Tagger: Dylan Baker 
Date:   Thu May 19 12:11:57 2022 -0700

mesa-22.0.4


Mesa (main): panfrost: Increase the limit for blend shader variants

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: f1f39fa645c59617546522d99f8bd85e70b5655e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1f39fa645c59617546522d99f8bd85e70b5655e

Author: Icecream95 
Date:   Thu May  5 13:04:37 2022 +1200

panfrost: Increase the limit for blend shader variants

Qt uses blend constants to set text colour, this will allow more
colours onscreen before thrashing happens.

Part-of: 

---

 src/panfrost/lib/pan_blend.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/panfrost/lib/pan_blend.h b/src/panfrost/lib/pan_blend.h
index f2ec30404a8..2dec9525c4a 100644
--- a/src/panfrost/lib/pan_blend.h
+++ b/src/panfrost/lib/pan_blend.h
@@ -90,7 +90,7 @@ struct pan_blend_shader_variant {
 unsigned work_reg_count;
 };
 
-#define PAN_BLEND_SHADER_MAX_VARIANTS 16
+#define PAN_BLEND_SHADER_MAX_VARIANTS 32
 
 struct pan_blend_shader {
 struct pan_blend_shader_key key;



Mesa (main): panfrost: Copy blend constant into variant even when reusing it

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 80404c8b640bdc24274b67561842ebf684e741f5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=80404c8b640bdc24274b67561842ebf684e741f5

Author: Icecream95 
Date:   Thu May  5 12:57:40 2022 +1200

panfrost: Copy blend constant into variant even when reusing it

Otherwise future lookups will match searches for the old constant.

Fixes: bbff09b9521 ("panfrost: Move the blend shader cache at the device level")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6355
Part-of: 

---

 src/panfrost/lib/pan_blend.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/panfrost/lib/pan_blend.c b/src/panfrost/lib/pan_blend.c
index 8c212a8457d..0ffcd0162db 100644
--- a/src/panfrost/lib/pan_blend.c
+++ b/src/panfrost/lib/pan_blend.c
@@ -802,7 +802,6 @@ GENX(pan_blend_get_shader_locked)(const struct 
panfrost_device *dev,
 
 if (shader->nvariants < PAN_BLEND_SHADER_MAX_VARIANTS) {
 variant = rzalloc(shader, struct pan_blend_shader_variant);
-memcpy(variant->constants, state->constants, 
sizeof(variant->constants));
 util_dynarray_init(&variant->binary, variant);
 list_add(&variant->node, &shader->variants);
 shader->nvariants++;
@@ -813,6 +812,8 @@ GENX(pan_blend_get_shader_locked)(const struct 
panfrost_device *dev,
 util_dynarray_clear(&variant->binary);
 }
 
+memcpy(variant->constants, state->constants, 
sizeof(variant->constants));
+
 nir_shader *nir =
 GENX(pan_blend_create_shader)(dev, state, src0_type, 
src1_type, rt);
 



Mesa (main): panfrost: Move patched_s out of the pan_blitter_views struct

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: 2f2ddfa0acaa5fbe14f1458abc49328b4ef610de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f2ddfa0acaa5fbe14f1458abc49328b4ef610de

Author: Icecream95 
Date:   Thu May  5 13:06:28 2022 +1200

panfrost: Move patched_s out of the pan_blitter_views struct

The struct is returned from a function, so in debug builds the address
may change after returning, and pointers to patched_s will be broken.

Pass the pointer to the patched stencil view as a parameter to
pan_preload_get_views to avoid this.

Part-of: 

---

 src/panfrost/lib/pan_blitter.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c
index 4eb761342ff..72261fd2c71 100644
--- a/src/panfrost/lib/pan_blitter.c
+++ b/src/panfrost/lib/pan_blitter.c
@@ -187,11 +187,6 @@ struct pan_blitter_views {
 const struct pan_image_view *dst_z;
 const struct pan_image_view *src_s;
 const struct pan_image_view *dst_s;
-
-/* Image view used when patching stencil formats for combined
- * depth/stencil preloads.
- */
-struct pan_image_view patched_s;
 };
 
 static bool
@@ -802,7 +797,7 @@ pan_blit_get_rsd(struct panfrost_device *dev,
 #endif
 
 static struct pan_blitter_views
-pan_preload_get_views(const struct pan_fb_info *fb, bool zs)
+pan_preload_get_views(const struct pan_fb_info *fb, bool zs, struct 
pan_image_view *patched_s)
 {
 struct pan_blitter_views views = { 0 };
 
@@ -821,9 +816,9 @@ pan_preload_get_views(const struct pan_fb_info *fb, bool zs)
 }
 
 if (fmt != view->format) {
-views.patched_s = *view;
-views.patched_s.format = fmt;
-views.src_s = views.dst_s = &views.patched_s;
+*patched_s = *view;
+patched_s->format = fmt;
+views.src_s = views.dst_s = patched_s;
 } else {
 views.src_s = views.dst_s = view;
 }
@@ -1086,7 +1081,13 @@ pan_preload_emit_dcd(struct pan_pool *pool,
  * for colour and Z/S), allowing us to suppress unnecessary writeback
  */
 UNUSED bool clean_fragment_write = !always_write;
-struct pan_blitter_views views = pan_preload_get_views(fb, zs);
+
+/* Image view used when patching stencil formats for combined
+ * depth/stencil preloads.
+ */
+struct pan_image_view patched_s;
+
+struct pan_blitter_views views = pan_preload_get_views(fb, zs, 
&patched_s);
 
 #if PAN_ARCH <= 7
 pan_pack(out, DRAW, cfg) {



Mesa (main): turnip: fix tu6_pack_border_color for z24

2022-05-20 Thread GitLab Mirror
Module: Mesa
Branch: main
Commit: e8eb6d13a5d089be0c637407e4d10db19620c2ad
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8eb6d13a5d089be0c637407e4d10db19620c2ad

Author: Chia-I Wu 
Date:   Tue May 17 16:30:34 2022 -0700

turnip: fix tu6_pack_border_color for z24

The value should be at the bottom 24 bits, not at the top.

dEQP-VK.pipeline.sampler.* still passes.  This fixes most of
dEQP-GLES31.functional.texture_border_clamp.formats.*depth* on angle.

Part-of: 

---

 src/freedreno/vulkan/tu_util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/freedreno/vulkan/tu_util.h b/src/freedreno/vulkan/tu_util.h
index eb62c0be74c..58a35da590f 100644
--- a/src/freedreno/vulkan/tu_util.h
+++ b/src/freedreno/vulkan/tu_util.h
@@ -320,7 +320,7 @@ tu6_pack_border_color(struct bcolor_entry *bcolor, const 
VkClearColorValue *val,
PACK_F(ui8, r8g8b8a8_unorm);
PACK_F(si8, r8g8b8a8_snorm);
PACK_F(rgb10a2, r10g10b10a2_unorm);
-   util_format_x8z24_unorm_pack_z_float((uint8_t*) &bcolor->z24,
+   util_format_z24x8_unorm_pack_z_float((uint8_t*) &bcolor->z24,
 0, val->float32, 0, 1, 1);
PACK_F(srgb, r16g16b16a16_float); /* TODO: clamp? */
 #undef PACK_F