Add first patches for d3d10.

This commit is contained in:
Michael Müller 2014-08-22 23:01:03 +02:00
parent e2f3ff5808
commit 8d274db63d
6 changed files with 375 additions and 0 deletions

View File

@ -51,6 +51,7 @@ PATCHLIST := \
user32-WndProc.ok \
wineboot-HKEY_DYN_DATA.ok \
winebuild-LinkerVersion.ok \
wined3d10.ok \
winepulse-PulseAudio_Support.ok \
winex11-Limited_Resolutions.ok \
winex11-Window_Groups.ok \
@ -900,6 +901,25 @@ winebuild-LinkerVersion.ok:
echo '+ { "winebuild-LinkerVersion", "Michael Müller", "Set a valid major and minor linker version in the PE header." },'; \
) > winebuild-LinkerVersion.ok
# Patchset wined3d10
# |
# | Included patches:
# | * Experimental patches to improve d3d10 support. [by Michael Müller]
# |
# | Modified files:
# | * dlls/d3d10core/buffer.c, dlls/d3d10core/device.c, dlls/dxgi/dxgi_private.h, dlls/dxgi/factory.c, dlls/wined3d/device.c,
# | dlls/wined3d/resource.c, dlls/wined3d/wined3d.spec, include/wine/wined3d.h
# |
.INTERMEDIATE: wined3d10.ok
wined3d10.ok:
$(call APPLY_FILE,wined3d10/0001-dxgi-Improve-stubs-for-MakeWindowAssociation-and-Get.patch)
$(call APPLY_FILE,wined3d10/0002-d3d10core-Implement-UpdateSubresource-for-buffers.patch)
$(call APPLY_FILE,wined3d10/0003-d3d10core-Implement-usage-flag-conversion-in-d3d10_b.patch)
$(call APPLY_FILE,wined3d10/0004-d3d10core-Improve-depth-buffer-and-stencil-buffer-ha.patch)
@( \
echo '+ { "wined3d10", "Michael Müller", "Experimental patches to improve d3d10 support." },'; \
) > wined3d10.ok
# Patchset winepulse-PulseAudio_Support
# |
# | Included patches:

View File

@ -0,0 +1,61 @@
From 50344b75872b911b01ede2282d53d5fce4d68252 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 19 Aug 2014 22:47:51 +0200
Subject: dxgi: Improve stubs for MakeWindowAssociation and
GetWindowAssociation.
---
dlls/dxgi/dxgi_private.h | 1 +
dlls/dxgi/factory.c | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 75126cf..2f035ad 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -84,6 +84,7 @@ struct dxgi_factory
UINT adapter_count;
IWineDXGIAdapter **adapters;
BOOL extended;
+ HWND window;
};
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended) DECLSPEC_HIDDEN;
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index b75802b..8e99569 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -161,16 +161,28 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IWineDXGIFactory *ifa
static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IWineDXGIFactory *iface, HWND window, UINT flags)
{
+ struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
+
FIXME("iface %p, window %p, flags %#x stub!\n", iface, window, flags);
- return E_NOTIMPL;
+ if (!window && flags)
+ return DXGI_ERROR_INVALID_CALL;
+
+ factory->window = window;
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IWineDXGIFactory *iface, HWND *window)
{
+ struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
+
FIXME("iface %p, window %p stub!\n", iface, window);
- return E_NOTIMPL;
+ if (!window)
+ return DXGI_ERROR_INVALID_CALL;
+
+ *window = factory->window;
+ return S_OK;
}
static UINT dxgi_rational_to_uint(const DXGI_RATIONAL *rational)
--
1.9.1

View File

