wined3d: Implement texldd in ARB.

This commit is contained in:
Stefan Doesinger 2009-05-29 17:23:35 +02:00 committed by Alexandre Julliard
parent 2f6a713805
commit 4830a29101
1 changed files with 39 additions and 14 deletions

View File

@ -901,7 +901,7 @@ static void gen_color_correction(SHADER_BUFFER *buffer, const char *reg, DWORD d
#define TEX_DERIV 0x10
static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD sampler_idx,
const char *dst_str, const char *coord_reg, WORD flags)
const char *dst_str, const char *coord_reg, WORD flags, const char *dsx, const char *dsy)
{
SHADER_BUFFER *buffer = ins->ctx->buffer;
DWORD sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
@ -944,7 +944,14 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
tex_type = "";
}
if (flags & TEX_BIAS)
if (flags & TEX_DERIV)
{
if(flags & TEX_PROJ) FIXME("Projected texture sampling with custom derivates\n");
if(flags & TEX_BIAS) FIXME("Biased texture sampling with custom derivates\n");
shader_addline(buffer, "TXD %s, %s, %s, %s, texture[%u], %s;\n", dst_str, coord_reg, dsx, dsy,
sampler_idx, tex_type);
}
else if (flags & TEX_BIAS)
{
/* Shouldn't be possible, but let's check for it */
if(flags & TEX_PROJ) FIXME("Biased and Projected texture sampling\n");
@ -1439,7 +1446,7 @@ static void pshader_hw_tex(const struct wined3d_shader_instruction *ins)
if (ins->flags & WINED3DSI_TEXLD_PROJECT) myflags |= TEX_PROJ;
if (ins->flags & WINED3DSI_TEXLD_BIAS) myflags |= TEX_BIAS;
}
shader_hw_sample(ins, reg_sampler_code, reg_dest, reg_coord, myflags);
shader_hw_sample(ins, reg_sampler_code, reg_dest, reg_coord, myflags, NULL, NULL);
}
static void pshader_hw_texcoord(const struct wined3d_shader_instruction *ins)
@ -1483,7 +1490,7 @@ static void pshader_hw_texreg2ar(const struct wined3d_shader_instruction *ins)
shader_addline(buffer, "MOV TA.y, %s.x;\n", src_str);
shader_addline(buffer, "MOV TA.x, %s.w;\n", src_str);
flags = reg1 < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg1][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
shader_hw_sample(ins, reg1, dst_str, "TA", flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0);
shader_hw_sample(ins, reg1, dst_str, "TA", flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
}
static void pshader_hw_texreg2gb(const struct wined3d_shader_instruction *ins)
@ -1499,7 +1506,7 @@ static void pshader_hw_texreg2gb(const struct wined3d_shader_instruction *ins)
shader_arb_get_src_param(ins, &ins->src[0], 0, src_str);
shader_addline(buffer, "MOV TA.x, %s.y;\n", src_str);
shader_addline(buffer, "MOV TA.y, %s.z;\n", src_str);
shader_hw_sample(ins, reg1, dst_str, "TA", 0);
shader_hw_sample(ins, reg1, dst_str, "TA", 0, NULL, NULL);
}
static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins)
@ -1511,7 +1518,7 @@ static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins)
/* Note that texreg2rg treats Tx as a temporary register, not as a varying */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
shader_arb_get_src_param(ins, &ins->src[0], 0, src_str);
shader_hw_sample(ins, reg1, dst_str, src_str, 0);
shader_hw_sample(ins, reg1, dst_str, src_str, 0, NULL, NULL);
}
static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins)
@ -1557,7 +1564,7 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins)
shader_addline(buffer, "ADD TA.xy, TA, %s;\n", reg_coord);
}
shader_hw_sample(ins, reg_dest_code, dst_reg, "TA", 0);
shader_hw_sample(ins, reg_dest_code, dst_reg, "TA", 0, NULL, NULL);
if (ins->handler_idx == WINED3DSIH_TEXBEML)
{
@ -1604,7 +1611,7 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins)
shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name);
shader_addline(buffer, "DP3 %s.y, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name);
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0);
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
}
static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins)
@ -1649,7 +1656,7 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins)
/* Sample the texture using the calculated coordinates */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
shader_hw_sample(ins, reg, dst_str, dst_name, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0);
shader_hw_sample(ins, reg, dst_str, dst_name, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
current_state->current_row = 0;
}
@ -1691,7 +1698,7 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins
/* Sample the texture using the calculated coordinates */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0);
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
current_state->current_row = 0;
}
@ -1733,7 +1740,7 @@ static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins)
/* Sample the texture using the calculated coordinates */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0);
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
current_state->current_row = 0;
}
@ -1780,7 +1787,7 @@ static void pshader_hw_texdp3tex(const struct wined3d_shader_instruction *ins)
shader_addline(buffer, "DP3 TB.x, fragment.texcoord[%u], %s;\n", sampler_idx, src0);
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
shader_hw_sample(ins, sampler_idx, dst_str, "TB", 0 /* Only one coord, can't be projected */);
shader_hw_sample(ins, sampler_idx, dst_str, "TB", 0 /* Only one coord, can't be projected */, NULL, NULL);
}
/** Process the WINED3DSIO_TEXDP3 instruction in ARB:
@ -2374,6 +2381,24 @@ static void shader_hw_endif(const struct wined3d_shader_instruction *ins)
}
}
static void shader_hw_texldd(const struct wined3d_shader_instruction *ins)
{
DWORD sampler_idx = ins->src[1].reg.idx;
char reg_dest[40];
char reg_src[3][40];
DWORD flags = TEX_DERIV;
shader_arb_get_dst_param(ins, &ins->dst[0], reg_dest);
shader_arb_get_src_param(ins, &ins->src[0], 0, reg_src[0]);
shader_arb_get_src_param(ins, &ins->src[2], 1, reg_src[1]);
shader_arb_get_src_param(ins, &ins->src[3], 2, reg_src[2]);
if (ins->flags & WINED3DSI_TEXLD_PROJECT) flags |= TEX_PROJ;
if (ins->flags & WINED3DSI_TEXLD_BIAS) flags |= TEX_BIAS;
shader_hw_sample(ins, sampler_idx, reg_dest, reg_src[0], flags, reg_src[1], reg_src[2]);
}
static GLuint create_arb_blt_vertex_program(const WineD3D_GL_Info *gl_info)
{
GLuint program_id = 0;
@ -2578,7 +2603,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This,
* Testing shows no performance difference between OPTION NV_fragment_program2 and NV_fragment_program.
* So enable the best we can get.
*/
if(reg_maps->usesdsx || reg_maps->usesdsy || reg_maps->loop_depth > 0)
if(reg_maps->usesdsx || reg_maps->usesdsy || reg_maps->loop_depth > 0 || reg_maps->usestexldd)
{
want_nv_prog = TRUE;
}
@ -3466,7 +3491,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_TEXDP3 */ pshader_hw_texdp3,
/* WINED3DSIH_TEXDP3TEX */ pshader_hw_texdp3tex,
/* WINED3DSIH_TEXKILL */ pshader_hw_texkill,
/* WINED3DSIH_TEXLDD */ NULL,
/* WINED3DSIH_TEXLDD */ shader_hw_texldd,
/* WINED3DSIH_TEXLDL */ NULL,
/* WINED3DSIH_TEXM3x2DEPTH */ pshader_hw_texm3x2depth,
/* WINED3DSIH_TEXM3x2PAD */ pshader_hw_texm3x2pad,