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.
From: Zebediah Figura zfigura@codeweavers.com
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,
Unfortunate. How does this interact with the target environment? I.e., does this patch do the right thing when VKD3D_SHADER_SPIRV_ENVIRONMENT_OPENGL_4_5 is specified?
Unfortunate. How does this interact with the target environment? I.e., does this patch do the right thing when VKD3D_SHADER_SPIRV_ENVIRONMENT_OPENGL_4_5 is specified?
The GL spec (and the ARB_gl_spirv spec), as far as I can find, is annoyingly vague about how GLSL sampler types correspond to GL texture bindings, and doesn't seem to specify at all how SPIR-V image types correspond to GL texture bindings (or, for that matter, how GLSL sampler types correspond to SPIR-V image types).
I can only assume that sampler2D <-> SPIRV MS = 0 <-> GL_TEXTURE_2D, and sampler2DMS <-> SPIRV MS = 1 <-> GL_TEXTURE_2D_MULTISAMPLE. That seems like the only reasonable mapping, and it'd be consistent with how GLSL maps to GL when SPIR-V isn't involved. In that case this patch should do the right thing.
This merge request was approved by Henri Verbeet.