Skip to content

Commit

Permalink
[WINESYNC] d3d9: Don't store currently used textures in the d3d9 device.
Browse files Browse the repository at this point in the history
The texture tracking in d3d9 was not correct for applications using
stateblocks.

Signed-off-by: Matteo Bruni <[email protected]>
Signed-off-by: Henri Verbeet <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>

wine commit id 6cfab2f7adf8d8a32b5fad6bf75f9859e6fa0b01 by Matteo Bruni <[email protected]>
  • Loading branch information
winesync authored and DarkFire01 committed Sep 12, 2023
1 parent cad494c commit d4916d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
1 change: 0 additions & 1 deletion dll/directx/wine/d3d9/d3d9_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ struct d3d9_device
UINT index_buffer_size;
UINT index_buffer_pos;

struct d3d9_texture *textures[D3D9_MAX_TEXTURE_UNITS];
struct d3d9_surface *render_targets[D3D_MAX_SIMULTANEOUS_RENDERTARGETS];

LONG device_state;
Expand Down
23 changes: 8 additions & 15 deletions dll/directx/wine/d3d9/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,6 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
device->device_state = D3D9_DEVICE_STATE_OK;
}

if (!device->d3d_parent->extended)
for (i = 0; i < ARRAY_SIZE(device->textures); ++i)
device->textures[i] = NULL;

rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, 0);
device->render_targets[0] = wined3d_rendertarget_view_get_sub_resource_parent(rtv);
for (i = 1; i < ARRAY_SIZE(device->render_targets); ++i)
Expand Down Expand Up @@ -2402,13 +2398,6 @@ static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD st
wined3d_mutex_lock();
hr = wined3d_device_set_texture(device->wined3d_device, stage,
texture_impl ? texture_impl->wined3d_texture : NULL);
if (SUCCEEDED(hr))
{
unsigned int i = stage >= D3DVERTEXTEXTURESAMPLER0 ? stage - D3DVERTEXTEXTURESAMPLER0 + 16 : stage;

if (stage < ARRAY_SIZE(device->textures))
device->textures[i] = texture_impl;
}
wined3d_mutex_unlock();

return hr;
Expand Down Expand Up @@ -2652,11 +2641,15 @@ static float WINAPI d3d9_device_GetNPatchMode(IDirect3DDevice9Ex *iface)
/* wined3d critical section must be taken by the caller. */
static void d3d9_generate_auto_mipmaps(struct d3d9_device *device)
{
unsigned int i;
struct wined3d_texture *texture;
unsigned int i, stage;

for (i = 0; i < ARRAY_SIZE(device->textures); ++i)
if (device->textures[i])
d3d9_texture_gen_auto_mipmap(device->textures[i]);
for (i = 0; i < D3D9_MAX_TEXTURE_UNITS; ++i)
{
stage = i >= 16 ? i - 16 + D3DVERTEXTEXTURESAMPLER0 : i;
if ((texture = wined3d_device_get_texture(device->wined3d_device, stage)))
d3d9_texture_gen_auto_mipmap(wined3d_texture_get_parent(texture));
}
}

static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface,
Expand Down

0 comments on commit d4916d3

Please sign in to comment.