From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 2 ++ libs/vkd3d-shader/spirv.c | 24 ++++++++++++++++++------ libs/vkd3d-shader/trace.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 4 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 7cc11e7586ac..996a7e544c1e 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -296,6 +296,7 @@ enum vkd3d_sm4_opcode VKD3D_SM5_OP_IMM_ATOMIC_UMIN = 0xbd, VKD3D_SM5_OP_SYNC = 0xbe, VKD3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc, + VKD3D_SM5_OP_EVAL_CENTROID = 0xcd, VKD3D_SM5_OP_DCL_GS_INSTANCES = 0xce, };
@@ -1108,6 +1109,7 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] = {VKD3D_SM5_OP_SYNC, VKD3DSIH_SYNC, "", "", shader_sm5_read_sync}, {VKD3D_SM5_OP_EVAL_SAMPLE_INDEX, VKD3DSIH_EVAL_SAMPLE_INDEX, "f", "fi"}, + {VKD3D_SM5_OP_EVAL_CENTROID, VKD3DSIH_EVAL_CENTROID, "f", "f"}, {VKD3D_SM5_OP_DCL_GS_INSTANCES, VKD3DSIH_DCL_GS_INSTANCES, "", "", shader_sm4_read_declaration_count}, }; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index accdd756e1ac..e13d7301c0a4 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -7605,7 +7605,7 @@ 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, +static void vkd3d_dxbc_compiler_emit_eval_attrib(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; @@ -7614,6 +7614,8 @@ static void vkd3d_dxbc_compiler_emit_interpolate(struct vkd3d_dxbc_compiler *com 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; + unsigned int src_count = 0; + enum GLSLstd450 op;
if (!vkd3d_dxbc_compiler_get_register_info(compiler, input, ®ister_info)) return; @@ -7626,15 +7628,24 @@ static void vkd3d_dxbc_compiler_emit_interpolate(struct vkd3d_dxbc_compiler *com
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); + src_ids[src_count++] = register_info.id; + + if (instruction->handler_idx == VKD3DSIH_EVAL_CENTROID) + { + op = GLSLstd450InterpolateAtCentroid; + } + else + { + assert(instruction->handler_idx == VKD3DSIH_EVAL_SAMPLE_INDEX); + op = GLSLstd450InterpolateAtSample; + src_ids[src_count++] = 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_spirv_build_op_ext_inst(builder, type_id, instr_set_id, op, src_ids, src_count);
val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler, val_id, register_info.write_mask, VKD3D_TYPE_FLOAT, src[0].swizzle, dst->write_mask); @@ -8048,8 +8059,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_CENTROID: case VKD3DSIH_EVAL_SAMPLE_INDEX: - vkd3d_dxbc_compiler_emit_interpolate(compiler, instruction); + vkd3d_dxbc_compiler_emit_eval_attrib(compiler, instruction); break; case VKD3DSIH_SYNC: vkd3d_dxbc_compiler_emit_sync(compiler, instruction); diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index bb0e6ad5a3d0..13fb117b5360 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -130,6 +130,7 @@ static const char * const shader_opcode_names[] = /* VKD3DSIH_ENDREP */ "endrep", /* VKD3DSIH_ENDSWITCH */ "endswitch", /* VKD3DSIH_EQ */ "eq", + /* VKD3DSIH_EVAL_CENTROID */ "eval_centroid", /* VKD3DSIH_EVAL_SAMPLE_INDEX */ "eval_sample_index", /* VKD3DSIH_EXP */ "exp", /* VKD3DSIH_EXPP */ "expp", diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index a6860969c068..fba493e3b563 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -156,6 +156,7 @@ enum VKD3D_SHADER_INSTRUCTION_HANDLER VKD3DSIH_ENDREP, VKD3DSIH_ENDSWITCH, VKD3DSIH_EQ, + VKD3DSIH_EVAL_CENTROID, VKD3DSIH_EVAL_SAMPLE_INDEX, VKD3DSIH_EXP, VKD3DSIH_EXPP,