[2/2] WineD3D: Create a common sampling function in GLSL

Henri Verbeet hverbeet at gmail.com
Wed Feb 25 02:32:04 CST 2009


2009/2/24 Stefan Dösinger <stefan at codeweavers.com>:
>
> +static void shader_glsl_gen_sample_code(const SHADER_OPCODE_ARG *arg, DWORD sampler, const char *coord_reg,
> +                                        const glsl_sample_function_t *sample_function, const char *dst_swizzle,
> +                                        const char *bias) {
You need to pass dst_swizzle as a swizzle + write mask instead of a
string. As an API it's nicer than passing in random strings, but you
will also need this when you're going to integrate the fixup code. I
think it's a bit silly to pass sample_function to this function, the
caller will only call shader_glsl_get_sample_function() to pass it to
this function, so you might as well call it yourself.

> +    shader_glsl_append_dst(arg->buffer, arg);
I'm not sure about this one. It's not strictly necessary to do this in
the caller, but it would be more consistent between different
instruction handlers to do it there, and have
shader_glsl_gen_sample_code() only generate the second part of the
line.

I think it would be nicer to avoid the stack buffers foor coord_reg,
either by splitting shader_glsl_gen_sample_code() in two functions to
generate the start and end, or by passing it a format string for
coord_reg.

> +    sprintf(instr, "%sLod", sample_function.name);
> +    sample_function.name = instr;
> +    shader_glsl_gen_sample_code(arg, sampler_idx, coord_param.param_str,
> +                                &sample_function, dst_swizzle,
> +                                lod_param.param_str);
This is just ugly.



More information about the wine-devel mailing list