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.
This commit is contained in:
Zebediah Figura 2023-04-14 14:37:18 -05:00 committed by Alexandre Julliard
parent dfe923ea1d
commit d8ef0c69a8
Notes: Alexandre Julliard 2023-04-19 22:10:46 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/160

View File

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