From 14dd2026f6ef554c066c6e3ea173c32ab3dcff50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 11 Apr 2017 13:30:34 +0200 Subject: [PATCH] wined3d: Implement SM5 gather4_po instruction. 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 --- dlls/wined3d/arb_program_shader.c | 1 + dlls/wined3d/glsl_shader.c | 26 +++++++++++++++++--------- dlls/wined3d/shader.c | 6 ++++++ dlls/wined3d/shader_sm4.c | 2 ++ dlls/wined3d/wined3d_private.h | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 446d64935a3..a6819973ad0 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -5125,6 +5125,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_FTOU */ NULL, /* WINED3DSIH_GATHER4 */ NULL, /* WINED3DSIH_GATHER4_C */ NULL, + /* WINED3DSIH_GATHER4_PO */ NULL, /* WINED3DSIH_GE */ NULL, /* WINED3DSIH_HS_CONTROL_POINT_PHASE */ NULL, /* WINED3DSIH_HS_DECLS */ NULL, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index fada7465ef1..b5df3a39019 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5926,13 +5926,13 @@ static void shader_glsl_sample_c(const struct wined3d_shader_instruction *ins) static void shader_glsl_gather4(const struct wined3d_shader_instruction *ins) { + unsigned int resource_param_idx, resource_idx, sampler_idx, sampler_bind_idx, component_idx; const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps; const char *prefix = shader_glsl_get_prefix(reg_maps->shader_version.type); - unsigned int resource_idx, sampler_idx, sampler_bind_idx, component_idx; + struct glsl_src_param coord_param, compare_param, offset_param; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; const struct wined3d_shader_resource_info *resource_info; struct wined3d_string_buffer *buffer = ins->ctx->buffer; - struct glsl_src_param coord_param, compare_param; unsigned int coord_size, offset_size; char dst_swizzle[6]; BOOL has_offset; @@ -5943,14 +5943,16 @@ static void shader_glsl_gather4(const struct wined3d_shader_instruction *ins) return; } - has_offset = wined3d_shader_instruction_has_texel_offset(ins); + has_offset = ins->handler_idx == WINED3DSIH_GATHER4_PO + || wined3d_shader_instruction_has_texel_offset(ins); - resource_idx = ins->src[1].reg.idx[0].offset; - sampler_idx = ins->src[2].reg.idx[0].offset; - component_idx = shader_glsl_swizzle_get_component(ins->src[2].swizzle, 0); + resource_param_idx = ins->handler_idx == WINED3DSIH_GATHER4_PO ? 2 : 1; + resource_idx = ins->src[resource_param_idx].reg.idx[0].offset; + sampler_idx = ins->src[resource_param_idx + 1].reg.idx[0].offset; + component_idx = shader_glsl_swizzle_get_component(ins->src[resource_param_idx + 1].swizzle, 0); sampler_bind_idx = shader_glsl_find_sampler(®_maps->sampler_map, resource_idx, sampler_idx); - if (!(resource_info = shader_glsl_get_resource_info(ins, &ins->src[1].reg))) + if (!(resource_info = shader_glsl_get_resource_info(ins, &ins->src[resource_param_idx].reg))) return; if (resource_info->type >= ARRAY_SIZE(resource_type_info)) @@ -5960,7 +5962,7 @@ static void shader_glsl_gather4(const struct wined3d_shader_instruction *ins) } shader_glsl_get_coord_size(resource_info->type, &coord_size, &offset_size); - shader_glsl_swizzle_to_str(ins->src[1].swizzle, FALSE, ins->dst[0].write_mask, dst_swizzle); + shader_glsl_swizzle_to_str(ins->src[resource_param_idx].swizzle, FALSE, ins->dst[0].write_mask, dst_swizzle); shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], resource_info->data_type); shader_glsl_add_src_param(ins, &ins->src[0], (1u << coord_size) - 1, &coord_param); @@ -5972,7 +5974,12 @@ static void shader_glsl_gather4(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[3], WINED3DSP_WRITEMASK_0, &compare_param); shader_addline(buffer, ", %s", compare_param.param_str); } - if (has_offset) + if (ins->handler_idx == WINED3DSIH_GATHER4_PO) + { + shader_glsl_add_src_param(ins, &ins->src[1], (1u << offset_size) - 1, &offset_param); + shader_addline(buffer, ", %s", offset_param.param_str); + } + else if (has_offset) { int offset_immdata[4] = {ins->texel_offset.u, ins->texel_offset.v, ins->texel_offset.w}; shader_addline(buffer, ", "); @@ -10049,6 +10056,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_FTOU */ shader_glsl_to_uint, /* WINED3DSIH_GATHER4 */ shader_glsl_gather4, /* WINED3DSIH_GATHER4_C */ shader_glsl_gather4, + /* WINED3DSIH_GATHER4_PO */ shader_glsl_gather4, /* WINED3DSIH_GE */ shader_glsl_relop, /* WINED3DSIH_HS_CONTROL_POINT_PHASE */ NULL, /* WINED3DSIH_HS_DECLS */ shader_glsl_nop, diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index acf914bd408..e62056e73f5 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -145,6 +145,7 @@ static const char * const shader_opcode_names[] = /* WINED3DSIH_FTOU */ "ftou", /* WINED3DSIH_GATHER4 */ "gather4", /* WINED3DSIH_GATHER4_C */ "gather4_c", + /* WINED3DSIH_GATHER4_PO */ "gather4_po", /* WINED3DSIH_GE */ "ge", /* WINED3DSIH_HS_CONTROL_POINT_PHASE */ "hs_control_point_phase", /* WINED3DSIH_HS_DECLS */ "hs_decls", @@ -1460,6 +1461,11 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st shader_record_sample(reg_maps, ins.src[1].reg.idx[0].offset, ins.src[2].reg.idx[0].offset, reg_maps->sampler_map.count); } + else if (ins.handler_idx == WINED3DSIH_GATHER4_PO) + { + shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset, + ins.src[3].reg.idx[0].offset, reg_maps->sampler_map.count); + } else if (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE) { shader_record_sample(reg_maps, ins.src[0].reg.idx[0].offset, diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index 3e8b1f21e8c..fbc2f5115bc 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -232,6 +232,7 @@ enum wined3d_sm4_opcode WINED3D_SM5_OP_DERIV_RTY_COARSE = 0x7c, WINED3D_SM5_OP_DERIV_RTY_FINE = 0x7d, WINED3D_SM5_OP_GATHER4_C = 0x7e, + WINED3D_SM5_OP_GATHER4_PO = 0x7f, WINED3D_SM5_OP_RCP = 0x81, WINED3D_SM5_OP_F32TOF16 = 0x82, WINED3D_SM5_OP_F16TOF32 = 0x83, @@ -967,6 +968,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] = {WINED3D_SM5_OP_DERIV_RTY_COARSE, WINED3DSIH_DSY_COARSE, "f", "f"}, {WINED3D_SM5_OP_DERIV_RTY_FINE, WINED3DSIH_DSY_FINE, "f", "f"}, {WINED3D_SM5_OP_GATHER4_C, WINED3DSIH_GATHER4_C, "f", "fRSf"}, + {WINED3D_SM5_OP_GATHER4_PO, WINED3DSIH_GATHER4_PO, "f", "fiRS"}, {WINED3D_SM5_OP_RCP, WINED3DSIH_RCP, "f", "f"}, {WINED3D_SM5_OP_F32TOF16, WINED3DSIH_F32TOF16, "u", "f"}, {WINED3D_SM5_OP_F16TOF32, WINED3DSIH_F16TOF32, "f", "u"}, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9f981365354..676e9822e62 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -761,6 +761,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_FTOU, WINED3DSIH_GATHER4, WINED3DSIH_GATHER4_C, + WINED3DSIH_GATHER4_PO, WINED3DSIH_GE, WINED3DSIH_HS_CONTROL_POINT_PHASE, WINED3DSIH_HS_DECLS,