[PATCH 1/5] wined3d: Handle WINED3D_LOCATION_CLEARED in wined3d_texture_load_location().

Zebediah Figura zfigura at codeweavers.com
Wed Feb 23 18:13:28 CST 2022



On 2/21/22 10:16, Henri Verbeet wrote:
> On Mon, 21 Feb 2022 at 06:22, Zebediah Figura <zfigura at codeweavers.com> wrote:
>> @@ -789,6 +789,19 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
>>           return TRUE;
>>       }
>>
>> +    if (current & WINED3D_LOCATION_CLEARED)
>> +    {
>> +        struct wined3d_bo_address addr;
>> +
>> +        /* FIXME: Clear textures on the GPU if possible. */
>> +
>> +        if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM))
>> +            return FALSE;
>> +        wined3d_texture_get_memory(texture, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM);
>> +        memset(addr.addr, 0, texture->sub_resources[sub_resource_idx].size);
>> +        current = WINED3D_LOCATION_SYSMEM;
>> +    }
>> +
> This is broken. If WINED3D_LOCATION_BUFFER exists,
> wined3d_texture_get_memory() will return that instead of
> WINED3D_LOCATION_SYSMEM. (It won't if WINED3D_LOCATION_CLEARED is the
> only location that's current, but nothing prevents us from e.g. first
> calling wined3d_load_location(..., WINED3D_LOCATION_BUFFER), and then
> subsequently calling wined3d_load_location(...,
> WINED3D_LOCATION_TEXTURE_RGB).)
> 
> More generally, wined3d_texture_get_memory() should only be used in
> cases where we don't care about the exact location that's returned.

Maybe I'm misreading something, but wined3d_texture_get_memory() doesn't 
check sub_resource->locations, only the requested location, so this 
isn't broken per se.

Regardless, if we want to preserve this model, I'll write a helper that 
retrieves the correct BO address for a given location.



More information about the wine-devel mailing list