wined3d: Get rid of the WINED3DTEXTURETRANSFORMFLAGS typedef.

This commit is contained in:
Henri Verbeet 2012-01-09 22:16:52 +01:00 committed by Alexandre Julliard
parent 43fcbcb36e
commit 7f7bc520b6
5 changed files with 88 additions and 56 deletions

View File

@ -3041,14 +3041,24 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
enum wined3d_sampler_texture_type sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
/* Projected cube textures don't make a lot of sense, the resulting coordinates stay the same. */
if (flags & WINED3D_PSARGS_PROJECTED && sampler_type != WINED3DSTT_CUBE) {
if (flags & WINED3D_PSARGS_PROJECTED && sampler_type != WINED3DSTT_CUBE)
{
sample_flags |= WINED3D_GLSL_SAMPLE_PROJECTED;
switch (flags & ~WINED3D_PSARGS_PROJECTED) {
case WINED3DTTFF_COUNT1: FIXME("WINED3DTTFF_PROJECTED with WINED3DTTFF_COUNT1?\n"); break;
case WINED3DTTFF_COUNT2: mask = WINED3DSP_WRITEMASK_1; break;
case WINED3DTTFF_COUNT3: mask = WINED3DSP_WRITEMASK_2; break;
case WINED3DTTFF_COUNT4:
case WINED3DTTFF_DISABLE: mask = WINED3DSP_WRITEMASK_3; break;
switch (flags & ~WINED3D_PSARGS_PROJECTED)
{
case WINED3D_TTFF_COUNT1:
FIXME("WINED3D_TTFF_PROJECTED with WINED3D_TTFF_COUNT1?\n");
break;
case WINED3D_TTFF_COUNT2:
mask = WINED3DSP_WRITEMASK_1;
break;
case WINED3D_TTFF_COUNT3:
mask = WINED3DSP_WRITEMASK_2;
break;
case WINED3D_TTFF_COUNT4:
case WINED3D_TTFF_DISABLE:
mask = WINED3DSP_WRITEMASK_3;
break;
}
}
}
@ -3502,18 +3512,27 @@ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins)
shader_glsl_write_mask_to_str(mask, coord_mask);
/* with projective textures, texbem only divides the static texture coord, not the displacement,
* so we can't let the GL handle this.
*/
if (flags & WINED3D_PSARGS_PROJECTED) {
/* With projected textures, texbem only divides the static texture coord,
* not the displacement, so we can't let GL handle this. */
if (flags & WINED3D_PSARGS_PROJECTED)
{
DWORD div_mask=0;
char coord_div_mask[3];
switch (flags & ~WINED3D_PSARGS_PROJECTED) {
case WINED3DTTFF_COUNT1: FIXME("WINED3DTTFF_PROJECTED with WINED3DTTFF_COUNT1?\n"); break;
case WINED3DTTFF_COUNT2: div_mask = WINED3DSP_WRITEMASK_1; break;
case WINED3DTTFF_COUNT3: div_mask = WINED3DSP_WRITEMASK_2; break;
case WINED3DTTFF_COUNT4:
case WINED3DTTFF_DISABLE: div_mask = WINED3DSP_WRITEMASK_3; break;
switch (flags & ~WINED3D_PSARGS_PROJECTED)
{
case WINED3D_TTFF_COUNT1:
FIXME("WINED3D_TTFF_PROJECTED with WINED3D_TTFF_COUNT1?\n");
break;
case WINED3D_TTFF_COUNT2:
div_mask = WINED3DSP_WRITEMASK_1;
break;
case WINED3D_TTFF_COUNT3:
div_mask = WINED3DSP_WRITEMASK_2;
break;
case WINED3D_TTFF_COUNT4:
case WINED3D_TTFF_DISABLE:
div_mask = WINED3DSP_WRITEMASK_3;
break;
}
shader_glsl_write_mask_to_str(div_mask, coord_div_mask);
shader_addline(ins->ctx->buffer, "T%u%s /= T%u%s;\n", sampler_idx, coord_mask, sampler_idx, coord_div_mask);

View File

@ -1912,11 +1912,11 @@ void find_ps_compile_args(const struct wined3d_state *state,
{
DWORD flags = state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS];
if (flags & WINED3DTTFF_PROJECTED)
if (flags & WINED3D_TTFF_PROJECTED)
{
enum wined3d_sampler_texture_type sampler_type = shader->reg_maps.sampler_type[i];
DWORD tex_transform = flags & ~WINED3DTTFF_PROJECTED;
DWORD max_valid = WINED3DTTFF_COUNT4;
DWORD tex_transform = flags & ~WINED3D_TTFF_PROJECTED;
DWORD max_valid = WINED3D_TTFF_COUNT4;
if (!state->vertex_shader)
{
@ -1943,9 +1943,9 @@ void find_ps_compile_args(const struct wined3d_state *state,
tex_transform = max_valid;
}
if ((sampler_type == WINED3DSTT_1D && tex_transform > WINED3DTTFF_COUNT1)
|| (sampler_type == WINED3DSTT_2D && tex_transform > WINED3DTTFF_COUNT2)
|| (sampler_type == WINED3DSTT_VOLUME && tex_transform > WINED3DTTFF_COUNT3))
if ((sampler_type == WINED3DSTT_1D && tex_transform > WINED3D_TTFF_COUNT1)
|| (sampler_type == WINED3DSTT_2D && tex_transform > WINED3D_TTFF_COUNT2)
|| (sampler_type == WINED3DSTT_VOLUME && tex_transform > WINED3D_TTFF_COUNT3))
tex_transform |= WINED3D_PSARGS_PROJECTED;
else
WARN("Application requested projected texture with unsuitable texture coordinates.\n");

View File

@ -1267,7 +1267,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] = i;
state->texture_states[i][WINED3D_TSS_BUMPENV_LSCALE] = 0;
state->texture_states[i][WINED3D_TSS_BUMPENV_LOFFSET] = 0;
state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS] = WINED3DTTFF_DISABLE;
state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS] = WINED3D_TTFF_DISABLE;
state->texture_states[i][WINED3D_TSS_COLOR_ARG0] = WINED3DTA_CURRENT;
state->texture_states[i][WINED3D_TSS_ALPHA_ARG0] = WINED3DTA_CURRENT;
state->texture_states[i][WINED3D_TSS_RESULT_ARG] = WINED3DTA_CURRENT;

View File

@ -2503,30 +2503,41 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B
glMatrixMode(GL_TEXTURE);
checkGLcall("glMatrixMode(GL_TEXTURE)");
if (flags == WINED3DTTFF_DISABLE || flags == WINED3DTTFF_COUNT1 || transformed) {
if (flags == WINED3D_TTFF_DISABLE || flags == WINED3D_TTFF_COUNT1 || transformed)
{
glLoadIdentity();
checkGLcall("glLoadIdentity()");
return;
}
if (flags == (WINED3DTTFF_COUNT1|WINED3DTTFF_PROJECTED)) {
ERR("Invalid texture transform flags: WINED3DTTFF_COUNT1|WINED3DTTFF_PROJECTED\n");
if (flags == (WINED3D_TTFF_COUNT1 | WINED3D_TTFF_PROJECTED))
{
ERR("Invalid texture transform flags: WINED3D_TTFF_COUNT1 | WINED3D_TTFF_PROJECTED.\n");
return;
}
memcpy(mat, smat, 16 * sizeof(float));
if (flags & WINED3DTTFF_PROJECTED) {
if(!ffp_proj_control) {
switch (flags & ~WINED3DTTFF_PROJECTED) {
case WINED3DTTFF_COUNT2:
mat[3] = mat[1], mat[7] = mat[5], mat[11] = mat[9], mat[15] = mat[13];
mat[1] = mat[5] = mat[9] = mat[13] = 0;
break;
case WINED3DTTFF_COUNT3:
mat[3] = mat[2], mat[7] = mat[6], mat[11] = mat[10], mat[15] = mat[14];
mat[2] = mat[6] = mat[10] = mat[14] = 0;
break;
if (flags & WINED3D_TTFF_PROJECTED)
{
if (!ffp_proj_control)
{
switch (flags & ~WINED3D_TTFF_PROJECTED)
{
case WINED3D_TTFF_COUNT2:
mat[ 3] = mat[ 1];
mat[ 7] = mat[ 5];
mat[11] = mat[ 9];
mat[15] = mat[13];
mat[ 1] = mat[ 5] = mat[ 9] = mat[13] = 0.0f;
break;
case WINED3D_TTFF_COUNT3:
mat[ 3] = mat[ 2];
mat[ 7] = mat[ 6];
mat[11] = mat[10];
mat[15] = mat[14];
mat[ 2] = mat[ 6] = mat[10] = mat[14] = 0.0f;
break;
}
}
} else { /* under directx the R/Z coord can be used for translation, under opengl we use the Q coord instead */
@ -2564,10 +2575,13 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B
FIXME("Unexpected fixed function texture coord input\n");
}
}
if(!ffp_proj_control) {
switch (flags & ~WINED3DTTFF_PROJECTED) {
/* case WINED3DTTFF_COUNT1: Won't ever get here */
case WINED3DTTFF_COUNT2: mat[2] = mat[6] = mat[10] = mat[14] = 0;
if (!ffp_proj_control)
{
switch (flags & ~WINED3D_TTFF_PROJECTED)
{
/* case WINED3D_TTFF_COUNT1: Won't ever get here. */
case WINED3D_TTFF_COUNT2:
mat[2] = mat[6] = mat[10] = mat[14] = 0;
/* OpenGL divides the first 3 vertex coord by the 4th by default,
* which is essentially the same as D3DTTFF_PROJECTED. Make sure that
* the 4th coord evaluates to 1.0 to eliminate that.
@ -2579,9 +2593,9 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B
*
* A more serious problem occurs if the app passes 4 coordinates in, and the
* 4th is != 1.0(opengl default). This would have to be fixed in drawStridedSlow
* or a replacement shader
*/
default: mat[3] = mat[7] = mat[11] = 0; mat[15] = 1;
* or a replacement shader. */
default:
mat[3] = mat[7] = mat[11] = 0; mat[15] = 1;
}
}
}
@ -3015,9 +3029,9 @@ void gen_ffp_frag_op(const struct wined3d_device *device, const struct wined3d_s
|| aarg1 == WINED3DTA_TEXTURE || aarg2 == WINED3DTA_TEXTURE || aarg0 == WINED3DTA_TEXTURE)
{
ttff = state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS];
if (ttff == (WINED3DTTFF_PROJECTED | WINED3DTTFF_COUNT3))
if (ttff == (WINED3D_TTFF_PROJECTED | WINED3D_TTFF_COUNT3))
settings->op[i].projected = proj_count3;
else if (ttff & WINED3DTTFF_PROJECTED)
else if (ttff & WINED3D_TTFF_PROJECTED)
settings->op[i].projected = proj_count4;
else
settings->op[i].projected = proj_none;

View File

@ -572,16 +572,15 @@ enum wined3d_texture_stage_state
};
#define WINED3D_HIGHEST_TEXTURE_STATE WINED3D_TSS_CONSTANT
typedef enum _WINED3DTEXTURETRANSFORMFLAGS
enum wined3d_texture_transform_flags
{
WINED3DTTFF_DISABLE = 0,
WINED3DTTFF_COUNT1 = 1,
WINED3DTTFF_COUNT2 = 2,
WINED3DTTFF_COUNT3 = 3,
WINED3DTTFF_COUNT4 = 4,
WINED3DTTFF_PROJECTED = 256,
WINED3DTTFF_FORCE_DWORD = 0x7fffffff
} WINED3DTEXTURETRANSFORMFLAGS;
WINED3D_TTFF_DISABLE = 0,
WINED3D_TTFF_COUNT1 = 1,
WINED3D_TTFF_COUNT2 = 2,
WINED3D_TTFF_COUNT3 = 3,
WINED3D_TTFF_COUNT4 = 4,
WINED3D_TTFF_PROJECTED = 256,
};
typedef enum _WINED3DTEXTUREOP
{