From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index d1bcaf39c14..3b829cdce3a 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27869,6 +27869,39 @@ static void test_managed_reset(void) release_test_context(&context); }
+static void test_managed_generate_mipmap(void) +{ + struct d3d9_test_context context; + IDirect3DTexture9 *texture; + IDirect3DDevice9 *device; + HRESULT hr; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 0, D3DUSAGE_AUTOGENMIPMAP, + D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + fill_texture(texture, 0x0000ff00, 0); + + IDirect3DTexture9_GenerateMipSubLevels(texture); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + draw_textured_quad(&context, texture); + check_rt_color_todo(context.backbuffer, 0x0000ff00); + + IDirect3DTexture9_Release(texture); + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -28021,4 +28054,5 @@ START_TEST(visual) test_dynamic_map_synchronization(); test_filling_convention(); test_managed_reset(); + test_managed_generate_mipmap(); }
From: Zebediah Figura zfigura@codeweavers.com
Instead of uploading all currently bound textures. Besides being redundant, this would generate mipmaps for an uninitialized texture, and subsequently trying to render from nonzero mipmap levels would yield uninitialized data.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54170 --- dlls/d3d9/d3d9_private.h | 1 - dlls/d3d9/device.c | 2 +- dlls/d3d9/tests/visual.c | 2 +- dlls/d3d9/texture.c | 4 +++- 4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index fe13f679db4..7dc32e6c12f 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -125,7 +125,6 @@ struct d3d9_device HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wined3d *wined3d, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode) DECLSPEC_HIDDEN; -void d3d9_device_upload_managed_textures(struct d3d9_device *device);
struct d3d9_resource { diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 55641670665..eddb2a0ebdd 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3010,7 +3010,7 @@ static HRESULT d3d9_device_upload_sysmem_index_buffer(struct d3d9_device *device return S_OK; }
-void d3d9_device_upload_managed_textures(struct d3d9_device *device) +static void d3d9_device_upload_managed_textures(struct d3d9_device *device) { const struct wined3d_stateblock_state *state = device->stateblock_state; unsigned int i; diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 3b829cdce3a..12619288587 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27896,7 +27896,7 @@ static void test_managed_generate_mipmap(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
draw_textured_quad(&context, texture); - check_rt_color_todo(context.backbuffer, 0x0000ff00); + check_rt_color(context.backbuffer, 0x0000ff00);
IDirect3DTexture9_Release(texture); release_test_context(&context); diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index e5b52fdcc82..0a27941ac2b 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -138,7 +138,9 @@ void d3d9_texture_gen_auto_mipmap(struct d3d9_texture *texture) if (!(texture->flags & D3D9_TEXTURE_MIPMAP_DIRTY)) return; d3d9_texture_acquire_shader_resource_view(texture); - d3d9_device_upload_managed_textures(texture->parent_device); + if (texture->draw_texture) + wined3d_device_update_texture(texture->parent_device->wined3d_device, + texture->wined3d_texture, texture->draw_texture); wined3d_device_context_generate_mipmaps(texture->parent_device->immediate_context, texture->wined3d_srv); texture->flags &= ~D3D9_TEXTURE_MIPMAP_DIRTY; }
This merge request was approved by Jan Sikorski.