Module: vkd3d
Branch: master
Commit: d8ef0c69a817d059b1d4fc62520131eed80aba29
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/d8ef0c69a817d059b1d4fc6252013…
Author: Zebediah Figura <zfigura(a)codeweavers.com>
Date: Fri Apr 14 14:37:18 2023 -0500
vkd3d-shader/spirv: Do not declare resources as multisampled if the sample count is 1.
It is illegal to match a SPIR-V multisampled resource to a Vulkan resource which
is not multisampled. Vulkan considers a resource to be multisampled if its
sample count is greater than 1 (and SPIR-V does not care about the sample count).
This fixes validation errors in the case where the sample count does actually
match the resource. In order to provide correct behaviour when there is a
mismatch, or when the sample count is missing, we will need yet another
additional interface. In the absence of that it seems best to provide a best
guess.
This fixes a validation error with the not-yet-committed merge request 135, when
the d3d11 runner is run through Wine with the Vulkan backend.
---
libs/vkd3d-shader/spirv.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 73510f8b..ec4e1d1d 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -6039,6 +6039,7 @@ static void spirv_compiler_emit_dcl_resource(struct spirv_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
const struct vkd3d_shader_semantic *semantic = &instruction->declaration.semantic;
+ enum vkd3d_shader_resource_type resource_type = semantic->resource_type;
uint32_t flags = instruction->flags;
/* We don't distinguish between APPEND and COUNTER UAVs. */
@@ -6046,8 +6047,13 @@ static void spirv_compiler_emit_dcl_resource(struct spirv_compiler *compiler,
if (flags)
FIXME("Unhandled UAV flags %#x.\n", flags);
+ if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMS && semantic->sample_count == 1)
+ resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2D;
+ else if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY && semantic->sample_count == 1)
+ resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY;
+
spirv_compiler_emit_resource_declaration(compiler, &semantic->resource,
- semantic->resource_type, semantic->resource_data_type[0], 0, false);
+ resource_type, semantic->resource_data_type[0], 0, false);
}
static void spirv_compiler_emit_dcl_resource_raw(struct spirv_compiler *compiler,
@@ -8046,7 +8052,7 @@ static void spirv_compiler_emit_ld(struct spirv_compiler *compiler,
image_operands[image_operand_count++] = spirv_compiler_emit_texel_offset(compiler,
instruction, image.resource_type_info);
}
- if (multisample)
+ if (multisample && image.resource_type_info->ms)
{
operands_mask |= SpvImageOperandsSampleMask;
image_operands[image_operand_count++] = spirv_compiler_emit_load_src(compiler,