[PATCH] d3dx9: Correctly handle NULL constant state for objects on 64 bit arch.

Matteo Bruni matteo.mystral at gmail.com
Wed Oct 30 04:26:22 CDT 2019


On Mon, Oct 28, 2019 at 8:59 AM Paul Gofman <gofmanp at gmail.com> wrote:
>
> Signed-off-by: Paul Gofman <gofmanp at gmail.com>
> ---
>  dlls/d3dx9_36/effect.c | 25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
> index 7d686a435d..5be2725d3c 100644
> --- a/dlls/d3dx9_36/effect.c
> +++ b/dlls/d3dx9_36/effect.c
> @@ -973,6 +973,8 @@ static HRESULT d3dx9_get_param_value_ptr(struct d3dx_pass *pass, struct d3dx_sta
>          BOOL update_all, BOOL *param_dirty)
>  {
>      struct d3dx_parameter *param = &state->parameter;
> +    enum STATE_CLASS state_class;
> +    static void *null_ptr;
>
>      *param_value = NULL;
>      *out_param = NULL;
> @@ -981,13 +983,30 @@ static HRESULT d3dx9_get_param_value_ptr(struct d3dx_pass *pass, struct d3dx_sta
>      switch (state->type)
>      {
>          case ST_PARAMETER:
> -            param = state->referenced_param;
> +            *out_param = param = state->referenced_param;
> +            *param_value = param->data;
>              *param_dirty = is_param_dirty(param, pass->update_version);
> -            /* fallthrough */
> +            return D3D_OK;
> +
>          case ST_CONSTANT:
>              *out_param = param;
> -            *param_value = param->data;
> +
> +            if (((state_class = state_table[state->operation].class) == SC_VERTEXSHADER
> +                    || state_class == SC_PIXELSHADER || state_class == SC_TEXTURE)
> +                    && param->bytes < sizeof(void *))
> +            {
> +                *param_value = &null_ptr;
> +
> +                if (param->type != D3DXPT_INT || *(unsigned int *)param->data)
> +                    FIXME("Unexpected parameter for object, param->type %u, param->class %u.\n",
> +                            param->type, param->class);

How does this happen? The effect somehow uses D3DXPT_INT instead of
e.g. D3DXPT_VERTEXSHADER and tries to get away with it? What effects /
games did you see doing that?

OT, right now I'm having weird issues with the 64-bit mingw build: for
some reason the (only) sprintf() call in effect.c always returns just
"[", which then breaks a bunch of things. I assume it's some issue on
my side but if anyone has any idea I'm all ears...



More information about the wine-devel mailing list