[3/5] WineD3D: Unroll loops in ARB if GL_NV_vertex_program2_option is not supported

Henri Verbeet hverbeet at gmail.com
Sat Jun 6 17:30:48 CDT 2009


2009/6/7 Stefan Dösinger <stefan at codeweavers.com>:
> +/* Not reentrant! */
> +static inline const int *get_int_const(const struct wined3d_shader_instruction *ins, IWineD3DBaseShaderImpl *This, DWORD idx)
> +{
> +    BOOL vshader = shader_is_vshader_version(This->baseShader.reg_maps.shader_version.type);
> +    WORD flag = (1 << idx);
> +    const local_constant *constant;
> +    struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
> +
> +    if(This->baseShader.reg_maps.local_int_consts & flag)
> +    {
> +        static const int err_ret[4] = {0, 0, 0, 0};
> +        /* What good is a if(bool) with a hardcoded local constant? I don't know, but handle it */
> +        LIST_FOR_EACH_ENTRY(constant, &This->baseShader.constantsI, local_constant, entry)
> +        {
> +            if (constant->idx == idx)
> +            {
> +                return (int *) constant->value;
> +            }
> +        }
> +        ERR("Local constant not found\n");
> +        return err_ret;
> +    }
> +    else
> +    {
> +        static int ret[4];
> +        ret[3] = 0;
> +        if(vshader)
> +        {
> +            /* Count and aL start value are unsigned */
> +            ret[0] = priv->cur_vs_args->loop_ctrl[idx][0];
> +            ret[1] = priv->cur_vs_args->loop_ctrl[idx][1];
> +            /* The step/stride is signed */
> +            ret[2] = ((char) priv->cur_vs_args->loop_ctrl[idx][3]);
> +        }
> +        else
> +        {
> +            ret[0] = priv->cur_ps_args->loop_ctrl[idx][0];
> +            ret[1] = priv->cur_ps_args->loop_ctrl[idx][1];
> +            ret[2] = ((char) priv->cur_ps_args->loop_ctrl[idx][3]);
> +        }
> +        return ret;
> +    }
> +}
I said I wouldn't be reviewing arb_program_shader.c changes (and I'm
not, in general), but I couldn't help noticing this bit of code.
*blink*?

> +                const int *control_values = get_int_const(ins, This, ins->src[0].reg.idx);
> +                list_init(&priv->record);
> +                priv->recording = TRUE;
> +                control_frame->outer_loop = TRUE;
> +                control_frame->loop_control[0] = control_values[0];
> +                control_frame->loop_control[1] = control_values[1];
> +                control_frame->loop_control[1] = control_values[2];
This is either a typo or redundant.



More information about the wine-devel mailing list