From 9492a10f4438b3f7878250f3b3906e5dfc53ac6d Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 19 Mar 2024 15:54:03 -0600 Subject: [PATCH] wined3d: Factor out wined3d_texture_set_lod() function. --- dlls/wined3d/stateblock.c | 22 ++++------------------ dlls/wined3d/texture.c | 24 ++++++++++++++++++++++++ include/wine/wined3d.h | 1 + 3 files changed, 29 insertions(+), 18 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)) + old = wined3d_texture_set_lod(texture, lod); + + if (old != lod) { - 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; - - if (texture->lod != 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);