From 3957242ea72ebf6ba7fc47ef942161b804c0fb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Thu, 18 Oct 2018 14:59:46 +0200 Subject: [PATCH] vkd3d-shader: Translate ld2dms instructions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/spirv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index ac95bd3b..2f72c5c0 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5423,6 +5423,9 @@ static void vkd3d_dxbc_compiler_emit_ld(struct vkd3d_dxbc_compiler *compiler, struct vkd3d_shader_image image; uint32_t image_operands[2]; DWORD coordinate_mask; + bool multisample; + + multisample = instruction->handler_idx == VKD3DSIH_LD2DMS; /* OpImageFetch must be used with a sampled image. */ vkd3d_dxbc_compiler_prepare_dummy_sampled_image(compiler, &image, &src[1].reg); @@ -5431,7 +5434,7 @@ static void vkd3d_dxbc_compiler_emit_ld(struct vkd3d_dxbc_compiler *compiler, type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE); coordinate_mask = (1u << image.resource_type_info->coordinate_component_count) - 1; coordinate_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], coordinate_mask); - if (image.resource_type_info->resource_type != VKD3D_SHADER_RESOURCE_BUFFER) + if (image.resource_type_info->resource_type != VKD3D_SHADER_RESOURCE_BUFFER && !multisample) { operands_mask |= SpvImageOperandsLodMask; image_operands[image_operand_count++] = vkd3d_dxbc_compiler_emit_load_src(compiler, @@ -5443,6 +5446,13 @@ static void vkd3d_dxbc_compiler_emit_ld(struct vkd3d_dxbc_compiler *compiler, image_operands[image_operand_count++] = vkd3d_dxbc_compiler_emit_texel_offset(compiler, instruction, image.resource_type_info); } + if (multisample) + { + operands_mask |= SpvImageOperandsSampleMask; + image_operands[image_operand_count++] = vkd3d_dxbc_compiler_emit_load_src(compiler, + &src[2], VKD3DSP_WRITEMASK_0); + } + assert(image_operand_count <= ARRAY_SIZE(image_operands)); val_id = vkd3d_spirv_build_op_image_fetch(builder, type_id, image_id, coordinate_id, operands_mask, image_operands, image_operand_count); @@ -6490,6 +6500,7 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler case VKD3DSIH_DSY_FINE: vkd3d_dxbc_compiler_emit_deriv_instruction(compiler, instruction); break; + case VKD3DSIH_LD2DMS: case VKD3DSIH_LD: vkd3d_dxbc_compiler_emit_ld(compiler, instruction); break;