From 0b278a7773d8961348126e44c699084914082909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Thu, 13 Sep 2018 11:25:57 +0200 Subject: [PATCH] vkd3d-shader: Implement texel offsets for ld 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 | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 10134bf9..f0e2491a 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5262,6 +5262,17 @@ static void vkd3d_dxbc_compiler_prepare_sampled_image(struct vkd3d_dxbc_compiler vkd3d_dxbc_compiler_get_register_id(compiler, sampler_reg), depth_comparison); } +static uint32_t vkd3d_dxbc_compiler_emit_texel_offset(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction, + const struct vkd3d_spirv_resource_type *resource_type_info) +{ + const struct vkd3d_shader_texel_offset *offset = &instruction->texel_offset; + unsigned int component_count = resource_type_info->offset_component_count; + int32_t data[4] = {offset->u, offset->v, offset->w, 0}; + return vkd3d_dxbc_compiler_get_constant(compiler, + VKD3D_TYPE_INT, component_count, (const uint32_t *)data); +} + static void vkd3d_dxbc_compiler_emit_ld(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { @@ -5275,9 +5286,6 @@ static void vkd3d_dxbc_compiler_emit_ld(struct vkd3d_dxbc_compiler *compiler, uint32_t image_operands[2]; DWORD coordinate_mask; - if (vkd3d_shader_instruction_has_texel_offset(instruction)) - FIXME("Texel offset not supported.\n"); - /* OpImageFetch must be used with a sampled image. */ vkd3d_dxbc_compiler_prepare_dummy_sampled_image(compiler, &image, &src[1].reg); image_id = vkd3d_spirv_build_op_image(builder, image.image_type_id, image.sampled_image_id); @@ -5291,6 +5299,12 @@ static void vkd3d_dxbc_compiler_emit_ld(struct vkd3d_dxbc_compiler *compiler, image_operands[image_operand_count++] = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_3); } + if (vkd3d_shader_instruction_has_texel_offset(instruction)) + { + operands_mask |= SpvImageOperandsConstOffsetMask; + image_operands[image_operand_count++] = vkd3d_dxbc_compiler_emit_texel_offset(compiler, + instruction, image.resource_type_info); + } val_id = vkd3d_spirv_build_op_image_fetch(builder, type_id, image_id, coordinate_id, operands_mask, image_operands, image_operand_count); @@ -5386,17 +5400,6 @@ static void vkd3d_dxbc_compiler_emit_sample_c(struct vkd3d_dxbc_compiler *compil dst, val_id, image.sampled_type, src[1].swizzle); } -static uint32_t vkd3d_dxbc_compiler_emit_texel_offset(struct vkd3d_dxbc_compiler *compiler, - const struct vkd3d_shader_instruction *instruction, - const struct vkd3d_spirv_resource_type *resource_type_info) -{ - const struct vkd3d_shader_texel_offset *offset = &instruction->texel_offset; - unsigned int component_count = resource_type_info->offset_component_count; - int32_t data[4] = {offset->u, offset->v, offset->w, 0}; - return vkd3d_dxbc_compiler_get_constant(compiler, - VKD3D_TYPE_INT, component_count, (const uint32_t *)data); -} - static void vkd3d_dxbc_compiler_emit_gather4(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) {