From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index a734539b7b88..accdd756e1ac 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -7605,6 +7605,43 @@ static void vkd3d_dxbc_compiler_emit_sample_info(struct vkd3d_dxbc_compiler *com vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); }
+static void vkd3d_dxbc_compiler_emit_interpolate(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + const struct vkd3d_shader_dst_param *dst = instruction->dst; + const struct vkd3d_shader_src_param *src = instruction->src; + const struct vkd3d_shader_register *input = &src[0].reg; + uint32_t instr_set_id, type_id, val_id, src_ids[2]; + struct vkd3d_shader_register_info register_info; + + if (!vkd3d_dxbc_compiler_get_register_info(compiler, input, ®ister_info)) + return; + + if (register_info.storage_class != SpvStorageClassInput) + { + FIXME("Not supported for storage class %#x.\n", register_info.storage_class); + return; + } + + vkd3d_spirv_enable_capability(builder, SpvCapabilityInterpolationFunction); + + src_ids[0] = register_info.id; + src_ids[1] = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[1], VKD3DSP_WRITEMASK_0); + + type_id = vkd3d_spirv_get_type_id(builder, + VKD3D_TYPE_FLOAT, vkd3d_write_mask_component_count(register_info.write_mask)); + + instr_set_id = vkd3d_spirv_get_glsl_std450_instr_set(builder); + val_id = vkd3d_spirv_build_op_ext_inst(builder, type_id, + instr_set_id, GLSLstd450InterpolateAtSample, src_ids, 2); + + val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler, + val_id, register_info.write_mask, VKD3D_TYPE_FLOAT, src[0].swizzle, dst->write_mask); + + vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); +} + /* From the Vulkan spec: * * "Scope for execution must be limited to: * Workgroup * Subgroup" @@ -8011,6 +8048,9 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_SAMPLE_INFO: vkd3d_dxbc_compiler_emit_sample_info(compiler, instruction); break; + case VKD3DSIH_EVAL_SAMPLE_INDEX: + vkd3d_dxbc_compiler_emit_interpolate(compiler, instruction); + break; case VKD3DSIH_SYNC: vkd3d_dxbc_compiler_emit_sync(compiler, instruction); break;