From: Amine Khaldi Date: Tue, 23 Sep 2014 17:50:22 +0000 (+0000) Subject: [D3D8][D3D9][DDRAW][WINED3D] X-Git-Tag: backups/0.3.17@66124~497 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=a20555967180d5f637cf783c46988e3a8491929d [D3D8][D3D9][DDRAW][WINED3D] * Sync with Wine 1.7.27. CORE-8540 svn path=/trunk/; revision=64240 --- diff --git a/reactos/dll/directx/wine/d3d8/buffer.c b/reactos/dll/directx/wine/d3d8/buffer.c index e230519dae0..a5786cca04a 100644 --- a/reactos/dll/directx/wine/d3d8/buffer.c +++ b/reactos/dll/directx/wine/d3d8/buffer.c @@ -128,12 +128,14 @@ static HRESULT WINAPI d3d8_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer8 * static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface, DWORD priority) { struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface); + struct wined3d_resource *resource; DWORD previous; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + previous = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return previous; @@ -142,12 +144,14 @@ static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface, static DWORD WINAPI d3d8_vertexbuffer_GetPriority(IDirect3DVertexBuffer8 *iface) { struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface); + const struct wined3d_resource *resource; DWORD priority; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - priority = wined3d_buffer_get_priority(buffer->wined3d_buffer); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + priority = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return priority; @@ -401,12 +405,14 @@ static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *if static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, DWORD priority) { struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface); + struct wined3d_resource *resource; DWORD previous; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + previous = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return previous; @@ -415,12 +421,14 @@ static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, D static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface) { struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface); + const struct wined3d_resource *resource; DWORD priority; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - priority = wined3d_buffer_get_priority(buffer->wined3d_buffer); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + priority = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return priority; diff --git a/reactos/dll/directx/wine/d3d8/d3d8_main.c b/reactos/dll/directx/wine/d3d8/d3d8_main.c index a4dc5e69e2f..144817a545b 100644 --- a/reactos/dll/directx/wine/d3d8/d3d8_main.c +++ b/reactos/dll/directx/wine/d3d8/d3d8_main.c @@ -51,15 +51,6 @@ IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version) return &object->IDirect3D8_iface; } -/* At process attach */ -BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) -{ - if (reason == DLL_PROCESS_ATTACH) - DisableThreadLibraryCalls(inst); - - return TRUE; -} - /*********************************************************************** * ValidateVertexShader (D3D8.@) * diff --git a/reactos/dll/directx/wine/d3d8/d3d8_private.h b/reactos/dll/directx/wine/d3d8/d3d8_private.h index a60652d78f3..6d79917fc14 100644 --- a/reactos/dll/directx/wine/d3d8/d3d8_private.h +++ b/reactos/dll/directx/wine/d3d8/d3d8_private.h @@ -153,6 +153,13 @@ struct FvfToDecl struct d3d8_vertex_declaration *declaration; }; +enum d3d8_device_state +{ + D3D8_DEVICE_STATE_OK, + D3D8_DEVICE_STATE_LOST, + D3D8_DEVICE_STATE_NOT_RESET, +}; + struct d3d8_device { /* IUnknown fields */ @@ -175,14 +182,19 @@ struct d3d8_device UINT index_buffer_size; UINT index_buffer_pos; + LONG device_state; /* Avoids recursion with nested ReleaseRef to 0 */ BOOL inDestruction; - BOOL lost; }; HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) DECLSPEC_HIDDEN; +static inline struct d3d8_device *impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface) +{ + return CONTAINING_RECORD(iface, struct d3d8_device, IDirect3DDevice8_iface); +} + struct d3d8_resource { LONG refcount; @@ -202,12 +214,11 @@ struct d3d8_volume IDirect3DVolume8 IDirect3DVolume8_iface; struct d3d8_resource resource; struct wined3d_volume *wined3d_volume; - IUnknown *container; - IUnknown *forwardReference; + struct d3d8_texture *texture; }; -void volume_init(struct d3d8_volume *volume, struct wined3d_volume *wined3d_volume, - const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; +void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d8_swapchain { @@ -225,17 +236,16 @@ struct d3d8_surface IDirect3DSurface8 IDirect3DSurface8_iface; struct d3d8_resource resource; struct wined3d_surface *wined3d_surface; + struct list rtv_entry; + struct wined3d_rendertarget_view *wined3d_rtv; IDirect3DDevice8 *parent_device; - - /* The surface container */ - IUnknown *container; - - /* If set forward refcounting to this object */ - IUnknown *forwardReference; + IUnknown *container; + struct d3d8_texture *texture; }; -void surface_init(struct d3d8_surface *surface, struct wined3d_surface *wined3d_surface, - struct d3d8_device *device, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; +struct wined3d_rendertarget_view *d3d8_surface_get_rendertarget_view(struct d3d8_surface *surface) DECLSPEC_HIDDEN; +void surface_init(struct d3d8_surface *surface, IUnknown *container_parent, + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN; struct d3d8_vertexbuffer @@ -270,6 +280,7 @@ struct d3d8_texture struct d3d8_resource resource; struct wined3d_texture *wined3d_texture; IDirect3DDevice8 *parent_device; + struct list rtv_list; }; HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *device, diff --git a/reactos/dll/directx/wine/d3d8/device.c b/reactos/dll/directx/wine/d3d8/device.c index c519f80f0ea..7516764c8d5 100644 --- a/reactos/dll/directx/wine/d3d8/device.c +++ b/reactos/dll/directx/wine/d3d8/device.c @@ -286,11 +286,6 @@ static void *d3d8_get_object(struct d3d8_handle_table *t, DWORD handle, enum d3d return entry->object; } -static inline struct d3d8_device *impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface) -{ - return CONTAINING_RECORD(iface, struct d3d8_device, IDirect3DDevice8_iface); -} - static HRESULT WINAPI d3d8_device_QueryInterface(IDirect3DDevice8 *iface, REFIID riid, void **out) { TRACE("iface %p, riid %s, out %p.\n", @@ -373,27 +368,32 @@ static HRESULT WINAPI d3d8_device_TestCooperativeLevel(IDirect3DDevice8 *iface) TRACE("iface %p.\n", iface); - if (device->lost) + TRACE("device state: %#x.\n", device->device_state); + + switch (device->device_state) { - TRACE("Device is lost.\n"); - return D3DERR_DEVICENOTRESET; + default: + case D3D8_DEVICE_STATE_OK: + return D3D_OK; + case D3D8_DEVICE_STATE_LOST: + return D3DERR_DEVICELOST; + case D3D8_DEVICE_STATE_NOT_RESET: + return D3DERR_DEVICENOTRESET; } - - return D3D_OK; } static UINT WINAPI d3d8_device_GetAvailableTextureMem(IDirect3DDevice8 *iface) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; + UINT ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - hr = wined3d_device_get_available_texture_mem(device->wined3d_device); + ret = wined3d_device_get_available_texture_mem(device->wined3d_device); wined3d_mutex_unlock(); - return hr; + return ret; } static HRESULT WINAPI d3d8_device_ResourceManagerDiscardBytes(IDirect3DDevice8 *iface, DWORD byte_count) @@ -626,11 +626,11 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface, NULL, reset_enum_callback, TRUE))) { wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_POINTSIZE_MIN, 0); - device->lost = FALSE; + device->device_state = D3D8_DEVICE_STATE_OK; } else { - device->lost = TRUE; + device->device_state = D3D8_DEVICE_STATE_NOT_RESET; } wined3d_mutex_unlock(); @@ -646,6 +646,9 @@ static HRESULT WINAPI d3d8_device_Present(IDirect3DDevice8 *iface, const RECT *s TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n", iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region); + if (device->device_state != D3D8_DEVICE_STATE_OK) + return D3DERR_DEVICELOST; + wined3d_mutex_lock(); hr = wined3d_device_present(device->wined3d_device, src_rect, dst_rect, dst_window_override, dirty_region, 0); @@ -900,7 +903,6 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width sub_resource = wined3d_texture_get_sub_resource(texture, 0); surface_impl = wined3d_resource_get_parent(sub_resource); - surface_impl->forwardReference = NULL; surface_impl->parent_device = &device->IDirect3DDevice8_iface; *surface = &surface_impl->IDirect3DSurface8_iface; IDirect3DSurface8_AddRef(*surface); @@ -1110,7 +1112,7 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface, struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_surface *rt_impl = unsafe_impl_from_IDirect3DSurface8(render_target); struct d3d8_surface *ds_impl = unsafe_impl_from_IDirect3DSurface8(depth_stencil); - struct wined3d_surface *original_ds = NULL; + struct wined3d_rendertarget_view *original_dsv; HRESULT hr = D3D_OK; TRACE("iface %p, render_target %p, depth_stencil %p.\n", iface, render_target, depth_stencil); @@ -1119,19 +1121,22 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface, if (ds_impl) { + struct wined3d_rendertarget_view *original_rtv; struct wined3d_resource_desc ds_desc, rt_desc; struct wined3d_resource *wined3d_resource; - struct wined3d_surface *original_rt = NULL; + struct d3d8_surface *original_surface; /* If no render target is passed in check the size against the current RT */ if (!render_target) { - if (!(original_rt = wined3d_device_get_render_target(device->wined3d_device, 0))) + + if (!(original_rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, 0))) { wined3d_mutex_unlock(); return D3DERR_NOTFOUND; } - wined3d_resource = wined3d_surface_get_resource(original_rt); + original_surface = wined3d_rendertarget_view_get_sub_resource_parent(original_rtv); + wined3d_resource = wined3d_surface_get_resource(original_surface->wined3d_surface); } else wined3d_resource = wined3d_surface_get_resource(rt_impl->wined3d_surface); @@ -1148,14 +1153,12 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface, } } - original_ds = wined3d_device_get_depth_stencil(device->wined3d_device); - wined3d_device_set_depth_stencil(device->wined3d_device, ds_impl ? ds_impl->wined3d_surface : NULL); - if (render_target) - { - hr = wined3d_device_set_render_target(device->wined3d_device, 0, rt_impl->wined3d_surface, TRUE); - if (FAILED(hr)) - wined3d_device_set_depth_stencil(device->wined3d_device, original_ds); - } + original_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device); + wined3d_device_set_depth_stencil_view(device->wined3d_device, + ds_impl ? d3d8_surface_get_rendertarget_view(ds_impl) : NULL); + if (render_target && FAILED(hr = wined3d_device_set_rendertarget_view(device->wined3d_device, 0, + d3d8_surface_get_rendertarget_view(rt_impl), TRUE))) + wined3d_device_set_depth_stencil_view(device->wined3d_device, original_dsv); wined3d_mutex_unlock(); @@ -1165,7 +1168,7 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface, static HRESULT WINAPI d3d8_device_GetRenderTarget(IDirect3DDevice8 *iface, IDirect3DSurface8 **render_target) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - struct wined3d_surface *wined3d_surface; + struct wined3d_rendertarget_view *wined3d_rtv; struct d3d8_surface *surface_impl; HRESULT hr; @@ -1175,9 +1178,11 @@ static HRESULT WINAPI d3d8_device_GetRenderTarget(IDirect3DDevice8 *iface, IDire return D3DERR_INVALIDCALL; wined3d_mutex_lock(); - if ((wined3d_surface = wined3d_device_get_render_target(device->wined3d_device, 0))) + if ((wined3d_rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, 0))) { - surface_impl = wined3d_surface_get_parent(wined3d_surface); + /* We want the sub resource parent here, since the view itself may be + * internal to wined3d and may not have a parent. */ + surface_impl = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_rtv); *render_target = &surface_impl->IDirect3DSurface8_iface; IDirect3DSurface8_AddRef(*render_target); hr = D3D_OK; @@ -1196,7 +1201,7 @@ static HRESULT WINAPI d3d8_device_GetRenderTarget(IDirect3DDevice8 *iface, IDire static HRESULT WINAPI d3d8_device_GetDepthStencilSurface(IDirect3DDevice8 *iface, IDirect3DSurface8 **depth_stencil) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - struct wined3d_surface *wined3d_surface; + struct wined3d_rendertarget_view *wined3d_dsv; struct d3d8_surface *surface_impl; HRESULT hr = D3D_OK; @@ -1206,9 +1211,11 @@ static HRESULT WINAPI d3d8_device_GetDepthStencilSurface(IDirect3DDevice8 *iface return D3DERR_INVALIDCALL; wined3d_mutex_lock(); - if ((wined3d_surface = wined3d_device_get_depth_stencil(device->wined3d_device))) + if ((wined3d_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device))) { - surface_impl = wined3d_surface_get_parent(wined3d_surface); + /* We want the sub resource parent here, since the view itself may be + * internal to wined3d and may not have a parent. */ + surface_impl = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_dsv); *depth_stencil = &surface_impl->IDirect3DSurface8_iface; IDirect3DSurface8_AddRef(*depth_stencil); } @@ -2776,7 +2783,6 @@ static HRESULT WINAPI d3d8_device_GetStreamSource(IDirect3DDevice8 *iface, buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); *buffer = &buffer_impl->IDirect3DVertexBuffer8_iface; IDirect3DVertexBuffer8_AddRef(*buffer); - wined3d_buffer_decref(wined3d_buffer); } else { @@ -2906,33 +2912,34 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic TRACE("device_parent %p.\n", device_parent); } +static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + struct d3d8_device *device = device_from_device_parent(device_parent); + + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); + + if (!activate) + InterlockedCompareExchange(&device->device_state, D3D8_DEVICE_STATE_LOST, D3D8_DEVICE_STATE_OK); + else + InterlockedCompareExchange(&device->device_state, D3D8_DEVICE_STATE_NOT_RESET, D3D8_DEVICE_STATE_LOST); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) { - struct d3d8_device *device = device_from_device_parent(device_parent); struct d3d8_surface *d3d_surface; TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n", device_parent, container_parent, surface, parent, parent_ops); if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) - { - FIXME("Failed to allocate surface memory.\n"); - return D3DERR_OUTOFVIDEOMEMORY; - } + return E_OUTOFMEMORY; - surface_init(d3d_surface, surface, device, parent_ops); + surface_init(d3d_surface, container_parent, surface, parent_ops); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface); - d3d_surface->container = container_parent; - IDirect3DDevice8_Release(d3d_surface->parent_device); - d3d_surface->parent_device = NULL; - - IDirect3DSurface8_Release(&d3d_surface->IDirect3DSurface8_iface); - d3d_surface->forwardReference = container_parent; - return D3D_OK; } @@ -2948,15 +2955,10 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent * if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY; - volume_init(d3d_volume, volume, parent_ops); + volume_init(d3d_volume, container_parent, volume, parent_ops); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume); - d3d_volume->container = container_parent; - - IDirect3DVolume8_Release(&d3d_volume->IDirect3DVolume8_iface); - d3d_volume->forwardReference = container_parent; - return D3D_OK; } @@ -2986,7 +2988,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic wined3d_texture_decref(texture); d3d_surface = wined3d_surface_get_parent(*surface); - d3d_surface->forwardReference = NULL; d3d_surface->parent_device = &device->IDirect3DDevice8_iface; return hr; @@ -3019,6 +3020,7 @@ static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/reactos/dll/directx/wine/d3d8/surface.c b/reactos/dll/directx/wine/d3d8/surface.c index 116b5b94a12..33100361af4 100644 --- a/reactos/dll/directx/wine/d3d8/surface.c +++ b/reactos/dll/directx/wine/d3d8/surface.c @@ -47,69 +47,64 @@ static HRESULT WINAPI d3d8_surface_QueryInterface(IDirect3DSurface8 *iface, REFI static ULONG WINAPI d3d8_surface_AddRef(IDirect3DSurface8 *iface) { struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface); + ULONG refcount; TRACE("iface %p.\n", iface); - if (surface->forwardReference) + if (surface->texture) { - /* Forward refcounting */ - TRACE("Forwarding to %p.\n", surface->forwardReference); - return IUnknown_AddRef(surface->forwardReference); + TRACE("Forwarding to %p.\n", surface->texture); + return IDirect3DBaseTexture8_AddRef(&surface->texture->IDirect3DBaseTexture8_iface); } - else - { - /* No container, handle our own refcounting */ - ULONG ref = InterlockedIncrement(&surface->resource.refcount); - - TRACE("%p increasing refcount to %u.\n", iface, ref); - if (ref == 1) - { - if (surface->parent_device) - IDirect3DDevice8_AddRef(surface->parent_device); - wined3d_mutex_lock(); - wined3d_surface_incref(surface->wined3d_surface); - wined3d_mutex_unlock(); - } + refcount = InterlockedIncrement(&surface->resource.refcount); + TRACE("%p increasing refcount to %u.\n", iface, refcount); - return ref; + if (refcount == 1) + { + if (surface->parent_device) + IDirect3DDevice8_AddRef(surface->parent_device); + wined3d_mutex_lock(); + if (surface->wined3d_rtv) + wined3d_rendertarget_view_incref(surface->wined3d_rtv); + wined3d_surface_incref(surface->wined3d_surface); + wined3d_mutex_unlock(); } + + return refcount; } static ULONG WINAPI d3d8_surface_Release(IDirect3DSurface8 *iface) { struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface); + ULONG refcount; TRACE("iface %p.\n", iface); - if (surface->forwardReference) + if (surface->texture) { - /* Forward refcounting */ - TRACE("Forwarding to %p.\n", surface->forwardReference); - return IUnknown_Release(surface->forwardReference); + TRACE("Forwarding to %p.\n", surface->texture); + return IDirect3DBaseTexture8_Release(&surface->texture->IDirect3DBaseTexture8_iface); } - else - { - /* No container, handle our own refcounting */ - ULONG ref = InterlockedDecrement(&surface->resource.refcount); - - TRACE("%p decreasing refcount to %u.\n", iface, ref); - if (!ref) - { - IDirect3DDevice8 *parent_device = surface->parent_device; + refcount = InterlockedDecrement(&surface->resource.refcount); + TRACE("%p decreasing refcount to %u.\n", iface, refcount); - /* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */ - wined3d_mutex_lock(); - wined3d_surface_decref(surface->wined3d_surface); - wined3d_mutex_unlock(); + if (!refcount) + { + IDirect3DDevice8 *parent_device = surface->parent_device; - if (parent_device) - IDirect3DDevice8_Release(parent_device); - } + wined3d_mutex_lock(); + if (surface->wined3d_rtv) + wined3d_rendertarget_view_decref(surface->wined3d_rtv); + wined3d_surface_decref(surface->wined3d_surface); + wined3d_mutex_unlock(); - return ref; + if (parent_device) + IDirect3DDevice8_Release(parent_device); } + + return refcount; } static HRESULT WINAPI d3d8_surface_GetDevice(IDirect3DSurface8 *iface, IDirect3DDevice8 **device) @@ -118,22 +113,8 @@ static HRESULT WINAPI d3d8_surface_GetDevice(IDirect3DSurface8 *iface, IDirect3D TRACE("iface %p, device %p.\n", iface, device); - if (surface->forwardReference) - { - IDirect3DResource8 *resource; - HRESULT hr; - - hr = IUnknown_QueryInterface(surface->forwardReference, &IID_IDirect3DResource8, (void **)&resource); - if (SUCCEEDED(hr)) - { - hr = IDirect3DResource8_GetDevice(resource, device); - IDirect3DResource8_Release(resource); - - TRACE("Returning device %p.\n", *device); - } - - return hr; - } + if (surface->texture) + return IDirect3DBaseTexture8_GetDevice(&surface->texture->IDirect3DBaseTexture8_iface, device); *device = surface->parent_device; IDirect3DDevice8_AddRef(*device); @@ -308,19 +289,70 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = surface_wined3d_object_destroyed, }; -void surface_init(struct d3d8_surface *surface, struct wined3d_surface *wined3d_surface, - struct d3d8_device *device, const struct wined3d_parent_ops **parent_ops) +void surface_init(struct d3d8_surface *surface, IUnknown *container_parent, + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) { + IDirect3DBaseTexture8 *texture; + surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl; d3d8_resource_init(&surface->resource); - wined3d_surface_incref(wined3d_surface); + surface->resource.refcount = 0; surface->wined3d_surface = wined3d_surface; - surface->parent_device = &device->IDirect3DDevice8_iface; - IDirect3DDevice8_AddRef(surface->parent_device); + list_init(&surface->rtv_entry); + surface->container = container_parent; + + if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent, + &IID_IDirect3DBaseTexture8, (void **)&texture))) + { + surface->texture = unsafe_impl_from_IDirect3DBaseTexture8(texture); + IDirect3DBaseTexture8_Release(texture); + } *parent_ops = &d3d8_surface_wined3d_parent_ops; } +static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent) +{ + struct d3d8_surface *surface = parent; + + /* If the surface reference count drops to zero, we release our reference + * to the view, but don't clear the pointer yet, in case e.g. a + * GetRenderTarget() call brings the surface back before the view is + * actually destroyed. When the view is destroyed, we need to clear the + * pointer, or a subsequent surface AddRef() would reference it again. + * + * This is safe because as long as the view still has a reference to the + * texture, the surface is also still alive, and we're called before the + * view releases that reference. */ + surface->wined3d_rtv = NULL; + list_remove(&surface->rtv_entry); +} + +static const struct wined3d_parent_ops d3d8_view_wined3d_parent_ops = +{ + view_wined3d_object_destroyed, +}; + +struct wined3d_rendertarget_view *d3d8_surface_get_rendertarget_view(struct d3d8_surface *surface) +{ + HRESULT hr; + + if (surface->wined3d_rtv) + return surface->wined3d_rtv; + + if (FAILED(hr = wined3d_rendertarget_view_create_from_surface(surface->wined3d_surface, + surface, &d3d8_view_wined3d_parent_ops, &surface->wined3d_rtv))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return NULL; + } + + if (surface->texture) + list_add_head(&surface->texture->rtv_list, &surface->rtv_entry); + + return surface->wined3d_rtv; +} + struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) { if (!iface) diff --git a/reactos/dll/directx/wine/d3d8/swapchain.c b/reactos/dll/directx/wine/d3d8/swapchain.c index 80c7e7d199b..9e69efb0495 100644 --- a/reactos/dll/directx/wine/d3d8/swapchain.c +++ b/reactos/dll/directx/wine/d3d8/swapchain.c @@ -88,11 +88,15 @@ static HRESULT WINAPI d3d8_swapchain_Present(IDirect3DSwapChain8 *iface, const RGNDATA *dirty_region) { struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface); + struct d3d8_device *device = impl_from_IDirect3DDevice8(swapchain->parent_device); HRESULT hr; TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n", iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region); + if (device->device_state != D3D8_DEVICE_STATE_OK) + return D3DERR_DEVICELOST; + wined3d_mutex_lock(); hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, src_rect, dst_rect, dst_window_override, dirty_region, 0); diff --git a/reactos/dll/directx/wine/d3d8/texture.c b/reactos/dll/directx/wine/d3d8/texture.c index 7aadf5b3dab..76c18cf6b46 100644 --- a/reactos/dll/directx/wine/d3d8/texture.c +++ b/reactos/dll/directx/wine/d3d8/texture.c @@ -62,8 +62,14 @@ static ULONG WINAPI d3d8_texture_2d_AddRef(IDirect3DTexture8 *iface) if (ref == 1) { + struct d3d8_surface *surface; + IDirect3DDevice8_AddRef(texture->parent_device); wined3d_mutex_lock(); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d8_surface, rtv_entry) + { + wined3d_rendertarget_view_incref(surface->wined3d_rtv); + } wined3d_texture_incref(texture->wined3d_texture); wined3d_mutex_unlock(); } @@ -81,8 +87,13 @@ static ULONG WINAPI d3d8_texture_2d_Release(IDirect3DTexture8 *iface) if (!ref) { IDirect3DDevice8 *parent_device = texture->parent_device; + struct d3d8_surface *surface; wined3d_mutex_lock(); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d8_surface, rtv_entry) + { + wined3d_rendertarget_view_decref(surface->wined3d_rtv); + } wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); @@ -137,12 +148,14 @@ static HRESULT WINAPI d3d8_texture_2d_FreePrivateData(IDirect3DTexture8 *iface, static DWORD WINAPI d3d8_texture_2d_SetPriority(IDirect3DTexture8 *iface, DWORD priority) { struct d3d8_texture *texture = impl_from_IDirect3DTexture8(iface); + struct wined3d_resource *resource; DWORD ret; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - ret = wined3d_texture_set_priority(texture->wined3d_texture, priority); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return ret; @@ -151,12 +164,14 @@ static DWORD WINAPI d3d8_texture_2d_SetPriority(IDirect3DTexture8 *iface, DWORD static DWORD WINAPI d3d8_texture_2d_GetPriority(IDirect3DTexture8 *iface) { struct d3d8_texture *texture = impl_from_IDirect3DTexture8(iface); + const struct wined3d_resource *resource; DWORD ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - ret = wined3d_texture_get_priority(texture->wined3d_texture); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return ret; @@ -406,8 +421,14 @@ static ULONG WINAPI d3d8_texture_cube_AddRef(IDirect3DCubeTexture8 *iface) if (ref == 1) { + struct d3d8_surface *surface; + IDirect3DDevice8_AddRef(texture->parent_device); wined3d_mutex_lock(); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d8_surface, rtv_entry) + { + wined3d_rendertarget_view_incref(surface->wined3d_rtv); + } wined3d_texture_incref(texture->wined3d_texture); wined3d_mutex_unlock(); } @@ -425,10 +446,15 @@ static ULONG WINAPI d3d8_texture_cube_Release(IDirect3DCubeTexture8 *iface) if (!ref) { IDirect3DDevice8 *parent_device = texture->parent_device; + struct d3d8_surface *surface; TRACE("Releasing child %p.\n", texture->wined3d_texture); wined3d_mutex_lock(); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d8_surface, rtv_entry) + { + wined3d_rendertarget_view_decref(surface->wined3d_rtv); + } wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); @@ -483,12 +509,14 @@ static HRESULT WINAPI d3d8_texture_cube_FreePrivateData(IDirect3DCubeTexture8 *i static DWORD WINAPI d3d8_texture_cube_SetPriority(IDirect3DCubeTexture8 *iface, DWORD priority) { struct d3d8_texture *texture = impl_from_IDirect3DCubeTexture8(iface); + struct wined3d_resource *resource; DWORD ret; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - ret = wined3d_texture_set_priority(texture->wined3d_texture, priority); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return ret; @@ -497,12 +525,14 @@ static DWORD WINAPI d3d8_texture_cube_SetPriority(IDirect3DCubeTexture8 *iface, static DWORD WINAPI d3d8_texture_cube_GetPriority(IDirect3DCubeTexture8 *iface) { struct d3d8_texture *texture = impl_from_IDirect3DCubeTexture8(iface); + const struct wined3d_resource *resource; DWORD ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - ret = wined3d_texture_get_priority(texture->wined3d_texture); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return ret; @@ -850,12 +880,14 @@ static HRESULT WINAPI d3d8_texture_3d_FreePrivateData(IDirect3DVolumeTexture8 *i static DWORD WINAPI d3d8_texture_3d_SetPriority(IDirect3DVolumeTexture8 *iface, DWORD priority) { struct d3d8_texture *texture = impl_from_IDirect3DVolumeTexture8(iface); + struct wined3d_resource *resource; DWORD ret; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - ret = wined3d_texture_set_priority(texture->wined3d_texture, priority); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return ret; @@ -864,12 +896,14 @@ static DWORD WINAPI d3d8_texture_3d_SetPriority(IDirect3DVolumeTexture8 *iface, static DWORD WINAPI d3d8_texture_3d_GetPriority(IDirect3DVolumeTexture8 *iface) { struct d3d8_texture *texture = impl_from_IDirect3DVolumeTexture8(iface); + const struct wined3d_resource *resource; DWORD ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - ret = wined3d_texture_get_priority(texture->wined3d_texture); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return ret; @@ -1118,6 +1152,7 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, texture->IDirect3DBaseTexture8_iface.lpVtbl = (const IDirect3DBaseTexture8Vtbl *)&Direct3DTexture8_Vtbl; d3d8_resource_init(&texture->resource); + list_init(&texture->rtv_list); desc.resource_type = WINED3D_RTYPE_TEXTURE; desc.format = wined3dformat_from_d3dformat(format); @@ -1159,6 +1194,7 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic texture->IDirect3DBaseTexture8_iface.lpVtbl = (const IDirect3DBaseTexture8Vtbl *)&Direct3DCubeTexture8_Vtbl; d3d8_resource_init(&texture->resource); + list_init(&texture->rtv_list); desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE; desc.format = wined3dformat_from_d3dformat(format); @@ -1199,6 +1235,7 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev texture->IDirect3DBaseTexture8_iface.lpVtbl = (const IDirect3DBaseTexture8Vtbl *)&Direct3DVolumeTexture8_Vtbl; d3d8_resource_init(&texture->resource); + list_init(&texture->rtv_list); desc.resource_type = WINED3D_RTYPE_VOLUME_TEXTURE; desc.format = wined3dformat_from_d3dformat(format); diff --git a/reactos/dll/directx/wine/d3d8/volume.c b/reactos/dll/directx/wine/d3d8/volume.c index 6396887e7cf..8c94f53d3a7 100644 --- a/reactos/dll/directx/wine/d3d8/volume.c +++ b/reactos/dll/directx/wine/d3d8/volume.c @@ -48,29 +48,9 @@ static ULONG WINAPI d3d8_volume_AddRef(IDirect3DVolume8 *iface) struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); TRACE("iface %p.\n", iface); + TRACE("Forwarding to %p.\n", volume->texture); - if (volume->forwardReference) - { - /* Forward to the containerParent */ - TRACE("Forwarding to %p,\n", volume->forwardReference); - return IUnknown_AddRef(volume->forwardReference); - } - else - { - /* No container, handle our own refcounting */ - ULONG ref = InterlockedIncrement(&volume->resource.refcount); - - TRACE("%p increasing refcount to %u.\n", iface, ref); - - if (ref == 1) - { - wined3d_mutex_lock(); - wined3d_volume_incref(volume->wined3d_volume); - wined3d_mutex_unlock(); - } - - return ref; - } + return IDirect3DBaseTexture8_AddRef(&volume->texture->IDirect3DBaseTexture8_iface); } static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface) @@ -78,49 +58,18 @@ static ULONG WINAPI d3d8_volume_Release(IDirect3DVolume8 *iface) struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); TRACE("iface %p.\n", iface); + TRACE("Forwarding to %p.\n", volume->texture); - if (volume->forwardReference) - { - /* Forward to the containerParent */ - TRACE("Forwarding to %p.\n", volume->forwardReference); - return IUnknown_Release(volume->forwardReference); - } - else - { - /* No container, handle our own refcounting */ - ULONG ref = InterlockedDecrement(&volume->resource.refcount); - - TRACE("%p decreasing refcount to %u.\n", iface, ref); - - if (!ref) - { - wined3d_mutex_lock(); - wined3d_volume_decref(volume->wined3d_volume); - wined3d_mutex_unlock(); - } - - return ref; - } + return IDirect3DBaseTexture8_Release(&volume->texture->IDirect3DBaseTexture8_iface); } static HRESULT WINAPI d3d8_volume_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); - IDirect3DResource8 *resource; - HRESULT hr; TRACE("iface %p, device %p.\n", iface, device); - hr = IUnknown_QueryInterface(volume->forwardReference, &IID_IDirect3DResource8, (void **)&resource); - if (SUCCEEDED(hr)) - { - hr = IDirect3DResource8_GetDevice(resource, device); - IDirect3DResource8_Release(resource); - - TRACE("Returning device %p.\n", *device); - } - - return hr; + return IDirect3DBaseTexture8_GetDevice(&volume->texture->IDirect3DBaseTexture8_iface, device); } static HRESULT WINAPI d3d8_volume_SetPrivateData(IDirect3DVolume8 *iface, REFGUID guid, @@ -154,19 +103,10 @@ static HRESULT WINAPI d3d8_volume_FreePrivateData(IDirect3DVolume8 *iface, REFGU static HRESULT WINAPI d3d8_volume_GetContainer(IDirect3DVolume8 *iface, REFIID riid, void **container) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); - HRESULT res; - - TRACE("iface %p, riid %s, container %p.\n", - iface, debugstr_guid(riid), container); - - if (!volume->container) - return E_NOINTERFACE; - - res = IUnknown_QueryInterface(volume->container, riid, container); - TRACE("Returning %p.\n", *container); + TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container); - return res; + return IDirect3DBaseTexture8_QueryInterface(&volume->texture->IDirect3DBaseTexture8_iface, riid, container); } static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc) @@ -258,13 +198,14 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = volume_wined3d_object_destroyed, }; -void volume_init(struct d3d8_volume *volume, struct wined3d_volume *wined3d_volume, - const struct wined3d_parent_ops **parent_ops) +void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) { volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl; d3d8_resource_init(&volume->resource); - wined3d_volume_incref(wined3d_volume); + volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; + volume->texture = texture; *parent_ops = &d3d8_volume_wined3d_parent_ops; } diff --git a/reactos/dll/directx/wine/d3d9/buffer.c b/reactos/dll/directx/wine/d3d9/buffer.c index bb91b2aa5dc..9101fd10cc4 100644 --- a/reactos/dll/directx/wine/d3d9/buffer.c +++ b/reactos/dll/directx/wine/d3d9/buffer.c @@ -129,12 +129,14 @@ static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 * static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface, DWORD priority) { struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface); + struct wined3d_resource *resource; DWORD previous; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + previous = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return previous; @@ -143,12 +145,14 @@ static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface, static DWORD WINAPI d3d9_vertexbuffer_GetPriority(IDirect3DVertexBuffer9 *iface) { struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface); + const struct wined3d_resource *resource; DWORD priority; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - priority = wined3d_buffer_get_priority(buffer->wined3d_buffer); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + priority = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return priority; @@ -401,12 +405,14 @@ static HRESULT WINAPI d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *if static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, DWORD priority) { struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface); + struct wined3d_resource *resource; DWORD previous; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + previous = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return previous; @@ -415,12 +421,14 @@ static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, D static DWORD WINAPI d3d9_indexbuffer_GetPriority(IDirect3DIndexBuffer9 *iface) { struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface); + const struct wined3d_resource *resource; DWORD priority; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - priority = wined3d_buffer_get_priority(buffer->wined3d_buffer); + resource = wined3d_buffer_get_resource(buffer->wined3d_buffer); + priority = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return priority; diff --git a/reactos/dll/directx/wine/d3d9/d3d9_main.c b/reactos/dll/directx/wine/d3d9/d3d9_main.c index c0518562919..4bd80e1b916 100644 --- a/reactos/dll/directx/wine/d3d9/d3d9_main.c +++ b/reactos/dll/directx/wine/d3d9/d3d9_main.c @@ -86,17 +86,6 @@ void* WINAPI Direct3DShaderValidatorCreate9(void) return NULL; } -/******************************************************************* - * DllMain - */ -BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) -{ - if (reason == DLL_PROCESS_ATTACH) - DisableThreadLibraryCalls(inst); - - return TRUE; -} - /*********************************************************************** * D3DPERF_BeginEvent (D3D9.@) */ diff --git a/reactos/dll/directx/wine/d3d9/d3d9_private.h b/reactos/dll/directx/wine/d3d9/d3d9_private.h index fb8d1666c9b..300a5f04c7a 100644 --- a/reactos/dll/directx/wine/d3d9/d3d9_private.h +++ b/reactos/dll/directx/wine/d3d9/d3d9_private.h @@ -145,6 +145,13 @@ struct fvf_declaration DWORD fvf; }; +enum d3d9_device_state +{ + D3D9_DEVICE_STATE_OK, + D3D9_DEVICE_STATE_LOST, + D3D9_DEVICE_STATE_NOT_RESET, +}; + struct d3d9_device { IDirect3DDevice9Ex IDirect3DDevice9Ex_iface; @@ -163,8 +170,8 @@ struct d3d9_device UINT index_buffer_size; UINT index_buffer_pos; + LONG device_state; BOOL in_destruction; - BOOL not_reset; BOOL in_scene; }; @@ -191,12 +198,11 @@ struct d3d9_volume IDirect3DVolume9 IDirect3DVolume9_iface; struct d3d9_resource resource; struct wined3d_volume *wined3d_volume; - IUnknown *container; - IUnknown *forwardReference; + struct d3d9_texture *texture; }; -void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume, - const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; +void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d9_swapchain { @@ -214,14 +220,17 @@ struct d3d9_surface IDirect3DSurface9 IDirect3DSurface9_iface; struct d3d9_resource resource; struct wined3d_surface *wined3d_surface; + struct list rtv_entry; + struct wined3d_rendertarget_view *wined3d_rtv; IDirect3DDevice9Ex *parent_device; IUnknown *container; - IUnknown *forwardReference; + struct d3d9_texture *texture; BOOL getdc_supported; }; -void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface, - struct d3d9_device *device, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; +struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN; +void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN; struct d3d9_vertexbuffer @@ -256,6 +265,7 @@ struct d3d9_texture struct d3d9_resource resource; struct wined3d_texture *wined3d_texture; IDirect3DDevice9Ex *parent_device; + struct list rtv_list; }; HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *device, diff --git a/reactos/dll/directx/wine/d3d9/device.c b/reactos/dll/directx/wine/d3d9/device.c index 7306d0851ba..ff430d5fda4 100644 --- a/reactos/dll/directx/wine/d3d9/device.c +++ b/reactos/dll/directx/wine/d3d9/device.c @@ -320,27 +320,35 @@ static HRESULT WINAPI d3d9_device_TestCooperativeLevel(IDirect3DDevice9Ex *iface TRACE("iface %p.\n", iface); - if (device->not_reset) + TRACE("device state: %#x.\n", device->device_state); + + if (device->d3d_parent->extended) + return D3D_OK; + + switch (device->device_state) { - TRACE("D3D9 device is marked not reset.\n"); - return D3DERR_DEVICENOTRESET; + default: + case D3D9_DEVICE_STATE_OK: + return D3D_OK; + case D3D9_DEVICE_STATE_LOST: + return D3DERR_DEVICELOST; + case D3D9_DEVICE_STATE_NOT_RESET: + return D3DERR_DEVICENOTRESET; } - - return D3D_OK; } static UINT WINAPI d3d9_device_GetAvailableTextureMem(IDirect3DDevice9Ex *iface) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr; + UINT ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - hr = wined3d_device_get_available_texture_mem(device->wined3d_device); + ret = wined3d_device_get_available_texture_mem(device->wined3d_device); wined3d_mutex_unlock(); - return hr; + return ret; } static HRESULT WINAPI d3d9_device_EvictManagedResources(IDirect3DDevice9Ex *iface) @@ -618,9 +626,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, NULL, reset_enum_callback, !device->d3d_parent->extended); if (FAILED(hr) && !device->d3d_parent->extended) - device->not_reset = TRUE; + device->device_state = D3D9_DEVICE_STATE_NOT_RESET; else - device->not_reset = FALSE; + device->device_state = D3D9_DEVICE_STATE_OK; wined3d_mutex_unlock(); return hr; @@ -635,6 +643,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex * TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n", iface, src_rect, dst_rect, dst_window_override, dirty_region); + if (device->device_state != D3D9_DEVICE_STATE_OK) + return device->d3d_parent->extended ? S_PRESENT_OCCLUDED : D3DERR_DEVICELOST; + wined3d_mutex_lock(); hr = wined3d_device_present(device->wined3d_device, src_rect, dst_rect, dst_window_override, dirty_region, 0); @@ -1012,7 +1023,6 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width sub_resource = wined3d_texture_get_sub_resource(texture, 0); surface_impl = wined3d_resource_get_parent(sub_resource); - surface_impl->forwardReference = NULL; surface_impl->parent_device = &device->IDirect3DDevice9Ex_iface; *surface = &surface_impl->IDirect3DSurface9_iface; IDirect3DSurface9_AddRef(*surface); @@ -1258,8 +1268,14 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface, return D3DERR_INVALIDCALL; } - /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */ - hr = wined3d_device_color_fill(device->wined3d_device, surface_impl->wined3d_surface, rect, &c); + if (desc.pool != WINED3D_POOL_DEFAULT && desc.pool != WINED3D_POOL_SYSTEM_MEM) + { + WARN("Color-fill not allowed on surfaces in pool %#x.\n", desc.pool); + return D3DERR_INVALIDCALL; + } + + hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, + d3d9_surface_get_rendertarget_view(surface_impl), rect, &c); wined3d_mutex_unlock(); @@ -1332,8 +1348,8 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO } wined3d_mutex_lock(); - hr = wined3d_device_set_render_target(device->wined3d_device, idx, - surface_impl ? surface_impl->wined3d_surface : NULL, TRUE); + hr = wined3d_device_set_rendertarget_view(device->wined3d_device, idx, + surface_impl ? d3d9_surface_get_rendertarget_view(surface_impl) : NULL, TRUE); wined3d_mutex_unlock(); return hr; @@ -1342,7 +1358,7 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 **surface) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - struct wined3d_surface *wined3d_surface; + struct wined3d_rendertarget_view *wined3d_rtv; struct d3d9_surface *surface_impl; HRESULT hr = D3D_OK; @@ -1358,9 +1374,11 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO } wined3d_mutex_lock(); - if ((wined3d_surface = wined3d_device_get_render_target(device->wined3d_device, idx))) + if ((wined3d_rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, idx))) { - surface_impl = wined3d_surface_get_parent(wined3d_surface); + /* We want the sub resource parent here, since the view itself may be + * internal to wined3d and may not have a parent. */ + surface_impl = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_rtv); *surface = &surface_impl->IDirect3DSurface9_iface; IDirect3DSurface9_AddRef(*surface); } @@ -1382,7 +1400,8 @@ static HRESULT WINAPI d3d9_device_SetDepthStencilSurface(IDirect3DDevice9Ex *ifa TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil); wined3d_mutex_lock(); - wined3d_device_set_depth_stencil(device->wined3d_device, ds_impl ? ds_impl->wined3d_surface : NULL); + wined3d_device_set_depth_stencil_view(device->wined3d_device, + ds_impl ? d3d9_surface_get_rendertarget_view(ds_impl) : NULL); wined3d_mutex_unlock(); return D3D_OK; @@ -1391,7 +1410,7 @@ static HRESULT WINAPI d3d9_device_SetDepthStencilSurface(IDirect3DDevice9Ex *ifa static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *iface, IDirect3DSurface9 **depth_stencil) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - struct wined3d_surface *wined3d_surface; + struct wined3d_rendertarget_view *wined3d_dsv; struct d3d9_surface *surface_impl; HRESULT hr = D3D_OK; @@ -1401,9 +1420,11 @@ static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *ifa return D3DERR_INVALIDCALL; wined3d_mutex_lock(); - if ((wined3d_surface = wined3d_device_get_depth_stencil(device->wined3d_device))) + if ((wined3d_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device))) { - surface_impl = wined3d_surface_get_parent(wined3d_surface); + /* We want the sub resource parent here, since the view itself may be + * internal to wined3d and may not have a parent. */ + surface_impl = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_dsv); *depth_stencil = &surface_impl->IDirect3DSurface9_iface; IDirect3DSurface9_AddRef(*depth_stencil); } @@ -2745,7 +2766,6 @@ static HRESULT WINAPI d3d9_device_GetStreamSource(IDirect3DDevice9Ex *iface, buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); *buffer = &buffer_impl->IDirect3DVertexBuffer9_iface; IDirect3DVertexBuffer9_AddRef(*buffer); - wined3d_buffer_decref(wined3d_buffer); } else { @@ -3074,6 +3094,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_PresentEx(IDirect3DDevice9Ex iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region, flags); + if (device->device_state != D3D9_DEVICE_STATE_OK) + return S_PRESENT_OCCLUDED; + wined3d_mutex_lock(); hr = wined3d_device_present(device->wined3d_device, src_rect, dst_rect, dst_window_override, dirty_region, flags); @@ -3130,14 +3153,26 @@ static HRESULT WINAPI d3d9_device_GetMaximumFrameLatency(IDirect3DDevice9Ex *ifa static HRESULT WINAPI d3d9_device_CheckDeviceState(IDirect3DDevice9Ex *iface, HWND dst_window) { - static int i; + struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); + struct wined3d_swapchain_desc swapchain_desc; + struct wined3d_swapchain *swapchain; - TRACE("iface %p, dst_window %p stub!\n", iface, dst_window); + TRACE("iface %p, dst_window %p.\n", iface, dst_window); - if (!i++) - FIXME("iface %p, dst_window %p stub!\n", iface, dst_window); + wined3d_mutex_lock(); + swapchain = wined3d_device_get_swapchain(device->wined3d_device, 0); + wined3d_swapchain_get_desc(swapchain, &swapchain_desc); + wined3d_mutex_unlock(); - return D3D_OK; + if (swapchain_desc.windowed) + return D3D_OK; + + /* FIXME: This is actually supposed to check if any other device is in + * fullscreen mode. */ + if (dst_window != swapchain_desc.device_window) + return device->device_state == D3D9_DEVICE_STATE_OK ? S_PRESENT_OCCLUDED : D3D_OK; + + return device->device_state == D3D9_DEVICE_STATE_OK ? D3D_OK : S_PRESENT_OCCLUDED; } static HRESULT WINAPI d3d9_device_CreateRenderTargetEx(IDirect3DDevice9Ex *iface, @@ -3411,33 +3446,39 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic TRACE("device_parent %p.\n", device_parent); } +static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + struct d3d9_device *device = device_from_device_parent(device_parent); + + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); + + if (!device->d3d_parent) + return; + + if (!activate) + InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_LOST, D3D9_DEVICE_STATE_OK); + else if (device->d3d_parent->extended) + InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_OK, D3D9_DEVICE_STATE_LOST); + else + InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_NOT_RESET, D3D9_DEVICE_STATE_LOST); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) { - struct d3d9_device *device = device_from_device_parent(device_parent); struct d3d9_surface *d3d_surface; TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n", device_parent, container_parent, surface, parent, parent_ops); if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) - { - FIXME("Failed to allocate surface memory.\n"); - return D3DERR_OUTOFVIDEOMEMORY; - } + return E_OUTOFMEMORY; - surface_init(d3d_surface, surface, device, parent_ops); + surface_init(d3d_surface, container_parent, surface, parent_ops); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface); - d3d_surface->container = container_parent; - IDirect3DDevice9Ex_Release(d3d_surface->parent_device); - d3d_surface->parent_device = NULL; - - IDirect3DSurface9_Release(&d3d_surface->IDirect3DSurface9_iface); - d3d_surface->forwardReference = container_parent; - return D3D_OK; } @@ -3453,15 +3494,10 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent * if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY; - volume_init(d3d_volume, volume, parent_ops); + volume_init(d3d_volume, container_parent, volume, parent_ops); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume); - d3d_volume->container = container_parent; - - IDirect3DVolume9_Release(&d3d_volume->IDirect3DVolume9_iface); - d3d_volume->forwardReference = container_parent; - return D3D_OK; } @@ -3494,7 +3530,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic wined3d_texture_decref(texture); d3d_surface = wined3d_surface_get_parent(*surface); - d3d_surface->forwardReference = NULL; d3d_surface->parent_device = &device->IDirect3DDevice9Ex_iface; return hr; @@ -3528,6 +3563,7 @@ static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/reactos/dll/directx/wine/d3d9/query.c b/reactos/dll/directx/wine/d3d9/query.c index 044a2ad4f9b..578476d2f46 100644 --- a/reactos/dll/directx/wine/d3d9/query.c +++ b/reactos/dll/directx/wine/d3d9/query.c @@ -150,8 +150,11 @@ static HRESULT WINAPI d3d9_query_GetData(IDirect3DQuery9 *iface, void *data, DWO { struct wined3d_query_data_timestamp_disjoint data_disjoint; + if (size > sizeof(data_disjoint.disjoint)) + size = sizeof(data_disjoint.disjoint); + hr = wined3d_query_get_data(query->wined3d_query, &data_disjoint, sizeof(data_disjoint), flags); - *(BOOL *)data = data_disjoint.disjoint; + memcpy(data, &data_disjoint.disjoint, size); } else { @@ -183,7 +186,7 @@ HRESULT query_init(struct d3d9_query *query, struct d3d9_device *device, D3DQUER query->refcount = 1; wined3d_mutex_lock(); - hr = wined3d_query_create(device->wined3d_device, type, &query->wined3d_query); + hr = wined3d_query_create(device->wined3d_device, type, query, &query->wined3d_query); wined3d_mutex_unlock(); if (FAILED(hr)) { diff --git a/reactos/dll/directx/wine/d3d9/surface.c b/reactos/dll/directx/wine/d3d9/surface.c index 785e8604a88..4a563d3d28c 100644 --- a/reactos/dll/directx/wine/d3d9/surface.c +++ b/reactos/dll/directx/wine/d3d9/surface.c @@ -52,10 +52,10 @@ static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface) TRACE("iface %p.\n", iface); - if (surface->forwardReference) + if (surface->texture) { - TRACE("Forwarding to %p.\n", surface->forwardReference); - return IUnknown_AddRef(surface->forwardReference); + TRACE("Forwarding to %p.\n", surface->texture); + return IDirect3DBaseTexture9_AddRef(&surface->texture->IDirect3DBaseTexture9_iface); } refcount = InterlockedIncrement(&surface->resource.refcount); @@ -66,6 +66,8 @@ static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface) if (surface->parent_device) IDirect3DDevice9Ex_AddRef(surface->parent_device); wined3d_mutex_lock(); + if (surface->wined3d_rtv) + wined3d_rendertarget_view_incref(surface->wined3d_rtv); wined3d_surface_incref(surface->wined3d_surface); wined3d_mutex_unlock(); } @@ -80,10 +82,10 @@ static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface) TRACE("iface %p.\n", iface); - if (surface->forwardReference) + if (surface->texture) { - TRACE("Forwarding to %p.\n", surface->forwardReference); - return IUnknown_Release(surface->forwardReference); + TRACE("Forwarding to %p.\n", surface->texture); + return IDirect3DBaseTexture9_Release(&surface->texture->IDirect3DBaseTexture9_iface); } refcount = InterlockedDecrement(&surface->resource.refcount); @@ -94,6 +96,8 @@ static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface) IDirect3DDevice9Ex *parent_device = surface->parent_device; wined3d_mutex_lock(); + if (surface->wined3d_rtv) + wined3d_rendertarget_view_decref(surface->wined3d_rtv); wined3d_surface_decref(surface->wined3d_surface); wined3d_mutex_unlock(); @@ -111,22 +115,8 @@ static HRESULT WINAPI d3d9_surface_GetDevice(IDirect3DSurface9 *iface, IDirect3D TRACE("iface %p, device %p.\n", iface, device); - if (surface->forwardReference) - { - IDirect3DResource9 *resource; - HRESULT hr; - - hr = IUnknown_QueryInterface(surface->forwardReference, &IID_IDirect3DResource9, (void **)&resource); - if (SUCCEEDED(hr)) - { - hr = IDirect3DResource9_GetDevice(resource, device); - IDirect3DResource9_Release(resource); - - TRACE("Returning device %p.\n", *device); - } - - return hr; - } + if (surface->texture) + return IDirect3DBaseTexture9_GetDevice(&surface->texture->IDirect3DBaseTexture9_iface, device); *device = (IDirect3DDevice9 *)surface->parent_device; IDirect3DDevice9_AddRef(*device); @@ -166,30 +156,14 @@ static HRESULT WINAPI d3d9_surface_FreePrivateData(IDirect3DSurface9 *iface, REF static DWORD WINAPI d3d9_surface_SetPriority(IDirect3DSurface9 *iface, DWORD priority) { - struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface); - DWORD ret; - - TRACE("iface %p, priority %u.\n", iface, priority); - - wined3d_mutex_lock(); - ret = wined3d_surface_set_priority(surface->wined3d_surface, priority); - wined3d_mutex_unlock(); - - return ret; + TRACE("iface %p, priority %u. Ignored on surfaces.\n", iface, priority); + return 0; } static DWORD WINAPI d3d9_surface_GetPriority(IDirect3DSurface9 *iface) { - struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface); - DWORD ret; - - TRACE("iface %p.\n", iface); - - wined3d_mutex_lock(); - ret = wined3d_surface_get_priority(surface->wined3d_surface); - wined3d_mutex_unlock(); - - return ret; + TRACE("iface %p. Ignored on surfaces.\n", iface); + return 0; } static void WINAPI d3d9_surface_PreLoad(IDirect3DSurface9 *iface) @@ -368,13 +342,25 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops = surface_wined3d_object_destroyed, }; -void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface, - struct d3d9_device *device, const struct wined3d_parent_ops **parent_ops) +void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) { struct wined3d_resource_desc desc; + IDirect3DBaseTexture9 *texture; surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl; d3d9_resource_init(&surface->resource); + surface->resource.refcount = 0; + surface->wined3d_surface = wined3d_surface; + list_init(&surface->rtv_entry); + surface->container = container_parent; + + if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent, + &IID_IDirect3DBaseTexture9, (void **)&texture))) + { + surface->texture = unsafe_impl_from_IDirect3DBaseTexture9(texture); + IDirect3DBaseTexture9_Release(texture); + } wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &desc); switch (d3dformat_from_wined3dformat(desc.format)) @@ -393,14 +379,51 @@ void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_ break; } - wined3d_surface_incref(wined3d_surface); - surface->wined3d_surface = wined3d_surface; - surface->parent_device = &device->IDirect3DDevice9Ex_iface; - IDirect3DDevice9Ex_AddRef(surface->parent_device); - *parent_ops = &d3d9_surface_wined3d_parent_ops; } +static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent) +{ + struct d3d9_surface *surface = parent; + + /* If the surface reference count drops to zero, we release our reference + * to the view, but don't clear the pointer yet, in case e.g. a + * GetRenderTarget() call brings the surface back before the view is + * actually destroyed. When the view is destroyed, we need to clear the + * pointer, or a subsequent surface AddRef() would reference it again. + * + * This is safe because as long as the view still has a reference to the + * texture, the surface is also still alive, and we're called before the + * view releases that reference. */ + surface->wined3d_rtv = NULL; + list_remove(&surface->rtv_entry); +} + +static const struct wined3d_parent_ops d3d9_view_wined3d_parent_ops = +{ + view_wined3d_object_destroyed, +}; + +struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) +{ + HRESULT hr; + + if (surface->wined3d_rtv) + return surface->wined3d_rtv; + + if (FAILED(hr = wined3d_rendertarget_view_create_from_surface(surface->wined3d_surface, + surface, &d3d9_view_wined3d_parent_ops, &surface->wined3d_rtv))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return NULL; + } + + if (surface->texture) + list_add_head(&surface->texture->rtv_list, &surface->rtv_entry); + + return surface->wined3d_rtv; +} + struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) { if (!iface) diff --git a/reactos/dll/directx/wine/d3d9/swapchain.c b/reactos/dll/directx/wine/d3d9/swapchain.c index f5ec38307aa..6698a8b1e65 100644 --- a/reactos/dll/directx/wine/d3d9/swapchain.c +++ b/reactos/dll/directx/wine/d3d9/swapchain.c @@ -112,12 +112,16 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_swapchain_Present(IDirect3DSwapChai const RGNDATA *dirty_region, DWORD flags) { struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9Ex(iface); + struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(swapchain->parent_device); HRESULT hr; TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p, flags %#x.\n", iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region, flags); + if (device->device_state != D3D9_DEVICE_STATE_OK) + return device->d3d_parent->extended ? S_PRESENT_OCCLUDED : D3DERR_DEVICELOST; + wined3d_mutex_lock(); hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, src_rect, dst_rect, dst_window_override, dirty_region, flags); diff --git a/reactos/dll/directx/wine/d3d9/texture.c b/reactos/dll/directx/wine/d3d9/texture.c index 5f14bf25c4a..182f53c9b65 100644 --- a/reactos/dll/directx/wine/d3d9/texture.c +++ b/reactos/dll/directx/wine/d3d9/texture.c @@ -64,8 +64,14 @@ static ULONG WINAPI d3d9_texture_2d_AddRef(IDirect3DTexture9 *iface) if (ref == 1) { + struct d3d9_surface *surface; + IDirect3DDevice9Ex_AddRef(texture->parent_device); wined3d_mutex_lock(); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) + { + wined3d_rendertarget_view_incref(surface->wined3d_rtv); + } wined3d_texture_incref(texture->wined3d_texture); wined3d_mutex_unlock(); } @@ -83,8 +89,13 @@ static ULONG WINAPI d3d9_texture_2d_Release(IDirect3DTexture9 *iface) 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(); @@ -139,12 +150,14 @@ static HRESULT WINAPI d3d9_texture_2d_FreePrivateData(IDirect3DTexture9 *iface, static DWORD WINAPI d3d9_texture_2d_SetPriority(IDirect3DTexture9 *iface, DWORD priority) { struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface); + struct wined3d_resource *resource; DWORD ret; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - ret = wined3d_texture_set_priority(texture->wined3d_texture, priority); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return ret; @@ -153,12 +166,14 @@ static DWORD WINAPI d3d9_texture_2d_SetPriority(IDirect3DTexture9 *iface, DWORD static DWORD WINAPI d3d9_texture_2d_GetPriority(IDirect3DTexture9 *iface) { struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface); + const struct wined3d_resource *resource; DWORD ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - ret = wined3d_texture_get_priority(texture->wined3d_texture); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return ret; @@ -451,8 +466,14 @@ static ULONG WINAPI d3d9_texture_cube_AddRef(IDirect3DCubeTexture9 *iface) if (ref == 1) { + struct d3d9_surface *surface; + IDirect3DDevice9Ex_AddRef(texture->parent_device); 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_incref(texture->wined3d_texture); wined3d_mutex_unlock(); } @@ -470,10 +491,15 @@ static ULONG WINAPI d3d9_texture_cube_Release(IDirect3DCubeTexture9 *iface) 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(); @@ -528,12 +554,14 @@ static HRESULT WINAPI d3d9_texture_cube_FreePrivateData(IDirect3DCubeTexture9 *i static DWORD WINAPI d3d9_texture_cube_SetPriority(IDirect3DCubeTexture9 *iface, DWORD priority) { struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface); + struct wined3d_resource *resource; DWORD ret; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - ret = wined3d_texture_set_priority(texture->wined3d_texture, priority); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return ret; @@ -542,12 +570,14 @@ static DWORD WINAPI d3d9_texture_cube_SetPriority(IDirect3DCubeTexture9 *iface, static DWORD WINAPI d3d9_texture_cube_GetPriority(IDirect3DCubeTexture9 *iface) { struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface); + const struct wined3d_resource *resource; DWORD ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - ret = wined3d_texture_get_priority(texture->wined3d_texture); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return ret; @@ -941,12 +971,14 @@ static HRESULT WINAPI d3d9_texture_3d_FreePrivateData(IDirect3DVolumeTexture9 *i static DWORD WINAPI d3d9_texture_3d_SetPriority(IDirect3DVolumeTexture9 *iface, DWORD priority) { struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); + struct wined3d_resource *resource; DWORD ret; TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - ret = wined3d_texture_set_priority(texture->wined3d_texture, priority); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_set_priority(resource, priority); wined3d_mutex_unlock(); return ret; @@ -955,12 +987,14 @@ static DWORD WINAPI d3d9_texture_3d_SetPriority(IDirect3DVolumeTexture9 *iface, static DWORD WINAPI d3d9_texture_3d_GetPriority(IDirect3DVolumeTexture9 *iface) { struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); + const struct wined3d_resource *resource; DWORD ret; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - ret = wined3d_texture_get_priority(texture->wined3d_texture); + resource = wined3d_texture_get_resource(texture->wined3d_texture); + ret = wined3d_resource_get_priority(resource); wined3d_mutex_unlock(); return ret; @@ -1242,6 +1276,7 @@ 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); desc.resource_type = WINED3D_RTYPE_TEXTURE; desc.format = wined3dformat_from_d3dformat(format); @@ -1283,6 +1318,7 @@ 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); desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE; desc.format = wined3dformat_from_d3dformat(format); @@ -1323,6 +1359,7 @@ 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); desc.resource_type = WINED3D_RTYPE_VOLUME_TEXTURE; desc.format = wined3dformat_from_d3dformat(format); diff --git a/reactos/dll/directx/wine/d3d9/volume.c b/reactos/dll/directx/wine/d3d9/volume.c index 9a3419d295f..9a7aad6d785 100644 --- a/reactos/dll/directx/wine/d3d9/volume.c +++ b/reactos/dll/directx/wine/d3d9/volume.c @@ -47,73 +47,30 @@ static HRESULT WINAPI d3d9_volume_QueryInterface(IDirect3DVolume9 *iface, REFIID static ULONG WINAPI d3d9_volume_AddRef(IDirect3DVolume9 *iface) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - ULONG refcount; TRACE("iface %p.\n", iface); + TRACE("Forwarding to %p.\n", volume->texture); - if (volume->forwardReference) - { - TRACE("Forwarding to %p.\n", volume->forwardReference); - return IUnknown_AddRef(volume->forwardReference); - } - - refcount = InterlockedIncrement(&volume->resource.refcount); - TRACE("%p increasing refcount to %u.\n", iface, refcount); - - if (refcount == 1) - { - wined3d_mutex_lock(); - wined3d_volume_incref(volume->wined3d_volume); - wined3d_mutex_unlock(); - } - - return refcount; + return IDirect3DBaseTexture9_AddRef(&volume->texture->IDirect3DBaseTexture9_iface); } static ULONG WINAPI d3d9_volume_Release(IDirect3DVolume9 *iface) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - ULONG refcount; TRACE("iface %p.\n", iface); + TRACE("Forwarding to %p.\n", volume->texture); - if (volume->forwardReference) - { - TRACE("Forwarding to %p.\n", volume->forwardReference); - return IUnknown_Release(volume->forwardReference); - } - - refcount = InterlockedDecrement(&volume->resource.refcount); - TRACE("%p decreasing refcount to %u.\n", iface, refcount); - - if (!refcount) - { - wined3d_mutex_lock(); - wined3d_volume_decref(volume->wined3d_volume); - wined3d_mutex_unlock(); - } - - return refcount; + return IDirect3DBaseTexture9_Release(&volume->texture->IDirect3DBaseTexture9_iface); } static HRESULT WINAPI d3d9_volume_GetDevice(IDirect3DVolume9 *iface, IDirect3DDevice9 **device) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - IDirect3DResource9 *resource; - HRESULT hr; TRACE("iface %p, device %p.\n", iface, device); - hr = IUnknown_QueryInterface(volume->forwardReference, &IID_IDirect3DResource9, (void **)&resource); - if (SUCCEEDED(hr)) - { - hr = IDirect3DResource9_GetDevice(resource, device); - IDirect3DResource9_Release(resource); - - TRACE("Returning device %p.\n", *device); - } - - return hr; + return IDirect3DBaseTexture9_GetDevice(&volume->texture->IDirect3DBaseTexture9_iface, device); } static HRESULT WINAPI d3d9_volume_SetPrivateData(IDirect3DVolume9 *iface, REFGUID guid, @@ -147,18 +104,10 @@ static HRESULT WINAPI d3d9_volume_FreePrivateData(IDirect3DVolume9 *iface, REFGU static HRESULT WINAPI d3d9_volume_GetContainer(IDirect3DVolume9 *iface, REFIID riid, void **container) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - HRESULT hr; TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container); - if (!volume->container) - return E_NOINTERFACE; - - hr = IUnknown_QueryInterface(volume->container, riid, container); - - TRACE("Returning %p,\n", *container); - - return hr; + return IDirect3DBaseTexture9_QueryInterface(&volume->texture->IDirect3DBaseTexture9_iface, riid, container); } static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DESC *desc) @@ -249,13 +198,14 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = volume_wined3d_object_destroyed, }; -void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume, - const struct wined3d_parent_ops **parent_ops) +void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) { volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl; d3d9_resource_init(&volume->resource); - wined3d_volume_incref(wined3d_volume); + volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; + volume->texture = texture; *parent_ops = &d3d9_volume_wined3d_parent_ops; } diff --git a/reactos/dll/directx/wine/ddraw/ddraw.c b/reactos/dll/directx/wine/ddraw/ddraw.c index e16a23d7e7e..44e535d889d 100644 --- a/reactos/dll/directx/wine/ddraw/ddraw.c +++ b/reactos/dll/directx/wine/ddraw/ddraw.c @@ -762,7 +762,7 @@ static HRESULT WINAPI ddraw1_RestoreDisplayMode(IDirectDraw *iface) static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window, DWORD cooplevel, BOOL restore_mode_on_normal) { - struct wined3d_surface *rt = NULL, *ds = NULL; + struct wined3d_rendertarget_view *rtv = NULL, *dsv = NULL; struct wined3d_stateblock *stateblock; BOOL restore_state = FALSE; HRESULT hr; @@ -913,14 +913,15 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window, } wined3d_stateblock_capture(stateblock); - rt = wined3d_device_get_render_target(ddraw->wined3d_device, 0); - if (rt == ddraw->wined3d_frontbuffer) - rt = NULL; - else if (rt) - wined3d_surface_incref(rt); - - if ((ds = wined3d_device_get_depth_stencil(ddraw->wined3d_device))) - wined3d_surface_incref(ds); + rtv = wined3d_device_get_rendertarget_view(ddraw->wined3d_device, 0); + /* Rendering to ddraw->wined3d_frontbuffer. */ + if (rtv && !wined3d_rendertarget_view_get_sub_resource_parent(rtv)) + rtv = NULL; + else if (rtv) + wined3d_rendertarget_view_incref(rtv); + + if ((dsv = wined3d_device_get_depth_stencil_view(ddraw->wined3d_device))) + wined3d_rendertarget_view_incref(dsv); } ddraw_destroy_swapchain(ddraw); @@ -931,16 +932,16 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window, if (restore_state) { - if (ds) + if (dsv) { - wined3d_device_set_depth_stencil(ddraw->wined3d_device, ds); - wined3d_surface_decref(ds); + wined3d_device_set_depth_stencil_view(ddraw->wined3d_device, dsv); + wined3d_rendertarget_view_decref(dsv); } - if (rt) + if (rtv) { - wined3d_device_set_render_target(ddraw->wined3d_device, 0, rt, FALSE); - wined3d_surface_decref(rt); + wined3d_device_set_rendertarget_view(ddraw->wined3d_device, 0, rtv, FALSE); + wined3d_rendertarget_view_decref(rtv); } wined3d_stateblock_apply(stateblock); @@ -1885,7 +1886,7 @@ static HRESULT WINAPI ddraw1_GetVerticalBlankStatus(IDirectDraw *iface, BOOL *st * * Returns * DD_OK on success - * DDERR_INVALIDPARAMS of free and total are NULL + * DDERR_INVALIDPARAMS if free and total are NULL * *****************************************************************************/ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *Caps, DWORD *total, @@ -1921,7 +1922,7 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C struct wined3d_adapter_identifier desc = {0}; hr = wined3d_get_adapter_identifier(ddraw->wined3d, WINED3DADAPTER_DEFAULT, 0, &desc); - *total = desc.video_memory; + *total = min(UINT_MAX, desc.video_memory); } wined3d_mutex_unlock(); @@ -2180,23 +2181,13 @@ static HRESULT WINAPI ddraw1_GetScanLine(IDirectDraw *iface, DWORD *line) return ddraw7_GetScanLine(&ddraw->IDirectDraw7_iface, line); } -/***************************************************************************** - * IDirectDraw7::TestCooperativeLevel - * - * Informs the application about the state of the video adapter, depending - * on the cooperative level - * - * Returns: - * DD_OK if the device is in a sane state - * DDERR_NOEXCLUSIVEMODE or DDERR_EXCLUSIVEMODEALREADYSET - * if the state is not correct(See below) - * - *****************************************************************************/ static HRESULT WINAPI ddraw7_TestCooperativeLevel(IDirectDraw7 *iface) { + struct ddraw *ddraw = impl_from_IDirectDraw7(iface); + TRACE("iface %p.\n", iface); - return DD_OK; + return ddraw->device_state == DDRAW_DEVICE_STATE_OK ? DD_OK : DDERR_NOEXCLUSIVEMODE; } static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface) @@ -2680,27 +2671,20 @@ static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc, return hr; } -/***************************************************************************** - * IDirectDraw7::RestoreAllSurfaces - * - * Calls the restore method of all surfaces - * - * Params: - * - * Returns: - * Always returns DD_OK because it's a stub - * - *****************************************************************************/ +static HRESULT CALLBACK restore_callback(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context) +{ + IDirectDrawSurface_Restore(surface); + IDirectDrawSurface_Release(surface); + + return DDENUMRET_OK; +} + static HRESULT WINAPI ddraw7_RestoreAllSurfaces(IDirectDraw7 *iface) { - FIXME("iface %p stub!\n", iface); + TRACE("iface %p.\n", iface); - /* This isn't hard to implement: Enumerate all WineD3D surfaces, - * get their parent and call their restore method. Do not implement - * it in WineD3D, as restoring a surface means re-creating the - * WineD3DDSurface - */ - return DD_OK; + return IDirectDraw7_EnumSurfaces(iface, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, + NULL, NULL, restore_callback); } static HRESULT WINAPI ddraw4_RestoreAllSurfaces(IDirectDraw4 *iface) @@ -3695,6 +3679,8 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE); /* RGB, RAMP and MMX devices have a HAL dcmColorModel of 0 */ hal_desc.dcmColorModel = 0; + /* RGB, RAMP and MMX devices cannot report HAL hardware flags */ + hal_desc.dwFlags = 0; hr = callback((GUID *)&IID_IDirect3DRGBDevice, reference_description, device_name, &hal_desc, &hel_desc, context); @@ -4169,7 +4155,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid, * D3D_OK on success * DDERR_OUTOFMEMORY if memory allocation failed * The return value of IWineD3DDevice::CreateVertexBuffer if this call fails - * DDERR_INVALIDPARAMS if desc or vertex_buffer are NULL + * DDERR_INVALIDPARAMS if desc or vertex_buffer is NULL * *****************************************************************************/ static HRESULT WINAPI d3d7_CreateVertexBuffer(IDirect3D7 *iface, D3DVERTEXBUFFERDESC *desc, @@ -4717,6 +4703,18 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ERR("Failed to resize window.\n"); } +static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + struct ddraw *ddraw = ddraw_from_device_parent(device_parent); + + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); + + if (!activate) + InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_LOST, DDRAW_DEVICE_STATE_OK); + else + InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_OK, DDRAW_DEVICE_STATE_LOST); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) @@ -4728,8 +4726,8 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n", device_parent, container_parent, surface, parent, parent_ops); - /* We have a swapchain texture. */ - if (container_parent == ddraw) + /* We have a swapchain or wined3d internal texture. */ + if (!container_parent || container_parent == ddraw) { *parent = NULL; *parent_ops = &ddraw_null_wined3d_parent_ops; @@ -4841,6 +4839,7 @@ static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/reactos/dll/directx/wine/ddraw/ddraw_private.h b/reactos/dll/directx/wine/ddraw/ddraw_private.h index ae2adbd218a..1ad8c2c5e22 100644 --- a/reactos/dll/directx/wine/ddraw/ddraw_private.h +++ b/reactos/dll/directx/wine/ddraw/ddraw_private.h @@ -65,6 +65,12 @@ struct FvfToDecl #define DDRAW_STRIDE_ALIGNMENT 8 +enum ddraw_device_state +{ + DDRAW_DEVICE_STATE_OK, + DDRAW_DEVICE_STATE_LOST, +}; + struct ddraw { /* Interfaces */ @@ -84,6 +90,7 @@ struct ddraw struct wined3d *wined3d; struct wined3d_device *wined3d_device; DWORD flags; + LONG device_state; struct ddraw_surface *primary; RECT primary_lock; @@ -157,6 +164,7 @@ struct ddraw_surface struct ddraw *ddraw; struct wined3d_surface *wined3d_surface; struct wined3d_texture *wined3d_texture; + struct wined3d_rendertarget_view *wined3d_rtv; struct wined3d_private_store private_store; struct d3d_device *device1; @@ -204,9 +212,12 @@ struct ddraw_texture HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc, struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version) DECLSPEC_HIDDEN; +struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN; HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture, struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN; +HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, + const RECT *rect, BOOL read) DECLSPEC_HIDDEN; static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface) { @@ -582,6 +593,20 @@ void DDSD2_to_DDSD(const DDSURFACEDESC2 *in, DDSURFACEDESC *out) DECLSPEC_HIDDEN void multiply_matrix(D3DMATRIX *dst, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN; +static inline BOOL format_is_compressed(const DDPIXELFORMAT *format) +{ + return (format->dwFlags & DDPF_FOURCC) && (format->dwFourCC == WINED3DFMT_DXT1 + || format->dwFourCC == WINED3DFMT_DXT2 || format->dwFourCC == WINED3DFMT_DXT3 + || format->dwFourCC == WINED3DFMT_DXT4 || format->dwFourCC == WINED3DFMT_DXT5); +} + +static inline BOOL format_is_paletteindexed(const DDPIXELFORMAT *fmt) +{ + DWORD flags = DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4 + | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8; + return !!(fmt->dwFlags & flags); +} + /* Used for generic dumping */ struct flag_info { diff --git a/reactos/dll/directx/wine/ddraw/device.c b/reactos/dll/directx/wine/ddraw/device.c index c53f69b1633..ee0c2582b81 100644 --- a/reactos/dll/directx/wine/ddraw/device.c +++ b/reactos/dll/directx/wine/ddraw/device.c @@ -242,7 +242,7 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface) if (This->vertex_buffer) wined3d_buffer_decref(This->vertex_buffer); - wined3d_device_set_render_target(This->wined3d_device, 0, NULL, FALSE); + wined3d_device_set_rendertarget_view(This->wined3d_device, 0, NULL, FALSE); /* Release the wined3d device. This won't destroy it. */ if (!wined3d_device_decref(This->wined3d_device)) @@ -1794,11 +1794,8 @@ static HRESULT WINAPI d3d_device2_GetCurrentViewport(IDirect3DDevice2 *iface, ID static BOOL validate_surface_palette(struct ddraw_surface *surface) { - return !(surface->surface_desc.u4.ddpfPixelFormat.dwFlags - & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 - | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 - | DDPF_PALETTEINDEXEDTO8)) - || wined3d_surface_get_palette(surface->wined3d_surface); + return !format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat) + || surface->palette; } static HRESULT d3d_device_set_render_target(struct d3d_device *device, @@ -1817,8 +1814,8 @@ static HRESULT d3d_device_set_render_target(struct d3d_device *device, return DDERR_INVALIDPARAMS; } - if (FAILED(hr = wined3d_device_set_render_target(device->wined3d_device, - 0, target->wined3d_surface, FALSE))) + if (FAILED(hr = wined3d_device_set_rendertarget_view(device->wined3d_device, + 0, ddraw_surface_get_rendertarget_view(target), FALSE))) return hr; IUnknown_AddRef(rt_iface); @@ -2941,16 +2938,19 @@ static HRESULT WINAPI d3d_device3_SetLightState(IDirect3DDevice3 *iface, wined3d_mutex_lock(); if (state == D3DLIGHTSTATE_MATERIAL) { - struct d3d_material *m = ddraw_get_object(&device->handle_table, value - 1, DDRAW_HANDLE_MATERIAL); - if (!m) + if (value) { - WARN("Invalid material handle.\n"); - wined3d_mutex_unlock(); - return DDERR_INVALIDPARAMS; - } + struct d3d_material *m; + + if (!(m = ddraw_get_object(&device->handle_table, value - 1, DDRAW_HANDLE_MATERIAL))) + { + WARN("Invalid material handle.\n"); + wined3d_mutex_unlock(); + return DDERR_INVALIDPARAMS; + } - TRACE(" activating material %p.\n", m); - material_activate(m); + material_activate(m); + } device->material = value; } @@ -3564,15 +3564,11 @@ static HRESULT WINAPI d3d_device7_DrawPrimitive_FPUPreserve(IDirect3DDevice7 *if static void setup_lighting(const struct d3d_device *device, DWORD fvf, DWORD flags) { - BOOL enable; + BOOL enable = TRUE; /* Ignore the D3DFVF_XYZRHW case here, wined3d takes care of that */ - if (flags & D3DDP_DONOTLIGHT) + if (!device->material || !(fvf & D3DFVF_NORMAL) || (flags & D3DDP_DONOTLIGHT)) enable = FALSE; - else if (!(fvf & D3DFVF_NORMAL)) - enable = FALSE; - else - enable = TRUE; wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING, enable); } @@ -4440,8 +4436,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface * are passed in the Centers and Radii arrays, the results are passed back * in the ReturnValues array. Return values are either completely visible, * partially visible or completely invisible. - * The return value consist of a combination of D3DCLIP_* flags, or it's - * 0 if the sphere is completely visible(according to the SDK, not checked) + * The return value consists of a combination of D3DCLIP_* flags, or is + * 0 if the sphere is completely visible (according to the SDK, not checked) * * Version 3 and 7 * @@ -4732,7 +4728,7 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface, } } - /* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */ + /* Args 1 and 2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */ if (tex_alpha) wined3d_device_set_texture_stage_state(device->wined3d_device, 0, WINED3D_TSS_ALPHA_OP, WINED3D_TOP_SELECT_ARG1); @@ -6046,7 +6042,7 @@ static void copy_mipmap_chain(struct d3d_device *device, struct ddraw_surface *d * * Returns: * D3D_OK on success - * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL, broken coordinates or anything unexpected. + * DDERR_INVALIDPARAMS if dst_texture or src_texture is NULL, broken coordinates or anything unexpected. * * *****************************************************************************/ @@ -6759,13 +6755,13 @@ enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device if (!depthStencil) { TRACE("Setting wined3d depth stencil to NULL\n"); - wined3d_device_set_depth_stencil(device->wined3d_device, NULL); + wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL); return WINED3D_ZB_FALSE; } dsi = impl_from_IDirectDrawSurface7(depthStencil); - TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->wined3d_surface); - wined3d_device_set_depth_stencil(device->wined3d_device, dsi->wined3d_surface); + wined3d_device_set_depth_stencil_view(device->wined3d_device, + ddraw_surface_get_rendertarget_view(dsi)); IDirectDrawSurface7_Release(depthStencil); return WINED3D_ZB_TRUE; @@ -6818,8 +6814,8 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, wined3d_device_incref(ddraw->wined3d_device); /* Render to the back buffer */ - hr = wined3d_device_set_render_target(ddraw->wined3d_device, 0, target->wined3d_surface, TRUE); - if (FAILED(hr)) + if (FAILED(hr = wined3d_device_set_rendertarget_view(ddraw->wined3d_device, + 0, ddraw_surface_get_rendertarget_view(target), TRUE))) { ERR("Failed to set render target, hr %#x.\n", hr); ddraw_handle_table_destroy(&device->handle_table); diff --git a/reactos/dll/directx/wine/ddraw/executebuffer.c b/reactos/dll/directx/wine/ddraw/executebuffer.c index 4109d7a13eb..c645aedb32a 100644 --- a/reactos/dll/directx/wine/ddraw/executebuffer.c +++ b/reactos/dll/directx/wine/ddraw/executebuffer.c @@ -45,12 +45,27 @@ static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC *lpDesc) { TRACE("lpData : %p\n", lpDesc->lpData); } +static void transform_vertex(D3DTLVERTEX *dst, const D3DMATRIX *mat, + const D3DVIEWPORT *vp, float x, float y, float z) +{ + dst->u1.sx = (x * mat->_11) + (y * mat->_21) + (z * mat->_31) + mat->_41; + dst->u2.sy = (x * mat->_12) + (y * mat->_22) + (z * mat->_32) + mat->_42; + dst->u3.sz = (x * mat->_13) + (y * mat->_23) + (z * mat->_33) + mat->_43; + dst->u4.rhw = (x * mat->_14) + (y * mat->_24) + (z * mat->_34) + mat->_44; + + dst->u1.sx = dst->u1.sx / dst->u4.rhw * vp->dvScaleX + vp->dwX + vp->dwWidth / 2; + dst->u2.sy = -dst->u2.sy / dst->u4.rhw * vp->dvScaleY + vp->dwY + vp->dwHeight / 2; + dst->u3.sz /= dst->u4.rhw; + dst->u4.rhw = 1.0f / dst->u4.rhw; +} + HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d_device *device, struct d3d_viewport *viewport) { DWORD vs = buffer->data.dwVertexOffset; DWORD is = buffer->data.dwInstructionOffset; char *instr = (char *)buffer->desc.lpData + is; + unsigned int i; if (viewport->active_device != device) { @@ -87,8 +102,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, instr += count * size; } break; - case D3DOP_TRIANGLE: { - DWORD i; + case D3DOP_TRIANGLE: + { D3DTLVERTEX *tl_vx = buffer->vertex_data; TRACE("TRIANGLE (%d)\n", count); @@ -139,10 +154,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, instr += count * size; break; - case D3DOP_MATRIXMULTIPLY: { - DWORD i; - TRACE("MATRIXMULTIPLY (%d)\n", count); - + case D3DOP_MATRIXMULTIPLY: + TRACE("MATRIXMULTIPLY (%d)\n", count); for (i = 0; i < count; ++i) { D3DMATRIXMULTIPLY *ci = (D3DMATRIXMULTIPLY *)instr; @@ -164,13 +177,11 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, } instr += size; - } - } break; + } + break; - case D3DOP_STATETRANSFORM: { - DWORD i; - TRACE("STATETRANSFORM (%d)\n", count); - + case D3DOP_STATETRANSFORM: + TRACE("STATETRANSFORM (%d)\n", count); for (i = 0; i < count; ++i) { D3DSTATE *ci = (D3DSTATE *)instr; @@ -195,97 +206,42 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, instr += size; } - } break; - - case D3DOP_STATELIGHT: { - DWORD i; - TRACE("STATELIGHT (%d)\n", count); + break; + case D3DOP_STATELIGHT: + TRACE("STATELIGHT (%d)\n", count); for (i = 0; i < count; ++i) { D3DSTATE *ci = (D3DSTATE *)instr; - TRACE("(%08x,%08x)\n", ci->u1.dlstLightStateType, ci->u2.dwArg[0]); - - if (!ci->u1.dlstLightStateType || (ci->u1.dlstLightStateType > D3DLIGHTSTATE_COLORVERTEX)) - ERR("Unexpected Light State Type %d\n", ci->u1.dlstLightStateType); - else if (ci->u1.dlstLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) - { - struct d3d_material *m; - - m = ddraw_get_object(&device->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATERIAL); - if (!m) - ERR("Invalid material handle %#x.\n", ci->u2.dwArg[0]); - else - material_activate(m); - } - else if (ci->u1.dlstLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) - { - switch (ci->u2.dwArg[0]) { - case D3DCOLOR_MONO: - ERR("DDCOLOR_MONO should not happen!\n"); - break; - case D3DCOLOR_RGB: - /* We are already in this mode */ - break; - default: - ERR("Unknown color model!\n"); - } - } else { - D3DRENDERSTATETYPE rs = 0; - switch (ci->u1.dlstLightStateType) { - - case D3DLIGHTSTATE_AMBIENT: /* 2 */ - rs = D3DRENDERSTATE_AMBIENT; - break; - case D3DLIGHTSTATE_FOGMODE: /* 4 */ - rs = D3DRENDERSTATE_FOGVERTEXMODE; - break; - case D3DLIGHTSTATE_FOGSTART: /* 5 */ - rs = D3DRENDERSTATE_FOGSTART; - break; - case D3DLIGHTSTATE_FOGEND: /* 6 */ - rs = D3DRENDERSTATE_FOGEND; - break; - case D3DLIGHTSTATE_FOGDENSITY: /* 7 */ - rs = D3DRENDERSTATE_FOGDENSITY; - break; - case D3DLIGHTSTATE_COLORVERTEX: /* 8 */ - rs = D3DRENDERSTATE_COLORVERTEX; - break; - default: - break; - } - - IDirect3DDevice7_SetRenderState(&device->IDirect3DDevice7_iface, rs, ci->u2.dwArg[0]); - } - - instr += size; - } - } break; + if (FAILED(IDirect3DDevice3_SetLightState(&device->IDirect3DDevice3_iface, + ci->u1.dlstLightStateType, ci->u2.dwArg[0]))) + WARN("Failed to set light state.\n"); - case D3DOP_STATERENDER: { - DWORD i; - IDirect3DDevice2 *d3d_device2 = &device->IDirect3DDevice2_iface; - TRACE("STATERENDER (%d)\n", count); + instr += size; + } + break; + case D3DOP_STATERENDER: + TRACE("STATERENDER (%d)\n", count); for (i = 0; i < count; ++i) { D3DSTATE *ci = (D3DSTATE *)instr; - IDirect3DDevice2_SetRenderState(d3d_device2, ci->u1.drstRenderStateType, ci->u2.dwArg[0]); + if (FAILED(IDirect3DDevice3_SetRenderState(&device->IDirect3DDevice3_iface, + ci->u1.drstRenderStateType, ci->u2.dwArg[0]))) + WARN("Failed to set render state.\n"); - instr += size; - } - } break; + instr += size; + } + break; case D3DOP_PROCESSVERTICES: { - /* TODO: Share code with IDirect3DVertexBuffer::ProcessVertices and / or - * IWineD3DDevice::ProcessVertices - */ - DWORD i; - D3DMATRIX view_mat, world_mat, proj_mat; + /* TODO: Share code with d3d_vertex_buffer7_ProcessVertices() + * and / or wined3d_device_process_vertices(). */ + D3DMATRIX view_mat, world_mat, proj_mat, mat; + TRACE("PROCESSVERTICES (%d)\n", count); /* Get the transform and world matrix */ @@ -297,157 +253,91 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, wined3d_device_get_transform(device->wined3d_device, WINED3D_TS_WORLD_MATRIX(0), (struct wined3d_matrix *)&world_mat); - for (i = 0; i < count; ++i) + if (TRACE_ON(ddraw)) { - D3DPROCESSVERTICES *ci = (D3DPROCESSVERTICES *)instr; - - TRACE(" Start : %d Dest : %d Count : %d\n", - ci->wStart, ci->wDest, ci->dwCount); - TRACE(" Flags : "); - if (TRACE_ON(ddraw)) - { - if (ci->dwFlags & D3DPROCESSVERTICES_COPY) - TRACE("COPY "); - if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR) - TRACE("NOCOLOR "); - if (ci->dwFlags == D3DPROCESSVERTICES_OPMASK) - TRACE("OPMASK "); - if (ci->dwFlags & D3DPROCESSVERTICES_TRANSFORM) - TRACE("TRANSFORM "); - if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) - TRACE("TRANSFORMLIGHT "); - if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS) - TRACE("UPDATEEXTENTS "); - TRACE("\n"); - } - - /* This is where doing Direct3D on top on OpenGL is quite difficult. - This method transforms a set of vertices using the CURRENT state - (lighting, projection, ...) but does not rasterize them. - They will only be put on screen later (with the POINT / LINE and - TRIANGLE op-codes). The problem is that you can have a triangle - with each point having been transformed using another state... - - In this implementation, I will emulate only ONE thing : each - vertex can have its own "WORLD" transformation (this is used in the - TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the - execute buffer use the same state. - - If I find applications that change other states, I will try to do a - more 'fine-tuned' state emulation (but I may become quite tricky if - it changes a light position in the middle of a triangle). - - In this case, a 'direct' approach (i.e. without using OpenGL, but - writing our own 3D rasterizer) would be easier. */ - - /* The current method (with the hypothesis that only the WORLD matrix - will change between two points) is like this : - - I transform 'manually' all the vertices with the current WORLD - matrix and store them in the vertex buffer - - during the rasterization phase, the WORLD matrix will be set to - the Identity matrix */ - - /* Enough for the moment */ - if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) { - unsigned int nb; - D3DVERTEX *src = ((D3DVERTEX *)((char *)buffer->desc.lpData + vs)) + ci->wStart; - D3DTLVERTEX *dst = ((D3DTLVERTEX *)buffer->vertex_data) + ci->wDest; - D3DVIEWPORT *Viewport = &viewport->viewports.vp1; - D3DMATRIX mat; - - if (TRACE_ON(ddraw)) - { - TRACE(" Projection Matrix : (%p)\n", &proj_mat); - dump_D3DMATRIX(&proj_mat); - TRACE(" View Matrix : (%p)\n", &view_mat); - dump_D3DMATRIX(&view_mat); - TRACE(" World Matrix : (%p)\n", &world_mat); - dump_D3DMATRIX(&world_mat); - } - - multiply_matrix(&mat,&view_mat,&world_mat); - multiply_matrix(&mat,&proj_mat,&mat); - - for (nb = 0; nb < ci->dwCount; nb++) { - /* No lighting yet */ - dst->u5.color = 0xFFFFFFFF; /* Opaque white */ - dst->u6.specular = 0xFF000000; /* No specular and no fog factor */ + TRACE(" Projection Matrix:\n"); + dump_D3DMATRIX(&proj_mat); + TRACE(" View Matrix:\n"); + dump_D3DMATRIX(&view_mat); + TRACE(" World Matrix:\n"); + dump_D3DMATRIX(&world_mat); + } - dst->u7.tu = src->u7.tu; - dst->u8.tv = src->u8.tv; + multiply_matrix(&mat, &view_mat, &world_mat); + multiply_matrix(&mat, &proj_mat, &mat); - dst->u1.sx = (src->u1.x * mat._11) + (src->u2.y * mat._21) + (src->u3.z * mat._31) + mat._41; - dst->u2.sy = (src->u1.x * mat._12) + (src->u2.y * mat._22) + (src->u3.z * mat._32) + mat._42; - dst->u3.sz = (src->u1.x * mat._13) + (src->u2.y * mat._23) + (src->u3.z * mat._33) + mat._43; - dst->u4.rhw = (src->u1.x * mat._14) + (src->u2.y * mat._24) + (src->u3.z * mat._34) + mat._44; + for (i = 0; i < count; ++i) + { + D3DPROCESSVERTICES *ci = (D3DPROCESSVERTICES *)instr; + D3DTLVERTEX *dst = (D3DTLVERTEX *)buffer->vertex_data + ci->wDest; + DWORD op = ci->dwFlags & D3DPROCESSVERTICES_OPMASK; - dst->u1.sx = dst->u1.sx / dst->u4.rhw * Viewport->dvScaleX - + Viewport->dwX + Viewport->dwWidth / 2; - dst->u2.sy = (-dst->u2.sy) / dst->u4.rhw * Viewport->dvScaleY - + Viewport->dwY + Viewport->dwHeight / 2; - dst->u3.sz /= dst->u4.rhw; - dst->u4.rhw = 1 / dst->u4.rhw; + TRACE(" start %u, dest %u, count %u, flags %#x.\n", + ci->wStart, ci->wDest, ci->dwCount, ci->dwFlags); - src++; - dst++; + if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS) + FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n"); + if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR) + FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n"); - } - } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) { - unsigned int nb; - D3DLVERTEX *src = ((D3DLVERTEX *)((char *)buffer->desc.lpData + vs)) + ci->wStart; - D3DTLVERTEX *dst = ((D3DTLVERTEX *)buffer->vertex_data) + ci->wDest; - D3DVIEWPORT *Viewport = &viewport->viewports.vp1; - D3DMATRIX mat; - - if (TRACE_ON(ddraw)) + switch (op) + { + case D3DPROCESSVERTICES_TRANSFORMLIGHT: { - TRACE(" Projection Matrix : (%p)\n", &proj_mat); - dump_D3DMATRIX(&proj_mat); - TRACE(" View Matrix : (%p)\n",&view_mat); - dump_D3DMATRIX(&view_mat); - TRACE(" World Matrix : (%p)\n", &world_mat); - dump_D3DMATRIX(&world_mat); - } - - multiply_matrix(&mat,&view_mat,&world_mat); - multiply_matrix(&mat,&proj_mat,&mat); - - for (nb = 0; nb < ci->dwCount; nb++) { - dst->u5.color = src->u4.color; - dst->u6.specular = src->u5.specular; - dst->u7.tu = src->u6.tu; - dst->u8.tv = src->u7.tv; + const D3DVERTEX *src = (D3DVERTEX *)((char *)buffer->desc.lpData + vs) + ci->wStart; + unsigned int vtx_idx; + static unsigned int once; + + if (!once++) + FIXME("Lighting not implemented.\n"); + + for (vtx_idx = 0; vtx_idx < ci->dwCount; ++vtx_idx) + { + transform_vertex(&dst[vtx_idx], &mat, &viewport->viewports.vp1, + src[vtx_idx].u1.x, src[vtx_idx].u2.y, src[vtx_idx].u3.z); + /* No lighting yet */ + dst[vtx_idx].u5.color = 0xffffffff; /* Opaque white */ + dst[vtx_idx].u6.specular = 0xff000000; /* No specular and no fog factor */ + dst[vtx_idx].u7.tu = src[vtx_idx].u7.tu; + dst[vtx_idx].u8.tv = src[vtx_idx].u8.tv; + } + break; + } - dst->u1.sx = (src->u1.x * mat._11) + (src->u2.y * mat._21) + (src->u3.z * mat._31) + mat._41; - dst->u2.sy = (src->u1.x * mat._12) + (src->u2.y * mat._22) + (src->u3.z * mat._32) + mat._42; - dst->u3.sz = (src->u1.x * mat._13) + (src->u2.y * mat._23) + (src->u3.z * mat._33) + mat._43; - dst->u4.rhw = (src->u1.x * mat._14) + (src->u2.y * mat._24) + (src->u3.z * mat._34) + mat._44; + case D3DPROCESSVERTICES_TRANSFORM: + { + const D3DLVERTEX *src = (D3DLVERTEX *)((char *)buffer->desc.lpData + vs) + ci->wStart; + unsigned int vtx_idx; + + for (vtx_idx = 0; vtx_idx < ci->dwCount; ++vtx_idx) + { + transform_vertex(&dst[vtx_idx], &mat, &viewport->viewports.vp1, + src[vtx_idx].u1.x, src[vtx_idx].u2.y, src[vtx_idx].u3.z); + dst[vtx_idx].u5.color = src[vtx_idx].u4.color; + dst[vtx_idx].u6.specular = src[vtx_idx].u5.specular; + dst[vtx_idx].u7.tu = src[vtx_idx].u6.tu; + dst[vtx_idx].u8.tv = src[vtx_idx].u7.tv; + } + break; + } - dst->u1.sx = dst->u1.sx / dst->u4.rhw * Viewport->dvScaleX - + Viewport->dwX + Viewport->dwWidth / 2; - dst->u2.sy = (-dst->u2.sy) / dst->u4.rhw * Viewport->dvScaleY - + Viewport->dwY + Viewport->dwHeight / 2; + case D3DPROCESSVERTICES_COPY: + { + const D3DTLVERTEX *src = (D3DTLVERTEX *)((char *)buffer->desc.lpData + vs) + ci->wStart; - dst->u3.sz /= dst->u4.rhw; - dst->u4.rhw = 1 / dst->u4.rhw; + memcpy(dst, src, ci->dwCount * sizeof(*dst)); + break; + } - src++; - dst++; - } + default: + FIXME("Unhandled vertex processing op %#x.\n", op); + break; } - else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) - { - D3DTLVERTEX *src = ((D3DTLVERTEX *)((char *)buffer->desc.lpData + vs)) + ci->wStart; - D3DTLVERTEX *dst = ((D3DTLVERTEX *)buffer->vertex_data) + ci->wDest; - - memcpy(dst, src, ci->dwCount * sizeof(D3DTLVERTEX)); - } else { - ERR("Unhandled vertex processing flag %#x.\n", ci->dwFlags); - } - instr += size; - } - } break; + instr += size; + } + break; + } case D3DOP_TEXTURELOAD: { WARN("TEXTURELOAD-s (%d)\n", count); @@ -463,10 +353,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, goto end_of_buffer; } break; - case D3DOP_BRANCHFORWARD: { - DWORD i; - TRACE("BRANCHFORWARD (%d)\n", count); - + case D3DOP_BRANCHFORWARD: + TRACE("BRANCHFORWARD (%d)\n", count); for (i = 0; i < count; ++i) { D3DBRANCH *ci = (D3DBRANCH *)instr; @@ -492,8 +380,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, } instr += size; - } - } break; + } + break; case D3DOP_SPAN: { WARN("SPAN-s (%d)\n", count); @@ -501,16 +389,14 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, instr += count * size; } break; - case D3DOP_SETSTATUS: { - DWORD i; - TRACE("SETSTATUS (%d)\n", count); - + case D3DOP_SETSTATUS: + TRACE("SETSTATUS (%d)\n", count); for (i = 0; i < count; ++i) { buffer->data.dsStatus = *(D3DSTATUS *)instr; instr += size; } - } break; + break; default: ERR("Unhandled OpCode %d !!!\n",current->bOpcode); @@ -529,45 +415,24 @@ static inline struct d3d_execute_buffer *impl_from_IDirect3DExecuteBuffer(IDirec return CONTAINING_RECORD(iface, struct d3d_execute_buffer, IDirect3DExecuteBuffer_iface); } -/***************************************************************************** - * IDirect3DExecuteBuffer::QueryInterface - * - * Well, a usual QueryInterface function. Don't know fur sure which - * interfaces it can Query. - * - * Params: - * riid: The interface ID queried for - * obj: Address to return the interface pointer at - * - * Returns: - * D3D_OK in case of a success (S_OK? Think it's the same) - * OLE_E_ENUM_NOMORE if the interface wasn't found. - * (E_NOINTERFACE?? Don't know what I really need) - * - *****************************************************************************/ -static HRESULT WINAPI d3d_execute_buffer_QueryInterface(IDirect3DExecuteBuffer *iface, REFIID riid, void **obj) +static HRESULT WINAPI d3d_execute_buffer_QueryInterface(IDirect3DExecuteBuffer *iface, REFIID iid, void **out) { - TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj); + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); - *obj = NULL; - - if ( IsEqualGUID( &IID_IUnknown, riid ) ) { - IDirect3DExecuteBuffer_AddRef(iface); - *obj = iface; - TRACE(" Creating IUnknown interface at %p.\n", *obj); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3DExecuteBuffer, riid ) ) { + if (IsEqualGUID(&IID_IDirect3DExecuteBuffer, iid) + || IsEqualGUID(&IID_IUnknown, iid)) + { IDirect3DExecuteBuffer_AddRef(iface); - *obj = iface; - TRACE(" Creating IDirect3DExecuteBuffer interface %p\n", *obj); - return S_OK; + *out = iface; + return S_OK; } - FIXME("(%p): interface for IID %s NOT found!\n", iface, debugstr_guid(riid)); + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + + *out = NULL; return E_NOINTERFACE; } - /***************************************************************************** * IDirect3DExecuteBuffer::AddRef * diff --git a/reactos/dll/directx/wine/ddraw/palette.c b/reactos/dll/directx/wine/ddraw/palette.c index fca27068547..4f5570bc2d9 100644 --- a/reactos/dll/directx/wine/ddraw/palette.c +++ b/reactos/dll/directx/wine/ddraw/palette.c @@ -170,6 +170,10 @@ static HRESULT WINAPI ddraw_palette_SetEntries(IDirectDrawPalette *iface, wined3d_mutex_lock(); hr = wined3d_palette_set_entries(palette->wineD3DPalette, flags, start, count, entries); + + if (SUCCEEDED(hr) && palette->flags & DDPCAPS_PRIMARYSURFACE) + ddraw_surface_update_frontbuffer(palette->ddraw->primary, NULL, FALSE); + wined3d_mutex_unlock(); return hr; diff --git a/reactos/dll/directx/wine/ddraw/surface.c b/reactos/dll/directx/wine/ddraw/surface.c index 4e465d3727c..49db2aa84c2 100644 --- a/reactos/dll/directx/wine/ddraw/surface.c +++ b/reactos/dll/directx/wine/ddraw/surface.c @@ -35,7 +35,7 @@ static inline struct ddraw_surface *impl_from_IDirectDrawGammaControl(IDirectDra * applications from drawing to the screen while we've locked the frontbuffer. * We'd like to do this in wined3d instead, but for that to work wined3d needs * to support windowless rendering first. */ -static HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RECT *rect, BOOL read) +HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RECT *rect, BOOL read) { HDC surface_dc, screen_dc; int x, y, w, h; @@ -317,6 +317,8 @@ static void ddraw_surface_add_iface(struct ddraw_surface *surface) if (surface->ifaceToRelease) IUnknown_AddRef(surface->ifaceToRelease); wined3d_mutex_lock(); + if (surface->wined3d_rtv) + wined3d_rendertarget_view_incref(surface->wined3d_rtv); if (surface->wined3d_surface) wined3d_surface_incref(surface->wined3d_surface); if (surface->wined3d_texture) @@ -442,6 +444,47 @@ static ULONG WINAPI d3d_texture1_AddRef(IDirect3DTexture *iface) return IUnknown_AddRef(surface->texture_outer); } +static HRESULT ddraw_surface_set_palette(struct ddraw_surface *surface, IDirectDrawPalette *palette) +{ + struct ddraw_palette *palette_impl = unsafe_impl_from_IDirectDrawPalette(palette); + struct ddraw_palette *prev; + + TRACE("iface %p, palette %p.\n", surface, palette); + + if (palette_impl && palette_impl->flags & DDPCAPS_ALPHA + && !(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)) + { + WARN("Alpha palette set on non-texture surface, returning DDERR_INVALIDSURFACETYPE.\n"); + return DDERR_INVALIDSURFACETYPE; + } + + if (!format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat)) + return DDERR_INVALIDPIXELFORMAT; + + wined3d_mutex_lock(); + + prev = surface->palette; + if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) + { + if (prev) + prev->flags &= ~DDPCAPS_PRIMARYSURFACE; + if (palette_impl) + palette_impl->flags |= DDPCAPS_PRIMARYSURFACE; + wined3d_swapchain_set_palette(surface->ddraw->wined3d_swapchain, + palette_impl ? palette_impl->wineD3DPalette : NULL); + ddraw_surface_update_frontbuffer(surface, NULL, FALSE); + } + if (palette_impl) + IDirectDrawPalette_AddRef(&palette_impl->IDirectDrawPalette_iface); + if (prev) + IDirectDrawPalette_Release(&prev->IDirectDrawPalette_iface); + surface->palette = palette_impl; + + wined3d_mutex_unlock(); + + return DD_OK; +} + static void ddraw_surface_cleanup(struct ddraw_surface *surface) { struct ddraw_surface *surf; @@ -451,7 +494,7 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface) /* The refcount test shows that the palette is detached when the surface * is destroyed. */ - IDirectDrawSurface7_SetPalette(&surface->IDirectDrawSurface7_iface, NULL); + ddraw_surface_set_palette(surface, NULL); /* Loop through all complex attached surfaces and destroy them. * @@ -480,6 +523,8 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface) surface, surface->ref7, surface->ref4, surface->ref3, surface->ref2, surface->ref1); } + if (surface->wined3d_rtv) + wined3d_rendertarget_view_decref(surface->wined3d_rtv); if (surface->wined3d_texture) wined3d_texture_decref(surface->wined3d_texture); if (surface->wined3d_surface) @@ -965,12 +1010,9 @@ static HRESULT surface_lock(struct ddraw_surface *This, SetRect(&This->ddraw->primary_lock, 0, 0, This->surface_desc.dwWidth, This->surface_desc.dwHeight); } - /* Override the memory area. The pitch should be set already. Strangely windows - * does not set the LPSURFACE flag on locked surfaces !?!. - * DDSD->dwFlags |= DDSD_LPSURFACE; - */ - This->surface_desc.lpSurface = map_desc.data; + /* Windows does not set DDSD_LPSURFACE on locked surfaces. */ DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc)); + DDSD->lpSurface = map_desc.data; TRACE("locked surface returning description :\n"); if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD); @@ -1115,12 +1157,8 @@ static HRESULT WINAPI ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pR wined3d_mutex_lock(); hr = wined3d_surface_unmap(surface->wined3d_surface); - if (SUCCEEDED(hr)) - { - if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) - hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE); - surface->surface_desc.lpSurface = NULL; - } + if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) + hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE); wined3d_mutex_unlock(); return hr; @@ -1169,11 +1207,12 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra { struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface7(iface); struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src); + struct wined3d_rendertarget_view *tmp_rtv, *src_rtv, *rtv; struct ddraw_texture *ddraw_texture, *prev_ddraw_texture; DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, {0}}; - struct wined3d_surface *tmp, *rt; struct wined3d_texture *texture; IDirectDrawSurface7 *current; + struct wined3d_surface *tmp; HRESULT hr; TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags); @@ -1181,11 +1220,15 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra if (src == iface || !(dst_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_OVERLAY))) return DDERR_NOTFLIPPABLE; + if (IDirectDrawSurface7_IsLost(iface) == DDERR_SURFACELOST) + return DDERR_SURFACELOST; + wined3d_mutex_lock(); + tmp_rtv = ddraw_surface_get_rendertarget_view(dst_impl); tmp = dst_impl->wined3d_surface; texture = dst_impl->wined3d_texture; - rt = wined3d_device_get_render_target(dst_impl->ddraw->wined3d_device, 0); + rtv = wined3d_device_get_rendertarget_view(dst_impl->ddraw->wined3d_device, 0); ddraw_texture = wined3d_texture_get_parent(dst_impl->wined3d_texture); if (src_impl) @@ -1207,8 +1250,11 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra } } - if (rt == dst_impl->wined3d_surface) - wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, src_impl->wined3d_surface, FALSE); + src_rtv = ddraw_surface_get_rendertarget_view(src_impl); + if (rtv == dst_impl->wined3d_rtv) + wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, src_rtv, FALSE); + wined3d_rendertarget_view_set_parent(src_rtv, dst_impl); + dst_impl->wined3d_rtv = src_rtv; wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl); dst_impl->wined3d_surface = src_impl->wined3d_surface; prev_ddraw_texture = wined3d_texture_get_parent(src_impl->wined3d_texture); @@ -1234,8 +1280,11 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra } src_impl = impl_from_IDirectDrawSurface7(current); - if (rt == dst_impl->wined3d_surface) - wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, src_impl->wined3d_surface, FALSE); + src_rtv = ddraw_surface_get_rendertarget_view(src_impl); + if (rtv == dst_impl->wined3d_rtv) + wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, src_rtv, FALSE); + wined3d_rendertarget_view_set_parent(src_rtv, dst_impl); + dst_impl->wined3d_rtv = src_rtv; wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl); dst_impl->wined3d_surface = src_impl->wined3d_surface; prev_ddraw_texture = wined3d_texture_get_parent(src_impl->wined3d_texture); @@ -1248,8 +1297,10 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra /* We don't have to worry about potential texture bindings, since * flippable surfaces can never be textures. */ - if (rt == src_impl->wined3d_surface) - wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, tmp, FALSE); + if (rtv == src_impl->wined3d_rtv) + wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, tmp_rtv, FALSE); + wined3d_rendertarget_view_set_parent(tmp_rtv, src_impl); + src_impl->wined3d_rtv = tmp_rtv; wined3d_resource_set_parent(wined3d_surface_get_resource(tmp), src_impl); src_impl->wined3d_surface = tmp; wined3d_resource_set_parent(wined3d_texture_get_resource(texture), ddraw_texture); @@ -1968,6 +2019,22 @@ static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *hdc) hr = ddraw_surface_update_frontbuffer(surface, NULL, TRUE); if (SUCCEEDED(hr)) hr = wined3d_surface_getdc(surface->wined3d_surface, hdc); + + if (SUCCEEDED(hr) && format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat)) + { + const struct ddraw_palette *palette; + + if (surface->palette) + palette = surface->palette; + else if (surface->ddraw->primary) + palette = surface->ddraw->primary->palette; + else + palette = NULL; + + if (palette) + wined3d_palette_apply_to_dc(palette->wineD3DPalette, *hdc); + } + wined3d_mutex_unlock(); switch(hr) { @@ -2164,63 +2231,63 @@ static HRESULT WINAPI ddraw_surface1_GetCaps(IDirectDrawSurface *iface, DDSCAPS return hr; } -/***************************************************************************** - * IDirectDrawSurface7::SetPriority - * - * Sets a texture priority for managed textures. - * - * Params: - * Priority: The new priority - * - * Returns: - * DD_OK on success - * For more details, see IWineD3DSurface::SetPriority - * - *****************************************************************************/ -static HRESULT WINAPI ddraw_surface7_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority) +static HRESULT WINAPI ddraw_surface7_SetPriority(IDirectDrawSurface7 *iface, DWORD priority) { struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); + DWORD managed = DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE; HRESULT hr; + struct wined3d_resource *resource; - TRACE("iface %p, priority %u.\n", iface, Priority); + TRACE("iface %p, priority %u.\n", iface, priority); wined3d_mutex_lock(); - hr = wined3d_surface_set_priority(surface->wined3d_surface, Priority); + /* No need to check for offscreen plain surfaces or mipmap sublevels. SetPriority + * calls on such surfaces segfault on Windows. */ + if (!(surface->surface_desc.ddsCaps.dwCaps2 & managed)) + { + WARN("Called on non-managed texture returning DDERR_INVALIDPARAMS.\n"); + hr = DDERR_INVALIDPARAMS; + } + else + { + resource = wined3d_texture_get_resource(surface->wined3d_texture); + wined3d_resource_set_priority(resource, priority); + hr = DD_OK; + } wined3d_mutex_unlock(); return hr; } -/***************************************************************************** - * IDirectDrawSurface7::GetPriority - * - * Returns the surface's priority - * - * Params: - * Priority: Address of a variable to write the priority to - * - * Returns: - * D3D_OK on success - * DDERR_INVALIDPARAMS if Priority == NULL - * For more details, see IWineD3DSurface::GetPriority - * - *****************************************************************************/ -static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWORD *Priority) +static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWORD *priority) { struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); + const struct wined3d_resource *resource; + DWORD managed = DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE; + HRESULT hr; - TRACE("iface %p, priority %p.\n", iface, Priority); + TRACE("iface %p, priority %p.\n", iface, priority); - if(!Priority) + wined3d_mutex_lock(); + if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN) { - return DDERR_INVALIDPARAMS; + WARN("Called on offscreenplain surface, returning DDERR_INVALIDOBJECT.\n"); + hr = DDERR_INVALIDOBJECT; + } + else if (!(surface->surface_desc.ddsCaps.dwCaps2 & managed) || !surface->wined3d_texture) + { + WARN("Called on non-managed texture or mipmap sublevel, returning DDERR_INVALIDPARAMS.\n"); + hr = DDERR_INVALIDPARAMS; + } + else + { + resource = wined3d_texture_get_resource(surface->wined3d_texture); + *priority = wined3d_resource_get_priority(resource); + hr = DD_OK; } - - wined3d_mutex_lock(); - *Priority = wined3d_surface_get_priority(surface->wined3d_surface); wined3d_mutex_unlock(); - return DD_OK; + return hr; } /***************************************************************************** @@ -4450,6 +4517,11 @@ static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDir if (!palette) return DDERR_INVALIDPARAMS; + if (IDirectDrawSurface7_IsLost(iface) == DDERR_SURFACELOST) + { + WARN("Surface lost, returning DDERR_SURFACELOST.\n"); + return DDERR_SURFACELOST; + } wined3d_mutex_lock(); if ((palette_impl = surface->palette)) @@ -4635,42 +4707,18 @@ static HRESULT WINAPI ddraw_surface1_SetColorKey(IDirectDrawSurface *iface, DWOR static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette *palette) { struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); - struct ddraw_palette *palette_impl = unsafe_impl_from_IDirectDrawPalette(palette); - struct ddraw_palette *prev; TRACE("iface %p, palette %p.\n", iface, palette); - if (!(surface->surface_desc.u4.ddpfPixelFormat.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 - | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8))) - return DDERR_INVALIDPIXELFORMAT; - if (surface->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL) return DDERR_NOTONMIPMAPSUBLEVEL; - - wined3d_mutex_lock(); - - prev = surface->palette; - if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) + if (IDirectDrawSurface7_IsLost(iface) == DDERR_SURFACELOST) { - if (prev) - prev->flags &= ~DDPCAPS_PRIMARYSURFACE; - if (palette_impl) - palette_impl->flags |= DDPCAPS_PRIMARYSURFACE; - /* Update the wined3d frontbuffer if this is the primary. */ - if (surface->ddraw->wined3d_frontbuffer) - wined3d_surface_set_palette(surface->ddraw->wined3d_frontbuffer, - palette_impl ? palette_impl->wineD3DPalette : NULL); + WARN("Surface lost, returning DDERR_SURFACELOST.\n"); + return DDERR_SURFACELOST; } - if (palette_impl) - IDirectDrawPalette_AddRef(&palette_impl->IDirectDrawPalette_iface); - if (prev) - IDirectDrawPalette_Release(&prev->IDirectDrawPalette_iface); - surface->palette = palette_impl; - wined3d_surface_set_palette(surface->wined3d_surface, palette_impl ? palette_impl->wineD3DPalette : NULL); - wined3d_mutex_unlock(); - - return DD_OK; + return ddraw_surface_set_palette(surface, palette); } static HRESULT WINAPI ddraw_surface4_SetPalette(IDirectDrawSurface4 *iface, IDirectDrawPalette *palette) @@ -4679,7 +4727,13 @@ static HRESULT WINAPI ddraw_surface4_SetPalette(IDirectDrawSurface4 *iface, IDir TRACE("iface %p, palette %p.\n", iface, palette); - return ddraw_surface7_SetPalette(&surface->IDirectDrawSurface7_iface, palette); + if (IDirectDrawSurface4_IsLost(iface) == DDERR_SURFACELOST) + { + WARN("Surface lost, returning DDERR_SURFACELOST.\n"); + return DDERR_SURFACELOST; + } + + return ddraw_surface_set_palette(surface, palette); } static HRESULT WINAPI ddraw_surface3_SetPalette(IDirectDrawSurface3 *iface, IDirectDrawPalette *palette) @@ -4688,7 +4742,13 @@ static HRESULT WINAPI ddraw_surface3_SetPalette(IDirectDrawSurface3 *iface, IDir TRACE("iface %p, palette %p.\n", iface, palette); - return ddraw_surface7_SetPalette(&surface->IDirectDrawSurface7_iface, palette); + if (IDirectDrawSurface3_IsLost(iface) == DDERR_SURFACELOST) + { + WARN("Surface lost, returning DDERR_SURFACELOST.\n"); + return DDERR_SURFACELOST; + } + + return ddraw_surface_set_palette(surface, palette); } static HRESULT WINAPI ddraw_surface2_SetPalette(IDirectDrawSurface2 *iface, IDirectDrawPalette *palette) @@ -4697,7 +4757,13 @@ static HRESULT WINAPI ddraw_surface2_SetPalette(IDirectDrawSurface2 *iface, IDir TRACE("iface %p, palette %p.\n", iface, palette); - return ddraw_surface7_SetPalette(&surface->IDirectDrawSurface7_iface, palette); + if (IDirectDrawSurface2_IsLost(iface) == DDERR_SURFACELOST) + { + WARN("Surface lost, returning DDERR_SURFACELOST.\n"); + return DDERR_SURFACELOST; + } + + return ddraw_surface_set_palette(surface, palette); } static HRESULT WINAPI ddraw_surface1_SetPalette(IDirectDrawSurface *iface, IDirectDrawPalette *palette) @@ -4706,7 +4772,13 @@ static HRESULT WINAPI ddraw_surface1_SetPalette(IDirectDrawSurface *iface, IDire TRACE("iface %p, palette %p.\n", iface, palette); - return ddraw_surface7_SetPalette(&surface->IDirectDrawSurface7_iface, palette); + if (IDirectDrawSurface_IsLost(iface) == DDERR_SURFACELOST) + { + WARN("Surface lost, returning DDERR_SURFACELOST.\n"); + return DDERR_SURFACELOST; + } + + return ddraw_surface_set_palette(surface, palette); } /********************************************************** @@ -4962,7 +5034,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu for (;;) { - struct wined3d_palette *wined3d_dst_pal, *wined3d_src_pal; + struct ddraw_palette *dst_pal, *src_pal; DDSURFACEDESC *src_desc, *dst_desc; TRACE("Copying surface %p to surface %p (mipmap level %d).\n", @@ -4972,20 +5044,20 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD; /* Get the palettes */ - wined3d_dst_pal = wined3d_surface_get_palette(dst_surface->wined3d_surface); - wined3d_src_pal = wined3d_surface_get_palette(src_surface->wined3d_surface); + dst_pal = dst_surface->palette; + src_pal = src_surface->palette; - if (wined3d_src_pal) + if (src_pal) { PALETTEENTRY palent[256]; - if (!wined3d_dst_pal) + if (!dst_pal) { wined3d_mutex_unlock(); return DDERR_NOPALETTEATTACHED; } - wined3d_palette_get_entries(wined3d_src_pal, 0, 0, 256, palent); - wined3d_palette_set_entries(wined3d_dst_pal, 0, 0, 256, palent); + IDirectDrawPalette_GetEntries(&src_pal->IDirectDrawPalette_iface, 0, 0, 256, palent); + IDirectDrawPalette_SetEntries(&dst_pal->IDirectDrawPalette_iface, 0, 0, 256, palent); } /* Copy one surface on the other */ @@ -5851,11 +5923,30 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ return DDERR_INVALIDPARAMS; } - if (!(desc->dwFlags & DDSD_PITCH)) + if (format_is_compressed(&desc->u4.ddpfPixelFormat)) { - WARN("User memory surfaces should explicitly specify the pitch.\n"); - HeapFree(GetProcessHeap(), 0, texture); - return DDERR_INVALIDPARAMS; + if (version != 4 && (desc->dwFlags & DDSD_PITCH)) + { + WARN("Pitch specified on a compressed user memory surface.\n"); + HeapFree(GetProcessHeap(), 0, texture); + return DDERR_INVALIDPARAMS; + } + + if (!(desc->dwFlags & (DDSD_LINEARSIZE | DDSD_PITCH))) + { + WARN("Compressed user memory surfaces should explicitly specify the linear size.\n"); + HeapFree(GetProcessHeap(), 0, texture); + return DDERR_INVALIDPARAMS; + } + } + else + { + if (!(desc->dwFlags & DDSD_PITCH)) + { + WARN("User memory surfaces should explicitly specify the pitch.\n"); + HeapFree(GetProcessHeap(), 0, texture); + return DDERR_INVALIDPARAMS; + } } } @@ -6077,42 +6168,65 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s desc->dwHeight = wined3d_desc.height; surface->first_attached = surface; - /* Anno 1602 stores the pitch right after surface creation, so make sure - * it's there. TODO: Test other fourcc formats. */ - if (wined3d_desc.format == WINED3DFMT_DXT1 || wined3d_desc.format == WINED3DFMT_DXT2 - || wined3d_desc.format == WINED3DFMT_DXT3 || wined3d_desc.format == WINED3DFMT_DXT4 - || wined3d_desc.format == WINED3DFMT_DXT5) + if (format_is_compressed(&desc->u4.ddpfPixelFormat)) { - surface->surface_desc.dwFlags |= DDSD_LINEARSIZE; - if (wined3d_desc.format == WINED3DFMT_DXT1) - surface->surface_desc.u1.dwLinearSize = max(4, desc->dwWidth) * max(4, desc->dwHeight) / 2; + if (desc->dwFlags & DDSD_LPSURFACE) + { + if ((desc->dwFlags & DDSD_LINEARSIZE) + && desc->u1.dwLinearSize < wined3d_surface_get_pitch(wined3d_surface) * ((desc->dwHeight + 3) / 4)) + { + WARN("Invalid linear size %u specified.\n", desc->u1.dwLinearSize); + return DDERR_INVALIDPARAMS; + } + + if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width, + wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0, + desc->lpSurface, 0))) + { + ERR("Failed to set surface memory, hr %#x.\n", hr); + return hr; + } + + desc->dwFlags |= DDSD_LINEARSIZE; + desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH); + desc->u1.dwLinearSize = ~0u; + } else - surface->surface_desc.u1.dwLinearSize = max(4, desc->dwWidth) * max(4, desc->dwHeight); - } - else if (!(desc->dwFlags & DDSD_LPSURFACE)) - { - desc->dwFlags |= DDSD_PITCH; - desc->u1.lPitch = wined3d_surface_get_pitch(wined3d_surface); + { + desc->dwFlags |= DDSD_LINEARSIZE; + desc->dwFlags &= ~DDSD_PITCH; + desc->u1.dwLinearSize = wined3d_surface_get_pitch(wined3d_surface) * ((desc->dwHeight + 3) / 4); + } } - - if (desc->dwFlags & DDSD_LPSURFACE) + else { - if (desc->u1.lPitch < wined3d_surface_get_pitch(wined3d_surface) || desc->u1.lPitch & 3) + if (desc->dwFlags & DDSD_LPSURFACE) { - WARN("Invalid pitch %u specified.\n", desc->u1.lPitch); - return DDERR_INVALIDPARAMS; - } + if (desc->u1.lPitch < wined3d_calculate_format_pitch(ddraw->wined3d, WINED3DADAPTER_DEFAULT, + wined3d_desc.format, wined3d_desc.width) || desc->u1.lPitch & 3) + { + WARN("Invalid pitch %u specified.\n", desc->u1.lPitch); + return DDERR_INVALIDPARAMS; + } + + if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width, + wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0, + desc->lpSurface, desc->u1.lPitch))) + { + ERR("Failed to set surface memory, hr %#x.\n", hr); + return hr; + } - if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width, - wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0, - desc->lpSurface, desc->u1.lPitch))) + desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE); + } + else { - ERR("Failed to set surface memory, hr %#x.\n", hr); - return hr; + desc->dwFlags |= DDSD_PITCH; + desc->dwFlags &= ~DDSD_LINEARSIZE; + desc->u1.lPitch = wined3d_surface_get_pitch(wined3d_surface); } - - desc->dwFlags &= ~DDSD_LPSURFACE; } + desc->lpSurface = NULL; wined3d_surface_incref(wined3d_surface); surface->wined3d_surface = wined3d_surface; @@ -6122,3 +6236,41 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s return DD_OK; } + +static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent) +{ + struct ddraw_surface *surface = parent; + + /* If the surface reference count drops to zero, we release our reference + * to the view, but don't clear the pointer yet, in case e.g. a + * GetRenderTarget() call brings the surface back before the view is + * actually destroyed. When the view is destroyed, we need to clear the + * pointer, or a subsequent surface AddRef() would reference it again. + * + * This is safe because as long as the view still has a reference to the + * texture, the surface is also still alive, and we're called before the + * view releases that reference. */ + surface->wined3d_rtv = NULL; +} + +static const struct wined3d_parent_ops ddraw_view_wined3d_parent_ops = +{ + view_wined3d_object_destroyed, +}; + +struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) +{ + HRESULT hr; + + if (surface->wined3d_rtv) + return surface->wined3d_rtv; + + if (FAILED(hr = wined3d_rendertarget_view_create_from_surface(surface->wined3d_surface, + surface, &ddraw_view_wined3d_parent_ops, &surface->wined3d_rtv))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return NULL; + } + + return surface->wined3d_rtv; +} diff --git a/reactos/dll/directx/wine/ddraw/utils.c b/reactos/dll/directx/wine/ddraw/utils.c index daf0f6ca7d5..ab2600af4eb 100644 --- a/reactos/dll/directx/wine/ddraw/utils.c +++ b/reactos/dll/directx/wine/ddraw/utils.c @@ -730,57 +730,35 @@ DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf) TRACE("( "); DDRAW_dump_pixelformat_flag(pf->dwFlags); if (pf->dwFlags & DDPF_FOURCC) - { - TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel", + TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %u bits per pixel", (unsigned char)( pf->dwFourCC &0xff), (unsigned char)((pf->dwFourCC>> 8)&0xff), (unsigned char)((pf->dwFourCC>>16)&0xff), (unsigned char)((pf->dwFourCC>>24)&0xff), pf->dwFourCC, - pf->u1.dwYUVBitCount - ); - } + pf->u1.dwYUVBitCount); if (pf->dwFlags & DDPF_RGB) { - const char *cmd; - TRACE(", RGB bits: %d, ", pf->u1.dwRGBBitCount); - switch (pf->u1.dwRGBBitCount) - { - case 4: cmd = "%1lx"; break; - case 8: cmd = "%02lx"; break; - case 16: cmd = "%04lx"; break; - case 24: cmd = "%06lx"; break; - case 32: cmd = "%08lx"; break; - default: ERR("Unexpected bit depth!\n"); cmd = "%d"; break; - } - TRACE(" R "); TRACE(cmd, pf->u2.dwRBitMask); - TRACE(" G "); TRACE(cmd, pf->u3.dwGBitMask); - TRACE(" B "); TRACE(cmd, pf->u4.dwBBitMask); + TRACE(", RGB bits: %u, R 0x%08x G 0x%08x B 0x%08x", + pf->u1.dwRGBBitCount, + pf->u2.dwRBitMask, + pf->u3.dwGBitMask, + pf->u4.dwBBitMask); if (pf->dwFlags & DDPF_ALPHAPIXELS) - { - TRACE(" A "); TRACE(cmd, pf->u5.dwRGBAlphaBitMask); - } + TRACE(" A 0x%08x", pf->u5.dwRGBAlphaBitMask); if (pf->dwFlags & DDPF_ZPIXELS) - { - TRACE(" Z "); TRACE(cmd, pf->u5.dwRGBZBitMask); - } + TRACE(" Z 0x%08x", pf->u5.dwRGBZBitMask); } if (pf->dwFlags & DDPF_ZBUFFER) - { - TRACE(", Z bits : %d", pf->u1.dwZBufferBitDepth); - } + TRACE(", Z bits: %u", pf->u1.dwZBufferBitDepth); if (pf->dwFlags & DDPF_ALPHA) - { - TRACE(", Alpha bits : %d", pf->u1.dwAlphaBitDepth); - } + TRACE(", Alpha bits: %u", pf->u1.dwAlphaBitDepth); if (pf->dwFlags & DDPF_BUMPDUDV) - { - const char *cmd = "%08lx"; - TRACE(", Bump bits: %d, ", pf->u1.dwBumpBitCount); - TRACE(" U "); TRACE(cmd, pf->u2.dwBumpDuBitMask); - TRACE(" V "); TRACE(cmd, pf->u3.dwBumpDvBitMask); - TRACE(" L "); TRACE(cmd, pf->u4.dwBumpLuminanceBitMask); - } + TRACE(", Bump bits: %u, U 0x%08x V 0x%08x L 0x%08x", + pf->u1.dwBumpBitCount, + pf->u2.dwBumpDuBitMask, + pf->u3.dwBumpDvBitMask, + pf->u4.dwBumpLuminanceBitMask); TRACE(")\n"); } diff --git a/reactos/dll/directx/wine/ddraw/vertexbuffer.c b/reactos/dll/directx/wine/ddraw/vertexbuffer.c index 842a3bd2ad7..47cebe8c4ad 100644 --- a/reactos/dll/directx/wine/ddraw/vertexbuffer.c +++ b/reactos/dll/directx/wine/ddraw/vertexbuffer.c @@ -154,8 +154,6 @@ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface) 0, &curVB, &offset, &stride); if (curVB == buffer->wineD3DVertexBuffer) wined3d_device_set_stream_source(buffer->ddraw->wined3d_device, 0, NULL, 0, 0); - if (curVB) - wined3d_buffer_decref(curVB); /* For the GetStreamSource */ wined3d_vertex_declaration_decref(buffer->wineD3DVertexDeclaration); wined3d_buffer_decref(buffer->wineD3DVertexBuffer); diff --git a/reactos/dll/directx/wine/ddraw/viewport.c b/reactos/dll/directx/wine/ddraw/viewport.c index 42640055611..f4114ad1554 100644 --- a/reactos/dll/directx/wine/ddraw/viewport.c +++ b/reactos/dll/directx/wine/ddraw/viewport.c @@ -519,39 +519,18 @@ static HRESULT WINAPI d3d_viewport_LightElements(IDirect3DViewport3 *iface, return DDERR_UNSUPPORTED; } -/***************************************************************************** - * IDirect3DViewport3::SetBackground - * - * Sets the background material - * - * Params: - * hMat: Handle from a IDirect3DMaterial interface - * - * Returns: - * D3D_OK on success - * - *****************************************************************************/ -static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE hMat) +static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material) { struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface); struct d3d_material *m; - TRACE("iface %p, material %#x.\n", iface, hMat); + TRACE("iface %p, material %#x.\n", iface, material); wined3d_mutex_lock(); - if (!hMat) + if (!(m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, material - 1, DDRAW_HANDLE_MATERIAL))) { - viewport->background = NULL; - TRACE("Setting background to NULL\n"); - wined3d_mutex_unlock(); - return D3D_OK; - } - - m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, hMat - 1, DDRAW_HANDLE_MATERIAL); - if (!m) - { - WARN("Invalid material handle.\n"); + WARN("Invalid material handle %#x.\n", material); wined3d_mutex_unlock(); return DDERR_INVALIDPARAMS; } @@ -681,16 +660,13 @@ static HRESULT WINAPI d3d_viewport_Clear(IDirect3DViewport3 *iface, if (flags & D3DCLEAR_TARGET) { - if (This->background == NULL) { - ERR(" Trying to clear the color buffer without background material!\n"); - } + if (!This->background) + WARN("No background material set.\n"); else - { - color = ((int)((This->background->mat.u.diffuse.u1.r) * 255) << 16) - | ((int) ((This->background->mat.u.diffuse.u2.g) * 255) << 8) - | ((int) ((This->background->mat.u.diffuse.u3.b) * 255) << 0) - | ((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24); - } + color = D3DRGBA(This->background->mat.u.diffuse.u1.r, + This->background->mat.u.diffuse.u2.g, + This->background->mat.u.diffuse.u3.b, + This->background->mat.u.diffuse.u4.a); } /* Need to temporarily activate viewport to clear it. Previously active one will be restored diff --git a/reactos/dll/directx/wine/wined3d/arb_program_shader.c b/reactos/dll/directx/wine/wined3d/arb_program_shader.c index 3519c783b1c..d1e2a3cf35e 100644 --- a/reactos/dll/directx/wine/wined3d/arb_program_shader.c +++ b/reactos/dll/directx/wine/wined3d/arb_program_shader.c @@ -700,7 +700,7 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv, { const struct wined3d_shader *pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL]; const struct arb_ps_compiled_shader *gl_shader = priv->compiled_fprog; - UINT rt_height = state->fb->render_targets[0]->resource.height; + UINT rt_height = state->fb->render_targets[0]->height; /* Load DirectX 9 float constants for pixel shader */ priv->highest_dirty_ps_const = shader_arb_load_constantsF(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB, @@ -3278,7 +3278,7 @@ static GLuint create_arb_blt_vertex_program(const struct wined3d_gl_info *gl_inf GLuint program_id = 0; GLint pos; - const char *blt_vprogram = + static const char blt_vprogram[] = "!!ARBvp1.0\n" "PARAM c[1] = { { 1, 0.5 } };\n" "MOV result.position, vertex.position;\n" @@ -4667,7 +4667,7 @@ static void shader_arb_select(void *shader_priv, struct wined3d_context *context } else { - UINT rt_height = state->fb->render_targets[0]->resource.height; + UINT rt_height = state->fb->render_targets[0]->height; shader_arb_ps_local_constants(compiled, context, state, rt_height); } @@ -5185,6 +5185,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_DEFB */ shader_hw_nop, /* WINED3DSIH_DEFI */ shader_hw_nop, /* WINED3DSIH_DIV */ NULL, + /* WINED3DSIH_DP2 */ NULL, /* WINED3DSIH_DP2ADD */ pshader_hw_dp2add, /* WINED3DSIH_DP3 */ shader_hw_map2gl, /* WINED3DSIH_DP4 */ shader_hw_map2gl, @@ -5208,6 +5209,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_IFC */ shader_hw_ifc, /* WINED3DSIH_IGE */ NULL, /* WINED3DSIH_IMUL */ NULL, + /* WINED3DSIH_ISHL */ NULL, /* WINED3DSIH_ITOF */ NULL, /* WINED3DSIH_LABEL */ shader_hw_label, /* WINED3DSIH_LD */ NULL, @@ -6783,7 +6785,7 @@ static void arbfp_free_blit_shader(struct wine_rb_entry *entry, void *context) HeapFree(GetProcessHeap(), 0, entry_arb); } -const struct wine_rb_functions wined3d_arbfp_blit_rb_functions = +static const struct wine_rb_functions wined3d_arbfp_blit_rb_functions = { wined3d_rb_alloc, wined3d_rb_realloc, @@ -7270,15 +7272,12 @@ static GLuint gen_p8_shader(struct arbfp_blit_priv *priv, } /* Context activation is done by the caller. */ -static void upload_palette(const struct wined3d_surface *surface, struct wined3d_context *context) +static void upload_palette(const struct wined3d_texture *texture, struct wined3d_context *context) { - BYTE table[256][4]; - struct wined3d_device *device = surface->resource.device; + const struct wined3d_palette *palette = texture->swapchain ? texture->swapchain->palette : NULL; + struct wined3d_device *device = texture->resource.device; const struct wined3d_gl_info *gl_info = context->gl_info; struct arbfp_blit_priv *priv = device->blit_priv; - BOOL colorkey = !!(surface->container->color_key_flags & WINEDDSD_CKSRCBLT); - - d3dfmt_p8_init_palette(surface, table, colorkey); if (!priv->palette_texture) gl_info->gl_ops.gl.p_glGenTextures(1, &priv->palette_texture); @@ -7292,9 +7291,19 @@ static void upload_palette(const struct wined3d_surface *surface, struct wined3d /* Make sure we have discrete color levels. */ gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - /* Upload the palette */ /* TODO: avoid unneeded uploads in the future by adding some SFLAG_PALETTE_DIRTY mechanism */ - gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, table); + if (palette) + { + gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 256, 0, GL_BGRA, + GL_UNSIGNED_INT_8_8_8_8_REV, palette->colors); + } + else + { + static const DWORD black; + FIXME("P8 surface loaded without a palette.\n"); + gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 1, 0, GL_BGRA, + GL_UNSIGNED_INT_8_8_8_8_REV, &black); + } /* Switch back to unit 0 in which the 2D texture will be stored. */ context_active_texture(context, gl_info, 0); @@ -7523,7 +7532,7 @@ err_out: } if (fixup == COMPLEX_FIXUP_P8) - upload_palette(surface, context); + upload_palette(surface->container, context); gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB); checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)"); @@ -7630,7 +7639,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, if (wined3d_settings.offscreen_rendering_mode != ORM_FBO && (src_surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_DRAWABLE)) == WINED3D_LOCATION_DRAWABLE - && !surface_is_offscreen(src_surface)) + && !wined3d_resource_is_offscreen(&src_surface->container->resource)) { /* Without FBO blits transferring from the drawable to the texture is * expensive, because we have to flip the data in sysmem. Since we can @@ -7647,7 +7656,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, context_apply_blit_state(context, device); - if (!surface_is_offscreen(dst_surface)) + if (!wined3d_resource_is_offscreen(&dst_surface->container->resource)) surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect); arbfp_blit_set(device->blit_priv, context, src_surface); @@ -7659,13 +7668,14 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, arbfp_blit_unset(context->gl_info); if (wined3d_settings.strict_draw_ordering - || (dst_surface->swapchain && (dst_surface->swapchain->front_buffer == dst_surface))) + || (dst_surface->container->swapchain + && (dst_surface->container->swapchain->front_buffer == dst_surface->container))) context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); - surface_validate_location(dst_surface, dst_surface->draw_binding); - surface_invalidate_location(dst_surface, ~dst_surface->draw_binding); + surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding); + surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding); return WINED3D_OK; } diff --git a/reactos/dll/directx/wine/wined3d/buffer.c b/reactos/dll/directx/wine/wined3d/buffer.c index 2bffe83e7ae..810771a680d 100644 --- a/reactos/dll/directx/wine/wined3d/buffer.c +++ b/reactos/dll/directx/wine/wined3d/buffer.c @@ -31,7 +31,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); #define WINED3D_BUFFER_DOUBLEBUFFER 0x04 /* Keep both a buffer object and a system memory copy for this buffer. */ #define WINED3D_BUFFER_FLUSH 0x08 /* Manual unmap flushing. */ #define WINED3D_BUFFER_DISCARD 0x10 /* A DISCARD lock has occurred since the last preload. */ -#define WINED3D_BUFFER_NOSYNC 0x20 /* All locks since the last preload had NOOVERWRITE set. */ +#define WINED3D_BUFFER_SYNC 0x20 /* There has been at least one synchronized map since the last preload. */ #define WINED3D_BUFFER_APPLESYNC 0x40 /* Using sync as in GL_APPLE_flush_buffer_range. */ #define VB_MAXDECLCHANGES 100 /* After that number of decl changes we stop converting */ @@ -574,16 +574,6 @@ void * CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer) return buffer->resource.parent; } -DWORD CDECL wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD priority) -{ - return resource_set_priority(&buffer->resource, priority); -} - -DWORD CDECL wined3d_buffer_get_priority(const struct wined3d_buffer *buffer) -{ - return resource_get_priority(&buffer->resource); -} - /* The caller provides a context and binds the buffer */ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const struct wined3d_gl_info *gl_info) { @@ -669,7 +659,7 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined mapflags = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT; if (flags & WINED3D_BUFFER_DISCARD) mapflags |= GL_MAP_INVALIDATE_BUFFER_BIT; - if (flags & WINED3D_BUFFER_NOSYNC) + else if (!(flags & WINED3D_BUFFER_SYNC)) mapflags |= GL_MAP_UNSYNCHRONIZED_BIT; map = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0, This->resource.size, mapflags)); @@ -682,7 +672,7 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined DWORD syncflags = 0; if (flags & WINED3D_BUFFER_DISCARD) syncflags |= WINED3D_MAP_DISCARD; - if (flags & WINED3D_BUFFER_NOSYNC) + else if (!(flags & WINED3D_BUFFER_SYNC)) syncflags |= WINED3D_MAP_NOOVERWRITE; buffer_sync_apple(This, syncflags, gl_info); } @@ -718,11 +708,16 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined checkGLcall("glUnmapBufferARB"); } +void buffer_mark_used(struct wined3d_buffer *buffer) +{ + buffer->flags &= ~(WINED3D_BUFFER_SYNC | WINED3D_BUFFER_DISCARD); +} + /* Context activation is done by the caller. */ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state) { - DWORD flags = buffer->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD); + DWORD flags = buffer->flags & (WINED3D_BUFFER_SYNC | WINED3D_BUFFER_DISCARD); struct wined3d_device *device = buffer->resource.device; UINT start = 0, end = 0, len = 0, vertices; const struct wined3d_gl_info *gl_info; @@ -738,7 +733,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte return; } - buffer->flags &= ~(WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD); + buffer_mark_used(buffer); if (!buffer->buffer_object) { @@ -1033,11 +1028,8 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN if (flags & WINED3D_MAP_DISCARD) buffer->flags |= WINED3D_BUFFER_DISCARD; - - if (!(flags & WINED3D_MAP_NOOVERWRITE)) - buffer->flags &= ~WINED3D_BUFFER_NOSYNC; - else if (!buffer_is_dirty(buffer)) - buffer->flags |= WINED3D_BUFFER_NOSYNC; + else if (!(flags & WINED3D_MAP_NOOVERWRITE)) + buffer->flags |= WINED3D_BUFFER_SYNC; } base = buffer->map_ptr ? buffer->map_ptr : buffer->resource.heap_memory; @@ -1118,8 +1110,20 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer) } } +static ULONG buffer_resource_incref(struct wined3d_resource *resource) +{ + return wined3d_buffer_incref(buffer_from_resource(resource)); +} + +static ULONG buffer_resource_decref(struct wined3d_resource *resource) +{ + return wined3d_buffer_decref(buffer_from_resource(resource)); +} + static const struct wined3d_resource_ops buffer_resource_ops = { + buffer_resource_incref, + buffer_resource_decref, buffer_unload, }; @@ -1217,8 +1221,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device return WINED3D_OK; } -HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, struct wined3d_buffer_desc *desc, const void *data, - void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer) +HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc, + const void *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer) { struct wined3d_buffer *object; HRESULT hr; diff --git a/reactos/dll/directx/wine/wined3d/context.c b/reactos/dll/directx/wine/wined3d/context.c index a8d30335b43..cbb5815ef9f 100644 --- a/reactos/dll/directx/wine/wined3d/context.c +++ b/reactos/dll/directx/wine/wined3d/context.c @@ -1582,7 +1582,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ret->current_rt = target; ret->tid = GetCurrentThreadId(); - ret->render_offscreen = surface_is_offscreen(target); + ret->render_offscreen = wined3d_resource_is_offscreen(&target->container->resource); ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK); ret->valid = 1; @@ -1713,7 +1713,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, * So make sure a program is assigned to each context. The first real ARBFP use will set a different * program and the dummy program is destroyed when the context is destroyed. */ - const char *dummy_program = + static const char dummy_program[] = "!!ARBfp1.0\n" "MOV result.color, fragment.color.primary;\n" "END\n"; @@ -1818,7 +1818,7 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz { const struct wined3d_surface *rt = context->current_rt; - if (rt->swapchain && rt->swapchain->front_buffer == rt) + if (rt->container->swapchain && rt->container->swapchain->front_buffer == rt->container) { RECT window_size; @@ -2193,13 +2193,13 @@ static BOOL match_depth_stencil_format(const struct wined3d_format *existing, /* The caller provides a context */ static void context_validate_onscreen_formats(struct wined3d_context *context, - const struct wined3d_surface *depth_stencil) + const struct wined3d_rendertarget_view *depth_stencil) { /* Onscreen surfaces are always in a swapchain */ - struct wined3d_swapchain *swapchain = context->current_rt->swapchain; + struct wined3d_swapchain *swapchain = context->current_rt->container->swapchain; if (context->render_offscreen || !depth_stencil) return; - if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format)) return; + if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->format)) return; /* TODO: If the requested format would satisfy the needs of the existing one(reverse match), * or no onscreen depth buffer was created, the OpenGL drawable could be changed to the new @@ -2217,7 +2217,7 @@ static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_device *device { if (!rt || rt->resource.format->id == WINED3DFMT_NULL) return 0; - else if (rt->swapchain) + else if (rt->container->swapchain) return context_generate_rt_mask_from_surface(rt); else return context_generate_rt_mask(device->offscreenBuffer); @@ -2237,7 +2237,7 @@ void context_apply_blit_state(struct wined3d_context *context, const struct wine { wined3d_texture_load(rt->container, context, FALSE); - context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, rt, NULL, rt->draw_binding); + context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, rt, NULL, rt->container->resource.draw_binding); if (rt->resource.format->id != WINED3DFMT_NULL) rt_mask = 1; else @@ -2272,8 +2272,8 @@ void context_apply_blit_state(struct wined3d_context *context, const struct wine context_invalidate_state(context, STATE_FRAMEBUFFER); } -static BOOL context_validate_rt_config(UINT rt_count, - struct wined3d_surface * const *rts, const struct wined3d_surface *ds) +static BOOL context_validate_rt_config(UINT rt_count, struct wined3d_rendertarget_view * const *rts, + const struct wined3d_rendertarget_view *ds) { unsigned int i; @@ -2281,7 +2281,7 @@ static BOOL context_validate_rt_config(UINT rt_count, for (i = 0; i < rt_count; ++i) { - if (rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL) + if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL) return TRUE; } @@ -2293,10 +2293,10 @@ static BOOL context_validate_rt_config(UINT rt_count, BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb) { + struct wined3d_rendertarget_view **rts = fb->render_targets; const struct wined3d_gl_info *gl_info = context->gl_info; DWORD rt_mask = 0, *cur_mask; UINT i; - struct wined3d_surface **rts = fb->render_targets; if (isStateDirty(context, STATE_FRAMEBUFFER) || fb != &device->fb || rt_count != context->gl_info->limits.buffers) @@ -2308,12 +2308,12 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win { context_validate_onscreen_formats(context, fb->depth_stencil); - if (!rt_count || surface_is_offscreen(rts[0])) + if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)) { for (i = 0; i < rt_count; ++i) { - context->blit_targets[i] = rts[i]; - if (rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL) + context->blit_targets[i] = wined3d_rendertarget_view_get_surface(rts[i]); + if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL) rt_mask |= (1 << i); } while (i < context->gl_info->limits.buffers) @@ -2321,13 +2321,14 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win context->blit_targets[i] = NULL; ++i; } - context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, fb->depth_stencil, - rt_count ? rts[0]->draw_binding : WINED3D_LOCATION_TEXTURE_RGB); + context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, + wined3d_rendertarget_view_get_surface(fb->depth_stencil), + rt_count ? rts[0]->resource->draw_binding : WINED3D_LOCATION_TEXTURE_RGB); } else { context_apply_fbo_state(context, GL_FRAMEBUFFER, NULL, NULL, WINED3D_LOCATION_DRAWABLE); - rt_mask = context_generate_rt_mask_from_surface(rts[0]); + rt_mask = context_generate_rt_mask_from_surface(wined3d_rendertarget_view_get_surface(rts[0])); } /* If the framebuffer is not the device's fb the device's fb has to be reapplied @@ -2337,20 +2338,23 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win } else { - rt_mask = context_generate_rt_mask_no_fbo(device, rt_count ? rts[0] : NULL); + rt_mask = context_generate_rt_mask_no_fbo(device, + rt_count ? wined3d_rendertarget_view_get_surface(rts[0]) : NULL); } } else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO - && (!rt_count || surface_is_offscreen(rts[0]))) + && (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))) { for (i = 0; i < rt_count; ++i) { - if (rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL) rt_mask |= (1 << i); + if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL) + rt_mask |= (1 << i); } } else { - rt_mask = context_generate_rt_mask_no_fbo(device, rt_count ? rts[0] : NULL); + rt_mask = context_generate_rt_mask_no_fbo(device, + rt_count ? wined3d_rendertarget_view_get_surface(rts[0]) : NULL); } cur_mask = context->current_fbo ? &context->current_fbo->rt_mask : &context->draw_buffers_mask; @@ -2387,13 +2391,15 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const struct wined3d_device *device) { const struct wined3d_state *state = &device->state; - struct wined3d_surface **rts = state->fb->render_targets; + struct wined3d_rendertarget_view **rts = state->fb->render_targets; struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL]; DWORD rt_mask, rt_mask_bits; unsigned int i; - if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return context_generate_rt_mask_no_fbo(device, rts[0]); - else if (!context->render_offscreen) return context_generate_rt_mask_from_surface(rts[0]); + if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) + return context_generate_rt_mask_no_fbo(device, wined3d_rendertarget_view_get_surface(rts[0])); + else if (!context->render_offscreen) + return context_generate_rt_mask_from_surface(wined3d_rendertarget_view_get_surface(rts[0])); rt_mask = ps ? ps->reg_maps.rt_mask : 1; rt_mask &= context->d3d_info->valid_rt_mask; @@ -2402,7 +2408,7 @@ static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const while (rt_mask_bits) { rt_mask_bits &= ~(1 << i); - if (!rts[i] || rts[i]->resource.format->id == WINED3DFMT_NULL) + if (!rts[i] || rts[i]->format->id == WINED3DFMT_NULL) rt_mask &= ~(1 << i); i++; @@ -2427,8 +2433,15 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat } else { - context_apply_fbo_state(context, GL_FRAMEBUFFER, fb->render_targets, fb->depth_stencil, - fb->render_targets[0]->draw_binding); + unsigned int i; + + for (i = 0; i < context->gl_info->limits.buffers; ++i) + { + context->blit_targets[i] = wined3d_rendertarget_view_get_surface(fb->render_targets[i]); + } + context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, + wined3d_rendertarget_view_get_surface(fb->depth_stencil), + fb->render_targets[0]->resource->draw_binding); } } @@ -2717,7 +2730,6 @@ static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum) return TRUE; } -/* FIXME: Separate buffer loading from declaration decoding */ /* Context activation is done by the caller. */ void context_stream_info_from_declaration(struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_stream_info *stream_info) @@ -2726,11 +2738,9 @@ void context_stream_info_from_declaration(struct wined3d_context *context, struct wined3d_vertex_declaration *declaration = state->vertex_declaration; BOOL use_vshader = use_vs(state); unsigned int i; - WORD map; stream_info->use_map = 0; stream_info->swizzle_map = 0; - stream_info->all_vbo = 1; stream_info->position_transformed = declaration->position_transformed; /* Translate the declaration into strided data. */ @@ -2738,38 +2748,14 @@ void context_stream_info_from_declaration(struct wined3d_context *context, { const struct wined3d_vertex_declaration_element *element = &declaration->elements[i]; const struct wined3d_stream_state *stream = &state->streams[element->input_slot]; - struct wined3d_buffer *buffer = stream->buffer; - struct wined3d_bo_address data; BOOL stride_used; unsigned int idx; - DWORD stride; TRACE("%p Element %p (%u of %u).\n", declaration->elements, element, i + 1, declaration->element_count); - if (!buffer) continue; - - stride = stream->stride; - TRACE("Stream %u in buffer %p.\n", element->input_slot, buffer); - buffer_get_memory(buffer, context, &data); - - /* Can't use vbo's if the base vertex index is negative. OpenGL doesn't accept negative offsets - * (or rather offsets bigger than the vbo, because the pointer is unsigned), so use system memory - * sources. In most sane cases the pointer - offset will still be > 0, otherwise it will wrap - * around to some big value. Hope that with the indices, the driver wraps it back internally. If - * not, drawStridedSlow is needed, including a vertex buffer path. */ - if (state->load_base_vertex_index < 0) - { - WARN_(d3d_perf)("load_base_vertex_index is < 0 (%d), not using VBOs.\n", - state->load_base_vertex_index); - data.buffer_object = 0; - data.addr = buffer_get_sysmem(buffer, context); - if ((UINT_PTR)data.addr < -state->load_base_vertex_index * stride) - { - FIXME("System memory vertex data load offset is negative!\n"); - } - } - data.addr += element->offset; + if (!stream->buffer) + continue; TRACE("offset %u input_slot %u usage_idx %d.\n", element->offset, element->input_slot, element->usage_idx); @@ -2806,16 +2792,15 @@ void context_stream_info_from_declaration(struct wined3d_context *context, if (stride_used) { TRACE("Load %s array %u [usage %s, usage_idx %u, " - "input_slot %u, offset %u, stride %u, format %s, buffer_object %u].\n", + "input_slot %u, offset %u, stride %u, format %s].\n", use_vshader ? "shader": "fixed function", idx, debug_d3ddeclusage(element->usage), element->usage_idx, element->input_slot, - element->offset, stride, debug_d3dformat(element->format->id), data.buffer_object); - - data.addr += stream->offset; + element->offset, stream->stride, debug_d3dformat(element->format->id)); stream_info->elements[idx].format = element->format; - stream_info->elements[idx].data = data; - stream_info->elements[idx].stride = stride; + stream_info->elements[idx].data.buffer_object = 0; + stream_info->elements[idx].data.addr = (BYTE *)NULL + stream->offset + element->offset; + stream_info->elements[idx].stride = stream->stride; stream_info->elements[idx].stream_idx = element->input_slot; if (!context->gl_info->supported[ARB_VERTEX_ARRAY_BGRA] @@ -2826,12 +2811,26 @@ void context_stream_info_from_declaration(struct wined3d_context *context, stream_info->use_map |= 1 << idx; } } +} + +/* Context activation is done by the caller. */ +static void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + const struct wined3d_d3d_info *d3d_info = context->d3d_info; + struct wined3d_stream_info *stream_info = &context->stream_info; + DWORD prev_all_vbo = stream_info->all_vbo; + unsigned int i; + WORD map; - /* Preload the vertex buffers. */ + context_stream_info_from_declaration(context, state, stream_info); + + stream_info->all_vbo = 1; context->num_buffer_queries = 0; for (i = 0, map = stream_info->use_map; map; map >>= 1, ++i) { struct wined3d_stream_info_element *element; + struct wined3d_bo_address data; struct wined3d_buffer *buffer; if (!(map & 1)) @@ -2839,34 +2838,39 @@ void context_stream_info_from_declaration(struct wined3d_context *context, element = &stream_info->elements[i]; buffer = state->streams[element->stream_idx].buffer; - buffer_internal_preload(buffer, context, state); - /* If the preload dropped the buffer object, update the stream info. */ - if (buffer->buffer_object != element->data.buffer_object) + /* We can't use VBOs if the base vertex index is negative. OpenGL + * doesn't accept negative offsets (or rather offsets bigger than the + * VBO, because the pointer is unsigned), so use system memory + * sources. In most sane cases the pointer - offset will still be > 0, + * otherwise it will wrap around to some big value. Hope that with the + * indices the driver wraps it back internally. If not, + * drawStridedSlow is needed, including a vertex buffer path. */ + if (state->load_base_vertex_index < 0) { + WARN_(d3d_perf)("load_base_vertex_index is < 0 (%d), not using VBOs.\n", + state->load_base_vertex_index); element->data.buffer_object = 0; - element->data.addr = buffer_get_sysmem(buffer, context) - + (ptrdiff_t)element->data.addr; + element->data.addr += (ULONG_PTR)buffer_get_sysmem(buffer, context); + if ((UINT_PTR)element->data.addr < -state->load_base_vertex_index * element->stride) + FIXME("System memory vertex data load offset is negative!\n"); + } + else + { + buffer_internal_preload(buffer, context, state); + buffer_get_memory(buffer, context, &data); + element->data.buffer_object = data.buffer_object; + element->data.addr += (ULONG_PTR)data.addr; } - if (!buffer->buffer_object) + if (!element->data.buffer_object) stream_info->all_vbo = 0; if (buffer->query) context->buffer_queries[context->num_buffer_queries++] = buffer->query; - } -} - -/* Context activation is done by the caller. */ -static void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state) -{ - const struct wined3d_gl_info *gl_info = context->gl_info; - const struct wined3d_d3d_info *d3d_info = context->d3d_info; - struct wined3d_stream_info *stream_info = &context->stream_info; - DWORD prev_all_vbo = stream_info->all_vbo; - TRACE("============================= Vertex Declaration =============================\n"); - context_stream_info_from_declaration(context, state, stream_info); + TRACE("Load array %u {%#x:%p}.\n", i, element->data.buffer_object, element->data.addr); + } if (use_vs(state)) { @@ -2949,7 +2953,8 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de const struct wined3d_state *state = &device->state; const struct StateEntry *state_table = context->state_table; const struct wined3d_fb_state *fb = state->fb; - unsigned int i; + unsigned int i, j; + WORD map; if (!context_validate_rt_config(context->gl_info->limits.buffers, fb->render_targets, fb->depth_stencil)) @@ -2966,7 +2971,17 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de context_update_tex_unit_map(context, state); context_preload_textures(context, state); if (isStateDirty(context, STATE_VDECL) || isStateDirty(context, STATE_STREAMSRC)) + { context_update_stream_info(context, state); + } + else + { + for (i = 0, map = context->stream_info.use_map; map; map >>= 1, ++i) + { + if (map & 1) + buffer_mark_used(state->streams[context->stream_info.elements[i].stream_idx].buffer); + } + } if (state->index_buffer) { if (context->stream_info.all_vbo) @@ -2975,6 +2990,15 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de buffer_get_sysmem(state->index_buffer, context); } + for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) + { + for (j = 0; j < WINED3D_MAX_CBS; ++j) + { + if (state->cb[i][j]) + buffer_internal_preload(state->cb[i][j], context, state); + } + } + for (i = 0; i < context->numDirtyEntries; ++i) { DWORD rep = context->dirtyArray[i]; @@ -3011,7 +3035,7 @@ static void context_setup_target(struct wined3d_context *context, struct wined3d { BOOL old_render_offscreen = context->render_offscreen, render_offscreen; - render_offscreen = surface_is_offscreen(target); + render_offscreen = wined3d_resource_is_offscreen(&target->container->resource); if (context->current_rt == target && render_offscreen == old_render_offscreen) return; /* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers @@ -3083,9 +3107,9 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str { struct wined3d_swapchain *swapchain = device->swapchains[0]; if (swapchain->back_buffers) - target = swapchain->back_buffers[0]; + target = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)); else - target = swapchain->front_buffer; + target = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)); } } @@ -3093,11 +3117,11 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str { context = current_context; } - else if (target->swapchain) + else if (target->container->swapchain) { TRACE("Rendering onscreen.\n"); - context = swapchain_get_context(target->swapchain); + context = swapchain_get_context(target->container->swapchain); } else { diff --git a/reactos/dll/directx/wine/wined3d/cs.c b/reactos/dll/directx/wine/wined3d/cs.c index f85cf982b1c..08dbbed7f5d 100644 --- a/reactos/dll/directx/wine/wined3d/cs.c +++ b/reactos/dll/directx/wine/wined3d/cs.c @@ -27,10 +27,11 @@ enum wined3d_cs_op WINED3D_CS_OP_PRESENT, WINED3D_CS_OP_CLEAR, WINED3D_CS_OP_DRAW, + WINED3D_CS_OP_SET_PREDICATION, WINED3D_CS_OP_SET_VIEWPORT, WINED3D_CS_OP_SET_SCISSOR_RECT, - WINED3D_CS_OP_SET_RENDER_TARGET, - WINED3D_CS_OP_SET_DEPTH_STENCIL, + WINED3D_CS_OP_SET_RENDERTARGET_VIEW, + WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW, WINED3D_CS_OP_SET_VERTEX_DECLARATION, WINED3D_CS_OP_SET_STREAM_SOURCE, WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ, @@ -38,6 +39,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_CONSTANT_BUFFER, WINED3D_CS_OP_SET_TEXTURE, + WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW, WINED3D_CS_OP_SET_SAMPLER, WINED3D_CS_OP_SET_SHADER, WINED3D_CS_OP_SET_RENDER_STATE, @@ -81,6 +83,13 @@ struct wined3d_cs_draw BOOL indexed; }; +struct wined3d_cs_set_predication +{ + enum wined3d_cs_op opcode; + struct wined3d_query *predicate; + BOOL value; +}; + struct wined3d_cs_set_viewport { enum wined3d_cs_op opcode; @@ -93,17 +102,17 @@ struct wined3d_cs_set_scissor_rect const RECT *rect; }; -struct wined3d_cs_set_render_target +struct wined3d_cs_set_rendertarget_view { enum wined3d_cs_op opcode; - UINT render_target_idx; - struct wined3d_surface *render_target; + unsigned int view_idx; + struct wined3d_rendertarget_view *view; }; -struct wined3d_cs_set_depth_stencil +struct wined3d_cs_set_depth_stencil_view { enum wined3d_cs_op opcode; - struct wined3d_surface *depth_stencil; + struct wined3d_rendertarget_view *view; }; struct wined3d_cs_set_vertex_declaration @@ -159,6 +168,14 @@ struct wined3d_cs_set_texture struct wined3d_texture *texture; }; +struct wined3d_cs_set_shader_resource_view +{ + enum wined3d_cs_op opcode; + enum wined3d_shader_type type; + UINT view_idx; + struct wined3d_shader_resource_view *view; +}; + struct wined3d_cs_set_sampler { enum wined3d_cs_op opcode; @@ -306,6 +323,26 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, UINT start_idx, UINT index_coun cs->ops->submit(cs); } +static void wined3d_cs_exec_set_predication(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_predication *op = data; + + cs->state.predicate = op->predicate; + cs->state.predicate_value = op->value; +} + +void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query *predicate, BOOL value) +{ + struct wined3d_cs_set_predication *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_PREDICATION; + op->predicate = predicate; + op->value = value; + + cs->ops->submit(cs); +} + static void wined3d_cs_exec_set_viewport(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_viewport *op = data; @@ -344,41 +381,42 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) cs->ops->submit(cs); } -static void wined3d_cs_exec_set_render_target(struct wined3d_cs *cs, const void *data) +static void wined3d_cs_exec_set_rendertarget_view(struct wined3d_cs *cs, const void *data) { - const struct wined3d_cs_set_render_target *op = data; + const struct wined3d_cs_set_rendertarget_view *op = data; - cs->state.fb->render_targets[op->render_target_idx] = op->render_target; + cs->state.fb->render_targets[op->view_idx] = op->view; device_invalidate_state(cs->device, STATE_FRAMEBUFFER); } -void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target_idx, - struct wined3d_surface *render_target) +void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx, + struct wined3d_rendertarget_view *view) { - struct wined3d_cs_set_render_target *op; + struct wined3d_cs_set_rendertarget_view *op; op = cs->ops->require_space(cs, sizeof(*op)); - op->opcode = WINED3D_CS_OP_SET_RENDER_TARGET; - op->render_target_idx = render_target_idx; - op->render_target = render_target; + op->opcode = WINED3D_CS_OP_SET_RENDERTARGET_VIEW; + op->view_idx = view_idx; + op->view = view; cs->ops->submit(cs); } -static void wined3d_cs_exec_set_depth_stencil(struct wined3d_cs *cs, const void *data) +static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const void *data) { - const struct wined3d_cs_set_depth_stencil *op = data; + const struct wined3d_cs_set_depth_stencil_view *op = data; struct wined3d_device *device = cs->device; - struct wined3d_surface *prev; + struct wined3d_rendertarget_view *prev; if ((prev = cs->state.fb->depth_stencil)) { - if (device->swapchains[0]->desc.flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL - || prev->flags & SFLAG_DISCARD) + struct wined3d_surface *prev_surface = wined3d_rendertarget_view_get_surface(prev); + + if (prev_surface && (device->swapchains[0]->desc.flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL + || prev_surface->flags & SFLAG_DISCARD)) { - surface_modify_ds_location(prev, WINED3D_LOCATION_DISCARDED, - prev->resource.width, prev->resource.height); - if (prev == device->onscreen_depth_stencil) + surface_modify_ds_location(prev_surface, WINED3D_LOCATION_DISCARDED, prev->width, prev->height); + if (prev_surface == device->onscreen_depth_stencil) { wined3d_surface_decref(device->onscreen_depth_stencil); device->onscreen_depth_stencil = NULL; @@ -386,9 +424,9 @@ static void wined3d_cs_exec_set_depth_stencil(struct wined3d_cs *cs, const void } } - cs->fb.depth_stencil = op->depth_stencil; + cs->fb.depth_stencil = op->view; - if (!prev != !op->depth_stencil) + if (!prev != !op->view) { /* Swapping NULL / non NULL depth stencil affects the depth and tests */ device_invalidate_state(device, STATE_RENDER(WINED3D_RS_ZENABLE)); @@ -396,7 +434,7 @@ static void wined3d_cs_exec_set_depth_stencil(struct wined3d_cs *cs, const void device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK)); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); } - else if (prev && prev->resource.format->depth_size != op->depth_stencil->resource.format->depth_size) + else if (prev && prev->format->depth_size != op->view->format->depth_size) { device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); } @@ -404,13 +442,13 @@ static void wined3d_cs_exec_set_depth_stencil(struct wined3d_cs *cs, const void device_invalidate_state(device, STATE_FRAMEBUFFER); } -void wined3d_cs_emit_set_depth_stencil(struct wined3d_cs *cs, struct wined3d_surface *depth_stencil) +void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3d_rendertarget_view *view) { - struct wined3d_cs_set_depth_stencil *op; + struct wined3d_cs_set_depth_stencil_view *op; op = cs->ops->require_space(cs, sizeof(*op)); - op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL; - op->depth_stencil = depth_stencil; + op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW; + op->view = view; cs->ops->submit(cs); } @@ -567,6 +605,8 @@ static void wined3d_cs_exec_set_constant_buffer(struct wined3d_cs *cs, const voi InterlockedIncrement(&op->buffer->resource.bind_count); if (prev) InterlockedDecrement(&prev->resource.bind_count); + + device_invalidate_state(cs->device, STATE_CONSTANT_BUFFER(op->type)); } void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type, @@ -652,6 +692,27 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined cs->ops->submit(cs); } +static void wined3d_cs_exec_set_shader_resource_view(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_shader_resource_view *op = data; + + cs->state.shader_resource_view[op->type][op->view_idx] = op->view; +} + +void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type, + UINT view_idx, struct wined3d_shader_resource_view *view) +{ + struct wined3d_cs_set_shader_resource_view *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW; + op->type = type; + op->view_idx = view_idx; + op->view = view; + + cs->ops->submit(cs); +} + static void wined3d_cs_exec_set_sampler(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_sampler *op = data; @@ -842,29 +903,31 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = { - /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, - /* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear, - /* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw, - /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, - /* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect, - /* WINED3D_CS_OP_SET_RENDER_TARGET */ wined3d_cs_exec_set_render_target, - /* WINED3D_CS_OP_SET_DEPTH_STENCIL */ wined3d_cs_exec_set_depth_stencil, - /* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration, - /* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source, - /* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq, - /* WINED3D_CS_OP_SET_STREAM_OUTPUT */ wined3d_cs_exec_set_stream_output, - /* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer, - /* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer, - /* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture, - /* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler, - /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, - /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, - /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, - /* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state, - /* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform, - /* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane, - /* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material, - /* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state, + /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, + /* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear, + /* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw, + /* WINED3D_CS_OP_SET_PREDICATION */ wined3d_cs_exec_set_predication, + /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, + /* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect, + /* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view, + /* WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW */ wined3d_cs_exec_set_depth_stencil_view, + /* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration, + /* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source, + /* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq, + /* WINED3D_CS_OP_SET_STREAM_OUTPUT */ wined3d_cs_exec_set_stream_output, + /* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer, + /* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer, + /* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture, + /* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW */ wined3d_cs_exec_set_shader_resource_view, + /* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler, + /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, + /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, + /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, + /* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state, + /* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform, + /* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane, + /* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material, + /* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state, }; static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) diff --git a/reactos/dll/directx/wine/wined3d/device.c b/reactos/dll/directx/wine/wined3d/device.c index 37d9acb24da..5513a0d5e27 100644 --- a/reactos/dll/directx/wine/wined3d/device.c +++ b/reactos/dll/directx/wine/wined3d/device.c @@ -82,7 +82,8 @@ GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) default: FIXME("Unhandled primitive type %s\n", debug_d3dprimitivetype(primitive_type)); - return GL_NONE; + case WINED3D_PT_UNDEFINED: + return ~0u; } } @@ -122,6 +123,7 @@ static enum wined3d_primitive_type d3d_primitive_type_from_gl(GLenum primitive_t default: FIXME("Unhandled primitive type %s\n", debug_d3dprimitivetype(primitive_type)); + case ~0u: return WINED3D_PT_UNDEFINED; } } @@ -278,8 +280,10 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) { + struct wined3d_surface *target = rt_count ? wined3d_rendertarget_view_get_surface(fb->render_targets[0]) : NULL; + struct wined3d_surface *depth_stencil = fb->depth_stencil + ? wined3d_rendertarget_view_get_surface(fb->depth_stencil) : NULL; const RECT *clear_rect = (rect_count > 0 && rects) ? (const RECT *)rects : NULL; - struct wined3d_surface *target = rt_count ? fb->render_targets[0] : NULL; const struct wined3d_gl_info *gl_info; UINT drawable_width, drawable_height; struct wined3d_context *context; @@ -300,9 +304,9 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c { for (i = 0; i < rt_count; ++i) { - struct wined3d_surface *rt = fb->render_targets[i]; + struct wined3d_surface *rt = wined3d_rendertarget_view_get_surface(fb->render_targets[i]); if (rt) - surface_load_location(rt, rt->draw_binding); + surface_load_location(rt, rt->container->resource.draw_binding); } } @@ -318,22 +322,22 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c if (target) { render_offscreen = context->render_offscreen; - target->get_drawable_size(context, &drawable_width, &drawable_height); + surface_get_drawable_size(target, context, &drawable_width, &drawable_height); } else { render_offscreen = TRUE; - drawable_width = fb->depth_stencil->pow2Width; - drawable_height = fb->depth_stencil->pow2Height; + drawable_width = depth_stencil->pow2Width; + drawable_height = depth_stencil->pow2Height; } if (flags & WINED3DCLEAR_ZBUFFER) { - DWORD location = render_offscreen ? fb->depth_stencil->draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = render_offscreen ? fb->depth_stencil->resource->draw_binding : WINED3D_LOCATION_DRAWABLE; - if (!render_offscreen && fb->depth_stencil != device->onscreen_depth_stencil) - device_switch_onscreen_ds(device, context, fb->depth_stencil); - prepare_ds_clear(fb->depth_stencil, context, location, + if (!render_offscreen && depth_stencil != device->onscreen_depth_stencil) + device_switch_onscreen_ds(device, context, depth_stencil); + prepare_ds_clear(depth_stencil, context, location, draw_rect, rect_count, clear_rect, &ds_rect); } @@ -361,9 +365,9 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c if (flags & WINED3DCLEAR_ZBUFFER) { - DWORD location = render_offscreen ? fb->depth_stencil->draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = render_offscreen ? fb->depth_stencil->resource->draw_binding : WINED3D_LOCATION_DRAWABLE; - surface_modify_ds_location(fb->depth_stencil, location, ds_rect.right, ds_rect.bottom); + surface_modify_ds_location(depth_stencil, location, ds_rect.right, ds_rect.bottom); gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE); context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZWRITEENABLE)); @@ -376,12 +380,12 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c { for (i = 0; i < rt_count; ++i) { - struct wined3d_surface *rt = fb->render_targets[i]; + struct wined3d_surface *rt = wined3d_rendertarget_view_get_surface(fb->render_targets[i]); if (rt) { - surface_validate_location(rt, rt->draw_binding); - surface_invalidate_location(rt, ~rt->draw_binding); + surface_validate_location(rt, rt->container->resource.draw_binding); + surface_invalidate_location(rt, ~rt->container->resource.draw_binding); } } @@ -452,7 +456,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c } if (wined3d_settings.strict_draw_ordering || (flags & WINED3DCLEAR_TARGET - && target->swapchain && target->swapchain->front_buffer == target)) + && target->container->swapchain && target->container->swapchain->front_buffer == target->container)) gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); @@ -599,9 +603,11 @@ static void device_load_logo(struct wined3d_device *device, const char *filename } else { + const RECT rect = {0, 0, surface->resource.width, surface->resource.height}; const struct wined3d_color c = {1.0f, 1.0f, 1.0f, 1.0f}; + /* Fill the surface with a white color to show that wined3d is there */ - wined3d_device_color_fill(device, surface, NULL, &c); + surface_color_fill(surface, &rect, &c); } out: @@ -841,13 +847,13 @@ static void device_init_swapchain_state(struct wined3d_device *device, struct wi { for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i) { - wined3d_device_set_render_target(device, i, NULL, FALSE); + wined3d_device_set_rendertarget_view(device, i, NULL, FALSE); } - if (swapchain->back_buffers && swapchain->back_buffers[0]) - wined3d_device_set_render_target(device, 0, swapchain->back_buffers[0], TRUE); + if (device->back_buffer_view) + wined3d_device_set_rendertarget_view(device, 0, device->back_buffer_view, TRUE); } - wined3d_device_set_depth_stencil(device, ds_enable ? device->auto_depth_stencil : NULL); + wined3d_device_set_depth_stencil_view(device, ds_enable ? device->auto_depth_stencil_view : NULL); wined3d_device_set_render_state(device, WINED3D_RS_ZENABLE, ds_enable); } @@ -893,6 +899,14 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device, goto err_out; } + if (swapchain_desc->backbuffer_count && FAILED(hr = wined3d_rendertarget_view_create_from_surface( + surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)), + NULL, &wined3d_null_parent_ops, &device->back_buffer_view))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + goto err_out; + } + device->swapchain_count = 1; device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains)); if (!device->swapchains) @@ -903,7 +917,8 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device, device->swapchains[0] = swapchain; device_init_swapchain_state(device, swapchain); - context = context_acquire(device, swapchain->front_buffer); + context = context_acquire(device, + surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0))); create_dummy_textures(device, context); @@ -952,6 +967,8 @@ err_out: HeapFree(GetProcessHeap(), 0, device->fb.render_targets); HeapFree(GetProcessHeap(), 0, device->swapchains); device->swapchain_count = 0; + if (device->back_buffer_view) + wined3d_rendertarget_view_decref(device->back_buffer_view); if (swapchain) wined3d_swapchain_decref(swapchain); if (device->blit_priv) @@ -1053,25 +1070,31 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) if (device->fb.depth_stencil) { - surface = device->fb.depth_stencil; + struct wined3d_rendertarget_view *view = device->fb.depth_stencil; - TRACE("Releasing depth/stencil buffer %p.\n", surface); + TRACE("Releasing depth/stencil view %p.\n", view); device->fb.depth_stencil = NULL; - wined3d_surface_decref(surface); + wined3d_rendertarget_view_decref(view); } - if (device->auto_depth_stencil) + if (device->auto_depth_stencil_view) { - surface = device->auto_depth_stencil; - device->auto_depth_stencil = NULL; - if (wined3d_surface_decref(surface)) - FIXME("Something's still holding the auto depth stencil buffer (%p).\n", surface); + struct wined3d_rendertarget_view *view = device->auto_depth_stencil_view; + + device->auto_depth_stencil_view = NULL; + if (wined3d_rendertarget_view_decref(view)) + ERR("Something's still holding the auto depth/stencil view (%p).\n", view); } for (i = 0; i < gl_info->limits.buffers; ++i) { - wined3d_device_set_render_target(device, i, NULL, FALSE); + wined3d_device_set_rendertarget_view(device, i, NULL, FALSE); + } + if (device->back_buffer_view) + { + wined3d_rendertarget_view_decref(device->back_buffer_view); + device->back_buffer_view = NULL; } context_release(context); @@ -1130,11 +1153,12 @@ UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device { TRACE("device %p.\n", device); - TRACE("Emulating %d MB, returning %d MB left.\n", - device->adapter->TextureRam / (1024 * 1024), - (device->adapter->TextureRam - device->adapter->UsedTextureRam) / (1024 * 1024)); + TRACE("Emulating 0x%s bytes. 0x%s used, returning 0x%s left.\n", + wine_dbgstr_longlong(device->adapter->vram_bytes), + wine_dbgstr_longlong(device->adapter->vram_bytes_used), + wine_dbgstr_longlong(device->adapter->vram_bytes - device->adapter->vram_bytes_used)); - return device->adapter->TextureRam - device->adapter->UsedTextureRam; + return min(UINT_MAX, device->adapter->vram_bytes - device->adapter->vram_bytes_used); } void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT idx, @@ -1246,8 +1270,6 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi stream = &device->state.streams[stream_idx]; *buffer = stream->buffer; - if (*buffer) - wined3d_buffer_incref(*buffer); if (offset) *offset = stream->offset; *stride = stream->stride; @@ -1880,8 +1902,7 @@ static void resolve_depth_buffer(struct wined3d_state *state) || !(texture->resource.format->flags & WINED3DFMT_FLAG_DEPTH)) return; surface = surface_from_resource(texture->sub_resources[0]); - depth_stencil = state->fb->depth_stencil; - if (!depth_stencil) + if (!(depth_stencil = wined3d_rendertarget_view_get_surface(state->fb->depth_stencil))) return; wined3d_surface_blt(surface, NULL, depth_stencil, NULL, 0, NULL, WINED3D_TEXF_POINT); @@ -2111,6 +2132,52 @@ struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_devi return device->state.cb[WINED3D_SHADER_TYPE_VERTEX][idx]; } +static void wined3d_device_set_shader_resource_view(struct wined3d_device *device, + enum wined3d_shader_type type, UINT idx, struct wined3d_shader_resource_view *view) +{ + struct wined3d_shader_resource_view *prev; + + if (idx >= MAX_SHADER_RESOURCE_VIEWS) + { + WARN("Invalid view index %u.\n", idx); + return; + } + + prev = device->update_state->shader_resource_view[type][idx]; + if (view == prev) + return; + + if (view) + wined3d_shader_resource_view_incref(view); + device->update_state->shader_resource_view[type][idx] = view; + if (!device->recording) + wined3d_cs_emit_set_shader_resource_view(device->cs, type, idx, view); + if (prev) + wined3d_shader_resource_view_decref(prev); +} + +void CDECL wined3d_device_set_vs_resource_view(struct wined3d_device *device, + UINT idx, struct wined3d_shader_resource_view *view) +{ + TRACE("device %p, idx %u, view %p.\n", device, idx, view); + + wined3d_device_set_shader_resource_view(device, WINED3D_SHADER_TYPE_VERTEX, idx, view); +} + +struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view(const struct wined3d_device *device, + UINT idx) +{ + TRACE("device %p, idx %u.\n", device, idx); + + if (idx >= MAX_SHADER_RESOURCE_VIEWS) + { + WARN("Invalid view index %u.\n", idx); + return NULL; + } + + return device->state.shader_resource_view[WINED3D_SHADER_TYPE_VERTEX][idx]; +} + static void wined3d_device_set_sampler(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler) { @@ -2357,6 +2424,28 @@ struct wined3d_buffer * CDECL wined3d_device_get_ps_cb(const struct wined3d_devi return device->state.cb[WINED3D_SHADER_TYPE_PIXEL][idx]; } +void CDECL wined3d_device_set_ps_resource_view(struct wined3d_device *device, + UINT idx, struct wined3d_shader_resource_view *view) +{ + TRACE("device %p, idx %u, view %p.\n", device, idx, view); + + wined3d_device_set_shader_resource_view(device, WINED3D_SHADER_TYPE_PIXEL, idx, view); +} + +struct wined3d_shader_resource_view * CDECL wined3d_device_get_ps_resource_view(const struct wined3d_device *device, + UINT idx) +{ + TRACE("device %p, idx %u.\n", device, idx); + + if (idx >= MAX_SHADER_RESOURCE_VIEWS) + { + WARN("Invalid view index %u.\n", idx); + return NULL; + } + + return device->state.shader_resource_view[WINED3D_SHADER_TYPE_PIXEL][idx]; +} + void CDECL wined3d_device_set_ps_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler) { TRACE("device %p, idx %u, sampler %p.\n", device, idx, sampler); @@ -2564,6 +2653,28 @@ struct wined3d_buffer * CDECL wined3d_device_get_gs_cb(const struct wined3d_devi return device->state.cb[WINED3D_SHADER_TYPE_GEOMETRY][idx]; } +void CDECL wined3d_device_set_gs_resource_view(struct wined3d_device *device, + UINT idx, struct wined3d_shader_resource_view *view) +{ + TRACE("device %p, idx %u, view %p.\n", device, idx, view); + + wined3d_device_set_shader_resource_view(device, WINED3D_SHADER_TYPE_GEOMETRY, idx, view); +} + +struct wined3d_shader_resource_view * CDECL wined3d_device_get_gs_resource_view(const struct wined3d_device *device, + UINT idx) +{ + TRACE("device %p, idx %u.\n", device, idx); + + if (idx >= MAX_SHADER_RESOURCE_VIEWS) + { + WARN("Invalid view index %u.\n", idx); + return NULL; + } + + return device->state.shader_resource_view[WINED3D_SHADER_TYPE_GEOMETRY][idx]; +} + void CDECL wined3d_device_set_gs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler) { TRACE("device %p, idx %u, sampler %p.\n", device, idx, sampler); @@ -2862,6 +2973,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, struct wined3d_shader *vs; unsigned int i; HRESULT hr; + WORD map; TRACE("device %p, src_start_idx %u, dst_idx %u, vertex_count %u, " "dst_buffer %p, declaration %p, flags %#x, dst_fvf %#x.\n", @@ -2885,21 +2997,22 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, * VBOs in those buffers and fix up the stream_info structure. * * Also apply the start index. */ - for (i = 0; i < (sizeof(stream_info.elements) / sizeof(*stream_info.elements)); ++i) + for (i = 0, map = stream_info.use_map; map; map >>= 1, ++i) { struct wined3d_stream_info_element *e; + struct wined3d_buffer *buffer; - if (!(stream_info.use_map & (1 << i))) + if (!(map & 1)) continue; e = &stream_info.elements[i]; - if (e->data.buffer_object) + buffer = state->streams[e->stream_idx].buffer; + e->data.buffer_object = 0; + e->data.addr += (ULONG_PTR)buffer_get_sysmem(buffer, context); + if (buffer->buffer_object) { - struct wined3d_buffer *vb = state->streams[e->stream_idx].buffer; - e->data.buffer_object = 0; - e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, context)); - GL_EXTCALL(glDeleteBuffersARB(1, &vb->buffer_object)); - vb->buffer_object = 0; + GL_EXTCALL(glDeleteBuffersARB(1, &buffer->buffer_object)); + buffer->buffer_object = 0; } if (e->data.addr) e->data.addr += e->stride * src_start_idx; @@ -3189,7 +3302,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL)) { - struct wined3d_surface *ds = device->fb.depth_stencil; + struct wined3d_rendertarget_view *ds = device->fb.depth_stencil; if (!ds) { WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n"); @@ -3198,8 +3311,8 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou } else if (flags & WINED3DCLEAR_TARGET) { - if (ds->resource.width < device->fb.render_targets[0]->resource.width - || ds->resource.height < device->fb.render_targets[0]->resource.height) + if (ds->width < device->fb.render_targets[0]->width + || ds->height < device->fb.render_targets[0]->height) { WARN("Silently ignoring depth and target clear with mismatching sizes\n"); return WINED3D_OK; @@ -3212,6 +3325,35 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou return WINED3D_OK; } +void CDECL wined3d_device_set_predication(struct wined3d_device *device, + struct wined3d_query *predicate, BOOL value) +{ + struct wined3d_query *prev; + + TRACE("device %p, predicate %p, value %#x.\n", device, predicate, value); + + prev = device->update_state->predicate; + if (predicate) + { + FIXME("Predicated rendering not implemented.\n"); + wined3d_query_incref(predicate); + } + device->update_state->predicate = predicate; + device->update_state->predicate_value = value; + if (!device->recording) + wined3d_cs_emit_set_predication(device->cs, predicate, value); + if (prev) + wined3d_query_decref(prev); +} + +struct wined3d_query * CDECL wined3d_device_get_predication(struct wined3d_device *device, BOOL *value) +{ + TRACE("device %p, value %p.\n", device, value); + + *value = device->state.predicate_value; + return device->state.predicate; +} + void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device, enum wined3d_primitive_type primitive_type) { @@ -3517,11 +3659,10 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device if (state->render_states[WINED3D_RS_ZENABLE] || state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_STENCILENABLE]) { - struct wined3d_surface *ds = device->fb.depth_stencil; - struct wined3d_surface *target = device->fb.render_targets[0]; + struct wined3d_rendertarget_view *rt = device->fb.render_targets[0]; + struct wined3d_rendertarget_view *ds = device->fb.depth_stencil; - if(ds && target - && (ds->resource.width < target->resource.width || ds->resource.height < target->resource.height)) + if (ds && rt && (ds->width < rt->width || ds->height < rt->height)) { WARN("Depth stencil is smaller than the color buffer, returning D3DERR_CONFLICTINGRENDERSTATE\n"); return WINED3DERR_CONFLICTINGRENDERSTATE; @@ -3630,148 +3771,208 @@ HRESULT CDECL wined3d_device_update_surface(struct wined3d_device *device, return surface_upload_from_surface(dst_surface, dst_point, src_surface, src_rect); } -HRESULT CDECL wined3d_device_color_fill(struct wined3d_device *device, - struct wined3d_surface *surface, const RECT *rect, const struct wined3d_color *color) +void CDECL wined3d_device_copy_resource(struct wined3d_device *device, + struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource) { - RECT r; + struct wined3d_surface *dst_surface, *src_surface; + struct wined3d_texture *dst_texture, *src_texture; + unsigned int i, count; + HRESULT hr; - TRACE("device %p, surface %p, rect %s, color {%.8e, %.8e, %.8e, %.8e}.\n", - device, surface, wine_dbgstr_rect(rect), - color->r, color->g, color->b, color->a); + TRACE("device %p, dst_resource %p, src_resource %p.\n", device, dst_resource, src_resource); - if (surface->resource.pool != WINED3D_POOL_DEFAULT && surface->resource.pool != WINED3D_POOL_SYSTEM_MEM) + if (src_resource == dst_resource) { - WARN("Color-fill not allowed on %s surfaces.\n", debug_d3dpool(surface->resource.pool)); - return WINED3DERR_INVALIDCALL; + WARN("Source and destination are the same resource.\n"); + return; } - if (!rect) + if (src_resource->type != dst_resource->type) { - SetRect(&r, 0, 0, surface->resource.width, surface->resource.height); - rect = &r; + WARN("Resource types (%s / %s) don't match.\n", + debug_d3dresourcetype(dst_resource->type), + debug_d3dresourcetype(src_resource->type)); + return; + } + + if (src_resource->width != dst_resource->width + || src_resource->height != dst_resource->height + || src_resource->depth != dst_resource->depth) + { + WARN("Resource dimensions (%ux%ux%u / %ux%ux%u) don't match.\n", + dst_resource->width, dst_resource->height, dst_resource->depth, + src_resource->width, src_resource->height, src_resource->depth); + return; + } + + if (src_resource->format->id != dst_resource->format->id) + { + WARN("Resource formats (%s / %s) don't match.\n", + debug_d3dformat(dst_resource->format->id), + debug_d3dformat(src_resource->format->id)); + return; } - return surface_color_fill(surface, rect, color); + if (dst_resource->type != WINED3D_RTYPE_TEXTURE) + { + FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(dst_resource->type)); + return; + } + + dst_texture = wined3d_texture_from_resource(dst_resource); + src_texture = wined3d_texture_from_resource(src_resource); + + if (src_texture->layer_count != dst_texture->layer_count + || src_texture->level_count != dst_texture->level_count) + { + WARN("Subresource layouts (%ux%u / %ux%u) don't match.\n", + dst_texture->layer_count, dst_texture->level_count, + src_texture->layer_count, src_texture->level_count); + return; + } + + count = dst_texture->layer_count * dst_texture->level_count; + for (i = 0; i < count; ++i) + { + dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i)); + src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, i)); + + if (FAILED(hr = wined3d_surface_blt(dst_surface, NULL, src_surface, NULL, 0, NULL, WINED3D_TEXF_POINT))) + ERR("Failed to blit, subresource %u, hr %#x.\n", i, hr); + } } -void CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device, - struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color) +HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device, + struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color) { struct wined3d_resource *resource; - HRESULT hr; - RECT rect; + RECT r; + + TRACE("device %p, view %p, rect %s, color {%.8e, %.8e, %.8e, %.8e}.\n", + device, view, wine_dbgstr_rect(rect), color->r, color->g, color->b, color->a); - resource = rendertarget_view->resource; - if (resource->type != WINED3D_RTYPE_SURFACE) + resource = view->resource; + if (resource->type != WINED3D_RTYPE_TEXTURE && resource->type != WINED3D_RTYPE_CUBE_TEXTURE) { - FIXME("Only supported on surface resources\n"); - return; + FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); + return WINED3DERR_INVALIDCALL; + } + + if (view->depth > 1) + { + FIXME("Layered clears not implemented.\n"); + return WINED3DERR_INVALIDCALL; } - SetRect(&rect, 0, 0, resource->width, resource->height); - hr = surface_color_fill(surface_from_resource(resource), &rect, color); - if (FAILED(hr)) ERR("Color fill failed, hr %#x.\n", hr); + if (!rect) + { + SetRect(&r, 0, 0, view->width, view->height); + rect = &r; + } + + resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), view->sub_resource_idx); + + return surface_color_fill(surface_from_resource(resource), rect, color); } -struct wined3d_surface * CDECL wined3d_device_get_render_target(const struct wined3d_device *device, - UINT render_target_idx) +struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(const struct wined3d_device *device, + unsigned int view_idx) { - TRACE("device %p, render_target_idx %u.\n", device, render_target_idx); + TRACE("device %p, view_idx %u.\n", device, view_idx); - if (render_target_idx >= device->adapter->gl_info.limits.buffers) + if (view_idx >= device->adapter->gl_info.limits.buffers) { WARN("Only %u render targets are supported.\n", device->adapter->gl_info.limits.buffers); return NULL; } - return device->fb.render_targets[render_target_idx]; + return device->fb.render_targets[view_idx]; } -struct wined3d_surface * CDECL wined3d_device_get_depth_stencil(const struct wined3d_device *device) +struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(const struct wined3d_device *device) { TRACE("device %p.\n", device); return device->fb.depth_stencil; } -HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device, - UINT render_target_idx, struct wined3d_surface *render_target, BOOL set_viewport) +HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device, + unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport) { - struct wined3d_surface *prev; + struct wined3d_rendertarget_view *prev; - TRACE("device %p, render_target_idx %u, render_target %p, set_viewport %#x.\n", - device, render_target_idx, render_target, set_viewport); + TRACE("device %p, view_idx %u, view %p, set_viewport %#x.\n", + device, view_idx, view, set_viewport); - if (render_target_idx >= device->adapter->gl_info.limits.buffers) + if (view_idx >= device->adapter->gl_info.limits.buffers) { WARN("Only %u render targets are supported.\n", device->adapter->gl_info.limits.buffers); return WINED3DERR_INVALIDCALL; } - if (render_target && !(render_target->resource.usage & WINED3DUSAGE_RENDERTARGET)) + if (view && !(view->resource->usage & WINED3DUSAGE_RENDERTARGET)) { - WARN("Surface %p doesn't have render target usage.\n", render_target); + WARN("View resource %p doesn't have render target usage.\n", view->resource); return WINED3DERR_INVALIDCALL; } /* Set the viewport and scissor rectangles, if requested. Tests show that * stateblock recording is ignored, the change goes directly into the * primary stateblock. */ - if (!render_target_idx && set_viewport) + if (!view_idx && set_viewport) { struct wined3d_state *state = &device->state; state->viewport.x = 0; state->viewport.y = 0; - state->viewport.width = render_target->resource.width; - state->viewport.height = render_target->resource.height; + state->viewport.width = view->width; + state->viewport.height = view->height; state->viewport.min_z = 0.0f; state->viewport.max_z = 1.0f; wined3d_cs_emit_set_viewport(device->cs, &state->viewport); state->scissor_rect.top = 0; state->scissor_rect.left = 0; - state->scissor_rect.right = render_target->resource.width; - state->scissor_rect.bottom = render_target->resource.height; + state->scissor_rect.right = view->width; + state->scissor_rect.bottom = view->height; wined3d_cs_emit_set_scissor_rect(device->cs, &state->scissor_rect); } - prev = device->fb.render_targets[render_target_idx]; - if (render_target == prev) + prev = device->fb.render_targets[view_idx]; + if (view == prev) return WINED3D_OK; - if (render_target) - wined3d_surface_incref(render_target); - device->fb.render_targets[render_target_idx] = render_target; - wined3d_cs_emit_set_render_target(device->cs, render_target_idx, render_target); + if (view) + wined3d_rendertarget_view_incref(view); + device->fb.render_targets[view_idx] = view; + wined3d_cs_emit_set_rendertarget_view(device->cs, view_idx, view); /* Release after the assignment, to prevent device_resource_released() * from seeing the surface as still in use. */ if (prev) - wined3d_surface_decref(prev); + wined3d_rendertarget_view_decref(prev); return WINED3D_OK; } -void CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil) +void CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device, struct wined3d_rendertarget_view *view) { - struct wined3d_surface *prev = device->fb.depth_stencil; + struct wined3d_rendertarget_view *prev; - TRACE("device %p, depth_stencil %p, old depth_stencil %p.\n", - device, depth_stencil, prev); + TRACE("device %p, view %p.\n", device, view); - if (prev == depth_stencil) + prev = device->fb.depth_stencil; + if (prev == view) { TRACE("Trying to do a NOP SetRenderTarget operation.\n"); return; } - device->fb.depth_stencil = depth_stencil; - if (depth_stencil) - wined3d_surface_incref(depth_stencil); - wined3d_cs_emit_set_depth_stencil(device->cs, depth_stencil); + if ((device->fb.depth_stencil = view)) + wined3d_rendertarget_view_incref(view); + wined3d_cs_emit_set_depth_stencil_view(device->cs, view); if (prev) - wined3d_surface_decref(prev); + wined3d_rendertarget_view_decref(prev); } static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined3d_device *device, @@ -4085,7 +4286,9 @@ static HRESULT create_primary_opengl_context(struct wined3d_device *device, stru return E_OUTOFMEMORY; } - target = swapchain->back_buffers ? swapchain->back_buffers[0] : swapchain->front_buffer; + target = swapchain->back_buffers + ? surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)) + : surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)); if (!(context = context_create(swapchain, target, swapchain->ds_format))) { WARN("Failed to create context.\n"); @@ -4144,12 +4347,10 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, { for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i) { - wined3d_device_set_render_target(device, i, NULL, FALSE); + wined3d_device_set_rendertarget_view(device, i, NULL, FALSE); } - if (swapchain->back_buffers && swapchain->back_buffers[0]) - wined3d_device_set_render_target(device, 0, swapchain->back_buffers[0], FALSE); } - wined3d_device_set_depth_stencil(device, NULL); + wined3d_device_set_depth_stencil_view(device, NULL); if (device->onscreen_depth_stencil) { @@ -4216,35 +4417,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, wined3d_swapchain_set_window(swapchain, NULL); } - if (swapchain_desc->enable_auto_depth_stencil && !device->auto_depth_stencil) - { - struct wined3d_resource_desc surface_desc; - - TRACE("Creating the depth stencil buffer\n"); - - surface_desc.resource_type = WINED3D_RTYPE_SURFACE; - surface_desc.format = swapchain_desc->auto_depth_stencil_format; - surface_desc.multisample_type = swapchain_desc->multisample_type; - surface_desc.multisample_quality = swapchain_desc->multisample_quality; - surface_desc.usage = WINED3DUSAGE_DEPTHSTENCIL; - surface_desc.pool = WINED3D_POOL_DEFAULT; - surface_desc.width = swapchain_desc->backbuffer_width; - surface_desc.height = swapchain_desc->backbuffer_height; - surface_desc.depth = 1; - surface_desc.size = 0; - - if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, - device->device_parent, &surface_desc, &device->auto_depth_stencil))) - { - ERR("Failed to create the depth stencil buffer, hr %#x.\n", hr); - return WINED3DERR_INVALIDCALL; - } - } - - /* Reset the depth stencil */ - if (swapchain_desc->enable_auto_depth_stencil) - wined3d_device_set_depth_stencil(device, device->auto_depth_stencil); - if (mode) { DisplayModeChanged = TRUE; @@ -4317,25 +4489,75 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, { UINT i; - if (FAILED(hr = wined3d_surface_update_desc(swapchain->front_buffer, swapchain->desc.backbuffer_width, + if (FAILED(hr = wined3d_surface_update_desc(surface_from_resource( + wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)), swapchain->desc.backbuffer_width, swapchain->desc.backbuffer_height, swapchain->desc.backbuffer_format, swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0))) return hr; for (i = 0; i < swapchain->desc.backbuffer_count; ++i) { - if (FAILED(hr = wined3d_surface_update_desc(swapchain->back_buffers[i], swapchain->desc.backbuffer_width, + if (FAILED(hr = wined3d_surface_update_desc(surface_from_resource( + wined3d_texture_get_sub_resource(swapchain->back_buffers[i], 0)), swapchain->desc.backbuffer_width, swapchain->desc.backbuffer_height, swapchain->desc.backbuffer_format, swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0))) return hr; } - if (device->auto_depth_stencil) + } + + if (device->auto_depth_stencil_view) + { + wined3d_rendertarget_view_decref(device->auto_depth_stencil_view); + device->auto_depth_stencil_view = NULL; + } + if (swapchain->desc.enable_auto_depth_stencil) + { + struct wined3d_resource_desc surface_desc; + struct wined3d_surface *surface; + + TRACE("Creating the depth stencil buffer\n"); + + surface_desc.resource_type = WINED3D_RTYPE_SURFACE; + surface_desc.format = swapchain->desc.auto_depth_stencil_format; + surface_desc.multisample_type = swapchain->desc.multisample_type; + surface_desc.multisample_quality = swapchain->desc.multisample_quality; + surface_desc.usage = WINED3DUSAGE_DEPTHSTENCIL; + surface_desc.pool = WINED3D_POOL_DEFAULT; + surface_desc.width = swapchain->desc.backbuffer_width; + surface_desc.height = swapchain->desc.backbuffer_height; + surface_desc.depth = 1; + surface_desc.size = 0; + + if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, + device->device_parent, &surface_desc, &surface))) { - if (FAILED(hr = wined3d_surface_update_desc(device->auto_depth_stencil, swapchain->desc.backbuffer_width, - swapchain->desc.backbuffer_height, device->auto_depth_stencil->resource.format->id, - swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0))) - return hr; + ERR("Failed to create the auto depth/stencil surface, hr %#x.\n", hr); + return WINED3DERR_INVALIDCALL; } + + hr = wined3d_rendertarget_view_create_from_surface(surface, + NULL, &wined3d_null_parent_ops, &device->auto_depth_stencil_view); + wined3d_surface_decref(surface); + if (FAILED(hr)) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return hr; + } + + wined3d_device_set_depth_stencil_view(device, device->auto_depth_stencil_view); + } + + if (device->back_buffer_view) + { + wined3d_rendertarget_view_decref(device->back_buffer_view); + device->back_buffer_view = NULL; + } + if (swapchain->desc.backbuffer_count && FAILED(hr = wined3d_rendertarget_view_create_from_surface( + surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)), + NULL, &wined3d_null_parent_ops, &device->back_buffer_view))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return hr; } if (!swapchain_desc->windowed != !swapchain->desc.windowed @@ -4420,22 +4642,24 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, device_init_swapchain_state(device, swapchain); } - else + else if (device->back_buffer_view) { - struct wined3d_surface *rt = device->fb.render_targets[0]; + struct wined3d_rendertarget_view *view = device->back_buffer_view; struct wined3d_state *state = &device->state; + wined3d_device_set_rendertarget_view(device, 0, view, FALSE); + /* Note the min_z / max_z is not reset. */ state->viewport.x = 0; state->viewport.y = 0; - state->viewport.width = rt->resource.width; - state->viewport.height = rt->resource.height; + state->viewport.width = view->width; + state->viewport.height = view->height; wined3d_cs_emit_set_viewport(device->cs, &state->viewport); state->scissor_rect.top = 0; state->scissor_rect.left = 0; - state->scissor_rect.right = rt->resource.width; - state->scissor_rect.bottom = rt->resource.height; + state->scissor_rect.right = view->width; + state->scissor_rect.bottom = view->height; wined3d_cs_emit_set_scissor_rect(device->cs, &state->scissor_rect); } @@ -4526,14 +4750,14 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i) { - if (device->fb.render_targets[i] == surface) + if (wined3d_rendertarget_view_get_surface(device->fb.render_targets[i]) == surface) { ERR("Surface %p is still in use as render target %u.\n", surface, i); device->fb.render_targets[i] = NULL; } } - if (device->fb.depth_stencil == surface) + if (wined3d_rendertarget_view_get_surface(device->fb.depth_stencil) == surface) { ERR("Surface %p is still in use as depth/stencil buffer.\n", surface); device->fb.depth_stencil = NULL; @@ -4725,23 +4949,6 @@ void device_invalidate_state(const struct wined3d_device *device, DWORD state) } } -void get_drawable_size_fbo(const struct wined3d_context *context, UINT *width, UINT *height) -{ - /* The drawable size of a fbo target is the opengl texture size, which is the power of two size. */ - *width = context->current_rt->pow2Width; - *height = context->current_rt->pow2Height; -} - -void get_drawable_size_backbuffer(const struct wined3d_context *context, UINT *width, UINT *height) -{ - const struct wined3d_swapchain *swapchain = context->swapchain; - /* The drawable size of a backbuffer / aux buffer offscreen target is the size of the - * current context's drawable, which is the size of the back buffer of the swapchain - * the active context belongs to. */ - *width = swapchain->desc.backbuffer_width; - *height = swapchain->desc.backbuffer_height; -} - LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode, UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) { @@ -4767,6 +4974,10 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL { device->device_parent->ops->mode_changed(device->device_parent); } + else if (message == WM_ACTIVATEAPP) + { + device->device_parent->ops->activate(device->device_parent, wparam); + } if (unicode) return CallWindowProcW(proc, window, message, wparam, lparam); diff --git a/reactos/dll/directx/wine/wined3d/directx.c b/reactos/dll/directx/wine/wined3d/directx.c index 4ecbf6e7de3..4927a0e600d 100644 --- a/reactos/dll/directx/wine/wined3d/directx.c +++ b/reactos/dll/directx/wine/wined3d/directx.c @@ -29,10 +29,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); +WINE_DECLARE_DEBUG_CHANNEL(winediag); #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024) #define DEFAULT_REFRESH_RATE 0 +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) +#endif + /* The driver names reflect the lowest GPU supported * by a certain driver, so DRIVER_AMD_R300 supports * R3xx, R4xx and R5xx GPUs. */ @@ -71,6 +76,19 @@ enum wined3d_gl_vendor GL_VENDOR_NVIDIA, }; +enum wined3d_d3d_level +{ + WINED3D_D3D_LEVEL_5, + WINED3D_D3D_LEVEL_6, + WINED3D_D3D_LEVEL_7, + WINED3D_D3D_LEVEL_8, + WINED3D_D3D_LEVEL_9_SM2, + WINED3D_D3D_LEVEL_9_SM3, + WINED3D_D3D_LEVEL_10, + WINED3D_D3D_LEVEL_11, + WINED3D_D3D_LEVEL_COUNT +}; + /* The d3d device ID */ static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } }; @@ -138,6 +156,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE }, {"GL_ARB_texture_rg", ARB_TEXTURE_RG }, {"GL_ARB_timer_query", ARB_TIMER_QUERY }, + {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT }, {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA }, {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND }, {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT }, @@ -389,11 +408,13 @@ fail: } /* Adjust the amount of used texture memory */ -unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount) +UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) { - adapter->UsedTextureRam += amount; - TRACE("Adjusted adapter memory by %d to %d.\n", amount, adapter->UsedTextureRam); - return adapter->UsedTextureRam; + adapter->vram_bytes_used += amount; + TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n", + wine_dbgstr_longlong(amount), + wine_dbgstr_longlong(adapter->vram_bytes_used)); + return adapter->vram_bytes_used; } static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) @@ -436,7 +457,7 @@ static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info) { GLuint prog; BOOL ret = FALSE; - const char *testcode = + static const char testcode[] = "!!ARBvp1.0\n" "PARAM C[66] = { program.env[0..65] };\n" "ADDRESS A0;" @@ -650,7 +671,7 @@ static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const ch GLuint prog; BOOL ret = FALSE; GLint pos; - const char *testcode = + static const char testcode[] = "!!ARBvp1.0\n" "OPTION NV_vertex_program2;\n" "MOV result.clip[0], 0.0;\n" @@ -787,7 +808,7 @@ static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, const ch float color[4] = {0.0f, 1.0f, 0.0f, 0.0f}; GLuint prog; GLint err_pos; - static const char *program_code = + static const char program_code[] = "!!ARBfp1.0\n" "OPTION ARB_fog_linear;\n" "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n" @@ -1267,6 +1288,8 @@ static const struct gpu_description gpu_description_table[] = {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX765M, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_GEFORCE6, 2048}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE6, 3072}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE6, 2048}, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_GEFORCE6, 3072}, + {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780TI, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_GEFORCE6, 3072}, /* AMD cards */ {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 }, @@ -1299,9 +1322,16 @@ static const struct gpu_description gpu_description_table[] = {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024}, {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024}, {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7660D, "AMD Radeon HD 7660D", DRIVER_AMD_R600, 2048}, {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024}, {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048}, {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8600M, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600, 1024}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8670, "AMD Radeon HD 8670", DRIVER_AMD_R600, 2048}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8770, "AMD Radeon HD 8770", DRIVER_AMD_R600, 2048}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_R3, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600, 2048}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_R7, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600, 2048}, + {HW_VENDOR_AMD, CARD_AMD_RADEON_R9, "AMD Radeon R9 290", DRIVER_AMD_R600, 4096}, /* VMware */ {HW_VENDOR_VMWARE, CARD_VMWARE_SVGA3D, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE, 1024}, @@ -1364,33 +1394,56 @@ static const struct driver_version_information *get_driver_version_info(enum win return NULL; } +static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor vendor, + enum wined3d_pci_device device) +{ + unsigned int i; + + for (i = 0; i < (sizeof(gpu_description_table) / sizeof(*gpu_description_table)); ++i) + { + if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card) + return &gpu_description_table[i]; + } + + return NULL; +} + static void init_driver_info(struct wined3d_driver_info *driver_info, enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) { OSVERSIONINFOW os_version; WORD driver_os_version; - unsigned int i; - enum wined3d_display_driver driver = DRIVER_UNKNOWN; + enum wined3d_display_driver driver; enum wined3d_driver_model driver_model; const struct driver_version_information *version_info; + const struct gpu_description *gpu_desc; - if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE) + if (driver_info->vendor != PCI_VENDOR_NONE || driver_info->device != PCI_DEVICE_NONE) { - TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings.pci_vendor_id); - vendor = wined3d_settings.pci_vendor_id; - } - driver_info->vendor = vendor; + static unsigned int once; - if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE) - { - TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings.pci_device_id); - device = wined3d_settings.pci_device_id; + TRACE("GPU override %04x:%04x.\n", wined3d_settings.pci_vendor_id, wined3d_settings.pci_device_id); + + driver_info->vendor = wined3d_settings.pci_vendor_id; + if (driver_info->vendor == PCI_VENDOR_NONE) + driver_info->vendor = vendor; + + driver_info->device = wined3d_settings.pci_device_id; + if (driver_info->device == PCI_DEVICE_NONE) + driver_info->device = device; + + if (get_gpu_description(driver_info->vendor, driver_info->device)) + { + vendor = driver_info->vendor; + device = driver_info->device; + } + else if (!once++) + ERR_(winediag)("Invalid GPU override %04x:%04x specified, ignoring.\n", + driver_info->vendor, driver_info->device); } - driver_info->device = device; - /* Set a default amount of video memory (64 MB). In general this code isn't used unless the user - * overrides the pci ids to a card which is not in our database. */ - driver_info->vidmem = WINE_DEFAULT_VIDMEM; + driver_info->vendor = vendor; + driver_info->device = device; memset(&os_version, 0, sizeof(os_version)); os_version.dwOSVersionInfoSize = sizeof(os_version); @@ -1450,25 +1503,25 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, } } - /* When we reach this stage we always have a vendor or device id (it can be a default one). - * This means that unless the ids are overridden, we will always find a GPU description. */ - for (i = 0; i < (sizeof(gpu_description_table) / sizeof(gpu_description_table[0])); i++) + if ((gpu_desc = get_gpu_description(driver_info->vendor, driver_info->device))) { - if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card) - { - TRACE("Found card %04x:%04x in driver DB.\n", vendor, device); - - driver_info->description = gpu_description_table[i].description; - driver_info->vidmem = gpu_description_table[i].vidmem * 1024*1024; - driver = gpu_description_table[i].driver; - break; - } + driver_info->description = gpu_desc->description; + driver_info->vram_bytes = (UINT64)gpu_desc->vidmem * 1024 * 1024; + driver = gpu_desc->driver; + } + else + { + ERR("Card %04x:%04x not found in driver DB.\n", vendor, device); + driver_info->description = "Direct3D HAL"; + driver_info->vram_bytes = WINE_DEFAULT_VIDMEM; + driver = DRIVER_UNKNOWN; } if (wined3d_settings.emulated_textureram) { - TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings.emulated_textureram); - driver_info->vidmem = wined3d_settings.emulated_textureram; + TRACE("Overriding amount of video memory with 0x%s bytes.\n", + wine_dbgstr_longlong(wined3d_settings.emulated_textureram)); + driver_info->vram_bytes = wined3d_settings.emulated_textureram; } /* Try to obtain driver version information for the current Windows version. This fails in @@ -1484,8 +1537,8 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id) * This could be an indication that our database is not up to date, so this should be fixed. */ - version_info = get_driver_version_info(driver, driver_model); - if (version_info) + if ((version_info = get_driver_version_info(driver, driver_model)) + || (version_info = get_driver_version_info(driver, DRIVER_MODEL_NT5X))) { driver_info->name = version_info->driver_name; driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version); @@ -1493,23 +1546,11 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, } else { - version_info = get_driver_version_info(driver, DRIVER_MODEL_NT5X); - if (version_info) - { - driver_info->name = version_info->driver_name; - driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version); - driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build); - } - else - { - driver_info->description = "Direct3D HAL"; - driver_info->name = "Display"; - driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15); - driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */ - - FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n", - vendor, device, driver_model); - } + ERR("No driver version info found for device %04x:%04x, driver model %#x.\n", + vendor, device, driver_model); + driver_info->name = "Display"; + driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15); + driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */ } TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n", @@ -1636,703 +1677,561 @@ static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_s return HW_VENDOR_NVIDIA; } -static UINT d3d_level_from_gl_info(const struct wined3d_gl_info *gl_info) -{ - UINT level = 0; - - if (gl_info->supported[ARB_MULTITEXTURE]) - level = 6; - if (gl_info->supported[ARB_TEXTURE_COMPRESSION] - && gl_info->supported[ARB_TEXTURE_CUBE_MAP] - && gl_info->supported[ARB_TEXTURE_ENV_DOT3]) - level = 7; - if (level == 7 && gl_info->supported[ARB_MULTISAMPLE] - && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP]) - level = 8; - if (level == 8 && gl_info->supported[ARB_FRAGMENT_PROGRAM] - && gl_info->supported[ARB_VERTEX_SHADER]) - level = 9; - if (level == 9 && gl_info->supported[EXT_GPU_SHADER4]) - level = 10; - - return level; -} +static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info); +static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info, const struct wined3d_shader_backend_ops *shader_backend_ops); -static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info, - const char *gl_renderer) +static enum wined3d_d3d_level d3d_level_from_gl_info(const struct wined3d_gl_info *gl_info) { - UINT d3d_level = d3d_level_from_gl_info(gl_info); - unsigned int i; - - if (d3d_level >= 10) - { - static const struct - { - const char *renderer; - enum wined3d_pci_device id; - } - cards[] = - { - {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */ - {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */ - {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M}, /* Geforce 700 - midend high mobile */ - {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */ - {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */ - {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */ - {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */ - {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */ - {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */ - {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */ - {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M}, /* Geforce 600 - midend high mobile */ - {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */ - {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */ - {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */ - {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */ - {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */ - {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */ - {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */ - {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */ - {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */ - {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */ - {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */ - {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */ - {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */ - {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */ - {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */ - {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */ - {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */ - {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */ - {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */ - {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */ - {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */ - {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */ - {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */ - {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */ - {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */ - {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */ - {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */ - {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */ - {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */ - {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */ - {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */ - {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */ - {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */ - {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */ - {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */ - {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */ - {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */ - {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */ - {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */ - {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */ - {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */ - {"Geforce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ - {"Geforce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ - {"Geforce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ - {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ - {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */ - {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */ - {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */ - {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */ - {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */ - {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */ - {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */ - {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */ - {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */ - {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */ - {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */ - {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */ - {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */ - {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */ - {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */ - {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */ - {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */ - {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */ - {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */ - {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */ - {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */ - {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */ - {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */ - {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */ - {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */ - }; - - for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i) - { - if (strstr(gl_renderer, cards[i].renderer)) - return cards[i].id; - } - return PCI_DEVICE_NONE; - } + struct shader_caps shader_caps; + struct fragment_caps fragment_caps; + const struct wined3d_shader_backend_ops *shader_backend; + const struct fragment_pipeline *fragment_pipeline; - /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more - * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx. - */ - if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3]) - { - static const struct - { - const char *renderer; - enum wined3d_pci_device id; - } - cards[] = - { - {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ - {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ - {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ - {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ - {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ - {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */ - {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */ - {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */ - {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */ - {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */ - {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */ - {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */ - {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */ - }; - - for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i) - { - if (strstr(gl_renderer, cards[i].renderer)) - return cards[i].id; - } - return PCI_DEVICE_NONE; - } + shader_backend = select_shader_backend(gl_info); + shader_backend->shader_get_caps(gl_info, &shader_caps); - if (d3d_level >= 9) + if (shader_caps.vs_version >= 5) + return WINED3D_D3D_LEVEL_11; + if (shader_caps.vs_version == 4) { - /* GeforceFX - highend */ - if (strstr(gl_renderer, "5800") - || strstr(gl_renderer, "5900") - || strstr(gl_renderer, "5950") - || strstr(gl_renderer, "Quadro FX")) - { - return CARD_NVIDIA_GEFORCEFX_5800; - } - - /* GeforceFX - midend */ - if (strstr(gl_renderer, "5600") - || strstr(gl_renderer, "5650") - || strstr(gl_renderer, "5700") - || strstr(gl_renderer, "5750")) - { - return CARD_NVIDIA_GEFORCEFX_5600; - } - - /* GeforceFX - lowend */ - return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */ + /* No backed supports SM 5 at the moment */ + if (gl_info->glsl_version >= MAKEDWORD_VERSION(4, 00)) + return WINED3D_D3D_LEVEL_11; + return WINED3D_D3D_LEVEL_10; } - - if (d3d_level >= 8) + if (shader_caps.vs_version == 3) { - if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4")) - { - return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */ - } - - return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */ + /* Wine can not use SM 4 on mesa drivers as the necessary functionality is not exposed + * on compatibility contexts */ + if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30)) + return WINED3D_D3D_LEVEL_10; + return WINED3D_D3D_LEVEL_9_SM3; } + if (shader_caps.vs_version == 2) + return WINED3D_D3D_LEVEL_9_SM2; + if (shader_caps.vs_version == 1) + return WINED3D_D3D_LEVEL_8; - if (d3d_level >= 7) - { - if (strstr(gl_renderer, "GeForce4 MX")) - { - return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */ - } - - if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR")) - { - return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */ - } - - if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2")) - { - return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */ - } - - return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */ - } + fragment_pipeline = select_fragment_implementation(gl_info, shader_backend); + fragment_pipeline->get_caps(gl_info, &fragment_caps); - if (strstr(gl_renderer, "TNT2")) - { - return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */ - } + if (fragment_caps.TextureOpCaps & WINED3DTEXOPCAPS_DOTPRODUCT3) + return WINED3D_D3D_LEVEL_7; + if (fragment_caps.MaxSimultaneousTextures > 1) + return WINED3D_D3D_LEVEL_6; - return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */ + return WINED3D_D3D_LEVEL_5; } -static enum wined3d_pci_device select_card_amd_binary(const struct wined3d_gl_info *gl_info, - const char *gl_renderer) +static const struct wined3d_renderer_table { - UINT d3d_level = d3d_level_from_gl_info(gl_info); - - /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx - * - * Beware: renderer string do not match exact card model, - * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ - if (d3d_level >= 10) - { - unsigned int i; - - static const struct - { - const char *renderer; - enum wined3d_pci_device id; - } - cards[] = - { - /* Southern Islands */ - {"HD 7900", CARD_AMD_RADEON_HD7900}, - {"HD 7800", CARD_AMD_RADEON_HD7800}, - {"HD 7700", CARD_AMD_RADEON_HD7700}, - /* Northern Islands */ - {"HD 6970", CARD_AMD_RADEON_HD6900}, - {"HD 6900", CARD_AMD_RADEON_HD6900}, - {"HD 6800", CARD_AMD_RADEON_HD6800}, - {"HD 6770M",CARD_AMD_RADEON_HD6600M}, - {"HD 6750M",CARD_AMD_RADEON_HD6600M}, - {"HD 6700", CARD_AMD_RADEON_HD6700}, - {"HD 6670", CARD_AMD_RADEON_HD6600}, - {"HD 6630M",CARD_AMD_RADEON_HD6600M}, - {"HD 6600M",CARD_AMD_RADEON_HD6600M}, - {"HD 6600", CARD_AMD_RADEON_HD6600}, - {"HD 6570", CARD_AMD_RADEON_HD6600}, - {"HD 6500M",CARD_AMD_RADEON_HD6600M}, - {"HD 6500", CARD_AMD_RADEON_HD6600}, - {"HD 6400", CARD_AMD_RADEON_HD6400}, - {"HD 6300", CARD_AMD_RADEON_HD6300}, - {"HD 6200", CARD_AMD_RADEON_HD6300}, - /* Evergreen */ - {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */ - {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */ - {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */ - {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */ - {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */ - {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */ - {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */ - {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */ - {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */ - {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */ - {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */ - /* R700 */ - {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */ - {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */ - {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */ - {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */ - {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */ - {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */ - {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */ - {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */ - {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */ - {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */ - {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */ - {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */ - /* R600/R700 integrated */ - {"HD 4200M", CARD_AMD_RADEON_HD4200M}, - {"HD 3300", CARD_AMD_RADEON_HD3200}, - {"HD 3200", CARD_AMD_RADEON_HD3200}, - {"HD 3100", CARD_AMD_RADEON_HD3200}, - /* R600 */ - {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */ - {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */ - {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */ - {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */ - {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */ - {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */ - {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */ - {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ - {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ - {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ - {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ - {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ - {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ - }; - - for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i) - { - if (strstr(gl_renderer, cards[i].renderer)) - return cards[i].id; - } - return PCI_DEVICE_NONE; - } - - if (d3d_level >= 9) - { - /* Radeon R5xx */ - if (strstr(gl_renderer, "X1600") - || strstr(gl_renderer, "X1650") - || strstr(gl_renderer, "X1800") - || strstr(gl_renderer, "X1900") - || strstr(gl_renderer, "X1950")) - { - return CARD_AMD_RADEON_X1600; - } - - /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx) - * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */ - if (strstr(gl_renderer, "X700") - || strstr(gl_renderer, "X800") - || strstr(gl_renderer, "X850") - || strstr(gl_renderer, "X1300") - || strstr(gl_renderer, "X1400") - || strstr(gl_renderer, "X1450") - || strstr(gl_renderer, "X1550") - || strstr(gl_renderer, "X2300") - || strstr(gl_renderer, "X2500") - || strstr(gl_renderer, "HD 2300") - ) - { - return CARD_AMD_RADEON_X700; - } - - /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */ - if (strstr(gl_renderer, "Radeon Xpress")) - { - return CARD_AMD_RADEON_XPRESS_200M; - } - } - return PCI_DEVICE_NONE; + const char *renderer; + enum wined3d_pci_device id; } - -static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *gl_info, - const char *gl_renderer) +cards_nvidia_binary[] = { - unsigned int i; - - static const struct - { - const char *renderer; - enum wined3d_pci_device id; - } - cards[] = - { - /* Haswell */ - {"Haswell Mobile", CARD_INTEL_HWM}, - /* Ivybridge */ - {"Ivybridge Server", CARD_INTEL_IVBS}, - {"Ivybridge Mobile", CARD_INTEL_IVBM}, - {"Ivybridge Desktop", CARD_INTEL_IVBD}, - /* Sandybridge */ - {"Sandybridge Server", CARD_INTEL_SNBS}, - {"Sandybridge Mobile", CARD_INTEL_SNBM}, - {"Sandybridge Desktop", CARD_INTEL_SNBD}, - /* Ironlake */ - {"Ironlake Mobile", CARD_INTEL_ILKM}, - {"Ironlake Desktop", CARD_INTEL_ILKD}, - /* G4x */ - {"B43", CARD_INTEL_B43}, - {"G41", CARD_INTEL_G41}, - {"G45", CARD_INTEL_G45}, - {"Q45", CARD_INTEL_Q45}, - {"Integrated Graphics Device", CARD_INTEL_IGD}, - {"GM45", CARD_INTEL_GM45}, - /* i965 */ - {"965GME", CARD_INTEL_965GME}, - {"965GM", CARD_INTEL_965GM}, - {"X3100", CARD_INTEL_965GM}, /* MacOS */ - {"946GZ", CARD_INTEL_946GZ}, - {"965G", CARD_INTEL_965G}, - {"965Q", CARD_INTEL_965Q}, - /* i945 */ - {"Pineview M", CARD_INTEL_PNVM}, - {"Pineview G", CARD_INTEL_PNVG}, - {"IGD", CARD_INTEL_PNVG}, - {"Q33", CARD_INTEL_Q33}, - {"G33", CARD_INTEL_G33}, - {"Q35", CARD_INTEL_Q35}, - {"945GME", CARD_INTEL_945GME}, - {"945GM", CARD_INTEL_945GM}, - {"GMA 950", CARD_INTEL_945GM}, /* MacOS */ - {"945G", CARD_INTEL_945G}, - /* i915 */ - {"915GM", CARD_INTEL_915GM}, - {"E7221G", CARD_INTEL_E7221G}, - {"915G", CARD_INTEL_915G}, - /* i8xx */ - {"865G", CARD_INTEL_865G}, - {"845G", CARD_INTEL_845G}, - {"855GM", CARD_INTEL_855GM}, - {"830M", CARD_INTEL_830M}, - }; - - for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i) - { - if (strstr(gl_renderer, cards[i].renderer)) - return cards[i].id; - } - - return PCI_DEVICE_NONE; -} - -static enum wined3d_pci_device select_card_amd_mesa(const struct wined3d_gl_info *gl_info, - const char *gl_renderer) + /* Direct 3D 11 */ + {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI}, /* Geforce 700 - highend */ + {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780}, /* Geforce 700 - highend */ + {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */ + {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */ + {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M}, /* Geforce 700 - midend high mobile */ + {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */ + {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */ + {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */ + {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */ + {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */ + {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */ + {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */ + {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M}, /* Geforce 600 - midend high mobile */ + {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */ + {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */ + {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */ + {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */ + {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */ + {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */ + {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */ + {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */ + {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */ + {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */ + {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */ + {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */ + {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */ + {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */ + {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */ + {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */ + {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */ + {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */ + /* Direct 3D 10 */ + {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */ + {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */ + {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */ + {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */ + {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */ + {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */ + {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */ + {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */ + {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */ + {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */ + {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */ + {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */ + {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */ + {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */ + {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */ + {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */ + {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */ + {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */ + {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */ + {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */ + {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */ + {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */ + {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */ + {"GeForce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ + {"GeForce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ + {"GeForce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ + {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */ + {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */ + {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */ + {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */ + {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */ + {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */ + {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */ + {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */ + {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */ + {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */ + {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */ + {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */ + {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */ + {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */ + {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */ + {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */ + {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */ + {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */ + {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */ + {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */ + {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */ + {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */ + {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */ + {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */ + {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */ + {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */ + /* Direct 3D 9 SM3 */ + {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ + {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ + {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ + {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ + {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */ + {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */ + {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */ + {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */ + {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */ + {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */ + {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */ + {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */ + {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */ + /* Direct 3D 9 SM2 */ + {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */ + {"5950", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */ + {"5900", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */ + {"5800", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */ + {"5750", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */ + {"5700", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */ + {"5650", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */ + {"5600", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */ + {"5500", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */ + {"5300", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */ + {"5250", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */ + {"5200", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */ + {"5100", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */ + /* Direct 3D 8 */ + {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200}, + {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */ + /* Direct 3D 7 */ + {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX}, /* MX420/MX440/MX460/MX4000 */ + {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX}, + {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX}, /* Geforce2 standard/MX100/MX200/MX400 */ + {"Quadro2", CARD_NVIDIA_GEFORCE2}, + {"GeForce2", CARD_NVIDIA_GEFORCE2}, /* Geforce2 GTS/Pro/Ti/Ultra */ + /* Direct 3D 6 */ + {"TNT2", CARD_NVIDIA_RIVA_TNT2}, /* Riva TNT2 standard/M64/Pro/Ultra */ +}, +/* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/ + * + * Beware: renderer string do not match exact card model, + * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */ +cards_amd_binary[] = { - unsigned int i; - - /* 20101109 - These are never returned by current Gallium radeon - * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351. - * - * These are returned but not handled: RC410, RV380. */ - static const struct - { - const char *renderer; - enum wined3d_pci_device id; - } - cards[] = - { - /* Southern Islands */ - {"TAHITI", CARD_AMD_RADEON_HD7900}, - {"PITCAIRN", CARD_AMD_RADEON_HD7800}, - {"CAPE VERDE", CARD_AMD_RADEON_HD7700}, - /* Northern Islands */ - {"CAYMAN", CARD_AMD_RADEON_HD6900}, - {"BARTS", CARD_AMD_RADEON_HD6800}, - {"TURKS", CARD_AMD_RADEON_HD6600}, - {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */ - {"SUMO", CARD_AMD_RADEON_HD6550D}, - {"CAICOS", CARD_AMD_RADEON_HD6400}, - {"PALM", CARD_AMD_RADEON_HD6300}, - /* Evergreen */ - {"HEMLOCK", CARD_AMD_RADEON_HD5900}, - {"CYPRESS", CARD_AMD_RADEON_HD5800}, - {"JUNIPER", CARD_AMD_RADEON_HD5700}, - {"REDWOOD", CARD_AMD_RADEON_HD5600}, - {"CEDAR", CARD_AMD_RADEON_HD5400}, - /* R700 */ - {"R700", CARD_AMD_RADEON_HD4800}, - {"RV790", CARD_AMD_RADEON_HD4800}, - {"RV770", CARD_AMD_RADEON_HD4800}, - {"RV740", CARD_AMD_RADEON_HD4700}, - {"RV730", CARD_AMD_RADEON_HD4600}, - {"RV710", CARD_AMD_RADEON_HD4350}, - /* R600/R700 integrated */ - {"RS880", CARD_AMD_RADEON_HD4200M}, - {"RS780", CARD_AMD_RADEON_HD3200}, - /* R600 */ - {"R680", CARD_AMD_RADEON_HD2900}, - {"R600", CARD_AMD_RADEON_HD2900}, - {"RV670", CARD_AMD_RADEON_HD2900}, - {"RV635", CARD_AMD_RADEON_HD2600}, - {"RV630", CARD_AMD_RADEON_HD2600}, - {"RV620", CARD_AMD_RADEON_HD2350}, - {"RV610", CARD_AMD_RADEON_HD2350}, - /* R500 */ - {"R580", CARD_AMD_RADEON_X1600}, - {"R520", CARD_AMD_RADEON_X1600}, - {"RV570", CARD_AMD_RADEON_X1600}, - {"RV560", CARD_AMD_RADEON_X1600}, - {"RV535", CARD_AMD_RADEON_X1600}, - {"RV530", CARD_AMD_RADEON_X1600}, - {"RV516", CARD_AMD_RADEON_X700}, - {"RV515", CARD_AMD_RADEON_X700}, - /* R400 */ - {"R481", CARD_AMD_RADEON_X700}, - {"R480", CARD_AMD_RADEON_X700}, - {"R430", CARD_AMD_RADEON_X700}, - {"R423", CARD_AMD_RADEON_X700}, - {"R420", CARD_AMD_RADEON_X700}, - {"R410", CARD_AMD_RADEON_X700}, - {"RV410", CARD_AMD_RADEON_X700}, - /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */ - {"RS740", CARD_AMD_RADEON_XPRESS_200M}, - {"RS690", CARD_AMD_RADEON_XPRESS_200M}, - {"RS600", CARD_AMD_RADEON_XPRESS_200M}, - {"RS485", CARD_AMD_RADEON_XPRESS_200M}, - {"RS482", CARD_AMD_RADEON_XPRESS_200M}, - {"RS480", CARD_AMD_RADEON_XPRESS_200M}, - {"RS400", CARD_AMD_RADEON_XPRESS_200M}, - /* R300 */ - {"R360", CARD_AMD_RADEON_9500}, - {"R350", CARD_AMD_RADEON_9500}, - {"R300", CARD_AMD_RADEON_9500}, - {"RV370", CARD_AMD_RADEON_9500}, - {"RV360", CARD_AMD_RADEON_9500}, - {"RV351", CARD_AMD_RADEON_9500}, - {"RV350", CARD_AMD_RADEON_9500}, - }; - - for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i) - { - if (strstr(gl_renderer, cards[i].renderer)) - return cards[i].id; - } - - return PCI_DEVICE_NONE; -} - -static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info, - const char *gl_renderer) + /* Southern Islands */ + {"HD 7900", CARD_AMD_RADEON_HD7900}, + {"HD 7800", CARD_AMD_RADEON_HD7800}, + {"HD 7700", CARD_AMD_RADEON_HD7700}, + /* Northern Islands */ + {"HD 6970", CARD_AMD_RADEON_HD6900}, + {"HD 6900", CARD_AMD_RADEON_HD6900}, + {"HD 6800", CARD_AMD_RADEON_HD6800}, + {"HD 6770M", CARD_AMD_RADEON_HD6600M}, + {"HD 6750M", CARD_AMD_RADEON_HD6600M}, + {"HD 6700", CARD_AMD_RADEON_HD6700}, + {"HD 6670", CARD_AMD_RADEON_HD6600}, + {"HD 6630M", CARD_AMD_RADEON_HD6600M}, + {"HD 6600M", CARD_AMD_RADEON_HD6600M}, + {"HD 6600", CARD_AMD_RADEON_HD6600}, + {"HD 6570", CARD_AMD_RADEON_HD6600}, + {"HD 6500M", CARD_AMD_RADEON_HD6600M}, + {"HD 6500", CARD_AMD_RADEON_HD6600}, + {"HD 6400", CARD_AMD_RADEON_HD6400}, + {"HD 6300", CARD_AMD_RADEON_HD6300}, + {"HD 6200", CARD_AMD_RADEON_HD6300}, + /* Evergreen */ + {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */ + {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */ + {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */ + {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */ + {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */ + {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */ + {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */ + {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */ + {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */ + {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */ + {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */ + /* R700 */ + {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */ + {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */ + {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */ + {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */ + {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */ + {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */ + {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */ + {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */ + {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */ + {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */ + {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */ + {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */ + /* R600/R700 integrated */ + {"HD 4200M", CARD_AMD_RADEON_HD4200M}, + {"HD 3300", CARD_AMD_RADEON_HD3200}, + {"HD 3200", CARD_AMD_RADEON_HD3200}, + {"HD 3100", CARD_AMD_RADEON_HD3200}, + /* R600 */ + {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */ + {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */ + {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */ + {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */ + {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */ + {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */ + {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */ + {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ + {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ + {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ + {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ + {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ + {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */ + /* Radeon R5xx */ + {"X1950", CARD_AMD_RADEON_X1600}, + {"X1900", CARD_AMD_RADEON_X1600}, + {"X1800", CARD_AMD_RADEON_X1600}, + {"X1650", CARD_AMD_RADEON_X1600}, + {"X1600", CARD_AMD_RADEON_X1600}, + /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx) + * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */ + {"HD 2300", CARD_AMD_RADEON_X700}, + {"X2500", CARD_AMD_RADEON_X700}, + {"X2300", CARD_AMD_RADEON_X700}, + {"X1550", CARD_AMD_RADEON_X700}, + {"X1450", CARD_AMD_RADEON_X700}, + {"X1400", CARD_AMD_RADEON_X700}, + {"X1300", CARD_AMD_RADEON_X700}, + {"X850", CARD_AMD_RADEON_X700}, + {"X800", CARD_AMD_RADEON_X700}, + {"X700", CARD_AMD_RADEON_X700}, + /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */ + {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M}, +}, +cards_intel[] = { - unsigned int i; - - static const struct - { - const char *renderer; - enum wined3d_pci_device id; - } - cards[] = - { - /* Maxwell */ - {"NV117", CARD_NVIDIA_GEFORCE_GTX750}, - /* Kepler */ - {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M}, - {"NVE4", CARD_NVIDIA_GEFORCE_GTX680}, - /* Fermi */ - {"NVD9", CARD_NVIDIA_GEFORCE_GT520}, - {"NVCF", CARD_NVIDIA_GEFORCE_GTX550}, - {"NVCE", CARD_NVIDIA_GEFORCE_GTX560}, - {"NVC8", CARD_NVIDIA_GEFORCE_GTX570}, - {"NVC4", CARD_NVIDIA_GEFORCE_GTX460}, - {"NVC3", CARD_NVIDIA_GEFORCE_GT440}, - {"NVC1", CARD_NVIDIA_GEFORCE_GT420}, - {"NVC0", CARD_NVIDIA_GEFORCE_GTX480}, - /* Tesla */ - {"NVAF", CARD_NVIDIA_GEFORCE_GT320M}, - {"NVAC", CARD_NVIDIA_GEFORCE_8200}, - {"NVAA", CARD_NVIDIA_GEFORCE_8200}, - {"NVA8", CARD_NVIDIA_GEFORCE_210}, - {"NVA5", CARD_NVIDIA_GEFORCE_GT220}, - {"NVA3", CARD_NVIDIA_GEFORCE_GT240}, - {"NVA0", CARD_NVIDIA_GEFORCE_GTX280}, - {"NV98", CARD_NVIDIA_GEFORCE_9200}, - {"NV96", CARD_NVIDIA_GEFORCE_9400GT}, - {"NV94", CARD_NVIDIA_GEFORCE_9600GT}, - {"NV92", CARD_NVIDIA_GEFORCE_9800GT}, - {"NV86", CARD_NVIDIA_GEFORCE_8500GT}, - {"NV84", CARD_NVIDIA_GEFORCE_8600GT}, - {"NV50", CARD_NVIDIA_GEFORCE_8800GTX}, - /* Curie */ - {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */ - {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */ - {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */ - {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */ - {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */ - {"NV4B", CARD_NVIDIA_GEFORCE_7600}, - {"NV4A", CARD_NVIDIA_GEFORCE_6200}, - {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */ - {"NV47", CARD_NVIDIA_GEFORCE_7800GT}, - {"NV46", CARD_NVIDIA_GEFORCE_7400}, - {"NV45", CARD_NVIDIA_GEFORCE_6800}, - {"NV44", CARD_NVIDIA_GEFORCE_6200}, - {"NV43", CARD_NVIDIA_GEFORCE_6600GT}, - {"NV42", CARD_NVIDIA_GEFORCE_6800}, - {"NV41", CARD_NVIDIA_GEFORCE_6800}, - {"NV40", CARD_NVIDIA_GEFORCE_6800}, - /* Rankine */ - {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */ - {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */ - {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */ - {"NV34", CARD_NVIDIA_GEFORCEFX_5200}, - {"NV31", CARD_NVIDIA_GEFORCEFX_5600}, - {"NV30", CARD_NVIDIA_GEFORCEFX_5800}, - /* Kelvin */ - {"nv28", CARD_NVIDIA_GEFORCE4_TI4200}, - {"nv25", CARD_NVIDIA_GEFORCE4_TI4200}, - {"nv20", CARD_NVIDIA_GEFORCE3}, - /* Celsius */ - {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */ - {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */ - {"nv18", CARD_NVIDIA_GEFORCE4_MX}, - {"nv17", CARD_NVIDIA_GEFORCE4_MX}, - {"nv16", CARD_NVIDIA_GEFORCE2}, - {"nv15", CARD_NVIDIA_GEFORCE2}, - {"nv11", CARD_NVIDIA_GEFORCE2_MX}, - {"nv10", CARD_NVIDIA_GEFORCE}, - /* Fahrenheit */ - {"nv05", CARD_NVIDIA_RIVA_TNT2}, - {"nv04", CARD_NVIDIA_RIVA_TNT}, - {"nv03", CARD_NVIDIA_RIVA_128}, - }; - - for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i) - { - if (strstr(gl_renderer, cards[i].renderer)) - return cards[i].id; - } - return PCI_DEVICE_NONE; -} - -static enum wined3d_pci_device select_card_vmware(const struct wined3d_gl_info *gl_info, const char *gl_renderer) + /* Haswell */ + {"Haswell Mobile", CARD_INTEL_HWM}, + /* Ivybridge */ + {"Ivybridge Server", CARD_INTEL_IVBS}, + {"Ivybridge Mobile", CARD_INTEL_IVBM}, + {"Ivybridge Desktop", CARD_INTEL_IVBD}, + /* Sandybridge */ + {"Sandybridge Server", CARD_INTEL_SNBS}, + {"Sandybridge Mobile", CARD_INTEL_SNBM}, + {"Sandybridge Desktop", CARD_INTEL_SNBD}, + /* Ironlake */ + {"Ironlake Mobile", CARD_INTEL_ILKM}, + {"Ironlake Desktop", CARD_INTEL_ILKD}, + /* G4x */ + {"B43", CARD_INTEL_B43}, + {"G41", CARD_INTEL_G41}, + {"G45", CARD_INTEL_G45}, + {"Q45", CARD_INTEL_Q45}, + {"Integrated Graphics Device", CARD_INTEL_IGD}, + {"GM45", CARD_INTEL_GM45}, + /* i965 */ + {"965GME", CARD_INTEL_965GME}, + {"965GM", CARD_INTEL_965GM}, + {"X3100", CARD_INTEL_965GM}, /* MacOS */ + {"946GZ", CARD_INTEL_946GZ}, + {"965G", CARD_INTEL_965G}, + {"965Q", CARD_INTEL_965Q}, + /* i945 */ + {"Pineview M", CARD_INTEL_PNVM}, + {"Pineview G", CARD_INTEL_PNVG}, + {"IGD", CARD_INTEL_PNVG}, + {"Q33", CARD_INTEL_Q33}, + {"G33", CARD_INTEL_G33}, + {"Q35", CARD_INTEL_Q35}, + {"945GME", CARD_INTEL_945GME}, + {"945GM", CARD_INTEL_945GM}, + {"GMA 950", CARD_INTEL_945GM}, /* MacOS */ + {"945G", CARD_INTEL_945G}, + /* i915 */ + {"915GM", CARD_INTEL_915GM}, + {"E7221G", CARD_INTEL_E7221G}, + {"915G", CARD_INTEL_915G}, + /* i8xx */ + {"865G", CARD_INTEL_865G}, + {"845G", CARD_INTEL_845G}, + {"855GM", CARD_INTEL_855GM}, + {"830M", CARD_INTEL_830M}, +}, +/* 20101109 - These are never returned by current Gallium radeon + * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351. + * + * These are returned but not handled: RC410, RV380. */ +cards_amd_mesa[] = { - if (strstr(gl_renderer, "SVGA3D")) - return CARD_VMWARE_SVGA3D; - - return PCI_DEVICE_NONE; -} + /* Sea Islands */ + {"HAWAII", CARD_AMD_RADEON_R9 }, + {"KAVERI", CARD_AMD_RADEON_R7 }, + {"KABINI", CARD_AMD_RADEON_R3 }, + {"BONAIRE", CARD_AMD_RADEON_HD8770}, + /* Southern Islands */ + {"OLAND", CARD_AMD_RADEON_HD8670}, + {"HAINAN", CARD_AMD_RADEON_HD8600M}, + {"TAHITI", CARD_AMD_RADEON_HD7900}, + {"PITCAIRN", CARD_AMD_RADEON_HD7800}, + {"CAPE VERDE", CARD_AMD_RADEON_HD7700}, + /* Northern Islands */ + {"ARUBA", CARD_AMD_RADEON_HD7660D}, + {"CAYMAN", CARD_AMD_RADEON_HD6900}, + {"BARTS", CARD_AMD_RADEON_HD6800}, + {"TURKS", CARD_AMD_RADEON_HD6600}, + {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */ + {"SUMO", CARD_AMD_RADEON_HD6550D}, + {"CAICOS", CARD_AMD_RADEON_HD6400}, + {"PALM", CARD_AMD_RADEON_HD6300}, + /* Evergreen */ + {"HEMLOCK", CARD_AMD_RADEON_HD5900}, + {"CYPRESS", CARD_AMD_RADEON_HD5800}, + {"JUNIPER", CARD_AMD_RADEON_HD5700}, + {"REDWOOD", CARD_AMD_RADEON_HD5600}, + {"CEDAR", CARD_AMD_RADEON_HD5400}, + /* R700 */ + {"R700", CARD_AMD_RADEON_HD4800}, + {"RV790", CARD_AMD_RADEON_HD4800}, + {"RV770", CARD_AMD_RADEON_HD4800}, + {"RV740", CARD_AMD_RADEON_HD4700}, + {"RV730", CARD_AMD_RADEON_HD4600}, + {"RV710", CARD_AMD_RADEON_HD4350}, + /* R600/R700 integrated */ + {"RS880", CARD_AMD_RADEON_HD4200M}, + {"RS780", CARD_AMD_RADEON_HD3200}, + /* R600 */ + {"R680", CARD_AMD_RADEON_HD2900}, + {"R600", CARD_AMD_RADEON_HD2900}, + {"RV670", CARD_AMD_RADEON_HD2900}, + {"RV635", CARD_AMD_RADEON_HD2600}, + {"RV630", CARD_AMD_RADEON_HD2600}, + {"RV620", CARD_AMD_RADEON_HD2350}, + {"RV610", CARD_AMD_RADEON_HD2350}, + /* R500 */ + {"R580", CARD_AMD_RADEON_X1600}, + {"R520", CARD_AMD_RADEON_X1600}, + {"RV570", CARD_AMD_RADEON_X1600}, + {"RV560", CARD_AMD_RADEON_X1600}, + {"RV535", CARD_AMD_RADEON_X1600}, + {"RV530", CARD_AMD_RADEON_X1600}, + {"RV516", CARD_AMD_RADEON_X700}, + {"RV515", CARD_AMD_RADEON_X700}, + /* R400 */ + {"R481", CARD_AMD_RADEON_X700}, + {"R480", CARD_AMD_RADEON_X700}, + {"R430", CARD_AMD_RADEON_X700}, + {"R423", CARD_AMD_RADEON_X700}, + {"R420", CARD_AMD_RADEON_X700}, + {"R410", CARD_AMD_RADEON_X700}, + {"RV410", CARD_AMD_RADEON_X700}, + /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */ + {"RS740", CARD_AMD_RADEON_XPRESS_200M}, + {"RS690", CARD_AMD_RADEON_XPRESS_200M}, + {"RS600", CARD_AMD_RADEON_XPRESS_200M}, + {"RS485", CARD_AMD_RADEON_XPRESS_200M}, + {"RS482", CARD_AMD_RADEON_XPRESS_200M}, + {"RS480", CARD_AMD_RADEON_XPRESS_200M}, + {"RS400", CARD_AMD_RADEON_XPRESS_200M}, + /* R300 */ + {"R360", CARD_AMD_RADEON_9500}, + {"R350", CARD_AMD_RADEON_9500}, + {"R300", CARD_AMD_RADEON_9500}, + {"RV370", CARD_AMD_RADEON_9500}, + {"RV360", CARD_AMD_RADEON_9500}, + {"RV351", CARD_AMD_RADEON_9500}, + {"RV350", CARD_AMD_RADEON_9500}, +}, +cards_nvidia_mesa[] = +{ + /* Maxwell */ + {"NV117", CARD_NVIDIA_GEFORCE_GTX750}, + /* Kepler */ + {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI}, + {"NVF0", CARD_NVIDIA_GEFORCE_GTX780}, + {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M}, + {"NVE4", CARD_NVIDIA_GEFORCE_GTX680}, + /* Fermi */ + {"NVD9", CARD_NVIDIA_GEFORCE_GT520}, + {"NVCF", CARD_NVIDIA_GEFORCE_GTX550}, + {"NVCE", CARD_NVIDIA_GEFORCE_GTX560}, + {"NVC8", CARD_NVIDIA_GEFORCE_GTX570}, + {"NVC4", CARD_NVIDIA_GEFORCE_GTX460}, + {"NVC3", CARD_NVIDIA_GEFORCE_GT440}, + {"NVC1", CARD_NVIDIA_GEFORCE_GT420}, + {"NVC0", CARD_NVIDIA_GEFORCE_GTX480}, + /* Tesla */ + {"NVAF", CARD_NVIDIA_GEFORCE_GT320M}, + {"NVAC", CARD_NVIDIA_GEFORCE_8200}, + {"NVAA", CARD_NVIDIA_GEFORCE_8200}, + {"NVA8", CARD_NVIDIA_GEFORCE_210}, + {"NVA5", CARD_NVIDIA_GEFORCE_GT220}, + {"NVA3", CARD_NVIDIA_GEFORCE_GT240}, + {"NVA0", CARD_NVIDIA_GEFORCE_GTX280}, + {"NV98", CARD_NVIDIA_GEFORCE_9200}, + {"NV96", CARD_NVIDIA_GEFORCE_9400GT}, + {"NV94", CARD_NVIDIA_GEFORCE_9600GT}, + {"NV92", CARD_NVIDIA_GEFORCE_9800GT}, + {"NV86", CARD_NVIDIA_GEFORCE_8500GT}, + {"NV84", CARD_NVIDIA_GEFORCE_8600GT}, + {"NV50", CARD_NVIDIA_GEFORCE_8800GTX}, + /* Curie */ + {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */ + {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */ + {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */ + {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */ + {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */ + {"NV4B", CARD_NVIDIA_GEFORCE_7600}, + {"NV4A", CARD_NVIDIA_GEFORCE_6200}, + {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */ + {"NV47", CARD_NVIDIA_GEFORCE_7800GT}, + {"NV46", CARD_NVIDIA_GEFORCE_7400}, + {"NV45", CARD_NVIDIA_GEFORCE_6800}, + {"NV44", CARD_NVIDIA_GEFORCE_6200}, + {"NV43", CARD_NVIDIA_GEFORCE_6600GT}, + {"NV42", CARD_NVIDIA_GEFORCE_6800}, + {"NV41", CARD_NVIDIA_GEFORCE_6800}, + {"NV40", CARD_NVIDIA_GEFORCE_6800}, + /* Rankine */ + {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */ + {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */ + {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */ + {"NV34", CARD_NVIDIA_GEFORCEFX_5200}, + {"NV31", CARD_NVIDIA_GEFORCEFX_5600}, + {"NV30", CARD_NVIDIA_GEFORCEFX_5800}, + /* Kelvin */ + {"nv28", CARD_NVIDIA_GEFORCE4_TI4200}, + {"nv25", CARD_NVIDIA_GEFORCE4_TI4200}, + {"nv20", CARD_NVIDIA_GEFORCE3}, + /* Celsius */ + {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */ + {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */ + {"nv18", CARD_NVIDIA_GEFORCE4_MX}, + {"nv17", CARD_NVIDIA_GEFORCE4_MX}, + {"nv16", CARD_NVIDIA_GEFORCE2}, + {"nv15", CARD_NVIDIA_GEFORCE2}, + {"nv11", CARD_NVIDIA_GEFORCE2_MX}, + {"nv10", CARD_NVIDIA_GEFORCE}, + /* Fahrenheit */ + {"nv05", CARD_NVIDIA_RIVA_TNT2}, + {"nv04", CARD_NVIDIA_RIVA_TNT}, + {"nv03", CARD_NVIDIA_RIVA_128}, +}, +cards_vmware[] = +{ + {"SVGA3D", CARD_VMWARE_SVGA3D}, +}; static const struct gl_vendor_selection { enum wined3d_gl_vendor gl_vendor; const char *description; /* Description of the card selector i.e. Apple OS/X Intel */ - enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer); + const struct wined3d_renderer_table *cards; /* To be used as cards[], pointer to the first member in an array */ + size_t cards_size; /* Number of entries in the array above */ } amd_gl_vendor_table[] = { - {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", select_card_amd_binary}, - {GL_VENDOR_FGLRX, "AMD/ATI binary driver", select_card_amd_binary}, - {GL_VENDOR_MESA, "Mesa AMD/ATI driver", select_card_amd_mesa}, + {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)}, + {GL_VENDOR_FGLRX, "AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)}, + {GL_VENDOR_MESA, "Mesa AMD/ATI driver", cards_amd_mesa, ARRAY_SIZE(cards_amd_mesa)}, }, nvidia_gl_vendor_table[] = { - {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", select_card_nvidia_binary}, - {GL_VENDOR_MESA, "Mesa Nouveau driver", select_card_nvidia_mesa}, - {GL_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary}, + {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)}, + {GL_VENDOR_MESA, "Mesa Nouveau driver", cards_nvidia_mesa, ARRAY_SIZE(cards_nvidia_mesa)}, + {GL_VENDOR_NVIDIA, "Nvidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)}, }, vmware_gl_vendor_table[] = { - {GL_VENDOR_MESA, "VMware driver", select_card_vmware}, + {GL_VENDOR_MESA, "VMware driver", cards_vmware, ARRAY_SIZE(cards_vmware)}, }, intel_gl_vendor_table[] = { - {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", select_card_intel}, - {GL_VENDOR_MESA, "Mesa Intel driver", select_card_intel}, + {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", cards_intel, ARRAY_SIZE(cards_intel)}, + {GL_VENDOR_MESA, "Mesa Intel driver", cards_intel, ARRAY_SIZE(cards_intel)}, }; -static enum wined3d_pci_device select_card_fallback_nvidia(const struct wined3d_gl_info *gl_info) +static const enum wined3d_pci_device +card_fallback_nvidia[] = { - UINT d3d_level = d3d_level_from_gl_info(gl_info); - if (d3d_level >= 10) - return CARD_NVIDIA_GEFORCE_8800GTX; - if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3]) - return CARD_NVIDIA_GEFORCE_6800; - if (d3d_level >= 9) - return CARD_NVIDIA_GEFORCEFX_5800; - if (d3d_level >= 8) - return CARD_NVIDIA_GEFORCE3; - if (d3d_level >= 7) - return CARD_NVIDIA_GEFORCE; - if (d3d_level >= 6) - return CARD_NVIDIA_RIVA_TNT; - return CARD_NVIDIA_RIVA_128; -} - -static enum wined3d_pci_device select_card_fallback_amd(const struct wined3d_gl_info *gl_info) + CARD_NVIDIA_RIVA_128, /* D3D5 */ + CARD_NVIDIA_RIVA_TNT, /* D3D6 */ + CARD_NVIDIA_GEFORCE, /* D3D7 */ + CARD_NVIDIA_GEFORCE3, /* D3D8 */ + CARD_NVIDIA_GEFORCEFX_5800, /* D3D9_SM2 */ + CARD_NVIDIA_GEFORCE_6800, /* D3D9_SM3 */ + CARD_NVIDIA_GEFORCE_8800GTX, /* D3D10 */ + CARD_NVIDIA_GEFORCE_GTX470, /* D3D11 */ +}, +card_fallback_amd[] = { - UINT d3d_level = d3d_level_from_gl_info(gl_info); - if (d3d_level >= 10) - return CARD_AMD_RADEON_HD2900; - if (d3d_level >= 9) - return CARD_AMD_RADEON_9500; - if (d3d_level >= 8) - return CARD_AMD_RADEON_8500; - if (d3d_level >= 7) - return CARD_AMD_RADEON_7200; - return CARD_AMD_RAGE_128PRO; -} - -static enum wined3d_pci_device select_card_fallback_intel(const struct wined3d_gl_info *gl_info) + CARD_AMD_RAGE_128PRO, /* D3D5 */ + CARD_AMD_RAGE_128PRO, /* D3D6 */ + CARD_AMD_RADEON_7200, /* D3D7 */ + CARD_AMD_RADEON_8500, /* D3D8 */ + CARD_AMD_RADEON_9500, /* D3D9_SM2 */ + CARD_AMD_RADEON_X1600, /* D3D9_SM3 */ + CARD_AMD_RADEON_HD2900, /* D3D10 */ + CARD_AMD_RADEON_HD5600, /* D3D11 */ +}, +card_fallback_intel[] = { - UINT d3d_level = d3d_level_from_gl_info(gl_info); - if (d3d_level >= 10) - return CARD_INTEL_G45; - return CARD_INTEL_915G; -} + CARD_INTEL_915G, /* D3D5 */ + CARD_INTEL_915G, /* D3D6 */ + CARD_INTEL_915G, /* D3D7 */ + CARD_INTEL_915G, /* D3D8 */ + CARD_INTEL_915G, /* D3D9_SM2 */ + CARD_INTEL_915G, /* D3D9_SM3 */ + CARD_INTEL_G45, /* D3D10 */ + CARD_INTEL_IVBD, /* D3D11 */ +}; +C_ASSERT(ARRAY_SIZE(card_fallback_nvidia) == WINED3D_D3D_LEVEL_COUNT); +C_ASSERT(ARRAY_SIZE(card_fallback_amd) == WINED3D_D3D_LEVEL_COUNT); +C_ASSERT(ARRAY_SIZE(card_fallback_intel) == WINED3D_D3D_LEVEL_COUNT); static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table, - unsigned int table_size, enum wined3d_gl_vendor gl_vendor, - const struct wined3d_gl_info *gl_info, const char *gl_renderer) + unsigned int table_size, enum wined3d_gl_vendor gl_vendor, const char *gl_renderer) { - unsigned int i; + unsigned int i, j; for (i = 0; i < table_size; ++i) { @@ -2340,7 +2239,13 @@ static enum wined3d_pci_device select_card_handler(const struct gl_vendor_select continue; TRACE("Applying card selector \"%s\".\n", table[i].description); - return table[i].select_card(gl_info, gl_renderer); + + for (j = 0; j < table[i].cards_size; ++j) + { + if (strstr(gl_renderer, table[i].cards[j].renderer)) + return table[i].cards[j].id; + } + return PCI_DEVICE_NONE; } FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n", gl_vendor, debugstr_a(gl_renderer)); @@ -2354,22 +2259,22 @@ static const struct const char *description; /* Description of the card selector i.e. Apple OS/X Intel */ const struct gl_vendor_selection *gl_vendor_selection; unsigned int gl_vendor_count; - enum wined3d_pci_device (*select_card_fallback)(const struct wined3d_gl_info *gl_info); + const enum wined3d_pci_device *card_fallback; /* An array with D3D_LEVEL_COUNT elements */ } card_vendor_table[] = { {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table, sizeof(amd_gl_vendor_table) / sizeof(*amd_gl_vendor_table), - select_card_fallback_amd}, + card_fallback_amd}, {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table, sizeof(nvidia_gl_vendor_table) / sizeof(*nvidia_gl_vendor_table), - select_card_fallback_nvidia}, + card_fallback_nvidia}, {HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table, sizeof(vmware_gl_vendor_table) / sizeof(*vmware_gl_vendor_table), - select_card_fallback_amd}, + card_fallback_amd}, {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table, sizeof(intel_gl_vendor_table) / sizeof(*intel_gl_vendor_table), - select_card_fallback_intel}, + card_fallback_intel}, }; @@ -2427,6 +2332,7 @@ static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info * * memory can be overruled using a registry setting. */ unsigned int i; + enum wined3d_d3d_level d3d_level = d3d_level_from_gl_info(gl_info); enum wined3d_pci_device device; for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i) @@ -2436,12 +2342,12 @@ static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info * TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description); device = select_card_handler(card_vendor_table[i].gl_vendor_selection, - card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_info, gl_renderer); + card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_renderer); if (device != PCI_DEVICE_NONE) return device; TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer)); - return card_vendor_table[i].select_card_fallback(gl_info); + return card_vendor_table[i].card_fallback[d3d_level]; } FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n", @@ -2449,7 +2355,7 @@ static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info * /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */ *card_vendor = HW_VENDOR_NVIDIA; - return select_card_fallback_nvidia(gl_info); + return card_fallback_nvidia[d3d_level]; } static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info, @@ -2563,6 +2469,9 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->limits.buffers = 1; gl_info->limits.textures = 1; gl_info->limits.texture_coords = 1; + gl_info->limits.vertex_uniform_blocks = 0; + gl_info->limits.geometry_uniform_blocks = 0; + gl_info->limits.fragment_uniform_blocks = 0; gl_info->limits.fragment_samplers = 1; gl_info->limits.vertex_samplers = 0; gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers; @@ -2739,6 +2648,19 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max); gl_info->limits.glsl_vs_float_constants = gl_max / 4; TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants); + + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + { + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &gl_max); + gl_info->limits.vertex_uniform_blocks = min(gl_max, WINED3D_MAX_CBS); + TRACE("Max vertex uniform blocks: %u (%d).\n", gl_info->limits.vertex_uniform_blocks, gl_max); + } + } + if (gl_info->supported[ARB_GEOMETRY_SHADER4] && gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + { + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &gl_max); + gl_info->limits.geometry_uniform_blocks = min(gl_max, WINED3D_MAX_CBS); + TRACE("Max geometry uniform blocks: %u (%d).\n", gl_info->limits.geometry_uniform_blocks, gl_max); } if (gl_info->supported[ARB_FRAGMENT_SHADER]) { @@ -2748,6 +2670,20 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max); gl_info->limits.glsl_varyings = gl_max; TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4); + + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + { + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &gl_max); + gl_info->limits.fragment_uniform_blocks = min(gl_max, WINED3D_MAX_CBS); + TRACE("Max fragment uniform blocks: %u (%d).\n", gl_info->limits.fragment_uniform_blocks, gl_max); + } + } + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + { + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &gl_max); + TRACE("Max combined uniform blocks: %d.\n", gl_max); + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &gl_max); + TRACE("Max uniform buffer bindings: %d.\n", gl_max); } if (gl_info->supported[NV_LIGHT_MAX_EXPONENT]) @@ -3481,7 +3417,7 @@ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d, memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier)); identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1; memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid)); - identifier->video_memory = adapter->TextureRam; + identifier->video_memory = min(~(SIZE_T)0, adapter->vram_bytes); return WINED3D_OK; } @@ -4023,6 +3959,21 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad return WINED3D_OK; } +UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx, + enum wined3d_format_id format_id, UINT width) +{ + const struct wined3d_gl_info *gl_info; + + TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n", + wined3d, adapter_idx, debug_d3dformat(format_id), width); + + if (adapter_idx >= wined3d->adapter_count) + return ~0u; + + gl_info = &wined3d->adapters[adapter_idx].gl_info; + return wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id), width); +} + HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format) { @@ -5169,9 +5120,9 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal) return FALSE; } - adapter->TextureRam = adapter->driver_info.vidmem; - adapter->UsedTextureRam = 0; - TRACE("Emulating %u MB of texture ram.\n", adapter->TextureRam / (1024 * 1024)); + adapter->vram_bytes = adapter->driver_info.vram_bytes; + adapter->vram_bytes_used = 0; + TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes)); display_device.cb = sizeof(display_device); EnumDisplayDevicesW(NULL, ordinal, &display_device, 0); @@ -5197,9 +5148,9 @@ static void wined3d_adapter_init_nogl(struct wined3d_adapter *adapter, UINT ordi adapter->driver_info.name = "Display"; adapter->driver_info.description = "WineD3D DirectDraw Emulation"; if (wined3d_settings.emulated_textureram) - adapter->TextureRam = wined3d_settings.emulated_textureram; + adapter->vram_bytes = wined3d_settings.emulated_textureram; else - adapter->TextureRam = 128 * 1024 * 1024; + adapter->vram_bytes = 128 * 1024 * 1024; initPixelFormatsNoGL(&adapter->gl_info); diff --git a/reactos/dll/directx/wine/wined3d/drawprim.c b/reactos/dll/directx/wine/wined3d/drawprim.c index e2f087c8323..5c041192b4e 100644 --- a/reactos/dll/directx/wine/wined3d/drawprim.c +++ b/reactos/dll/directx/wine/wined3d/drawprim.c @@ -607,16 +607,16 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co /* Invalidate the back buffer memory so LockRect will read it the next time */ for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i) { - struct wined3d_surface *target = device->fb.render_targets[i]; + struct wined3d_surface *target = wined3d_rendertarget_view_get_surface(device->fb.render_targets[i]); if (target) { - surface_load_location(target, target->draw_binding); - surface_invalidate_location(target, ~target->draw_binding); + surface_load_location(target, target->container->resource.draw_binding); + surface_invalidate_location(target, ~target->container->resource.draw_binding); } } } - context = context_acquire(device, device->fb.render_targets[0]); + context = context_acquire(device, wined3d_rendertarget_view_get_surface(device->fb.render_targets[0])); if (!context->valid) { context_release(context); @@ -632,11 +632,11 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co * Z-compare function into account, but we could skip loading the * depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note * that we never copy the stencil data.*/ - DWORD location = context->render_offscreen ? - device->fb.depth_stencil->draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = context->render_offscreen ? device->fb.depth_stencil->resource->draw_binding + : WINED3D_LOCATION_DRAWABLE; if (state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE]) { - struct wined3d_surface *ds = device->fb.depth_stencil; + struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(device->fb.depth_stencil); RECT current_rect, draw_rect, r; if (!context->render_offscreen && ds != device->onscreen_depth_stencil) @@ -664,8 +664,8 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co if (device->fb.depth_stencil && state->render_states[WINED3D_RS_ZWRITEENABLE]) { - struct wined3d_surface *ds = device->fb.depth_stencil; - DWORD location = context->render_offscreen ? ds->draw_binding : WINED3D_LOCATION_DRAWABLE; + struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(device->fb.depth_stencil); + DWORD location = context->render_offscreen ? ds->container->resource.draw_binding : WINED3D_LOCATION_DRAWABLE; surface_modify_ds_location(ds, location, ds->ds_current_size.cx, ds->ds_current_size.cy); } diff --git a/reactos/dll/directx/wine/wined3d/glsl_shader.c b/reactos/dll/directx/wine/wined3d/glsl_shader.c index 2a18b8fa0bf..85d82f2c22e 100644 --- a/reactos/dll/directx/wine/wined3d/glsl_shader.c +++ b/reactos/dll/directx/wine/wined3d/glsl_shader.c @@ -32,7 +32,6 @@ #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); -WINE_DECLARE_DEBUG_CHANNEL(d3d_constants); WINE_DECLARE_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(winediag); @@ -105,6 +104,7 @@ struct glsl_vs_program GLenum vertex_color_clamp; GLint *uniform_f_locations; GLint uniform_i_locations[MAX_CONST_I]; + GLint uniform_b_locations[MAX_CONST_B]; GLint pos_fixup_location; }; @@ -120,9 +120,11 @@ struct glsl_ps_program GLhandleARB id; GLint *uniform_f_locations; GLint uniform_i_locations[MAX_CONST_I]; + GLint uniform_b_locations[MAX_CONST_B]; GLint bumpenv_mat_location[MAX_TEXTURES]; GLint bumpenv_lum_scale_location[MAX_TEXTURES]; GLint bumpenv_lum_offset_location[MAX_TEXTURES]; + GLint tss_constant_location[MAX_TEXTURES]; GLint tex_factor_location; GLint specular_enable_location; GLint ycorrection_location; @@ -638,12 +640,8 @@ static void shader_glsl_load_constantsI(const struct wined3d_shader *shader, con { if (!(constants_set & 1)) continue; - TRACE_(d3d_constants)("Loading constants %u: %i, %i, %i, %i\n", - i, constants[i*4], constants[i*4+1], constants[i*4+2], constants[i*4+3]); - /* We found this uniform name in the program - go ahead and send the data */ GL_EXTCALL(glUniform4ivARB(locations[i], 1, &constants[i*4])); - checkGLcall("glUniform4ivARB"); } /* Load immediate constants */ @@ -654,41 +652,25 @@ static void shader_glsl_load_constantsI(const struct wined3d_shader *shader, con unsigned int idx = lconst->idx; const GLint *values = (const GLint *)lconst->value; - TRACE_(d3d_constants)("Loading local constants %i: %i, %i, %i, %i\n", idx, - values[0], values[1], values[2], values[3]); - /* We found this uniform name in the program - go ahead and send the data */ GL_EXTCALL(glUniform4ivARB(locations[idx], 1, values)); - checkGLcall("glUniform4ivARB"); ptr = list_next(&shader->constantsI, ptr); } + checkGLcall("glUniform4ivARB()"); } /* Context activation is done by the caller. */ static void shader_glsl_load_constantsB(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, - GLhandleARB programId, const BOOL *constants, WORD constants_set) + const GLint locations[MAX_CONST_B], const BOOL *constants, WORD constants_set) { - GLint tmp_loc; unsigned int i; - char tmp_name[10]; - const char *prefix; struct list* ptr; - prefix = shader_glsl_get_prefix(shader->reg_maps.shader_version.type); - - /* TODO: Benchmark and see if it would be beneficial to store the - * locations of the constants to avoid looking up each time */ for (i = 0; constants_set; constants_set >>= 1, ++i) { if (!(constants_set & 1)) continue; - TRACE_(d3d_constants)("Loading constants %i: %i;\n", i, constants[i]); - - /* TODO: Benchmark and see if it would be beneficial to store the - * locations of the constants to avoid looking up each time */ - snprintf(tmp_name, sizeof(tmp_name), "%s_b[%i]", prefix, i); - tmp_loc = GL_EXTCALL(glGetUniformLocationARB(programId, tmp_name)); - GL_EXTCALL(glUniform1ivARB(tmp_loc, 1, &constants[i])); + GL_EXTCALL(glUniform1ivARB(locations[i], 1, &constants[i])); } /* Load immediate constants */ @@ -699,15 +681,10 @@ static void shader_glsl_load_constantsB(const struct wined3d_shader *shader, con unsigned int idx = lconst->idx; const GLint *values = (const GLint *)lconst->value; - TRACE_(d3d_constants)("Loading local constants %i: %i\n", idx, values[0]); - - snprintf(tmp_name, sizeof(tmp_name), "%s_b[%i]", prefix, idx); - tmp_loc = GL_EXTCALL(glGetUniformLocationARB(programId, tmp_name)); - GL_EXTCALL(glUniform1ivARB(tmp_loc, 1, values)); + GL_EXTCALL(glUniform1ivARB(locations[idx], 1, values)); ptr = list_next(&shader->constantsB, ptr); } - - checkGLcall("shader_glsl_load_constantsB()"); + checkGLcall("glUniform1ivARB()"); } static void reset_program_constant_version(struct wine_rb_entry *entry, void *context) @@ -762,7 +739,6 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context float position_fixup[4]; DWORD update_mask = 0; - GLhandleARB programId; struct glsl_shader_prog_link *prog = ctx_data->glsl_program; UINT constant_version; int i; @@ -771,7 +747,6 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context /* No GLSL program set - nothing to do. */ return; } - programId = prog->programId; constant_version = prog->constant_version; update_mask = context->constant_update_mask & prog->constant_update_mask; @@ -784,7 +759,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context vshader->reg_maps.integer_constants); if (update_mask & WINED3D_SHADER_CONST_VS_B) - shader_glsl_load_constantsB(vshader, gl_info, programId, state->vs_consts_b, + shader_glsl_load_constantsB(vshader, gl_info, prog->vs.uniform_b_locations, state->vs_consts_b, vshader->reg_maps.boolean_constants); if (update_mask & WINED3D_SHADER_CONST_VS_POS_FIXUP) @@ -803,7 +778,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context pshader->reg_maps.integer_constants); if (update_mask & WINED3D_SHADER_CONST_PS_B) - shader_glsl_load_constantsB(pshader, gl_info, programId, state->ps_consts_b, + shader_glsl_load_constantsB(pshader, gl_info, prog->ps.uniform_b_locations, state->ps_consts_b, pshader->reg_maps.boolean_constants); if (update_mask & WINED3D_SHADER_CONST_PS_BUMP_ENV) @@ -862,6 +837,15 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context else GL_EXTCALL(glUniform4fARB(prog->ps.specular_enable_location, 0.0f, 0.0f, 0.0f, 0.0f)); + for (i = 0; i < MAX_TEXTURES; ++i) + { + if (prog->ps.tss_constant_location[i] == -1) + continue; + + D3DCOLORTOGLFLOAT4(state->texture_states[i][WINED3D_TSS_CONSTANT], col); + GL_EXTCALL(glUniform4fvARB(prog->ps.tss_constant_location[i], 1, col)); + } + checkGLcall("fixed function uniforms"); } @@ -1064,7 +1048,8 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont for (i = 0; i < WINED3D_MAX_CBS; ++i) { if (reg_maps->cb_sizes[i]) - shader_addline(buffer, "uniform vec4 %s_cb%u[%u];\n", prefix, i, reg_maps->cb_sizes[i]); + shader_addline(buffer, "layout(std140) uniform block_%s_cb%u { vec4 %s_cb%u[%u]; };\n", + prefix, i, prefix, i, reg_maps->cb_sizes[i]); } /* Declare texture samplers */ @@ -1237,7 +1222,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont { float ycorrection[] = { - context->render_offscreen ? 0.0f : fb->render_targets[0]->resource.height, + context->render_offscreen ? 0.0f : fb->render_targets[0]->height, context->render_offscreen ? 1.0f : -1.0f, 0.0f, 0.0f, @@ -2316,6 +2301,7 @@ static void shader_glsl_binop(const struct wined3d_shader_instruction *ins) case WINED3DSIH_AND: op = "&"; break; case WINED3DSIH_DIV: op = "/"; break; case WINED3DSIH_IADD: op = "+"; break; + case WINED3DSIH_ISHL: op = "<<"; break; case WINED3DSIH_MUL: op = "*"; break; case WINED3DSIH_SUB: op = "-"; break; case WINED3DSIH_USHR: op = ">>"; break; @@ -4054,6 +4040,8 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins) shader_glsl_add_dst_param(ins, &ins->dst[0], &dst_param); if (ins->ctx->reg_maps->shader_version.major >= 2) { + if (ins->ctx->reg_maps->shader_version.major >= 4) + FIXME("SM4 discard not implemented.\n"); /* 2.0 shaders compare all 4 components in texkill */ shader_addline(ins->ctx->buffer, "if (any(lessThan(%s.xyzw, vec4(0.0)))) discard;\n", dst_param.reg_name); } else { @@ -4466,6 +4454,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context * nvidia drivers write a warning if we don't do so. */ if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); if (gl_info->supported[EXT_GPU_SHADER4]) shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); @@ -4519,6 +4509,8 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n"); + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); if (gl_info->supported[EXT_GPU_SHADER4]) shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); @@ -4592,6 +4584,8 @@ static GLhandleARB shader_glsl_generate_geometry_shader(const struct wined3d_con shader_addline(buffer, "#extension GL_ARB_geometry_shader4 : enable\n"); if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n"); + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); if (gl_info->supported[EXT_GPU_SHADER4]) shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); @@ -5077,17 +5071,16 @@ static const char *shader_glsl_get_ffp_fragment_op_arg(struct wined3d_shader_buf break; case WINED3DTA_CONSTANT: - FIXME("Per-stage constants not implemented.\n"); switch (stage) { - case 0: ret = "const0"; break; - case 1: ret = "const1"; break; - case 2: ret = "const2"; break; - case 3: ret = "const3"; break; - case 4: ret = "const4"; break; - case 5: ret = "const5"; break; - case 6: ret = "const6"; break; - case 7: ret = "const7"; break; + case 0: ret = "tss_const0"; break; + case 1: ret = "tss_const1"; break; + case 2: ret = "tss_const2"; break; + case 3: ret = "tss_const3"; break; + case 4: ret = "tss_const4"; break; + case 5: ret = "tss_const5"; break; + case 6: ret = "tss_const6"; break; + case 7: ret = "tss_const7"; break; default: ret = ""; break; @@ -5278,8 +5271,8 @@ static void shader_glsl_ffp_fragment_op(struct wined3d_shader_buffer *buffer, un static GLuint shader_glsl_generate_ffp_fragment_shader(struct wined3d_shader_buffer *buffer, const struct ffp_frag_settings *settings, const struct wined3d_gl_info *gl_info) { + BYTE lum_map = 0, bump_map = 0, tex_map = 0, tss_const_map = 0; BOOL tempreg_used = FALSE, tfactor_used = FALSE; - BYTE lum_map = 0, bump_map = 0, tex_map = 0; const char *final_combiner_src = "ret"; UINT lowest_disabled_stage; GLhandleARB shader_obj; @@ -5306,6 +5299,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct wined3d_shader_buf tempreg_used = TRUE; if (settings->op[stage].dst == tempreg) tempreg_used = TRUE; + if (arg0 == WINED3DTA_CONSTANT || arg1 == WINED3DTA_CONSTANT || arg2 == WINED3DTA_CONSTANT) + tss_const_map |= 1 << stage; switch (settings->op[stage].cop) { @@ -5341,6 +5336,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct wined3d_shader_buf tfactor_used = TRUE; if (arg0 == WINED3DTA_TEMP || arg1 == WINED3DTA_TEMP || arg2 == WINED3DTA_TEMP) tempreg_used = TRUE; + if (arg0 == WINED3DTA_CONSTANT || arg1 == WINED3DTA_CONSTANT || arg2 == WINED3DTA_CONSTANT) + tss_const_map |= 1 << stage; } lowest_disabled_stage = stage; @@ -5357,6 +5354,9 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct wined3d_shader_buf for (stage = 0; stage < MAX_TEXTURES; ++stage) { + if (tss_const_map & (1 << stage)) + shader_addline(buffer, "uniform vec4 tss_const%u;\n", stage); + if (!(tex_map & (1 << stage))) continue; @@ -5684,6 +5684,12 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info * vs->uniform_i_locations[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); } + for (i = 0; i < MAX_CONST_B; ++i) + { + snprintf(name, sizeof(name), "vs_b[%u]", i); + vs->uniform_b_locations[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); + } + vs->pos_fixup_location = GL_EXTCALL(glGetUniformLocationARB(program_id, "posFixup")); } @@ -5709,6 +5715,12 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info * ps->uniform_i_locations[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); } + for (i = 0; i < MAX_CONST_B; ++i) + { + snprintf(name, sizeof(name), "ps_b[%u]", i); + ps->uniform_b_locations[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); + } + for (i = 0; i < MAX_TEXTURES; ++i) { snprintf(name, sizeof(name), "bumpenv_mat%u", i); @@ -5717,6 +5729,8 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info * ps->bumpenv_lum_scale_location[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); snprintf(name, sizeof(name), "bumpenv_lum_offset%u", i); ps->bumpenv_lum_offset_location[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); + snprintf(name, sizeof(name), "tss_const%u", i); + ps->tss_constant_location[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name)); } ps->tex_factor_location = GL_EXTCALL(glGetUniformLocationARB(program_id, "tex_factor")); @@ -5725,6 +5739,26 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info * ps->ycorrection_location = GL_EXTCALL(glGetUniformLocationARB(program_id, "ycorrection")); } +static void shader_glsl_init_uniform_block_bindings(const struct wined3d_gl_info *gl_info, GLhandleARB program_id, + const struct wined3d_shader_reg_maps *reg_maps, unsigned int base, unsigned int count) +{ + const char *prefix = shader_glsl_get_prefix(reg_maps->shader_version.type); + GLuint block_idx; + unsigned int i; + char name[16]; + + for (i = 0; i < count; ++i) + { + if (!reg_maps->cb_sizes[i]) + continue; + + snprintf(name, sizeof(name), "block_%s_cb%u", prefix, i); + block_idx = GL_EXTCALL(glGetUniformBlockIndex(program_id, name)); + GL_EXTCALL(glUniformBlockBinding(program_id, block_idx, base + i)); + } + checkGLcall("glUniformBlockBinding"); +} + /* Context activation is done by the caller. */ static void set_glsl_shader_program(const struct wined3d_context *context, const struct wined3d_state *state, struct shader_glsl_priv *priv, struct glsl_context_data *ctx_data) @@ -5955,8 +5989,15 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const if (vshader->reg_maps.boolean_constants) entry->constant_update_mask |= WINED3D_SHADER_CONST_VS_B; entry->constant_update_mask |= WINED3D_SHADER_CONST_VS_POS_FIXUP; + + shader_glsl_init_uniform_block_bindings(gl_info, programId, &vshader->reg_maps, + 0, gl_info->limits.vertex_uniform_blocks); } + if (gshader) + shader_glsl_init_uniform_block_bindings(gl_info, programId, &gshader->reg_maps, + gl_info->limits.vertex_uniform_blocks, gl_info->limits.geometry_uniform_blocks); + if (ps_id) { if (pshader) @@ -5968,6 +6009,10 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_B; if (entry->ps.ycorrection_location != -1) entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_Y_CORR; + + shader_glsl_init_uniform_block_bindings(gl_info, programId, &pshader->reg_maps, + gl_info->limits.vertex_uniform_blocks + gl_info->limits.geometry_uniform_blocks, + gl_info->limits.fragment_uniform_blocks); } else { @@ -5995,7 +6040,7 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info, GLhandleARB vshader_id, pshader_id; const char *blt_pshader; - static const char *blt_vshader = + static const char blt_vshader[] = "#version 120\n" "void main(void)\n" "{\n" @@ -6537,7 +6582,8 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s if (gl_info->supported[EXT_GPU_SHADER4] && gl_info->supported[ARB_SHADER_BIT_ENCODING] && gl_info->supported[ARB_GEOMETRY_SHADER4] && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50) - && gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX] && gl_info->supported[ARB_DRAW_INSTANCED]) + && gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX] && gl_info->supported[ARB_DRAW_INSTANCED] + && gl_info->supported[ARB_TEXTURE_RG]) shader_model = 4; /* ARB_shader_texture_lod or EXT_gpu_shader4 is required for the SM3 * texldd and texldl instructions. */ @@ -6566,7 +6612,10 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s * the shader will generate incorrect results too. Unfortunately, GL deliberately doesn't * offer a way to query this. */ - caps->ps_1x_max_value = 8.0; + if (shader_model >= 4) + caps->ps_1x_max_value = FLT_MAX; + else + caps->ps_1x_max_value = 1024.0f; /* Ideally we'd only set caps like sRGB writes here if supported by both * the shader backend and the fragment pipe, but we can get called before @@ -6618,6 +6667,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_DEFB */ shader_glsl_nop, /* WINED3DSIH_DEFI */ shader_glsl_nop, /* WINED3DSIH_DIV */ shader_glsl_binop, + /* WINED3DSIH_DP2 */ shader_glsl_dot, /* WINED3DSIH_DP2ADD */ shader_glsl_dp2add, /* WINED3DSIH_DP3 */ shader_glsl_dot, /* WINED3DSIH_DP4 */ shader_glsl_dot, @@ -6641,6 +6691,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_IFC */ shader_glsl_ifc, /* WINED3DSIH_IGE */ shader_glsl_relop, /* WINED3DSIH_IMUL */ shader_glsl_imul, + /* WINED3DSIH_ISHL */ shader_glsl_binop, /* WINED3DSIH_ITOF */ shader_glsl_to_float, /* WINED3DSIH_LABEL */ shader_glsl_label, /* WINED3DSIH_LD */ NULL, @@ -7021,7 +7072,8 @@ static void glsl_fragment_pipe_get_caps(const struct wined3d_gl_info *gl_info, s { caps->wined3d_caps = WINED3D_FRAGMENT_CAP_PROJ_CONTROL | WINED3D_FRAGMENT_CAP_SRGB_WRITE; - caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_TSSARGTEMP; + caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_TSSARGTEMP + | WINED3DPMISCCAPS_PERSTAGECONSTANT; caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE | WINED3DTEXOPCAPS_SELECTARG1 | WINED3DTEXOPCAPS_SELECTARG2 @@ -7247,6 +7299,14 @@ static const struct StateEntryTemplate glsl_fragment_pipe_state_template[] = {STATE_TEXTURESTAGE(5,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(6,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(7,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, + {STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_SPECULARENABLE), {STATE_RENDER(WINED3D_RS_SPECULARENABLE), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, {0 /* Terminate */, {0, 0 }, WINED3D_GL_EXT_NONE }, }; diff --git a/reactos/dll/directx/wine/wined3d/palette.c b/reactos/dll/directx/wine/wined3d/palette.c index b78249a6aff..15599da008d 100644 --- a/reactos/dll/directx/wine/wined3d/palette.c +++ b/reactos/dll/directx/wine/wined3d/palette.c @@ -39,10 +39,7 @@ ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette) TRACE("%p decreasing refcount to %u.\n", palette, refcount); if (!refcount) - { - DeleteObject(palette->hpal); HeapFree(GetProcessHeap(), 0, palette); - } return refcount; } @@ -50,32 +47,46 @@ ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette) HRESULT CDECL wined3d_palette_get_entries(const struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries) { + unsigned int i; TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n", palette, flags, start, count, entries); if (flags) return WINED3DERR_INVALIDCALL; /* unchecked */ - if (start > palette->palNumEntries || count > palette->palNumEntries - start) + if (start > palette->size || count > palette->size - start) return WINED3DERR_INVALIDCALL; if (palette->flags & WINED3D_PALETTE_8BIT_ENTRIES) { BYTE *entry = (BYTE *)entries; - unsigned int i; for (i = start; i < count + start; ++i) - *entry++ = palette->palents[i].peRed; + *entry++ = palette->colors[i].rgbRed; } else - memcpy(entries, palette->palents + start, count * sizeof(*entries)); + { + for (i = 0; i < count; ++i) + { + entries[i].peRed = palette->colors[i + start].rgbRed; + entries[i].peGreen = palette->colors[i + start].rgbGreen; + entries[i].peBlue = palette->colors[i + start].rgbBlue; + entries[i].peFlags = palette->colors[i + start].rgbReserved; + } + } return WINED3D_OK; } +void CDECL wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HDC dc) +{ + if (SetDIBColorTable(dc, 0, 256, palette->colors) != 256) + ERR("Failed to set DIB color table.\n"); +} + HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries) { - struct wined3d_resource *resource; + unsigned int i; TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n", palette, flags, start, count, entries); @@ -84,40 +95,31 @@ HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette, if (palette->flags & WINED3D_PALETTE_8BIT_ENTRIES) { const BYTE *entry = (const BYTE *)entries; - unsigned int i; for (i = start; i < count + start; ++i) - palette->palents[i].peRed = *entry++; + palette->colors[i].rgbRed = *entry++; } else { - memcpy(palette->palents + start, entries, count * sizeof(*palette->palents)); + for (i = 0; i < count; ++i) + { + palette->colors[i + start].rgbRed = entries[i].peRed; + palette->colors[i + start].rgbGreen = entries[i].peGreen; + palette->colors[i + start].rgbBlue = entries[i].peBlue; + palette->colors[i + start].rgbReserved = entries[i].peFlags; + } /* When WINEDDCAPS_ALLOW256 isn't set we need to override entry 0 with black and 255 with white */ if (!(palette->flags & WINED3D_PALETTE_ALLOW_256)) { TRACE("WINED3D_PALETTE_ALLOW_256 not set, overriding palette entry 0 with black and 255 with white.\n"); - palette->palents[0].peRed = 0; - palette->palents[0].peGreen = 0; - palette->palents[0].peBlue = 0; - - palette->palents[255].peRed = 255; - palette->palents[255].peGreen = 255; - palette->palents[255].peBlue = 255; - } - - if (palette->hpal) - SetPaletteEntries(palette->hpal, start, count, palette->palents + start); - } + palette->colors[0].rgbRed = 0; + palette->colors[0].rgbGreen = 0; + palette->colors[0].rgbBlue = 0; - /* If the palette is attached to the render target, update all render targets */ - LIST_FOR_EACH_ENTRY(resource, &palette->device->resources, struct wined3d_resource, resource_list_entry) - { - if (resource->type == WINED3D_RTYPE_SURFACE) - { - struct wined3d_surface *surface = surface_from_resource(resource); - if (surface->palette == palette) - surface->surface_ops->surface_realize_palette(surface); + palette->colors[255].rgbRed = 255; + palette->colors[255].rgbGreen = 255; + palette->colors[255].rgbBlue = 255; } } @@ -132,19 +134,11 @@ static HRESULT wined3d_palette_init(struct wined3d_palette *palette, struct wine palette->ref = 1; palette->device = device; palette->flags = flags; - - palette->palNumEntries = entry_count; - palette->hpal = CreatePalette((const LOGPALETTE *)&palette->palVersion); - if (!palette->hpal) - { - WARN("Failed to create palette.\n"); - return E_FAIL; - } + palette->size = entry_count; if (FAILED(hr = wined3d_palette_set_entries(palette, 0, 0, entry_count, entries))) { WARN("Failed to set palette entries, hr %#x.\n", hr); - DeleteObject(palette->hpal); return hr; } diff --git a/reactos/dll/directx/wine/wined3d/query.c b/reactos/dll/directx/wine/wined3d/query.c index 6ebb53c7eac..443626b82db 100644 --- a/reactos/dll/directx/wine/wined3d/query.c +++ b/reactos/dll/directx/wine/wined3d/query.c @@ -293,19 +293,23 @@ HRESULT CDECL wined3d_query_issue(struct wined3d_query *query, DWORD flags) return query->query_ops->query_issue(query, flags); } +static void fill_query_data(void *out, unsigned int out_size, const void *result, unsigned int result_size) +{ + memcpy(out, result, min(out_size, result_size)); +} + static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query, - void *pData, DWORD dwSize, DWORD flags) + void *data, DWORD size, DWORD flags) { struct wined3d_occlusion_query *oq = query->extendedData; struct wined3d_device *device = query->device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_context *context; - DWORD* data = pData; GLuint available; GLuint samples; HRESULT res; - TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, flags %#x.\n", query, pData, dwSize, flags); + TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags); if (!oq->context) query->state = QUERY_CREATED; @@ -314,7 +318,8 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query, { /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */ TRACE("Query wasn't yet started, returning S_OK\n"); - if(data) *data = 0; + samples = 0; + fill_query_data(data, size, &samples, sizeof(samples)); return S_OK; } @@ -328,14 +333,16 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query, if (!gl_info->supported[ARB_OCCLUSION_QUERY]) { WARN("%p Occlusion queries not supported. Returning 1.\n", query); - *data = 1; + samples = 1; + fill_query_data(data, size, &samples, sizeof(samples)); return S_OK; } if (oq->context->tid != GetCurrentThreadId()) { FIXME("%p Wrong thread, returning 1.\n", query); - *data = 1; + samples = 1; + fill_query_data(data, size, &samples, sizeof(samples)); return S_OK; } @@ -347,12 +354,12 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query, if (available) { - if (data) + if (size) { GL_EXTCALL(glGetQueryObjectuivARB(oq->id, GL_QUERY_RESULT_ARB, &samples)); checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)"); TRACE("Returning %d samples.\n", samples); - *data = samples; + fill_query_data(data, size, &samples, sizeof(samples)); } res = S_OK; } @@ -367,19 +374,20 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query, } static HRESULT wined3d_event_query_ops_get_data(struct wined3d_query *query, - void *pData, DWORD dwSize, DWORD flags) + void *data, DWORD size, DWORD flags) { struct wined3d_event_query *event_query = query->extendedData; - BOOL *data = pData; + BOOL signaled; enum wined3d_event_query_result ret; - TRACE("query %p, pData %p, dwSize %#x, flags %#x.\n", query, pData, dwSize, flags); + TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags); - if (!pData || !dwSize) return S_OK; + if (!data || !size) return S_OK; if (!event_query) { WARN("Event query not supported by GL, reporting GPU idle.\n"); - *data = TRUE; + signaled = TRUE; + fill_query_data(data, size, &signaled, sizeof(signaled)); return S_OK; } @@ -388,16 +396,19 @@ static HRESULT wined3d_event_query_ops_get_data(struct wined3d_query *query, { case WINED3D_EVENT_QUERY_OK: case WINED3D_EVENT_QUERY_NOT_STARTED: - *data = TRUE; + signaled = TRUE; + fill_query_data(data, size, &signaled, sizeof(signaled)); break; case WINED3D_EVENT_QUERY_WAITING: - *data = FALSE; + signaled = FALSE; + fill_query_data(data, size, &signaled, sizeof(signaled)); break; case WINED3D_EVENT_QUERY_WRONG_THREAD: FIXME("(%p) Wrong thread, reporting GPU idle.\n", query); - *data = TRUE; + signaled = TRUE; + fill_query_data(data, size, &signaled, sizeof(signaled)); break; case WINED3D_EVENT_QUERY_ERROR: @@ -408,6 +419,13 @@ static HRESULT wined3d_event_query_ops_get_data(struct wined3d_query *query, return S_OK; } +void * CDECL wined3d_query_get_parent(const struct wined3d_query *query) +{ + TRACE("query %p.\n", query); + + return query->parent; +} + enum wined3d_query_type CDECL wined3d_query_get_type(const struct wined3d_query *query) { TRACE("query %p.\n", query); @@ -532,12 +550,11 @@ static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query, struct wined3d_device *device = query->device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_context *context; - UINT64 *u64data = data; GLuint available; GLuint64 timestamp; HRESULT res; - TRACE("(%p) : type D3DQUERY_TIMESTAMP, data %p, size %#x, flags %#x.\n", query, data, size, flags); + TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags); if (!tq->context) query->state = QUERY_CREATED; @@ -546,16 +563,16 @@ static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query, { /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves. */ TRACE("Query wasn't yet started, returning S_OK.\n"); - if (u64data) - *u64data = 0; + timestamp = 0; + fill_query_data(data, size, ×tamp, sizeof(timestamp)); return S_OK; } if (tq->context->tid != GetCurrentThreadId()) { FIXME("%p Wrong thread, returning 1.\n", query); - if (u64data) - *u64data = 1; + timestamp = 1; + fill_query_data(data, size, ×tamp, sizeof(timestamp)); return S_OK; } @@ -567,12 +584,12 @@ static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query, if (available) { - if (u64data) + if (size) { GL_EXTCALL(glGetQueryObjectui64v(tq->id, GL_QUERY_RESULT_ARB, ×tamp)); checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)"); TRACE("Returning timestamp %s.\n", wine_dbgstr_longlong(timestamp)); - *u64data = timestamp; + fill_query_data(data, size, ×tamp, sizeof(timestamp)); } res = S_OK; } @@ -627,11 +644,11 @@ static HRESULT wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DW static HRESULT wined3d_timestamp_disjoint_query_ops_get_data(struct wined3d_query *query, void *data, DWORD size, DWORD flags) { - TRACE("(%p) : type D3DQUERY_TIMESTAMP_DISJOINT, data %p, size %#x, flags %#x.\n", query, data, size, flags); + TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags); if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT) { - struct wined3d_query_data_timestamp_disjoint *disjoint_data = data; + static const struct wined3d_query_data_timestamp_disjoint disjoint_data = {FALSE, 1000 * 1000 * 1000}; if (query->state == QUERY_BUILDING) { @@ -639,18 +656,13 @@ static HRESULT wined3d_timestamp_disjoint_query_ops_get_data(struct wined3d_quer return S_FALSE; } - if (disjoint_data) - { - disjoint_data->disjoint = FALSE; - disjoint_data->frequency = 1000 * 1000 * 1000; - } + fill_query_data(data, size, &disjoint_data, sizeof(disjoint_data)); } else { - UINT64 *u64data = data; + static const UINT64 freq = 1000 * 1000 * 1000; - if (u64data) - *u64data = 1000 * 1000 * 1000; + fill_query_data(data, size, &freq, sizeof(freq)); } return S_OK; } @@ -691,10 +703,13 @@ static const struct wined3d_query_ops timestamp_disjoint_query_ops = wined3d_timestamp_disjoint_query_ops_issue, }; -static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *device, enum wined3d_query_type type) +static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *device, + enum wined3d_query_type type, void *parent) { const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + query->parent = parent; + switch (type) { case WINED3D_QUERY_TYPE_OCCLUSION: @@ -790,7 +805,7 @@ static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *de } HRESULT CDECL wined3d_query_create(struct wined3d_device *device, - enum wined3d_query_type type, struct wined3d_query **query) + enum wined3d_query_type type, void *parent, struct wined3d_query **query) { struct wined3d_query *object; HRESULT hr; @@ -801,8 +816,7 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, if (!object) return E_OUTOFMEMORY; - hr = query_init(object, device, type); - if (FAILED(hr)) + if (FAILED(hr = query_init(object, device, type, parent))) { WARN("Failed to initialize query, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); diff --git a/reactos/dll/directx/wine/wined3d/resource.c b/reactos/dll/directx/wine/wined3d/resource.c index d65cc2944de..9b73bfcacf7 100644 --- a/reactos/dll/directx/wine/wined3d/resource.c +++ b/reactos/dll/directx/wine/wined3d/resource.c @@ -24,6 +24,7 @@ #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); +WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); static DWORD resource_access_from_pool(enum wined3d_pool pool) { @@ -49,14 +50,23 @@ static void resource_check_usage(DWORD usage) { static const DWORD handled = WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL + | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_AUTOGENMIPMAP | WINED3DUSAGE_STATICDECL | WINED3DUSAGE_OVERLAY | WINED3DUSAGE_TEXTURE; + /* WINED3DUSAGE_WRITEONLY is supposed to result in write-combined mappings + * being returned. OpenGL doesn't give us explicit control over that, but + * the hints and access flags we set for typical access patterns on + * dynamic resources should in theory have the same effect on the OpenGL + * driver. */ + if (usage & ~handled) FIXME("Unhandled usage flags %#x.\n", usage & ~handled); + if ((usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY)) == WINED3DUSAGE_DYNAMIC) + WARN_(d3d_perf)("WINED3DUSAGE_DYNAMIC used without WINED3DUSAGE_WRITEONLY.\n"); } HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device, @@ -98,6 +108,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * resource->parent = parent; resource->parent_ops = parent_ops; resource->resource_ops = resource_ops; + resource->map_binding = WINED3D_LOCATION_SYSMEM; if (size) { @@ -155,15 +166,23 @@ void resource_unload(struct wined3d_resource *resource) resource, resource->type); } -DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority) +DWORD CDECL wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority) { - DWORD prev = resource->priority; + DWORD prev; + + if (resource->pool != WINED3D_POOL_MANAGED) + { + WARN("Called on non-managed resource %p, ignoring.\n", resource); + return 0; + } + + prev = resource->priority; resource->priority = priority; TRACE("resource %p, new priority %u, returning old priority %u.\n", resource, priority, prev); return prev; } -DWORD resource_get_priority(const struct wined3d_resource *resource) +DWORD CDECL wined3d_resource_get_priority(const struct wined3d_resource *resource) { TRACE("resource %p, returning %u.\n", resource, resource->priority); return resource->priority; @@ -279,3 +298,34 @@ GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) return GL_WRITE_ONLY_ARB; return GL_READ_WRITE_ARB; } + +BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) +{ + struct wined3d_swapchain *swapchain; + + /* Only texture resources can be onscreen. */ + if (resource->type != WINED3D_RTYPE_TEXTURE) + return TRUE; + + /* Not on a swapchain - must be offscreen */ + if (!(swapchain = wined3d_texture_from_resource(resource)->swapchain)) + return TRUE; + + /* The front buffer is always onscreen */ + if (resource == &swapchain->front_buffer->resource) + return FALSE; + + /* If the swapchain is rendered to an FBO, the backbuffer is + * offscreen, otherwise onscreen */ + return swapchain->render_to_fbo; +} + +void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) +{ + if (!wined3d_resource_is_offscreen(resource) || wined3d_settings.offscreen_rendering_mode != ORM_FBO) + resource->draw_binding = WINED3D_LOCATION_DRAWABLE; + else if (resource->multisample_type) + resource->draw_binding = WINED3D_LOCATION_RB_MULTISAMPLE; + else + resource->draw_binding = WINED3D_LOCATION_TEXTURE_RGB; +} diff --git a/reactos/dll/directx/wine/wined3d/shader.c b/reactos/dll/directx/wine/wined3d/shader.c index eb6264a15b1..2bb945df0c4 100644 --- a/reactos/dll/directx/wine/wined3d/shader.c +++ b/reactos/dll/directx/wine/wined3d/shader.c @@ -55,6 +55,7 @@ static const char * const shader_opcode_names[] = /* WINED3DSIH_DEFB */ "defb", /* WINED3DSIH_DEFI */ "defi", /* WINED3DSIH_DIV */ "div", + /* WINED3DSIH_DP2 */ "dp2", /* WINED3DSIH_DP2ADD */ "dp2add", /* WINED3DSIH_DP3 */ "dp3", /* WINED3DSIH_DP4 */ "dp4", @@ -78,6 +79,7 @@ static const char * const shader_opcode_names[] = /* WINED3DSIH_IFC */ "ifc", /* WINED3DSIH_IGE */ "ige", /* WINED3DSIH_IMUL */ "imul", + /* WINED3DSIH_ISHL */ "ishl", /* WINED3DSIH_ITOF */ "itof", /* WINED3DSIH_LABEL */ "label", /* WINED3DSIH_LD */ "ld", @@ -1144,7 +1146,7 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, if (write_mask && write_mask != WINED3DSP_WRITEMASK_ALL) { - static const char *write_mask_chars = "xyzw"; + static const char write_mask_chars[] = "xyzw"; TRACE("."); if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]); @@ -1200,7 +1202,7 @@ void shader_dump_src_param(const struct wined3d_shader_src_param *param, if (swizzle != WINED3DSP_NOSWIZZLE) { - static const char *swizzle_chars = "xyzw"; + static const char swizzle_chars[] = "xyzw"; DWORD swizzle_x = swizzle & 0x03; DWORD swizzle_y = (swizzle >> 2) & 0x03; DWORD swizzle_z = (swizzle >> 4) & 0x03; @@ -2027,8 +2029,8 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */ if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && state->render_states[WINED3D_RS_SRGBWRITEENABLE]) { - const struct wined3d_surface *rt = state->fb->render_targets[0]; - if (rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE) + const struct wined3d_format *rt_format = state->fb->render_targets[0]->format; + if (rt_format->flags & WINED3DFMT_FLAG_SRGB_WRITE) { static unsigned int warned = 0; diff --git a/reactos/dll/directx/wine/wined3d/shader_sm4.c b/reactos/dll/directx/wine/wined3d/shader_sm4.c index c09d0bbab24..7a25e0235b0 100644 --- a/reactos/dll/directx/wine/wined3d/shader_sm4.c +++ b/reactos/dll/directx/wine/wined3d/shader_sm4.c @@ -24,7 +24,7 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode); #define WINED3D_SM4_INSTRUCTION_MODIFIER (1 << 31) #define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT 24 -#define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0xf << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT) +#define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0x1f << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT) #define WINED3D_SM4_PRIMITIVE_TYPE_SHIFT 11 #define WINED3D_SM4_PRIMITIVE_TYPE_MASK (0x7 << WINED3D_SM4_PRIMITIVE_TYPE_SHIFT) @@ -75,7 +75,9 @@ enum wined3d_sm4_opcode WINED3D_SM4_OP_CUT = 0x09, WINED3D_SM4_OP_DERIV_RTX = 0x0b, WINED3D_SM4_OP_DERIV_RTY = 0x0c, + WINED3D_SM4_OP_DISCARD = 0x0d, WINED3D_SM4_OP_DIV = 0x0e, + WINED3D_SM4_OP_DP2 = 0x0f, WINED3D_SM4_OP_DP3 = 0x10, WINED3D_SM4_OP_DP4 = 0x11, WINED3D_SM4_OP_EMIT = 0x13, @@ -91,6 +93,7 @@ enum wined3d_sm4_opcode WINED3D_SM4_OP_IEQ = 0x20, WINED3D_SM4_OP_IGE = 0x21, WINED3D_SM4_OP_IMUL = 0x26, + WINED3D_SM4_OP_ISHL = 0x29, WINED3D_SM4_OP_ITOF = 0x2b, WINED3D_SM4_OP_LD = 0x2d, WINED3D_SM4_OP_LOG = 0x2f, @@ -209,7 +212,9 @@ static const struct wined3d_sm4_opcode_info opcode_table[] = {WINED3D_SM4_OP_CUT, WINED3DSIH_CUT, "", ""}, {WINED3D_SM4_OP_DERIV_RTX, WINED3DSIH_DSX, "F", "F"}, {WINED3D_SM4_OP_DERIV_RTY, WINED3DSIH_DSY, "F", "F"}, + {WINED3D_SM4_OP_DISCARD, WINED3DSIH_TEXKILL, "", "U"}, {WINED3D_SM4_OP_DIV, WINED3DSIH_DIV, "F", "FF"}, + {WINED3D_SM4_OP_DP2, WINED3DSIH_DP2, "F", "FF"}, {WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, "F", "FF"}, {WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, "F", "FF"}, {WINED3D_SM4_OP_EMIT, WINED3DSIH_EMIT, "", ""}, @@ -225,6 +230,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] = {WINED3D_SM4_OP_IEQ, WINED3DSIH_IEQ, "U", "II"}, {WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, "U", "II"}, {WINED3D_SM4_OP_IMUL, WINED3DSIH_IMUL, "II", "II"}, + {WINED3D_SM4_OP_ISHL, WINED3DSIH_ISHL, "I", "II"}, {WINED3D_SM4_OP_ITOF, WINED3DSIH_ITOF, "F", "I"}, {WINED3D_SM4_OP_LD, WINED3DSIH_LD, "U", "FR"}, {WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, "F", "F"}, diff --git a/reactos/dll/directx/wine/wined3d/state.c b/reactos/dll/directx/wine/wined3d/state.c index 327f153bb2b..17162acb405 100644 --- a/reactos/dll/directx/wine/wined3d/state.c +++ b/reactos/dll/directx/wine/wined3d/state.c @@ -373,7 +373,7 @@ static GLenum gl_blend_factor(enum wined3d_blend factor, const struct wined3d_fo static void state_blend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - const struct wined3d_surface *target = state->fb->render_targets[0]; + const struct wined3d_format *rt_format = state->fb->render_targets[0]->format; const struct wined3d_gl_info *gl_info = context->gl_info; GLenum srcBlend, dstBlend; enum wined3d_blend d3d_blend; @@ -387,8 +387,7 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st /* Disable blending in all cases even without pixelshaders. * With blending on we could face a big performance penalty. * The d3d9 visual test confirms the behavior. */ - if (context->render_offscreen - && !(target->resource.format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) + if (context->render_offscreen && !(rt_format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) { gl_info->gl_ops.gl.p_glDisable(GL_BLEND); checkGLcall("glDisable GL_BLEND"); @@ -424,9 +423,8 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st } else { - srcBlend = gl_blend_factor(d3d_blend, target->resource.format); - dstBlend = gl_blend_factor(state->render_states[WINED3D_RS_DESTBLEND], - target->resource.format); + srcBlend = gl_blend_factor(d3d_blend, rt_format); + dstBlend = gl_blend_factor(state->render_states[WINED3D_RS_DESTBLEND], rt_format); } if (state->render_states[WINED3D_RS_EDGEANTIALIAS] @@ -476,9 +474,8 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st } else { - srcBlendAlpha = gl_blend_factor(d3d_blend, target->resource.format); - dstBlendAlpha = gl_blend_factor(state->render_states[WINED3D_RS_DESTBLENDALPHA], - target->resource.format); + srcBlendAlpha = gl_blend_factor(d3d_blend, rt_format); + dstBlendAlpha = gl_blend_factor(state->render_states[WINED3D_RS_DESTBLENDALPHA], rt_format); } GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend, dstBlend, srcBlendAlpha, dstBlendAlpha)); @@ -1760,7 +1757,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3 if (state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS] || state->render_states[WINED3D_RS_DEPTHBIAS]) { - const struct wined3d_surface *depth = state->fb->depth_stencil; + const struct wined3d_rendertarget_view *depth = state->fb->depth_stencil; float scale; union @@ -1785,7 +1782,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3 { if (depth) { - const struct wined3d_format *fmt = depth->resource.format; + const struct wined3d_format *fmt = depth->format; scale = powf(2, fmt->depth_size) - 1; TRACE("Depth format %s, using depthbias scale of %.8e.\n", debug_d3dformat(fmt->id), scale); @@ -4198,13 +4195,32 @@ static void load_numbered_arrays(struct wined3d_context *context, break; case WINED3DFMT_R16G16_FLOAT: - /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4 - * byte float according to the IEEE standard - */ - FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n"); + if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM]) + { + /* Not supported by GL_ARB_half_float_vertex. */ + GL_EXTCALL(glVertexAttrib2hvNV(i, (const GLhalfNV *)ptr)); + } + else + { + float x = float_16_to_32(((const unsigned short *)ptr) + 0); + float y = float_16_to_32(((const unsigned short *)ptr) + 1); + GL_EXTCALL(glVertexAttrib2fARB(i, x, y)); + } break; case WINED3DFMT_R16G16B16A16_FLOAT: - FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n"); + if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM]) + { + /* Not supported by GL_ARB_half_float_vertex. */ + GL_EXTCALL(glVertexAttrib4hvNV(i, (const GLhalfNV *)ptr)); + } + else + { + float x = float_16_to_32(((const unsigned short *)ptr) + 0); + float y = float_16_to_32(((const unsigned short *)ptr) + 1); + float z = float_16_to_32(((const unsigned short *)ptr) + 2); + float w = float_16_to_32(((const unsigned short *)ptr) + 3); + GL_EXTCALL(glVertexAttrib4fARB(i, x, y, z, w)); + } break; default: @@ -4629,14 +4645,14 @@ void vertexdeclaration(struct wined3d_context *context, const struct wined3d_sta static void viewport_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - const struct wined3d_surface *target = state->fb->render_targets[0]; + const struct wined3d_rendertarget_view *target = state->fb->render_targets[0]; const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_viewport vp = state->viewport; - if (vp.width > target->resource.width) - vp.width = target->resource.width; - if (vp.height > target->resource.height) - vp.height = target->resource.height; + if (vp.width > target->width) + vp.width = target->width; + if (vp.height > target->height) + vp.height = target->height; gl_info->gl_ops.gl.p_glDepthRange(vp.min_z, vp.max_z); checkGLcall("glDepthRange"); @@ -4650,7 +4666,7 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine { UINT width, height; - target->get_drawable_size(context, &width, &height); + surface_get_drawable_size(wined3d_rendertarget_view_get_surface(target), context, &width, &height); gl_info->gl_ops.gl.p_glViewport(vp.x, (height - (vp.y + vp.height)), vp.width, vp.height); } @@ -4809,11 +4825,11 @@ static void scissorrect(struct wined3d_context *context, const struct wined3d_st } else { - const struct wined3d_surface *target = state->fb->render_targets[0]; + const struct wined3d_rendertarget_view *target = state->fb->render_targets[0]; UINT height; UINT width; - target->get_drawable_size(context, &width, &height); + surface_get_drawable_size(wined3d_rendertarget_view_get_surface(target), context, &width, &height); gl_info->gl_ops.gl.p_glScissor(r->left, height - r->bottom, r->right - r->left, r->bottom - r->top); } checkGLcall("glScissor"); @@ -4876,19 +4892,76 @@ static void psorigin(struct wined3d_context *context, const struct wined3d_state void state_srgbwrite(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { + const struct wined3d_format *rt_format = state->fb->render_targets[0]->format; const struct wined3d_gl_info *gl_info = context->gl_info; - const struct wined3d_surface *rt = state->fb->render_targets[0]; TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); if (state->render_states[WINED3D_RS_SRGBWRITEENABLE] - && rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE) + && rt_format->flags & WINED3DFMT_FLAG_SRGB_WRITE) gl_info->gl_ops.gl.p_glEnable(GL_FRAMEBUFFER_SRGB); else gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB); } -const struct StateEntryTemplate misc_state_template[] = { +static void state_cb(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state, + enum wined3d_shader_type type, unsigned int base, unsigned int count) +{ + struct wined3d_buffer *buffer; + unsigned int i; + + for (i = 0; i < count; ++i) + { + buffer = state->cb[type][i]; + GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i, buffer ? buffer->buffer_object : 0)); + } + checkGLcall("glBindBufferBase"); +} + +static void state_cb_vs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + const struct wined3d_gl_limits *limits = &context->gl_info->limits; + + TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); + + state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_VERTEX, 0, limits->vertex_uniform_blocks); +} + +static void state_cb_gs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + const struct wined3d_gl_limits *limits = &context->gl_info->limits; + + TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); + + state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_GEOMETRY, + limits->vertex_uniform_blocks, limits->geometry_uniform_blocks); +} + +static void state_cb_ps(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + const struct wined3d_gl_limits *limits = &context->gl_info->limits; + + TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); + + state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_PIXEL, + limits->vertex_uniform_blocks + limits->geometry_uniform_blocks, limits->fragment_uniform_blocks); +} + +static void state_cb_warn(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); + + WARN("Constant buffers (%s) no supported.\n", debug_d3dstate(state_id)); +} + +const struct StateEntryTemplate misc_state_template[] = +{ + { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), state_cb_vs, }, ARB_UNIFORM_BUFFER_OBJECT }, + { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), state_cb_warn, }, WINED3D_GL_EXT_NONE }, + { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY),state_cb_gs, }, ARB_UNIFORM_BUFFER_OBJECT }, + { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY),state_cb_warn, }, WINED3D_GL_EXT_NONE }, + { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), state_cb_ps, }, ARB_UNIFORM_BUFFER_OBJECT }, + { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), state_cb_warn, }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_SRCBLEND), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_DESTBLEND), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), state_blend }, WINED3D_GL_EXT_NONE }, @@ -5083,7 +5156,7 @@ const struct StateEntryTemplate misc_state_template[] = { {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE }, }; -const struct StateEntryTemplate vp_ffp_states[] = +static const struct StateEntryTemplate vp_ffp_states[] = { { STATE_VDECL, { STATE_VDECL, vertexdeclaration }, WINED3D_GL_EXT_NONE }, { STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), { STATE_VDECL, NULL }, WINED3D_GL_EXT_NONE }, @@ -5817,6 +5890,9 @@ static void validate_state_table(struct StateEntry *state_table) STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY), STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), + STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), + STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY), + STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), STATE_VIEWPORT, STATE_LIGHT_TYPE, STATE_SCISSORRECT, diff --git a/reactos/dll/directx/wine/wined3d/stateblock.c b/reactos/dll/directx/wine/wined3d/stateblock.c index d76f6d6d6b7..3228c0f5b8d 100644 --- a/reactos/dll/directx/wine/wined3d/stateblock.c +++ b/reactos/dll/directx/wine/wined3d/stateblock.c @@ -537,6 +537,11 @@ void state_cleanup(struct wined3d_state *state) if (!(state->flags & WINED3D_STATE_NO_REF)) state_unbind_resources(state); + for (counter = 0; counter < MAX_ACTIVE_LIGHTS; ++counter) + { + state->lights[counter] = NULL; + } + for (counter = 0; counter < LIGHTMAP_SIZE; ++counter) { struct list *e1, *e2; @@ -1114,6 +1119,8 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d TRACE("state %p, gl_info %p.\n", state, gl_info); + state->gl_primitive_type = ~0u; + /* Set some of the defaults for lights, transforms etc */ state->transforms[WINED3D_TS_PROJECTION] = identity; state->transforms[WINED3D_TS_VIEW] = identity; diff --git a/reactos/dll/directx/wine/wined3d/surface.c b/reactos/dll/directx/wine/wined3d/surface.c index b995b359478..5f1bc101ded 100644 --- a/reactos/dll/directx/wine/wined3d/surface.c +++ b/reactos/dll/directx/wine/wined3d/surface.c @@ -101,70 +101,43 @@ static void surface_cleanup(struct wined3d_surface *surface) resource_cleanup(&surface->resource); } -void surface_update_draw_binding(struct wined3d_surface *surface) +void wined3d_surface_destroy(struct wined3d_surface *surface) { - if (!surface_is_offscreen(surface) || wined3d_settings.offscreen_rendering_mode != ORM_FBO) - surface->draw_binding = WINED3D_LOCATION_DRAWABLE; - else if (surface->resource.multisample_type) - surface->draw_binding = WINED3D_LOCATION_RB_MULTISAMPLE; - else - surface->draw_binding = WINED3D_LOCATION_TEXTURE_RGB; + TRACE("surface %p.\n", surface); + + surface_cleanup(surface); + surface->resource.parent_ops->wined3d_object_destroyed(surface->resource.parent); + HeapFree(GetProcessHeap(), 0, surface); } -void surface_set_swapchain(struct wined3d_surface *surface, struct wined3d_swapchain *swapchain) +void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context, + unsigned int *width, unsigned int *height) { - TRACE("surface %p, swapchain %p.\n", surface, swapchain); - - if (swapchain) + if (surface->container->swapchain) { - surface->get_drawable_size = get_drawable_size_swapchain; + /* The drawable size of an onscreen drawable is the surface size. + * (Actually: The window size, but the surface is created in window + * size.) */ + *width = context->current_rt->resource.width; + *height = context->current_rt->resource.height; } - else + else if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) { - switch (wined3d_settings.offscreen_rendering_mode) - { - case ORM_FBO: - surface->get_drawable_size = get_drawable_size_fbo; - break; - - case ORM_BACKBUFFER: - surface->get_drawable_size = get_drawable_size_backbuffer; - break; + const struct wined3d_swapchain *swapchain = context->swapchain; - default: - ERR("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode); - return; - } + /* The drawable size of a backbuffer / aux buffer offscreen target is + * the size of the current context's drawable, which is the size of + * the back buffer of the swapchain the active context belongs to. */ + *width = swapchain->desc.backbuffer_width; + *height = swapchain->desc.backbuffer_height; } - - surface->swapchain = swapchain; - surface_update_draw_binding(surface); -} - -void surface_set_container(struct wined3d_surface *surface, struct wined3d_texture *container) -{ - TRACE("surface %p, container %p.\n", surface, container); - - if (!surface->swapchain) + else { - switch (wined3d_settings.offscreen_rendering_mode) - { - case ORM_FBO: - surface->get_drawable_size = get_drawable_size_fbo; - break; - - case ORM_BACKBUFFER: - surface->get_drawable_size = get_drawable_size_backbuffer; - break; - - default: - ERR("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode); - return; - } + /* The drawable size of an FBO target is the OpenGL texture size, + * which is the power of two size. */ + *width = context->current_rt->pow2Width; + *height = context->current_rt->pow2Height; } - - surface->container = container; - surface_update_draw_binding(surface); } struct blt_info @@ -496,8 +469,6 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface) /* Now allocate a DC. */ surface->hDC = CreateCompatibleDC(0); SelectObject(surface->hDC, surface->dib.DIBsection); - TRACE("Using wined3d palette %p.\n", surface->palette); - SelectPalette(surface->hDC, surface->palette ? surface->palette->hpal : 0, FALSE); surface->flags |= SFLAG_DIBSECTION; @@ -587,7 +558,7 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface) void surface_prepare_map_memory(struct wined3d_surface *surface) { - switch (surface->map_binding) + switch (surface->resource.map_binding) { case WINED3D_LOCATION_SYSMEM: surface_prepare_system_memory(surface); @@ -608,7 +579,7 @@ void surface_prepare_map_memory(struct wined3d_surface *surface) break; default: - ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->map_binding)); + ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding)); } } @@ -669,8 +640,6 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface) TRACE("surface %p.\n", surface); - surface->texture_target = GL_TEXTURE_2D; - /* Non-power2 support */ if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] || gl_info->supported[ARB_TEXTURE_RECTANGLE]) @@ -731,85 +700,15 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface) surface->pow2Width, surface->pow2Height); } - switch (wined3d_settings.offscreen_rendering_mode) - { - case ORM_FBO: - surface->get_drawable_size = get_drawable_size_fbo; - break; - - case ORM_BACKBUFFER: - surface->get_drawable_size = get_drawable_size_backbuffer; - break; - - default: - ERR("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode); - return WINED3DERR_INVALIDCALL; - } - if (surface->resource.usage & WINED3DUSAGE_DEPTHSTENCIL) surface->locations = WINED3D_LOCATION_DISCARDED; if (surface_use_pbo(surface)) - surface->map_binding = WINED3D_LOCATION_BUFFER; + surface->resource.map_binding = WINED3D_LOCATION_BUFFER; return WINED3D_OK; } -static void surface_realize_palette(struct wined3d_surface *surface) -{ - struct wined3d_palette *palette = surface->palette; - - TRACE("surface %p.\n", surface); - - if (!palette) return; - - if (surface->resource.format->id == WINED3DFMT_P8_UINT - || surface->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM) - { - if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET) - { - /* Make sure the texture is up to date. This call doesn't do - * anything if the texture is already up to date. */ - surface_load_location(surface, WINED3D_LOCATION_TEXTURE_RGB); - - /* We want to force a palette refresh, so mark the drawable as not being up to date */ - if (!surface_is_offscreen(surface)) - surface_invalidate_location(surface, WINED3D_LOCATION_DRAWABLE); - } - else - { - if (!(surface->locations & surface->map_binding)) - { - TRACE("Palette changed with surface that does not have an up to date system memory copy.\n"); - surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - } - surface_invalidate_location(surface, ~surface->map_binding); - } - } - - if (surface->flags & SFLAG_DIBSECTION) - { - RGBQUAD col[256]; - unsigned int i; - - TRACE("Updating the DC's palette.\n"); - - for (i = 0; i < 256; ++i) - { - col[i].rgbRed = palette->palents[i].peRed; - col[i].rgbGreen = palette->palents[i].peGreen; - col[i].rgbBlue = palette->palents[i].peBlue; - col[i].rgbReserved = 0; - } - SetDIBColorTable(surface->hDC, 0, 256, col); - } - - /* Propagate the changes to the drawable when we have a palette. */ - if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET) - surface_load_location(surface, surface->draw_binding); -} - static void surface_unmap(struct wined3d_surface *surface) { struct wined3d_device *device = surface->resource.device; @@ -820,7 +719,7 @@ static void surface_unmap(struct wined3d_surface *surface) memset(&surface->lockedRect, 0, sizeof(surface->lockedRect)); - switch (surface->map_binding) + switch (surface->resource.map_binding) { case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_USER_MEMORY: @@ -839,7 +738,7 @@ static void surface_unmap(struct wined3d_surface *surface) break; default: - ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->map_binding)); + ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding)); } if (surface->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB)) @@ -848,8 +747,8 @@ static void surface_unmap(struct wined3d_surface *surface) return; } - if (surface->swapchain && surface->swapchain->front_buffer == surface) - surface_load_location(surface, surface->draw_binding); + if (surface->container->swapchain && surface->container->swapchain->front_buffer == surface->container) + surface_load_location(surface, surface->container->resource.draw_binding); else if (surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) FIXME("Depth / stencil buffer locking is not implemented.\n"); } @@ -1067,7 +966,7 @@ static void surface_blt_fbo(const struct wined3d_device *device, enum wined3d_te if (wined3d_settings.strict_draw_ordering || (dst_location == WINED3D_LOCATION_DRAWABLE - && dst_surface->swapchain->front_buffer == dst_surface)) + && dst_surface->container->swapchain->front_buffer == dst_surface->container)) gl_info->gl_ops.gl.p_glFlush(); context_release(context); @@ -1116,16 +1015,18 @@ static BOOL surface_convert_color_to_float(const struct wined3d_surface *surface DWORD color, struct wined3d_color *float_color) { const struct wined3d_format *format = surface->resource.format; - const struct wined3d_device *device = surface->resource.device; + const struct wined3d_palette *palette; switch (format->id) { case WINED3DFMT_P8_UINT: - if (surface->palette) + palette = surface->container->swapchain ? surface->container->swapchain->palette : NULL; + + if (palette) { - float_color->r = surface->palette->palents[color].peRed / 255.0f; - float_color->g = surface->palette->palents[color].peGreen / 255.0f; - float_color->b = surface->palette->palents[color].peBlue / 255.0f; + float_color->r = palette->colors[color].rgbRed / 255.0f; + float_color->g = palette->colors[color].rgbGreen / 255.0f; + float_color->b = palette->colors[color].rgbBlue / 255.0f; } else { @@ -1133,7 +1034,7 @@ static BOOL surface_convert_color_to_float(const struct wined3d_surface *surface float_color->g = 0.0f; float_color->b = 0.0f; } - float_color->a = swapchain_is_p8(device->swapchains[0]) ? color / 255.0f : 1.0f; + float_color->a = color / 255.0f; break; case WINED3DFMT_B5G6R5_UNORM: @@ -1199,7 +1100,7 @@ static BOOL surface_convert_depth_to_float(const struct wined3d_surface *surface static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const RECT *rect, float depth) { - const struct wined3d_resource *resource = &surface->resource; + const struct wined3d_resource *resource = &surface->container->resource; struct wined3d_device *device = resource->device; const struct blit_shader *blitter; @@ -1255,6 +1156,16 @@ static void surface_remove_pbo(struct wined3d_surface *surface, const struct win surface_invalidate_location(surface, WINED3D_LOCATION_BUFFER); } +static ULONG surface_resource_incref(struct wined3d_resource *resource) +{ + return wined3d_surface_incref(surface_from_resource(resource)); +} + +static ULONG surface_resource_decref(struct wined3d_resource *resource) +{ + return wined3d_surface_decref(surface_from_resource(resource)); +} + static void surface_unload(struct wined3d_resource *resource) { struct wined3d_surface *surface = surface_from_resource(resource); @@ -1290,8 +1201,8 @@ static void surface_unload(struct wined3d_resource *resource) else { surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - surface_invalidate_location(surface, ~surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); } surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED); @@ -1333,13 +1244,14 @@ static void surface_unload(struct wined3d_resource *resource) static const struct wined3d_resource_ops surface_resource_ops = { + surface_resource_incref, + surface_resource_decref, surface_unload, }; static const struct wined3d_surface_ops surface_ops = { surface_private_setup, - surface_realize_palette, surface_unmap, }; @@ -1375,7 +1287,7 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface) hr = surface_create_dib_section(surface); if (FAILED(hr)) return hr; - surface->map_binding = WINED3D_LOCATION_DIB; + surface->resource.map_binding = WINED3D_LOCATION_DIB; /* We don't mind the nonpow2 stuff in GDI. */ surface->pow2Width = surface->resource.width; @@ -1384,45 +1296,13 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface) return WINED3D_OK; } -static void gdi_surface_realize_palette(struct wined3d_surface *surface) -{ - struct wined3d_palette *palette = surface->palette; - - TRACE("surface %p.\n", surface); - - if (!palette) return; - - if (surface->flags & SFLAG_DIBSECTION) - { - RGBQUAD col[256]; - unsigned int i; - - TRACE("Updating the DC's palette.\n"); - - for (i = 0; i < 256; ++i) - { - col[i].rgbRed = palette->palents[i].peRed; - col[i].rgbGreen = palette->palents[i].peGreen; - col[i].rgbBlue = palette->palents[i].peBlue; - col[i].rgbReserved = 0; - } - SetDIBColorTable(surface->hDC, 0, 256, col); - } - - /* Update the image because of the palette change. Some games like e.g. - * Red Alert call SetEntries a lot to implement fading. */ - /* Tell the swapchain to update the screen. */ - if (surface->swapchain && surface == surface->swapchain->front_buffer) - x11_copy_to_screen(surface->swapchain, NULL); -} - static void gdi_surface_unmap(struct wined3d_surface *surface) { TRACE("surface %p.\n", surface); /* Tell the swapchain to update the screen. */ - if (surface->swapchain && surface == surface->swapchain->front_buffer) - x11_copy_to_screen(surface->swapchain, &surface->lockedRect); + if (surface->container->swapchain && surface->container == surface->container->swapchain->front_buffer) + x11_copy_to_screen(surface->container->swapchain, &surface->lockedRect); memset(&surface->lockedRect, 0, sizeof(RECT)); } @@ -1430,30 +1310,9 @@ static void gdi_surface_unmap(struct wined3d_surface *surface) static const struct wined3d_surface_ops gdi_surface_ops = { gdi_surface_private_setup, - gdi_surface_realize_palette, gdi_surface_unmap, }; -void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) -{ - TRACE("surface %p, target %#x.\n", surface, target); - - if (surface->texture_target != target) - { - if (target == GL_TEXTURE_RECTANGLE_ARB) - { - surface->flags &= ~SFLAG_NORMCOORD; - } - else if (surface->texture_target == GL_TEXTURE_RECTANGLE_ARB) - { - surface->flags |= SFLAG_NORMCOORD; - } - } - surface->texture_target = target; - surface->texture_level = level; - surface_force_reload(surface); -} - /* This call just downloads data, the caller is responsible for binding the * correct texture. */ /* Context activation is done by the caller. */ @@ -1501,13 +1360,6 @@ static void surface_download_data(struct wined3d_surface *surface, const struct int src_pitch = 0; int dst_pitch = 0; - /* In case of P8 the index is stored in the alpha component if the primary render target uses P8. */ - if (format->id == WINED3DFMT_P8_UINT && swapchain_is_p8(surface->resource.device->swapchains[0])) - { - gl_format = GL_ALPHA; - gl_type = GL_UNSIGNED_BYTE; - } - if (surface->flags & SFLAG_NONPOW2) { unsigned char alignment = surface->resource.device->surface_alignment; @@ -1656,7 +1508,8 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi if (srgb) internal = format->glGammaInternal; - else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(surface)) + else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET + && wined3d_resource_is_offscreen(&surface->container->resource)) internal = format->rtInternal; else internal = format->glInternal; @@ -1763,17 +1616,15 @@ static HRESULT d3dfmt_get_conv(const struct wined3d_surface *surface, BOOL need_ * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which * conflicts with this. */ - if (!((blit_supported && surface->swapchain && surface == surface->swapchain->front_buffer)) + if (!((blit_supported && surface->container->swapchain + && surface->container == surface->container->swapchain->front_buffer)) || colorkey_active || !use_texturing) { format->glFormat = GL_RGBA; format->glInternal = GL_RGBA; format->glType = GL_UNSIGNED_BYTE; format->conv_byte_count = 4; - if (colorkey_active) - *conversion_type = WINED3D_CT_PALETTED_CK; - else - *conversion_type = WINED3D_CT_PALETTED; + *conversion_type = WINED3D_CT_PALETTED; } break; @@ -2001,17 +1852,12 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru GLenum internal; if (srgb) - { internal = format->glGammaInternal; - } - else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(surface)) - { + else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET + && wined3d_resource_is_offscreen(&surface->container->resource)) internal = format->rtInternal; - } else - { internal = format->glInternal; - } if (!internal) FIXME("No GL internal format for format %s.\n", debug_d3dformat(format->id)); @@ -2139,7 +1985,7 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) { - const struct wined3d_swapchain *swapchain = surface->swapchain; + const struct wined3d_swapchain *swapchain = surface->container->swapchain; TRACE("surface %p.\n", surface); @@ -2149,7 +1995,7 @@ GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) return GL_NONE; } - if (swapchain->back_buffers && swapchain->back_buffers[0] == surface) + if (swapchain->back_buffers && swapchain->back_buffers[0] == surface->container) { if (swapchain->render_to_fbo) { @@ -2159,7 +2005,7 @@ GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) TRACE("Returning GL_BACK\n"); return GL_BACK; } - else if (surface == swapchain->front_buffer) + else if (surface->container == swapchain->front_buffer) { TRACE("Returning GL_FRONT\n"); return GL_FRONT; @@ -2194,8 +2040,8 @@ void surface_load(struct wined3d_surface *surface, BOOL srgb) * the surface. Make sure we have it. */ surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - surface_invalidate_location(surface, ~surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); /* Switching color keying on / off may change the internal format. */ if (ck_changed) surface_force_reload(surface); @@ -2279,59 +2125,16 @@ static inline unsigned short float_32_to_16(const float *in) ULONG CDECL wined3d_surface_incref(struct wined3d_surface *surface) { - ULONG refcount; - - TRACE("surface %p, swapchain %p, container %p.\n", - surface, surface->swapchain, surface->container); - - if (surface->swapchain) - return wined3d_swapchain_incref(surface->swapchain); - - if (surface->container) - return wined3d_texture_incref(surface->container); - - refcount = InterlockedIncrement(&surface->resource.ref); - TRACE("%p increasing refcount to %u.\n", surface, refcount); + TRACE("surface %p, container %p.\n", surface, surface->container); - return refcount; + return wined3d_texture_incref(surface->container); } ULONG CDECL wined3d_surface_decref(struct wined3d_surface *surface) { - ULONG refcount; - - TRACE("surface %p, swapchain %p, container %p.\n", - surface, surface->swapchain, surface->container); - - if (surface->swapchain) - return wined3d_swapchain_decref(surface->swapchain); - - if (surface->container) - return wined3d_texture_decref(surface->container); - - refcount = InterlockedDecrement(&surface->resource.ref); - TRACE("%p decreasing refcount to %u.\n", surface, refcount); - - if (!refcount) - { - surface_cleanup(surface); - surface->resource.parent_ops->wined3d_object_destroyed(surface->resource.parent); - - TRACE("Destroyed surface %p.\n", surface); - HeapFree(GetProcessHeap(), 0, surface); - } + TRACE("surface %p, container %p.\n", surface, surface->container); - return refcount; -} - -DWORD CDECL wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD priority) -{ - return resource_set_priority(&surface->resource, priority); -} - -DWORD CDECL wined3d_surface_get_priority(const struct wined3d_surface *surface) -{ - return resource_get_priority(&surface->resource); + return wined3d_texture_decref(surface->container); } void CDECL wined3d_surface_preload(struct wined3d_surface *surface) @@ -2409,31 +2212,9 @@ HRESULT CDECL wined3d_surface_restore(struct wined3d_surface *surface) return WINED3D_OK; } -void CDECL wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette) -{ - TRACE("surface %p, palette %p.\n", surface, palette); - - if (surface->palette == palette) - { - TRACE("Nop palette change.\n"); - return; - } - - surface->palette = palette; - if (palette) - surface->surface_ops->surface_realize_palette(surface); -} - -struct wined3d_palette * CDECL wined3d_surface_get_palette(const struct wined3d_surface *surface) -{ - TRACE("surface %p.\n", surface); - - return surface->palette; -} - DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface) { - const struct wined3d_format *format = surface->resource.format; + unsigned int alignment; DWORD pitch; TRACE("surface %p.\n", surface); @@ -2441,19 +2222,9 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface) if (surface->pitch) return surface->pitch; - if (format->flags & WINED3DFMT_FLAG_BLOCKS) - { - /* Since compressed formats are block based, pitch means the amount of - * bytes to the next row of block rather than the next row of pixels. */ - UINT row_block_count = (surface->resource.width + format->block_width - 1) / format->block_width; - pitch = row_block_count * format->block_byte_count; - } - else - { - unsigned char alignment = surface->resource.device->surface_alignment; - pitch = surface->resource.format->byte_count * surface->resource.width; /* Bytes / row */ - pitch = (pitch + alignment - 1) & ~(alignment - 1); - } + alignment = surface->resource.device->surface_alignment; + pitch = wined3d_format_calculate_pitch(surface->resource.format, surface->resource.width); + pitch = (pitch + alignment - 1) & ~(alignment - 1); TRACE("Returning %u.\n", pitch); @@ -2599,6 +2370,7 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_format *format = wined3d_get_format(gl_info, format_id); UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1); + struct wined3d_texture *texture; BOOL create_dib = FALSE; HRESULT hr; DWORD valid_location = 0; @@ -2656,7 +2428,7 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface, surface->user_memory = mem; if (surface->user_memory) { - surface->map_binding = WINED3D_LOCATION_USER_MEMORY; + surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY; valid_location = WINED3D_LOCATION_USER_MEMORY; } surface->pitch = pitch; @@ -2672,8 +2444,15 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface, * If the surface didn't use PBOs previously but could now, don't * change it - whatever made us not use PBOs might come back, e.g. * color keys. */ - if (surface->map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface)) - surface->map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM; + if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface)) + surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM; + + texture = surface->container; + texture->resource.format = format; + texture->resource.multisample_type = multisample_type; + texture->resource.multisample_quality = multisample_quality; + texture->resource.width = width; + texture->resource.height = height; if (create_dib) { @@ -3068,7 +2847,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, * mapped regularly do not throw away the system memory copy. This avoids * the need to download the surface from OpenGL all the time. The surface * is still downloaded if the OpenGL texture is changed. */ - if (!(surface->flags & SFLAG_DYNLOCK) && surface->map_binding == WINED3D_LOCATION_SYSMEM) + if (!(surface->flags & SFLAG_DYNLOCK) && surface->resource.map_binding == WINED3D_LOCATION_SYSMEM) { if (++surface->lockCount > MAXLOCKCOUNT) { @@ -3081,21 +2860,21 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, if (flags & WINED3D_MAP_DISCARD) { TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n", - wined3d_debug_location(surface->map_binding)); - surface_validate_location(surface, surface->map_binding); + wined3d_debug_location(surface->resource.map_binding)); + surface_validate_location(surface, surface->resource.map_binding); } else { if (surface->resource.usage & WINED3DUSAGE_DYNAMIC) WARN_(d3d_perf)("Mapping a dynamic surface without WINED3D_MAP_DISCARD.\n"); - surface_load_location(surface, surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); } if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY))) - surface_invalidate_location(surface, ~surface->map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); - switch (surface->map_binding) + switch (surface->resource.map_binding) { case WINED3D_LOCATION_SYSMEM: base_memory = surface->resource.heap_memory; @@ -3122,7 +2901,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, break; default: - ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->map_binding)); + ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding)); base_memory = NULL; } @@ -3193,52 +2972,15 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc) hr = surface_create_dib_section(surface); if (FAILED(hr)) return WINED3DERR_INVALIDCALL; - if (!(surface->map_binding == WINED3D_LOCATION_USER_MEMORY + if (!(surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY || surface->flags & SFLAG_PIN_SYSMEM || surface->pbo)) - surface->map_binding = WINED3D_LOCATION_DIB; + surface->resource.map_binding = WINED3D_LOCATION_DIB; } surface_load_location(surface, WINED3D_LOCATION_DIB); surface_invalidate_location(surface, ~WINED3D_LOCATION_DIB); - if (surface->resource.format->id == WINED3DFMT_P8_UINT - || surface->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM) - { - /* GetDC on palettized formats is unsupported in D3D9, and the method - * is missing in D3D8, so this should only be used for DX <=7 - * surfaces (with non-device palettes). */ - const PALETTEENTRY *pal = NULL; - - if (surface->palette) - { - pal = surface->palette->palents; - } - else - { - struct wined3d_swapchain *swapchain = surface->resource.device->swapchains[0]; - struct wined3d_surface *dds_primary = swapchain->front_buffer; - - if (dds_primary && dds_primary->palette) - pal = dds_primary->palette->palents; - } - - if (pal) - { - RGBQUAD col[256]; - unsigned int i; - - for (i = 0; i < 256; ++i) - { - col[i].rgbRed = pal[i].peRed; - col[i].rgbGreen = pal[i].peGreen; - col[i].rgbBlue = pal[i].peBlue; - col[i].rgbReserved = 0; - } - SetDIBColorTable(surface->hDC, 0, 256, col); - } - } - surface->flags |= SFLAG_DCINUSE; surface->resource.map_count++; @@ -3265,8 +3007,19 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc) surface->resource.map_count--; surface->flags &= ~SFLAG_DCINUSE; - if (surface->map_binding == WINED3D_LOCATION_USER_MEMORY) - surface_load_location(surface, WINED3D_LOCATION_USER_MEMORY); + if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY || (surface->flags & SFLAG_PIN_SYSMEM + && surface->resource.map_binding != WINED3D_LOCATION_DIB)) + { + /* The game Salammbo modifies the surface contents without mapping the surface between + * a GetDC/ReleaseDC operation and flipping the surface. If the DIB remains the active + * copy and is copied to the screen, this update, which draws the mouse pointer, is lost. + * Do not only copy the DIB to the map location, but also make sure the map location is + * copied back to the DIB in the next getdc call. + * + * The same consideration applies to user memory surfaces. */ + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, WINED3D_LOCATION_DIB); + } return WINED3D_OK; } @@ -3277,14 +3030,10 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc const struct wined3d_gl_info *gl_info; struct wined3d_context *context; BYTE *mem; - GLint fmt; - GLint type; BYTE *row, *top, *bottom; int i; - BOOL bpp; BOOL srcIsUpsideDown; struct wined3d_bo_address data; - UINT pitch = wined3d_surface_get_pitch(surface); surface_get_memory(surface, &data, dst_location); @@ -3296,7 +3045,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc * There is no need to keep track of the current read buffer or reset it, every part of the code * that reads sets the read buffer as desired. */ - if (surface_is_offscreen(surface)) + if (wined3d_resource_is_offscreen(&surface->container->resource)) { /* Mapping the primary render target which is not on a swapchain. * Read from the back buffer. */ @@ -3314,56 +3063,10 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc srcIsUpsideDown = FALSE; } - switch (surface->resource.format->id) - { - case WINED3DFMT_P8_UINT: - { - if (swapchain_is_p8(context->swapchain)) - { - /* In case of P8 render targets the index is stored in the alpha component */ - fmt = GL_ALPHA; - type = GL_UNSIGNED_BYTE; - mem = data.addr; - bpp = surface->resource.format->byte_count; - } - else - { - /* GL can't return palettized data, so read ARGB pixels into a - * separate block of memory and convert them into palettized format - * in software. Slow, but if the app means to use palettized render - * targets and locks it... - * - * Use GL_RGB, GL_UNSIGNED_BYTE to read the surface for performance reasons - * Don't use GL_BGR as in the WINED3DFMT_R8G8B8 case, instead watch out - * for the color channels when palettizing the colors. - */ - fmt = GL_RGB; - type = GL_UNSIGNED_BYTE; - pitch *= 3; - mem = HeapAlloc(GetProcessHeap(), 0, surface->resource.size * 3); - if (!mem) - { - ERR("Out of memory\n"); - return; - } - bpp = surface->resource.format->byte_count * 3; - } - } - break; - - default: - mem = data.addr; - fmt = surface->resource.format->glFormat; - type = surface->resource.format->glType; - bpp = surface->resource.format->byte_count; - } - if (data.buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, data.buffer_object)); checkGLcall("glBindBufferARB"); - if (mem) - ERR("mem not null for pbo -- unexpected\n"); } /* Setup pixel store pack state -- to glReadPixels into the correct place */ @@ -3372,109 +3075,55 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc gl_info->gl_ops.gl.p_glReadPixels(0, 0, surface->resource.width, surface->resource.height, - fmt, type, mem); + surface->resource.format->glFormat, + surface->resource.format->glType, data.addr); checkGLcall("glReadPixels"); /* Reset previous pixel store pack state */ gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, 0); checkGLcall("glPixelStorei"); - if (data.buffer_object && !srcIsUpsideDown) - { - /* Check if we need to flip the image. If we need to flip use glMapBufferARB - * to get a pointer to it and perform the flipping in software. This is a lot - * faster than calling glReadPixels for each line. In case we want more speed - * we should rerender it flipped in a FBO and read the data back from the FBO. */ - mem = GL_EXTCALL(glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB)); - checkGLcall("glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB)"); - } - - /* TODO: Merge this with the palettization loop below for P8 targets */ if (!srcIsUpsideDown) { - UINT len; /* glReadPixels returns the image upside down, and there is no way to prevent this. - Flip the lines in software */ - len = surface->resource.width * bpp; + * Flip the lines in software. */ + UINT pitch = wined3d_surface_get_pitch(surface); + + if (!(row = HeapAlloc(GetProcessHeap(), 0, pitch))) + goto error; - row = HeapAlloc(GetProcessHeap(), 0, len); - if (!row) + if (data.buffer_object) { - ERR("Out of memory\n"); - if (surface->resource.format->id == WINED3DFMT_P8_UINT) - HeapFree(GetProcessHeap(), 0, mem); - return; + mem = GL_EXTCALL(glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB)); + checkGLcall("glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB)"); } + else + mem = data.addr; top = mem; bottom = mem + pitch * (surface->resource.height - 1); for (i = 0; i < surface->resource.height / 2; i++) { - memcpy(row, top, len); - memcpy(top, bottom, len); - memcpy(bottom, row, len); + memcpy(row, top, pitch); + memcpy(top, bottom, pitch); + memcpy(bottom, row, pitch); top += pitch; bottom -= pitch; } HeapFree(GetProcessHeap(), 0, row); + + if (data.buffer_object) + GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB)); } +error: if (data.buffer_object) { - if (!srcIsUpsideDown) - GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB)); - GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0)); checkGLcall("glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0)"); } context_release(context); - - /* For P8 textures we need to perform an inverse palette lookup. This is - * done by searching for a palette index which matches the RGB value. - * Note this isn't guaranteed to work when there are multiple entries for - * the same color but we have no choice. In case of P8 render targets, - * the index is stored in the alpha component so no conversion is needed. */ - if (surface->resource.format->id == WINED3DFMT_P8_UINT && !swapchain_is_p8(context->swapchain)) - { - const PALETTEENTRY *pal = NULL; - DWORD width = pitch / 3; - int x, y, c; - - if (surface->palette) - { - pal = surface->palette->palents; - } - else - { - ERR("Palette is missing, cannot perform inverse palette lookup\n"); - HeapFree(GetProcessHeap(), 0, mem); - return; - } - - for (y = 0; y < surface->resource.height; y++) - { - for (x = 0; x < surface->resource.width; x++) - { - /* start lines pixels */ - const BYTE *blue = mem + y * pitch + x * (sizeof(BYTE) * 3); - const BYTE *green = blue + 1; - const BYTE *red = green + 1; - - for (c = 0; c < 256; c++) - { - if (*red == pal[c].peRed - && *green == pal[c].peGreen - && *blue == pal[c].peBlue) - { - *((BYTE *)data.addr + y * width + x) = c; - break; - } - } - } - } - HeapFree(GetProcessHeap(), 0, mem); - } } /* Read the framebuffer contents into a texture. Note that this function @@ -3495,7 +3144,7 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb) TRACE("Reading back offscreen render target %p.\n", surface); - if (surface_is_offscreen(surface)) + if (wined3d_resource_is_offscreen(&surface->container->resource)) gl_info->gl_ops.gl.p_glReadBuffer(device->offscreenBuffer); else gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(surface)); @@ -3580,58 +3229,6 @@ static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD colo && color <= color_key->color_space_high_value; } -void d3dfmt_p8_init_palette(const struct wined3d_surface *surface, BYTE table[256][4], BOOL colorkey) -{ - const struct wined3d_device *device = surface->resource.device; - const struct wined3d_palette *pal = surface->palette; - BOOL index_in_alpha = FALSE; - unsigned int i; - - /* Old games like StarCraft, C&C, Red Alert and others use P8 render targets. - * Reading back the RGB output each lockrect (each frame as they lock the whole screen) - * is slow. Further RGB->P8 conversion is not possible because palettes can have - * duplicate entries. Store the color key in the unused alpha component to speed the - * download up and to make conversion unneeded. */ - index_in_alpha = swapchain_is_p8(device->swapchains[0]); - - if (!pal) - { - FIXME("No palette set.\n"); - if (index_in_alpha) - { - /* Guarantees that memory representation remains correct after sysmem<->texture transfers even if - * there's no palette at this time. */ - for (i = 0; i < 256; i++) table[i][3] = i; - } - } - else - { - TRACE("Using surface palette %p\n", pal); - /* Get the surface's palette */ - for (i = 0; i < 256; ++i) - { - table[i][0] = pal->palents[i].peRed; - table[i][1] = pal->palents[i].peGreen; - table[i][2] = pal->palents[i].peBlue; - - /* When index_in_alpha is set the palette index is stored in the - * alpha component. In case of a readback we can then read - * GL_ALPHA. Color keying is handled in surface_blt_special() using a - * GL_ALPHA_TEST using GL_NOT_EQUAL. In case of index_in_alpha the - * color key itself is passed to glAlphaFunc in other cases the - * alpha component of pixels that should be masked away is set to 0. */ - if (index_in_alpha) - table[i][3] = i; - else if (colorkey && color_in_range(&surface->container->src_blt_color_key, i)) - table[i][3] = 0x00; - else if (pal->flags & WINED3D_PALETTE_ALPHA) - table[i][3] = pal->palents[i].peFlags; - else - table[i][3] = 0xff; - } - } -} - static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, enum wined3d_conversion_type conversion_type, struct wined3d_surface *surface) { @@ -3650,28 +3247,40 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI } case WINED3D_CT_PALETTED: - case WINED3D_CT_PALETTED_CK: - { - BYTE table[256][4]; - unsigned int x, y; - - d3dfmt_p8_init_palette(surface, table, (conversion_type == WINED3D_CT_PALETTED_CK)); - - for (y = 0; y < height; y++) + if (surface->container->swapchain && surface->container->swapchain->palette) { - source = src + pitch * y; - dest = dst + outpitch * y; - /* This is an 1 bpp format, using the width here is fine */ - for (x = 0; x < width; x++) { - BYTE color = *source++; - *dest++ = table[color][0]; - *dest++ = table[color][1]; - *dest++ = table[color][2]; - *dest++ = table[color][3]; + unsigned int x, y; + const struct wined3d_palette *palette = surface->container->swapchain->palette; + for (y = 0; y < height; y++) + { + source = src + pitch * y; + dest = dst + outpitch * y; + for (x = 0; x < width; x++) + { + BYTE color = *source++; + *dest++ = palette->colors[color].rgbRed; + *dest++ = palette->colors[color].rgbGreen; + *dest++ = palette->colors[color].rgbBlue; + *dest++ = 0; + } } } - } - break; + else + { + /* This should probably use the system palette, but unless + * the X server is running in P8 mode there is no such thing. + * The probably best solution is to set the fixed 20 colors + * from the default windows palette and set the rest to black, + * white, or some ugly pink. For now use black for the entire + * palette. Don't use pink everywhere. Age of Empires 2 draws + * a front buffer filled with zeroes without a palette when + * starting and we don't want the screen to flash in an ugly + * color. */ + FIXME("P8 surface loaded without a palette.\n"); + memset(dst, 0, height * outpitch); + } + + break; case WINED3D_CT_CK_565: { @@ -3902,7 +3511,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc /* Bind the target texture */ context_bind_texture(context, dst_surface->container->target, dst_surface->container->texture_rgb.name); - if (surface_is_offscreen(src_surface)) + if (wined3d_resource_is_offscreen(&src_surface->container->resource)) { TRACE("Reading from an offscreen target\n"); upsidedown = !upsidedown; @@ -4008,7 +3617,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st context_apply_blit_state(context, device); wined3d_texture_load(dst_surface->container, context, FALSE); - src_offscreen = surface_is_offscreen(src_surface); + src_offscreen = wined3d_resource_is_offscreen(&src_surface->container->resource); noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO; if (!noBackBufferBackup && !src_surface->container->texture_rgb.name) { @@ -4085,7 +3694,8 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st wined3d_gl_min_mip_filter(minMipLookup, filter, WINED3D_TEXF_NONE)); checkGLcall("glTexParameteri"); - if (!src_surface->swapchain || src_surface == src_surface->swapchain->back_buffers[0]) + if (!src_surface->container->swapchain + || src_surface->container == src_surface->container->swapchain->back_buffers[0]) { src = backup ? backup : src_surface->container->texture_rgb.name; } @@ -4264,7 +3874,7 @@ void surface_translate_drawable_coords(const struct wined3d_surface *surface, HW { UINT drawable_height; - if (surface->swapchain && surface == surface->swapchain->front_buffer) + if (surface->container->swapchain && surface->container == surface->container->swapchain->front_buffer) { POINT offset = {0, 0}; RECT windowsize; @@ -4307,7 +3917,7 @@ static void surface_blt_to_drawable(const struct wined3d_device *device, /* Activate the destination context, set it up for blitting */ context_apply_blit_state(context, device); - if (!surface_is_offscreen(dst_surface)) + if (!wined3d_resource_is_offscreen(&dst_surface->container->resource)) surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect); device->blitter->set_shader(device->blit_priv, context, src_surface); @@ -4317,11 +3927,10 @@ static void surface_blt_to_drawable(const struct wined3d_device *device, gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST); checkGLcall("glEnable(GL_ALPHA_TEST)"); - /* When the primary render target uses P8, the alpha component - * contains the palette index. Which means that the colorkey is one of - * the palette entries. In other cases pixels that should be masked - * away have alpha set to 0. */ - if (swapchain_is_p8(context->swapchain)) + /* For P8 surfaces, the alpha component contains the palette index. + * Which means that the colorkey is one of the palette entries. In + * other cases pixels that should be masked away have alpha set to 0. */ + if (src_surface->resource.format->id == WINED3DFMT_P8_UINT) gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, (float)src_surface->container->src_blt_color_key.color_space_low_value / 256.0f); else @@ -4346,7 +3955,8 @@ static void surface_blt_to_drawable(const struct wined3d_device *device, device->blitter->unset_shader(context->gl_info); if (wined3d_settings.strict_draw_ordering - || (dst_surface->swapchain && dst_surface->swapchain->front_buffer == dst_surface)) + || (dst_surface->container->swapchain + && dst_surface->container->swapchain->front_buffer == dst_surface->container)) gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ context_release(context); @@ -4373,6 +3983,7 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE enum wined3d_texture_filter_type filter) { struct wined3d_device *device = dst_surface->resource.device; + const struct wined3d_surface *rt = wined3d_rendertarget_view_get_surface(device->fb.render_targets[0]); const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_swapchain *src_swapchain, *dst_swapchain; @@ -4387,7 +3998,7 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE return WINED3DERR_INVALIDCALL; } - dst_swapchain = dst_surface->swapchain; + dst_swapchain = dst_surface->container->swapchain; if (src_surface) { @@ -4397,7 +4008,7 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE return WINED3DERR_INVALIDCALL; } - src_swapchain = src_surface->swapchain; + src_swapchain = src_surface->container->swapchain; } else { @@ -4405,9 +4016,7 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE } /* Early sort out of cases where no render target is used */ - if (!dst_swapchain && !src_swapchain - && src_surface != device->fb.render_targets[0] - && dst_surface != device->fb.render_targets[0]) + if (!dst_swapchain && !src_swapchain && src_surface != rt && dst_surface != rt) { TRACE("No surface is render target, not using hardware blit.\n"); return WINED3DERR_INVALIDCALL; @@ -4436,16 +4045,16 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE if (dst_swapchain) { /* Handled with regular texture -> swapchain blit */ - if (src_surface == device->fb.render_targets[0]) + if (src_surface == rt) TRACE("Blit from active render target to a swapchain\n"); } - else if (src_swapchain && dst_surface == device->fb.render_targets[0]) + else if (src_swapchain && dst_surface == rt) { FIXME("Implement blit from a swapchain to the active render target\n"); return WINED3DERR_INVALIDCALL; } - if ((src_swapchain || src_surface == device->fb.render_targets[0]) && !dst_swapchain) + if ((src_swapchain || src_surface == rt) && !dst_swapchain) { /* Blit from render target to texture */ BOOL stretchx; @@ -4543,8 +4152,8 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE src_surface->container->color_key_flags = old_color_key_flags; src_surface->container->src_blt_color_key = old_blt_key; - surface_validate_location(dst_surface, dst_surface->draw_binding); - surface_invalidate_location(dst_surface, ~dst_surface->draw_binding); + surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding); + surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding); return WINED3D_OK; } @@ -4719,7 +4328,8 @@ void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_co /* Note that we use depth_blt here as well, rather than glCopyTexImage2D * directly on the FBO texture. That's because we need to flip. */ context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, - context->swapchain->front_buffer, NULL, WINED3D_LOCATION_DRAWABLE); + surface_from_resource(wined3d_texture_get_sub_resource(context->swapchain->front_buffer, 0)), + NULL, WINED3D_LOCATION_DRAWABLE); if (surface->texture_target == GL_TEXTURE_RECTANGLE_ARB) { gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding); @@ -4765,7 +4375,8 @@ void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_co TRACE("Copying depth texture to onscreen depth buffer.\n"); context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, - context->swapchain->front_buffer, NULL, WINED3D_LOCATION_DRAWABLE); + surface_from_resource(wined3d_texture_get_sub_resource(context->swapchain->front_buffer, 0)), + NULL, WINED3D_LOCATION_DRAWABLE); surface_depth_blt(surface, context, surface->container->texture_rgb.name, 0, surface->pow2Height - h, w, h, surface->texture_target); checkGLcall("depth_blt"); @@ -4908,7 +4519,8 @@ static HRESULT surface_load_drawable(struct wined3d_surface *surface, { RECT r; - if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && surface_is_offscreen(surface)) + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO + && wined3d_resource_is_offscreen(&surface->container->resource)) { ERR("Trying to load offscreen surface into WINED3D_LOCATION_DRAWABLE.\n"); return WINED3DERR_INVALIDCALL; @@ -4936,7 +4548,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, BYTE *mem = NULL; if (wined3d_settings.offscreen_rendering_mode != ORM_FBO - && surface_is_offscreen(surface) + && wined3d_resource_is_offscreen(&surface->container->resource) && (surface->locations & WINED3D_LOCATION_DRAWABLE)) { surface_load_fb_texture(surface, srgb); @@ -4984,24 +4596,24 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, if (srgb) { - if ((surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | surface->map_binding)) + if ((surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | surface->resource.map_binding)) == WINED3D_LOCATION_TEXTURE_RGB) { /* Performance warning... */ FIXME("Downloading RGB surface %p to reload it as sRGB.\n", surface); surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); } } else { - if ((surface->locations & (WINED3D_LOCATION_TEXTURE_SRGB | surface->map_binding)) + if ((surface->locations & (WINED3D_LOCATION_TEXTURE_SRGB | surface->resource.map_binding)) == WINED3D_LOCATION_TEXTURE_SRGB) { /* Performance warning... */ FIXME("Downloading sRGB surface %p to reload it as RGB.\n", surface); surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); } } @@ -5037,12 +4649,12 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, TRACE("Removing the pbo attached to surface %p.\n", surface); if (surface->flags & SFLAG_DIBSECTION) - surface->map_binding = WINED3D_LOCATION_DIB; + surface->resource.map_binding = WINED3D_LOCATION_DIB; else - surface->map_binding = WINED3D_LOCATION_SYSMEM; + surface->resource.map_binding = WINED3D_LOCATION_SYSMEM; surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); surface_remove_pbo(surface, gl_info); } @@ -5129,7 +4741,8 @@ HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location) context_release(context); return WINED3D_OK; } - else if (location & surface->locations && surface->draw_binding != WINED3D_LOCATION_DRAWABLE) + else if (location & surface->locations + && surface->container->resource.draw_binding != WINED3D_LOCATION_DRAWABLE) { /* Already up to date, nothing to do. */ return WINED3D_OK; @@ -5200,22 +4813,6 @@ HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location) return WINED3D_OK; } -BOOL surface_is_offscreen(const struct wined3d_surface *surface) -{ - struct wined3d_swapchain *swapchain; - - /* Not on a swapchain - must be offscreen */ - if (!(swapchain = surface->swapchain)) - return TRUE; - - /* The front buffer is always onscreen */ - if (surface == swapchain->front_buffer) return FALSE; - - /* If the swapchain is rendered to an FBO, the backbuffer is - * offscreen, otherwise onscreen */ - return swapchain->render_to_fbo; -} - static HRESULT ffp_blit_alloc(struct wined3d_device *device) { return WINED3D_OK; } /* Context activation is done by the caller. */ static void ffp_blit_free(struct wined3d_device *device) { } @@ -5307,20 +4904,39 @@ static HRESULT ffp_blit_color_fill(struct wined3d_device *device, struct wined3d const RECT *dst_rect, const struct wined3d_color *color) { const RECT draw_rect = {0, 0, dst_surface->resource.width, dst_surface->resource.height}; - struct wined3d_fb_state fb = {&dst_surface, NULL}; + struct wined3d_rendertarget_view *view; + struct wined3d_fb_state fb = {&view, NULL}; + HRESULT hr; + + if (FAILED(hr = wined3d_rendertarget_view_create_from_surface(dst_surface, + NULL, &wined3d_null_parent_ops, &view))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return hr; + } device_clear_render_targets(device, 1, &fb, 1, dst_rect, &draw_rect, WINED3DCLEAR_TARGET, color, 0.0f, 0); + wined3d_rendertarget_view_decref(view); return WINED3D_OK; } -static HRESULT ffp_blit_depth_fill(struct wined3d_device *device, - struct wined3d_surface *surface, const RECT *rect, float depth) +static HRESULT ffp_blit_depth_fill(struct wined3d_device *device, struct wined3d_surface *dst_surface, + const RECT *dst_rect, float depth) { - const RECT draw_rect = {0, 0, surface->resource.width, surface->resource.height}; - struct wined3d_fb_state fb = {NULL, surface}; + const RECT draw_rect = {0, 0, dst_surface->resource.width, dst_surface->resource.height}; + struct wined3d_fb_state fb = {NULL, NULL}; + HRESULT hr; - device_clear_render_targets(device, 0, &fb, 1, rect, &draw_rect, WINED3DCLEAR_ZBUFFER, 0, depth, 0); + if (FAILED(hr = wined3d_rendertarget_view_create_from_surface(dst_surface, + NULL, &wined3d_null_parent_ops, &fb.depth_stencil))) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); + return hr; + } + + device_clear_render_targets(device, 0, &fb, 1, dst_rect, &draw_rect, WINED3DCLEAR_ZBUFFER, 0, depth, 0); + wined3d_rendertarget_view_decref(fb.depth_stencil); return WINED3D_OK; } @@ -5426,6 +5042,7 @@ static HRESULT surface_cpu_blt_compressed(const BYTE *src_data, BYTE *dst_data, } return WINED3D_OK; + case WINED3DFMT_DXT2: case WINED3DFMT_DXT3: for (y = 0; y < update_h; y += format->block_height) { @@ -6137,11 +5754,11 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC } if (src_surface) - src_swapchain = src_surface->swapchain; + src_swapchain = src_surface->container->swapchain; else src_swapchain = NULL; - dst_swapchain = dst_surface->swapchain; + dst_swapchain = dst_surface->container->swapchain; /* This isn't strictly needed. FBO blits for example could deal with * cross-swapchain blits by first downloading the source to a texture @@ -6187,8 +5804,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC return WINED3DERR_INVALIDCALL; } - if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_surface->draw_binding, &src_rect, - dst_surface, dst_surface->draw_binding, &dst_rect))) + if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_surface->container->resource.draw_binding, + &src_rect, dst_surface, dst_surface->container->resource.draw_binding, &dst_rect))) return WINED3D_OK; } } @@ -6196,8 +5813,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC { /* In principle this would apply to depth blits as well, but we don't * implement those in the CPU blitter at the moment. */ - if ((dst_surface->locations & dst_surface->map_binding) - && (!src_surface || (src_surface->locations & src_surface->map_binding))) + if ((dst_surface->locations & dst_surface->resource.map_binding) + && (!src_surface || (src_surface->locations & src_surface->resource.map_binding))) { if (scale) TRACE("Not doing sysmem blit because of scaling.\n"); @@ -6237,8 +5854,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC if (SUCCEEDED(surface_upload_from_surface(dst_surface, &dst_point, src_surface, &src_rect))) { - if (!surface_is_offscreen(dst_surface)) - surface_load_location(dst_surface, dst_surface->draw_binding); + if (!wined3d_resource_is_offscreen(&dst_surface->container->resource)) + surface_load_location(dst_surface, dst_surface->container->resource.draw_binding); return WINED3D_OK; } } @@ -6251,8 +5868,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC * to the frontbuffer instead of doing a Flip(). D3D8 and D3D9 * applications can't blit directly to the frontbuffer. */ if (dst_swapchain && dst_swapchain->back_buffers - && dst_surface == dst_swapchain->front_buffer - && src_surface == dst_swapchain->back_buffers[0]) + && dst_surface->container == dst_swapchain->front_buffer + && src_surface->container == dst_swapchain->back_buffers[0]) { enum wined3d_swap_effect swap_effect = dst_swapchain->desc.swap_effect; @@ -6274,10 +5891,10 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC TRACE("Using FBO blit.\n"); surface_blt_fbo(device, filter, - src_surface, src_surface->draw_binding, &src_rect, - dst_surface, dst_surface->draw_binding, &dst_rect); - surface_validate_location(dst_surface, dst_surface->draw_binding); - surface_invalidate_location(dst_surface, ~dst_surface->draw_binding); + src_surface, src_surface->container->resource.draw_binding, &src_rect, + dst_surface, dst_surface->container->resource.draw_binding, &dst_rect); + surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding); + surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding); return WINED3D_OK; } @@ -6308,7 +5925,7 @@ cpu: } static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_texture *container, - const struct wined3d_resource_desc *desc, DWORD flags) + const struct wined3d_resource_desc *desc, GLenum target, unsigned int level, unsigned int layer, DWORD flags) { struct wined3d_device *device = container->resource.device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; @@ -6372,13 +5989,14 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text return hr; } - surface_set_container(surface, container); + surface->container = container; surface_validate_location(surface, WINED3D_LOCATION_SYSMEM); list_init(&surface->renderbuffers); list_init(&surface->overlays); /* Flags */ - surface->flags |= SFLAG_NORMCOORD; /* Default to normalized coords. */ + if (target != GL_TEXTURE_RECTANGLE_ARB) + surface->flags |= SFLAG_NORMCOORD; if (flags & WINED3D_SURFACE_DISCARD) surface->flags |= SFLAG_DISCARD; if (flags & WINED3D_SURFACE_PIN_SYSMEM) @@ -6386,14 +6004,14 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE) surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU; - surface->map_binding = WINED3D_LOCATION_SYSMEM; + surface->texture_target = target; + surface->texture_level = level; + surface->texture_layer = layer; /* Call the private setup routine */ - hr = surface->surface_ops->surface_private_setup(surface); - if (FAILED(hr)) + if (FAILED(hr = surface->surface_ops->surface_private_setup(surface))) { - ERR("Private setup failed, returning %#x\n", hr); - surface_set_container(surface, NULL); + ERR("Private setup failed, hr %#x.\n", hr); surface_cleanup(surface); return hr; } @@ -6403,9 +6021,9 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text * after a wined3d_surface_getdc() call. */ if ((desc->usage & WINED3DUSAGE_OWNDC) && !surface->hDC && SUCCEEDED(surface_create_dib_section(surface))) - surface->map_binding = WINED3D_LOCATION_DIB; + surface->resource.map_binding = WINED3D_LOCATION_DIB; - if (surface->map_binding == WINED3D_LOCATION_DIB) + if (surface->resource.map_binding == WINED3D_LOCATION_DIB) { wined3d_resource_free_sysmem(&surface->resource); surface_validate_location(surface, WINED3D_LOCATION_DIB); @@ -6415,8 +6033,8 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text return hr; } -HRESULT CDECL wined3d_surface_create(struct wined3d_texture *container, - const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_surface **surface) +HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc, + GLenum target, unsigned int level, unsigned int layer, DWORD flags, struct wined3d_surface **surface) { struct wined3d_device_parent *device_parent = container->resource.device->device_parent; const struct wined3d_parent_ops *parent_ops; @@ -6424,16 +6042,16 @@ HRESULT CDECL wined3d_surface_create(struct wined3d_texture *container, void *parent; HRESULT hr; - TRACE("container %p, width %u, height %u, format %s, usage %s (%#x), " - "pool %s, multisample_type %#x, multisample_quality %u, flags %#x, surface %p.\n", + TRACE("container %p, width %u, height %u, format %s, usage %s (%#x), pool %s, " + "multisample_type %#x, multisample_quality %u, target %#x, level %u, layer %u, flags %#x, surface %p.\n", container, desc->width, desc->height, debug_d3dformat(desc->format), debug_d3dusage(desc->usage), desc->usage, debug_d3dpool(desc->pool), - desc->multisample_type, desc->multisample_quality, flags, surface); + desc->multisample_type, desc->multisample_quality, target, level, layer, flags, surface); if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; - if (FAILED(hr = surface_init(object, container, desc, flags))) + if (FAILED(hr = surface_init(object, container, desc, target, level, layer, flags))) { WARN("Failed to initialize surface, returning %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); @@ -6444,8 +6062,7 @@ HRESULT CDECL wined3d_surface_create(struct wined3d_texture *container, wined3d_texture_get_parent(container), object, &parent, &parent_ops))) { WARN("Failed to create surface parent, hr %#x.\n", hr); - surface_set_container(object, NULL); - wined3d_surface_decref(object); + wined3d_surface_destroy(object); return hr; } diff --git a/reactos/dll/directx/wine/wined3d/swapchain.c b/reactos/dll/directx/wine/wined3d/swapchain.c index 6dbcf804c30..276fa3644eb 100644 --- a/reactos/dll/directx/wine/wined3d/swapchain.c +++ b/reactos/dll/directx/wine/wined3d/swapchain.c @@ -38,8 +38,8 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) * is the last buffer to be destroyed, FindContext() depends on that. */ if (swapchain->front_buffer) { - surface_set_swapchain(swapchain->front_buffer, NULL); - if (wined3d_surface_decref(swapchain->front_buffer)) + wined3d_texture_set_swapchain(swapchain->front_buffer, NULL); + if (wined3d_texture_decref(swapchain->front_buffer)) WARN("Something's still holding the front buffer (%p).\n", swapchain->front_buffer); swapchain->front_buffer = NULL; } @@ -50,8 +50,8 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) while (i--) { - surface_set_swapchain(swapchain->back_buffers[i], NULL); - if (wined3d_surface_decref(swapchain->back_buffers[i])) + wined3d_texture_set_swapchain(swapchain->back_buffers[i], NULL); + if (wined3d_texture_decref(swapchain->back_buffers[i])) WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]); } HeapFree(GetProcessHeap(), 0, swapchain->back_buffers); @@ -161,7 +161,7 @@ HRESULT CDECL wined3d_swapchain_get_front_buffer_data(const struct wined3d_swapc TRACE("swapchain %p, dst_surface %p.\n", swapchain, dst_surface); - src_surface = swapchain->front_buffer; + src_surface = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)); SetRect(&src_rect, 0, 0, src_surface->resource.width, src_surface->resource.height); dst_rect = src_rect; @@ -196,7 +196,7 @@ struct wined3d_surface * CDECL wined3d_swapchain_get_back_buffer(const struct wi TRACE("Returning back buffer %p.\n", swapchain->back_buffers[back_buffer_idx]); - return swapchain->back_buffers[back_buffer_idx]; + return surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[back_buffer_idx], 0)); } HRESULT CDECL wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain, @@ -256,6 +256,12 @@ HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *s return WINED3D_OK; } +void CDECL wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette) +{ + TRACE("swapchain %p, palette %p.\n", swapchain, palette); + swapchain->palette = palette; +} + HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain, struct wined3d_gamma_ramp *ramp) { @@ -274,7 +280,8 @@ HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *s static void swapchain_blit(const struct wined3d_swapchain *swapchain, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect) { - struct wined3d_surface *backbuffer = swapchain->back_buffers[0]; + struct wined3d_surface *backbuffer = surface_from_resource( + wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)); UINT src_w = src_rect->right - src_rect->left; UINT src_h = src_rect->bottom - src_rect->top; GLenum gl_filter; @@ -307,7 +314,8 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain, gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0); context_check_fbo_status(context, GL_READ_FRAMEBUFFER); - context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, swapchain->front_buffer, + context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, + surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)), NULL, WINED3D_LOCATION_DRAWABLE); context_set_draw_buffer(context, GL_BACK); context_invalidate_state(context, STATE_FRAMEBUFFER); @@ -336,7 +344,7 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain, float tex_right = src_rect->right; float tex_bottom = src_rect->bottom; - context2 = context_acquire(device, swapchain->back_buffers[0]); + context2 = context_acquire(device, backbuffer); context_apply_blit_state(context2, device); if (backbuffer->flags & SFLAG_NORMCOORD) @@ -350,7 +358,8 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain, if (is_complex_fixup(backbuffer->resource.format->color_fixup)) gl_filter = GL_NEAREST; - context_apply_fbo_state_blit(context2, GL_FRAMEBUFFER, swapchain->front_buffer, + context_apply_fbo_state_blit(context2, GL_FRAMEBUFFER, + surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)), NULL, WINED3D_LOCATION_DRAWABLE); context_bind_texture(context2, backbuffer->texture_target, backbuffer->container->texture_rgb.name); @@ -408,10 +417,12 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain, static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in, const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags) { - struct wined3d_surface *back_buffer = swapchain->back_buffers[0]; + struct wined3d_surface *back_buffer = surface_from_resource( + wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)); const struct wined3d_fb_state *fb = &swapchain->device->fb; const struct wined3d_gl_info *gl_info; struct wined3d_context *context; + struct wined3d_surface *front; RECT src_rect, dst_rect; BOOL render_to_fbo; @@ -505,7 +516,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT } else { - surface_load_location(back_buffer, back_buffer->draw_binding); + surface_load_location(back_buffer, back_buffer->container->resource.draw_binding); } if (swapchain->render_to_fbo) @@ -541,13 +552,13 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT } } - if (!swapchain->render_to_fbo && ((swapchain->front_buffer->locations & WINED3D_LOCATION_SYSMEM) + front = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)); + if (!swapchain->render_to_fbo && ((front->locations & WINED3D_LOCATION_SYSMEM) || (back_buffer->locations & WINED3D_LOCATION_SYSMEM))) { /* Both memory copies of the surfaces are ok, flip them around too instead of dirtifying * Doesn't work with render_to_fbo because we're not flipping */ - struct wined3d_surface *front = swapchain->front_buffer; if (front->resource.size == back_buffer->resource.size) { @@ -568,8 +579,8 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT } else { - surface_validate_location(swapchain->front_buffer, WINED3D_LOCATION_DRAWABLE); - surface_invalidate_location(swapchain->front_buffer, ~WINED3D_LOCATION_DRAWABLE); + surface_validate_location(front, WINED3D_LOCATION_DRAWABLE); + surface_invalidate_location(front, ~WINED3D_LOCATION_DRAWABLE); /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM * and INTEXTURE copies can keep their old content if they have any defined content. * If the swapeffect is COPY, the content remains the same. If it is FLIP however, @@ -577,20 +588,21 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT */ if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP) { - surface_validate_location(back_buffer, back_buffer->draw_binding); - surface_invalidate_location(back_buffer, ~back_buffer->draw_binding); + surface_validate_location(back_buffer, back_buffer->container->resource.draw_binding); + surface_invalidate_location(back_buffer, ~back_buffer->container->resource.draw_binding); } } if (fb->depth_stencil) { - if (swapchain->desc.flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL - || fb->depth_stencil->flags & SFLAG_DISCARD) + struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(fb->depth_stencil); + + if (ds && (swapchain->desc.flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL + || ds->flags & SFLAG_DISCARD)) { - surface_modify_ds_location(fb->depth_stencil, WINED3D_LOCATION_DISCARDED, - fb->depth_stencil->resource.width, - fb->depth_stencil->resource.height); - if (fb->depth_stencil == swapchain->device->onscreen_depth_stencil) + surface_modify_ds_location(ds, WINED3D_LOCATION_DISCARDED, + fb->depth_stencil->width, fb->depth_stencil->height); + if (ds == swapchain->device->onscreen_depth_stencil) { wined3d_surface_decref(swapchain->device->onscreen_depth_stencil); swapchain->device->onscreen_depth_stencil = NULL; @@ -617,7 +629,10 @@ void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *r TRACE("swapchain %p, rect %s.\n", swapchain, wine_dbgstr_rect(rect)); - front = swapchain->front_buffer; + front = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)); + if (swapchain->palette) + wined3d_palette_apply_to_dc(swapchain->palette, front->hDC); + if (front->resource.map_count) ERR("Trying to blit a mapped surface.\n"); @@ -655,8 +670,8 @@ static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const REC { struct wined3d_surface *front, *back; - front = swapchain->front_buffer; - back = swapchain->back_buffers[0]; + front = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)); + back = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0)); /* Flip the DC. */ { @@ -756,6 +771,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 { const struct wined3d_adapter *adapter = device->adapter; struct wined3d_resource_desc surface_desc; + struct wined3d_surface *front_buffer; BOOL displaymode_set = FALSE; RECT client_rect; HWND window; @@ -837,17 +853,18 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 surface_desc.size = 0; if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, - parent, &surface_desc, &swapchain->front_buffer))) + parent, &surface_desc, &front_buffer))) { WARN("Failed to create front buffer, hr %#x.\n", hr); goto err; } - surface_set_swapchain(swapchain->front_buffer, swapchain); + swapchain->front_buffer = front_buffer->container; + wined3d_texture_set_swapchain(swapchain->front_buffer, swapchain); if (!(device->wined3d->flags & WINED3D_NO3D)) { - surface_validate_location(swapchain->front_buffer, WINED3D_LOCATION_DRAWABLE); - surface_invalidate_location(swapchain->front_buffer, ~WINED3D_LOCATION_DRAWABLE); + surface_validate_location(front_buffer, WINED3D_LOCATION_DRAWABLE); + surface_invalidate_location(front_buffer, ~WINED3D_LOCATION_DRAWABLE); } /* MSDN says we're only allowed a single fullscreen swapchain per device, @@ -909,7 +926,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 for (i = 0; i < (sizeof(formats) / sizeof(*formats)); i++) { swapchain->ds_format = wined3d_get_format(gl_info, formats[i]); - swapchain->context[0] = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format); + swapchain->context[0] = context_create(swapchain, front_buffer, swapchain->ds_format); if (swapchain->context[0]) break; TRACE("Depth stencil format %s is not supported, trying next format\n", debug_d3dformat(formats[i])); @@ -945,15 +962,18 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 surface_desc.usage |= WINED3DUSAGE_RENDERTARGET; for (i = 0; i < swapchain->desc.backbuffer_count; ++i) { + struct wined3d_surface *back_buffer; + TRACE("Creating back buffer %u.\n", i); if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, - parent, &surface_desc, &swapchain->back_buffers[i]))) + parent, &surface_desc, &back_buffer))) { WARN("Failed to create back buffer %u, hr %#x.\n", i, hr); swapchain->desc.backbuffer_count = i; goto err; } - surface_set_swapchain(swapchain->back_buffers[i], swapchain); + swapchain->back_buffers[i] = back_buffer->container; + wined3d_texture_set_swapchain(swapchain->back_buffers[i], swapchain); } } @@ -961,15 +981,26 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 if (desc->enable_auto_depth_stencil && !(device->wined3d->flags & WINED3D_NO3D)) { TRACE("Creating depth/stencil buffer.\n"); - if (!device->auto_depth_stencil) + if (!device->auto_depth_stencil_view) { + struct wined3d_surface *ds; + surface_desc.format = swapchain->desc.auto_depth_stencil_format; surface_desc.usage = WINED3DUSAGE_DEPTHSTENCIL; if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, - device->device_parent, &surface_desc, &device->auto_depth_stencil))) + device->device_parent, &surface_desc, &ds))) { - WARN("Failed to create the auto depth stencil, hr %#x.\n", hr); + WARN("Failed to create the auto depth/stencil surface, hr %#x.\n", hr); + goto err; + } + + hr = wined3d_rendertarget_view_create_from_surface(ds, + NULL, &wined3d_null_parent_ops, &device->auto_depth_stencil_view); + wined3d_surface_decref(ds); + if (FAILED(hr)) + { + ERR("Failed to create rendertarget view, hr %#x.\n", hr); goto err; } } @@ -994,8 +1025,8 @@ err: { if (swapchain->back_buffers[i]) { - surface_set_swapchain(swapchain->back_buffers[i], NULL); - wined3d_surface_decref(swapchain->back_buffers[i]); + wined3d_texture_set_swapchain(swapchain->back_buffers[i], NULL); + wined3d_texture_decref(swapchain->back_buffers[i]); } } HeapFree(GetProcessHeap(), 0, swapchain->back_buffers); @@ -1014,8 +1045,8 @@ err: if (swapchain->front_buffer) { - surface_set_swapchain(swapchain->front_buffer, NULL); - wined3d_surface_decref(swapchain->front_buffer); + wined3d_texture_set_swapchain(swapchain->front_buffer, NULL); + wined3d_texture_decref(swapchain->front_buffer); } return hr; @@ -1055,7 +1086,9 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId()); - if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format))) + if (!(ctx = context_create(swapchain, + surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)), + swapchain->ds_format))) { ERR("Failed to create a new context for the swapchain\n"); return NULL; @@ -1104,14 +1137,6 @@ struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchai return swapchain_create_context(swapchain); } -void get_drawable_size_swapchain(const struct wined3d_context *context, UINT *width, UINT *height) -{ - /* The drawable size of an onscreen drawable is the surface size. - * (Actually: The window size, but the surface is created in window size) */ - *width = context->current_rt->resource.width; - *height = context->current_rt->resource.height; -} - HDC swapchain_get_backup_dc(struct wined3d_swapchain *swapchain) { if (!swapchain->backup_dc) @@ -1141,10 +1166,10 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) { UINT i; - surface_update_draw_binding(swapchain->front_buffer); + wined3d_resource_update_draw_binding(&swapchain->front_buffer->resource); for (i = 0; i < swapchain->desc.backbuffer_count; ++i) { - surface_update_draw_binding(swapchain->back_buffers[i]); + wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->resource); } } diff --git a/reactos/dll/directx/wine/wined3d/texture.c b/reactos/dll/directx/wine/wined3d/texture.c index 3aba595da70..fb8425cdaec 100644 --- a/reactos/dll/directx/wine/wined3d/texture.c +++ b/reactos/dll/directx/wine/wined3d/texture.c @@ -23,6 +23,7 @@ #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); +WINE_DECLARE_DEBUG_CHANNEL(winediag); static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, struct wined3d_device *device, @@ -51,9 +52,17 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc desc->multisample_type, desc->multisample_quality, desc->usage, desc->pool, desc->width, desc->height, desc->depth, 0, parent, parent_ops, resource_ops))) { + static unsigned int once; + + if ((desc->format == WINED3DFMT_DXT1 || desc->format == WINED3DFMT_DXT2 || desc->format == WINED3DFMT_DXT3 + || desc->format == WINED3DFMT_DXT4 || desc->format == WINED3DFMT_DXT5) + && !(format->flags & WINED3DFMT_FLAG_TEXTURE) && !once++) + ERR_(winediag)("The application tried to create a DXTn texture, but the driver does not support them.\n"); + WARN("Failed to initialize resource, returning %#x\n", hr); return hr; } + wined3d_resource_update_draw_binding(&texture->resource); texture->texture_ops = texture_ops; texture->sub_resources = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -135,6 +144,12 @@ static void wined3d_texture_cleanup(struct wined3d_texture *texture) resource_cleanup(&texture->resource); } +void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain) +{ + texture->swapchain = swapchain; + wined3d_resource_update_draw_binding(&texture->resource); +} + void wined3d_texture_set_dirty(struct wined3d_texture *texture) { texture->flags &= ~(WINED3D_TEXTURE_RGB_VALID | WINED3D_TEXTURE_SRGB_VALID); @@ -466,8 +481,14 @@ void wined3d_texture_apply_state_changes(struct wined3d_texture *texture, ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture) { - ULONG refcount = InterlockedIncrement(&texture->resource.ref); + ULONG refcount; + + TRACE("texture %p, swapchain %p.\n", texture, texture->swapchain); + if (texture->swapchain) + return wined3d_swapchain_incref(texture->swapchain); + + refcount = InterlockedIncrement(&texture->resource.ref); TRACE("%p increasing refcount to %u.\n", texture, refcount); return refcount; @@ -475,8 +496,14 @@ ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture) ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture) { - ULONG refcount = InterlockedDecrement(&texture->resource.ref); + ULONG refcount; + + TRACE("texture %p, swapchain %p.\n", texture, texture->swapchain); + + if (texture->swapchain) + return wined3d_swapchain_decref(texture->swapchain); + refcount = InterlockedDecrement(&texture->resource.ref); TRACE("%p decreasing refcount to %u.\n", texture, refcount); if (!refcount) @@ -496,16 +523,6 @@ struct wined3d_resource * CDECL wined3d_texture_get_resource(struct wined3d_text return &texture->resource; } -DWORD CDECL wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority) -{ - return resource_set_priority(&texture->resource, priority); -} - -DWORD CDECL wined3d_texture_get_priority(const struct wined3d_texture *texture) -{ - return resource_get_priority(&texture->resource); -} - /* Context activation is done by the caller */ void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) @@ -734,17 +751,15 @@ static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub struct wined3d_surface *surface = surface_from_resource(sub_resource); surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - surface_invalidate_location(surface, ~surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); } static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource) { struct wined3d_surface *surface = surface_from_resource(sub_resource); - surface_set_texture_target(surface, 0, 0); - surface_set_container(surface, NULL); - wined3d_surface_decref(surface); + wined3d_surface_destroy(surface); } static const struct wined3d_texture_ops texture2d_ops = @@ -754,6 +769,16 @@ static const struct wined3d_texture_ops texture2d_ops = texture2d_sub_resource_cleanup, }; +static ULONG texture_resource_incref(struct wined3d_resource *resource) +{ + return wined3d_texture_incref(wined3d_texture_from_resource(resource)); +} + +static ULONG texture_resource_decref(struct wined3d_resource *resource) +{ + return wined3d_texture_decref(wined3d_texture_from_resource(resource)); +} + static void wined3d_texture_unload(struct wined3d_resource *resource) { struct wined3d_texture *texture = wined3d_texture_from_resource(resource); @@ -774,6 +799,8 @@ static void wined3d_texture_unload(struct wined3d_resource *resource) static const struct wined3d_resource_ops texture_resource_ops = { + texture_resource_incref, + texture_resource_decref, wined3d_texture_unload, }; @@ -877,14 +904,14 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi UINT idx = j * texture->level_count + i; struct wined3d_surface *surface; - if (FAILED(hr = wined3d_surface_create(texture, &surface_desc, surface_flags, &surface))) + if (FAILED(hr = wined3d_surface_create(texture, &surface_desc, + cube_targets[j], i, j, surface_flags, &surface))) { WARN("Failed to create surface, hr %#x.\n", hr); wined3d_texture_cleanup(texture); return hr; } - surface_set_texture_target(surface, cube_targets[j], i); texture->sub_resources[idx] = &surface->resource; TRACE("Created surface level %u @ %p.\n", i, surface); } @@ -1031,14 +1058,14 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 { struct wined3d_surface *surface; - if (FAILED(hr = wined3d_surface_create(texture, &surface_desc, surface_flags, &surface))) + if (FAILED(hr = wined3d_surface_create(texture, &surface_desc, + texture->target, i, 0, surface_flags, &surface))) { WARN("Failed to create surface, hr %#x.\n", hr); wined3d_texture_cleanup(texture); return hr; } - surface_set_texture_target(surface, texture->target, i); texture->sub_resources[i] = &surface->resource; TRACE("Created surface level %u @ %p.\n", i, surface); /* Calculate the next mipmap level. */ @@ -1065,9 +1092,7 @@ static void texture3d_sub_resource_cleanup(struct wined3d_resource *sub_resource { struct wined3d_volume *volume = volume_from_resource(sub_resource); - /* Cleanup the container. */ - volume_set_container(volume, NULL); - wined3d_volume_decref(volume); + wined3d_volume_destroy(volume); } static const struct wined3d_texture_ops texture3d_ops = diff --git a/reactos/dll/directx/wine/wined3d/utils.c b/reactos/dll/directx/wine/wined3d/utils.c index cd55f2e3bd0..18e5b21ca98 100644 --- a/reactos/dll/directx/wine/wined3d/utils.c +++ b/reactos/dll/directx/wine/wined3d/utils.c @@ -84,6 +84,7 @@ static const struct wined3d_format_channels formats[] = {WINED3DFMT_B5G5R5A1_UNORM, 5, 5, 5, 1, 10, 5, 0, 15, 2, 0, 0}, {WINED3DFMT_B4G4R4A4_UNORM, 4, 4, 4, 4, 8, 4, 0, 12, 2, 0, 0}, {WINED3DFMT_B2G3R3_UNORM, 3, 3, 2, 0, 5, 2, 0, 0, 1, 0, 0}, + {WINED3DFMT_R8_UNORM, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {WINED3DFMT_A8_UNORM, 0, 0, 0, 8, 0, 0, 0, 0, 1, 0, 0}, {WINED3DFMT_B2G3R3A8_UNORM, 3, 3, 2, 8, 5, 2, 0, 8, 2, 0, 0}, {WINED3DFMT_B4G4R4X4_UNORM, 4, 4, 4, 0, 8, 4, 0, 0, 2, 0, 0}, @@ -739,10 +740,10 @@ static const struct wined3d_format_texture_info format_texture_info[] = | WINED3DFMT_FLAG_VTF, ARB_TEXTURE_FLOAT, NULL}, /* Palettized formats */ - {WINED3DFMT_P8_UINT, GL_RGBA, GL_RGBA, 0, + {WINED3DFMT_P8_UINT, GL_ALPHA8, GL_ALPHA8, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0, 0, - ARB_FRAGMENT_PROGRAM, NULL}, + 0, NULL}, /* Standard ARGB formats */ {WINED3DFMT_B8G8R8_UNORM, GL_RGB8, GL_RGB8, 0, GL_BGR, GL_UNSIGNED_BYTE, 0, @@ -781,6 +782,11 @@ static const struct wined3d_format_texture_info format_texture_info[] = GL_RGB, GL_UNSIGNED_BYTE_3_3_2, 0, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3D_GL_EXT_NONE, NULL}, + {WINED3DFMT_R8_UNORM, GL_R8, GL_R8, 0, + GL_RED, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING + | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_VTF, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_A8_UNORM, GL_ALPHA8, GL_ALPHA8, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, @@ -794,10 +800,11 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET, WINED3D_GL_EXT_NONE, NULL}, - {WINED3DFMT_R8G8B8A8_UNORM, GL_RGBA8, GL_RGBA8, 0, + {WINED3DFMT_R8G8B8A8_UNORM, GL_RGBA8, GL_SRGB8_ALPHA8_EXT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING - | WINED3DFMT_FLAG_RENDERTARGET, + | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE + | WINED3DFMT_FLAG_VTF, WINED3D_GL_EXT_NONE, NULL}, {WINED3DFMT_R8G8B8X8_UNORM, GL_RGB8, GL_RGB8, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 0, @@ -2018,9 +2025,20 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl return &gl_info->formats[idx]; } +UINT wined3d_format_calculate_pitch(const struct wined3d_format *format, UINT width) +{ + /* For block based formats, pitch means the amount of bytes to the next + * row of blocks rather than the next row of pixels. */ + if (format->flags & WINED3DFMT_FLAG_BLOCKS) + return format->block_byte_count * ((width + format->block_width - 1) / format->block_width); + + return format->byte_count * width; +} + UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT alignment, UINT width, UINT height, UINT depth) { + UINT pitch = wined3d_format_calculate_pitch(format, width); UINT size; if (format->id == WINED3DFMT_UNKNOWN) @@ -2029,13 +2047,12 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali } else if (format->flags & WINED3DFMT_FLAG_BLOCKS) { - UINT row_block_count = (width + format->block_width - 1) / format->block_width; UINT row_count = (height + format->block_height - 1) / format->block_height; - size = row_count * (((row_block_count * format->block_byte_count) + alignment - 1) & ~(alignment - 1)); + size = row_count * ((pitch + alignment - 1) & ~(alignment - 1)); } else { - size = height * (((width * format->byte_count) + alignment - 1) & ~(alignment - 1)); + size = height * ((pitch + alignment - 1) & ~(alignment - 1)); } if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE) @@ -2667,6 +2684,8 @@ const char *debug_d3dstate(DWORD state) return wine_dbg_sprintf("STATE_SAMPLER(%#x)", state - STATE_SAMPLER(0)); if (STATE_IS_SHADER(state)) return wine_dbg_sprintf("STATE_SHADER(%s)", debug_shader_type(state - STATE_SHADER(0))); + if (STATE_IS_CONSTANT_BUFFER(state)) + return wine_dbg_sprintf("STATE_CONSTANT_BUFFER(%s)", debug_shader_type(state - STATE_CONSTANT_BUFFER(0))); if (STATE_IS_TRANSFORM(state)) return wine_dbg_sprintf("STATE_TRANSFORM(%s)", debug_d3dtstype(state - STATE_TRANSFORM(0))); if (STATE_IS_STREAMSRC(state)) @@ -3045,6 +3064,7 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, c {WINED3DFMT_B5G6R5_UNORM, 31.0f, 63.0f, 31.0f, 0.0f, 11, 5, 0, 0}, {WINED3DFMT_B5G5R5A1_UNORM, 31.0f, 31.0f, 31.0f, 1.0f, 10, 5, 0, 15}, {WINED3DFMT_B5G5R5X1_UNORM, 31.0f, 31.0f, 31.0f, 1.0f, 10, 5, 0, 15}, + {WINED3DFMT_R8_UNORM, 255.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0}, {WINED3DFMT_A8_UNORM, 0.0f, 0.0f, 0.0f, 255.0f, 0, 0, 0, 0}, {WINED3DFMT_B4G4R4A4_UNORM, 15.0f, 15.0f, 15.0f, 15.0f, 8, 4, 0, 12}, {WINED3DFMT_B4G4R4X4_UNORM, 15.0f, 15.0f, 15.0f, 15.0f, 8, 4, 0, 12}, @@ -3053,6 +3073,7 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, c {WINED3DFMT_R8G8B8X8_UNORM, 255.0f, 255.0f, 255.0f, 255.0f, 0, 8, 16, 24}, {WINED3DFMT_B10G10R10A2_UNORM, 1023.0f, 1023.0f, 1023.0f, 3.0f, 20, 10, 0, 30}, {WINED3DFMT_R10G10B10A2_UNORM, 1023.0f, 1023.0f, 1023.0f, 3.0f, 0, 10, 20, 30}, + {WINED3DFMT_P8_UINT, 0.0f, 0.0f, 0.0f, 255.0f, 0, 0, 0, 0}, }; const struct wined3d_format *format = surface->resource.format; unsigned int i; @@ -3076,40 +3097,6 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, c return ret; } - if (format->id == WINED3DFMT_P8_UINT) - { - PALETTEENTRY *e; - BYTE r, g, b, a; - - if (!surface->palette) - { - WARN("Surface doesn't have a palette, returning 0.\n"); - return 0; - } - - r = (BYTE)((color->r * 255.0f) + 0.5f); - g = (BYTE)((color->g * 255.0f) + 0.5f); - b = (BYTE)((color->b * 255.0f) + 0.5f); - a = (BYTE)((color->a * 255.0f) + 0.5f); - - e = &surface->palette->palents[a]; - if (e->peRed == r && e->peGreen == g && e->peBlue == b) - return a; - - WARN("Alpha didn't match index, searching full palette.\n"); - - for (i = 0; i < 256; ++i) - { - e = &surface->palette->palents[i]; - if (e->peRed == r && e->peGreen == g && e->peBlue == b) - return i; - } - - FIXME("Unable to convert color to palette index.\n"); - - return 0; - } - FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format->id)); return 0; @@ -3226,7 +3213,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d unsigned int i; DWORD ttff; DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2; - const struct wined3d_surface *rt = state->fb->render_targets[0]; + const struct wined3d_format *rt_format = state->fb->render_targets[0]->format; const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_d3d_info *d3d_info = context->d3d_info; @@ -3440,7 +3427,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d } if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && state->render_states[WINED3D_RS_SRGBWRITEENABLE] - && rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE) + && rt_format->flags & WINED3DFMT_FLAG_SRGB_WRITE) { settings->sRGB_write = 1; } else { diff --git a/reactos/dll/directx/wine/wined3d/view.c b/reactos/dll/directx/wine/wined3d/view.c index bc579e37750..2f79a60865c 100644 --- a/reactos/dll/directx/wine/wined3d/view.c +++ b/reactos/dll/directx/wine/wined3d/view.c @@ -37,7 +37,13 @@ ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *v TRACE("%p decreasing refcount to %u.\n", view, refcount); if (!refcount) + { + /* Call wined3d_object_destroyed() before releasing the resource, + * since releasing the resource may end up destroying the parent. */ + view->parent_ops->wined3d_object_destroyed(view->parent); + wined3d_resource_decref(view->resource); HeapFree(GetProcessHeap(), 0, view); + } return refcount; } @@ -49,6 +55,29 @@ void * CDECL wined3d_rendertarget_view_get_parent(const struct wined3d_rendertar return view->parent; } +void * CDECL wined3d_rendertarget_view_get_sub_resource_parent(const struct wined3d_rendertarget_view *view) +{ + struct wined3d_resource *sub_resource; + + TRACE("view %p.\n", view); + + if (view->resource->type == WINED3D_RTYPE_BUFFER) + return wined3d_buffer_get_parent(buffer_from_resource(view->resource)); + + if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(view->resource), + view->sub_resource_idx))) + return NULL; + + return wined3d_resource_get_parent(sub_resource); +} + +void CDECL wined3d_rendertarget_view_set_parent(struct wined3d_rendertarget_view *view, void *parent) +{ + TRACE("view %p, parent %p.\n", view, parent); + + view->parent = parent; +} + struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view) { TRACE("view %p.\n", view); @@ -57,29 +86,123 @@ struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const str } static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view, - struct wined3d_resource *resource, void *parent) + const struct wined3d_rendertarget_view_desc *desc, struct wined3d_resource *resource, + void *parent, const struct wined3d_parent_ops *parent_ops) { + const struct wined3d_gl_info *gl_info = &resource->device->adapter->gl_info; + view->refcount = 1; view->resource = resource; + wined3d_resource_incref(resource); view->parent = parent; + view->parent_ops = parent_ops; + + view->format = wined3d_get_format(gl_info, desc->format_id); + if (resource->type == WINED3D_RTYPE_BUFFER) + { + view->sub_resource_idx = 0; + view->buffer_offset = desc->u.buffer.start_idx; + view->width = desc->u.buffer.count; + view->height = 1; + view->depth = 1; + } + else + { + struct wined3d_texture *texture = wined3d_texture_from_resource(resource); + struct wined3d_resource *sub_resource; + + view->sub_resource_idx = desc->u.texture.layer_idx * texture->level_count + desc->u.texture.level_idx; + sub_resource = wined3d_texture_get_sub_resource(texture, view->sub_resource_idx); + + view->buffer_offset = 0; + view->width = sub_resource->width; + view->height = sub_resource->height; + view->depth = desc->u.texture.layer_count; + } } -HRESULT CDECL wined3d_rendertarget_view_create(struct wined3d_resource *resource, - void *parent, struct wined3d_rendertarget_view **rendertarget_view) +HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc, + struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, + struct wined3d_rendertarget_view **view) { struct wined3d_rendertarget_view *object; - TRACE("resource %p, parent %p, rendertarget_view %p.\n", - resource, parent, rendertarget_view); + TRACE("desc %p, resource %p, parent %p, view %p.\n", + desc, resource, parent, view); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; - wined3d_rendertarget_view_init(object, resource, parent); + wined3d_rendertarget_view_init(object, desc, resource, parent, parent_ops); TRACE("Created render target view %p.\n", object); - *rendertarget_view = object; + *view = object; + + return WINED3D_OK; +} + +HRESULT CDECL wined3d_rendertarget_view_create_from_surface(struct wined3d_surface *surface, + void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view) +{ + struct wined3d_rendertarget_view_desc desc; + + TRACE("surface %p, view %p.\n", surface, view); + + desc.format_id = surface->resource.format->id; + desc.u.texture.level_idx = surface->texture_level; + desc.u.texture.layer_idx = surface->texture_layer; + desc.u.texture.layer_count = 1; + + return wined3d_rendertarget_view_create(&desc, &surface->container->resource, parent, parent_ops, view); +} + +ULONG CDECL wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view) +{ + ULONG refcount = InterlockedIncrement(&view->refcount); + + TRACE("%p increasing refcount to %u.\n", view, refcount); + + return refcount; +} + +ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view) +{ + ULONG refcount = InterlockedDecrement(&view->refcount); + + TRACE("%p decreasing refcount to %u.\n", view, refcount); + + if (!refcount) + { + view->parent_ops->wined3d_object_destroyed(view->parent); + HeapFree(GetProcessHeap(), 0, view); + } + + return refcount; +} + +void * CDECL wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view) +{ + TRACE("view %p.\n", view); + + return view->parent; +} + +HRESULT CDECL wined3d_shader_resource_view_create(void *parent, const struct wined3d_parent_ops *parent_ops, + struct wined3d_shader_resource_view **view) +{ + struct wined3d_shader_resource_view *object; + + TRACE("parent %p, parent_ops %p, view %p.\n", parent, parent_ops, view); + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + object->refcount = 1; + object->parent = parent; + object->parent_ops = parent_ops; + + TRACE("Created shader resource view %p.\n", object); + *view = object; return WINED3D_OK; } diff --git a/reactos/dll/directx/wine/wined3d/volume.c b/reactos/dll/directx/wine/wined3d/volume.c index bd0420066ce..f61825ad799 100644 --- a/reactos/dll/directx/wine/wined3d/volume.c +++ b/reactos/dll/directx/wine/wined3d/volume.c @@ -25,12 +25,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); -void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) -{ - TRACE("volume %p, container %p.\n", volume, container); - - volume->container = container; -} +#define WINED3D_VFLAG_ALLOCATED 0x00000001 +#define WINED3D_VFLAG_SRGB_ALLOCATED 0x00000002 +#define WINED3D_VFLAG_CLIENT_STORAGE 0x00000004 static BOOL volume_prepare_system_memory(struct wined3d_volume *volume) { @@ -369,7 +366,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume, break; case WINED3D_LOCATION_BUFFER: - if (!volume->pbo || !(volume->flags & WINED3D_VFLAG_PBO)) + if (!volume->pbo) ERR("Trying to load WINED3D_LOCATION_BUFFER without setting it up first.\n"); if (volume->locations & WINED3D_LOCATION_DISCARDED) @@ -459,6 +456,18 @@ static void wined3d_volume_free_pbo(struct wined3d_volume *volume) context_release(context); } +void wined3d_volume_destroy(struct wined3d_volume *volume) +{ + TRACE("volume %p.\n", volume); + + if (volume->pbo) + wined3d_volume_free_pbo(volume); + + resource_cleanup(&volume->resource); + volume->resource.parent_ops->wined3d_object_destroyed(volume->resource.parent); + HeapFree(GetProcessHeap(), 0, volume); +} + static void volume_unload(struct wined3d_resource *resource) { struct wined3d_volume *volume = volume_from_resource(resource); @@ -502,46 +511,16 @@ static void volume_unload(struct wined3d_resource *resource) ULONG CDECL wined3d_volume_incref(struct wined3d_volume *volume) { - ULONG refcount; - - if (volume->container) - { - TRACE("Forwarding to container %p.\n", volume->container); - return wined3d_texture_incref(volume->container); - } - - refcount = InterlockedIncrement(&volume->resource.ref); + TRACE("Forwarding to container %p.\n", volume->container); - TRACE("%p increasing refcount to %u.\n", volume, refcount); - - return refcount; + return wined3d_texture_incref(volume->container); } ULONG CDECL wined3d_volume_decref(struct wined3d_volume *volume) { - ULONG refcount; - - if (volume->container) - { - TRACE("Forwarding to container %p.\n", volume->container); - return wined3d_texture_decref(volume->container); - } - - refcount = InterlockedDecrement(&volume->resource.ref); + TRACE("Forwarding to container %p.\n", volume->container); - TRACE("%p decreasing refcount to %u.\n", volume, refcount); - - if (!refcount) - { - if (volume->pbo) - wined3d_volume_free_pbo(volume); - - resource_cleanup(&volume->resource); - volume->resource.parent_ops->wined3d_object_destroyed(volume->resource.parent); - HeapFree(GetProcessHeap(), 0, volume); - } - - return refcount; + return wined3d_texture_decref(volume->container); } void * CDECL wined3d_volume_get_parent(const struct wined3d_volume *volume) @@ -551,16 +530,6 @@ void * CDECL wined3d_volume_get_parent(const struct wined3d_volume *volume) return volume->resource.parent; } -DWORD CDECL wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD priority) -{ - return resource_set_priority(&volume->resource, priority); -} - -DWORD CDECL wined3d_volume_get_priority(const struct wined3d_volume *volume) -{ - return resource_get_priority(&volume->resource); -} - void CDECL wined3d_volume_preload(struct wined3d_volume *volume) { FIXME("volume %p stub!\n", volume); @@ -660,7 +629,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, flags = wined3d_resource_sanitize_map_flags(&volume->resource, flags); - if (volume->flags & WINED3D_VFLAG_PBO) + if (volume->resource.map_binding == WINED3D_LOCATION_BUFFER) { context = context_acquire(device, NULL); gl_info = context->gl_info; @@ -756,11 +725,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY))) { wined3d_texture_set_dirty(volume->container); - - if (volume->flags & WINED3D_VFLAG_PBO) - wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_BUFFER); - else - wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_SYSMEM); + wined3d_volume_invalidate_location(volume, ~volume->resource.map_binding); } volume->resource.map_count++; @@ -786,7 +751,7 @@ HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume) return WINED3DERR_INVALIDCALL; } - if (volume->flags & WINED3D_VFLAG_PBO) + if (volume->resource.map_binding == WINED3D_LOCATION_BUFFER) { struct wined3d_device *device = volume->resource.device; struct wined3d_context *context = context_acquire(device, NULL); @@ -805,8 +770,20 @@ HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume) return WINED3D_OK; } +static ULONG volume_resource_incref(struct wined3d_resource *resource) +{ + return wined3d_volume_incref(volume_from_resource(resource)); +} + +static ULONG volume_resource_decref(struct wined3d_resource *resource) +{ + return wined3d_volume_decref(volume_from_resource(resource)); +} + static const struct wined3d_resource_ops volume_resource_ops = { + volume_resource_incref, + volume_resource_decref, volume_unload, }; @@ -851,10 +828,10 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture && !format->convert) { wined3d_resource_free_sysmem(&volume->resource); - volume->flags |= WINED3D_VFLAG_PBO; + volume->resource.map_binding = WINED3D_LOCATION_BUFFER; } - volume_set_container(volume, container); + volume->container = container; return WINED3D_OK; } @@ -887,8 +864,7 @@ HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wi wined3d_texture_get_parent(container), object, &parent, &parent_ops))) { WARN("Failed to create volume parent, hr %#x.\n", hr); - volume_set_container(object, NULL); - wined3d_volume_decref(object); + wined3d_volume_destroy(object); return hr; } diff --git a/reactos/dll/directx/wine/wined3d/wined3d.spec b/reactos/dll/directx/wine/wined3d/wined3d.spec index bdfe017b670..615a85d49c1 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d.spec +++ b/reactos/dll/directx/wine/wined3d/wined3d.spec @@ -1,6 +1,7 @@ @ stdcall wined3d_mutex_lock() @ stdcall wined3d_mutex_unlock() +@ cdecl wined3d_calculate_format_pitch(ptr long long long) @ cdecl wined3d_check_depth_stencil_match(ptr long long long long long) @ cdecl wined3d_check_device_format(ptr long long long long long long) @ cdecl wined3d_check_device_format_conversion(ptr long long long long) @@ -25,20 +26,18 @@ @ cdecl wined3d_buffer_create_vb(ptr long long long ptr ptr ptr) @ cdecl wined3d_buffer_decref(ptr) @ cdecl wined3d_buffer_get_parent(ptr) -@ cdecl wined3d_buffer_get_priority(ptr) @ cdecl wined3d_buffer_get_resource(ptr) @ cdecl wined3d_buffer_incref(ptr) @ cdecl wined3d_buffer_map(ptr long long ptr long) @ cdecl wined3d_buffer_preload(ptr) -@ cdecl wined3d_buffer_set_priority(ptr long) @ cdecl wined3d_buffer_unmap(ptr) @ cdecl wined3d_device_acquire_focus_window(ptr ptr) @ cdecl wined3d_device_begin_scene(ptr) @ cdecl wined3d_device_begin_stateblock(ptr) @ cdecl wined3d_device_clear(ptr long ptr long ptr float long) -@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr) -@ cdecl wined3d_device_color_fill(ptr ptr ptr ptr) +@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr ptr) +@ cdecl wined3d_device_copy_resource(ptr ptr ptr) @ cdecl wined3d_device_create(ptr long long ptr long long ptr ptr) @ cdecl wined3d_device_decref(ptr) @ cdecl wined3d_device_draw_indexed_primitive(ptr long long) @@ -53,13 +52,14 @@ @ cdecl wined3d_device_get_clip_plane(ptr long ptr) @ cdecl wined3d_device_get_clip_status(ptr ptr) @ cdecl wined3d_device_get_creation_parameters(ptr ptr) -@ cdecl wined3d_device_get_depth_stencil(ptr) +@ cdecl wined3d_device_get_depth_stencil_view(ptr) @ cdecl wined3d_device_get_device_caps(ptr ptr) @ cdecl wined3d_device_get_display_mode(ptr long ptr ptr) @ cdecl wined3d_device_get_front_buffer_data(ptr long ptr) @ cdecl wined3d_device_get_gamma_ramp(ptr long ptr) @ cdecl wined3d_device_get_geometry_shader(ptr) @ cdecl wined3d_device_get_gs_cb(ptr long) +@ cdecl wined3d_device_get_gs_resource_view(ptr long) @ cdecl wined3d_device_get_gs_sampler(ptr long) @ cdecl wined3d_device_get_index_buffer(ptr ptr) @ cdecl wined3d_device_get_light(ptr long ptr) @@ -67,15 +67,17 @@ @ cdecl wined3d_device_get_material(ptr ptr) @ cdecl wined3d_device_get_npatch_mode(ptr) @ cdecl wined3d_device_get_pixel_shader(ptr) +@ cdecl wined3d_device_get_predication(ptr ptr) @ cdecl wined3d_device_get_primitive_type(ptr ptr) @ cdecl wined3d_device_get_ps_cb(ptr long) @ cdecl wined3d_device_get_ps_consts_b(ptr long ptr long) @ cdecl wined3d_device_get_ps_consts_f(ptr long ptr long) @ cdecl wined3d_device_get_ps_consts_i(ptr long ptr long) +@ cdecl wined3d_device_get_ps_resource_view(ptr long) @ cdecl wined3d_device_get_ps_sampler(ptr long) @ cdecl wined3d_device_get_raster_status(ptr long ptr) @ cdecl wined3d_device_get_render_state(ptr long) -@ cdecl wined3d_device_get_render_target(ptr long) +@ cdecl wined3d_device_get_rendertarget_view(ptr long) @ cdecl wined3d_device_get_sampler_state(ptr long long) @ cdecl wined3d_device_get_scissor_rect(ptr ptr) @ cdecl wined3d_device_get_software_vertex_processing(ptr) @@ -95,6 +97,7 @@ @ cdecl wined3d_device_get_vs_consts_b(ptr long ptr long) @ cdecl wined3d_device_get_vs_consts_f(ptr long ptr long) @ cdecl wined3d_device_get_vs_consts_i(ptr long ptr long) +@ cdecl wined3d_device_get_vs_resource_view(ptr long) @ cdecl wined3d_device_get_vs_sampler(ptr long) @ cdecl wined3d_device_incref(ptr) @ cdecl wined3d_device_init_3d(ptr ptr) @@ -110,11 +113,12 @@ @ cdecl wined3d_device_set_clip_status(ptr ptr) @ cdecl wined3d_device_set_cursor_position(ptr long long long) @ cdecl wined3d_device_set_cursor_properties(ptr long long ptr) -@ cdecl wined3d_device_set_depth_stencil(ptr ptr) +@ cdecl wined3d_device_set_depth_stencil_view(ptr ptr) @ cdecl wined3d_device_set_dialog_box_mode(ptr long) @ cdecl wined3d_device_set_gamma_ramp(ptr long long ptr) @ cdecl wined3d_device_set_geometry_shader(ptr ptr) @ cdecl wined3d_device_set_gs_cb(ptr long ptr) +@ cdecl wined3d_device_set_gs_resource_view(ptr long ptr) @ cdecl wined3d_device_set_gs_sampler(ptr long ptr) @ cdecl wined3d_device_set_index_buffer(ptr ptr long) @ cdecl wined3d_device_set_light(ptr long ptr) @@ -123,14 +127,16 @@ @ cdecl wined3d_device_set_multithreaded(ptr) @ cdecl wined3d_device_set_npatch_mode(ptr float) @ cdecl wined3d_device_set_pixel_shader(ptr ptr) +@ cdecl wined3d_device_set_predication(ptr ptr long) @ cdecl wined3d_device_set_primitive_type(ptr long) @ cdecl wined3d_device_set_ps_cb(ptr long ptr) @ cdecl wined3d_device_set_ps_consts_b(ptr long ptr long) @ cdecl wined3d_device_set_ps_consts_f(ptr long ptr long) @ cdecl wined3d_device_set_ps_consts_i(ptr long ptr long) +@ cdecl wined3d_device_set_ps_resource_view(ptr long ptr) @ cdecl wined3d_device_set_ps_sampler(ptr long ptr) @ cdecl wined3d_device_set_render_state(ptr long long) -@ cdecl wined3d_device_set_render_target(ptr long ptr long) +@ cdecl wined3d_device_set_rendertarget_view(ptr long ptr long) @ cdecl wined3d_device_set_sampler_state(ptr long long long) @ cdecl wined3d_device_set_scissor_rect(ptr ptr) @ cdecl wined3d_device_set_software_vertex_processing(ptr long) @@ -147,6 +153,7 @@ @ cdecl wined3d_device_set_vs_consts_b(ptr long ptr long) @ cdecl wined3d_device_set_vs_consts_f(ptr long ptr long) @ cdecl wined3d_device_set_vs_consts_i(ptr long ptr long) +@ cdecl wined3d_device_set_vs_resource_view(ptr long ptr) @ cdecl wined3d_device_set_vs_sampler(ptr long ptr) @ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long) @ cdecl wined3d_device_show_cursor(ptr long) @@ -159,26 +166,33 @@ @ cdecl wined3d_palette_create(ptr long long ptr ptr) @ cdecl wined3d_palette_decref(ptr) @ cdecl wined3d_palette_get_entries(ptr long long long ptr) +@ cdecl wined3d_palette_apply_to_dc(ptr ptr) @ cdecl wined3d_palette_incref(ptr) @ cdecl wined3d_palette_set_entries(ptr long long long ptr) -@ cdecl wined3d_query_create(ptr long ptr) +@ cdecl wined3d_query_create(ptr long ptr ptr) @ cdecl wined3d_query_decref(ptr) @ cdecl wined3d_query_get_data(ptr ptr long long) @ cdecl wined3d_query_get_data_size(ptr) +@ cdecl wined3d_query_get_parent(ptr) @ cdecl wined3d_query_get_type(ptr) @ cdecl wined3d_query_incref(ptr) @ cdecl wined3d_query_issue(ptr long) @ cdecl wined3d_resource_get_desc(ptr ptr) @ cdecl wined3d_resource_get_parent(ptr) +@ cdecl wined3d_resource_get_priority(ptr) @ cdecl wined3d_resource_set_parent(ptr ptr) +@ cdecl wined3d_resource_set_priority(ptr long) -@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr) +@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr ptr ptr) +@ cdecl wined3d_rendertarget_view_create_from_surface(ptr ptr ptr ptr) @ cdecl wined3d_rendertarget_view_decref(ptr) @ cdecl wined3d_rendertarget_view_get_parent(ptr) @ cdecl wined3d_rendertarget_view_get_resource(ptr) +@ cdecl wined3d_rendertarget_view_get_sub_resource_parent(ptr) @ cdecl wined3d_rendertarget_view_incref(ptr) +@ cdecl wined3d_rendertarget_view_set_parent(ptr ptr) @ cdecl wined3d_sampler_create(ptr ptr) @ cdecl wined3d_sampler_decref(ptr) @@ -194,6 +208,11 @@ @ cdecl wined3d_shader_incref(ptr) @ cdecl wined3d_shader_set_local_constants_float(ptr long ptr long) +@ cdecl wined3d_shader_resource_view_create(ptr ptr ptr) +@ cdecl wined3d_shader_resource_view_decref(ptr) +@ cdecl wined3d_shader_resource_view_get_parent(ptr) +@ cdecl wined3d_shader_resource_view_incref(ptr) + @ cdecl wined3d_stateblock_apply(ptr) @ cdecl wined3d_stateblock_capture(ptr) @ cdecl wined3d_stateblock_create(ptr long ptr) @@ -206,10 +225,8 @@ @ cdecl wined3d_surface_get_blt_status(ptr long) @ cdecl wined3d_surface_get_flip_status(ptr long) @ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr) -@ cdecl wined3d_surface_get_palette(ptr) @ cdecl wined3d_surface_get_parent(ptr) @ cdecl wined3d_surface_get_pitch(ptr) -@ cdecl wined3d_surface_get_priority(ptr) @ cdecl wined3d_surface_get_render_target_data(ptr ptr) @ cdecl wined3d_surface_get_resource(ptr) @ cdecl wined3d_surface_getdc(ptr ptr) @@ -220,8 +237,6 @@ @ cdecl wined3d_surface_releasedc(ptr ptr) @ cdecl wined3d_surface_restore(ptr) @ cdecl wined3d_surface_set_overlay_position(ptr long long) -@ cdecl wined3d_surface_set_palette(ptr ptr) -@ cdecl wined3d_surface_set_priority(ptr long) @ cdecl wined3d_surface_unmap(ptr) @ cdecl wined3d_surface_update_desc(ptr long long long long long ptr long) @ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr) @@ -240,6 +255,7 @@ @ cdecl wined3d_swapchain_incref(ptr) @ cdecl wined3d_swapchain_present(ptr ptr ptr ptr ptr long) @ cdecl wined3d_swapchain_set_gamma_ramp(ptr long ptr) +@ cdecl wined3d_swapchain_set_palette(ptr ptr) @ cdecl wined3d_swapchain_set_window(ptr ptr) @ cdecl wined3d_texture_add_dirty_region(ptr long ptr) @@ -250,7 +266,6 @@ @ cdecl wined3d_texture_get_level_count(ptr) @ cdecl wined3d_texture_get_lod(ptr) @ cdecl wined3d_texture_get_parent(ptr) -@ cdecl wined3d_texture_get_priority(ptr) @ cdecl wined3d_texture_get_resource(ptr) @ cdecl wined3d_texture_get_sub_resource(ptr long) @ cdecl wined3d_texture_incref(ptr) @@ -258,7 +273,6 @@ @ cdecl wined3d_texture_set_autogen_filter_type(ptr long) @ cdecl wined3d_texture_set_color_key(ptr long ptr) @ cdecl wined3d_texture_set_lod(ptr long) -@ cdecl wined3d_texture_set_priority(ptr long) @ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr) @ cdecl wined3d_vertex_declaration_create_from_fvf(ptr long ptr ptr ptr) @@ -269,10 +283,8 @@ @ cdecl wined3d_volume_decref(ptr) @ cdecl wined3d_volume_from_resource(ptr) @ cdecl wined3d_volume_get_parent(ptr) -@ cdecl wined3d_volume_get_priority(ptr) @ cdecl wined3d_volume_get_resource(ptr) @ cdecl wined3d_volume_incref(ptr) @ cdecl wined3d_volume_map(ptr ptr ptr long) @ cdecl wined3d_volume_preload(ptr) -@ cdecl wined3d_volume_set_priority(ptr long) @ cdecl wined3d_volume_unmap(ptr) diff --git a/reactos/dll/directx/wine/wined3d/wined3d_gl.h b/reactos/dll/directx/wine/wined3d/wined3d_gl.h index acfbe3cebfd..b02905e5734 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d_gl.h +++ b/reactos/dll/directx/wine/wined3d/wined3d_gl.h @@ -90,6 +90,7 @@ enum wined3d_gl_extension ARB_TEXTURE_RECTANGLE, ARB_TEXTURE_RG, ARB_TIMER_QUERY, + ARB_UNIFORM_BUFFER_OBJECT, ARB_VERTEX_ARRAY_BGRA, ARB_VERTEX_BLEND, ARB_VERTEX_BUFFER_OBJECT, @@ -325,6 +326,17 @@ enum wined3d_gl_extension /* GL_ARB_timer_query */ \ USE_GL_FUNC(glQueryCounter) \ USE_GL_FUNC(glGetQueryObjectui64v) \ + /* GL_ARB_uniform_buffer_object */ \ + USE_GL_FUNC(glBindBufferBase) \ + USE_GL_FUNC(glBindBufferRange) \ + USE_GL_FUNC(glGetActiveUniformBlockName) \ + USE_GL_FUNC(glGetActiveUniformBlockiv) \ + USE_GL_FUNC(glGetActiveUniformName) \ + USE_GL_FUNC(glGetActiveUniformsiv) \ + USE_GL_FUNC(glGetIntegeri_v) \ + USE_GL_FUNC(glGetUniformBlockIndex) \ + USE_GL_FUNC(glGetUniformIndices) \ + USE_GL_FUNC(glUniformBlockBinding) \ /* GL_ARB_vertex_blend */ \ USE_GL_FUNC(glVertexBlendARB) \ USE_GL_FUNC(glWeightPointerARB) \ diff --git a/reactos/dll/directx/wine/wined3d/wined3d_main.c b/reactos/dll/directx/wine/wined3d/wined3d_main.c index c62d1f56f3b..530287f3259 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d_main.c +++ b/reactos/dll/directx/wine/wined3d/wined3d_main.c @@ -254,10 +254,10 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) int TmpVideoMemorySize = atoi(buffer); if(TmpVideoMemorySize > 0) { - wined3d_settings.emulated_textureram = TmpVideoMemorySize *1024*1024; - TRACE("Use %iMB = %d byte for emulated_textureram\n", + wined3d_settings.emulated_textureram = (UINT64)TmpVideoMemorySize *1024*1024; + TRACE("Use %iMiB = 0x%s bytes for emulated_textureram\n", TmpVideoMemorySize, - wined3d_settings.emulated_textureram); + wine_dbgstr_longlong(wined3d_settings.emulated_textureram)); } else ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize); diff --git a/reactos/dll/directx/wine/wined3d/wined3d_private.h b/reactos/dll/directx/wine/wined3d/wined3d_private.h index 6863f141ed9..81197174812 100644 --- a/reactos/dll/directx/wine/wined3d/wined3d_private.h +++ b/reactos/dll/directx/wine/wined3d/wined3d_private.h @@ -165,16 +165,17 @@ void *wined3d_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN; void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN; /* Device caps */ -#define MAX_STREAM_OUT 4 -#define MAX_STREAMS 16 -#define MAX_TEXTURES 8 -#define MAX_FRAGMENT_SAMPLERS 16 -#define MAX_VERTEX_SAMPLERS 4 -#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS) -#define MAX_ACTIVE_LIGHTS 8 -#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES -#define MAX_CONSTANT_BUFFERS 15 -#define MAX_SAMPLER_OBJECTS 16 +#define MAX_STREAM_OUT 4 +#define MAX_STREAMS 16 +#define MAX_TEXTURES 8 +#define MAX_FRAGMENT_SAMPLERS 16 +#define MAX_VERTEX_SAMPLERS 4 +#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS) +#define MAX_ACTIVE_LIGHTS 8 +#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES +#define MAX_CONSTANT_BUFFERS 15 +#define MAX_SAMPLER_OBJECTS 16 +#define MAX_SHADER_RESOURCE_VIEWS 128 struct min_lookup { @@ -266,7 +267,7 @@ struct wined3d_settings unsigned short pci_vendor_id; unsigned short pci_device_id; /* Memory tracking and object counting. */ - unsigned int emulated_textureram; + UINT64 emulated_textureram; char *logo; int allow_multisampling; BOOL strict_draw_ordering; @@ -455,6 +456,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_DEFB, WINED3DSIH_DEFI, WINED3DSIH_DIV, + WINED3DSIH_DP2, WINED3DSIH_DP2ADD, WINED3DSIH_DP3, WINED3DSIH_DP4, @@ -478,6 +480,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_IFC, WINED3DSIH_IGE, WINED3DSIH_IMUL, + WINED3DSIH_ISHL, WINED3DSIH_ITOF, WINED3DSIH_LABEL, WINED3DSIH_LD, @@ -968,7 +971,10 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN; #define STATE_SHADER(a) (STATE_SAMPLER(MAX_COMBINED_SAMPLERS) + (a)) #define STATE_IS_SHADER(a) ((a) >= STATE_SHADER(0) && (a) < STATE_SHADER(WINED3D_SHADER_TYPE_COUNT)) -#define STATE_TRANSFORM(a) (STATE_SHADER(WINED3D_SHADER_TYPE_COUNT) + (a) - 1) +#define STATE_CONSTANT_BUFFER(a) (STATE_SHADER(WINED3D_SHADER_TYPE_COUNT) + (a)) +#define STATE_IS_CONSTANT_BUFFER(a) ((a) >= STATE_CONSTANT_BUFFER(0) && (a) < STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COUNT)) + +#define STATE_TRANSFORM(a) (STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COUNT) + (a) - 1) #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255))) #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1) @@ -1179,8 +1185,8 @@ struct wined3d_context struct wined3d_fb_state { - struct wined3d_surface **render_targets; - struct wined3d_surface *depth_stencil; + struct wined3d_rendertarget_view **render_targets; + struct wined3d_rendertarget_view *depth_stencil; }; typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id); @@ -1417,9 +1423,16 @@ enum wined3d_pci_device CARD_AMD_RADEON_HD6700 = 0x68ba, CARD_AMD_RADEON_HD6800 = 0x6739, CARD_AMD_RADEON_HD6900 = 0x6719, + CARD_AMD_RADEON_HD7660D = 0x9901, CARD_AMD_RADEON_HD7700 = 0x683d, CARD_AMD_RADEON_HD7800 = 0x6819, CARD_AMD_RADEON_HD7900 = 0x679a, + CARD_AMD_RADEON_HD8600M = 0x6660, + CARD_AMD_RADEON_HD8670 = 0x6610, + CARD_AMD_RADEON_HD8770 = 0x665c, + CARD_AMD_RADEON_R3 = 0x9830, + CARD_AMD_RADEON_R7 = 0x130f, + CARD_AMD_RADEON_R9 = 0x67b1, CARD_NVIDIA_RIVA_128 = 0x0018, CARD_NVIDIA_RIVA_TNT = 0x0020, @@ -1504,6 +1517,8 @@ enum wined3d_pci_device CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2, CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0, CARD_NVIDIA_GEFORCE_GTX770 = 0x1184, + CARD_NVIDIA_GEFORCE_GTX780 = 0x1004, + CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a, CARD_VMWARE_SVGA3D = 0x0405, @@ -1581,6 +1596,9 @@ struct wined3d_gl_limits UINT lights; UINT textures; UINT texture_coords; + UINT vertex_uniform_blocks; + UINT geometry_uniform_blocks; + UINT fragment_uniform_blocks; UINT fragment_samplers; UINT vertex_samplers; UINT combined_samplers; @@ -1633,7 +1651,7 @@ struct wined3d_driver_info enum wined3d_pci_device device; const char *name; const char *description; - unsigned int vidmem; + UINT64 vram_bytes; DWORD version_high; DWORD version_low; }; @@ -1682,8 +1700,8 @@ struct wined3d_adapter WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */ unsigned int cfg_count; struct wined3d_pixel_format *cfgs; - unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */ - unsigned int UsedTextureRam; + UINT64 vram_bytes; + UINT64 vram_bytes_used; LUID luid; const struct wined3d_vertex_pipe_ops *vertex_pipe; @@ -1693,7 +1711,7 @@ struct wined3d_adapter }; BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN; -unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount) DECLSPEC_HIDDEN; +UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN; BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; @@ -1853,10 +1871,13 @@ struct wined3d_state INT base_vertex_index; INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */ GLenum gl_primitive_type; + struct wined3d_query *predicate; + BOOL predicate_value; struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT]; struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS]; struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS]; + struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS]; BOOL vs_consts_b[MAX_CONST_B]; INT vs_consts_i[MAX_CONST_I * 4]; @@ -1937,6 +1958,7 @@ struct wined3d_device struct wined3d_device_creation_parameters create_parms; HWND focus_window; + struct wined3d_rendertarget_view *back_buffer_view; struct wined3d_swapchain **swapchains; UINT swapchain_count; @@ -1946,7 +1968,7 @@ struct wined3d_device /* Render Target Support */ struct wined3d_fb_state fb; struct wined3d_surface *onscreen_depth_stencil; - struct wined3d_surface *auto_depth_stencil; + struct wined3d_rendertarget_view *auto_depth_stencil_view; /* For rendering to a texture using glCopyTexImage */ GLuint depth_blt_texture; @@ -2012,6 +2034,8 @@ static inline void context_invalidate_active_texture(struct wined3d_context *con struct wined3d_resource_ops { + ULONG (*resource_incref)(struct wined3d_resource *resource); + ULONG (*resource_decref)(struct wined3d_resource *resource); void (*resource_unload)(struct wined3d_resource *resource); }; @@ -2028,6 +2052,8 @@ struct wined3d_resource DWORD usage; enum wined3d_pool pool; DWORD access_flags; + DWORD draw_binding; + DWORD map_binding; UINT width; UINT height; UINT depth; @@ -2041,22 +2067,31 @@ struct wined3d_resource const struct wined3d_resource_ops *resource_ops; }; +static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource) +{ + return resource->resource_ops->resource_incref(resource); +} + +static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource) +{ + return resource->resource_ops->resource_decref(resource); +} + void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN; -DWORD resource_get_priority(const struct wined3d_resource *resource) DECLSPEC_HIDDEN; HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device, enum wined3d_resource_type type, const struct wined3d_format *format, enum wined3d_multisample_type multisample_type, UINT multisample_quality, DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN; -DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority) DECLSPEC_HIDDEN; void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN; BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN; void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN; -DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, - DWORD flags) DECLSPEC_HIDDEN; GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN; GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN; +BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN; +DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, DWORD flags) DECLSPEC_HIDDEN; +void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN; /* Tests show that the start address of resources is 32 byte aligned */ #define RESOURCE_ALIGNMENT 16 @@ -2104,6 +2139,7 @@ struct wined3d_texture const struct wined3d_texture_ops *texture_ops; struct gl_texture texture_rgb, texture_srgb; struct wined3d_resource **sub_resources; + struct wined3d_swapchain *swapchain; UINT layer_count; UINT level_count; float pow2_matrix[16]; @@ -2144,11 +2180,8 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN; - -#define WINED3D_VFLAG_ALLOCATED 0x00000001 -#define WINED3D_VFLAG_SRGB_ALLOCATED 0x00000002 -#define WINED3D_VFLAG_PBO 0x00000004 -#define WINED3D_VFLAG_CLIENT_STORAGE 0x00000008 +void wined3d_texture_set_swapchain(struct wined3d_texture *texture, + struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; #define WINED3D_LOCATION_DISCARDED 0x00000001 #define WINED3D_LOCATION_SYSMEM 0x00000002 @@ -2181,9 +2214,9 @@ static inline struct wined3d_volume *volume_from_resource(struct wined3d_resourc HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc, unsigned int level, struct wined3d_volume **volume) DECLSPEC_HIDDEN; +void wined3d_volume_destroy(struct wined3d_volume *volume) DECLSPEC_HIDDEN; void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN; -void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) DECLSPEC_HIDDEN; void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN; void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_bo_address *data) DECLSPEC_HIDDEN; @@ -2217,7 +2250,6 @@ struct fbo_entry struct wined3d_surface_ops { HRESULT (*surface_private_setup)(struct wined3d_surface *surface); - void (*surface_realize_palette)(struct wined3d_surface *surface); void (*surface_unmap)(struct wined3d_surface *surface); }; @@ -2226,9 +2258,6 @@ struct wined3d_surface struct wined3d_resource resource; const struct wined3d_surface_ops *surface_ops; struct wined3d_texture *container; - struct wined3d_swapchain *swapchain; - struct wined3d_palette *palette; /* D3D7 style palette handling */ - DWORD draw_binding, map_binding; void *user_memory; DWORD locations; @@ -2238,15 +2267,13 @@ struct wined3d_surface UINT pow2Width; UINT pow2Height; - /* A method to retrieve the drawable size. Not in the Vtable to make it changeable */ - void (*get_drawable_size)(const struct wined3d_context *context, UINT *width, UINT *height); - /* PBO */ GLuint pbo; GLuint rb_multisample; GLuint rb_resolved; - GLint texture_level; GLenum texture_target; + unsigned int texture_level; + unsigned int texture_layer; RECT lockedRect; int lockCount; @@ -2285,8 +2312,9 @@ void surface_set_dirty(struct wined3d_surface *surface) DECLSPEC_HIDDEN; HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN; GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) DECLSPEC_HIDDEN; +void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context, + unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN; void surface_invalidate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN; -BOOL surface_is_offscreen(const struct wined3d_surface *surface) DECLSPEC_HIDDEN; void surface_load(struct wined3d_surface *surface, BOOL srgb) DECLSPEC_HIDDEN; void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; @@ -2299,22 +2327,17 @@ void surface_prepare_texture(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const struct wined3d_surface *rt) DECLSPEC_HIDDEN; -void surface_set_container(struct wined3d_surface *surface, struct wined3d_texture *container) DECLSPEC_HIDDEN; -void surface_set_swapchain(struct wined3d_surface *surface, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN; void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN; -void surface_update_draw_binding(struct wined3d_surface *surface) DECLSPEC_HIDDEN; HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point, struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN; void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN; -HRESULT CDECL wined3d_surface_create(struct wined3d_texture *container, - const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_surface **surface) DECLSPEC_HIDDEN; +HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc, + GLenum target, unsigned int level, unsigned int layer, DWORD flags, + struct wined3d_surface **surface) DECLSPEC_HIDDEN; +void wined3d_surface_destroy(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void surface_prepare_map_memory(struct wined3d_surface *surface) DECLSPEC_HIDDEN; -void get_drawable_size_swapchain(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN; -void get_drawable_size_backbuffer(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN; -void get_drawable_size_fbo(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN; - void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN; void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) DECLSPEC_HIDDEN; @@ -2348,7 +2371,6 @@ enum wined3d_conversion_type { WINED3D_CT_NONE, WINED3D_CT_PALETTED, - WINED3D_CT_PALETTED_CK, WINED3D_CT_CK_565, WINED3D_CT_CK_5551, WINED3D_CT_CK_RGB24, @@ -2356,8 +2378,6 @@ enum wined3d_conversion_type WINED3D_CT_CK_ARGB32, }; -void d3dfmt_p8_init_palette(const struct wined3d_surface *surface, BYTE table[256][4], BOOL colorkey) DECLSPEC_HIDDEN; - struct wined3d_sampler { LONG refcount; @@ -2494,14 +2514,19 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type, UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; -void wined3d_cs_emit_set_depth_stencil(struct wined3d_cs *cs, struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, + struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer, enum wined3d_format_id format_id) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, + struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN; -void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target_idx, - struct wined3d_surface *render_target) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx, + struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type, + UINT view_idx, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type, UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, @@ -2543,6 +2568,8 @@ struct wined3d_query_ops struct wined3d_query { LONG ref; + + void *parent; const struct wined3d_query_ops *query_ops; struct wined3d_device *device; enum query_state state; @@ -2600,6 +2627,7 @@ void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *co BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *context) DECLSPEC_HIDDEN; void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN; +void buffer_mark_used(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; struct wined3d_rendertarget_view { @@ -2607,6 +2635,42 @@ struct wined3d_rendertarget_view struct wined3d_resource *resource; void *parent; + const struct wined3d_parent_ops *parent_ops; + + const struct wined3d_format *format; + unsigned int sub_resource_idx; + unsigned int buffer_offset; + + unsigned int width; + unsigned int height; + unsigned int depth; +}; + +static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface( + const struct wined3d_rendertarget_view *view) +{ + struct wined3d_resource *resource; + struct wined3d_texture *texture; + + if (!view) + return NULL; + + if (view->resource->type != WINED3D_RTYPE_TEXTURE && view->resource->type != WINED3D_RTYPE_CUBE_TEXTURE) + return NULL; + + texture = wined3d_texture_from_resource(view->resource); + if (!(resource = wined3d_texture_get_sub_resource(texture, view->sub_resource_idx))) + return NULL; + + return surface_from_resource(resource); +} + +struct wined3d_shader_resource_view +{ + LONG refcount; + + void *parent; + const struct wined3d_parent_ops *parent_ops; }; struct wined3d_swapchain_ops @@ -2623,13 +2687,14 @@ struct wined3d_swapchain const struct wined3d_swapchain_ops *swapchain_ops; struct wined3d_device *device; - struct wined3d_surface **back_buffers; - struct wined3d_surface *front_buffer; + struct wined3d_texture **back_buffers; + struct wined3d_texture *front_buffer; struct wined3d_swapchain_desc desc; struct wined3d_display_mode original_mode; struct wined3d_gamma_ramp orig_gamma; BOOL render_to_fbo; const struct wined3d_format *ds_format; + struct wined3d_palette *palette; LONG prev_time, frames; /* Performance tracking */ @@ -2643,11 +2708,6 @@ struct wined3d_swapchain HWND backup_wnd; }; -static inline BOOL swapchain_is_p8(const struct wined3d_swapchain *swapchain) -{ - return swapchain->desc.backbuffer_format == WINED3DFMT_P8_UINT; -} - void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *rect) DECLSPEC_HIDDEN; struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; @@ -2964,10 +3024,8 @@ struct wined3d_palette LONG ref; struct wined3d_device *device; - HPALETTE hpal; - WORD palVersion; /*| */ - WORD palNumEntries; /*| LOGPALETTE */ - PALETTEENTRY palents[256]; /*| */ + unsigned int size; + RGBQUAD colors[256]; DWORD flags; }; @@ -3048,6 +3106,7 @@ struct wined3d_format const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id) DECLSPEC_HIDDEN; +UINT wined3d_format_calculate_pitch(const struct wined3d_format *format, UINT width) DECLSPEC_HIDDEN; UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN; DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, diff --git a/reactos/include/psdk/d3d8.h b/reactos/include/psdk/d3d8.h index 46e0812d799..8e709753879 100644 --- a/reactos/include/psdk/d3d8.h +++ b/reactos/include/psdk/d3d8.h @@ -129,6 +129,7 @@ typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLU /***************************************************************************** * IDirect3D8 interface */ +#undef INTERFACE #define INTERFACE IDirect3D8 DECLARE_INTERFACE_(IDirect3D8,IUnknown) { @@ -205,12 +206,12 @@ DECLARE_INTERFACE_(IDirect3DVolume8,IUnknown) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DVolume8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD(GetContainer)(THIS_ REFIID riid, void ** ppContainer) PURE; STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC * pDesc) PURE; - STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX * pBox, DWORD Flags) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) PURE; STDMETHOD(UnlockBox)(THIS) PURE; }; #undef INTERFACE @@ -256,7 +257,8 @@ DECLARE_INTERFACE_(IDirect3DSwapChain8,IUnknown) STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DSwapChain8 methods ***/ - STDMETHOD(Present)(THIS_ CONST RECT * pSourceRect, CONST RECT * pDestRect, HWND hDestWindowOverride,CONST RGNDATA * pDirtyRegion) PURE; + STDMETHOD(Present)(THIS_ const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, + const RGNDATA *dirty_region) PURE; STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer, D3DBACKBUFFER_TYPE Type, struct IDirect3DSurface8 ** ppBackBuffer) PURE; }; #undef INTERFACE @@ -267,7 +269,7 @@ DECLARE_INTERFACE_(IDirect3DSwapChain8,IUnknown) #define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) #define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) /*** IDirect3DSwapChain8 methods ***/ -#define IDirect3DSwapChain8_Present(p,a,b,c) (p)->lpVtbl->Present(p,a,b,c) +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) #define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) #else /*** IUnknown methods ***/ @@ -275,7 +277,7 @@ DECLARE_INTERFACE_(IDirect3DSwapChain8,IUnknown) #define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() #define IDirect3DSwapChain8_Release(p) (p)->Release() /*** IDirect3DSwapChain8 methods ***/ -#define IDirect3DSwapChain8_Present(p,a,b,c) (p)->Present(a,b,c) +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) #define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) #endif @@ -291,12 +293,12 @@ DECLARE_INTERFACE_(IDirect3DSurface8,IUnknown) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DSurface8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void * pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void * pData,DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD(GetContainer)(THIS_ REFIID riid, void ** ppContainer) PURE; STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC * pDesc) PURE; - STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT * pLockedRect, CONST RECT * pRect,DWORD Flags) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) PURE; STDMETHOD(UnlockRect)(THIS) PURE; }; #undef INTERFACE @@ -343,7 +345,7 @@ DECLARE_INTERFACE_(IDirect3DResource8,IUnknown) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -395,7 +397,7 @@ DECLARE_INTERFACE_(IDirect3DVertexBuffer8,IDirect3DResource8) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -459,7 +461,7 @@ DECLARE_INTERFACE_(IDirect3DIndexBuffer8,IDirect3DResource8) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -523,7 +525,7 @@ DECLARE_INTERFACE_(IDirect3DBaseTexture8,IDirect3DResource8) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -587,7 +589,7 @@ DECLARE_INTERFACE_(IDirect3DCubeTexture8,IDirect3DBaseTexture8) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -601,9 +603,10 @@ DECLARE_INTERFACE_(IDirect3DCubeTexture8,IDirect3DBaseTexture8) /*** IDirect3DCubeTexture8 methods ***/ STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC * pDesc) PURE; STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8 ** ppCubeMapSurface) PURE; - STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT * pLockedRect,CONST RECT * pRect,DWORD Flags) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES face, UINT level, D3DLOCKED_RECT *locked_rect, + const RECT *rect, DWORD flags) PURE; STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT * pDirtyRect) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES face, const RECT *dirty_rect) PURE; }; #undef INTERFACE @@ -669,7 +672,7 @@ DECLARE_INTERFACE_(IDirect3DTexture8,IDirect3DBaseTexture8) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -683,9 +686,9 @@ DECLARE_INTERFACE_(IDirect3DTexture8,IDirect3DBaseTexture8) /*** IDirect3DTexture8 methods ***/ STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC * pDesc) PURE; STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8 ** ppSurfaceLevel) PURE; - STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT * pLockedRect,CONST RECT * pRect,DWORD Flags) PURE; + STDMETHOD(LockRect)(THIS_ UINT level, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) PURE; STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ CONST RECT * pDirtyRect) PURE; + STDMETHOD(AddDirtyRect)(THIS_ const RECT *dirty_rect) PURE; }; #undef INTERFACE @@ -751,7 +754,7 @@ DECLARE_INTERFACE_(IDirect3DVolumeTexture8,IDirect3DBaseTexture8) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource8 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8 ** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -765,9 +768,9 @@ DECLARE_INTERFACE_(IDirect3DVolumeTexture8,IDirect3DBaseTexture8) /*** IDirect3DVolumeTexture8 methods ***/ STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC * pDesc) PURE; STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8 ** ppVolumeLevel) PURE; - STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX * pBox,DWORD Flags) PURE; + STDMETHOD(LockBox)(THIS_ UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) PURE; STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX * pDirtyBox) PURE; + STDMETHOD(AddDirtyBox)(THIS_ const D3DBOX *dirty_box) PURE; }; #undef INTERFACE @@ -844,10 +847,11 @@ DECLARE_INTERFACE_(IDirect3DDevice8,IUnknown) STDMETHOD_(BOOL,ShowCursor)(THIS_ BOOL bShow) PURE; STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS * pPresentationParameters, IDirect3DSwapChain8 ** pSwapChain) PURE; STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS * pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT * pSourceRect,CONST RECT * pDestRect,HWND hDestWindowOverride,CONST RGNDATA * pDirtyRegion) PURE; + STDMETHOD(Present)(THIS_ const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, + const RGNDATA *dirty_region) PURE; STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8 ** ppBackBuffer) PURE; STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS * pRasterStatus) PURE; - STDMETHOD_(void,SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP * pRamp) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD flags, const D3DGAMMARAMP *ramp) PURE; STDMETHOD_(void,GetGammaRamp)(THIS_ D3DGAMMARAMP * pRamp) PURE; STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8 ** ppTexture) PURE; STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8 ** ppVolumeTexture) PURE; @@ -857,7 +861,8 @@ DECLARE_INTERFACE_(IDirect3DDevice8,IUnknown) STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8 ** ppSurface) PURE; STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8 ** ppSurface) PURE; STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8 ** ppSurface) PURE; - STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8 * pSourceSurface,CONST RECT * pSourceRectsArray,UINT cRects,IDirect3DSurface8 * pDestinationSurface,CONST POINT * pDestPointsArray) PURE; + STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8 *src_surface, const RECT *src_rects, + UINT rect_count, IDirect3DSurface8 *dst_surface, const POINT *dst_points) PURE; STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8 * pSourceTexture,IDirect3DBaseTexture8 * pDestinationTexture) PURE; STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8 * pDestSurface) PURE; STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8 * pRenderTarget,IDirect3DSurface8 * pNewZStencil) PURE; @@ -865,19 +870,20 @@ DECLARE_INTERFACE_(IDirect3DDevice8,IUnknown) STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8 ** ppZStencilSurface) PURE; STDMETHOD(BeginScene)(THIS) PURE; STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT * pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX * pMatrix) PURE; + STDMETHOD(Clear)(THIS_ DWORD rect_count, const D3DRECT *rects, DWORD flags, D3DCOLOR color, + float z, DWORD stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix) PURE; STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX * pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX * pMatrix) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8 * pViewport) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix) PURE; + STDMETHOD(SetViewport)(THIS_ const D3DVIEWPORT8 *viewport) PURE; STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8 * pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8 * pMaterial) PURE; + STDMETHOD(SetMaterial)(THIS_ const D3DMATERIAL8 *material) PURE; STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8 *pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8 * pLight) PURE; + STDMETHOD(SetLight)(THIS_ DWORD index, const D3DLIGHT8 *light) PURE; STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8 * pLight) PURE; STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL * pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float * pPlane) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD index, const float *plane) PURE; STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float * pPlane) PURE; STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD * pValue) PURE; @@ -887,7 +893,7 @@ DECLARE_INTERFACE_(IDirect3DDevice8,IUnknown) STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD * pToken) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8 * pClipStatus) PURE; + STDMETHOD(SetClipStatus)(THIS_ const D3DCLIPSTATUS8 *clip_status) PURE; STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8 * pClipStatus) PURE; STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8 ** ppTexture) PURE; STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8 * pTexture) PURE; @@ -895,20 +901,24 @@ DECLARE_INTERFACE_(IDirect3DDevice8,IUnknown) STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; STDMETHOD(ValidateDevice)(THIS_ DWORD * pNumPasses) PURE; STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void * pDevInfoStruct,DWORD DevInfoStructSize) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY * pEntries) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT palette_idx, const PALETTEENTRY *entries) PURE; STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY * pEntries) PURE; STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT * PaletteNumber) PURE; STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void * pIndexData,D3DFORMAT IndexDataFormat,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE primitive_type, UINT primitive_count, + const void *data, UINT stride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE primitive_type, UINT min_vertex_idx, + UINT vertex_count, UINT primitive_count, const void *index_data, D3DFORMAT index_format, + const void *data, UINT stride) PURE; STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8 * pDestBuffer,DWORD Flags) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD * pDeclaration,CONST DWORD * pFunction,DWORD * pHandle,DWORD Usage) PURE; + STDMETHOD(CreateVertexShader)(THIS_ const DWORD *declaration, const DWORD *byte_code, + DWORD *shader, DWORD usage) PURE; STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; STDMETHOD(GetVertexShader)(THIS_ DWORD * pHandle) PURE; STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void * pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD reg_idx, const void *data, DWORD count) PURE; STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void * pConstantData,DWORD ConstantCount) PURE; STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void * pData,DWORD * pSizeOfData) PURE; STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void * pData,DWORD * pSizeOfData) PURE; @@ -916,15 +926,17 @@ DECLARE_INTERFACE_(IDirect3DDevice8,IUnknown) STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8 ** ppStreamData,UINT * pStride) PURE; STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8 * pIndexData,UINT BaseVertexIndex) PURE; STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8 ** ppIndexData,UINT * pBaseVertexIndex) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD * pFunction,DWORD * pHandle) PURE; + STDMETHOD(CreatePixelShader)(THIS_ const DWORD *byte_code, DWORD *shader) PURE; STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; STDMETHOD(GetPixelShader)(THIS_ DWORD * pHandle) PURE; STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void * pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD reg_idx, const void *data, DWORD count) PURE; STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void * pConstantData,DWORD ConstantCount) PURE; STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void * pData,DWORD * pSizeOfData) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float * pNumSegs,CONST D3DRECTPATCH_INFO * pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float * pNumSegs,CONST D3DTRIPATCH_INFO * pTriPatchInfo) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT handle, const float *segment_count, + const D3DRECTPATCH_INFO *patch_info) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT handle, const float *segment_count, + const D3DTRIPATCH_INFO *patch_info) PURE; STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; }; #undef INTERFACE diff --git a/reactos/include/psdk/d3d8types.h b/reactos/include/psdk/d3d8types.h index 609cd9c9910..65ea0f82ccf 100644 --- a/reactos/include/psdk/d3d8types.h +++ b/reactos/include/psdk/d3d8types.h @@ -154,7 +154,7 @@ ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) #endif -/**************************** +/**************************** * Vertex Shaders Declaration */ @@ -170,7 +170,7 @@ typedef enum _D3DVSD_TOKENTYPE { D3DVSD_FORCE_DWORD = 0x7FFFFFFF } D3DVSD_TOKENTYPE; -/** input registers for vertes shaders functions */ +/** input registers for vertex shaders functions */ /* #define D3DVSDE_POSITION 0 #define D3DVSDE_BLENDWEIGHT 1 @@ -683,7 +683,7 @@ typedef enum _D3DMULTISAMPLE_TYPE { D3DMULTISAMPLE_15_SAMPLES = 15, D3DMULTISAMPLE_16_SAMPLES = 16, - D3DMULTISAMPLE_FORCE_DWORD = 0xffffffff + D3DMULTISAMPLE_FORCE_DWORD = 0x7fffffff } D3DMULTISAMPLE_TYPE; typedef enum _D3DORDERTYPE { @@ -1053,11 +1053,14 @@ typedef struct _D3DINDEXBUFFER_DESC { UINT Size; } D3DINDEXBUFFER_DESC; +#ifndef D3DVECTOR_DEFINED typedef struct _D3DVECTOR { float x; float y; float z; } D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif typedef struct _D3DLIGHT8 { D3DLIGHTTYPE Type; @@ -1131,6 +1134,8 @@ typedef struct _D3DPRESENT_PARAMETERS_ { } D3DPRESENT_PARAMETERS; +#define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER 0x00000001 + typedef struct _D3DRANGE { UINT Offset; UINT Size; diff --git a/reactos/include/psdk/d3d9.h b/reactos/include/psdk/d3d9.h index c538cd7ea42..0a1065c40c5 100644 --- a/reactos/include/psdk/d3d9.h +++ b/reactos/include/psdk/d3d9.h @@ -17,8 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __WINE_D3D9_H -#define __WINE_D3D9_H +#ifndef _D3D9_H_ +#define _D3D9_H_ #ifndef DIRECT3D_VERSION #define DIRECT3D_VERSION 0x0900 @@ -47,6 +47,12 @@ #define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L #define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L #define D3DCREATE_ADAPTERGROUP_DEVICE 0x00000200L +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX 0x00000400L +#define D3DCREATE_NOWINDOWCHANGES 0x00000800L +#define D3DCREATE_DISABLE_PSGP_THREADING 0x00002000L +#define D3DCREATE_ENABLE_PRESENTSTATS 0x00004000L +#define D3DCREATE_DISABLE_PRINTSCREEN 0x00008000L +#define D3DCREATE_SCREENSAVER 0x10000000L /***************************************************************************** * Flags for SetPrivateData @@ -57,16 +63,8 @@ /***************************************************************************** * #defines and error codes */ -#ifdef D3D_DEBUG_INFO -#define D3D_SDK_VERSION (32 | 0x80000000L) -#define D3D9b_SDK_VERSION (31 | 0x80000000L) -#else #define D3D_SDK_VERSION 32 -#define D3D9b_SDK_VERSION 31 -#endif - #define D3DADAPTER_DEFAULT 0 -#define D3DENUM_WHQL_LEVEL 0x00000002L #define D3DENUM_NO_WHQL_LEVEL 0x00000002L #define D3DPRESENT_BACK_BUFFERS_MAX 3L #define D3DSGR_NO_CALIBRATION 0x00000000L @@ -104,6 +102,18 @@ #define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540) #define D3DOK_NOAUTOGEN MAKE_D3DSTATUS(2159) +#define D3DERR_DEVICEREMOVED MAKE_D3DHRESULT(2160) +#define D3DERR_DEVICEHUNG MAKE_D3DHRESULT(2164) +#define S_NOT_RESIDENT MAKE_D3DSTATUS(2165) +#define S_RESIDENT_IN_SHARED_MEMORY MAKE_D3DSTATUS(2166) +#define S_PRESENT_MODE_CHANGED MAKE_D3DSTATUS(2167) +#define S_PRESENT_OCCLUDED MAKE_D3DSTATUS(2168) +#define D3DERR_UNSUPPORTEDOVERLAY MAKE_D3DHRESULT(2171) +#define D3DERR_UNSUPPORTEDOVERLAYFORMAT MAKE_D3DHRESULT(2172) +#define D3DERR_CANNOTPROTECTCONTENT MAKE_D3DHRESULT(2173) +#define D3DERR_UNSUPPORTEDCRYPTO MAKE_D3DHRESULT(2174) +#define D3DERR_PRESENT_STATISTICS_DISJOINT MAKE_D3DHRESULT(2180) + /***************************************************************************** * Predeclare the interfaces @@ -132,7 +142,7 @@ typedef struct IDirect3DVolume9 *LPDIRECT3DVOLUME9, *PDIRECT3DVOLUME9; DEFINE_GUID(IID_IDirect3DSwapChain9, 0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b); typedef struct IDirect3DSwapChain9 *LPDIRECT3DSWAPCHAIN9, *PDIRECT3DSWAPCHAIN9; -DEFINE_GUID(IID_IDirect3DSwapChain9Ex, 0x91886caf, 0x1c3d, 0x4d2e, 0xa0, 0xab, 0x3e, 0x4c, 0x7d, 0x8d, 0x33, 0x3); +DEFINE_GUID(IID_IDirect3DSwapChain9Ex, 0x91886caf, 0x1c3d, 0x4d2e, 0xa0, 0xab, 0x3e, 0x4c, 0x7d, 0x8d, 0x33, 0x3); typedef struct IDirect3DSwapChain9Ex *LPDIRECT3DSWAPCHAIN9EX, *PDIRECT3DSWAPCHAIN9EX; DEFINE_GUID(IID_IDirect3DSurface9, 0xcfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b); @@ -171,6 +181,7 @@ typedef struct IDirect3DQuery9 *LPDIRECT3DQUERY9, *PDIRECT3DQUERY9; /***************************************************************************** * IDirect3D9 interface */ +#undef INTERFACE #define INTERFACE IDirect3D9 DECLARE_INTERFACE_(IDirect3D9,IUnknown) { @@ -193,14 +204,13 @@ DECLARE_INTERFACE_(IDirect3D9,IUnknown) STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) PURE; STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, struct IDirect3DDevice9** ppReturnedDeviceInterface) PURE; - -#ifdef D3D_DEBUG_INFO - LPCWSTR Version; -#endif - }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3D9, 0x81BDCBCA, 0x64D4, 0x426D, 0xAE, 0x8D, 0xAD, 0x1, 0x47, 0xF4, 0x27, 0x5C); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3D9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -254,7 +264,15 @@ DECLARE_INTERFACE_(IDirect3D9Ex,IDirect3D9) STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3D9 methods ***/ + + /* Note: Microsoft's d3d9.h does not declare IDirect3D9Ex::RegisterSoftwareDevice . This would mean that + * the offsets of the other methods in the Vtable change too. This is wrong. In Microsoft's + * d3d9.dll, the offsets for the other functions are still compatible with IDirect3D9. + * This is probably because even in MS header IDirect3D9Ex inherits from IDirect3D9, which makes the + * C++ interface compatible, and nobody uses the C interface in Windows world. + */ STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) PURE; STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter, D3DFORMAT Format) PURE; @@ -269,14 +287,19 @@ DECLARE_INTERFACE_(IDirect3D9Ex,IDirect3D9) STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, struct IDirect3DDevice9** ppReturnedDeviceInterface) PURE; /*** IDirect3D9Ex methods ***/ - STDMETHOD_(UINT, GetAdapterModeCountEx)(THIS_ UINT Adapter, CONST D3DDISPLAYMODEFILTER *pFilter) PURE; - STDMETHOD(EnumAdapterModesEx)(THIS_ UINT Adapter, CONST D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode) PURE; + STDMETHOD_(UINT, GetAdapterModeCountEx)(THIS_ UINT adapter_idx, const D3DDISPLAYMODEFILTER *filter) PURE; + STDMETHOD(EnumAdapterModesEx)(THIS_ UINT adapter_idx, const D3DDISPLAYMODEFILTER *filter, + UINT mode_idx, D3DDISPLAYMODEEX *mode) PURE; STDMETHOD(GetAdapterDisplayModeEx)(THIS_ UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation); STDMETHOD(CreateDeviceEx)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, struct IDirect3DDevice9Ex **ppReturnedDeviceInterface) PURE; STDMETHOD(GetAdapterLUID)(THIS_ UINT Adatper, LUID *pLUID) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3D9Ex, 0x02177241, 0x69FC, 0x400C, 0x8F, 0xF1, 0x93, 0xA4, 0x4D, 0xF6, 0x86, 0x1D); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3D9Ex_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -337,16 +360,20 @@ DECLARE_INTERFACE_(IDirect3DVolume9,IUnknown) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DVolume9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD(GetContainer)(THIS_ REFIID riid, void** ppContainer) PURE; STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC* pDesc) PURE; - STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) PURE; STDMETHOD(UnlockBox)(THIS) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DVolume9, 0x24f416e6, 0x1f67, 0x4aa7, 0xb8, 0x8e, 0xd3, 0x3f, 0x6f, 0x31, 0x28, 0xa1); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DVolume9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -384,20 +411,25 @@ DECLARE_INTERFACE_(IDirect3DVolume9,IUnknown) DECLARE_INTERFACE_(IDirect3DSwapChain9,IUnknown) { /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DSwapChain9 methods ***/ - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) PURE; - STDMETHOD(GetFrontBufferData)(THIS_ struct IDirect3DSurface9* pDestSurface) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, struct IDirect3DSurface9** ppBackBuffer) PURE; - STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; - STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, + const RGNDATA *dirty_region, DWORD flags) PURE; + STDMETHOD(GetFrontBufferData)(THIS_ struct IDirect3DSurface9 *pDestSurface) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, struct IDirect3DSurface9 **ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS *pRasterStatus) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE *pMode) PURE; + STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9 **ppDevice) PURE; + STDMETHOD(GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS *pPresentationParameters) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DSwapChain9, 0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -452,6 +484,10 @@ DECLARE_INTERFACE_(IDirect3DSwapChain9Ex,IDirect3DSwapChain9) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DSwapChain9Ex, 0x91886caf, 0x1c3d, 0x4d2e, 0xa0, 0xab, 0x3e, 0x4c, 0x7d, 0x8d, 0x33, 0x3); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DSwapChain9Ex_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -500,7 +536,7 @@ DECLARE_INTERFACE_(IDirect3DResource9,IUnknown) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -510,6 +546,10 @@ DECLARE_INTERFACE_(IDirect3DResource9,IUnknown) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DResource9, 0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DResource9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -552,7 +592,7 @@ DECLARE_INTERFACE_(IDirect3DSurface9,IDirect3DResource9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -562,13 +602,17 @@ DECLARE_INTERFACE_(IDirect3DSurface9,IDirect3DResource9) /*** IDirect3DSurface9 methods ***/ STDMETHOD(GetContainer)(THIS_ REFIID riid, void** ppContainer) PURE; STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC* pDesc) PURE; - STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) PURE; STDMETHOD(UnlockRect)(THIS) PURE; STDMETHOD(GetDC)(THIS_ HDC* phdc) PURE; STDMETHOD(ReleaseDC)(THIS_ HDC hdc) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DSurface9, 0xcfbaf3a, 0x9ff6, 0x429a, 0x99, 0xb3, 0xa2, 0x79, 0x6a, 0xf8, 0xb8, 0x9b); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DSurface9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -625,7 +669,7 @@ DECLARE_INTERFACE_(IDirect3DVertexBuffer9,IDirect3DResource9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -639,6 +683,10 @@ DECLARE_INTERFACE_(IDirect3DVertexBuffer9,IDirect3DResource9) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DVertexBuffer9, 0xb64bb1b5, 0xfd70, 0x4df6, 0xbf, 0x91, 0x19, 0xd0, 0xa1, 0x24, 0x55, 0xe3); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -689,7 +737,7 @@ DECLARE_INTERFACE_(IDirect3DIndexBuffer9,IDirect3DResource9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -703,6 +751,10 @@ DECLARE_INTERFACE_(IDirect3DIndexBuffer9,IDirect3DResource9) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DIndexBuffer9, 0x7c9dd65e, 0xd3f7, 0x4529, 0xac, 0xee, 0x78, 0x58, 0x30, 0xac, 0xde, 0x35); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -753,7 +805,7 @@ DECLARE_INTERFACE_(IDirect3DBaseTexture9,IDirect3DResource9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -770,6 +822,10 @@ DECLARE_INTERFACE_(IDirect3DBaseTexture9,IDirect3DResource9) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DBaseTexture9, 0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -826,7 +882,7 @@ DECLARE_INTERFACE_(IDirect3DCubeTexture9,IDirect3DBaseTexture9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -843,12 +899,17 @@ DECLARE_INTERFACE_(IDirect3DCubeTexture9,IDirect3DBaseTexture9) /*** IDirect3DCubeTexture9 methods ***/ STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC* pDesc) PURE; STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) PURE; - STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES face, UINT level, + D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) PURE; STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType, UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES face, const RECT *dirty_rect) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DCubeTexture9, 0xfff32f81, 0xd953, 0x473a, 0x92, 0x23, 0x93, 0xd6, 0x52, 0xab, 0xa9, 0x3f); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -917,7 +978,7 @@ DECLARE_INTERFACE_(IDirect3DTexture9,IDirect3DBaseTexture9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -934,12 +995,16 @@ DECLARE_INTERFACE_(IDirect3DTexture9,IDirect3DBaseTexture9) /*** IDirect3DTexture9 methods ***/ STDMETHOD(GetLevelDesc)(THIS_ UINT Level, D3DSURFACE_DESC* pDesc) PURE; STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level, IDirect3DSurface9** ppSurfaceLevel) PURE; - STDMETHOD(LockRect)(THIS_ UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) PURE; + STDMETHOD(LockRect)(THIS_ UINT level, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) PURE; STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; + STDMETHOD(AddDirtyRect)(THIS_ const RECT *dirty_rect) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DTexture9, 0x85c31227, 0x3de5, 0x4f00, 0x9b, 0x3a, 0xf1, 0x1a, 0xc3, 0x8c, 0x18, 0xb5); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1008,7 +1073,7 @@ DECLARE_INTERFACE_(IDirect3DVolumeTexture9,IDirect3DBaseTexture9) STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IDirect3DResource9 methods ***/ STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice9** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID guid, const void *data, DWORD data_size, DWORD flags) PURE; STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) PURE; STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; @@ -1025,12 +1090,16 @@ DECLARE_INTERFACE_(IDirect3DVolumeTexture9,IDirect3DBaseTexture9) /*** IDirect3DVolumeTexture9 methods ***/ STDMETHOD(GetLevelDesc)(THIS_ UINT Level, D3DVOLUME_DESC *pDesc) PURE; STDMETHOD(GetVolumeLevel)(THIS_ UINT Level, IDirect3DVolume9** ppVolumeLevel) PURE; - STDMETHOD(LockBox)(THIS_ UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) PURE; + STDMETHOD(LockBox)(THIS_ UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) PURE; STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; + STDMETHOD(AddDirtyBox)(THIS_ const D3DBOX *dirty_box) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DVolumeTexture9, 0x2518526c, 0xe789, 0x4111, 0xa7, 0xb9, 0x47, 0xef, 0x32, 0x8d, 0x13, 0xe6); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1103,6 +1172,10 @@ DECLARE_INTERFACE_(IDirect3DVertexDeclaration9,IUnknown) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DVertexDeclaration9, 0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1137,6 +1210,10 @@ DECLARE_INTERFACE_(IDirect3DVertexShader9,IUnknown) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DVertexShader9, 0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1171,6 +1248,10 @@ DECLARE_INTERFACE_(IDirect3DPixelShader9,IUnknown) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DPixelShader9, 0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1206,6 +1287,10 @@ DECLARE_INTERFACE_(IDirect3DStateBlock9,IUnknown) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DStateBlock9, 0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1245,6 +1330,10 @@ DECLARE_INTERFACE_(IDirect3DQuery9,IUnknown) }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DQuery9, 0xd9771460, 0xa695, 0x4f26, 0xbb, 0xd3, 0x27, 0xb8, 0x40, 0xb5, 0x41, 0xcc); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DQuery9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1294,11 +1383,12 @@ DECLARE_INTERFACE_(IDirect3DDevice9,IUnknown) STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) PURE; STDMETHOD_(UINT, GetNumberOfSwapChains)(THIS) PURE; STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(Present)(THIS_ const RECT *src_rect, const RECT *dst_rect, + HWND dst_window_override, const RGNDATA *dirty_region) PURE; STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) PURE; STDMETHOD(GetRasterStatus)(THIS_ UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) PURE; STDMETHOD(SetDialogBoxMode)(THIS_ BOOL bEnableDialogs) PURE; - STDMETHOD_(void, SetGammaRamp)(THIS_ UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ UINT swapchain_idx, DWORD flags, const D3DGAMMARAMP *ramp) PURE; STDMETHOD_(void, GetGammaRamp)(THIS_ UINT iSwapChain, D3DGAMMARAMP* pRamp) PURE; STDMETHOD(CreateTexture)(THIS_ UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) PURE; STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) PURE; @@ -1307,12 +1397,14 @@ DECLARE_INTERFACE_(IDirect3DDevice9,IUnknown) STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) PURE; STDMETHOD(CreateRenderTarget)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) PURE; STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) PURE; - STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) PURE; + STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9 *src_surface, const RECT *src_rect, + IDirect3DSurface9 *dst_surface, const POINT *dst_point) PURE; STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) PURE; STDMETHOD(GetRenderTargetData)(THIS_ IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) PURE; STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain, IDirect3DSurface9* pDestSurface) PURE; - STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) PURE; - STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) PURE; + STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9 *src_surface, const RECT *src_rect, + IDirect3DSurface9 *dst_surface, const RECT *dst_rect, D3DTEXTUREFILTERTYPE filter) PURE; + STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9 *surface, const RECT *rect, D3DCOLOR color) PURE; STDMETHOD(CreateOffscreenPlainSurface)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) PURE; STDMETHOD(SetRenderTarget)(THIS_ DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) PURE; STDMETHOD(GetRenderTarget)(THIS_ DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) PURE; @@ -1320,26 +1412,27 @@ DECLARE_INTERFACE_(IDirect3DDevice9,IUnknown) STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface9** ppZStencilSurface) PURE; STDMETHOD(BeginScene)(THIS) PURE; STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(Clear)(THIS_ DWORD rect_count, const D3DRECT *rects, DWORD flags, + D3DCOLOR color, float z, DWORD stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix) PURE; STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE, CONST D3DMATRIX*) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix) PURE; + STDMETHOD(SetViewport)(THIS_ const D3DVIEWPORT9 *viewport) PURE; STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT9* pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9* pMaterial) PURE; + STDMETHOD(SetMaterial)(THIS_ const D3DMATERIAL9 *material) PURE; STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL9* pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index, CONST D3DLIGHT9*) PURE; + STDMETHOD(SetLight)(THIS_ DWORD index, const D3DLIGHT9 *light) PURE; STDMETHOD(GetLight)(THIS_ DWORD Index, D3DLIGHT9*) PURE; STDMETHOD(LightEnable)(THIS_ DWORD Index, BOOL Enable) PURE; STDMETHOD(GetLightEnable)(THIS_ DWORD Index, BOOL* pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index, CONST float* pPlane) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD index, const float *plane) PURE; STDMETHOD(GetClipPlane)(THIS_ DWORD Index, float* pPlane) PURE; STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State, DWORD Value) PURE; STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State, DWORD* pValue) PURE; STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) PURE; STDMETHOD(BeginStateBlock)(THIS) PURE; STDMETHOD(EndStateBlock)(THIS_ IDirect3DStateBlock9** ppSB) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS9* pClipStatus) PURE; + STDMETHOD(SetClipStatus)(THIS_ const D3DCLIPSTATUS9 *clip_status) PURE; STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS9* pClipStatus) PURE; STDMETHOD(GetTexture)(THIS_ DWORD Stage, IDirect3DBaseTexture9** ppTexture) PURE; STDMETHOD(SetTexture)(THIS_ DWORD Stage, IDirect3DBaseTexture9* pTexture) PURE; @@ -1348,11 +1441,11 @@ DECLARE_INTERFACE_(IDirect3DDevice9,IUnknown) STDMETHOD(GetSamplerState)(THIS_ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) PURE; STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) PURE; STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber, CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT palette_idx, const PALETTEENTRY *entries) PURE; STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; - STDMETHOD(SetScissorRect)(THIS_ CONST RECT* pRect) PURE; + STDMETHOD(SetScissorRect)(THIS_ const RECT *rect) PURE; STDMETHOD(GetScissorRect)(THIS_ RECT* pRect) PURE; STDMETHOD(SetSoftwareVertexProcessing)(THIS_ BOOL bSoftware) PURE; STDMETHOD_(BOOL, GetSoftwareVertexProcessing)(THIS) PURE; @@ -1360,22 +1453,25 @@ DECLARE_INTERFACE_(IDirect3DDevice9,IUnknown) STDMETHOD_(float, GetNPatchMode)(THIS) PURE; STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) PURE; STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE primitive_type, + UINT primitive_count, const void *data, UINT stride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE primitive_type, UINT min_vertex_idx, UINT vertex_count, + UINT primitive_count, const void *index_data, D3DFORMAT index_format, const void *data, UINT stride) PURE; STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) PURE; - STDMETHOD(CreateVertexDeclaration)(THIS_ CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) PURE; + STDMETHOD(CreateVertexDeclaration)(THIS_ const D3DVERTEXELEMENT9 *elements, + IDirect3DVertexDeclaration9 **declaration) PURE; STDMETHOD(SetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9* pDecl) PURE; STDMETHOD(GetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9** ppDecl) PURE; STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; STDMETHOD(GetFVF)(THIS_ DWORD* pFVF) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) PURE; + STDMETHOD(CreateVertexShader)(THIS_ const DWORD *byte_code, IDirect3DVertexShader9 **shader) PURE; STDMETHOD(SetVertexShader)(THIS_ IDirect3DVertexShader9* pShader) PURE; STDMETHOD(GetVertexShader)(THIS_ IDirect3DVertexShader9** ppShader) PURE; - STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) PURE; + STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT reg_idx, const float *data, UINT count) PURE; STDMETHOD(GetVertexShaderConstantF)(THIS_ UINT StartRegister, float* pConstantData, UINT Vector4fCount) PURE; - STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) PURE; + STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT reg_idx, const int *data, UINT count) PURE; STDMETHOD(GetVertexShaderConstantI)(THIS_ UINT StartRegister, int* pConstantData, UINT Vector4iCount) PURE; - STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) PURE; + STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT reg_idx, const BOOL *data, UINT count) PURE; STDMETHOD(GetVertexShaderConstantB)(THIS_ UINT StartRegister, BOOL* pConstantData, UINT BoolCount) PURE; STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) PURE; STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) PURE; @@ -1383,22 +1479,26 @@ DECLARE_INTERFACE_(IDirect3DDevice9,IUnknown) STDMETHOD(GetStreamSourceFreq)(THIS_ UINT StreamNumber, UINT* Divider) PURE; STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer9* pIndexData) PURE; STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer9** ppIndexData) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) PURE; + STDMETHOD(CreatePixelShader)(THIS_ const DWORD *byte_code, IDirect3DPixelShader9 **shader) PURE; STDMETHOD(SetPixelShader)(THIS_ IDirect3DPixelShader9* pShader) PURE; STDMETHOD(GetPixelShader)(THIS_ IDirect3DPixelShader9** ppShader) PURE; - STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) PURE; + STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT reg_idx, const float *data, UINT count) PURE; STDMETHOD(GetPixelShaderConstantF)(THIS_ UINT StartRegister, float* pConstantData, UINT Vector4fCount) PURE; - STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) PURE; + STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT reg_idx, const int *data, UINT count) PURE; STDMETHOD(GetPixelShaderConstantI)(THIS_ UINT StartRegister, int* pConstantData, UINT Vector4iCount) PURE; - STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) PURE; + STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT reg_idx, const BOOL *data, UINT count) PURE; STDMETHOD(GetPixelShaderConstantB)(THIS_ UINT StartRegister, BOOL* pConstantData, UINT BoolCount) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT handle, const float *segment_count, const D3DRECTPATCH_INFO *patch_info) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT handle, const float *segment_count, const D3DTRIPATCH_INFO *patch_info) PURE; STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; STDMETHOD(CreateQuery)(THIS_ D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DDevice9, 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DDevice9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -1671,11 +1771,12 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) PURE; STDMETHOD_(UINT, GetNumberOfSwapChains)(THIS) PURE; STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(Present)(THIS_ const RECT *src_rect, const RECT *dst_rect, + HWND dst_window_override, const RGNDATA *dirty_region) PURE; STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) PURE; STDMETHOD(GetRasterStatus)(THIS_ UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) PURE; STDMETHOD(SetDialogBoxMode)(THIS_ BOOL bEnableDialogs) PURE; - STDMETHOD_(void, SetGammaRamp)(THIS_ UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ UINT swapchain_idx, DWORD flags, const D3DGAMMARAMP *ramp) PURE; STDMETHOD_(void, GetGammaRamp)(THIS_ UINT iSwapChain, D3DGAMMARAMP* pRamp) PURE; STDMETHOD(CreateTexture)(THIS_ UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) PURE; STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) PURE; @@ -1684,12 +1785,14 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) PURE; STDMETHOD(CreateRenderTarget)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) PURE; STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) PURE; - STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) PURE; + STDMETHOD(UpdateSurface)(THIS_ IDirect3DSurface9 *src_surface, const RECT *src_rect, + IDirect3DSurface9 *dst_surface, const POINT *dst_point) PURE; STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) PURE; STDMETHOD(GetRenderTargetData)(THIS_ IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) PURE; STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain, IDirect3DSurface9* pDestSurface) PURE; - STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) PURE; - STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) PURE; + STDMETHOD(StretchRect)(THIS_ IDirect3DSurface9 *src_surface, const RECT *src_rect, + IDirect3DSurface9 *dst_surface, const RECT *dst_rect, D3DTEXTUREFILTERTYPE filter) PURE; + STDMETHOD(ColorFill)(THIS_ IDirect3DSurface9 *surface, const RECT *rect, D3DCOLOR color) PURE; STDMETHOD(CreateOffscreenPlainSurface)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) PURE; STDMETHOD(SetRenderTarget)(THIS_ DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) PURE; STDMETHOD(GetRenderTarget)(THIS_ DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) PURE; @@ -1697,26 +1800,27 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface9** ppZStencilSurface) PURE; STDMETHOD(BeginScene)(THIS) PURE; STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(Clear)(THIS_ DWORD rect_count, const D3DRECT *rects, DWORD flags, + D3DCOLOR color, float z, DWORD stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix) PURE; STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE, CONST D3DMATRIX*) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT9* pViewport) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix) PURE; + STDMETHOD(SetViewport)(THIS_ const D3DVIEWPORT9 *viewport) PURE; STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT9* pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL9* pMaterial) PURE; + STDMETHOD(SetMaterial)(THIS_ const D3DMATERIAL9 *material) PURE; STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL9* pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index, CONST D3DLIGHT9*) PURE; + STDMETHOD(SetLight)(THIS_ DWORD index, const D3DLIGHT9 *light) PURE; STDMETHOD(GetLight)(THIS_ DWORD Index, D3DLIGHT9*) PURE; STDMETHOD(LightEnable)(THIS_ DWORD Index, BOOL Enable) PURE; STDMETHOD(GetLightEnable)(THIS_ DWORD Index, BOOL* pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index, CONST float* pPlane) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD index, const float *plane) PURE; STDMETHOD(GetClipPlane)(THIS_ DWORD Index, float* pPlane) PURE; STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State, DWORD Value) PURE; STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State, DWORD* pValue) PURE; STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) PURE; STDMETHOD(BeginStateBlock)(THIS) PURE; STDMETHOD(EndStateBlock)(THIS_ IDirect3DStateBlock9** ppSB) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS9* pClipStatus) PURE; + STDMETHOD(SetClipStatus)(THIS_ const D3DCLIPSTATUS9 *clip_status) PURE; STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS9* pClipStatus) PURE; STDMETHOD(GetTexture)(THIS_ DWORD Stage, IDirect3DBaseTexture9** ppTexture) PURE; STDMETHOD(SetTexture)(THIS_ DWORD Stage, IDirect3DBaseTexture9* pTexture) PURE; @@ -1725,11 +1829,11 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) STDMETHOD(GetSamplerState)(THIS_ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) PURE; STDMETHOD(SetSamplerState)(THIS_ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) PURE; STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber, CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT palette_idx, const PALETTEENTRY *entries) PURE; STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; - STDMETHOD(SetScissorRect)(THIS_ CONST RECT* pRect) PURE; + STDMETHOD(SetScissorRect)(THIS_ const RECT *rect) PURE; STDMETHOD(GetScissorRect)(THIS_ RECT* pRect) PURE; STDMETHOD(SetSoftwareVertexProcessing)(THIS_ BOOL bSoftware) PURE; STDMETHOD_(BOOL, GetSoftwareVertexProcessing)(THIS) PURE; @@ -1737,22 +1841,25 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) STDMETHOD_(float, GetNPatchMode)(THIS) PURE; STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) PURE; STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE primitive_type, + UINT primitive_count, const void *data, UINT stride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE primitive_type, UINT min_vertex_idx, UINT vertex_count, + UINT primitive_count, const void *index_data, D3DFORMAT index_format, const void *data, UINT stride) PURE; STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) PURE; - STDMETHOD(CreateVertexDeclaration)(THIS_ CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) PURE; + STDMETHOD(CreateVertexDeclaration)(THIS_ const D3DVERTEXELEMENT9 *elements, + IDirect3DVertexDeclaration9 **declaration) PURE; STDMETHOD(SetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9* pDecl) PURE; STDMETHOD(GetVertexDeclaration)(THIS_ IDirect3DVertexDeclaration9** ppDecl) PURE; STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE; STDMETHOD(GetFVF)(THIS_ DWORD* pFVF) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) PURE; + STDMETHOD(CreateVertexShader)(THIS_ const DWORD *byte_core, IDirect3DVertexShader9 **shader) PURE; STDMETHOD(SetVertexShader)(THIS_ IDirect3DVertexShader9* pShader) PURE; STDMETHOD(GetVertexShader)(THIS_ IDirect3DVertexShader9** ppShader) PURE; - STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) PURE; + STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT reg_idx, const float *data, UINT count) PURE; STDMETHOD(GetVertexShaderConstantF)(THIS_ UINT StartRegister, float* pConstantData, UINT Vector4fCount) PURE; - STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) PURE; + STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT reg_idx, const int *data, UINT count) PURE; STDMETHOD(GetVertexShaderConstantI)(THIS_ UINT StartRegister, int* pConstantData, UINT Vector4iCount) PURE; - STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) PURE; + STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT reg_idx, const BOOL *data, UINT count) PURE; STDMETHOD(GetVertexShaderConstantB)(THIS_ UINT StartRegister, BOOL* pConstantData, UINT BoolCount) PURE; STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) PURE; STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) PURE; @@ -1760,38 +1867,47 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) STDMETHOD(GetStreamSourceFreq)(THIS_ UINT StreamNumber, UINT* Divider) PURE; STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer9* pIndexData) PURE; STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer9** ppIndexData) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) PURE; + STDMETHOD(CreatePixelShader)(THIS_ const DWORD *byte_code, IDirect3DPixelShader9 **shader) PURE; STDMETHOD(SetPixelShader)(THIS_ IDirect3DPixelShader9* pShader) PURE; STDMETHOD(GetPixelShader)(THIS_ IDirect3DPixelShader9** ppShader) PURE; - STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) PURE; + STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT reg_idx, const float *data, UINT count) PURE; STDMETHOD(GetPixelShaderConstantF)(THIS_ UINT StartRegister, float* pConstantData, UINT Vector4fCount) PURE; - STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) PURE; + STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT reg_idx, const int *data, UINT count) PURE; STDMETHOD(GetPixelShaderConstantI)(THIS_ UINT StartRegister, int* pConstantData, UINT Vector4iCount) PURE; - STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) PURE; + STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT reg_idx, const BOOL *data, UINT count) PURE; STDMETHOD(GetPixelShaderConstantB)(THIS_ UINT StartRegister, BOOL* pConstantData, UINT BoolCount) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT handle, const float *segment_count, const D3DRECTPATCH_INFO *patch_info) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT handle, const float *segment_count, const D3DTRIPATCH_INFO *patch_info) PURE; STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; STDMETHOD(CreateQuery)(THIS_ D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) PURE; /* IDirect3DDevice9Ex methods */ STDMETHOD(SetConvolutionMonoKernel)(THIS_ UINT width, UINT height, float *rows, float *columns) PURE; - STDMETHOD(ComposeRects)(THIS_ IDirect3DSurface9 *pSrc, IDirect3DSurface9 *pDst, IDirect3DVertexBuffer9 *pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset) PURE; - STDMETHOD(PresentEx)(THIS_ CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) PURE; + STDMETHOD(ComposeRects)(THIS_ IDirect3DSurface9 *src_surface, IDirect3DSurface9 *dst_surface, + IDirect3DVertexBuffer9 *src_descs, UINT rect_count, IDirect3DVertexBuffer9 *dst_descs, + D3DCOMPOSERECTSOP operation, INT offset_x, INT offset_y) PURE; + STDMETHOD(PresentEx)(THIS_ const RECT *src_rect, const RECT *dst_rect, + HWND dst_window_override, const RGNDATA *dirty_region, DWORD flags) PURE; STDMETHOD(GetGPUThreadPriority)(THIS_ INT *pPriority) PURE; STDMETHOD(SetGPUThreadPriority)(THIS_ INT Priority) PURE; STDMETHOD(WaitForVBlank)(THIS_ UINT iSwapChain) PURE; - STDMETHOD(CheckresourceResidency)(THIS_ IDirect3DResource9 ** pResourceArray, UINT32 Numresources) PURE; + STDMETHOD(CheckResourceResidency)(THIS_ IDirect3DResource9 **resources, UINT32 resource_count) PURE; STDMETHOD(SetMaximumFrameLatency)(THIS_ UINT MaxLatency) PURE; STDMETHOD(GetMaximumFrameLatency)(THIS_ UINT *pMaxLatenxy) PURE; - STDMETHOD(CheckdeviceState)(THIS_ HWND hDestinationWindow) PURE; + STDMETHOD(CheckDeviceState)(THIS_ HWND dst_window) PURE; STDMETHOD(CreateRenderTargetEx)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultiSampleQuality, BOOL Lockable, IDirect3DSurface9 ** ppSurface, HANDLE *pSharedHandle, DWORD Usage) PURE; STDMETHOD(CreateOffscreenPlainSurfaceEx)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage) PURE; - STDMETHOD(CreateDepthStencilSurfaceEx)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultiSampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurfface, HANDLE *pSharedHandle, DWORD Usage) PURE; + STDMETHOD(CreateDepthStencilSurfaceEx)(THIS_ UINT width, UINT height, D3DFORMAT format, + D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL discard, + IDirect3DSurface9 **surface, HANDLE *shared_handle, DWORD usage) PURE; STDMETHOD(ResetEx)(THIS_ D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode) PURE; STDMETHOD(GetDisplayModeEx)(THIS_ UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) PURE; }; #undef INTERFACE +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IDirect3DDevice9Ex, 0xb18b10ce, 0x2649, 0x405a, 0x87, 0xf, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a); +#endif + #if !defined(__cplusplus) || defined(CINTERFACE) /*** IUnknown methods ***/ #define IDirect3DDevice9Ex_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) @@ -2070,25 +2186,25 @@ DECLARE_INTERFACE_(IDirect3DDevice9Ex,IDirect3DDevice9) #define IDirect3DDevice9Ex_GetDisplayModeEx(p,a,b,c) (p)->GetDisplayModeEx(a,b,c) #endif - #ifdef __cplusplus extern "C" { #endif /* defined(__cplusplus) */ -int WINAPI D3DPERF_BeginEvent(D3DCOLOR,LPCWSTR); -int WINAPI D3DPERF_EndEvent(void); -DWORD WINAPI D3DPERF_GetStatus(void); -BOOL WINAPI D3DPERF_QueryRepeatFrame(void); -void WINAPI D3DPERF_SetMarker(D3DCOLOR,LPCWSTR); -void WINAPI D3DPERF_SetOptions(DWORD); -void WINAPI D3DPERF_SetRegion(D3DCOLOR,LPCWSTR); +int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, const WCHAR *name); +int WINAPI D3DPERF_EndEvent(void); +DWORD WINAPI D3DPERF_GetStatus(void); +BOOL WINAPI D3DPERF_QueryRepeatFrame(void); +void WINAPI D3DPERF_SetMarker(D3DCOLOR color, const WCHAR *name); +void WINAPI D3DPERF_SetOptions(DWORD options); +void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name); /* Define the main entrypoint as well */ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion); +HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex**); #ifdef __cplusplus } /* extern "C" */ #endif /* defined(__cplusplus) */ -#endif /* __WINE_D3D9_H */ +#endif /* _D3D9_H_ */ diff --git a/reactos/include/psdk/d3d9types.h b/reactos/include/psdk/d3d9types.h index 26b259a93bf..41f4a4208a1 100644 --- a/reactos/include/psdk/d3d9types.h +++ b/reactos/include/psdk/d3d9types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2003 Jason Edmeades + * Copyright (C) 2002-2003 Jason Edmeades * Copyright (C) 2002-2003 Raphael Junqueira * Copyright (C) 2005 Oliver Stieber * @@ -21,10 +21,6 @@ #ifndef __WINE_D3D9TYPES_H #define __WINE_D3D9TYPES_H -#if(DIRECT3D_VERSION >= 0x0900) - -#pragma pack(push, 4) - /***************************************************************************** * Direct 3D v9 #defines */ @@ -112,9 +108,6 @@ #define D3DUSAGE_DYNAMIC 0x00000200L #define D3DUSAGE_AUTOGENMIPMAP 0x00000400L #define D3DUSAGE_DMAP 0x00004000L -#ifndef D3D_DISABLE_9EX -#define D3DUSAGE_TEXTAPI 0x10000000L -#endif #define D3DUSAGE_QUERY_FILTER 0x00020000L #define D3DUSAGE_QUERY_LEGACYBUMPMAP 0x00008000L @@ -135,7 +128,7 @@ #define MAX_DEVICE_IDENTIFIER_STRING 512 #define D3DFVF_RESERVED0 0x0001 -#define D3DFVF_POSITION_MASK 0x000E +#define D3DFVF_POSITION_MASK 0x400E #define D3DFVF_XYZ 0x0002 #define D3DFVF_XYZRHW 0x0004 #define D3DFVF_XYZB1 0x0006 @@ -210,11 +203,13 @@ #define D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL 0x00000002 /* Discard Z buffer */ #define D3DPRESENTFLAG_DEVICECLIP 0x00000004 /* Clip the window blited into the client area 2k + xp only */ #define D3DPRESENTFLAG_VIDEO 0x00000010 /* backbuffer 'may' contain video data */ +#define D3DPRESENTFLAG_NOAUTOROTATE 0x00000020 /* d3d9ex, ignore display rotation */ +#define D3DPRESENTFLAG_UNPRUNEDMODE 0x00000040 /* d3d9ex, specify invalid display modes */ #define D3DPRESENT_BACK_BUFFERS_MAX 3L #define D3DPRESENT_RATE_DEFAULT 0x00000000 -/**************************** +/**************************** * Vertex Shaders Declaration */ @@ -222,28 +217,19 @@ typedef enum _D3DDECLUSAGE { D3DDECLUSAGE_POSITION = 0, D3DDECLUSAGE_BLENDWEIGHT = 1, D3DDECLUSAGE_BLENDINDICES = 2, - D3DDECLUSAGE_NORMAL = 3, - D3DDECLUSAGE_PSIZE = 4, - D3DDECLUSAGE_TEXCOORD = 5, - D3DDECLUSAGE_TANGENT = 6, - D3DDECLUSAGE_BINORMAL = 7, - D3DDECLUSAGE_TESSFACTOR = 8, - D3DDECLUSAGE_POSITIONT = 9, - D3DDECLUSAGE_COLOR = 10, - D3DDECLUSAGE_FOG = 11, - D3DDECLUSAGE_DEPTH = 12, - D3DDECLUSAGE_SAMPLE = 13 + D3DDECLUSAGE_NORMAL = 3, + D3DDECLUSAGE_PSIZE = 4, + D3DDECLUSAGE_TEXCOORD = 5, + D3DDECLUSAGE_TANGENT = 6, + D3DDECLUSAGE_BINORMAL = 7, + D3DDECLUSAGE_TESSFACTOR = 8, + D3DDECLUSAGE_POSITIONT = 9, + D3DDECLUSAGE_COLOR = 10, + D3DDECLUSAGE_FOG = 11, + D3DDECLUSAGE_DEPTH = 12, + D3DDECLUSAGE_SAMPLE = 13 } D3DDECLUSAGE; -/* MSDN is quite confussing at this point... -http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/constants/OTHER_D3D.asp -says D3DMAX, and D3DMAXDECLUSAGE = D3DDECLUSAGE_DEPTH -http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/directx9_c_summer_03/directx/graphics/reference/d3d/constants/other_d3d.asp -says MAXD3D, and D3DDECLUSAGE_SAMPLE - -So both are defined -*/ - #define D3DMAXDECLUSAGE D3DDECLUSAGE_SAMPLE #define D3DMAXDECLUSAGEINDEX 15 #define D3DMAXDECLLENGTH 18 @@ -448,7 +434,7 @@ typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE { D3DSIO_SETP = 94, D3DSIO_TEXLDL = 95, D3DSIO_BREAKP = 96, - + D3DSIO_PHASE = 0xFFFD, D3DSIO_COMMENT = 0xFFFE, D3DSIO_END = 0XFFFF, @@ -518,7 +504,7 @@ typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE { #define D3DSP_REGTYPE_MASK2 0x00001800 typedef enum _D3DSHADER_PARAM_REGISTER_TYPE { - D3DSPR_TEMP = 0, + D3DSPR_TEMP = 0, D3DSPR_INPUT = 1, D3DSPR_CONST = 2, D3DSPR_ADDR = 3, @@ -740,7 +726,7 @@ typedef enum _D3DDEGREETYPE { D3DDEGREE_QUADRATIC = 2, D3DDEGREE_CUBIC = 3, D3DDEGREE_QUINTIC = 5, - + D3DDEGREE_FORCE_DWORD = 0x7fffffff } D3DDEGREETYPE; @@ -790,7 +776,7 @@ typedef enum _D3DFORMAT { D3DFMT_G16R16 = 34, D3DFMT_A2R10G10B10 = 35, D3DFMT_A16B16G16R16 = 36, - + D3DFMT_A8P8 = 40, D3DFMT_P8 = 41, @@ -828,11 +814,6 @@ typedef enum _D3DFORMAT { D3DFMT_D32F_LOCKABLE = 82, D3DFMT_D24FS8 = 83, -#ifndef D3D_DISABLE_9EX - D3DFMT_D32_LOCKABLE = 84, - D3DFMT_S8_LOCKABLE = 85, -#endif - D3DFMT_VERTEXDATA = 100, D3DFMT_INDEX16 = 101, D3DFMT_INDEX32 = 102, @@ -841,12 +822,12 @@ typedef enum _D3DFORMAT { D3DFMT_R16F = 111, D3DFMT_G16R16F = 112, D3DFMT_A16B16G16R16F = 113, - + /* IEEE formats */ D3DFMT_R32F = 114, D3DFMT_G32R32F = 115, D3DFMT_A32B32G32R32F = 116, - + D3DFMT_CxV8U8 = 117, @@ -1083,6 +1064,8 @@ typedef enum _D3DSWAPEFFECT { D3DSWAPEFFECT_DISCARD = 1, D3DSWAPEFFECT_FLIP = 2, D3DSWAPEFFECT_COPY = 3, + D3DSWAPEFFECT_OVERLAY = 4, + D3DSWAPEFFECT_FLIPEX = 5, D3DSWAPEFFECT_FORCE_DWORD = 0xFFFFFFFF } D3DSWAPEFFECT; @@ -1151,21 +1134,9 @@ typedef enum _D3DTEXTURESTAGESTATETYPE { D3DTSS_BUMPENVMAT10 = 9, D3DTSS_BUMPENVMAT11 = 10, D3DTSS_TEXCOORDINDEX = 11, -#if 1 /* TODO: remove once samplerstates are implemented. */ - D3DTSS_ADDRESSU = 13, - D3DTSS_ADDRESSV = 14, - D3DTSS_BORDERCOLOR = 15, - D3DTSS_MAGFILTER = 16, - D3DTSS_MINFILTER = 17, - D3DTSS_MIPFILTER = 18, - D3DTSS_MIPMAPLODBIAS = 19, - D3DTSS_MAXMIPLEVEL = 20, - D3DTSS_MAXANISOTROPY = 21, -#endif D3DTSS_BUMPENVLSCALE = 22, D3DTSS_BUMPENVLOFFSET = 23, D3DTSS_TEXTURETRANSFORMFLAGS = 24, - D3DTSS_ADDRESSW = 25, D3DTSS_COLORARG0 = 26, D3DTSS_ALPHAARG0 = 27, D3DTSS_RESULTARG = 28, @@ -1231,7 +1202,7 @@ typedef enum _D3DSAMPLERSTATETYPE { D3DSAMP_SRGBTEXTURE = 11, D3DSAMP_ELEMENTINDEX = 12, D3DSAMP_DMAPOFFSET = 13, - + D3DSAMP_FORCE_DWORD = 0x7fffffff, } D3DSAMPLERSTATETYPE; @@ -1251,7 +1222,7 @@ typedef struct _D3DADAPTER_IDENTIFIER9 { char Driver[MAX_DEVICE_IDENTIFIER_STRING]; char Description[MAX_DEVICE_IDENTIFIER_STRING]; char DeviceName[32]; - LARGE_INTEGER DriverVersion; + LARGE_INTEGER DriverVersion; DWORD VendorId; DWORD DeviceId; @@ -1331,13 +1302,13 @@ typedef struct _D3DDEVINFO_D3D9STAGETIMINGS { /* Vertex cache optimization hints. */ typedef struct D3DDEVINFO_VCACHE { /* Must be a 4 char code FOURCC (e.g. CACH) */ - DWORD Pattern; + DWORD Pattern; /* 0 to get the longest strips, 1 vertex cache */ - DWORD OptMethod; + DWORD OptMethod; /* Cache size to use (only valid if OptMethod==1) */ DWORD CacheSize; - /* internal for deciding when to restart strips, non user modifyable (only valid if OptMethod==1) */ - DWORD MagicNumber; + /* internal for deciding when to restart strips, non user modifiable (only valid if OptMethod==1) */ + DWORD MagicNumber; } D3DDEVINFO_VCACHE; typedef struct D3DRESOURCESTATS { @@ -1546,6 +1517,7 @@ typedef struct _D3DVOLUME_DESC { UINT Depth; } D3DVOLUME_DESC; +/* Parts added with d3d9ex */ #if !defined(D3D_DISABLE_9EX) typedef enum D3DSCANLINEORDERING { @@ -1611,9 +1583,4 @@ typedef enum _D3DSHADER_COMPARISON D3DSPC_RESERVED1, } D3DSHADER_COMPARISON; - -#pragma pack(pop) - -#endif /* DIRECT3D_VERSION >= 0x0900 */ - #endif /* __WINE_D3D9TYPES_H */ diff --git a/reactos/include/reactos/wine/wined3d.h b/reactos/include/reactos/wine/wined3d.h index 50bacdd59c1..fe90469e0ad 100644 --- a/reactos/include/reactos/wine/wined3d.h +++ b/reactos/include/reactos/wine/wined3d.h @@ -694,6 +694,9 @@ enum wined3d_pool enum wined3d_query_type { + WINED3D_QUERY_TYPE_PIPELINE_STATISTICS = 1, + WINED3D_QUERY_TYPE_SO_STATISTICS = 2, + WINED3D_QUERY_TYPE_SO_OVERFLOW = 3, WINED3D_QUERY_TYPE_VCACHE = 4, WINED3D_QUERY_TYPE_RESOURCE_MANAGER = 5, WINED3D_QUERY_TYPE_VERTEX_STATS = 6, @@ -1934,6 +1937,25 @@ struct wined3d_buffer_desc UINT misc_flags; }; +struct wined3d_rendertarget_view_desc +{ + enum wined3d_format_id format_id; + union + { + struct + { + unsigned int start_idx; + unsigned int count; + } buffer; + struct + { + unsigned int level_idx; + unsigned int layer_idx; + unsigned int layer_count; + } texture; + } u; +}; + struct wined3d_shader_signature_element { const char *semantic_name; @@ -1965,6 +1987,7 @@ struct wined3d_rendertarget_view; struct wined3d_resource; struct wined3d_sampler; struct wined3d_shader; +struct wined3d_shader_resource_view; struct wined3d_stateblock; struct wined3d_surface; struct wined3d_swapchain; @@ -1981,6 +2004,7 @@ struct wined3d_device_parent_ops { void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device); void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent); + void (__cdecl *activate)(struct wined3d_device_parent *device_parent, BOOL activate); HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops); HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent, void *container_parent, @@ -2015,6 +2039,8 @@ typedef HRESULT (CDECL *wined3d_device_reset_cb)(struct wined3d_resource *resour void __stdcall wined3d_mutex_lock(void); void __stdcall wined3d_mutex_unlock(void); +UINT __cdecl wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx, + enum wined3d_format_id format_id, UINT width); HRESULT __cdecl wined3d_check_depth_stencil_match(const struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id); @@ -2052,7 +2078,7 @@ HRESULT __cdecl wined3d_register_software_device(struct wined3d *wined3d, void * HRESULT __cdecl wined3d_set_adapter_display_mode(struct wined3d *wined3d, UINT adapter_idx, const struct wined3d_display_mode *mode); -HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, struct wined3d_buffer_desc *desc, +HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc, const void *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer); HRESULT __cdecl wined3d_buffer_create_ib(struct wined3d_device *device, UINT length, DWORD usage, enum wined3d_pool pool, void *parent, const struct wined3d_parent_ops *parent_ops, @@ -2062,12 +2088,10 @@ HRESULT __cdecl wined3d_buffer_create_vb(struct wined3d_device *device, UINT len struct wined3d_buffer **buffer); ULONG __cdecl wined3d_buffer_decref(struct wined3d_buffer *buffer); void * __cdecl wined3d_buffer_get_parent(const struct wined3d_buffer *buffer); -DWORD __cdecl wined3d_buffer_get_priority(const struct wined3d_buffer *buffer); struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buffer *buffer); ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer); HRESULT __cdecl wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags); void __cdecl wined3d_buffer_preload(struct wined3d_buffer *buffer); -DWORD __cdecl wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD new_priority); void __cdecl wined3d_buffer_unmap(struct wined3d_buffer *buffer); HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); @@ -2075,10 +2099,10 @@ HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device); HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float z, DWORD stencil); -void __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *device, - struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color); -HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface, - const RECT *rect, const struct wined3d_color *color); +HRESULT __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *device, + struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color); +void __cdecl wined3d_device_copy_resource(struct wined3d_device *device, + struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource); HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type, HWND focus_window, DWORD behaviour_flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent, struct wined3d_device **device); @@ -2100,7 +2124,7 @@ HRESULT __cdecl wined3d_device_get_clip_status(const struct wined3d_device *devi struct wined3d_clip_status *clip_status); void __cdecl wined3d_device_get_creation_parameters(const struct wined3d_device *device, struct wined3d_device_creation_parameters *creation_parameters); -struct wined3d_surface * __cdecl wined3d_device_get_depth_stencil(const struct wined3d_device *device); +struct wined3d_rendertarget_view * __cdecl wined3d_device_get_depth_stencil_view(const struct wined3d_device *device); HRESULT __cdecl wined3d_device_get_device_caps(const struct wined3d_device *device, WINED3DCAPS *caps); HRESULT __cdecl wined3d_device_get_display_mode(const struct wined3d_device *device, UINT swapchain_idx, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation); @@ -2110,6 +2134,8 @@ void __cdecl wined3d_device_get_gamma_ramp(const struct wined3d_device *device, UINT swapchain_idx, struct wined3d_gamma_ramp *ramp); struct wined3d_shader * __cdecl wined3d_device_get_geometry_shader(const struct wined3d_device *device); struct wined3d_buffer * __cdecl wined3d_device_get_gs_cb(const struct wined3d_device *device, UINT idx); +struct wined3d_shader_resource_view * __cdecl wined3d_device_get_gs_resource_view(const struct wined3d_device *device, + UINT idx); struct wined3d_sampler * __cdecl wined3d_device_get_gs_sampler(const struct wined3d_device *device, UINT idx); struct wined3d_buffer * __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device, enum wined3d_format_id *format); @@ -2119,6 +2145,7 @@ HRESULT __cdecl wined3d_device_get_light_enable(const struct wined3d_device *dev void __cdecl wined3d_device_get_material(const struct wined3d_device *device, struct wined3d_material *material); float __cdecl wined3d_device_get_npatch_mode(const struct wined3d_device *device); struct wined3d_shader * __cdecl wined3d_device_get_pixel_shader(const struct wined3d_device *device); +struct wined3d_query * __cdecl wined3d_device_get_predication(struct wined3d_device *device, BOOL *value); void __cdecl wined3d_device_get_primitive_type(const struct wined3d_device *device, enum wined3d_primitive_type *primitive_topology); struct wined3d_buffer * __cdecl wined3d_device_get_ps_cb(const struct wined3d_device *device, UINT idx); @@ -2128,12 +2155,14 @@ HRESULT __cdecl wined3d_device_get_ps_consts_f(const struct wined3d_device *devi UINT start_register, float *constants, UINT vector4f_count); HRESULT __cdecl wined3d_device_get_ps_consts_i(const struct wined3d_device *device, UINT start_register, int *constants, UINT vector4i_count); +struct wined3d_shader_resource_view * __cdecl wined3d_device_get_ps_resource_view(const struct wined3d_device *device, + UINT idx); struct wined3d_sampler * __cdecl wined3d_device_get_ps_sampler(const struct wined3d_device *device, UINT idx); HRESULT __cdecl wined3d_device_get_raster_status(const struct wined3d_device *device, UINT swapchain_idx, struct wined3d_raster_status *raster_status); DWORD __cdecl wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state state); -struct wined3d_surface * __cdecl wined3d_device_get_render_target(const struct wined3d_device *device, - UINT render_target_idx); +struct wined3d_rendertarget_view * __cdecl wined3d_device_get_rendertarget_view(const struct wined3d_device *device, + unsigned int view_idx); DWORD __cdecl wined3d_device_get_sampler_state(const struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state state); void __cdecl wined3d_device_get_scissor_rect(const struct wined3d_device *device, RECT *rect); @@ -2163,6 +2192,8 @@ HRESULT __cdecl wined3d_device_get_vs_consts_f(const struct wined3d_device *devi UINT start_register, float *constants, UINT vector4f_count); HRESULT __cdecl wined3d_device_get_vs_consts_i(const struct wined3d_device *device, UINT start_register, int *constants, UINT vector4i_count); +struct wined3d_shader_resource_view * __cdecl wined3d_device_get_vs_resource_view(const struct wined3d_device *device, + UINT idx); struct wined3d_sampler * __cdecl wined3d_device_get_vs_sampler(const struct wined3d_device *device, UINT idx); ULONG __cdecl wined3d_device_incref(struct wined3d_device *device); HRESULT __cdecl wined3d_device_init_3d(struct wined3d_device *device, struct wined3d_swapchain_desc *swapchain_desc); @@ -2188,12 +2219,15 @@ void __cdecl wined3d_device_set_cursor_position(struct wined3d_device *device, int x_screen_space, int y_screen_space, DWORD flags); HRESULT __cdecl wined3d_device_set_cursor_properties(struct wined3d_device *device, UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_surface); -void __cdecl wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil); +void __cdecl wined3d_device_set_depth_stencil_view(struct wined3d_device *device, + struct wined3d_rendertarget_view *view); HRESULT __cdecl wined3d_device_set_dialog_box_mode(struct wined3d_device *device, BOOL enable_dialogs); void __cdecl wined3d_device_set_gamma_ramp(const struct wined3d_device *device, UINT swapchain_idx, DWORD flags, const struct wined3d_gamma_ramp *ramp); void __cdecl wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader); void __cdecl wined3d_device_set_gs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer); +void __cdecl wined3d_device_set_gs_resource_view(struct wined3d_device *device, + UINT idx, struct wined3d_shader_resource_view *view); void __cdecl wined3d_device_set_gs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler); void __cdecl wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer *index_buffer, enum wined3d_format_id format_id); @@ -2204,6 +2238,8 @@ void __cdecl wined3d_device_set_material(struct wined3d_device *device, const st void __cdecl wined3d_device_set_multithreaded(struct wined3d_device *device); HRESULT __cdecl wined3d_device_set_npatch_mode(struct wined3d_device *device, float segments); void __cdecl wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader); +void __cdecl wined3d_device_set_predication(struct wined3d_device *device, + struct wined3d_query *predicate, BOOL value); void __cdecl wined3d_device_set_primitive_type(struct wined3d_device *device, enum wined3d_primitive_type primitive_topology); void __cdecl wined3d_device_set_ps_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer); @@ -2213,11 +2249,13 @@ HRESULT __cdecl wined3d_device_set_ps_consts_f(struct wined3d_device *device, UINT start_register, const float *constants, UINT vector4f_count); HRESULT __cdecl wined3d_device_set_ps_consts_i(struct wined3d_device *device, UINT start_register, const int *constants, UINT vector4i_count); +void __cdecl wined3d_device_set_ps_resource_view(struct wined3d_device *device, + UINT idx, struct wined3d_shader_resource_view *view); void __cdecl wined3d_device_set_ps_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler); void __cdecl wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state state, DWORD value); -HRESULT __cdecl wined3d_device_set_render_target(struct wined3d_device *device, - UINT render_target_idx, struct wined3d_surface *render_target, BOOL set_viewport); +HRESULT __cdecl wined3d_device_set_rendertarget_view(struct wined3d_device *device, + unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport); void __cdecl wined3d_device_set_sampler_state(struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state state, DWORD value); void __cdecl wined3d_device_set_scissor_rect(struct wined3d_device *device, const RECT *rect); @@ -2243,6 +2281,8 @@ HRESULT __cdecl wined3d_device_set_vs_consts_f(struct wined3d_device *device, UINT start_register, const float *constants, UINT vector4f_count); HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device, UINT start_register, const int *constants, UINT vector4i_count); +void __cdecl wined3d_device_set_vs_resource_view(struct wined3d_device *device, + UINT idx, struct wined3d_shader_resource_view *view); void __cdecl wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler); void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h); BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show); @@ -2259,15 +2299,17 @@ HRESULT __cdecl wined3d_palette_create(struct wined3d_device *device, DWORD flag ULONG __cdecl wined3d_palette_decref(struct wined3d_palette *palette); HRESULT __cdecl wined3d_palette_get_entries(const struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries); +void __cdecl wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HDC dc); ULONG __cdecl wined3d_palette_incref(struct wined3d_palette *palette); HRESULT __cdecl wined3d_palette_set_entries(struct wined3d_palette *palette, DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries); HRESULT __cdecl wined3d_query_create(struct wined3d_device *device, - enum wined3d_query_type type, struct wined3d_query **query); + enum wined3d_query_type type, void *parent, struct wined3d_query **query); ULONG __cdecl wined3d_query_decref(struct wined3d_query *query); HRESULT __cdecl wined3d_query_get_data(struct wined3d_query *query, void *data, UINT data_size, DWORD flags); UINT __cdecl wined3d_query_get_data_size(const struct wined3d_query *query); +void * __cdecl wined3d_query_get_parent(const struct wined3d_query *query); enum wined3d_query_type __cdecl wined3d_query_get_type(const struct wined3d_query *query); ULONG __cdecl wined3d_query_incref(struct wined3d_query *query); HRESULT __cdecl wined3d_query_issue(struct wined3d_query *query, DWORD flags); @@ -2349,14 +2391,21 @@ static inline HRESULT wined3d_private_store_set_private_data(struct wined3d_priv void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc); void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource); +DWORD __cdecl wined3d_resource_get_priority(const struct wined3d_resource *resource); void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent); +DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority); -HRESULT __cdecl wined3d_rendertarget_view_create(struct wined3d_resource *resource, - void *parent, struct wined3d_rendertarget_view **rendertarget_view); +HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc, + struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, + struct wined3d_rendertarget_view **view); +HRESULT __cdecl wined3d_rendertarget_view_create_from_surface(struct wined3d_surface *surface, + void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view); ULONG __cdecl wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view); void * __cdecl wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view); struct wined3d_resource * __cdecl wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view); +void * __cdecl wined3d_rendertarget_view_get_sub_resource_parent(const struct wined3d_rendertarget_view *view); ULONG __cdecl wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view); +void __cdecl wined3d_rendertarget_view_set_parent(struct wined3d_rendertarget_view *view, void *parent); HRESULT __cdecl wined3d_sampler_create(void *parent, struct wined3d_sampler **sampler); ULONG __cdecl wined3d_sampler_decref(struct wined3d_sampler *sampler); @@ -2380,6 +2429,12 @@ ULONG __cdecl wined3d_shader_incref(struct wined3d_shader *shader); HRESULT __cdecl wined3d_shader_set_local_constants_float(struct wined3d_shader *shader, UINT start_idx, const float *src_data, UINT vector4f_count); +HRESULT __cdecl wined3d_shader_resource_view_create(void *parent, const struct wined3d_parent_ops *parent_ops, + struct wined3d_shader_resource_view **view); +ULONG __cdecl wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view); +void * __cdecl wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view); +ULONG __cdecl wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view); + void __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock); void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock); HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, @@ -2395,10 +2450,8 @@ struct wined3d_surface * __cdecl wined3d_surface_from_resource(struct wined3d_re HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags); HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags); HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y); -struct wined3d_palette * __cdecl wined3d_surface_get_palette(const struct wined3d_surface *surface); void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface); DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface); -DWORD __cdecl wined3d_surface_get_priority(const struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_get_render_target_data(struct wined3d_surface *surface, struct wined3d_surface *render_target); struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_surface *surface); @@ -2411,8 +2464,6 @@ void __cdecl wined3d_surface_preload(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc); HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y); -void __cdecl wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette); -DWORD __cdecl wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD new_priority); HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_update_desc(struct wined3d_surface *surface, UINT width, UINT height, enum wined3d_format_id format_id, @@ -2446,6 +2497,7 @@ HRESULT __cdecl wined3d_swapchain_present(struct wined3d_swapchain *swapchain, const RGNDATA *dirty_region, DWORD flags); HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain, DWORD flags, const struct wined3d_gamma_ramp *ramp); +void __cdecl wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette); void __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window); HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture, @@ -2459,7 +2511,6 @@ enum wined3d_texture_filter_type __cdecl wined3d_texture_get_autogen_filter_type DWORD __cdecl wined3d_texture_get_level_count(const struct wined3d_texture *texture); DWORD __cdecl wined3d_texture_get_lod(const struct wined3d_texture *texture); void * __cdecl wined3d_texture_get_parent(const struct wined3d_texture *texture); -DWORD __cdecl wined3d_texture_get_priority(const struct wined3d_texture *texture); struct wined3d_resource * __cdecl wined3d_texture_get_resource(struct wined3d_texture *texture); struct wined3d_resource * __cdecl wined3d_texture_get_sub_resource(struct wined3d_texture *texture, UINT sub_resource_idx); @@ -2470,7 +2521,6 @@ HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture * HRESULT __cdecl wined3d_texture_set_color_key(struct wined3d_texture *texture, DWORD flags, const struct wined3d_color_key *color_key); DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod); -DWORD __cdecl wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority); HRESULT __cdecl wined3d_vertex_declaration_create(struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count, void *parent, @@ -2485,13 +2535,11 @@ ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaratio ULONG __cdecl wined3d_volume_decref(struct wined3d_volume *volume); struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource); void * __cdecl wined3d_volume_get_parent(const struct wined3d_volume *volume); -DWORD __cdecl wined3d_volume_get_priority(const struct wined3d_volume *volume); struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume); ULONG __cdecl wined3d_volume_incref(struct wined3d_volume *volume); HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); void __cdecl wined3d_volume_preload(struct wined3d_volume *volume); -DWORD __cdecl wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD new_priority); HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume); #endif /* __WINE_WINED3D_H */ diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index a7f7eaedbd3..007b00afafe 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -28,12 +28,12 @@ reactos/tools/wpp # Synced to Wine-1.7.27 The following libraries are shared with Wine. reactos/dll/directx/wine/amstream # Synced to Wine-1.7.27 -reactos/dll/directx/wine/d3d8 # Synced to Wine-1.7.17 -reactos/dll/directx/wine/d3d9 # Synced to Wine-1.7.17 +reactos/dll/directx/wine/d3d8 # Synced to Wine-1.7.27 +reactos/dll/directx/wine/d3d9 # Synced to Wine-1.7.27 reactos/dll/directx/wine/d3dcompiler_43 # Synced to Wine-1.7.17 reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-1.7.17 reactos/dll/directx/wine/d3dxof # Synced to Wine-1.7.17 -reactos/dll/directx/wine/ddraw # Synced to Wine-1.7.17 +reactos/dll/directx/wine/ddraw # Synced to Wine-1.7.27 reactos/dll/directx/wine/devenum # Synced to Wine-1.7.17 reactos/dll/directx/wine/dinput # Synced to Wine-1.7.17 reactos/dll/directx/wine/dinput8 # Synced to Wine-1.7.17 @@ -46,7 +46,7 @@ reactos/dll/directx/wine/dxgi # Synced to Wine-1.7.17 reactos/dll/directx/wine/msdmo # Synced to Wine-1.7.17 reactos/dll/directx/wine/qedit # Synced to Wine-1.7.17 reactos/dll/directx/wine/quartz # Synced to Wine-1.7.17 -reactos/dll/directx/wine/wined3d # Synced to Wine-1.7.17 +reactos/dll/directx/wine/wined3d # Synced to Wine-1.7.27 reactos/dll/win32/activeds # Synced to Wine-1.7.17 reactos/dll/win32/actxprxy # Synced to Wine-1.7.17