[PATCH 3/6] wined3d: Use an rbtree for storing shaders for texture format conversion/blitting

Martin Storsjö martin at martin.st
Tue Feb 11 08:25:23 CST 2014


On Tue, 11 Feb 2014, Stefan Dösinger wrote:

>
> Am 11.02.2014 um 12:14 schrieb Martin Storsjo <martin at martin.st>:
>
>> ---
>> dlls/wined3d/arb_program_shader.c | 187 +++++++++++++++++++++++++-------------
>> 1 file changed, 122 insertions(+), 65 deletions(-)
>>
>> diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
>> index 6d17ea3..8390c9e 100644
>> --- a/dlls/wined3d/arb_program_shader.c
>> +++ b/dlls/wined3d/arb_program_shader.c
>> @@ -6768,22 +6768,68 @@ const struct fragment_pipeline arbfp_fragment_pipeline = {
>>     arbfp_fragmentstate_template,
>> };
>>
>> +struct arbfp_blit_type
>> +{
>> +    enum complex_fixup fixup;
>> +    GLenum textype;
>> +};
>> ...
>> +static int arbfp_blit_type_compare(const void *key, const struct wine_rb_entry *entry)
>> +{
>> +    const struct arbfp_blit_type *ka = key;
>> +    const struct arbfp_blit_type *kb = &WINE_RB_ENTRY_VALUE(entry, const struct arbfp_blit_desc, entry)->type;
>> +
>> +    return memcmp(ka, kb, sizeof(*ka));
>> +}
> You have to watch out for padding space added by the compiler if you memcmp the structure. I think there’s no guarantee that enum complex_fixup is 4 bytes. Either use memset to initialize it to zero, or (preferred) make the fixup member a bitfield and add an explicit padding field for the remaining bits (see some structures in wined3d_private.h for examples) and set the padding to zero manually.

Ah, right, yes. Or what about just doing two separate comparisons for 
fixup and textype instead of a memcmp of the struct?

// Martin


More information about the wine-devel mailing list