[PATCH 4/5] wined3d: Introduce a get_texture_matrix() function.
Matteo Bruni
mbruni at codeweavers.com
Fri Mar 20 07:50:55 CDT 2015
---
dlls/wined3d/state.c | 40 +++++++++--------------------------
dlls/wined3d/utils.c | 47 +++++++++++++++++++++++++++++++++---------
dlls/wined3d/wined3d_private.h | 5 ++---
3 files changed, 49 insertions(+), 43 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index c651c17..ae6b84d 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3278,12 +3278,10 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st
void transform_texture(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
- DWORD texUnit = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
- const struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info;
- DWORD mapped_stage = context->tex_unit_map[texUnit];
- BOOL generated;
- int coordIdx;
+ unsigned int tex = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
+ unsigned int mapped_stage = context->tex_unit_map[tex];
+ struct wined3d_matrix mat;
/* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
if (use_vs(state) || isStateDirty(context, STATE_VDECL))
@@ -3296,31 +3294,13 @@ void transform_texture(struct wined3d_context *context, const struct wined3d_sta
if (mapped_stage >= gl_info->limits.textures) return;
context_active_texture(context, gl_info, mapped_stage);
- generated = (state->texture_states[texUnit][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU;
- coordIdx = min(state->texture_states[texUnit][WINED3D_TSS_TEXCOORD_INDEX & 0x0000ffff], MAX_TEXTURES - 1);
-
- set_texture_matrix(gl_info, &state->transforms[WINED3D_TS_TEXTURE0 + texUnit],
- state->texture_states[texUnit][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS],
- generated, context->last_was_rhw,
- context->stream_info.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx))
- ? context->stream_info.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].format->id
- : WINED3DFMT_UNKNOWN,
- device->shader_backend->shader_has_ffp_proj_control(device->shader_priv));
-
- /* The sampler applying function calls us if this changes */
- if ((context->lastWasPow2Texture & (1 << texUnit)) && state->textures[texUnit])
- {
- if(generated) {
- FIXME("Non-power2 texture being used with generated texture coords\n");
- }
- /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
- fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
- if (!use_ps(state))
- {
- TRACE("Non power two matrix multiply fixup\n");
- gl_info->gl_ops.gl.p_glMultMatrixf(state->textures[texUnit]->pow2_matrix);
- }
- }
+ gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE);
+ checkGLcall("glMatrixMode(GL_TEXTURE)");
+
+ get_texture_matrix(context, state, mapped_stage, &mat);
+
+ gl_info->gl_ops.gl.p_glLoadMatrixf(&mat._11);
+ checkGLcall("glLoadMatrixf");
}
static void unload_tex_coords(const struct wined3d_gl_info *gl_info)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 4452f7c..b28142c 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3203,19 +3203,15 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w
}
/* Setup this textures matrix according to the texture flags. */
-/* Context activation is done by the caller (state handler). */
-void set_texture_matrix(const struct wined3d_gl_info *gl_info, const struct wined3d_matrix *matrix, DWORD flags,
- BOOL calculated_coords, BOOL transformed, enum wined3d_format_id format_id, BOOL ffp_proj_control)
+static void compute_texture_matrix(const struct wined3d_gl_info *gl_info, const struct wined3d_matrix *matrix,
+ DWORD flags, BOOL calculated_coords, BOOL transformed, enum wined3d_format_id format_id,
+ BOOL ffp_proj_control, struct wined3d_matrix *out_matrix)
{
struct wined3d_matrix mat;
- gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE);
- checkGLcall("glMatrixMode(GL_TEXTURE)");
-
if (flags == WINED3D_TTFF_DISABLE || flags == WINED3D_TTFF_COUNT1 || transformed)
{
- gl_info->gl_ops.gl.p_glLoadIdentity();
- checkGLcall("glLoadIdentity()");
+ get_identity_matrix(out_matrix);
return;
}
@@ -3314,8 +3310,39 @@ void set_texture_matrix(const struct wined3d_gl_info *gl_info, const struct wine
}
}
- gl_info->gl_ops.gl.p_glLoadMatrixf(&mat._11);
- checkGLcall("glLoadMatrixf(mat)");
+ *out_matrix = mat;
+}
+
+void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
+ unsigned int tex, struct wined3d_matrix *mat)
+{
+ const struct wined3d_device *device = context->swapchain->device;
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ BOOL generated = (state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000)
+ != WINED3DTSS_TCI_PASSTHRU;
+ unsigned int coord_idx = min(state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX & 0x0000ffff],
+ MAX_TEXTURES - 1);
+
+ compute_texture_matrix(gl_info, &state->transforms[WINED3D_TS_TEXTURE0 + tex],
+ state->texture_states[tex][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS],
+ generated, context->last_was_rhw,
+ context->stream_info.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coord_idx))
+ ? context->stream_info.elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->id
+ : WINED3DFMT_UNKNOWN,
+ device->shader_backend->shader_has_ffp_proj_control(device->shader_priv), mat);
+
+ if ((context->lastWasPow2Texture & (1 << tex)) && state->textures[tex])
+ {
+ if (generated)
+ FIXME("Non-power-of-two texture being used with generated texture coords.\n");
+ /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
+ * fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
+ if (!use_ps(state))
+ {
+ TRACE("Non-power-of-two texture matrix multiply fixup.\n");
+ multiply_matrix(mat, mat, (struct wined3d_matrix *)state->textures[tex]->pow2_matrix);
+ }
+ }
}
/* This small helper function is used to convert a bitmask into the number of masked bits */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 6ccfad6..eaaf44c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2783,9 +2783,6 @@ BOOL is_invalid_op(const struct wined3d_state *state, int stage,
void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
-void set_texture_matrix(const struct wined3d_gl_info *gl_info, const struct wined3d_matrix *matrix,
- DWORD flags, BOOL calculated_coords, BOOL transformed, enum wined3d_format_id format_id,
- BOOL ffp_can_disable_proj) DECLSPEC_HIDDEN;
void texture_activate_dimensions(const struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
void sampler_texdim(struct wined3d_context *context,
@@ -3038,6 +3035,8 @@ void get_modelview_matrix(const struct wined3d_context *context, const struct wi
struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
+void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
+ unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
/* Using additional shader constants (uniforms in GLSL / program environment
* or local parameters in ARB) is costly:
--
2.0.5
More information about the wine-patches
mailing list