Skip to content

Commit

Permalink
The entireity of our wine ddraw is messed up and we should feel bad
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Apr 9, 2024
1 parent bc84861 commit 4e58eb0
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 385 deletions.
395 changes: 143 additions & 252 deletions dll/directx/wine/ddraw/ddraw.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dll/directx/wine/ddraw/ddraw_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct FvfToDecl
#define DDRAW_WINED3D_FLAGS (WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING \
| WINED3D_RESTORE_MODE_ON_ACTIVATE | WINED3D_FOCUS_MESSAGES | WINED3D_PIXEL_CENTER_INTEGER \
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART \
| WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT)
| WINED3D_LEGACY_CUBEMAP_FILTERING)

#define DDRAW_MAX_ACTIVE_LIGHTS 32

Expand Down Expand Up @@ -356,7 +356,7 @@ struct d3d_device
struct wined3d_stateblock *recording;
};

HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface,
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface,
UINT version, struct d3d_device **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN;
enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device *device) DECLSPEC_HIDDEN;

Expand Down
45 changes: 15 additions & 30 deletions dll/directx/wine/ddraw/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ static HRESULT d3d_device7_SetRenderTarget(IDirect3DDevice7 *iface,
return DDERR_INVALIDCAPS;
}

if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target_impl);
wined3d_mutex_unlock();
Expand Down Expand Up @@ -1930,7 +1930,7 @@ static HRESULT WINAPI d3d_device3_SetRenderTarget(IDirect3DDevice3 *iface,
return DDERR_INVALIDPIXELFORMAT;
}

if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target_impl);
IDirectDrawSurface4_AddRef(target);
Expand Down Expand Up @@ -1979,7 +1979,7 @@ static HRESULT WINAPI d3d_device2_SetRenderTarget(IDirect3DDevice2 *iface,
return DDERR_INVALIDPIXELFORMAT;
}

if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target_impl);
IDirectDrawSurface_AddRef(target);
Expand Down Expand Up @@ -2910,8 +2910,10 @@ static HRESULT WINAPI d3d_device3_SetLightState(IDirect3DDevice3 *iface,
wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS;
}

material_activate(m);
}

device->material = value;
}
else if (state == D3DLIGHTSTATE_COLORMODEL)
Expand Down Expand Up @@ -4792,8 +4794,7 @@ static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface,
struct ddraw_surface *surf = unsafe_impl_from_IDirectDrawSurface7(texture);
struct wined3d_texture *wined3d_texture = NULL;

TRACE("iface %p, stage %u, texture %p, surf %p, surf->surface_desc.ddsCaps.dwCaps %#x.\n",
iface, stage, texture, surf, surf ? surf->surface_desc.ddsCaps.dwCaps : 0);
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);

if (surf && (surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
wined3d_texture = surf->wined3d_texture;
Expand Down Expand Up @@ -4829,30 +4830,19 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
{
struct d3d_device *device = impl_from_IDirect3DDevice3(iface);
struct ddraw_surface *tex = unsafe_impl_from_IDirect3DTexture2(texture);
struct wined3d_texture *wined3d_texture;
HRESULT hr;

TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);

wined3d_mutex_lock();

if (tex && ((tex->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) || !device->hw))
{
if (!(tex->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
WARN("Setting texture without DDSCAPS_TEXTURE.\n");
wined3d_texture = tex->wined3d_texture;
}
else
{
wined3d_texture = NULL;
}

wined3d_device_set_texture(device->wined3d_device, stage, wined3d_texture);
hr = IDirect3DDevice7_SetTexture(&device->IDirect3DDevice7_iface, stage, &tex->IDirectDrawSurface7_iface);

fixup_texture_alpha_op(device);

wined3d_mutex_unlock();

return D3D_OK;
return hr;
}

static const struct tss_lookup
Expand Down Expand Up @@ -6943,7 +6933,7 @@ enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device
return WINED3D_ZB_TRUE;
}

static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, BOOL hw,
static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw,
struct ddraw_surface *target, IUnknown *rt_iface, UINT version, IUnknown *outer_unknown)
{
static const D3DMATRIX ident =
Expand All @@ -6966,7 +6956,6 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, B
device->IUnknown_inner.lpVtbl = &d3d_device_inner_vtbl;
device->ref = 1;
device->version = version;
device->hw = hw;

if (outer_unknown)
device->outer_unknown = outer_unknown;
Expand Down Expand Up @@ -7020,18 +7009,14 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, B
return D3D_OK;
}

HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface,
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface,
UINT version, struct d3d_device **device, IUnknown *outer_unknown)
{
struct d3d_device *object;
BOOL hw = TRUE;
HRESULT hr;

TRACE("ddraw %p, guid %s, target %p, version %u, device %p, outer_unknown %p.\n",
ddraw, debugstr_guid(guid), target, version, device, outer_unknown);

if (IsEqualGUID(guid, &IID_IDirect3DRGBDevice))
hw = FALSE;
TRACE("ddraw %p, target %p, version %u, device %p, outer_unknown %p.\n",
ddraw, target, version, device, outer_unknown);

if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
|| (target->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
Expand All @@ -7054,7 +7039,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_su
return DDERR_OUTOFMEMORY;
}

if (hw && !(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target);
return D3DERR_SURFACENOTINVIDMEM;
Expand All @@ -7072,7 +7057,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_su
return DDERR_OUTOFMEMORY;
}

if (FAILED(hr = d3d_device_init(object, ddraw, hw, target, rt_iface, version, outer_unknown)))
if (FAILED(hr = d3d_device_init(object, ddraw, target, rt_iface, version, outer_unknown)))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
heap_free(object);
Expand Down
5 changes: 1 addition & 4 deletions dll/directx/wine/ddraw/executebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
ci->wStart, ci->wDest, ci->dwCount, ci->dwFlags);

if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
{
static int once;
if (!once++) FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n");
}
FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n");
if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n");

Expand Down
4 changes: 1 addition & 3 deletions dll/directx/wine/ddraw/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
* an application would unload ddraw from the WM_DESTROY handler for
* that window, it would return to unmapped memory and die. Apparently
* this is supposed to work on Windows. */

/* ReactOS r61844: Comment out usage of GET_MODULE_HANDLE_EX_FLAG_PIN because it doesn't work */
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS /*| GET_MODULE_HANDLE_EX_FLAG_PIN*/,
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
(const WCHAR *)&ddraw_self, &ddraw_self))
ERR("Failed to get own module handle.\n");

Expand Down
2 changes: 1 addition & 1 deletion dll/directx/wine/ddraw/palette.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static HRESULT WINAPI ddraw_palette_GetEntries(IDirectDrawPalette *iface,
return hr;
}

static struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
{
/*** IUnknown ***/
ddraw_palette_QueryInterface,
Expand Down
Loading

0 comments on commit 4e58eb0

Please sign in to comment.