@ -0,0 +1,107 @@
From 526fa9da0f45b1bd01df63e60860b55cf9c8303d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 22 Aug 2014 20:32:53 +0200
Subject: d3d10core: Implement UpdateSubresource for buffers.
---
dlls/d3d10core/device.c | 20 +++++++++++++++++++-
dlls/wined3d/resource.c | 27 +++++++++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 2 ++
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index bb5265b..eef7e1b 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -548,8 +548,26 @@ static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *ifac
ID3D10Resource *resource, UINT subresource_idx, const D3D10_BOX *box,
const void *data, UINT row_pitch, UINT depth_pitch)
{
- FIXME("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
+ struct d3d10_device *device = impl_from_ID3D10Device(iface);
+ struct wined3d_resource* wined3d_resource;
+ struct wined3d_box wined3d_box;
+
+ TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u stub!\n",
iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
+
+ wined3d_resource = wined3d_resource_from_resource(resource);
+ if (box)
+ {
+ wined3d_box.left = box->left;
+ wined3d_box.top = box->top;
+ wined3d_box.front = box->front;
+ wined3d_box.right = box->right;
+ wined3d_box.bottom = box->bottom;
+ wined3d_box.back = box->back;
+ }
+
+ wined3d_resource_update(device->wined3d_device, wined3d_resource, subresource_idx,
+ box ? &wined3d_box : NULL, data, row_pitch, depth_pitch);
}
static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *iface,
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 4247cd7..3b934d8 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -333,3 +333,30 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
else
resource->draw_binding = WINED3D_LOCATION_TEXTURE_RGB;
}
+
+void CDECL wined3d_resource_update(struct wined3d_device *device, struct wined3d_resource *resource, UINT sub_resource_idx,
+ struct wined3d_box *box, const void *data, UINT row_pitch, UINT depth_pitch)
+{
+ struct wined3d_buffer *buffer;
+ BYTE *dest;
+
+ if (resource->type != WINED3D_RTYPE_BUFFER)
+ {
+ FIXME("Unsuported resource type: %d\n", resource->type);
+ return;
+ }
+
+ if (sub_resource_idx || box)
+ {
+ WARN("Subresource index and/or Box parameter is not supported for buffers\n");
+ return;
+ }
+
+ /* FIXME: should normally use the command stream here */
+ buffer = buffer_from_resource(resource);
+ if (SUCCEEDED(wined3d_buffer_map(buffer, 0, 0, &dest, 0)))
+ {
+ memcpy(dest, data, buffer->desc.byte_width); /* FIXME: is row_pitch and depth_pitch used? */
+ wined3d_buffer_unmap(buffer);
+ }
+}
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 0ee16c4..1904bc5 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -175,6 +175,7 @@
@ cdecl wined3d_resource_get_priority(ptr)
@ cdecl wined3d_resource_set_parent(ptr ptr)
@ cdecl wined3d_resource_set_priority(ptr long)
+@ cdecl wined3d_resource_update(ptr ptr long ptr ptr long long)
@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_rendertarget_view_create_from_surface(ptr ptr ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 6dda931..7a49b87 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2374,6 +2374,8 @@ void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resour
DWORD __cdecl wined3d_resource_get_priority(const struct wined3d_resource *resource);
void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent);
DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority);
+void __cdecl wined3d_resource_update(struct wined3d_device *device, struct wined3d_resource *resource, UINT sub_resource_idx,
+ struct wined3d_box *box, const void *data, UINT row_pitch, UINT depth_pitch);
HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
--
1.9.1

View File

@ -0,0 +1,43 @@
From 7f14ad95ae1d20d875c2ee945bfadeaa70a0aacb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 19 Aug 2014 23:04:02 +0200
Subject: d3d10core: Implement usage flag conversion in d3d10_buffer_init.
---
dlls/d3d10core/buffer.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d10core/buffer.c b/dlls/d3d10core/buffer.c
index b9ac6e1..51b227a 100644
--- a/dlls/d3d10core/buffer.c
+++ b/dlls/d3d10core/buffer.c
@@ -224,10 +224,23 @@ HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *devi
buffer->ID3D10Buffer_iface.lpVtbl = &d3d10_buffer_vtbl;
buffer->refcount = 1;
- FIXME("Implement DXGI<->wined3d usage conversion\n");
-
wined3d_desc.byte_width = desc->ByteWidth;
- wined3d_desc.usage = desc->Usage;
+ switch (desc->Usage)
+ {
+ case D3D10_USAGE_DYNAMIC:
+ wined3d_desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY;
+ break;
+ case D3D10_USAGE_STAGING:
+ wined3d_desc.usage = WINED3DUSAGE_DYNAMIC;
+ break;
+ case D3D10_USAGE_IMMUTABLE:
+ case D3D10_USAGE_DEFAULT:
+ wined3d_desc.usage = 0;
+ break;
+ default:
+ WARN("Invalid usage parameter: %d\n", desc->Usage);
+ return WINED3DERR_INVALIDCALL;
+ }
wined3d_desc.bind_flags = desc->BindFlags;
wined3d_desc.cpu_access_flags = desc->CPUAccessFlags;
wined3d_desc.misc_flags = desc->MiscFlags;
--
1.9.1

View File

