https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9987f02917539e05268ba…
commit 9987f02917539e05268ba2ad11e62d24a3636972
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Thu Mar 8 13:15:18 2018 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Thu Mar 8 13:15:18 2018 +0100
[D3D8][D3D9][DDRAW][WINED3D] Sync with Wine Staging 3.3. CORE-14434
---
dll/directx/wine/d3d8/CMakeLists.txt | 4 +-
dll/directx/wine/d3d8/buffer.c | 55 +-
dll/directx/wine/d3d8/d3d8_main.c | 89 +-
dll/directx/wine/d3d8/d3d8_private.h | 63 +-
dll/directx/wine/d3d8/device.c | 202 ++-
dll/directx/wine/d3d8/directx.c | 22 +-
dll/directx/wine/d3d8/precomp.h | 13 +
dll/directx/wine/d3d8/shader.c | 12 +-
dll/directx/wine/d3d8/surface.c | 11 +-
dll/directx/wine/d3d8/swapchain.c | 11 +-
dll/directx/wine/d3d8/texture.c | 37 +-
dll/directx/wine/d3d8/vertexdeclaration.c | 18 +-
dll/directx/wine/d3d8/volume.c | 14 +-
dll/directx/wine/d3d9/CMakeLists.txt | 4 +-
dll/directx/wine/d3d9/buffer.c | 57 +-
dll/directx/wine/d3d9/d3d9_main.c | 12 +-
dll/directx/wine/d3d9/d3d9_private.h | 86 +-
dll/directx/wine/d3d9/device.c | 310 +++--
dll/directx/wine/d3d9/directx.c | 17 +-
dll/directx/wine/d3d9/precomp.h | 13 +
dll/directx/wine/d3d9/query.c | 5 +-
dll/directx/wine/d3d9/shader.c | 7 +-
dll/directx/wine/d3d9/stateblock.c | 5 +-
dll/directx/wine/d3d9/surface.c | 15 +-
dll/directx/wine/d3d9/swapchain.c | 11 +-
dll/directx/wine/d3d9/texture.c | 359 ++++--
dll/directx/wine/d3d9/vertexdeclaration.c | 33 +-
dll/directx/wine/d3d9/volume.c | 14 +-
dll/directx/wine/ddraw/CMakeLists.txt | 4 +-
dll/directx/wine/ddraw/clipper.c | 7 +-
dll/directx/wine/ddraw/ddraw.c | 244 +++-
dll/directx/wine/ddraw/ddraw_private.h | 38 +-
dll/directx/wine/ddraw/device.c | 104 +-
dll/directx/wine/ddraw/executebuffer.c | 70 +-
dll/directx/wine/ddraw/light.c | 7 +-
dll/directx/wine/ddraw/main.c | 36 +-
dll/directx/wine/ddraw/material.c | 10 +-
dll/directx/wine/ddraw/palette.c | 7 +-
dll/directx/wine/ddraw/precomp.h | 15 +
dll/directx/wine/ddraw/surface.c | 277 +++--
dll/directx/wine/ddraw/utils.c | 55 +-
dll/directx/wine/ddraw/vertexbuffer.c | 52 +-
dll/directx/wine/ddraw/viewport.c | 11 +-
dll/directx/wine/wined3d/CMakeLists.txt | 5 +-
dll/directx/wine/wined3d/arb_program_shader.c | 182 +--
dll/directx/wine/wined3d/ati_fragment_shader.c | 23 +-
dll/directx/wine/wined3d/buffer.c | 149 +--
dll/directx/wine/wined3d/context.c | 1436 ++++++++++++++++++----
dll/directx/wine/wined3d/cs.c | 209 +++-
dll/directx/wine/wined3d/device.c | 543 +++++---
dll/directx/wine/wined3d/directx.c | 417 ++++---
dll/directx/wine/wined3d/drawprim.c | 785 ------------
dll/directx/wine/wined3d/dxtn.c | 5 +-
dll/directx/wine/wined3d/gl_compat.c | 8 +
dll/directx/wine/wined3d/glsl_shader.c | 796 +++++-------
dll/directx/wine/wined3d/nvidia_texture_shader.c | 4 +
dll/directx/wine/wined3d/palette.c | 10 +-
dll/directx/wine/wined3d/precomp.h | 44 +
dll/directx/wine/wined3d/query.c | 134 +-
dll/directx/wine/wined3d/resource.c | 227 +++-
dll/directx/wine/wined3d/sampler.c | 7 +-
dll/directx/wine/wined3d/shader.c | 165 +--
dll/directx/wine/wined3d/shader_sm1.c | 9 +-
dll/directx/wine/wined3d/shader_sm4.c | 11 +-
dll/directx/wine/wined3d/state.c | 324 +++--
dll/directx/wine/wined3d/stateblock.c | 27 +-
dll/directx/wine/wined3d/surface.c | 684 +++++++----
dll/directx/wine/wined3d/swapchain.c | 64 +-
dll/directx/wine/wined3d/texture.c | 1263 ++++++++++++++-----
dll/directx/wine/wined3d/utils.c | 494 +++++++-
dll/directx/wine/wined3d/vertexdeclaration.c | 30 +-
dll/directx/wine/wined3d/view.c | 64 +-
dll/directx/wine/wined3d/wined3d.spec | 26 +-
dll/directx/wine/wined3d/wined3d_gl.h | 8 +-
dll/directx/wine/wined3d/wined3d_main.c | 37 +-
dll/directx/wine/wined3d/wined3d_private.h | 275 +++--
media/doc/README.WINE | 8 +-
sdk/include/reactos/wine/wined3d.h | 163 ++-
78 files changed, 7134 insertions(+), 3938 deletions(-)
diff --git a/dll/directx/wine/d3d8/CMakeLists.txt b/dll/directx/wine/d3d8/CMakeLists.txt
index bad1641fea..09d7a6c659 100644
--- a/dll/directx/wine/d3d8/CMakeLists.txt
+++ b/dll/directx/wine/d3d8/CMakeLists.txt
@@ -17,7 +17,7 @@ list(APPEND SOURCE
texture.c
vertexdeclaration.c
volume.c
- d3d8_private.h)
+ precomp.h)
add_library(d3d8 SHARED
${SOURCE}
@@ -28,5 +28,5 @@ add_library(d3d8 SHARED
set_module_type(d3d8 win32dll UNICODE)
target_link_libraries(d3d8 uuid wine)
add_importlibs(d3d8 d3dwine msvcrt kernel32 ntdll)
-add_pch(d3d8 d3d8_private.h SOURCE)
+add_pch(d3d8 precomp.h SOURCE)
add_cd_file(TARGET d3d8 DESTINATION reactos/system32 FOR all)
diff --git a/dll/directx/wine/d3d8/buffer.c b/dll/directx/wine/d3d8/buffer.c
index d778e58360..fb6b7bc1e9 100644
--- a/dll/directx/wine/d3d8/buffer.c
+++ b/dll/directx/wine/d3d8/buffer.c
@@ -16,8 +16,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static inline struct d3d8_vertexbuffer
*impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface)
{
return CONTAINING_RECORD(iface, struct d3d8_vertexbuffer,
IDirect3DVertexBuffer8_iface);
@@ -190,7 +193,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8
*iface, UINT
wined3d_box.right = offset + size;
wined3d_mutex_lock();
hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
- 0, &wined3d_map_desc, &wined3d_box, flags);
+ 0, &wined3d_map_desc, &wined3d_box,
wined3dmapflags_from_d3dmapflags(flags));
wined3d_mutex_unlock();
*data = wined3d_map_desc.data;
@@ -224,12 +227,12 @@ static HRESULT WINAPI
d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface,
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
+ desc->Format = D3DFMT_VERTEXDATA;
desc->Type = D3DRTYPE_VERTEXBUFFER;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->FVF = buffer->fvf;
- desc->Format = D3DFMT_VERTEXDATA;
return D3D_OK;
}
@@ -259,7 +262,7 @@ static void STDMETHODCALLTYPE
d3d8_vertexbuffer_wined3d_object_destroyed(void *p
{
struct d3d8_vertexbuffer *buffer = parent;
d3d8_resource_cleanup(&buffer->resource);
- HeapFree(GetProcessHeap(), 0, buffer);
+ heap_free(buffer);
}
static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
@@ -270,15 +273,30 @@ static const struct wined3d_parent_ops
d3d8_vertexbuffer_wined3d_parent_ops =
HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *device,
UINT size, DWORD usage, DWORD fvf, D3DPOOL pool)
{
+ struct wined3d_buffer_desc desc;
HRESULT hr;
+ if (pool == D3DPOOL_SCRATCH)
+ {
+ WARN("Vertex buffer with D3DPOOL_SCRATCH requested.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
buffer->IDirect3DVertexBuffer8_iface.lpVtbl = &Direct3DVertexBuffer8_Vtbl;
d3d8_resource_init(&buffer->resource);
buffer->fvf = fvf;
+ desc.byte_width = size;
+ desc.usage = usage & WINED3DUSAGE_MASK;
+ desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
wined3d_mutex_lock();
- hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage &
WINED3DUSAGE_MASK,
- (enum wined3d_pool)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops,
&buffer->wined3d_buffer);
+ hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer,
+ &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -473,7 +491,7 @@ static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8
*iface, UINT o
wined3d_box.right = offset + size;
wined3d_mutex_lock();
hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
- 0, &wined3d_map_desc, &wined3d_box, flags);
+ 0, &wined3d_map_desc, &wined3d_box,
wined3dmapflags_from_d3dmapflags(flags));
wined3d_mutex_unlock();
*data = wined3d_map_desc.data;
@@ -509,8 +527,8 @@ static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8
*iface,
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Type = D3DRTYPE_INDEXBUFFER;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
return D3D_OK;
@@ -541,7 +559,7 @@ static void STDMETHODCALLTYPE
d3d8_indexbuffer_wined3d_object_destroyed(void *pa
{
struct d3d8_indexbuffer *buffer = parent;
d3d8_resource_cleanup(&buffer->resource);
- HeapFree(GetProcessHeap(), 0, buffer);
+ heap_free(buffer);
}
static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
@@ -552,15 +570,26 @@ static const struct wined3d_parent_ops
d3d8_indexbuffer_wined3d_parent_ops =
HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *device,
UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
+ struct wined3d_buffer_desc desc;
HRESULT hr;
+ desc.byte_width = size;
+ desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
buffer->IDirect3DIndexBuffer8_iface.lpVtbl = &d3d8_indexbuffer_vtbl;
d3d8_resource_init(&buffer->resource);
buffer->format = wined3dformat_from_d3dformat(format);
wined3d_mutex_lock();
- hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage &
WINED3DUSAGE_MASK,
- (enum wined3d_pool)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops,
&buffer->wined3d_buffer);
+ hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer,
+ &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
wined3d_mutex_unlock();
if (FAILED(hr))
{
diff --git a/dll/directx/wine/d3d8/d3d8_main.c b/dll/directx/wine/d3d8/d3d8_main.c
index 144817a545..0e686308f0 100644
--- a/dll/directx/wine/d3d8/d3d8_main.c
+++ b/dll/directx/wine/d3d8/d3d8_main.c
@@ -19,7 +19,12 @@
*
*/
+#include "config.h"
+#include "initguid.h"
#include "d3d8_private.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
HRESULT WINAPI D3D8GetSWInfo(void) {
FIXME("(void): stub\n");
@@ -36,13 +41,13 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT
sdk_version)
TRACE("sdk_version %#x.\n", sdk_version);
- if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return NULL;
if (!d3d8_init(object))
{
WARN("Failed to initialize d3d8.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return NULL;
}
@@ -53,75 +58,73 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT
sdk_version)
/***********************************************************************
* ValidateVertexShader (D3D8.@)
- *
- * I've seen reserved1 and reserved2 always passed as 0's
- * bool seems always passed as 0 or 1, but other values work as well...
- * toto result?
*/
-HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD*
reserved2, BOOL bool, DWORD* toto)
+HRESULT WINAPI ValidateVertexShader(DWORD *vertexshader, DWORD *reserved1, DWORD
*reserved2,
+ BOOL return_error, char **errors)
{
- HRESULT ret;
- static BOOL warned;
-
- if (TRACE_ON(d3d8) || !warned) {
- FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2,
bool, toto);
- warned = TRUE;
- }
+ const char *message = "";
+ HRESULT hr = E_FAIL;
- if (!vertexshader)
- return E_FAIL;
+ TRACE("(%p %p %p %d %p): semi-stub\n", vertexshader, reserved1, reserved2,
return_error, errors);
- if (reserved1 || reserved2)
- return E_FAIL;
+ if (!vertexshader)
+ {
+ message = "(Global Validation Error) Version Token: Code pointer cannot be
NULL.\n";
+ goto done;
+ }
- switch(*vertexshader) {
+ switch (*vertexshader)
+ {
case 0xFFFE0101:
case 0xFFFE0100:
- ret=S_OK;
+ hr = S_OK;
break;
+
default:
WARN("Invalid shader version token %#x.\n", *vertexshader);
- ret=E_FAIL;
- }
+ message = "(Global Validation Error) Version Token: Unsupported vertex
shader version.\n";
+ }
- return ret;
+done:
+ if (!return_error) message = "";
+ if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, strlen(message) +
1)))
+ strcpy(*errors, message);
+
+ return hr;
}
/***********************************************************************
* ValidatePixelShader (D3D8.@)
- *
- * PARAMS
- * toto result?
*/
-HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bool,
DWORD* toto)
+HRESULT WINAPI ValidatePixelShader(DWORD *pixelshader, DWORD *reserved1, BOOL
return_error, char **errors)
{
- HRESULT ret;
- static BOOL warned;
-
- if (TRACE_ON(d3d8) || !warned) {
- FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto);
- warned = TRUE;
- }
+ const char *message = "";
+ HRESULT hr = E_FAIL;
- if (!pixelshader)
- return E_FAIL;
+ TRACE("(%p %p %d %p): semi-stub\n", pixelshader, reserved1, return_error,
errors);
- if (reserved1)
- return E_FAIL;
+ if (!pixelshader)
+ return E_FAIL;
- switch(*pixelshader) {
+ switch (*pixelshader)
+ {
case 0xFFFF0100:
case 0xFFFF0101:
case 0xFFFF0102:
case 0xFFFF0103:
case 0xFFFF0104:
- ret=S_OK;
+ hr = S_OK;
break;
default:
WARN("Invalid shader version token %#x.\n", *pixelshader);
- ret=E_FAIL;
- }
- return ret;
+ message = "(Global Validation Error) Version Token: Unsupported pixel
shader version.\n";
+ }
+
+ if (!return_error) message = "";
+ if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, strlen(message) +
1)))
+ strcpy(*errors, message);
+
+ return hr;
}
void d3d8_resource_cleanup(struct d3d8_resource *resource)
diff --git a/dll/directx/wine/d3d8/d3d8_private.h b/dll/directx/wine/d3d8/d3d8_private.h
index a85e2995cb..cba5dd647b 100644
--- a/dll/directx/wine/d3d8/d3d8_private.h
+++ b/dll/directx/wine/d3d8/d3d8_private.h
@@ -23,27 +23,19 @@
#ifndef __WINE_D3D8_PRIVATE_H
#define __WINE_D3D8_PRIVATE_H
-#include <config.h>
-
#include <assert.h>
#include <stdarg.h>
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
-#include <windef.h>
-#include <winbase.h>
-#include <wingdi.h>
-
-#include <wine/debug.h>
-WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-
-#include <d3d8.h>
-#include <wine/wined3d.h>
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+#include "wine/heap.h"
+#include "d3d8.h"
+#include "wine/wined3d.h"
#define D3DPRESENTFLAGS_MASK 0x00000fffu
@@ -281,7 +273,48 @@ HRESULT d3d8_pixel_shader_init(struct d3d8_pixel_shader *shader,
struct d3d8_dev
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
+unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDEN;
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader
*wined3d_vertex_shader) DECLSPEC_HIDDEN;
size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN;
+static inline DWORD d3dusage_from_wined3dusage(unsigned int usage)
+{
+ return usage & WINED3DUSAGE_MASK;
+}
+
+static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int
usage)
+{
+ switch (access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU))
+ {
+ default:
+ case WINED3D_RESOURCE_ACCESS_GPU:
+ return D3DPOOL_DEFAULT;
+ case WINED3D_RESOURCE_ACCESS_CPU:
+ if (usage & WINED3DUSAGE_SCRATCH)
+ return D3DPOOL_SCRATCH;
+ return D3DPOOL_SYSTEMMEM;
+ case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU:
+ return D3DPOOL_MANAGED;
+ }
+}
+
+static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage)
+{
+ switch (pool)
+ {
+ case D3DPOOL_DEFAULT:
+ if (usage & D3DUSAGE_DYNAMIC)
+ return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ return WINED3D_RESOURCE_ACCESS_GPU;
+ case D3DPOOL_MANAGED:
+ return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+ case D3DPOOL_SYSTEMMEM:
+ case D3DPOOL_SCRATCH:
+ return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ default:
+ return 0;
+ }
+}
+
#endif /* __WINE_D3DX8_PRIVATE_H */
diff --git a/dll/directx/wine/d3d8/device.c b/dll/directx/wine/d3d8/device.c
index 6573baa355..5daf6f46c2 100644
--- a/dll/directx/wine/d3d8/device.c
+++ b/dll/directx/wine/d3d8/device.c
@@ -19,8 +19,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+
+#include <math.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static void STDMETHODCALLTYPE d3d8_null_wined3d_object_destroyed(void *parent) {}
static const struct wined3d_parent_ops d3d8_null_wined3d_parent_ops =
@@ -128,6 +141,29 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT
format)
}
}
+unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags)
+{
+ static const unsigned int handled = D3DLOCK_NOSYSLOCK
+ | D3DLOCK_NOOVERWRITE
+ | D3DLOCK_DISCARD
+ | D3DLOCK_NO_DIRTY_UPDATE;
+ unsigned int wined3d_flags;
+
+ wined3d_flags = flags & handled;
+ if (!(flags & (D3DLOCK_NOOVERWRITE | D3DLOCK_DISCARD)))
+ wined3d_flags |= WINED3D_MAP_READ;
+ if (!(flags & D3DLOCK_READONLY))
+ wined3d_flags |= WINED3D_MAP_WRITE;
+ if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE)))
+ wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE;
+ flags &= ~(handled | D3DLOCK_READONLY);
+
+ if (flags)
+ FIXME("Unhandled flags %#x.\n", flags);
+
+ return wined3d_flags;
+}
+
static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT
primitive_count)
{
switch (primitive_type)
@@ -154,6 +190,24 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE
primitive_type, U
}
}
+static D3DSWAPEFFECT d3dswapeffect_from_wined3dswapeffect(enum wined3d_swap_effect
effect)
+{
+ switch (effect)
+ {
+ case WINED3D_SWAP_EFFECT_DISCARD:
+ return D3DSWAPEFFECT_DISCARD;
+ case WINED3D_SWAP_EFFECT_SEQUENTIAL:
+ return D3DSWAPEFFECT_FLIP;
+ case WINED3D_SWAP_EFFECT_COPY:
+ return D3DSWAPEFFECT_COPY;
+ case WINED3D_SWAP_EFFECT_COPY_VSYNC:
+ return D3DSWAPEFFECT_COPY_VSYNC;
+ default:
+ FIXME("Unhandled swap effect %#x.\n", effect);
+ return D3DSWAPEFFECT_FLIP;
+ }
+}
+
static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS
*present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc)
{
@@ -162,7 +216,7 @@ static void
present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS
present_parameters->BackBufferFormat =
d3dformat_from_wined3dformat(swapchain_desc->backbuffer_format);
present_parameters->BackBufferCount = swapchain_desc->backbuffer_count;
present_parameters->MultiSampleType = swapchain_desc->multisample_type;
- present_parameters->SwapEffect = swapchain_desc->swap_effect;
+ present_parameters->SwapEffect =
d3dswapeffect_from_wined3dswapeffect(swapchain_desc->swap_effect);
present_parameters->hDeviceWindow = swapchain_desc->device_window;
present_parameters->Windowed = swapchain_desc->windowed;
present_parameters->EnableAutoDepthStencil =
swapchain_desc->enable_auto_depth_stencil;
@@ -173,6 +227,24 @@ static void
present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS
present_parameters->FullScreen_PresentationInterval =
swapchain_desc->swap_interval;
}
+static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFECT
effect)
+{
+ switch (effect)
+ {
+ case D3DSWAPEFFECT_DISCARD:
+ return WINED3D_SWAP_EFFECT_DISCARD;
+ case D3DSWAPEFFECT_FLIP:
+ return WINED3D_SWAP_EFFECT_SEQUENTIAL;
+ case D3DSWAPEFFECT_COPY:
+ return WINED3D_SWAP_EFFECT_COPY;
+ case D3DSWAPEFFECT_COPY_VSYNC:
+ return WINED3D_SWAP_EFFECT_COPY_VSYNC;
+ default:
+ FIXME("Unhandled swap effect %#x.\n", effect);
+ return WINED3D_SWAP_EFFECT_SEQUENTIAL;
+ }
+}
+
static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc
*swapchain_desc,
const D3DPRESENT_PARAMETERS *present_parameters)
{
@@ -194,9 +266,10 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct
wined3d_swapch
swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight;
swapchain_desc->backbuffer_format =
wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
swapchain_desc->backbuffer_count = max(1,
present_parameters->BackBufferCount);
+ swapchain_desc->backbuffer_usage = WINED3DUSAGE_RENDERTARGET;
swapchain_desc->multisample_type = present_parameters->MultiSampleType;
swapchain_desc->multisample_quality = 0; /* d3d9 only */
- swapchain_desc->swap_effect = present_parameters->SwapEffect;
+ swapchain_desc->swap_effect =
wined3dswapeffect_from_d3dswapeffect(present_parameters->SwapEffect);
swapchain_desc->device_window = present_parameters->hDeviceWindow;
swapchain_desc->windowed = present_parameters->Windowed;
swapchain_desc->enable_auto_depth_stencil =
present_parameters->EnableAutoDepthStencil;
@@ -310,9 +383,9 @@ static DWORD d3d8_allocate_handle(struct d3d8_handle_table *t, void
*object, enu
{
/* Grow the table */
UINT new_size = t->table_size + (t->table_size >> 1);
- struct d3d8_handle_entry *new_entries = HeapReAlloc(GetProcessHeap(),
- 0, t->entries, new_size * sizeof(*t->entries));
- if (!new_entries)
+ struct d3d8_handle_entry *new_entries;
+
+ if (!(new_entries = heap_realloc(t->entries, new_size *
sizeof(*t->entries))))
{
ERR("Failed to grow the handle table.\n");
return D3D8_INVALID_HANDLE;
@@ -430,7 +503,7 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
{
d3d8_vertex_declaration_destroy(device->decls[i].declaration);
}
- HeapFree(GetProcessHeap(), 0, device->decls);
+ heap_free(device->decls);
if (device->vertex_buffer)
wined3d_buffer_decref(device->vertex_buffer);
@@ -440,8 +513,8 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
wined3d_device_uninit_3d(device->wined3d_device);
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
- HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
- HeapFree(GetProcessHeap(), 0, device);
+ heap_free(device->handle_table.entries);
+ heap_free(device);
wined3d_mutex_unlock();
@@ -672,7 +745,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource
*resource)
IUnknown *parent;
wined3d_resource_get_desc(resource, &desc);
- if (desc.pool != WINED3D_POOL_DEFAULT)
+ if (desc.access & WINED3D_RESOURCE_ACCESS_CPU)
return D3D_OK;
if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
@@ -849,15 +922,14 @@ static HRESULT WINAPI d3d8_device_CreateTexture(IDirect3DDevice8
*iface,
return D3DERR_INVALIDCALL;
*texture = NULL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = texture_init(object, device, width, height, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize texture, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -882,15 +954,14 @@ static HRESULT WINAPI
d3d8_device_CreateVolumeTexture(IDirect3DDevice8 *iface,
return D3DERR_INVALIDCALL;
*texture = NULL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = volumetexture_init(object, device, width, height, depth, levels, usage, format,
pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume texture, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -914,15 +985,14 @@ static HRESULT WINAPI d3d8_device_CreateCubeTexture(IDirect3DDevice8
*iface, UIN
return D3DERR_INVALIDCALL;
*texture = NULL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = cubetexture_init(object, device, edge_length, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize cube texture, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -942,15 +1012,14 @@ static HRESULT WINAPI
d3d8_device_CreateVertexBuffer(IDirect3DDevice8 *iface, UI
TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p.\n",
iface, size, usage, fvf, pool, buffer);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = vertexbuffer_init(object, device, size, usage, fvf, pool);
if (FAILED(hr))
{
WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -970,15 +1039,14 @@ static HRESULT WINAPI
d3d8_device_CreateIndexBuffer(IDirect3DDevice8 *iface, UIN
TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p.\n",
iface, size, usage, format, pool, buffer);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = indexbuffer_init(object, device, size, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize index buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1007,7 +1075,10 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device
*device, UINT width
desc.multisample_type = multisample_type;
desc.multisample_quality = multisample_quality;
desc.usage = usage & WINED3DUSAGE_MASK;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.width = width;
desc.height = height;
desc.depth = 1;
@@ -2092,15 +2163,22 @@ static HRESULT d3d8_device_prepare_vertex_buffer(struct
d3d8_device *device, UIN
if (device->vertex_buffer_size < min_size || !device->vertex_buffer)
{
UINT size = max(device->vertex_buffer_size * 2, min_size);
+ struct wined3d_buffer_desc desc;
struct wined3d_buffer *buffer;
TRACE("Growing vertex buffer to %u bytes\n", size);
- hr = wined3d_buffer_create_vb(device->wined3d_device, size,
WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
- WINED3D_POOL_DEFAULT, NULL, &d3d8_null_wined3d_parent_ops,
&buffer);
- if (FAILED(hr))
+ desc.byte_width = size;
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY;
+ desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
+ NULL, NULL, &d3d8_null_wined3d_parent_ops, &buffer)))
{
- ERR("(%p) wined3d_buffer_create_vb failed with hr = %08x\n",
device, hr);
+ ERR("Failed to create vertex buffer, hr %#x.\n", hr);
return hr;
}
@@ -2153,7 +2231,7 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8
*iface,
wined3d_box.right = vb_pos + size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, data, size);
wined3d_resource_unmap(vb, 0);
@@ -2180,15 +2258,22 @@ static HRESULT d3d8_device_prepare_index_buffer(struct d3d8_device
*device, UINT
if (device->index_buffer_size < min_size || !device->index_buffer)
{
UINT size = max(device->index_buffer_size * 2, min_size);
+ struct wined3d_buffer_desc desc;
struct wined3d_buffer *buffer;
TRACE("Growing index buffer to %u bytes\n", size);
- hr = wined3d_buffer_create_ib(device->wined3d_device, size,
WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
- WINED3D_POOL_DEFAULT, NULL, &d3d8_null_wined3d_parent_ops,
&buffer);
- if (FAILED(hr))
+ desc.byte_width = size;
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY |
WINED3DUSAGE_STATICDECL;
+ desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
+ NULL, NULL, &d3d8_null_wined3d_parent_ops, &buffer)))
{
- ERR("(%p) wined3d_buffer_create_ib failed with hr = %08x\n",
device, hr);
+ ERR("Failed to create index buffer, hr %#x.\n", hr);
return hr;
}
@@ -2247,7 +2332,7 @@ static HRESULT WINAPI
d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride,
vtx_size);
wined3d_resource_unmap(vb, 0);
@@ -2269,7 +2354,7 @@ static HRESULT WINAPI
d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, index_data, idx_size);
wined3d_resource_unmap(ib, 0);
@@ -2325,8 +2410,7 @@ static HRESULT WINAPI
d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface,
TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#x.\n",
iface, declaration, byte_code, shader, usage);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
*shader = 0;
return E_OUTOFMEMORY;
@@ -2338,7 +2422,7 @@ static HRESULT WINAPI
d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface,
if (handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate vertex shader handle.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
*shader = 0;
return E_OUTOFMEMORY;
}
@@ -2352,7 +2436,7 @@ static HRESULT WINAPI
d3d8_device_CreateVertexShader(IDirect3DDevice8 *iface,
wined3d_mutex_lock();
d3d8_free_handle(&device->handle_table, handle, D3D8_HANDLE_VS);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
*shader = 0;
return hr;
}
@@ -2392,13 +2476,13 @@ static struct d3d8_vertex_declaration
*d3d8_device_get_fvf_declaration(struct d3
}
TRACE("not found. Creating and inserting at position %d.\n", low);
- if (!(d3d8_declaration = HeapAlloc(GetProcessHeap(), 0, sizeof(*d3d8_declaration))))
+ if (!(d3d8_declaration = heap_alloc(sizeof(*d3d8_declaration))))
return NULL;
if (FAILED(hr = d3d8_vertex_declaration_init_fvf(d3d8_declaration, device, fvf)))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, d3d8_declaration);
+ heap_free(d3d8_declaration);
return NULL;
}
@@ -2406,9 +2490,8 @@ static struct d3d8_vertex_declaration
*d3d8_device_get_fvf_declaration(struct d3
{
UINT grow = device->declArraySize / 2;
- convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
- sizeof(*convertedDecls) * (device->numConvertedDecls + grow));
- if (!convertedDecls)
+ if (!(convertedDecls = heap_realloc(convertedDecls,
+ sizeof(*convertedDecls) * (device->numConvertedDecls + grow))))
{
d3d8_vertex_declaration_destroy(d3d8_declaration);
return NULL;
@@ -2703,8 +2786,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8
*iface,
if (!shader)
return D3DERR_INVALIDCALL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_mutex_lock();
@@ -2713,7 +2795,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8
*iface,
if (handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate pixel shader handle.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return E_OUTOFMEMORY;
}
@@ -2726,7 +2808,7 @@ static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8
*iface,
wined3d_mutex_lock();
d3d8_free_handle(&device->handle_table, handle, D3D8_HANDLE_PS);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
*shader = 0;
return hr;
}
@@ -3089,7 +3171,7 @@ static HRESULT CDECL device_parent_surface_created(struct
wined3d_device_parent
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p,
parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
- if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*d3d_surface))))
+ if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
@@ -3108,7 +3190,7 @@ static HRESULT CDECL device_parent_volume_created(struct
wined3d_device_parent *
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops
%p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
- if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*d3d_volume))))
+ if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
@@ -3204,9 +3286,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent,
struct wine
device->IDirect3DDevice8_iface.lpVtbl = &d3d8_device_vtbl;
device->device_parent.ops = &d3d8_wined3d_device_parent_ops;
device->ref = 1;
- device->handle_table.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- D3D8_INITIAL_HANDLE_TABLE_SIZE * sizeof(*device->handle_table.entries));
- if (!device->handle_table.entries)
+ if (!(device->handle_table.entries =
heap_alloc_zero(D3D8_INITIAL_HANDLE_TABLE_SIZE
+ * sizeof(*device->handle_table.entries))))
{
ERR("Failed to allocate handle table memory.\n");
return E_OUTOFMEMORY;
@@ -3222,7 +3303,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent,
struct wine
{
WARN("Failed to create wined3d device, hr %#x.\n", hr);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
+ heap_free(device->handle_table.entries);
return hr;
}
@@ -3237,7 +3318,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent,
struct wine
ERR("Failed to acquire focus window, hr %#x.\n", hr);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
+ heap_free(device->handle_table.entries);
return hr;
}
@@ -3256,7 +3337,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent,
struct wine
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
+ heap_free(device->handle_table.entries);
return D3DERR_INVALIDCALL;
}
@@ -3266,7 +3347,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent,
struct wine
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
+ heap_free(device->handle_table.entries);
return hr;
}
@@ -3278,8 +3359,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent,
struct wine
present_parameters_from_wined3d_swapchain_desc(parameters, &swapchain_desc);
device->declArraySize = 16;
- device->decls = HeapAlloc(GetProcessHeap(), 0, device->declArraySize *
sizeof(*device->decls));
- if (!device->decls)
+ if (!(device->decls = heap_alloc(device->declArraySize *
sizeof(*device->decls))))
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
hr = E_OUTOFMEMORY;
@@ -3300,6 +3380,6 @@ err:
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
+ heap_free(device->handle_table.entries);
return hr;
}
diff --git a/dll/directx/wine/d3d8/directx.c b/dll/directx/wine/d3d8/directx.c
index ffb8ddefb4..6e8f93a25c 100644
--- a/dll/directx/wine/d3d8/directx.c
+++ b/dll/directx/wine/d3d8/directx.c
@@ -20,8 +20,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static inline struct d3d8 *impl_from_IDirect3D8(IDirect3D8 *iface)
{
return CONTAINING_RECORD(iface, struct d3d8, IDirect3D8_iface);
@@ -68,7 +81,7 @@ static ULONG WINAPI d3d8_Release(IDirect3D8 *iface)
wined3d_decref(d3d8->wined3d);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, d3d8);
+ heap_free(d3d8);
}
return refcount;
@@ -360,15 +373,14 @@ static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT
adapter,
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x,
parameters %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, device);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = device_init(object, d3d8, d3d8->wined3d, adapter, device_type, focus_window,
flags, parameters);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -405,7 +417,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING
| WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART
- | WINED3D_LEGACY_CUBEMAP_FILTERING;
+ | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT;
d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
d3d8->refcount = 1;
diff --git a/dll/directx/wine/d3d8/precomp.h b/dll/directx/wine/d3d8/precomp.h
new file mode 100644
index 0000000000..17c27cb718
--- /dev/null
+++ b/dll/directx/wine/d3d8/precomp.h
@@ -0,0 +1,13 @@
+
+#ifndef __WINE_D3D8_PRECOMP_H
+#define __WINE_D3D8_PRECOMP_H
+
+#include <wine/config.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#include "d3d8_private.h"
+
+#endif /* __WINE_D3D8_PRECOMP_H */
diff --git a/dll/directx/wine/d3d8/shader.c b/dll/directx/wine/d3d8/shader.c
index d0361a9e83..8192b238eb 100644
--- a/dll/directx/wine/d3d8/shader.c
+++ b/dll/directx/wine/d3d8/shader.c
@@ -17,13 +17,16 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
{
struct d3d8_vertex_shader *shader = parent;
d3d8_vertex_declaration_destroy(shader->vertex_declaration);
- HeapFree(GetProcessHeap(), 0, shader);
+ heap_free(shader);
}
void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader)
@@ -56,15 +59,14 @@ static HRESULT d3d8_vertexshader_create_vertexdeclaration(struct
d3d8_device *de
TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n",
device, declaration, shader_handle, decl_ptr);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = d3d8_vertex_declaration_init(object, device, declaration, shader_handle);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -140,7 +142,7 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader,
struct d3d8_d
static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
{
- HeapFree(GetProcessHeap(), 0, parent);
+ heap_free(parent);
}
void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
diff --git a/dll/directx/wine/d3d8/surface.c b/dll/directx/wine/d3d8/surface.c
index 545361644b..fff47f5ca1 100644
--- a/dll/directx/wine/d3d8/surface.c
+++ b/dll/directx/wine/d3d8/surface.c
@@ -18,8 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static inline struct d3d8_surface *impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
{
return CONTAINING_RECORD(iface, struct d3d8_surface, IDirect3DSurface8_iface);
@@ -188,8 +191,8 @@ static HRESULT WINAPI d3d8_surface_GetDesc(IDirect3DSurface8 *iface,
D3DSURFACE_
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_SURFACE;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->Width = wined3d_desc.width;
@@ -241,7 +244,7 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface,
}
hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture),
surface->sub_resource_idx,
- &map_desc, rect ? &box : NULL, flags);
+ &map_desc, rect ? &box : NULL,
wined3dmapflags_from_d3dmapflags(flags));
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
@@ -303,7 +306,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void
*parent)
{
struct d3d8_surface *surface = parent;
d3d8_resource_cleanup(&surface->resource);
- HeapFree(GetProcessHeap(), 0, surface);
+ heap_free(surface);
}
static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
diff --git a/dll/directx/wine/d3d8/swapchain.c b/dll/directx/wine/d3d8/swapchain.c
index d82a8ed657..3a588b5e8c 100644
--- a/dll/directx/wine/d3d8/swapchain.c
+++ b/dll/directx/wine/d3d8/swapchain.c
@@ -18,8 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static inline struct d3d8_swapchain *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8
*iface)
{
return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface);
@@ -102,7 +105,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d8_swapchain_Present(IDirect3DSwapChai
wined3d_mutex_lock();
hr = wined3d_swapchain_present(swapchain->wined3d_swapchain,
- src_rect, dst_rect, dst_window_override, 0);
+ src_rect, dst_rect, dst_window_override, 0, 0);
wined3d_mutex_unlock();
return hr;
@@ -155,7 +158,7 @@ static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl =
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
{
- HeapFree(GetProcessHeap(), 0, parent);
+ heap_free(parent);
}
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
@@ -194,13 +197,13 @@ HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct
wined3d_swapcha
struct d3d8_swapchain *object;
HRESULT hr;
- if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc)))
{
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
diff --git a/dll/directx/wine/d3d8/texture.c b/dll/directx/wine/d3d8/texture.c
index b860859987..87a2575cb1 100644
--- a/dll/directx/wine/d3d8/texture.c
+++ b/dll/directx/wine/d3d8/texture.c
@@ -16,21 +16,24 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static inline struct d3d8_texture *impl_from_IDirect3DTexture8(IDirect3DTexture8 *iface)
{
- return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface);
+ return CONTAINING_RECORD((IDirect3DBaseTexture8 *)iface, struct d3d8_texture,
IDirect3DBaseTexture8_iface);
}
static inline struct d3d8_texture *impl_from_IDirect3DCubeTexture8(IDirect3DCubeTexture8
*iface)
{
- return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface);
+ return CONTAINING_RECORD((IDirect3DBaseTexture8 *)iface, struct d3d8_texture,
IDirect3DBaseTexture8_iface);
}
static inline struct d3d8_texture
*impl_from_IDirect3DVolumeTexture8(IDirect3DVolumeTexture8 *iface)
{
- return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface);
+ return CONTAINING_RECORD((IDirect3DBaseTexture8 *)iface, struct d3d8_texture,
IDirect3DBaseTexture8_iface);
}
static HRESULT WINAPI d3d8_texture_2d_QueryInterface(IDirect3DTexture8 *iface, REFIID
riid, void **out)
@@ -250,8 +253,8 @@ static HRESULT WINAPI d3d8_texture_2d_GetLevelDesc(IDirect3DTexture8
*iface, UIN
{
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_SURFACE;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access,
wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->Width = wined3d_desc.width;
@@ -597,8 +600,8 @@ static HRESULT WINAPI
d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8 *ifac
{
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_SURFACE;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access,
wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->Width = wined3d_desc.width;
@@ -942,8 +945,8 @@ static HRESULT WINAPI
d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8 *ifac
{
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_VOLUME;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access,
wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
@@ -1080,7 +1083,7 @@ static void STDMETHODCALLTYPE
d3d8_texture_wined3d_object_destroyed(void *parent
{
struct d3d8_texture *texture = parent;
d3d8_resource_cleanup(&texture->resource);
- HeapFree(GetProcessHeap(), 0, texture);
+ heap_free(texture);
}
static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops =
@@ -1105,7 +1108,10 @@ HRESULT texture_init(struct d3d8_texture *texture, struct
d3d8_device *device,
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_TEXTURE;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.width = width;
desc.height = height;
desc.depth = 1;
@@ -1150,7 +1156,10 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct
d3d8_device *devic
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.width = edge_length;
desc.height = edge_length;
desc.depth = 1;
@@ -1194,7 +1203,9 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct
d3d8_device *dev
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_TEXTURE;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage);
desc.width = width;
desc.height = height;
desc.depth = depth;
diff --git a/dll/directx/wine/d3d8/vertexdeclaration.c
b/dll/directx/wine/d3d8/vertexdeclaration.c
index e01230e5ae..0cae3cd8c6 100644
--- a/dll/directx/wine/d3d8/vertexdeclaration.c
+++ b/dll/directx/wine/d3d8/vertexdeclaration.c
@@ -21,8 +21,11 @@
/* IDirect3DVertexDeclaration8 is internal to our implementation.
* It's not visible in the API. */
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static const char *debug_d3dvsdt_type(D3DVSDT_TYPE d3dvsdt_type)
{
switch (d3dvsdt_type)
@@ -263,7 +266,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements,
DWORD *d3
TRACE("d3d8_elements %p, d3d8_elements_size %p, wined3d_elements %p\n",
d3d8_elements, d3d8_elements_size, wined3d_elements);
/* 128 should be enough for anyone... */
- *wined3d_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 *
sizeof(**wined3d_elements));
+ *wined3d_elements = heap_alloc_zero(128 * sizeof(**wined3d_elements));
while (D3DVSD_END() != *token)
{
token_type = ((*token & D3DVSD_TOKENTYPEMASK) >>
D3DVSD_TOKENTYPESHIFT);
@@ -311,8 +314,8 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements,
DWORD *d3
static void STDMETHODCALLTYPE d3d8_vertexdeclaration_wined3d_object_destroyed(void
*parent)
{
struct d3d8_vertex_declaration *declaration = parent;
- HeapFree(GetProcessHeap(), 0, declaration->elements);
- HeapFree(GetProcessHeap(), 0, declaration);
+ heap_free(declaration->elements);
+ heap_free(declaration);
}
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration)
@@ -339,11 +342,10 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration
*declaration
declaration->shader_handle = shader_handle;
wined3d_element_count = convert_to_wined3d_declaration(elements,
&declaration->elements_size, &wined3d_elements);
- declaration->elements = HeapAlloc(GetProcessHeap(), 0,
declaration->elements_size);
- if (!declaration->elements)
+ if (!(declaration->elements = heap_alloc(declaration->elements_size)))
{
ERR("Failed to allocate vertex declaration elements memory.\n");
- HeapFree(GetProcessHeap(), 0, wined3d_elements);
+ heap_free(wined3d_elements);
return E_OUTOFMEMORY;
}
@@ -353,11 +355,11 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration
*declaration
hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements,
wined3d_element_count,
declaration, &d3d8_vertexdeclaration_wined3d_parent_ops,
&declaration->wined3d_vertex_declaration);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, wined3d_elements);
+ heap_free(wined3d_elements);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, declaration->elements);
+ heap_free(declaration->elements);
return hr;
}
diff --git a/dll/directx/wine/d3d8/volume.c b/dll/directx/wine/d3d8/volume.c
index 0e1e904e2f..89aa84fdb5 100644
--- a/dll/directx/wine/d3d8/volume.c
+++ b/dll/directx/wine/d3d8/volume.c
@@ -18,8 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d8_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
static inline struct d3d8_volume *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
{
return CONTAINING_RECORD(iface, struct d3d8_volume, IDirect3DVolume8_iface);
@@ -122,8 +125,8 @@ static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface,
D3DVOLUME_DES
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_VOLUME;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
@@ -144,7 +147,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
wined3d_mutex_lock();
if (FAILED(hr =
wined3d_resource_map(wined3d_texture_get_resource(volume->wined3d_texture),
- volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box,
flags)))
+ volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box,
+ wined3dmapflags_from_d3dmapflags(flags))))
map_desc.data = NULL;
wined3d_mutex_unlock();
@@ -152,6 +156,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
locked_box->SlicePitch = map_desc.slice_pitch;
locked_box->pBits = map_desc.data;
+ if (hr == E_INVALIDARG)
+ return D3DERR_INVALIDCALL;
return hr;
}
@@ -192,7 +198,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void
*parent)
{
struct d3d8_volume *volume = parent;
d3d8_resource_cleanup(&volume->resource);
- HeapFree(GetProcessHeap(), 0, volume);
+ heap_free(volume);
}
static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
diff --git a/dll/directx/wine/d3d9/CMakeLists.txt b/dll/directx/wine/d3d9/CMakeLists.txt
index 9dd8b4aa6a..223606b87e 100644
--- a/dll/directx/wine/d3d9/CMakeLists.txt
+++ b/dll/directx/wine/d3d9/CMakeLists.txt
@@ -19,7 +19,7 @@ list(APPEND SOURCE
texture.c
vertexdeclaration.c
volume.c
- d3d9_private.h)
+ precomp.h)
add_library(d3d9 SHARED
${SOURCE}
@@ -31,5 +31,5 @@ add_library(d3d9 SHARED
set_module_type(d3d9 win32dll UNICODE)
target_link_libraries(d3d9 wine)
add_importlibs(d3d9 d3dwine user32 msvcrt kernel32 ntdll)
-add_pch(d3d9 d3d9_private.h SOURCE)
+add_pch(d3d9 precomp.h SOURCE)
add_cd_file(TARGET d3d9 DESTINATION reactos/system32 FOR all)
diff --git a/dll/directx/wine/d3d9/buffer.c b/dll/directx/wine/d3d9/buffer.c
index 462ef3bb97..36a6ae3f90 100644
--- a/dll/directx/wine/d3d9/buffer.c
+++ b/dll/directx/wine/d3d9/buffer.c
@@ -18,8 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_vertexbuffer
*impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_vertexbuffer,
IDirect3DVertexBuffer9_iface);
@@ -191,7 +194,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9
*iface, UINT
wined3d_box.right = offset + size;
wined3d_mutex_lock();
hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
- 0, &wined3d_map_desc, &wined3d_box, flags);
+ 0, &wined3d_map_desc, &wined3d_box,
wined3dmapflags_from_d3dmapflags(flags));
wined3d_mutex_unlock();
*data = wined3d_map_desc.data;
@@ -226,10 +229,10 @@ static HRESULT WINAPI
d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface,
wined3d_mutex_unlock();
desc->Format = D3DFMT_VERTEXDATA;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
- desc->Size = wined3d_desc.size;
desc->Type = D3DRTYPE_VERTEXBUFFER;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
+ desc->Size = wined3d_desc.size;
desc->FVF = buffer->fvf;
return D3D_OK;
@@ -260,7 +263,7 @@ static void STDMETHODCALLTYPE
d3d9_vertexbuffer_wined3d_object_destroyed(void *p
{
struct d3d9_vertexbuffer *buffer = parent;
d3d9_resource_cleanup(&buffer->resource);
- HeapFree(GetProcessHeap(), 0, buffer);
+ heap_free(buffer);
}
static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops =
@@ -271,15 +274,30 @@ static const struct wined3d_parent_ops
d3d9_vertexbuffer_wined3d_parent_ops =
HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *device,
UINT size, UINT usage, DWORD fvf, D3DPOOL pool)
{
+ struct wined3d_buffer_desc desc;
HRESULT hr;
+ if (pool == D3DPOOL_SCRATCH)
+ {
+ WARN("Vertex buffer with D3DPOOL_SCRATCH requested.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
buffer->IDirect3DVertexBuffer9_iface.lpVtbl = &d3d9_vertexbuffer_vtbl;
buffer->fvf = fvf;
d3d9_resource_init(&buffer->resource);
+ desc.byte_width = size;
+ desc.usage = usage & WINED3DUSAGE_MASK;
+ desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
wined3d_mutex_lock();
- hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage &
WINED3DUSAGE_MASK,
- (enum wined3d_pool)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops,
&buffer->wined3d_buffer);
+ hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer,
+ &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -473,7 +491,7 @@ static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9
*iface,
wined3d_box.right = offset + size;
wined3d_mutex_lock();
hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
- 0, &wined3d_map_desc, &wined3d_box, flags);
+ 0, &wined3d_map_desc, &wined3d_box,
wined3dmapflags_from_d3dmapflags(flags));
wined3d_mutex_unlock();
*data = wined3d_map_desc.data;
@@ -507,10 +525,10 @@ static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9
*iface, D3D
wined3d_mutex_unlock();
desc->Format = d3dformat_from_wined3dformat(buffer->format);
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
- desc->Size = wined3d_desc.size;
desc->Type = D3DRTYPE_INDEXBUFFER;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
+ desc->Size = wined3d_desc.size;
return D3D_OK;
}
@@ -540,7 +558,7 @@ static void STDMETHODCALLTYPE
d3d9_indexbuffer_wined3d_object_destroyed(void *pa
{
struct d3d9_indexbuffer *buffer = parent;
d3d9_resource_cleanup(&buffer->resource);
- HeapFree(GetProcessHeap(), 0, buffer);
+ heap_free(buffer);
}
static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
@@ -551,15 +569,26 @@ static const struct wined3d_parent_ops
d3d9_indexbuffer_wined3d_parent_ops =
HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *device,
UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
+ struct wined3d_buffer_desc desc;
HRESULT hr;
+ desc.byte_width = size;
+ desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
buffer->IDirect3DIndexBuffer9_iface.lpVtbl = &d3d9_indexbuffer_vtbl;
buffer->format = wined3dformat_from_d3dformat(format);
d3d9_resource_init(&buffer->resource);
wined3d_mutex_lock();
- hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage &
WINED3DUSAGE_MASK,
- (enum wined3d_pool)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops,
&buffer->wined3d_buffer);
+ hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer,
+ &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
wined3d_mutex_unlock();
if (FAILED(hr))
{
diff --git a/dll/directx/wine/d3d9/d3d9_main.c b/dll/directx/wine/d3d9/d3d9_main.c
index 4bd80e1b91..c23fa54d99 100644
--- a/dll/directx/wine/d3d9/d3d9_main.c
+++ b/dll/directx/wine/d3d9/d3d9_main.c
@@ -21,8 +21,12 @@
*
*/
+#include "config.h"
+#include "initguid.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static int D3DPERF_event_level = 0;
void WINAPI DebugSetMute(void) {
@@ -35,13 +39,13 @@ IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT
sdk_version)
TRACE("sdk_version %#x.\n", sdk_version);
- if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return NULL;
if (!d3d9_init(object, FALSE))
{
WARN("Failed to initialize d3d9.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return NULL;
}
@@ -56,13 +60,13 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version,
IDirect3D9E
TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
- if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (!d3d9_init(object, TRUE))
{
WARN("Failed to initialize d3d9.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return D3DERR_NOTAVAILABLE;
}
diff --git a/dll/directx/wine/d3d9/d3d9_private.h b/dll/directx/wine/d3d9/d3d9_private.h
index d34dd73137..ba19e5fb08 100644
--- a/dll/directx/wine/d3d9/d3d9_private.h
+++ b/dll/directx/wine/d3d9/d3d9_private.h
@@ -23,36 +23,39 @@
#ifndef __WINE_D3D9_PRIVATE_H
#define __WINE_D3D9_PRIVATE_H
-#include <config.h>
-
#include <assert.h>
#include <stdarg.h>
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
-#include <windef.h>
-#include <winbase.h>
-#include <wingdi.h>
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/debug.h"
+#include "wine/heap.h"
+#include "wine/unicode.h"
-#include <wine/debug.h>
-WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+#include "d3d9.h"
+#include "wine/wined3d.h"
-#include <d3d9.h>
-#include <wine/wined3d.h>
+#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256
+#define D3D9_MAX_TEXTURE_UNITS 20
#define D3DPRESENTFLAGS_MASK 0x00000fffu
+#define D3D9_TEXTURE_MIPMAP_DIRTY 0x1
+
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+
extern const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops DECLSPEC_HIDDEN;
HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements)
DECLSPEC_HIDDEN;
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
+unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDEN;
void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS
*present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc) DECLSPEC_HIDDEN;
void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const WINED3DCAPS *wined3d_caps)
DECLSPEC_HIDDEN;
@@ -98,6 +101,9 @@ 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;
BOOL in_destruction;
BOOL in_scene;
@@ -204,6 +210,10 @@ struct d3d9_texture
struct wined3d_texture *wined3d_texture;
IDirect3DDevice9Ex *parent_device;
struct list rtv_list;
+ DWORD usage;
+ BOOL flags;
+ struct wined3d_shader_resource_view *wined3d_srv;
+ D3DTEXTUREFILTERTYPE autogen_filter_type;
};
HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *device,
@@ -213,6 +223,8 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device
*device,
HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *device,
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
D3DPOOL pool) DECLSPEC_HIDDEN;
struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture9 *iface)
DECLSPEC_HIDDEN;
+void d3d9_texture_flag_auto_gen_mipmap(struct d3d9_texture *texture) DECLSPEC_HIDDEN;
+void d3d9_texture_gen_auto_mipmap(struct d3d9_texture *texture) DECLSPEC_HIDDEN;
struct d3d9_stateblock
{
@@ -253,9 +265,6 @@ HRESULT vertexshader_init(struct d3d9_vertexshader *shader,
struct d3d9_device *device, const DWORD *byte_code) DECLSPEC_HIDDEN;
struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVertexShader9
*iface) DECLSPEC_HIDDEN;
-#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256
-#define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4
-
struct d3d9_pixelshader
{
IDirect3DPixelShader9 IDirect3DPixelShader9_iface;
@@ -284,4 +293,49 @@ static inline struct d3d9_device
*impl_from_IDirect3DDevice9Ex(IDirect3DDevice9E
return CONTAINING_RECORD(iface, struct d3d9_device, IDirect3DDevice9Ex_iface);
}
+static inline DWORD d3dusage_from_wined3dusage(unsigned int usage)
+{
+ return usage & WINED3DUSAGE_MASK;
+}
+
+static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int
usage)
+{
+ switch (access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU))
+ {
+ default:
+ case WINED3D_RESOURCE_ACCESS_GPU:
+ return D3DPOOL_DEFAULT;
+ case WINED3D_RESOURCE_ACCESS_CPU:
+ if (usage & WINED3DUSAGE_SCRATCH)
+ return D3DPOOL_SCRATCH;
+ return D3DPOOL_SYSTEMMEM;
+ case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU:
+ return D3DPOOL_MANAGED;
+ }
+}
+
+static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage)
+{
+ switch (pool)
+ {
+ case D3DPOOL_DEFAULT:
+ if (usage & D3DUSAGE_DYNAMIC)
+ return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ return WINED3D_RESOURCE_ACCESS_GPU;
+ case D3DPOOL_MANAGED:
+ return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
+ case D3DPOOL_SYSTEMMEM:
+ case D3DPOOL_SCRATCH:
+ return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ default:
+ return 0;
+ }
+}
+
+static inline DWORD wined3dusage_from_d3dusage(unsigned int usage)
+{
+ return usage & WINED3DUSAGE_MASK;
+}
+
#endif /* __WINE_D3D9_PRIVATE_H */
diff --git a/dll/directx/wine/d3d9/device.c b/dll/directx/wine/d3d9/device.c
index b3e085f34d..bc73699e52 100644
--- a/dll/directx/wine/d3d9/device.c
+++ b/dll/directx/wine/d3d9/device.c
@@ -20,9 +20,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
-#include <winuser.h>
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static void STDMETHODCALLTYPE d3d9_null_wined3d_object_destroyed(void *parent) {}
@@ -159,6 +160,30 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT
format)
}
}
+unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags)
+{
+ static const unsigned int handled = D3DLOCK_NOSYSLOCK
+ | D3DLOCK_NOOVERWRITE
+ | D3DLOCK_DISCARD
+ | D3DLOCK_DONOTWAIT
+ | D3DLOCK_NO_DIRTY_UPDATE;
+ unsigned int wined3d_flags;
+
+ wined3d_flags = flags & handled;
+ if (!(flags & (D3DLOCK_NOOVERWRITE | D3DLOCK_DISCARD)))
+ wined3d_flags |= WINED3D_MAP_READ;
+ if (!(flags & D3DLOCK_READONLY))
+ wined3d_flags |= WINED3D_MAP_WRITE;
+ if (!(wined3d_flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE)))
+ wined3d_flags |= WINED3D_MAP_READ | WINED3D_MAP_WRITE;
+ flags &= ~(handled | D3DLOCK_READONLY);
+
+ if (flags)
+ FIXME("Unhandled flags %#x.\n", flags);
+
+ return wined3d_flags;
+}
+
static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT
primitive_count)
{
switch (primitive_type)
@@ -185,6 +210,26 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE
primitive_type, U
}
}
+static D3DSWAPEFFECT d3dswapeffect_from_wined3dswapeffect(enum wined3d_swap_effect
effect)
+{
+ switch (effect)
+ {
+ case WINED3D_SWAP_EFFECT_DISCARD:
+ return D3DSWAPEFFECT_DISCARD;
+ case WINED3D_SWAP_EFFECT_SEQUENTIAL:
+ return D3DSWAPEFFECT_FLIP;
+ case WINED3D_SWAP_EFFECT_COPY:
+ return D3DSWAPEFFECT_COPY;
+ case WINED3D_SWAP_EFFECT_OVERLAY:
+ return D3DSWAPEFFECT_OVERLAY;
+ case WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL:
+ return D3DSWAPEFFECT_FLIPEX;
+ default:
+ FIXME("Unhandled swap effect %#x.\n", effect);
+ return D3DSWAPEFFECT_FLIP;
+ }
+}
+
void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS
*present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc)
{
@@ -194,7 +239,7 @@ void
present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *prese
present_parameters->BackBufferCount = swapchain_desc->backbuffer_count;
present_parameters->MultiSampleType = swapchain_desc->multisample_type;
present_parameters->MultiSampleQuality = swapchain_desc->multisample_quality;
- present_parameters->SwapEffect = swapchain_desc->swap_effect;
+ present_parameters->SwapEffect =
d3dswapeffect_from_wined3dswapeffect(swapchain_desc->swap_effect);
present_parameters->hDeviceWindow = swapchain_desc->device_window;
present_parameters->Windowed = swapchain_desc->windowed;
present_parameters->EnableAutoDepthStencil =
swapchain_desc->enable_auto_depth_stencil;
@@ -205,6 +250,26 @@ void
present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *prese
present_parameters->PresentationInterval = swapchain_desc->swap_interval;
}
+static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFECT
effect)
+{
+ switch (effect)
+ {
+ case D3DSWAPEFFECT_DISCARD:
+ return WINED3D_SWAP_EFFECT_DISCARD;
+ case D3DSWAPEFFECT_FLIP:
+ return WINED3D_SWAP_EFFECT_SEQUENTIAL;
+ case D3DSWAPEFFECT_COPY:
+ return WINED3D_SWAP_EFFECT_COPY;
+ case D3DSWAPEFFECT_OVERLAY:
+ return WINED3D_SWAP_EFFECT_OVERLAY;
+ case D3DSWAPEFFECT_FLIPEX:
+ return WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL;
+ default:
+ FIXME("Unhandled swap effect %#x.\n", effect);
+ return WINED3D_SWAP_EFFECT_SEQUENTIAL;
+ }
+}
+
static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc
*swapchain_desc,
const D3DPRESENT_PARAMETERS *present_parameters, BOOL extended)
{
@@ -228,9 +293,10 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct
wined3d_swapch
swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight;
swapchain_desc->backbuffer_format =
wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
swapchain_desc->backbuffer_count = max(1,
present_parameters->BackBufferCount);
+ swapchain_desc->backbuffer_usage = WINED3DUSAGE_RENDERTARGET;
swapchain_desc->multisample_type = present_parameters->MultiSampleType;
swapchain_desc->multisample_quality = present_parameters->MultiSampleQuality;
- swapchain_desc->swap_effect = present_parameters->SwapEffect;
+ swapchain_desc->swap_effect =
wined3dswapeffect_from_d3dswapeffect(present_parameters->SwapEffect);
swapchain_desc->device_window = present_parameters->hDeviceWindow;
swapchain_desc->windowed = present_parameters->Windowed;
swapchain_desc->enable_auto_depth_stencil =
present_parameters->EnableAutoDepthStencil;
@@ -387,7 +453,7 @@ void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const WINED3DCAPS
*wined3d_caps)
D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2|
D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
caps->MaxVertexShaderConst = min(D3D9_MAX_VERTEX_SHADER_CONSTANTF,
caps->MaxVertexShaderConst);
- caps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS,
caps->NumSimultaneousRTs);
+ caps->NumSimultaneousRTs = min(D3D_MAX_SIMULTANEOUS_RENDERTARGETS,
caps->NumSimultaneousRTs);
if (caps->PixelShaderVersion > 3)
{
@@ -478,14 +544,14 @@ static ULONG WINAPI DECLSPEC_HOTPATCH
d3d9_device_Release(IDirect3DDevice9Ex *if
{
wined3d_vertex_declaration_decref(device->fvf_decls[i].decl);
}
- HeapFree(GetProcessHeap(), 0, device->fvf_decls);
+ heap_free(device->fvf_decls);
if (device->vertex_buffer)
wined3d_buffer_decref(device->vertex_buffer);
if (device->index_buffer)
wined3d_buffer_decref(device->index_buffer);
- HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
+ heap_free(device->implicit_swapchains);
wined3d_device_uninit_3d(device->wined3d_device);
wined3d_device_release_focus_window(device->wined3d_device);
@@ -494,7 +560,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH
d3d9_device_Release(IDirect3DDevice9Ex *if
IDirect3D9Ex_Release(&device->d3d_parent->IDirect3D9Ex_iface);
- HeapFree(GetProcessHeap(), 0, device);
+ heap_free(device);
}
return refcount;
@@ -764,7 +830,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource
*resource)
IUnknown *parent;
wined3d_resource_get_desc(resource, &desc);
- if (desc.pool != WINED3D_POOL_DEFAULT)
+ if (desc.access & WINED3D_RESOURCE_ACCESS_CPU)
return D3D_OK;
if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
@@ -794,8 +860,7 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device)
UINT i, new_swapchain_count =
wined3d_device_get_swapchain_count(device->wined3d_device);
struct wined3d_swapchain *wined3d_swapchain;
- if (!(device->implicit_swapchains = HeapAlloc(GetProcessHeap(), 0,
- new_swapchain_count * sizeof(*device->implicit_swapchains))))
+ if (!(device->implicit_swapchains = heap_alloc(new_swapchain_count *
sizeof(*device->implicit_swapchains))))
return E_OUTOFMEMORY;
for (i = 0; i < new_swapchain_count; ++i)
@@ -814,9 +879,10 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
BOOL extended = device->d3d_parent->extended;
struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_display_mode wined3d_mode;
+ struct wined3d_rendertarget_view *rtv;
+ unsigned int i;
HRESULT hr;
-
if (!extended && device->device_state == D3D9_DEVICE_STATE_LOST)
{
WARN("App not active, returning D3DERR_DEVICELOST.\n");
@@ -854,7 +920,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device,
&swapchain_desc,
mode ? &wined3d_mode : NULL, reset_enum_callback, !extended)))
{
- HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
+ heap_free(device->implicit_swapchains);
if (!extended)
{
@@ -876,6 +942,15 @@ 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)
+ device->render_targets[i] = NULL;
}
else if (!extended)
{
@@ -917,7 +992,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d9_device_Present(IDirect3DDevice9Ex *
for (i = 0; i < device->implicit_swapchain_count; ++i)
{
if (FAILED(hr =
wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain,
- src_rect, dst_rect, dst_window_override, 0)))
+ src_rect, dst_rect, dst_window_override, 0, 0)))
{
wined3d_mutex_unlock();
return hr;
@@ -1050,15 +1125,14 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex
*iface,
}
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = texture_init(object, device, width, height, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize texture, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1103,15 +1177,14 @@ static HRESULT WINAPI
d3d9_device_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n",
*shared_handle);
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = volumetexture_init(object, device, width, height, depth, levels, usage, format,
pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume texture, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1149,15 +1222,14 @@ static HRESULT WINAPI
d3d9_device_CreateCubeTexture(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n",
*shared_handle);
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = cubetexture_init(object, device, edge_length, levels, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize cube texture, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1194,15 +1266,14 @@ static HRESULT WINAPI
d3d9_device_CreateVertexBuffer(IDirect3DDevice9Ex *iface,
FIXME("Resource sharing not implemented, *shared_handle %p.\n",
*shared_handle);
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = vertexbuffer_init(object, device, size, usage, fvf, pool);
if (FAILED(hr))
{
WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1239,15 +1310,14 @@ static HRESULT WINAPI
d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U
FIXME("Resource sharing not implemented, *shared_handle %p.\n",
*shared_handle);
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return D3DERR_OUTOFVIDEOMEMORY;
hr = indexbuffer_init(object, device, size, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize index buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1276,7 +1346,10 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device
*device, UINT width
desc.multisample_type = multisample_type;
desc.multisample_quality = multisample_quality;
desc.usage = usage & WINED3DUSAGE_MASK;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.width = width;
desc.height = height;
desc.depth = 1;
@@ -1428,6 +1501,9 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex
*iface,
wined3d_texture_get_resource(dst->wined3d_texture),
dst->sub_resource_idx, dst_point ? dst_point->x : 0,
dst_point ? dst_point->y : 0, 0,
wined3d_texture_get_resource(src->wined3d_texture),
src->sub_resource_idx, &src_box);
+ if (SUCCEEDED(hr) && dst->texture)
+ d3d9_texture_flag_auto_gen_mipmap(dst->texture);
+
wined3d_mutex_unlock();
if (FAILED(hr))
@@ -1451,6 +1527,8 @@ static HRESULT WINAPI d3d9_device_UpdateTexture(IDirect3DDevice9Ex
*iface,
wined3d_mutex_lock();
hr = wined3d_device_update_texture(device->wined3d_device,
src_impl->wined3d_texture, dst_impl->wined3d_texture);
+ if (SUCCEEDED(hr))
+ d3d9_texture_flag_auto_gen_mipmap(dst_impl);
wined3d_mutex_unlock();
return hr;
@@ -1534,6 +1612,23 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex
*iface, IDirect
src_rect = &s;
}
+ if (dst_desc.access & WINED3D_RESOURCE_ACCESS_CPU)
+ {
+ WARN("Destination resource is not in DEFAULT pool.\n");
+ goto done;
+ }
+ if (src_desc.access & WINED3D_RESOURCE_ACCESS_CPU)
+ {
+ WARN("Source resource is not in DEFAULT pool.\n");
+ goto done;
+ }
+
+ if (dst->texture && !(dst_desc.usage & (WINED3DUSAGE_RENDERTARGET |
WINED3DUSAGE_DEPTHSTENCIL)))
+ {
+ WARN("Destination is a regular texture.\n");
+ goto done;
+ }
+
if (src_desc.usage & WINED3DUSAGE_DEPTHSTENCIL)
{
if (device->in_scene)
@@ -1569,6 +1664,8 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex
*iface, IDirect
src->wined3d_texture, src->sub_resource_idx, src_rect, 0, NULL,
filter);
if (hr == WINEDDERR_INVALIDRECT)
hr = D3DERR_INVALIDCALL;
+ if (SUCCEEDED(hr) && dst->texture)
+ d3d9_texture_flag_auto_gen_mipmap(dst->texture);
done:
wined3d_mutex_unlock();
@@ -1602,10 +1699,10 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex
*iface,
return D3DERR_INVALIDCALL;
}
- if (desc.pool != WINED3D_POOL_DEFAULT)
+ if (desc.access & WINED3D_RESOURCE_ACCESS_CPU)
{
wined3d_mutex_unlock();
- WARN("Colorfill is not allowed on surfaces in pool %#x, returning
D3DERR_INVALIDCALL.\n", desc.pool);
+ WARN("Colour fills are not allowed on surfaces with resource access
%#x.\n", desc.access);
return D3DERR_INVALIDCALL;
}
if ((desc.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_TEXTURE)) ==
WINED3DUSAGE_TEXTURE)
@@ -1625,6 +1722,8 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex
*iface,
hr = wined3d_device_clear_rendertarget_view(device->wined3d_device,
rtv, rect, WINED3DCLEAR_TARGET, &c, 0.0f, 0);
d3d9_surface_release_rendertarget_view(surface_impl, rtv);
+ if (SUCCEEDED(hr) && surface_impl->texture)
+ d3d9_texture_flag_auto_gen_mipmap(surface_impl->texture);
wined3d_mutex_unlock();
@@ -1685,7 +1784,7 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex
*iface, DWO
TRACE("iface %p, idx %u, surface %p.\n", iface, idx, surface);
- if (idx >= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS)
+ if (idx >= D3D_MAX_SIMULTANEOUS_RENDERTARGETS)
{
WARN("Invalid index %u specified.\n", idx);
return D3DERR_INVALIDCALL;
@@ -1707,6 +1806,8 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex
*iface, DWO
rtv = surface_impl ? d3d9_surface_acquire_rendertarget_view(surface_impl) : NULL;
hr = wined3d_device_set_rendertarget_view(device->wined3d_device, idx, rtv,
TRUE);
d3d9_surface_release_rendertarget_view(surface_impl, rtv);
+ if (SUCCEEDED(hr))
+ device->render_targets[idx] = surface_impl;
wined3d_mutex_unlock();
return hr;
@@ -1724,7 +1825,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex
*iface, DWO
if (!surface)
return D3DERR_INVALIDCALL;
- if (idx >= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS)
+ if (idx >= D3D_MAX_SIMULTANEOUS_RENDERTARGETS)
{
WARN("Invalid index %u specified.\n", idx);
return D3DERR_INVALIDCALL;
@@ -1827,6 +1928,19 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d9_device_EndScene(IDirect3DDevice9Ex
return hr;
}
+static void d3d9_rts_flag_auto_gen_mipmap(struct d3d9_device *device)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(device->render_targets); ++i)
+ {
+ struct d3d9_surface *surface = device->render_targets[i];
+
+ if (surface && surface->texture)
+ d3d9_texture_flag_auto_gen_mipmap(surface->texture);
+ }
+}
+
static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface, DWORD rect_count,
const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil)
{
@@ -1851,6 +1965,8 @@ static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface,
DWORD rect_co
wined3d_mutex_lock();
hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects,
flags, &c, z, stencil);
+ if (SUCCEEDED(hr))
+ d3d9_rts_flag_auto_gen_mipmap(device);
wined3d_mutex_unlock();
return hr;
@@ -2104,15 +2220,14 @@ static HRESULT WINAPI
d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface,
return D3DERR_INVALIDCALL;
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = stateblock_init(object, device, type, NULL);
if (FAILED(hr))
{
WARN("Failed to initialize stateblock, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -2154,8 +2269,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex
*iface, IDire
return hr;
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
wined3d_mutex_lock();
wined3d_stateblock_decref(wined3d_stateblock);
@@ -2170,7 +2284,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex
*iface, IDire
wined3d_mutex_lock();
wined3d_stateblock_decref(wined3d_stateblock);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -2248,6 +2362,13 @@ 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;
@@ -2297,7 +2418,7 @@ static HRESULT WINAPI
d3d9_device_GetTextureStageState(IDirect3DDevice9Ex *iface
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, state,
value);
- if (state >= sizeof(tss_lookup) / sizeof(*tss_lookup))
+ if (state >= ARRAY_SIZE(tss_lookup))
{
WARN("Invalid state %#x passed.\n", state);
return D3D_OK;
@@ -2317,7 +2438,7 @@ static HRESULT WINAPI
d3d9_device_SetTextureStageState(IDirect3DDevice9Ex *iface
TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, stage, state,
value);
- if (state >= sizeof(tss_lookup) / sizeof(*tss_lookup))
+ if (state >= ARRAY_SIZE(tss_lookup))
{
WARN("Invalid state %#x passed.\n", state);
return D3D_OK;
@@ -2488,6 +2609,16 @@ static float WINAPI d3d9_device_GetNPatchMode(IDirect3DDevice9Ex
*iface)
return ret;
}
+/* wined3d critical section must be taken by the caller. */
+static void d3d9_generate_auto_mipmaps(struct d3d9_device *device)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(device->textures); ++i)
+ if (device->textures[i])
+ d3d9_texture_gen_auto_mipmap(device->textures[i]);
+}
+
static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface,
D3DPRIMITIVETYPE primitive_type, UINT start_vertex, UINT primitive_count)
{
@@ -2504,9 +2635,12 @@ static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex
*iface,
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
+ d3d9_generate_auto_mipmaps(device);
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0);
hr = wined3d_device_draw_primitive(device->wined3d_device, start_vertex,
vertex_count_from_primitive_count(primitive_type, primitive_count));
+ if (SUCCEEDED(hr))
+ d3d9_rts_flag_auto_gen_mipmap(device);
wined3d_mutex_unlock();
return hr;
@@ -2531,10 +2665,13 @@ static HRESULT WINAPI
d3d9_device_DrawIndexedPrimitive(IDirect3DDevice9Ex *iface
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
+ d3d9_generate_auto_mipmaps(device);
wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_idx);
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0);
hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, start_idx,
vertex_count_from_primitive_count(primitive_type, primitive_count));
+ if (SUCCEEDED(hr))
+ d3d9_rts_flag_auto_gen_mipmap(device);
wined3d_mutex_unlock();
return hr;
@@ -2548,15 +2685,22 @@ static HRESULT d3d9_device_prepare_vertex_buffer(struct
d3d9_device *device, UIN
if (device->vertex_buffer_size < min_size || !device->vertex_buffer)
{
UINT size = max(device->vertex_buffer_size * 2, min_size);
+ struct wined3d_buffer_desc desc;
struct wined3d_buffer *buffer;
TRACE("Growing vertex buffer to %u bytes.\n", size);
- hr = wined3d_buffer_create_vb(device->wined3d_device, size,
WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
- WINED3D_POOL_DEFAULT, NULL, &d3d9_null_wined3d_parent_ops,
&buffer);
- if (FAILED(hr))
+ desc.byte_width = size;
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY;
+ desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
+ NULL, NULL, &d3d9_null_wined3d_parent_ops, &buffer)))
{
- ERR("(%p) wined3d_buffer_create_vb failed with hr = %08x.\n",
device, hr);
+ ERR("Failed to create vertex buffer, hr %#x.\n", hr);
return hr;
}
@@ -2616,7 +2760,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex
*iface,
wined3d_box.right = vb_pos + size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, data, size);
wined3d_resource_unmap(vb, 0);
@@ -2626,9 +2770,12 @@ static HRESULT WINAPI
d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface,
if (FAILED(hr))
goto done;
+ d3d9_generate_auto_mipmaps(device);
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0);
hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / stride,
vtx_count);
wined3d_device_set_stream_source(device->wined3d_device, 0, NULL, 0, 0);
+ if (SUCCEEDED(hr))
+ d3d9_rts_flag_auto_gen_mipmap(device);
done:
wined3d_mutex_unlock();
@@ -2643,15 +2790,22 @@ static HRESULT d3d9_device_prepare_index_buffer(struct d3d9_device
*device, UINT
if (device->index_buffer_size < min_size || !device->index_buffer)
{
UINT size = max(device->index_buffer_size * 2, min_size);
+ struct wined3d_buffer_desc desc;
struct wined3d_buffer *buffer;
TRACE("Growing index buffer to %u bytes.\n", size);
- hr = wined3d_buffer_create_ib(device->wined3d_device, size,
WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
- WINED3D_POOL_DEFAULT, NULL, &d3d9_null_wined3d_parent_ops,
&buffer);
- if (FAILED(hr))
+ desc.byte_width = size;
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY |
WINED3DUSAGE_STATICDECL;
+ desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
+ NULL, NULL, &d3d9_null_wined3d_parent_ops, &buffer)))
{
- ERR("(%p) wined3d_buffer_create_ib failed with hr = %08x.\n",
device, hr);
+ ERR("Failed to create index buffer, hr %#x.\n", hr);
return hr;
}
@@ -2717,7 +2871,7 @@ static HRESULT WINAPI
d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride,
vtx_size);
wined3d_resource_unmap(vb, 0);
@@ -2739,7 +2893,7 @@ static HRESULT WINAPI
d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, index_data, idx_size);
wined3d_resource_unmap(ib, 0);
@@ -2749,6 +2903,7 @@ static HRESULT WINAPI
d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
if (FAILED(hr))
goto done;
+ d3d9_generate_auto_mipmaps(device);
wined3d_device_set_index_buffer(device->wined3d_device, device->index_buffer,
wined3dformat_from_d3dformat(index_format), 0);
wined3d_device_set_base_vertex_index(device->wined3d_device, vb_pos /
vertex_stride - min_vertex_idx);
@@ -2760,6 +2915,9 @@ static HRESULT WINAPI
d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN,
0);
wined3d_device_set_base_vertex_index(device->wined3d_device, 0);
+ if (SUCCEEDED(hr))
+ d3d9_rts_flag_auto_gen_mipmap(device);
+
done:
wined3d_mutex_unlock();
return hr;
@@ -2887,7 +3045,7 @@ static struct wined3d_vertex_declaration
*device_get_fvf_declaration(struct d3d9
return NULL;
hr = d3d9_vertex_declaration_create(device, elements, &d3d9_declaration);
- HeapFree(GetProcessHeap(), 0, elements);
+ heap_free(elements);
if (FAILED(hr))
return NULL;
@@ -2895,8 +3053,7 @@ static struct wined3d_vertex_declaration
*device_get_fvf_declaration(struct d3d9
{
UINT grow = max(device->fvf_decl_size / 2, 8);
- fvf_decls = HeapReAlloc(GetProcessHeap(), 0, fvf_decls, sizeof(*fvf_decls) *
(device->fvf_decl_size + grow));
- if (!fvf_decls)
+ if (!(fvf_decls = heap_realloc(fvf_decls, sizeof(*fvf_decls) *
(device->fvf_decl_size + grow))))
{
IDirect3DVertexDeclaration9_Release(&d3d9_declaration->IDirect3DVertexDeclaration9_iface);
return NULL;
@@ -2982,15 +3139,14 @@ static HRESULT WINAPI
d3d9_device_CreateVertexShader(IDirect3DDevice9Ex *iface,
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = vertexshader_init(object, device, byte_code);
if (FAILED(hr))
{
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -3280,8 +3436,7 @@ static HRESULT WINAPI
d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
FIXME("Failed to allocate pixel shader memory.\n");
return E_OUTOFMEMORY;
@@ -3291,7 +3446,7 @@ static HRESULT WINAPI
d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
if (FAILED(hr))
{
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -3468,15 +3623,14 @@ static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex
*iface, D3DQUER
TRACE("iface %p, type %#x, query %p.\n", iface, type, query);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = query_init(object, device, type);
if (FAILED(hr))
{
WARN("Failed to initialize query, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -3530,7 +3684,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d9_device_PresentEx(IDirect3DDevice9Ex
for (i = 0; i < device->implicit_swapchain_count; ++i)
{
if (FAILED(hr =
wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain,
- src_rect, dst_rect, dst_window_override, flags)))
+ src_rect, dst_rect, dst_window_override, 0, flags)))
{
wined3d_mutex_unlock();
return hr;
@@ -3905,7 +4059,7 @@ static HRESULT CDECL device_parent_surface_created(struct
wined3d_device_parent
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p,
parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
- if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*d3d_surface))))
+ if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
@@ -3924,7 +4078,7 @@ static HRESULT CDECL device_parent_volume_created(struct
wined3d_device_parent *
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops
%p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
- if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*d3d_volume))))
+ if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
@@ -4075,8 +4229,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent,
struct wine
}
}
- swapchain_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain_desc) * count);
- if (!swapchain_desc)
+ if (!(swapchain_desc = heap_alloc(sizeof(*swapchain_desc) * count)))
{
ERR("Failed to allocate wined3d parameters.\n");
wined3d_device_release_focus_window(device->wined3d_device);
@@ -4092,7 +4245,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent,
struct wine
{
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
- HeapFree(GetProcessHeap(), 0, swapchain_desc);
+ heap_free(swapchain_desc);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
@@ -4102,7 +4255,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent,
struct wine
{
WARN("Failed to initialize 3D, hr %#x.\n", hr);
wined3d_device_release_focus_window(device->wined3d_device);
- HeapFree(GetProcessHeap(), 0, swapchain_desc);
+ heap_free(swapchain_desc);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return hr;
@@ -4127,16 +4280,15 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9
*parent, struct wine
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, swapchain_desc);
+ heap_free(swapchain_desc);
/* Initialize the converted declaration array. This creates a valid pointer
* and when adding decls HeapReAlloc() can be used without further checking. */
- device->fvf_decls = HeapAlloc(GetProcessHeap(), 0, 0);
- if (!device->fvf_decls)
+ if (!(device->fvf_decls = heap_alloc(0)))
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
wined3d_mutex_lock();
- HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
+ heap_free(device->implicit_swapchains);
wined3d_device_uninit_3d(device->wined3d_device);
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
@@ -4144,6 +4296,14 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9
*parent, struct wine
return E_OUTOFMEMORY;
}
+ /* We could also simply ignore the initial rendertarget since it's known
+ * not to be a texture (we currently use these only for automatic mipmap
+ * generation). */
+ wined3d_mutex_lock();
+ device->render_targets[0] = wined3d_rendertarget_view_get_sub_resource_parent(
+ wined3d_device_get_rendertarget_view(device->wined3d_device, 0));
+ wined3d_mutex_unlock();
+
IDirect3D9Ex_AddRef(&parent->IDirect3D9Ex_iface);
device->d3d_parent = parent;
diff --git a/dll/directx/wine/d3d9/directx.c b/dll/directx/wine/d3d9/directx.c
index ab153a9030..644766c2e9 100644
--- a/dll/directx/wine/d3d9/directx.c
+++ b/dll/directx/wine/d3d9/directx.c
@@ -19,8 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9 *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
{
return CONTAINING_RECORD(iface, struct d3d9, IDirect3D9Ex_iface);
@@ -83,7 +86,7 @@ static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
wined3d_decref(d3d9->wined3d);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, d3d9);
+ heap_free(d3d9);
}
return refcount;
@@ -397,15 +400,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d9_CreateDevice(IDirect3D9Ex *iface, U
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x,
parameters %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, device);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window,
flags, parameters, NULL);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -505,15 +507,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d9_CreateDeviceEx(IDirect3D9Ex *iface,
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x,
parameters %p, mode %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, mode, device);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window,
flags, parameters, mode);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -578,7 +579,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE |
WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
- | WINED3D_NORMALIZED_DEPTH_BIAS;
+ | WINED3D_NORMALIZED_DEPTH_BIAS | WINED3D_LIMIT_VIEWPORT;
if (!extended)
flags |= WINED3D_VIDMEM_ACCOUNTING;
diff --git a/dll/directx/wine/d3d9/precomp.h b/dll/directx/wine/d3d9/precomp.h
new file mode 100644
index 0000000000..3d1e183794
--- /dev/null
+++ b/dll/directx/wine/d3d9/precomp.h
@@ -0,0 +1,13 @@
+
+#ifndef __WINE_D3D9_PRECOMP_H
+#define __WINE_D3D9_PRECOMP_H
+
+#include <wine/config.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#include "d3d9_private.h"
+
+#endif /* __WINE_D3D9_PRECOMP_H */
diff --git a/dll/directx/wine/d3d9/query.c b/dll/directx/wine/d3d9/query.c
index 8681502c49..12ff95b5a0 100644
--- a/dll/directx/wine/d3d9/query.c
+++ b/dll/directx/wine/d3d9/query.c
@@ -20,8 +20,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_query *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_query, IDirect3DQuery9_iface);
@@ -69,7 +72,7 @@ static ULONG WINAPI d3d9_query_Release(IDirect3DQuery9 *iface)
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(query->parent_device);
- HeapFree(GetProcessHeap(), 0, query);
+ heap_free(query);
}
return refcount;
}
diff --git a/dll/directx/wine/d3d9/shader.c b/dll/directx/wine/d3d9/shader.c
index 75dfc0f394..9cb398388b 100644
--- a/dll/directx/wine/d3d9/shader.c
+++ b/dll/directx/wine/d3d9/shader.c
@@ -17,8 +17,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_vertexshader
*impl_from_IDirect3DVertexShader9(IDirect3DVertexShader9 *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_vertexshader,
IDirect3DVertexShader9_iface);
@@ -123,7 +126,7 @@ static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl =
static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
{
- HeapFree(GetProcessHeap(), 0, parent);
+ heap_free(parent);
}
static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
@@ -277,7 +280,7 @@ static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl =
static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
{
- HeapFree(GetProcessHeap(), 0, parent);
+ heap_free(parent);
}
static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
diff --git a/dll/directx/wine/d3d9/stateblock.c b/dll/directx/wine/d3d9/stateblock.c
index 9355d9d51e..62b3bacb28 100644
--- a/dll/directx/wine/d3d9/stateblock.c
+++ b/dll/directx/wine/d3d9/stateblock.c
@@ -20,8 +20,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_stateblock *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9
*iface)
{
return CONTAINING_RECORD(iface, struct d3d9_stateblock, IDirect3DStateBlock9_iface);
@@ -69,7 +72,7 @@ static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9
*iface)
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(stateblock->parent_device);
- HeapFree(GetProcessHeap(), 0, stateblock);
+ heap_free(stateblock);
}
return refcount;
diff --git a/dll/directx/wine/d3d9/surface.c b/dll/directx/wine/d3d9/surface.c
index 47b5267910..0605e7142a 100644
--- a/dll/directx/wine/d3d9/surface.c
+++ b/dll/directx/wine/d3d9/surface.c
@@ -19,8 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_surface *impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_surface, IDirect3DSurface9_iface);
@@ -220,8 +223,8 @@ static HRESULT WINAPI d3d9_surface_GetDesc(IDirect3DSurface9 *iface,
D3DSURFACE_
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_SURFACE;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->MultiSampleQuality = wined3d_desc.multisample_quality;
desc->Width = wined3d_desc.width;
@@ -246,7 +249,7 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface,
wined3d_mutex_lock();
hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture),
surface->sub_resource_idx,
- &map_desc, rect ? &box : NULL, flags);
+ &map_desc, rect ? &box : NULL,
wined3dmapflags_from_d3dmapflags(flags));
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
@@ -267,6 +270,8 @@ static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9
*iface)
wined3d_mutex_lock();
hr =
wined3d_resource_unmap(wined3d_texture_get_resource(surface->wined3d_texture),
surface->sub_resource_idx);
+ if (SUCCEEDED(hr) && surface->texture)
+ d3d9_texture_flag_auto_gen_mipmap(surface->texture);
wined3d_mutex_unlock();
if (hr == WINEDDERR_NOTLOCKED)
@@ -304,6 +309,8 @@ static HRESULT WINAPI d3d9_surface_ReleaseDC(IDirect3DSurface9 *iface,
HDC dc)
wined3d_mutex_lock();
hr = wined3d_texture_release_dc(surface->wined3d_texture,
surface->sub_resource_idx, dc);
+ if (SUCCEEDED(hr) && surface->texture)
+ d3d9_texture_flag_auto_gen_mipmap(surface->texture);
wined3d_mutex_unlock();
return hr;
@@ -337,7 +344,7 @@ static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void
*parent)
{
struct d3d9_surface *surface = parent;
d3d9_resource_cleanup(&surface->resource);
- HeapFree(GetProcessHeap(), 0, surface);
+ heap_free(surface);
}
static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
diff --git a/dll/directx/wine/d3d9/swapchain.c b/dll/directx/wine/d3d9/swapchain.c
index 7b2dc7ea4f..dbb3f45b91 100644
--- a/dll/directx/wine/d3d9/swapchain.c
+++ b/dll/directx/wine/d3d9/swapchain.c
@@ -20,8 +20,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_swapchain
*impl_from_IDirect3DSwapChain9Ex(IDirect3DSwapChain9Ex *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_swapchain, IDirect3DSwapChain9Ex_iface);
@@ -134,7 +137,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH
d3d9_swapchain_Present(IDirect3DSwapChai
wined3d_mutex_lock();
hr = wined3d_swapchain_present(swapchain->wined3d_swapchain,
- src_rect, dst_rect, dst_window_override, flags);
+ src_rect, dst_rect, dst_window_override, 0, flags);
wined3d_mutex_unlock();
return hr;
@@ -332,7 +335,7 @@ static const struct IDirect3DSwapChain9ExVtbl d3d9_swapchain_vtbl =
static void STDMETHODCALLTYPE d3d9_swapchain_wined3d_object_released(void *parent)
{
- HeapFree(GetProcessHeap(), 0, parent);
+ heap_free(parent);
}
static const struct wined3d_parent_ops d3d9_swapchain_wined3d_parent_ops =
@@ -371,13 +374,13 @@ HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct
wined3d_swapcha
struct d3d9_swapchain *object;
HRESULT hr;
- if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = swapchain_init(object, device, desc)))
{
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
diff --git a/dll/directx/wine/d3d9/texture.c b/dll/directx/wine/d3d9/texture.c
index 16909d6888..c97fa6b021 100644
--- a/dll/directx/wine/d3d9/texture.c
+++ b/dll/directx/wine/d3d9/texture.c
@@ -18,21 +18,97 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_texture *impl_from_IDirect3DTexture9(IDirect3DTexture9 *iface)
{
- return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
+ return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture,
IDirect3DBaseTexture9_iface);
}
static inline struct d3d9_texture *impl_from_IDirect3DCubeTexture9(IDirect3DCubeTexture9
*iface)
{
- return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
+ return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture,
IDirect3DBaseTexture9_iface);
}
static inline struct d3d9_texture
*impl_from_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 *iface)
{
- return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
+ return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture,
IDirect3DBaseTexture9_iface);
+}
+
+static void STDMETHODCALLTYPE srv_wined3d_object_destroyed(void *parent)
+{
+ struct d3d9_texture *texture = parent;
+
+ texture->wined3d_srv = NULL;
+}
+
+static const struct wined3d_parent_ops d3d9_srv_wined3d_parent_ops =
+{
+ srv_wined3d_object_destroyed,
+};
+
+/* wined3d critical section must be taken by the caller. */
+static struct wined3d_shader_resource_view
*d3d9_texture_acquire_shader_resource_view(struct d3d9_texture *texture)
+{
+ struct wined3d_sub_resource_desc sr_desc;
+ struct wined3d_view_desc desc;
+ HRESULT hr;
+
+ if (texture->wined3d_srv)
+ return texture->wined3d_srv;
+
+ wined3d_texture_get_sub_resource_desc(texture->wined3d_texture, 0, &sr_desc);
+ desc.format_id = sr_desc.format;
+ desc.flags = 0;
+ desc.u.texture.level_idx = 0;
+ desc.u.texture.level_count =
wined3d_texture_get_level_count(texture->wined3d_texture);
+ desc.u.texture.layer_idx = 0;
+ desc.u.texture.layer_count = sr_desc.usage & WINED3DUSAGE_LEGACY_CUBEMAP ? 6 :
1;
+ if (FAILED(hr = wined3d_shader_resource_view_create(&desc,
+ wined3d_texture_get_resource(texture->wined3d_texture), texture,
+ &d3d9_srv_wined3d_parent_ops, &texture->wined3d_srv)))
+ {
+ ERR("Failed to create shader resource view, hr %#x.\n", hr);
+ return NULL;
+ }
+
+ return texture->wined3d_srv;
+}
+
+static void d3d9_texture_cleanup(struct d3d9_texture *texture)
+{
+ IDirect3DDevice9Ex *parent_device = texture->parent_device;
+ struct d3d9_surface *surface;
+
+ wined3d_mutex_lock();
+ if (texture->wined3d_srv)
+ wined3d_shader_resource_view_decref(texture->wined3d_srv);
+ LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface,
rtv_entry)
+ wined3d_rendertarget_view_decref(surface->wined3d_rtv);
+ wined3d_texture_decref(texture->wined3d_texture);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice9Ex_Release(parent_device);
+}
+
+/* wined3d critical section must be taken by the caller. */
+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);
+ wined3d_shader_resource_view_generate_mipmaps(texture->wined3d_srv);
+ texture->flags &= ~D3D9_TEXTURE_MIPMAP_DIRTY;
+}
+
+void d3d9_texture_flag_auto_gen_mipmap(struct d3d9_texture *texture)
+{
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP)
+ texture->flags |= D3D9_TEXTURE_MIPMAP_DIRTY;
}
static HRESULT WINAPI d3d9_texture_2d_QueryInterface(IDirect3DTexture9 *iface, REFIID
riid, void **out)
@@ -87,21 +163,7 @@ static ULONG WINAPI d3d9_texture_2d_Release(IDirect3DTexture9 *iface)
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref)
- {
- IDirect3DDevice9Ex *parent_device = texture->parent_device;
- struct d3d9_surface *surface;
-
- wined3d_mutex_lock();
- LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface,
rtv_entry)
- {
- wined3d_rendertarget_view_decref(surface->wined3d_rtv);
- }
- wined3d_texture_decref(texture->wined3d_texture);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parent_device);
- }
+ d3d9_texture_cleanup(texture);
return ref;
}
@@ -232,6 +294,9 @@ static DWORD WINAPI d3d9_texture_2d_GetLevelCount(IDirect3DTexture9
*iface)
TRACE("iface %p.\n", iface);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP)
+ return 1;
+
wined3d_mutex_lock();
ret = wined3d_texture_get_level_count(texture->wined3d_texture);
wined3d_mutex_unlock();
@@ -242,35 +307,44 @@ static DWORD WINAPI d3d9_texture_2d_GetLevelCount(IDirect3DTexture9
*iface)
static HRESULT WINAPI d3d9_texture_2d_SetAutoGenFilterType(IDirect3DTexture9 *iface,
D3DTEXTUREFILTERTYPE filter_type)
{
struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
- HRESULT hr;
TRACE("iface %p, filter_type %#x.\n", iface, filter_type);
- wined3d_mutex_lock();
- hr = wined3d_texture_set_autogen_filter_type(texture->wined3d_texture,
- (enum wined3d_texture_filter_type)filter_type);
- wined3d_mutex_unlock();
+ if (filter_type == D3DTEXF_NONE)
+ {
+ WARN("Invalid filter type D3DTEXF_NONE specified.\n");
+ return D3DERR_INVALIDCALL;
+ }
+ if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP))
+ WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP
flag.\n");
+ else if (filter_type != D3DTEXF_LINEAR)
+ FIXME("Unsupported filter type %u.\n", filter_type);
- return hr;
+ texture->autogen_filter_type = filter_type;
+ return D3D_OK;
}
static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_2d_GetAutoGenFilterType(IDirect3DTexture9
*iface)
{
struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
- D3DTEXTUREFILTERTYPE ret;
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock();
- ret =
(D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(texture->wined3d_texture);
- wined3d_mutex_unlock();
+ if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP))
+ WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP
flag.\n");
- return ret;
+ return texture->autogen_filter_type;
}
static void WINAPI d3d9_texture_2d_GenerateMipSubLevels(IDirect3DTexture9 *iface)
{
+ struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
+
TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ d3d9_texture_gen_auto_mipmap(texture);
+ wined3d_mutex_unlock();
}
static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9 *iface, UINT level,
D3DSURFACE_DESC *desc)
@@ -281,13 +355,19 @@ static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9
*iface, UIN
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
if (SUCCEEDED(hr = wined3d_texture_get_sub_resource_desc(texture->wined3d_texture,
level, &wined3d_desc)))
{
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_SURFACE;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = texture->usage;
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access,
wined3d_desc.usage);
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->MultiSampleQuality = wined3d_desc.multisample_quality;
desc->Width = wined3d_desc.width;
@@ -306,6 +386,12 @@ static HRESULT WINAPI
d3d9_texture_2d_GetSurfaceLevel(IDirect3DTexture9 *iface,
TRACE("iface %p, level %u, surface %p.\n", iface, level, surface);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
if (!(surface_impl =
wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, level)))
{
@@ -330,6 +416,12 @@ static HRESULT WINAPI d3d9_texture_2d_LockRect(IDirect3DTexture9
*iface,
TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
iface, level, locked_rect, rect, flags);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
if (!(surface_impl =
wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
@@ -348,6 +440,12 @@ static HRESULT WINAPI d3d9_texture_2d_UnlockRect(IDirect3DTexture9
*iface, UINT
TRACE("iface %p, level %u.\n", iface, level);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
if (!(surface_impl =
wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
@@ -463,23 +561,7 @@ static ULONG WINAPI d3d9_texture_cube_Release(IDirect3DCubeTexture9
*iface)
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref)
- {
- IDirect3DDevice9Ex *parent_device = texture->parent_device;
- struct d3d9_surface *surface;
-
- TRACE("Releasing child %p.\n", texture->wined3d_texture);
-
- wined3d_mutex_lock();
- LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface,
rtv_entry)
- {
- wined3d_rendertarget_view_decref(surface->wined3d_rtv);
- }
- wined3d_texture_decref(texture->wined3d_texture);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parent_device);
- }
+ d3d9_texture_cleanup(texture);
return ref;
}
@@ -610,6 +692,9 @@ static DWORD WINAPI
d3d9_texture_cube_GetLevelCount(IDirect3DCubeTexture9 *iface
TRACE("iface %p.\n", iface);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP)
+ return 1;
+
wined3d_mutex_lock();
ret = wined3d_texture_get_level_count(texture->wined3d_texture);
wined3d_mutex_unlock();
@@ -621,35 +706,44 @@ static HRESULT WINAPI
d3d9_texture_cube_SetAutoGenFilterType(IDirect3DCubeTextur
D3DTEXTUREFILTERTYPE filter_type)
{
struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
- HRESULT hr;
TRACE("iface %p, filter_type %#x.\n", iface, filter_type);
- wined3d_mutex_lock();
- hr = wined3d_texture_set_autogen_filter_type(texture->wined3d_texture,
- (enum wined3d_texture_filter_type)filter_type);
- wined3d_mutex_unlock();
+ if (filter_type == D3DTEXF_NONE)
+ {
+ WARN("Invalid filter type D3DTEXF_NONE specified.\n");
+ return D3DERR_INVALIDCALL;
+ }
+ if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP))
+ WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP
flag.\n");
+ else if (filter_type != D3DTEXF_LINEAR)
+ FIXME("Unsupported filter type %u.\n", filter_type);
- return hr;
+ texture->autogen_filter_type = filter_type;
+ return D3D_OK;
}
static D3DTEXTUREFILTERTYPE WINAPI
d3d9_texture_cube_GetAutoGenFilterType(IDirect3DCubeTexture9 *iface)
{
struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
- D3DTEXTUREFILTERTYPE ret;
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock();
- ret =
(D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(texture->wined3d_texture);
- wined3d_mutex_unlock();
+ if (!(texture->usage & D3DUSAGE_AUTOGENMIPMAP))
+ WARN("Called on a texture without the D3DUSAGE_AUTOGENMIPMAP
flag.\n");
- return ret;
+ return texture->autogen_filter_type;
}
static void WINAPI d3d9_texture_cube_GenerateMipSubLevels(IDirect3DCubeTexture9 *iface)
{
+ struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
+
TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ d3d9_texture_gen_auto_mipmap(texture);
+ wined3d_mutex_unlock();
}
static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *iface, UINT
level, D3DSURFACE_DESC *desc)
@@ -661,6 +755,12 @@ static HRESULT WINAPI
d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *ifac
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
level_count = wined3d_texture_get_level_count(texture->wined3d_texture);
if (level >= level_count)
@@ -673,8 +773,8 @@ static HRESULT WINAPI
d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *ifac
{
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_SURFACE;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = texture->usage;
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access,
wined3d_desc.usage);
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->MultiSampleQuality = wined3d_desc.multisample_quality;
desc->Width = wined3d_desc.width;
@@ -695,6 +795,12 @@ static HRESULT WINAPI
d3d9_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture9
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, face, level,
surface);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
level_count = wined3d_texture_get_level_count(texture->wined3d_texture);
if (level >= level_count)
@@ -729,6 +835,12 @@ static HRESULT WINAPI
d3d9_texture_cube_LockRect(IDirect3DCubeTexture9 *iface,
TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags
%#x.\n",
iface, face, level, locked_rect, rect, flags);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) *
face + level;
if (!(surface_impl =
wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, sub_resource_idx)))
@@ -750,6 +862,12 @@ static HRESULT WINAPI
d3d9_texture_cube_UnlockRect(IDirect3DCubeTexture9 *iface,
TRACE("iface %p, face %#x, level %u.\n", iface, face, level);
+ if (texture->usage & D3DUSAGE_AUTOGENMIPMAP && level)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP textures have only one accessible
level.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
wined3d_mutex_lock();
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) *
face + level;
if (!(surface_impl =
wined3d_texture_get_sub_resource_parent(texture->wined3d_texture, sub_resource_idx)))
@@ -861,16 +979,7 @@ static ULONG WINAPI d3d9_texture_3d_Release(IDirect3DVolumeTexture9
*iface)
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref)
- {
- IDirect3DDevice9Ex *parent_device = texture->parent_device;
-
- wined3d_mutex_lock();
- wined3d_texture_decref(texture->wined3d_texture);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parent_device);
- }
+ d3d9_texture_cleanup(texture);
return ref;
}
@@ -1011,31 +1120,16 @@ static DWORD WINAPI
d3d9_texture_3d_GetLevelCount(IDirect3DVolumeTexture9 *iface
static HRESULT WINAPI d3d9_texture_3d_SetAutoGenFilterType(IDirect3DVolumeTexture9
*iface,
D3DTEXTUREFILTERTYPE filter_type)
{
- struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface);
- HRESULT hr;
-
TRACE("iface %p, filter_type %#x.\n", iface, filter_type);
- wined3d_mutex_lock();
- hr = wined3d_texture_set_autogen_filter_type(texture->wined3d_texture,
- (enum wined3d_texture_filter_type)filter_type);
- wined3d_mutex_unlock();
-
- return hr;
+ return D3DERR_INVALIDCALL;
}
static D3DTEXTUREFILTERTYPE WINAPI
d3d9_texture_3d_GetAutoGenFilterType(IDirect3DVolumeTexture9 *iface)
{
- struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface);
- D3DTEXTUREFILTERTYPE filter_type;
-
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock();
- filter_type =
(D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(texture->wined3d_texture);
- wined3d_mutex_unlock();
-
- return filter_type;
+ return D3DTEXF_NONE;
}
static void WINAPI d3d9_texture_3d_GenerateMipSubLevels(IDirect3DVolumeTexture9 *iface)
@@ -1056,8 +1150,8 @@ static HRESULT WINAPI
d3d9_texture_3d_GetLevelDesc(IDirect3DVolumeTexture9 *ifac
{
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_VOLUME;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = texture->usage;
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access,
wined3d_desc.usage);
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
@@ -1192,7 +1286,7 @@ static void STDMETHODCALLTYPE
d3d9_texture_wined3d_object_destroyed(void *parent
{
struct d3d9_texture *texture = parent;
d3d9_resource_cleanup(&texture->resource);
- HeapFree(GetProcessHeap(), 0, texture);
+ heap_free(texture);
}
static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops =
@@ -1210,14 +1304,18 @@ HRESULT texture_init(struct d3d9_texture *texture, struct
d3d9_device *device,
texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl
*)&d3d9_texture_2d_vtbl;
d3d9_resource_init(&texture->resource);
list_init(&texture->rtv_list);
+ texture->usage = usage;
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
desc.format = wined3dformat_from_d3dformat(format);
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
desc.multisample_quality = 0;
- desc.usage = usage & WINED3DUSAGE_MASK;
+ desc.usage = wined3dusage_from_d3dusage(usage);
desc.usage |= WINED3DUSAGE_TEXTURE;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.width = width;
desc.height = height;
desc.depth = 1;
@@ -1229,13 +1327,28 @@ HRESULT texture_init(struct d3d9_texture *texture, struct
d3d9_device *device,
if (is_gdi_compat_wined3dformat(desc.format))
flags |= WINED3D_TEXTURE_CREATE_GET_DC;
- if (!levels)
+ if (usage & D3DUSAGE_AUTOGENMIPMAP)
{
- if (usage & D3DUSAGE_AUTOGENMIPMAP)
- levels = 1;
- else
- levels = wined3d_log2i(max(width, height)) + 1;
+ if (pool == D3DPOOL_SYSTEMMEM)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP texture can't be in D3DPOOL_SYSTEMMEM,
returning D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
+ }
+ if (levels && levels != 1)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP texture with %u levels, returning
D3DERR_INVALIDCALL.\n", levels);
+ return D3DERR_INVALIDCALL;
+ }
+ flags |= WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS;
+ texture->autogen_filter_type = D3DTEXF_LINEAR;
+ levels = 0;
+ }
+ else
+ {
+ texture->autogen_filter_type = D3DTEXF_NONE;
}
+ if (!levels)
+ levels = wined3d_log2i(max(width, height)) + 1;
wined3d_mutex_lock();
hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, flags,
@@ -1263,14 +1376,18 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct
d3d9_device *devic
texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl
*)&d3d9_texture_cube_vtbl;
d3d9_resource_init(&texture->resource);
list_init(&texture->rtv_list);
+ texture->usage = usage;
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
desc.format = wined3dformat_from_d3dformat(format);
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
desc.multisample_quality = 0;
- desc.usage = usage & WINED3DUSAGE_MASK;
+ desc.usage = wined3dusage_from_d3dusage(usage);
desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage)
+ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.width = edge_length;
desc.height = edge_length;
desc.depth = 1;
@@ -1282,13 +1399,28 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct
d3d9_device *devic
if (is_gdi_compat_wined3dformat(desc.format))
flags |= WINED3D_TEXTURE_CREATE_GET_DC;
- if (!levels)
+ if (usage & D3DUSAGE_AUTOGENMIPMAP)
+ {
+ if (pool == D3DPOOL_SYSTEMMEM)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP texture can't be in D3DPOOL_SYSTEMMEM,
returning D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
+ }
+ if (levels && levels != 1)
+ {
+ WARN("D3DUSAGE_AUTOGENMIPMAP texture with %u levels, returning
D3DERR_INVALIDCALL.\n", levels);
+ return D3DERR_INVALIDCALL;
+ }
+ flags |= WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS;
+ texture->autogen_filter_type = D3DTEXF_LINEAR;
+ levels = 0;
+ }
+ else
{
- if (usage & D3DUSAGE_AUTOGENMIPMAP)
- levels = 1;
- else
- levels = wined3d_log2i(edge_length) + 1;
+ texture->autogen_filter_type = D3DTEXF_NONE;
}
+ if (!levels)
+ levels = wined3d_log2i(edge_length) + 1;
wined3d_mutex_lock();
hr = wined3d_texture_create(device->wined3d_device, &desc, 6, levels, flags,
@@ -1315,26 +1447,29 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct
d3d9_device *dev
texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl
*)&d3d9_texture_3d_vtbl;
d3d9_resource_init(&texture->resource);
list_init(&texture->rtv_list);
+ texture->usage = usage;
desc.resource_type = WINED3D_RTYPE_TEXTURE_3D;
desc.format = wined3dformat_from_d3dformat(format);
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
desc.multisample_quality = 0;
- desc.usage = usage & WINED3DUSAGE_MASK;
+ desc.usage = wined3dusage_from_d3dusage(usage);
desc.usage |= WINED3DUSAGE_TEXTURE;
- desc.pool = pool;
+ if (pool == D3DPOOL_SCRATCH)
+ desc.usage |= WINED3DUSAGE_SCRATCH;
+ desc.access = wined3daccess_from_d3dpool(pool, usage);
desc.width = width;
desc.height = height;
desc.depth = depth;
desc.size = 0;
- if (!levels)
+ if (usage & D3DUSAGE_AUTOGENMIPMAP)
{
- if (usage & D3DUSAGE_AUTOGENMIPMAP)
- levels = 1;
- else
- levels = wined3d_log2i(max(max(width, height), depth)) + 1;
+ WARN("D3DUSAGE_AUTOGENMIPMAP volume texture is not supported, returning
D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
}
+ if (!levels)
+ levels = wined3d_log2i(max(max(width, height), depth)) + 1;
wined3d_mutex_lock();
hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, 0,
diff --git a/dll/directx/wine/d3d9/vertexdeclaration.c
b/dll/directx/wine/d3d9/vertexdeclaration.c
index e9248be5ea..5075309638 100644
--- a/dll/directx/wine/d3d9/vertexdeclaration.c
+++ b/dll/directx/wine/d3d9/vertexdeclaration.c
@@ -19,8 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static const struct
{
enum wined3d_format_id format;
@@ -86,8 +89,8 @@ HRESULT vdecl_convert_fvf(
has_psize + has_diffuse + has_specular + num_textures + 1;
/* convert the declaration */
- elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(D3DVERTEXELEMENT9));
- if (!elements) return D3DERR_OUTOFVIDEOMEMORY;
+ if (!(elements = heap_alloc(size * sizeof(*elements))))
+ return D3DERR_OUTOFVIDEOMEMORY;
elements[size-1] = end_element;
idx = 0;
@@ -307,8 +310,8 @@ struct d3d9_vertex_declaration
*unsafe_impl_from_IDirect3DVertexDeclaration9(IDi
static void STDMETHODCALLTYPE d3d9_vertexdeclaration_wined3d_object_destroyed(void
*parent)
{
struct d3d9_vertex_declaration *declaration = parent;
- HeapFree(GetProcessHeap(), 0, declaration->elements);
- HeapFree(GetProcessHeap(), 0, declaration);
+ heap_free(declaration->elements);
+ heap_free(declaration);
}
static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops =
@@ -333,18 +336,18 @@ static HRESULT convert_to_wined3d_declaration(const
D3DVERTEXELEMENT9 *d3d9_elem
/* Skip the END element */
--count;
- *wined3d_elements = HeapAlloc(GetProcessHeap(), 0, count *
sizeof(**wined3d_elements));
- if (!*wined3d_elements) {
+ if (!(*wined3d_elements = heap_alloc(count * sizeof(**wined3d_elements))))
+ {
FIXME("Memory allocation failed\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
for (i = 0; i < count; ++i)
{
- if (d3d9_elements[i].Type >= (sizeof(d3d_dtype_lookup) /
sizeof(*d3d_dtype_lookup)))
+ if (d3d9_elements[i].Type >= ARRAY_SIZE(d3d_dtype_lookup))
{
WARN("Invalid element type %#x.\n", d3d9_elements[i].Type);
- HeapFree(GetProcessHeap(), 0, *wined3d_elements);
+ heap_free(*wined3d_elements);
return E_FAIL;
}
(*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format;
@@ -382,10 +385,9 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration
*declaratio
declaration->refcount = 1;
element_count = wined3d_element_count + 1;
- declaration->elements = HeapAlloc(GetProcessHeap(), 0, element_count *
sizeof(*declaration->elements));
- if (!declaration->elements)
+ if (!(declaration->elements = heap_alloc(element_count *
sizeof(*declaration->elements))))
{
- HeapFree(GetProcessHeap(), 0, wined3d_elements);
+ heap_free(wined3d_elements);
ERR("Failed to allocate vertex declaration elements memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
@@ -396,10 +398,10 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration
*declaratio
hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements,
wined3d_element_count,
declaration, &d3d9_vertexdeclaration_wined3d_parent_ops,
&declaration->wined3d_declaration);
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, wined3d_elements);
+ heap_free(wined3d_elements);
if (FAILED(hr))
{
- HeapFree(GetProcessHeap(), 0, declaration->elements);
+ heap_free(declaration->elements);
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
return hr;
}
@@ -416,15 +418,14 @@ HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device,
struct d3d9_vertex_declaration *object;
HRESULT hr;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = vertexdeclaration_init(object, device, elements);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
diff --git a/dll/directx/wine/d3d9/volume.c b/dll/directx/wine/d3d9/volume.c
index 5c6a068811..f4c43bc589 100644
--- a/dll/directx/wine/d3d9/volume.c
+++ b/dll/directx/wine/d3d9/volume.c
@@ -19,8 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
#include "d3d9_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
static inline struct d3d9_volume *impl_from_IDirect3DVolume9(IDirect3DVolume9 *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_volume, IDirect3DVolume9_iface);
@@ -123,8 +126,8 @@ static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface,
D3DVOLUME_DES
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = D3DRTYPE_VOLUME;
- desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
- desc->Pool = wined3d_desc.pool;
+ desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
+ desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
@@ -144,7 +147,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface,
wined3d_mutex_lock();
if (FAILED(hr =
wined3d_resource_map(wined3d_texture_get_resource(volume->wined3d_texture),
- volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box,
flags)))
+ volume->sub_resource_idx, &map_desc, (const struct wined3d_box *)box,
+ wined3dmapflags_from_d3dmapflags(flags))))
map_desc.data = NULL;
wined3d_mutex_unlock();
@@ -152,6 +156,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface,
locked_box->SlicePitch = map_desc.slice_pitch;
locked_box->pBits = map_desc.data;
+ if (hr == E_INVALIDARG)
+ return D3DERR_INVALIDCALL;
return hr;
}
@@ -192,7 +198,7 @@ static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void
*parent)
{
struct d3d9_volume *volume = parent;
d3d9_resource_cleanup(&volume->resource);
- HeapFree(GetProcessHeap(), 0, volume);
+ heap_free(volume);
}
static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
diff --git a/dll/directx/wine/ddraw/CMakeLists.txt
b/dll/directx/wine/ddraw/CMakeLists.txt
index ed7801e4ce..6141d630f3 100644
--- a/dll/directx/wine/ddraw/CMakeLists.txt
+++ b/dll/directx/wine/ddraw/CMakeLists.txt
@@ -20,7 +20,7 @@ list(APPEND SOURCE
utils.c
vertexbuffer.c
viewport.c
- ddraw_private.h
+ precomp.h
${CMAKE_CURRENT_BINARY_DIR}/ddraw_stubs.c)
if(MSVC)
@@ -38,5 +38,5 @@ set_module_type(ddraw win32dll)
target_link_libraries(ddraw wine uuid dxguid ${PSEH_LIB})
add_importlibs(ddraw advapi32 gdi32 user32 d3dwine msvcrt kernel32 ntdll)
add_dependencies(ddraw wineheaders)
-add_pch(ddraw ddraw_private.h SOURCE)
+add_pch(ddraw precomp.h SOURCE)
add_cd_file(TARGET ddraw DESTINATION reactos/system32 FOR all)
diff --git a/dll/directx/wine/ddraw/clipper.c b/dll/directx/wine/ddraw/clipper.c
index f1fadd429a..01cac40ec6 100644
--- a/dll/directx/wine/ddraw/clipper.c
+++ b/dll/directx/wine/ddraw/clipper.c
@@ -19,8 +19,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
#include "ddraw_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
+
static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClipper
*iface)
{
return CONTAINING_RECORD(iface, struct ddraw_clipper, IDirectDrawClipper_iface);
@@ -67,7 +72,7 @@ static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface)
{
if (clipper->region)
DeleteObject(clipper->region);
- HeapFree(GetProcessHeap(), 0, clipper);
+ heap_free(clipper);
}
return refcount;
diff --git a/dll/directx/wine/ddraw/ddraw.c b/dll/directx/wine/ddraw/ddraw.c
index 2ab9edd015..e5205c0d00 100644
--- a/dll/directx/wine/ddraw/ddraw.c
+++ b/dll/directx/wine/ddraw/ddraw.c
@@ -21,9 +21,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
#include "ddraw_private.h"
-#include <wine/exception.h>
+#include "wine/exception.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const struct ddraw *exclusive_ddraw;
static HWND exclusive_window;
@@ -45,6 +50,7 @@ static struct enum_device_entry
char interface_name[100];
char device_name[100];
const GUID *device_guid;
+ DWORD remove_caps;
} device_list7[] =
{
/* T&L HAL device */
@@ -52,6 +58,7 @@ static struct enum_device_entry
"WINE Direct3D7 Hardware Transform and Lighting acceleration using
WineD3D",
"Wine D3D7 T&L HAL",
&IID_IDirect3DTnLHalDevice,
+ 0,
},
/* HAL device */
@@ -59,6 +66,7 @@ static struct enum_device_entry
"WINE Direct3D7 Hardware acceleration using WineD3D",
"Direct3D HAL",
&IID_IDirect3DHALDevice,
+ 0,
},
/* RGB device */
@@ -66,6 +74,7 @@ static struct enum_device_entry
"WINE Direct3D7 RGB Software Emulation using WineD3D",
"Wine D3D7 RGB",
&IID_IDirect3DRGBDevice,
+ D3DDEVCAPS_HWTRANSFORMANDLIGHT,
},
};
@@ -371,7 +380,7 @@ static void ddraw_destroy_swapchain(struct ddraw *ddraw)
{
wined3d_vertex_declaration_decref(ddraw->decls[i].decl);
}
- HeapFree(GetProcessHeap(), 0, ddraw->decls);
+ heap_free(ddraw->decls);
ddraw->numConvertedDecls = 0;
if (FAILED(wined3d_device_uninit_3d(ddraw->wined3d_device)))
@@ -437,7 +446,7 @@ static void ddraw_destroy(struct ddraw *This)
This->d3ddevice->ddraw = NULL;
/* Now free the object */
- HeapFree(GetProcessHeap(), 0, This);
+ heap_free(This);
}
/*****************************************************************************
@@ -595,8 +604,7 @@ static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw,
}
ddraw->declArraySize = 2;
- ddraw->decls = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*ddraw->decls) * ddraw->declArraySize);
- if (!ddraw->decls)
+ if (!(ddraw->decls = heap_alloc_zero(ddraw->declArraySize *
sizeof(*ddraw->decls))))
{
ERR("Error allocating an array for the converted vertex decls.\n");
ddraw->declArraySize = 0;
@@ -625,6 +633,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND
window, BOOL win
swapchain_desc.backbuffer_width = mode.width;
swapchain_desc.backbuffer_height = mode.height;
swapchain_desc.backbuffer_format = mode.format_id;
+ swapchain_desc.backbuffer_usage = WINED3DUSAGE_RENDERTARGET;
swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_COPY;
swapchain_desc.device_window = window;
swapchain_desc.windowed = windowed;
@@ -1430,6 +1439,28 @@ HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7
*caps)
return DD_OK;
}
+HRESULT CALLBACK enum_zbuffer(DDPIXELFORMAT *format, void *ctx)
+{
+ DDCAPS *caps = ctx;
+
+ switch (format->u1.dwZBufferBitDepth)
+ {
+ case 8:
+ caps->dwZBufferBitDepths |= DDBD_8;
+ break;
+ case 16:
+ caps->dwZBufferBitDepths |= DDBD_16;
+ break;
+ case 24:
+ caps->dwZBufferBitDepths |= DDBD_24;
+ break;
+ case 32:
+ caps->dwZBufferBitDepths |= DDBD_32;
+ break;
+ }
+ return D3DENUMRET_OK;
+}
+
/*****************************************************************************
* IDirectDraw7::GetCaps
*
@@ -1510,6 +1541,10 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS
*DriverCaps, DD
caps.dwCaps |= DDCAPS_ALIGNSTRIDE;
caps.dwAlignStrideAlign = DDRAW_STRIDE_ALIGNMENT;
+ caps.ddsOldCaps.dwCaps = caps.ddsCaps.dwCaps;
+
+ IDirect3D7_EnumZBufferFormats(&ddraw->IDirect3D7_iface,
&IID_IDirect3DHALDevice, enum_zbuffer, &caps);
+
if(DriverCaps)
{
DD_STRUCT_COPY_BYSIZE(DriverCaps, &caps);
@@ -1733,7 +1768,7 @@ static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface,
DWORD *NumCodes
outsize = NumCodes && Codes ? *NumCodes : 0;
- for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); ++i)
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d,
WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
mode.format_id, 0, WINED3D_RTYPE_TEXTURE_2D, formats[i])))
@@ -2057,7 +2092,14 @@ static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID
riid)
*****************************************************************************/
static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface)
{
- FIXME("iface %p stub!\n", iface);
+ struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
+
+ TRACE("iface %p.\n", iface);
+
+ ddraw->flags |= DDRAW_GDI_FLIP;
+
+ if (ddraw->primary)
+ ddraw_surface_update_frontbuffer(ddraw->primary, NULL, FALSE);
return DD_OK;
}
@@ -2384,13 +2426,13 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface,
DWORD Flags,
if (!cb)
return DDERR_INVALIDPARAMS;
- enum_modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_modes) *
enum_mode_array_size);
- if (!enum_modes) return DDERR_OUTOFMEMORY;
+ if (!(enum_modes = heap_alloc(enum_mode_array_size * sizeof(*enum_modes))))
+ return DDERR_OUTOFMEMORY;
wined3d_mutex_lock();
pixelformat.dwSize = sizeof(pixelformat);
- for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++)
+ for(fmt = 0; fmt < ARRAY_SIZE(checkFormatList); fmt++)
{
modenum = 0;
while (wined3d_enum_adapter_modes(ddraw->wined3d, WINED3DADAPTER_DEFAULT,
checkFormatList[fmt],
@@ -2449,7 +2491,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface,
DWORD Flags,
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
{
TRACE("Application asked to terminate the enumeration\n");
- HeapFree(GetProcessHeap(), 0, enum_modes);
+ heap_free(enum_modes);
wined3d_mutex_unlock();
return DD_OK;
}
@@ -2459,11 +2501,9 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface,
DWORD Flags,
struct wined3d_display_mode *new_enum_modes;
enum_mode_array_size *= 2;
- new_enum_modes = HeapReAlloc(GetProcessHeap(), 0, enum_modes,
- sizeof(*new_enum_modes) *
enum_mode_array_size);
- if (!new_enum_modes)
+ if (!(new_enum_modes = heap_realloc(enum_modes, enum_mode_array_size *
sizeof(*new_enum_modes))))
{
- HeapFree(GetProcessHeap(), 0, enum_modes);
+ heap_free(enum_modes);
wined3d_mutex_unlock();
return DDERR_OUTOFMEMORY;
}
@@ -2475,7 +2515,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface,
DWORD Flags,
}
TRACE("End of enumeration\n");
- HeapFree(GetProcessHeap(), 0, enum_modes);
+ heap_free(enum_modes);
wined3d_mutex_unlock();
return DD_OK;
@@ -3108,7 +3148,7 @@ static BOOL ddraw_match_surface_desc(const DDSURFACEDESC2
*requested, const DDSU
if ((requested->dwFlags & provided->dwFlags) != requested->dwFlags)
return FALSE;
- for (i=0; i < sizeof(compare)/sizeof(compare[0]); i++)
+ for (i=0; i < ARRAY_SIZE(compare); i++)
{
if (requested->dwFlags & compare[i].flag
&& memcmp((const char *)provided + compare[i].offset,
@@ -3189,46 +3229,97 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface,
DWORD Flags,
{
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
struct ddraw_surface *surf;
- BOOL all, nomatch;
- DDSURFACEDESC2 desc;
- struct list *entry, *entry2;
+ DWORD match_flags = Flags & (DDENUMSURFACES_ALL | DDENUMSURFACES_NOMATCH |
DDENUMSURFACES_MATCH);
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
iface, Flags, DDSD, Context, Callback);
- all = Flags & DDENUMSURFACES_ALL;
- nomatch = Flags & DDENUMSURFACES_NOMATCH;
-
if (!Callback)
return DDERR_INVALIDPARAMS;
- wined3d_mutex_lock();
-
- /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
- LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
+ if (Flags & DDENUMSURFACES_CANBECREATED)
{
- surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
+ IDirectDrawSurface7 *surface;
+ DDSURFACEDESC2 testdesc;
+ HRESULT hr;
+
+ if (match_flags != DDENUMSURFACES_MATCH)
+ return DDERR_INVALIDPARAMS;
- if (!surf->iface_count)
+ if (!DDSD)
+ return DDERR_INVALIDPARAMS;
+
+ memcpy(&testdesc, DDSD, sizeof(testdesc));
+ if (!(testdesc.dwFlags & DDSD_WIDTH))
{
- WARN("Not enumerating surface %p because it doesn't have any
references.\n", surf);
- continue;
+ testdesc.dwFlags |= DDSD_WIDTH;
+ testdesc.dwWidth = 512;
}
+ if (!(testdesc.dwFlags & DDSD_HEIGHT))
+ {
+ testdesc.dwFlags |= DDSD_HEIGHT;
+ testdesc.dwHeight = 512;
+ }
+
+ hr = IDirectDraw7_CreateSurface(iface, &testdesc, &surface, NULL);
+ if (SUCCEEDED(hr))
+ {
+ surf = unsafe_impl_from_IDirectDrawSurface7(surface);
+ Callback(NULL, &surf->surface_desc, Context);
+ IDirectDrawSurface7_Release(surface);
+ }
+ else
+ ERR("Failed to create surface, hr %#x.\n", hr);
+ }
+ else if (Flags & DDENUMSURFACES_DOESEXIST)
+ {
+ BOOL all, nomatch;
+ DDSURFACEDESC2 desc;
+ struct list *entry, *entry2;
+
+ /* a combination of match flags is not allowed */
+ if (match_flags != 0 &&
+ match_flags != DDENUMSURFACES_ALL &&
+ match_flags != DDENUMSURFACES_MATCH &&
+ match_flags != DDENUMSURFACES_NOMATCH)
+ return DDERR_INVALIDPARAMS;
+
+ all = (Flags & DDENUMSURFACES_ALL) != 0;
+ nomatch = (Flags & DDENUMSURFACES_NOMATCH) != 0;
+
+ if (!all && !DDSD)
+ return DDERR_INVALIDPARAMS;
+
+ wined3d_mutex_lock();
- if (all || (nomatch != ddraw_match_surface_desc(DDSD,
&surf->surface_desc)))
+ /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
+ LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
{
- TRACE("Enumerating surface %p.\n", surf);
- desc = surf->surface_desc;
- IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
- if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) !=
DDENUMRET_OK)
+ surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
+
+ if (!surf->iface_count)
{
- wined3d_mutex_unlock();
- return DD_OK;
+ WARN("Not enumerating surface %p because it doesn't have any
references.\n", surf);
+ continue;
+ }
+
+ if (all || (nomatch != ddraw_match_surface_desc(DDSD,
&surf->surface_desc)))
+ {
+ TRACE("Enumerating surface %p.\n", surf);
+ desc = surf->surface_desc;
+ IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
+ if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context)
!= DDENUMRET_OK)
+ {
+ wined3d_mutex_unlock();
+ return DD_OK;
+ }
}
}
- }
- wined3d_mutex_unlock();
+ wined3d_mutex_unlock();
+ }
+ else
+ return DDERR_INVALIDPARAMS;
return DD_OK;
}
@@ -3313,8 +3404,7 @@ HRESULT WINAPI DirectDrawCreateClipper(DWORD flags,
IDirectDrawClipper **clipper
wined3d_mutex_lock();
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
@@ -3324,7 +3414,7 @@ HRESULT WINAPI DirectDrawCreateClipper(DWORD flags,
IDirectDrawClipper **clipper
if (FAILED(hr))
{
WARN("Failed to initialize clipper, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
wined3d_mutex_unlock();
return hr;
}
@@ -3424,8 +3514,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface,
DWORD Flags,
return DDERR_NOCOOPERATIVELEVELSET;
}
- object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc(sizeof(*object))))
{
ERR("Out of memory when allocating memory for a palette
implementation\n");
wined3d_mutex_unlock();
@@ -3436,7 +3525,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface,
DWORD Flags,
if (FAILED(hr))
{
WARN("Failed to initialize palette, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
wined3d_mutex_unlock();
return hr;
}
@@ -3626,6 +3715,7 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface,
LPD3DENUMDEVICESCALLBA
{
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
D3DDEVICEDESC7 device_desc7;
+ DWORD dev_caps;
HRESULT hr;
size_t i;
@@ -3642,11 +3732,15 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface,
LPD3DENUMDEVICESCALLBA
return hr;
}
- for (i = 0; i < sizeof(device_list7)/sizeof(device_list7[0]); i++)
+ dev_caps = device_desc7.dwDevCaps;
+
+ for (i = 0; i < ARRAY_SIZE(device_list7); i++)
{
HRESULT ret;
device_desc7.deviceGUID = *device_list7[i].device_guid;
+ device_desc7.dwDevCaps = dev_caps & ~device_list7[i].remove_caps;
+
ret = callback(device_list7[i].interface_name, device_list7[i].device_name,
&device_desc7, context);
if (ret != DDENUMRET_OK)
{
@@ -3832,10 +3926,10 @@ static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface,
IDirect3DLight **light
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light,
outer_unknown);
- if (outer_unknown) return CLASS_E_NOAGGREGATION;
+ if (outer_unknown)
+ return CLASS_E_NOAGGREGATION;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
ERR("Failed to allocate light memory.\n");
return DDERR_OUTOFMEMORY;
@@ -3982,8 +4076,7 @@ static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface,
IDirect3DViewport3
if (outer_unknown) return CLASS_E_NOAGGREGATION;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
ERR("Failed to allocate viewport memory.\n");
return DDERR_OUTOFMEMORY;
@@ -4044,8 +4137,8 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface,
D3DFINDDEVICESEARCH *fd
if (!fds || !fdr) return DDERR_INVALIDPARAMS;
- if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH)
- || fdr->dwSize != sizeof(D3DFINDDEVICERESULT))
+ if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) || (fdr->dwSize !=
sizeof(D3DFINDDEVICERESULT1) &&
+ fdr->dwSize != sizeof(D3DFINDDEVICERESULT2) && fdr->dwSize !=
sizeof(D3DFINDDEVICERESULT)))
return DDERR_INVALIDPARAMS;
if ((fds->dwFlags & D3DFDS_COLORMODEL)
@@ -4074,8 +4167,24 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface,
D3DFINDDEVICESEARCH *fd
/* Now return our own GUID */
ddraw_d3dcaps1_from_7(&desc1, &desc7);
fdr->guid = IID_D3DDEVICE_WineD3D;
- fdr->ddHwDesc = desc1;
- fdr->ddSwDesc = desc1;
+
+ if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT1))
+ {
+ D3DFINDDEVICERESULT1 *fdr1 = (D3DFINDDEVICERESULT1 *)fdr;
+ memcpy(&fdr1->ddHwDesc, &desc1, sizeof(fdr1->ddHwDesc));
+ memcpy(&fdr1->ddSwDesc, &desc1, sizeof(fdr1->ddSwDesc));
+ }
+ else if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT2))
+ {
+ D3DFINDDEVICERESULT2 *fdr2 = (D3DFINDDEVICERESULT2 *)fdr;
+ memcpy(&fdr2->ddHwDesc, &desc1, sizeof(fdr2->ddHwDesc));
+ memcpy(&fdr2->ddSwDesc, &desc1, sizeof(fdr2->ddSwDesc));
+ }
+ else
+ {
+ fdr->ddHwDesc = desc1;
+ fdr->ddSwDesc = desc1;
+ }
TRACE("Returning Wine's wined3d device with (undumped)
capabilities.\n");
@@ -4132,7 +4241,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID
riid,
TRACE("iface %p, riid %s, surface %p, device %p.\n", iface,
debugstr_guid(riid), surface, device);
wined3d_mutex_lock();
- if (SUCCEEDED(hr = d3d_device_create(ddraw, target, (IUnknown *)surface, 7,
&object, NULL)))
+ if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, target, (IUnknown *)surface, 7,
&object, NULL)))
{
*device = &object->IDirect3DDevice7_iface;
}
@@ -4161,7 +4270,7 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID
riid,
return CLASS_E_NOAGGREGATION;
wined3d_mutex_lock();
- if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 3,
&device_impl, NULL)))
+ if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, surface_impl, (IUnknown *)surface,
3, &device_impl, NULL)))
{
*device = &device_impl->IDirect3DDevice3_iface;
}
@@ -4187,7 +4296,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID
riid,
iface, debugstr_guid(riid), surface, device);
wined3d_mutex_lock();
- if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 2,
&device_impl, NULL)))
+ if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, surface_impl, (IUnknown *)surface,
2, &device_impl, NULL)))
{
*device = &device_impl->IDirect3DDevice2_iface;
}
@@ -4357,7 +4466,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface,
REFCLSID device
return hr;
}
- for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i)
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d,
WINED3DADAPTER_DEFAULT, type, mode.format_id,
WINED3DUSAGE_DEPTHSTENCIL, WINED3D_RTYPE_TEXTURE_2D, formats[i])))
@@ -4559,7 +4668,7 @@ static const struct IDirectDraw2Vtbl ddraw2_vtbl =
ddraw2_GetAvailableVidMem,
};
-static const struct IDirectDrawVtbl ddraw1_vtbl =
+static struct IDirectDrawVtbl ddraw1_vtbl =
{
/* IUnknown */
ddraw1_QueryInterface,
@@ -4698,11 +4807,12 @@ struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw
*This, DWORD fvf
fvf, This, &ddraw_null_wined3d_parent_ops, &pDecl);
if (hr != S_OK) return NULL;
- if(This->declArraySize == This->numConvertedDecls) {
- int grow = max(This->declArraySize / 2, 8);
- convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
- sizeof(convertedDecls[0]) *
(This->numConvertedDecls + grow));
- if (!convertedDecls)
+ if (This->declArraySize == This->numConvertedDecls)
+ {
+ unsigned int grow = max(This->declArraySize / 2, 8);
+
+ if (!(convertedDecls = heap_realloc(convertedDecls,
+ (This->numConvertedDecls + grow) * sizeof(*convertedDecls))))
{
wined3d_vertex_declaration_decref(pDecl);
return NULL;
@@ -4818,7 +4928,7 @@ static HRESULT CDECL device_parent_surface_created(struct
wined3d_device_parent
return DD_OK;
}
- if (!(ddraw_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*ddraw_surface))))
+ if (!(ddraw_surface = heap_alloc_zero(sizeof(*ddraw_surface))))
{
ERR("Failed to allocate surface memory.\n");
return DDERR_OUTOFVIDEOMEMORY;
diff --git a/dll/directx/wine/ddraw/ddraw_private.h
b/dll/directx/wine/ddraw/ddraw_private.h
index 04ee59c05f..1454e8012a 100644
--- a/dll/directx/wine/ddraw/ddraw_private.h
+++ b/dll/directx/wine/ddraw/ddraw_private.h
@@ -19,30 +19,25 @@
#ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
#define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
-#include <config.h>
-#include <wine/port.h>
-
#include <assert.h>
-#include <stdarg.h>
-
-#define _INC_WINDOWS
-#define COM_NO_WINDOW_H
-
+#include <limits.h>
#define COBJMACROS
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
+#include "wine/debug.h"
+#include "wine/heap.h"
-#include <windef.h>
-#include <winbase.h>
-#include <wingdi.h>
-#include <winuser.h>
-#include <d3d.h>
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
-#include <wine/debug.h>
-#include <wine/list.h>
-#include <wine/wined3d.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
+#include "d3d.h"
+#include "ddraw.h"
+#ifdef DDRAW_INIT_GUID
+#include "initguid.h"
+#endif
+#include "wine/list.h"
+#include "wine/wined3d.h"
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
@@ -64,13 +59,14 @@ struct FvfToDecl
#define DDRAW_NO3D 0x00000008
#define DDRAW_SCL_DDRAW1 0x00000010
#define DDRAW_SCL_RECURSIVE 0x00000020
+#define DDRAW_GDI_FLIP 0x00000040
#define DDRAW_STRIDE_ALIGNMENT 8
#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_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT)
enum ddraw_device_state
{
@@ -309,6 +305,7 @@ struct d3d_device
IUnknown IUnknown_inner;
LONG ref;
UINT version;
+ BOOL hw;
IUnknown *outer_unknown;
struct wined3d_device *wined3d_device;
@@ -353,7 +350,7 @@ struct d3d_device
struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES];
};
-HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown
*rt_iface,
+HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, 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;
@@ -592,6 +589,7 @@ void ddrawformat_from_wined3dformat(DDPIXELFORMAT *ddraw_format,
BOOL wined3d_colour_from_ddraw_colour(const DDPIXELFORMAT *pf, const struct ddraw_palette
*palette,
DWORD colour, struct wined3d_color *wined3d_colour) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_ddrawformat(const DDPIXELFORMAT *format)
DECLSPEC_HIDDEN;
+unsigned int wined3dmapflags_from_ddrawmapflags(unsigned int flags) DECLSPEC_HIDDEN;
void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN;
void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN;
void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;
diff --git a/dll/directx/wine/ddraw/device.c b/dll/directx/wine/ddraw/device.c
index fe48ad3b36..24dbd3be50 100644
--- a/dll/directx/wine/ddraw/device.c
+++ b/dll/directx/wine/ddraw/device.c
@@ -27,8 +27,12 @@
*
*/
+#include "config.h"
+#include "wine/port.h"
+
#include "ddraw_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(winediag);
/* The device ID */
@@ -318,7 +322,7 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface)
This->ddraw->d3ddevice = NULL;
/* Now free the structure */
- HeapFree(GetProcessHeap(), 0, This);
+ heap_free(This);
wined3d_mutex_unlock();
}
@@ -659,8 +663,7 @@ static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice
*iface,
return CLASS_E_NOAGGREGATION;
/* Allocate the new Execute Buffer */
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if(!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
ERR("Failed to allocate execute buffer memory.\n");
return DDERR_OUTOFMEMORY;
@@ -670,7 +673,7 @@ static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice
*iface,
if (FAILED(hr))
{
WARN("Failed to initialize execute buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
@@ -1083,7 +1086,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7
*iface,
return hr;
}
- for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
+ for (i = 0; i < ARRAY_SIZE(FormatList); ++i)
{
if (wined3d_check_device_format(device->ddraw->wined3d,
WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
mode.format_id, WINED3DUSAGE_TEXTURE, WINED3D_RTYPE_TEXTURE_2D,
FormatList[i]) == D3D_OK)
@@ -1105,7 +1108,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7
*iface,
}
}
- for (i = 0; i < sizeof(BumpFormatList) / sizeof(*BumpFormatList); ++i)
+ for (i = 0; i < ARRAY_SIZE(BumpFormatList); ++i)
{
if (wined3d_check_device_format(device->ddraw->wined3d,
WINED3DADAPTER_DEFAULT,
WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_TEXTURE |
WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
@@ -1211,7 +1214,7 @@ static HRESULT WINAPI
d3d_device2_EnumTextureFormats(IDirect3DDevice2 *iface,
return hr;
}
- for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
+ for (i = 0; i < ARRAY_SIZE(FormatList); ++i)
{
if (wined3d_check_device_format(device->ddraw->wined3d, 0,
WINED3D_DEVICE_TYPE_HAL,
mode.format_id, WINED3DUSAGE_TEXTURE, WINED3D_RTYPE_TEXTURE_2D,
FormatList[i]) == D3D_OK)
@@ -1270,7 +1273,7 @@ static HRESULT WINAPI d3d_device1_EnumTextureFormats(IDirect3DDevice
*iface,
static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE
*D3DMatHandle)
{
struct d3d_device *device = impl_from_IDirect3DDevice(iface);
- D3DMATRIX *Matrix;
+ D3DMATRIX *matrix;
DWORD h;
TRACE("iface %p, matrix_handle %p.\n", iface, D3DMatHandle);
@@ -1278,8 +1281,7 @@ static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice
*iface, D3DMATRIX
if(!D3DMatHandle)
return DDERR_INVALIDPARAMS;
- Matrix = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DMATRIX));
- if(!Matrix)
+ if (!(matrix = heap_alloc_zero(sizeof(*matrix))))
{
ERR("Out of memory when allocating a D3DMATRIX\n");
return DDERR_OUTOFMEMORY;
@@ -1287,11 +1289,11 @@ static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice
*iface, D3DMATRIX
wined3d_mutex_lock();
- h = ddraw_allocate_handle(&device->handle_table, Matrix,
DDRAW_HANDLE_MATRIX);
+ h = ddraw_allocate_handle(&device->handle_table, matrix,
DDRAW_HANDLE_MATRIX);
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate a matrix handle.\n");
- HeapFree(GetProcessHeap(), 0, Matrix);
+ heap_free(matrix);
wined3d_mutex_unlock();
return DDERR_OUTOFMEMORY;
}
@@ -1442,7 +1444,7 @@ static HRESULT WINAPI d3d_device1_DeleteMatrix(IDirect3DDevice
*iface, D3DMATRIX
wined3d_mutex_unlock();
- HeapFree(GetProcessHeap(), 0, m);
+ heap_free(m);
return D3D_OK;
}
@@ -1852,7 +1854,7 @@ static HRESULT d3d_device7_SetRenderTarget(IDirect3DDevice7 *iface,
return DDERR_INVALIDCAPS;
}
- if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
+ if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps &
DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target_impl);
wined3d_mutex_unlock();
@@ -1928,7 +1930,7 @@ static HRESULT WINAPI d3d_device3_SetRenderTarget(IDirect3DDevice3
*iface,
return DDERR_INVALIDPIXELFORMAT;
}
- if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
+ if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps &
DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target_impl);
IDirectDrawSurface4_AddRef(target);
@@ -1977,7 +1979,7 @@ static HRESULT WINAPI d3d_device2_SetRenderTarget(IDirect3DDevice2
*iface,
return DDERR_INVALIDPIXELFORMAT;
}
- if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
+ if (device->hw && !(target_impl->surface_desc.ddsCaps.dwCaps &
DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target_impl);
IDirectDrawSurface_AddRef(target);
@@ -2214,11 +2216,11 @@ static HRESULT WINAPI d3d_device3_Vertex(IDirect3DDevice3 *iface,
void *vertex)
device->buffer_size = device->buffer_size ? device->buffer_size * 2 :
device->vertex_size * 3;
old_buffer = device->sysmem_vertex_buffer;
- device->sysmem_vertex_buffer = HeapAlloc(GetProcessHeap(), 0,
device->buffer_size);
+ device->sysmem_vertex_buffer = heap_alloc(device->buffer_size);
if (old_buffer)
{
memcpy(device->sysmem_vertex_buffer, old_buffer, device->nb_vertices *
device->vertex_size);
- HeapFree(GetProcessHeap(), 0, old_buffer);
+ heap_free(old_buffer);
}
}
@@ -3461,15 +3463,22 @@ static HRESULT d3d_device_prepare_vertex_buffer(struct d3d_device
*device, UINT
if (device->vertex_buffer_size < min_size || !device->vertex_buffer)
{
UINT size = max(device->vertex_buffer_size * 2, min_size);
+ struct wined3d_buffer_desc desc;
struct wined3d_buffer *buffer;
TRACE("Growing vertex buffer to %u bytes\n", size);
- hr = wined3d_buffer_create_vb(device->wined3d_device, size,
WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
- WINED3D_POOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops,
&buffer);
- if (FAILED(hr))
+ desc.byte_width = size;
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY;
+ desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
+ NULL, NULL, &ddraw_null_wined3d_parent_ops, &buffer)))
{
- ERR("(%p) wined3d_buffer_create_vb failed with hr = %08x\n",
device, hr);
+ ERR("Failed to create vertex buffer, hr %#x.\n", hr);
return hr;
}
@@ -3524,7 +3533,7 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface,
wined3d_box.right = vb_pos + size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, vertices, size);
wined3d_resource_unmap(vb, 0);
@@ -3646,15 +3655,22 @@ static HRESULT d3d_device_prepare_index_buffer(struct d3d_device
*device, UINT m
if (device->index_buffer_size < min_size || !device->index_buffer)
{
UINT size = max(device->index_buffer_size * 2, min_size);
+ struct wined3d_buffer_desc desc;
struct wined3d_buffer *buffer;
TRACE("Growing index buffer to %u bytes\n", size);
- hr = wined3d_buffer_create_ib(device->wined3d_device, size,
WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
- WINED3D_POOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops,
&buffer);
- if (FAILED(hr))
+ desc.byte_width = size;
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY |
WINED3DUSAGE_STATICDECL;
+ desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
+ NULL, NULL, &ddraw_null_wined3d_parent_ops, &buffer)))
{
- ERR("(%p) wined3d_buffer_create_ib failed with hr = %08x\n",
device, hr);
+ ERR("Failed to create index buffer, hr %#x.\n", hr);
return hr;
}
@@ -3709,7 +3725,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7
*iface,
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, vertices, vtx_size);
wined3d_resource_unmap(vb, 0);
@@ -3726,7 +3742,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7
*iface,
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, indices, idx_size);
wined3d_resource_unmap(ib, 0);
@@ -4040,7 +4056,7 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7
*iface, D3DPRIM
wined3d_box.right = vb_pos + dst_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
pack_strided_data(wined3d_map_desc.data, vertex_count, strided_data, fvf);
wined3d_resource_unmap(vb, 0);
@@ -4156,7 +4172,7 @@ static HRESULT
d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
wined3d_box.right = vb_pos + vtx_dst_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
- vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (vb_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
pack_strided_data(wined3d_map_desc.data, vertex_count, strided_data, fvf);
wined3d_resource_unmap(vb, 0);
@@ -4173,7 +4189,7 @@ static HRESULT
d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
goto done;
memcpy(wined3d_map_desc.data, indices, idx_size);
wined3d_resource_unmap(ib, 0);
@@ -4393,7 +4409,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7
*iface,
wined3d_box.right = ib_pos + index_count * sizeof(WORD);
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
- ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
+ WINED3D_MAP_WRITE | (ib_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD))))
{
ERR("Failed to map buffer, hr %#x.\n", hr);
wined3d_mutex_unlock();
@@ -6887,7 +6903,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,
+static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, BOOL hw,
struct ddraw_surface *target, IUnknown *rt_iface, UINT version, IUnknown
*outer_unknown)
{
static const D3DMATRIX ident =
@@ -6910,6 +6926,7 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct
ddraw *ddraw,
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;
@@ -6960,14 +6977,18 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct
ddraw *ddraw,
return D3D_OK;
}
-HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown
*rt_iface,
+HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, 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, target %p, version %u, device %p, outer_unknown %p.\n",
- ddraw, target, version, device, outer_unknown);
+ 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;
if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
|| (target->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
@@ -6982,7 +7003,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface
*target, IUn
return DDERR_NOPALETTEATTACHED;
}
- if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
+ if (hw && !(target->surface_desc.ddsCaps.dwCaps &
DDSCAPS_VIDEOMEMORY))
{
WARN("Surface %p is not in video memory.\n", target);
return D3DERR_SURFACENOTINVIDMEM;
@@ -7002,17 +7023,16 @@ HRESULT d3d_device_create(struct ddraw *ddraw, struct
ddraw_surface *target, IUn
return DDERR_INVALIDPARAMS;
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
+ if (!(object = heap_alloc_zero(sizeof(*object))))
{
ERR("Failed to allocate device memory.\n");
return DDERR_OUTOFMEMORY;
}
- if (FAILED(hr = d3d_device_init(object, ddraw, target, rt_iface, version,
outer_unknown)))
+ if (FAILED(hr = d3d_device_init(object, ddraw, hw, target, rt_iface, version,
outer_unknown)))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
+ heap_free(object);
return hr;
}
diff --git a/dll/directx/wine/ddraw/executebuffer.c
b/dll/directx/wine/ddraw/executebuffer.c
index 7b68bd70b5..17bea2764c 100644
--- a/dll/directx/wine/ddraw/executebuffer.c
+++ b/dll/directx/wine/ddraw/executebuffer.c
@@ -18,8 +18,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
#include "ddraw_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
+
/*****************************************************************************
* _dump_executedata
* _dump_D3DEXECUTEBUFFERDESC
@@ -119,13 +124,20 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer
*buffer,
if (buffer->index_size < index_count)
{
- struct wined3d_buffer *new_buffer;
unsigned int new_size = max(buffer->index_size * 2, index_count);
-
- hr = wined3d_buffer_create_ib(device->wined3d_device, new_size *
sizeof(*indices),
- WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
WINED3D_POOL_DEFAULT,
- NULL, &ddraw_null_wined3d_parent_ops, &new_buffer);
- if (FAILED(hr))
+ struct wined3d_buffer *new_buffer;
+ struct wined3d_buffer_desc desc;
+
+ desc.byte_width = new_size * sizeof(*indices);
+ desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY |
WINED3DUSAGE_STATICDECL;
+ desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU
+ | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(device->wined3d_device,
&desc,
+ NULL, NULL, &ddraw_null_wined3d_parent_ops,
&new_buffer)))
return hr;
buffer->index_size = new_size;
@@ -141,9 +153,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer,
box.left = index_pos * sizeof(*indices);
box.right = (index_pos + index_count) * sizeof(*indices);
- hr =
wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0,
- &map_desc, &box, index_pos ? WINED3D_MAP_NOOVERWRITE :
WINED3D_MAP_DISCARD);
- if (FAILED(hr))
+ if (FAILED(hr =
wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0,
&map_desc,
+ &box, WINED3D_MAP_WRITE | (index_pos ?
WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
return hr;
indices = map_desc.data;
@@ -297,7 +308,10 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer
*buffer,
ci->wStart, ci->wDest, ci->dwCount,
ci->dwFlags);
if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
- FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not
implemented.\n");
+ {
+ static int once;
+ if (!once++) FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not
implemented.\n");
+ }
if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
FIXME("D3DPROCESSVERTICES_NOCOLOR not
implemented.\n");
@@ -497,7 +511,7 @@ static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer
*iface)
if (!ref)
{
if (buffer->need_free)
- HeapFree(GetProcessHeap(), 0, buffer->desc.lpData);
+ heap_free(buffer->desc.lpData);
if (buffer->index_buffer)
wined3d_buffer_decref(buffer->index_buffer);
if (buffer->dst_vertex_buffer)
@@ -505,7 +519,7 @@ static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer
*iface)
wined3d_buffer_decref(buffer->src_vertex_buffer);
wined3d_buffer_decref(buffer->dst_vertex_buffer);
}
- HeapFree(GetProcessHeap(), 0, buffer);
+ heap_free(buffer);
}
return ref;
@@ -606,17 +620,25 @@ static HRESULT WINAPI
d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer *
{
unsigned int new_size = max(data->dwVertexCount, buffer->vertex_size * 2);
struct wined3d_buffer *src_buffer, *dst_buffer;
+ struct wined3d_buffer_desc desc;
- hr = wined3d_buffer_create_vb(buffer->d3ddev->wined3d_device, new_size *
sizeof(D3DVERTEX),
- WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY, WINED3D_POOL_SYSTEM_MEM,
- NULL, &ddraw_null_wined3d_parent_ops, &src_buffer);
- if (FAILED(hr))
+ desc.byte_width = new_size * sizeof(D3DVERTEX);
+ desc.usage = 0;
+ desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
+ desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+ desc.misc_flags = 0;
+ desc.structure_byte_stride = 0;
+
+ if (FAILED(hr = wined3d_buffer_create(buffer->d3ddev->wined3d_device,
&desc,
+ NULL, NULL, &ddraw_null_wined3d_parent_ops, &src_buffer)))
return hr;
- hr = wined3d_buffer_create_vb(buffer->d3ddev->wined3d_device, new_size *
sizeof(D3DTLVERTEX),
- WINED3DUSAGE_STATICDECL, WINED3D_POOL_DEFAULT,
- NULL, &ddraw_null_wined3d_parent_ops, &dst_buffer);
- if (FAILED(hr))
+ desc.byte_width = new_size * sizeof(D3DTLVERTEX);
+ desc.usage = WINED3DUSAGE_STATICDECL;
+ desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R |
WINED3D_RESOURCE_ACCESS_MAP_W;
+
+ if (FAILED(hr = wined3d_buffer_create(buffer->d3ddev->wined3d_device,
&desc,
+ NULL, NULL, &ddraw_null_wined3d_parent_ops, &dst_buffer)))
{
wined3d_buffer_decref(src_buffer);
return hr;
@@ -641,9 +663,8 @@ static HRESULT WINAPI
d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer *
{
box.left = buffer->src_vertex_pos * sizeof(D3DVERTEX);
box.right = box.left + data->dwVertexCount * sizeof(D3DVERTEX);
- hr =
wined3d_resource_map(wined3d_buffer_get_resource(buffer->src_vertex_buffer), 0,
- &map_desc, &box, buffer->src_vertex_pos ?
WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD);
- if (FAILED(hr))
+ if (FAILED(hr =
wined3d_resource_map(wined3d_buffer_get_resource(buffer->src_vertex_buffer),
+ 0, &map_desc, &box, WINED3D_MAP_WRITE)))
return hr;
memcpy(map_desc.data, ((BYTE *)buffer->desc.lpData) +
data->dwVertexOffset,
@@ -773,8 +794,7 @@ HRESULT d3d_execute_buffer_init(struct d3d_execute_buffer
*execute_buffer,
if (!execute_buffer->desc.lpData && execute_buffer->desc.dwBufferSize)
{
execute_buffer->need_free = TRUE;
- execute_buffer->desc.lpData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
execute_buffer->desc.dwBufferSize);
- if (!execute_buffer->desc.lpData)
+ if (!(execute_buffer->desc.lpData =
heap_alloc_zero(execute_buffer->desc.dwBufferSize)))
{
ERR("Failed to allocate execute buffer data.\n");
return DDERR_OUTOFMEMORY;
diff --git a/dll/directx/wine/ddraw/light.c b/dll/directx/wine/ddraw/light.c
index d20c132c37..9d0bb6028f 100644
--- a/dll/directx/wine/ddraw/light.c
+++ b/dll/directx/wine/ddraw/light.c
@@ -17,8 +17,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
#include "ddraw_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
+
/*****************************************************************************
* light_update
*
@@ -128,7 +133,7 @@ static ULONG WINAPI d3d_light_Release(IDirect3DLight *iface)
if (!ref)
{
- HeapFree(GetProcessHeap(), 0, light);
+ heap_free(light);
return 0;
}
return ref;
diff --git a/dll/directx/wine/ddraw/main.c b/dll/directx/wine/ddraw/main.c
index ea3cbbe42d..9c0a81ca18 100644
--- a/dll/directx/wine/ddraw/main.c
+++ b/dll/directx/wine/ddraw/main.c
@@ -21,11 +21,17 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
+#define DDRAW_INIT_GUID
#include "ddraw_private.h"
-#include <winreg.h>
-#include <rpcproxy.h>
+#include "rpcproxy.h"
#include "wine/exception.h"
+#include "winreg.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static struct list global_ddraw_list = LIST_INIT(global_ddraw_list);
@@ -86,8 +92,7 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d,
LPDDENUMC
/* Handle table functions */
BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size)
{
- t->entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, initial_size *
sizeof(*t->entries));
- if (!t->entries)
+ if (!(t->entries = heap_alloc_zero(initial_size * sizeof(*t->entries))))
{
ERR("Failed to allocate handle table memory.\n");
return FALSE;
@@ -101,7 +106,7 @@ BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT
initial_size)
void ddraw_handle_table_destroy(struct ddraw_handle_table *t)
{
- HeapFree(GetProcessHeap(), 0, t->entries);
+ heap_free(t->entries);
memset(t, 0, sizeof(*t));
}
@@ -130,9 +135,9 @@ DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void
*object, enum ddr
{
/* Grow the table */
UINT new_size = t->table_size + (t->table_size >> 1);
- struct ddraw_handle_entry *new_entries = HeapReAlloc(GetProcessHeap(),
- 0, t->entries, new_size * sizeof(*t->entries));
- if (!new_entries)
+ struct ddraw_handle_entry *new_entries;
+
+ if (!(new_entries = heap_realloc(t->entries, new_size *
sizeof(*t->entries))))
{
ERR("Failed to grow the handle table.\n");
return DDRAW_INVALID_HANDLE;
@@ -292,8 +297,7 @@ DDRAW_Create(const GUID *guid,
flags = WINED3D_LEGACY_FFP_LIGHTING;
/* DirectDraw creation comes here */
- ddraw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw));
- if (!ddraw)
+ if (!(ddraw = heap_alloc_zero(sizeof(*ddraw))))
{
ERR("Out of memory when creating DirectDraw\n");
return E_OUTOFMEMORY;
@@ -303,7 +307,7 @@ DDRAW_Create(const GUID *guid,
if (FAILED(hr))
{
WARN("Failed to initialize ddraw object, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, ddraw);
+ heap_free(ddraw);
return hr;
}
@@ -664,7 +668,7 @@ static ULONG WINAPI ddraw_class_factory_Release(IClassFactory *iface)
TRACE("%p decreasing refcount to %u.\n", factory, ref);
if (!ref)
- HeapFree(GetProcessHeap(), 0, factory);
+ heap_free(factory);
return ref;
}
@@ -736,20 +740,20 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void
**out)
&& !IsEqualGUID(&IID_IUnknown, riid))
return E_NOINTERFACE;
- for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
+ for (i=0; i < ARRAY_SIZE(object_creation); i++)
{
... 16675 lines suppressed ...