Module: wine Branch: master Commit: 9492a10f4438b3f7878250f3b3906e5dfc53ac6d URL: https://gitlab.winehq.org/wine/wine/-/commit/9492a10f4438b3f7878250f3b3906e5...
Author: Paul Gofman pgofman@codeweavers.com Date: Tue Mar 19 15:54:03 2024 -0600
wined3d: Factor out wined3d_texture_set_lod() function.
---
dlls/wined3d/stateblock.c | 20 +++----------------- dlls/wined3d/texture.c | 24 ++++++++++++++++++++++++ include/wine/wined3d.h | 1 + 3 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 0cf8e91c3c9..a834a02fddf 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3321,28 +3321,14 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, unsigned int CDECL wined3d_stateblock_set_texture_lod(struct wined3d_stateblock *stateblock, struct wined3d_texture *texture, unsigned int lod) { - struct wined3d_resource *resource; - unsigned int old = texture->lod; + unsigned int old;
TRACE("texture %p, lod %u.\n", texture, lod);
- /* The d3d9:texture test shows that SetLOD is ignored on non-managed - * textures. The call always returns 0, and GetLOD always returns 0. */ - resource = &texture->resource; - if (!(resource->usage & WINED3DUSAGE_MANAGED)) - { - TRACE("Ignoring LOD on texture with resource access %s.\n", - wined3d_debug_resource_access(resource->access)); - return 0; - } + old = wined3d_texture_set_lod(texture, lod);
- if (lod >= texture->level_count) - lod = texture->level_count - 1; - - if (texture->lod != lod) + if (old != lod) { - texture->lod = lod; - for (unsigned int i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) { /* Mark the texture as changed. The next time the appplication diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index a9c8e152cf2..7fb06d71dcd 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1784,6 +1784,30 @@ unsigned int CDECL wined3d_texture_get_lod(const struct wined3d_texture *texture return texture->lod; }
+unsigned int CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, unsigned int lod) +{ + struct wined3d_resource *resource; + unsigned int old = texture->lod; + + TRACE("texture %p, returning %u.\n", texture, texture->lod); + + /* The d3d9:texture test shows that SetLOD is ignored on non-managed + * textures. The call always returns 0, and GetLOD always returns 0. */ + resource = &texture->resource; + if (!(resource->usage & WINED3DUSAGE_MANAGED)) + { + TRACE("Ignoring LOD on texture with resource access %s.\n", + wined3d_debug_resource_access(resource->access)); + return 0; + } + + if (lod >= texture->level_count) + lod = texture->level_count - 1; + + texture->lod = lod; + return old; +} + UINT CDECL wined3d_texture_get_level_count(const struct wined3d_texture *texture) { TRACE("texture %p, returning %u.\n", texture, texture->level_count); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 492065711f3..0b906886585 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2883,6 +2883,7 @@ ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture); HRESULT __cdecl wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc); unsigned int __cdecl wined3d_texture_get_level_count(const struct wined3d_texture *texture); unsigned int __cdecl wined3d_texture_get_lod(const struct wined3d_texture *texture); +unsigned int __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, unsigned int lod); HRESULT __cdecl wined3d_texture_get_overlay_position(const struct wined3d_texture *texture, unsigned int sub_resource_idx, LONG *x, LONG *y); void * __cdecl wined3d_texture_get_parent(const struct wined3d_texture *texture);