Module: wine Branch: master Commit: a3c4410fea86a47a012d3ab67485b9d37a89d9a4 URL: https://gitlab.winehq.org/wine/wine/-/commit/a3c4410fea86a47a012d3ab67485b9d...
Author: Zebediah Figura zfigura@codeweavers.com Date: Fri Jul 29 14:21:34 2022 -0500
d3d9: Introduce a wined3d_usage_from_d3d() helper.
---
dlls/d3d9/buffer.c | 4 ++-- dlls/d3d9/d3d9_private.h | 13 ++++++++----- dlls/d3d9/device.c | 6 ++---- dlls/d3d9/texture.c | 13 +++---------- 4 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 0ffb48a66c8..e6224f95763 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -303,7 +303,7 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device * d3d9_resource_init(&buffer->resource);
desc.byte_width = size; - desc.usage = usage & WINED3DUSAGE_MASK; + desc.usage = wined3d_usage_from_d3d(pool, usage); desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); /* Buffers are always readable. */ @@ -611,7 +611,7 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de return D3DERR_INVALIDCALL;
desc.byte_width = size; - desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; + desc.usage = wined3d_usage_from_d3d(pool, usage) | WINED3DUSAGE_STATICDECL; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); /* Buffers are always readable. */ diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index eb01b15338a..caa146ccd85 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -373,6 +373,14 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int return access; }
+static inline unsigned int wined3d_usage_from_d3d(D3DPOOL pool, DWORD usage) +{ + usage &= WINED3DUSAGE_MASK; + if (pool == D3DPOOL_SCRATCH) + usage |= WINED3DUSAGE_SCRATCH; + return usage; +} + static inline unsigned int wined3d_bind_flags_from_d3d9_usage(DWORD usage) { unsigned int bind_flags = 0; @@ -385,11 +393,6 @@ static inline unsigned int wined3d_bind_flags_from_d3d9_usage(DWORD usage) return bind_flags; }
-static inline DWORD wined3dusage_from_d3dusage(unsigned int usage) -{ - return usage & WINED3DUSAGE_MASK; -} - static inline enum wined3d_multisample_type wined3d_multisample_type_from_d3d(D3DMULTISAMPLE_TYPE type) { return (enum wined3d_multisample_type)type; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 894659e9ff9..9b8e44f6891 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1976,10 +1976,8 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex } }
- usage = 0; - if (pool == D3DPOOL_SCRATCH) - usage |= WINED3DUSAGE_SCRATCH; - access = wined3daccess_from_d3dpool(pool, usage) + usage = wined3d_usage_from_d3d(pool, 0); + access = wined3daccess_from_d3dpool(pool, 0) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
return d3d9_device_create_surface(device, 0, wined3dformat_from_d3dformat(format), diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 19f0363db07..31bf95834b8 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1317,9 +1317,7 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, desc.format = wined3dformat_from_d3dformat(format); desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = wined3dusage_from_d3dusage(usage); - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; + desc.usage = wined3d_usage_from_d3d(pool, usage); desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; @@ -1414,10 +1412,7 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic desc.format = wined3dformat_from_d3dformat(format); desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = wined3dusage_from_d3dusage(usage); - desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; + desc.usage = wined3d_usage_from_d3d(pool, usage) | WINED3DUSAGE_LEGACY_CUBEMAP; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = edge_length; @@ -1500,9 +1495,7 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev desc.format = wined3dformat_from_d3dformat(format); desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = wined3dusage_from_d3dusage(usage); - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; + desc.usage = wined3d_usage_from_d3d(pool, usage); desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width;