wined3d: Implement SM4 sample_d instruction.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-02-03 11:49:11 +01:00 committed by Alexandre Julliard
parent e116295dd7
commit 9fff169498
1 changed files with 18 additions and 7 deletions

View File

@ -4395,15 +4395,23 @@ static void shader_glsl_ld(const struct wined3d_shader_instruction *ins)
static void shader_glsl_sample(const struct wined3d_shader_instruction *ins) static void shader_glsl_sample(const struct wined3d_shader_instruction *ins)
{ {
const char *lod_param_str = NULL, *dx_param_str = NULL, *dy_param_str = NULL;
struct glsl_src_param coord_param, lod_param, dx_param, dy_param;
unsigned int resource_idx, sampler_idx, sampler_bind_idx; unsigned int resource_idx, sampler_idx, sampler_bind_idx;
struct glsl_src_param coord_param, lod_param;
struct glsl_sample_function sample_function; struct glsl_sample_function sample_function;
const char *lod_param_str = NULL;
DWORD flags = 0; DWORD flags = 0;
if (ins->handler_idx == WINED3DSIH_SAMPLE_GRAD)
flags |= WINED3D_GLSL_SAMPLE_GRAD;
if (ins->handler_idx == WINED3DSIH_SAMPLE_LOD)
flags |= WINED3D_GLSL_SAMPLE_LOD;
resource_idx = ins->src[1].reg.idx[0].offset; resource_idx = ins->src[1].reg.idx[0].offset;
sampler_idx = ins->src[2].reg.idx[0].offset; sampler_idx = ins->src[2].reg.idx[0].offset;
shader_glsl_get_sample_function(ins->ctx, resource_idx, flags, &sample_function);
shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param);
switch (ins->handler_idx) switch (ins->handler_idx)
{ {
case WINED3DSIH_SAMPLE: case WINED3DSIH_SAMPLE:
@ -4412,8 +4420,13 @@ static void shader_glsl_sample(const struct wined3d_shader_instruction *ins)
shader_glsl_add_src_param(ins, &ins->src[3], WINED3DSP_WRITEMASK_0, &lod_param); shader_glsl_add_src_param(ins, &ins->src[3], WINED3DSP_WRITEMASK_0, &lod_param);
lod_param_str = lod_param.param_str; lod_param_str = lod_param.param_str;
break; break;
case WINED3DSIH_SAMPLE_GRAD:
shader_glsl_add_src_param(ins, &ins->src[3], sample_function.coord_mask, &dx_param);
shader_glsl_add_src_param(ins, &ins->src[4], sample_function.coord_mask, &dy_param);
dx_param_str = dx_param.param_str;
dy_param_str = dy_param.param_str;
break;
case WINED3DSIH_SAMPLE_LOD: case WINED3DSIH_SAMPLE_LOD:
flags |= WINED3D_GLSL_SAMPLE_LOD;
shader_glsl_add_src_param(ins, &ins->src[3], WINED3DSP_WRITEMASK_0, &lod_param); shader_glsl_add_src_param(ins, &ins->src[3], WINED3DSP_WRITEMASK_0, &lod_param);
lod_param_str = lod_param.param_str; lod_param_str = lod_param.param_str;
break; break;
@ -4422,11 +4435,9 @@ static void shader_glsl_sample(const struct wined3d_shader_instruction *ins)
break; break;
} }
shader_glsl_get_sample_function(ins->ctx, resource_idx, flags, &sample_function);
shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param);
sampler_bind_idx = shader_glsl_find_sampler(&ins->ctx->reg_maps->sampler_map, resource_idx, sampler_idx); sampler_bind_idx = shader_glsl_find_sampler(&ins->ctx->reg_maps->sampler_map, resource_idx, sampler_idx);
shader_glsl_gen_sample_code(ins, sampler_bind_idx, &sample_function, ins->src[1].swizzle, shader_glsl_gen_sample_code(ins, sampler_bind_idx, &sample_function, ins->src[1].swizzle,
NULL, NULL, lod_param_str, "%s", coord_param.param_str); dx_param_str, dy_param_str, lod_param_str, "%s", coord_param.param_str);
shader_glsl_release_sample_function(ins->ctx, &sample_function); shader_glsl_release_sample_function(ins->ctx, &sample_function);
} }
@ -8111,7 +8122,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_SAMPLE_B */ shader_glsl_sample, /* WINED3DSIH_SAMPLE_B */ shader_glsl_sample,
/* WINED3DSIH_SAMPLE_C */ NULL, /* WINED3DSIH_SAMPLE_C */ NULL,
/* WINED3DSIH_SAMPLE_C_LZ */ NULL, /* WINED3DSIH_SAMPLE_C_LZ */ NULL,
/* WINED3DSIH_SAMPLE_GRAD */ NULL, /* WINED3DSIH_SAMPLE_GRAD */ shader_glsl_sample,
/* WINED3DSIH_SAMPLE_LOD */ shader_glsl_sample, /* WINED3DSIH_SAMPLE_LOD */ shader_glsl_sample,
/* WINED3DSIH_SETP */ NULL, /* WINED3DSIH_SETP */ NULL,
/* WINED3DSIH_SGE */ shader_glsl_compare, /* WINED3DSIH_SGE */ shader_glsl_compare,