[1/7] [wined3d] add ps_np2fixup_t struct to ps_compiled_shader

Tobias Jakobi liquid.acid at gmx.net
Wed Apr 22 13:06:19 CDT 2009

Henri Verbeet wrote:
> A handle table would probably make the most sense. A pointer would
> work for ARB, but for GLSL that's just extra indirection that isn't
> really needed.
Sry, I have to correct myself.

It won't work that way.

Setting up the data of the np2 fixup data struct is done in
shader_generate_glsl_declarations, where I don't have any access to a
glsl_shader_prog_link structure. I might not even exist, since the
entries of prog_link are all setup by set_glsl_shader_program.

Furthermore the np2 fixup data struct doesn't really belong in
prog_link, it has nothing to do with the GLSL program object itself but
is a feature of the fragment shader.

That does not apply to np2Fixup_location, which has to be part of the
GLSL object since the uniform locations are based on the program and not
the individual components.

That is not the case for the np2 fixup data, which is unique to the
fragment shader - and doesn't change when creating a different vshader,
fshader/pshader combination.

>>> Not in the current code, no. But if you store the index of the fixup
>>> parameter instead of the index of the packed uniform the parameter is
>>> stored in, you can derive the index of the packed uniform as (idx >>
>>> 1) and the position within that uniform as (idx & 1).
>> I don't think I can follow you.
>> I tried some similar approach in the beginning, but it I think it failed
>> if tex1 and tex3 need fixup, but tex2 does not.
>> The approach didn't like "holes" in the indices. However we can't assume
>> that all texture samples that need fixup are consecutive.
> Tex fixup parameter for tex1 would have idx 0, the one for tex3 would
> have idx 1. These would then be packed as PsamplerNP2Fixup0.xy and
> PsamplerNP2Fixup0.zw.
OK, I think I have figured out how to get it work.

I my previous approach didn't work so well, because I was adressing the
uniforms in a different way. I also switched to a uniform array, to make
it easier to update the texture dimensions in one go. Fewer GL calls
that way.

More information about the wine-devel mailing list