@ -0,0 +1,141 @@
From aba7d294cc5ab566fc36b0a0e9b84b0390316b49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 22 Aug 2014 22:34:12 +0200
Subject: d3d10core: Improve depth buffer and stencil buffer handling.
---
dlls/d3d10core/device.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-
dlls/wined3d/device.c | 10 ++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 2 ++
4 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index eef7e1b..c10c06c 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -417,6 +417,26 @@ static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *ifa
dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
wined3d_device_set_depth_stencil_view(device->wined3d_device,
dsv ? dsv->wined3d_view : NULL);
+
+ /*
+ * DirectX 10 enables the depth buffer depending on the depth_stencil_view value
+ * as long as no explicit depth buffer state was set using OMSetDepthStencilState
+ * to disable the depth buffer test.
+ * The default values are described at:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/bb205036(v=vs.85).aspx
+ */
+ if (!device->depth_stencil_state)
+ {
+ wined3d_mutex_lock();
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE, dsv ? TRUE : FALSE);
+ wined3d_mutex_unlock();
+ }
+ else if (device->depth_stencil_state->desc.DepthEnable && !dsv)
+ {
+ wined3d_mutex_lock();
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE, FALSE);
+ wined3d_mutex_unlock();
+ }
}
static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface,
@@ -436,12 +456,26 @@ static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1
ID3D10DepthStencilState *depth_stencil_state, UINT stencil_ref)
{
struct d3d10_device *device = impl_from_ID3D10Device(iface);
+ D3D10_DEPTH_STENCIL_DESC *desc;
TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n",
iface, depth_stencil_state, stencil_ref);
device->depth_stencil_state = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state);
device->stencil_ref = stencil_ref;
+
+ desc = &device->depth_stencil_state->desc;
+
+ wined3d_mutex_lock();
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE, desc->DepthEnable);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZWRITEENABLE, (desc->DepthWriteMask == D3D10_DEPTH_WRITE_MASK_ALL));
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZFUNC, desc->DepthFunc); /* the enumeration is identical */
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILENABLE, desc->StencilEnable);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILMASK, desc->StencilReadMask);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILWRITEMASK, desc->StencilWriteMask);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_STENCILREF, device->stencil_ref);
+ /* TODO: set front face and backface stencil operations, otherwise the stencil buffer is quite useless */
+ wined3d_mutex_unlock();
}
static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface,
@@ -588,8 +622,20 @@ static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 *
static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface,
ID3D10DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil)
{
- FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
+ struct d3d10_device *device = impl_from_ID3D10Device(iface);
+ struct d3d10_depthstencil_view *view = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
+ int wined3d_flags = 0;
+
+ TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n",
iface, depth_stencil_view, flags, depth, stencil);
+
+ if (!depth_stencil_view)
+ return;
+
+ if (flags & D3D10_CLEAR_DEPTH) wined3d_flags = WINED3DCLEAR_ZBUFFER;
+ if (flags & D3D10_CLEAR_STENCIL) wined3d_flags |= WINED3DCLEAR_STENCIL;
+
+ wined3d_device_clear_depthstencil_view(device->wined3d_device, view->wined3d_view, wined3d_flags, depth, stencil);
}
static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 9df422f..8a2fa3b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3731,6 +3731,16 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
}
}
+void CDECL wined3d_device_clear_depthstencil_view(struct wined3d_device *device,
+ struct wined3d_rendertarget_view *view, int flags, float depth, DWORD stencil)
+{
+ struct wined3d_fb_state fb = {NULL, view};
+ const RECT draw_rect = {0, 0, view->width, view->height};
+
+ device_clear_render_targets(device, 0, &fb, 0, NULL, &draw_rect, flags, 0, depth, stencil);
+}
+
+
HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 1904bc5..7262366 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -36,6 +36,7 @@
@ cdecl wined3d_device_begin_scene(ptr)
@ cdecl wined3d_device_begin_stateblock(ptr)
@ cdecl wined3d_device_clear(ptr long ptr long ptr float long)
+@ cdecl wined3d_device_clear_depthstencil_view(ptr ptr long float long)
@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr ptr)
@ cdecl wined3d_device_copy_resource(ptr ptr ptr)
@ cdecl wined3d_device_create(ptr long long ptr long long ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 7a49b87..54b5eee 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2095,6 +2095,8 @@ HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags,
const struct wined3d_color *color, float z, DWORD stencil);
+void CDECL wined3d_device_clear_depthstencil_view(struct wined3d_device *device,
+ struct wined3d_rendertarget_view *view, int flags, float depth, DWORD stencil);
HRESULT __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color);
void __cdecl wined3d_device_copy_resource(struct wined3d_device *device,
--
1.9.1

View File

@ -0,0 +1,3 @@
Author: Michael Müller
Subject: Experimental patches to improve d3d10 support.
Revision: 1