From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/stateblock.c | 7 +------ dlls/wined3d/utils.c | 24 +++++++++++++++--------- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index f2307b97e08..a79eb7b5f9f 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3697,14 +3697,9 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, if (changed->texture_matrices) { struct wined3d_ffp_vs_constants constants; - struct wined3d_stream_info si; - - /* FIXME: This is a bit fragile. Ideally we should be calculating - * stream info from the stateblock state. */ - wined3d_stream_info_from_declaration(&si, context->state, &device->adapter->d3d_info);
for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) - get_texture_matrix(&si, state, i, &constants.texture_matrices[i]); + get_texture_matrix(state, i, &constants.texture_matrices[i]); wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_TEXMATRIX, offsetof(struct wined3d_ffp_vs_constants, texture_matrices), diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 30572bc0ded..bf970b055a3 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5649,23 +5649,29 @@ static void compute_texture_matrix(const struct wined3d_matrix *matrix, uint32_t *out_matrix = mat; }
-void get_texture_matrix(const struct wined3d_stream_info *si, - const struct wined3d_stateblock_state *state, const unsigned int tex, struct wined3d_matrix *mat) +static enum wined3d_format_id get_texcoord_format(const struct wined3d_vertex_declaration *decl, unsigned int index) +{ + for (unsigned int i = 0; i < decl->element_count; ++i) + { + if (decl->elements[i].usage == WINED3D_DECL_USAGE_TEXCOORD + && decl->elements[i].usage_idx == index) + return decl->elements[i].format->id; + } + + return WINED3DFMT_UNKNOWN; +} + +void get_texture_matrix(const struct wined3d_stateblock_state *state, + const unsigned int tex, struct wined3d_matrix *mat) { 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, WINED3D_MAX_FFP_TEXTURES - 1); - enum wined3d_format_id attribute_format; - - if (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx))) - attribute_format = si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->id; - else - attribute_format = WINED3DFMT_UNKNOWN;
compute_texture_matrix(&state->transforms[WINED3D_TS_TEXTURE0 + tex], state->texture_states[tex][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS], - generated, attribute_format, mat); + generated, get_texcoord_format(state->vertex_declaration, coord_idx), mat); }
void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 511d135a8f5..50418992163 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4376,8 +4376,8 @@ static inline BOOL shader_sampler_is_shadow(const struct wined3d_shader *shader,
void get_identity_matrix(struct wined3d_matrix *mat); void get_modelview_matrix(const struct wined3d_stateblock_state *state, unsigned int index, struct wined3d_matrix *mat); -void get_texture_matrix(const struct wined3d_stream_info *si, - const struct wined3d_stateblock_state *state, const unsigned int tex, struct wined3d_matrix *mat); +void get_texture_matrix(const struct wined3d_stateblock_state *state, + const unsigned int tex, struct wined3d_matrix *mat); void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state, float *out_min, float *out_max); void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,