/*
* IDirect3DDevice9 implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include "d3d9_private.h"
#ifdef VBOX_WITH_WDDM
# include "../../common/VBoxVideoTools.h"
#endif
{
/* Don't translate FOURCC formats */
switch(format)
{
case WINED3DFMT_UNKNOWN: return D3DFMT_UNKNOWN;
case WINED3DFMT_B8G8R8_UNORM: return D3DFMT_R8G8B8;
case WINED3DFMT_B8G8R8A8_UNORM: return D3DFMT_A8R8G8B8;
case WINED3DFMT_B8G8R8X8_UNORM: return D3DFMT_X8R8G8B8;
case WINED3DFMT_B5G6R5_UNORM: return D3DFMT_R5G6B5;
case WINED3DFMT_B5G5R5X1_UNORM: return D3DFMT_X1R5G5B5;
case WINED3DFMT_B5G5R5A1_UNORM: return D3DFMT_A1R5G5B5;
case WINED3DFMT_B4G4R4A4_UNORM: return D3DFMT_A4R4G4B4;
case WINED3DFMT_B2G3R3_UNORM: return D3DFMT_R3G3B2;
case WINED3DFMT_A8_UNORM: return D3DFMT_A8;
case WINED3DFMT_B2G3R3A8_UNORM: return D3DFMT_A8R3G3B2;
case WINED3DFMT_B4G4R4X4_UNORM: return D3DFMT_X4R4G4B4;
case WINED3DFMT_R10G10B10A2_UNORM: return D3DFMT_A2B10G10R10;
case WINED3DFMT_R8G8B8A8_UNORM: return D3DFMT_A8B8G8R8;
case WINED3DFMT_R8G8B8X8_UNORM: return D3DFMT_X8B8G8R8;
case WINED3DFMT_R16G16_UNORM: return D3DFMT_G16R16;
case WINED3DFMT_B10G10R10A2_UNORM: return D3DFMT_A2R10G10B10;
case WINED3DFMT_R16G16B16A16_UNORM: return D3DFMT_A16B16G16R16;
case WINED3DFMT_P8_UINT_A8_UNORM: return D3DFMT_A8P8;
case WINED3DFMT_P8_UINT: return D3DFMT_P8;
case WINED3DFMT_L8_UNORM: return D3DFMT_L8;
case WINED3DFMT_L8A8_UNORM: return D3DFMT_A8L8;
case WINED3DFMT_L4A4_UNORM: return D3DFMT_A4L4;
case WINED3DFMT_R8G8_SNORM: return D3DFMT_V8U8;
case WINED3DFMT_R5G5_SNORM_L6_UNORM: return D3DFMT_L6V5U5;
case WINED3DFMT_R8G8_SNORM_L8X8_UNORM: return D3DFMT_X8L8V8U8;
case WINED3DFMT_R8G8B8A8_SNORM: return D3DFMT_Q8W8V8U8;
case WINED3DFMT_R16G16_SNORM: return D3DFMT_V16U16;
case WINED3DFMT_R10G10B10_SNORM_A2_UNORM: return D3DFMT_A2W10V10U10;
case WINED3DFMT_D16_LOCKABLE: return D3DFMT_D16_LOCKABLE;
case WINED3DFMT_D32_UNORM: return D3DFMT_D32;
case WINED3DFMT_S1_UINT_D15_UNORM: return D3DFMT_D15S1;
case WINED3DFMT_D24_UNORM_S8_UINT: return D3DFMT_D24S8;
case WINED3DFMT_X8D24_UNORM: return D3DFMT_D24X8;
case WINED3DFMT_S4X4_UINT_D24_UNORM: return D3DFMT_D24X4S4;
case WINED3DFMT_D16_UNORM: return D3DFMT_D16;
case WINED3DFMT_L16_UNORM: return D3DFMT_L16;
case WINED3DFMT_D32_FLOAT: return D3DFMT_D32F_LOCKABLE;
case WINED3DFMT_S8_UINT_D24_FLOAT: return D3DFMT_D24FS8;
case WINED3DFMT_VERTEXDATA: return D3DFMT_VERTEXDATA;
case WINED3DFMT_R16_UINT: return D3DFMT_INDEX16;
case WINED3DFMT_R32_UINT: return D3DFMT_INDEX32;
case WINED3DFMT_R16G16B16A16_SNORM: return D3DFMT_Q16W16V16U16;
case WINED3DFMT_R16_FLOAT: return D3DFMT_R16F;
case WINED3DFMT_R16G16_FLOAT: return D3DFMT_G16R16F;
case WINED3DFMT_R16G16B16A16_FLOAT: return D3DFMT_A16B16G16R16F;
case WINED3DFMT_R32_FLOAT: return D3DFMT_R32F;
case WINED3DFMT_R32G32_FLOAT: return D3DFMT_G32R32F;
case WINED3DFMT_R32G32B32A32_FLOAT: return D3DFMT_A32B32G32R32F;
case WINED3DFMT_R8G8_SNORM_Cx: return D3DFMT_CxV8U8;
default:
return D3DFMT_UNKNOWN;
}
}
{
/* Don't translate FOURCC formats */
switch(format)
{
case D3DFMT_UNKNOWN: return WINED3DFMT_UNKNOWN;
case D3DFMT_R8G8B8: return WINED3DFMT_B8G8R8_UNORM;
case D3DFMT_A8R8G8B8: return WINED3DFMT_B8G8R8A8_UNORM;
case D3DFMT_X8R8G8B8: return WINED3DFMT_B8G8R8X8_UNORM;
case D3DFMT_R5G6B5: return WINED3DFMT_B5G6R5_UNORM;
case D3DFMT_X1R5G5B5: return WINED3DFMT_B5G5R5X1_UNORM;
case D3DFMT_A1R5G5B5: return WINED3DFMT_B5G5R5A1_UNORM;
case D3DFMT_A4R4G4B4: return WINED3DFMT_B4G4R4A4_UNORM;
case D3DFMT_R3G3B2: return WINED3DFMT_B2G3R3_UNORM;
case D3DFMT_A8: return WINED3DFMT_A8_UNORM;
case D3DFMT_A8R3G3B2: return WINED3DFMT_B2G3R3A8_UNORM;
case D3DFMT_X4R4G4B4: return WINED3DFMT_B4G4R4X4_UNORM;
case D3DFMT_A2B10G10R10: return WINED3DFMT_R10G10B10A2_UNORM;
case D3DFMT_A8B8G8R8: return WINED3DFMT_R8G8B8A8_UNORM;
case D3DFMT_X8B8G8R8: return WINED3DFMT_R8G8B8X8_UNORM;
case D3DFMT_G16R16: return WINED3DFMT_R16G16_UNORM;
case D3DFMT_A2R10G10B10: return WINED3DFMT_B10G10R10A2_UNORM;
case D3DFMT_A16B16G16R16: return WINED3DFMT_R16G16B16A16_UNORM;
case D3DFMT_A8P8: return WINED3DFMT_P8_UINT_A8_UNORM;
case D3DFMT_P8: return WINED3DFMT_P8_UINT;
case D3DFMT_L8: return WINED3DFMT_L8_UNORM;
case D3DFMT_A8L8: return WINED3DFMT_L8A8_UNORM;
case D3DFMT_A4L4: return WINED3DFMT_L4A4_UNORM;
case D3DFMT_V8U8: return WINED3DFMT_R8G8_SNORM;
case D3DFMT_L6V5U5: return WINED3DFMT_R5G5_SNORM_L6_UNORM;
case D3DFMT_X8L8V8U8: return WINED3DFMT_R8G8_SNORM_L8X8_UNORM;
case D3DFMT_Q8W8V8U8: return WINED3DFMT_R8G8B8A8_SNORM;
case D3DFMT_V16U16: return WINED3DFMT_R16G16_SNORM;
case D3DFMT_A2W10V10U10: return WINED3DFMT_R10G10B10_SNORM_A2_UNORM;
case D3DFMT_D16_LOCKABLE: return WINED3DFMT_D16_LOCKABLE;
case D3DFMT_D32: return WINED3DFMT_D32_UNORM;
case D3DFMT_D15S1: return WINED3DFMT_S1_UINT_D15_UNORM;
case D3DFMT_D24S8: return WINED3DFMT_D24_UNORM_S8_UINT;
case D3DFMT_D24X8: return WINED3DFMT_X8D24_UNORM;
case D3DFMT_D24X4S4: return WINED3DFMT_S4X4_UINT_D24_UNORM;
case D3DFMT_D16: return WINED3DFMT_D16_UNORM;
case D3DFMT_L16: return WINED3DFMT_L16_UNORM;
case D3DFMT_D32F_LOCKABLE: return WINED3DFMT_D32_FLOAT;
case D3DFMT_D24FS8: return WINED3DFMT_S8_UINT_D24_FLOAT;
case D3DFMT_VERTEXDATA: return WINED3DFMT_VERTEXDATA;
case D3DFMT_INDEX16: return WINED3DFMT_R16_UINT;
case D3DFMT_INDEX32: return WINED3DFMT_R32_UINT;
case D3DFMT_Q16W16V16U16: return WINED3DFMT_R16G16B16A16_SNORM;
case D3DFMT_R16F: return WINED3DFMT_R16_FLOAT;
case D3DFMT_G16R16F: return WINED3DFMT_R16G16_FLOAT;
case D3DFMT_A16B16G16R16F: return WINED3DFMT_R16G16B16A16_FLOAT;
case D3DFMT_R32F: return WINED3DFMT_R32_FLOAT;
case D3DFMT_G32R32F: return WINED3DFMT_R32G32_FLOAT;
case D3DFMT_A32B32G32R32F: return WINED3DFMT_R32G32B32A32_FLOAT;
case D3DFMT_CxV8U8: return WINED3DFMT_R8G8_SNORM_Cx;
default:
return WINED3DFMT_UNKNOWN;
}
}
static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
{
switch(primitive_type)
{
case D3DPT_POINTLIST:
return primitive_count;
case D3DPT_LINELIST:
return primitive_count * 2;
case D3DPT_LINESTRIP:
return primitive_count + 1;
case D3DPT_TRIANGLELIST:
return primitive_count * 3;
case D3DPT_TRIANGLESTRIP:
case D3DPT_TRIANGLEFAN:
return primitive_count + 2;
default:
return 0;
}
}
const struct wined3d_swapchain_desc *swapchain_desc)
{
present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(swapchain_desc->backbuffer_format);
}
static void wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
{
swapchain_desc->backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
#ifdef VBOX_WITH_WDDM
#endif
}
static HRESULT WINAPI d3d9_device_QueryInterface(IDirect3DDevice9Ex *iface, REFIID riid, void **out)
{
{
return S_OK;
}
{
/* Find out if the creating d3d9 interface was created with Direct3DCreate9Ex.
* It doesn't matter with which function the device was created. */
{
WARN("IDirect3D9 instance wasn't created with CreateDirect3D9Ex, returning E_NOINTERFACE.\n");
return E_NOINTERFACE;
}
return S_OK;
}
return E_NOINTERFACE;
}
{
return refcount;
}
#ifdef VBOX
{
unsigned i;
if (refs != 1)
{
}
for (i = 0; i < device->fvf_decl_count; ++i)
{
}
if (device->vertex_buffer)
if (device->index_buffer)
# ifndef VBOX_WITH_WDDM
# endif
return wined3d_refs;
}
#endif
{
if (device->in_destruction)
return 0;
if (!refcount)
{
#ifdef VBOX
#else
unsigned i;
for (i = 0; i < device->fvf_decl_count; ++i)
{
}
if (device->vertex_buffer)
if (device->index_buffer)
#endif
}
return refcount;
}
{
{
TRACE("D3D9 device is marked not reset.\n");
return D3DERR_DEVICENOTRESET;
}
return D3D_OK;
}
{
return hr;
}
{
return D3D_OK;
}
{
if (!d3d9)
return D3DERR_INVALIDCALL;
return IDirect3D9Ex_QueryInterface(&device->d3d_parent->IDirect3D9Ex_iface, &IID_IDirect3D9, (void **)d3d9);
}
{
if (!caps)
return D3DERR_INVALIDCALL;
return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
/* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
return hr;
}
static HRESULT WINAPI d3d9_device_GetDisplayMode(IDirect3DDevice9Ex *iface, UINT swapchain, D3DDISPLAYMODE *mode)
{
{
}
return hr;
}
{
(struct wined3d_device_creation_parameters *)parameters);
return D3D_OK;
}
{
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
if (!bitmap)
{
WARN("No cursor bitmap, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
return hr;
}
static void WINAPI d3d9_device_SetCursorPosition(IDirect3DDevice9Ex *iface, int x, int y, DWORD flags)
{
}
{
return ret;
}
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface,
{
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
return hr;
}
{
{
}
else
{
}
return hr;
}
{
return count;
}
{
{
{
{
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
return D3DERR_INVALIDCALL;
}
{
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
return D3DERR_INVALIDCALL;
}
}
return D3D_OK;
}
{
if (device->vertex_buffer)
{
device->vertex_buffer_size = 0;
}
if (device->index_buffer)
{
device->index_buffer_size = 0;
}
else
return hr;
}
{
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
return hr;
}
{
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
{
}
return hr;
}
{
return hr;
}
{
return hr;
}
{
/* Note: D3DGAMMARAMP is compatible with struct wined3d_gamma_ramp. */
wined3d_device_set_gamma_ramp(device->wined3d_device, swapchain, flags, (const struct wined3d_gamma_ramp *)ramp);
}
static void WINAPI d3d9_device_GetGammaRamp(IDirect3DDevice9Ex *iface, UINT swapchain, D3DGAMMARAMP *ramp)
{
/* Note: D3DGAMMARAMP is compatible with struct wined3d_gamma_ramp. */
wined3d_device_get_gamma_ramp(device->wined3d_device, swapchain, (struct wined3d_gamma_ramp *)ramp);
}
#ifdef VBOX_WITH_WDDM
//#pragma comment(linker, "/export:VBoxWineExD3DDev9Flush=_VBoxWineExD3DDev9Flush@4")
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
//#pragma comment(linker, "/export:VBoxWineExD3DDev9CreateTexture=_VBoxWineExD3DDev9CreateTexture@40")
void **pavClientMem) /* <- extension arg to pass in the client memory buffer,
* applicable ONLY for SYSMEM textures */
{
TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
hr = texture_init(object, device, width, height, levels, usage, format, pool, shared_handle, pavClientMem);
{
return hr;
}
return D3D_OK;
}
void **pavClientMem)
{
TRACE("iface %p, width %u, height %u, depth %u, levels %u\n",
TRACE("usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
hr = volumetexture_init(object, device, width, height, depth, levels, usage, format, pool, shared_handle, pavClientMem);
{
return hr;
}
return D3D_OK;
}
void **pavClientMem) /* <- extension arg to pass in the client memory buffer,
* applicable ONLY for SYSMEM textures */
{
TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
hr = cubetexture_init(object, device, edge_length, levels, usage, format, pool, shared_handle, pavClientMem);
{
return hr;
}
return D3D_OK;
}
#endif
{
#ifdef VBOX_WITH_WDDM
NULL);
#else
struct d3d9_texture *object;
TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (shared_handle)
{
if (pool == D3DPOOL_SYSTEMMEM)
{
if (levels != 1)
return D3DERR_INVALIDCALL;
}
else
}
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
if (set_mem)
{
struct wined3d_resource *resource;
struct d3d9_surface *surface;
}
return D3D_OK;
#endif
}
{
#ifdef VBOX_WITH_WDDM
#else
struct d3d9_texture *object;
TRACE("iface %p, width %u, height %u, depth %u, levels %u\n",
TRACE("usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
#endif
}
{
#ifdef VBOX_WITH_WDDM
#else
struct d3d9_texture *object;
TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
#endif
}
{
TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p, shared_handle %p.\n",
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
}
{
TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p, shared_handle %p.\n",
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
}
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
#endif
)
{
TRACE("device %p, width %u, height %u, format %#x, flags %#x, surface %p.\n"
"usage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
{
FIXME("Failed to allocate surface memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
#ifdef VBOX_WITH_WDDM
)))
#else
#endif
{
return hr;
}
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_CreateRenderTarget(IDirect3DDevice9Ex *iface, UINT width, UINT height,
{
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
"lockable %#x, surface %p, shared_handle %p.\n",
if (shared_handle)
if (lockable)
#ifdef VBOX_WITH_WDDM
, NULL
#endif
);
}
static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *iface, UINT width, UINT height,
{
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
"discard %#x, surface %p, shared_handle %p.\n",
if (shared_handle)
if (discard)
#ifdef VBOX_WITH_WDDM
, NULL
#endif
);
}
{
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
return hr;
}
{
return hr;
}
{
return hr;
}
{
hr = wined3d_device_get_front_buffer_data(device->wined3d_device, swapchain, dst_impl->wined3d_surface);
return hr;
}
static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex *iface, IDirect3DSurface9 *src_surface,
const RECT *src_rect, IDirect3DSurface9 *dst_surface, const RECT *dst_rect, D3DTEXTUREFILTERTYPE filter)
{
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_rect %p, filter %#x.\n",
{
{
WARN("Rejecting depth / stencil blit while in scene.\n");
goto done;
}
if (src_rect)
{
{
WARN("Rejecting depth / stencil blit with invalid source rect %s.\n",
goto done;
}
}
if (dst_rect)
{
{
WARN("Rejecting depth / stencil blit with invalid destination rect %s.\n",
goto done;
}
}
{
WARN("Rejecting depth / stencil blit with mismatched surface sizes.\n");
goto done;
}
}
hr = wined3d_surface_blt(dst->wined3d_surface, dst_rect, src->wined3d_surface, src_rect, 0, NULL, filter);
if (hr == WINEDDERR_INVALIDRECT)
done:
return hr;
}
{
const struct wined3d_color c =
{
};
/* This method is only allowed with surfaces that are render targets, or
* offscreen plain surfaces in D3DPOOL_DEFAULT. */
{
WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
return D3DERR_INVALIDCALL;
}
/* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
return hr;
}
{
TRACE("iface %p, width %u, height %u, format %#x, pool %#x, surface %p, shared_handle %p.\n",
if (shared_handle)
if (pool == D3DPOOL_MANAGED)
{
WARN("Attempting to create a managed offscreen plain surface.\n");
return D3DERR_INVALIDCALL;
}
/* FIXME: Offscreen surfaces are supposed to be always lockable,
* regardless of the pool they're created in. Should we set dynamic usage
* here? */
#ifdef VBOX_WITH_WDDM
, NULL
#endif
);
}
static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface)
{
{
return D3DERR_INVALIDCALL;
}
#ifdef VBOX_WITH_WDDM
#else
#endif
);
return hr;
}
static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 **surface)
{
if (!surface)
return D3DERR_INVALIDCALL;
{
return D3DERR_INVALIDCALL;
}
{
}
else
{
}
return hr;
}
static HRESULT WINAPI d3d9_device_SetDepthStencilSurface(IDirect3DDevice9Ex *iface, IDirect3DSurface9 *depth_stencil)
{
wined3d_device_set_depth_stencil(device->wined3d_device, ds_impl ? ds_impl->wined3d_surface : NULL);
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *iface, IDirect3DSurface9 **depth_stencil)
{
if (!depth_stencil)
return D3DERR_INVALIDCALL;
{
}
else
{
*depth_stencil = NULL;
}
return hr;
}
{
return hr;
}
{
return hr;
}
{
const struct wined3d_color c =
{
};
TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
return hr;
}
{
/* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
return D3D_OK;
}
{
/* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
return D3D_OK;
}
{
/* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
wined3d_device_multiply_transform(device->wined3d_device, state, (const struct wined3d_matrix *)matrix);
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetViewport(IDirect3DDevice9Ex *iface, const D3DVIEWPORT9 *viewport)
{
/* Note: D3DVIEWPORT9 is compatible with struct wined3d_viewport. */
return D3D_OK;
}
{
/* Note: D3DVIEWPORT9 is compatible with struct wined3d_viewport. */
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetMaterial(IDirect3DDevice9Ex *iface, const D3DMATERIAL9 *material)
{
/* Note: D3DMATERIAL9 is compatible with struct wined3d_material. */
return D3D_OK;
}
{
/* Note: D3DMATERIAL9 is compatible with struct wined3d_material. */
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetLight(IDirect3DDevice9Ex *iface, DWORD index, const D3DLIGHT9 *light)
{
/* Note: D3DLIGHT9 is compatible with struct wined3d_light. */
return hr;
}
static HRESULT WINAPI d3d9_device_GetLight(IDirect3DDevice9Ex *iface, DWORD index, D3DLIGHT9 *light)
{
/* Note: D3DLIGHT9 is compatible with struct wined3d_light. */
return hr;
}
{
return hr;
}
static HRESULT WINAPI d3d9_device_GetLightEnable(IDirect3DDevice9Ex *iface, DWORD index, BOOL *enable)
{
return hr;
}
static HRESULT WINAPI d3d9_device_SetClipPlane(IDirect3DDevice9Ex *iface, DWORD index, const float *plane)
{
hr = wined3d_device_set_clip_plane(device->wined3d_device, index, (const struct wined3d_vec4 *)plane);
return hr;
}
static HRESULT WINAPI d3d9_device_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD index, float *plane)
{
return hr;
}
{
return D3D_OK;
}
{
return D3D_OK;
}
{
{
WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
if (!object)
return E_OUTOFMEMORY;
{
return hr;
}
return D3D_OK;
}
{
return hr;
}
static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **stateblock)
{
{
return hr;
}
if (!object)
{
return E_OUTOFMEMORY;
}
{
return hr;
}
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetClipStatus(IDirect3DDevice9Ex *iface, const D3DCLIPSTATUS9 *clip_status)
{
hr = wined3d_device_set_clip_status(device->wined3d_device, (const struct wined3d_clip_status *)clip_status);
return hr;
}
static HRESULT WINAPI d3d9_device_GetClipStatus(IDirect3DDevice9Ex *iface, D3DCLIPSTATUS9 *clip_status)
{
hr = wined3d_device_get_clip_status(device->wined3d_device, (struct wined3d_clip_status *)clip_status);
return hr;
}
static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 **texture)
{
if (!texture)
return D3DERR_INVALIDCALL;
{
}
else
{
}
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 *texture)
{
return hr;
}
{
WINED3D_TSS_INVALID, /* 0, unused */
WINED3D_TSS_COLOR_OP, /* 1, D3DTSS_COLOROP */
WINED3D_TSS_COLOR_ARG1, /* 2, D3DTSS_COLORARG1 */
WINED3D_TSS_COLOR_ARG2, /* 3, D3DTSS_COLORARG2 */
WINED3D_TSS_ALPHA_OP, /* 4, D3DTSS_ALPHAOP */
WINED3D_TSS_ALPHA_ARG1, /* 5, D3DTSS_ALPHAARG1 */
WINED3D_TSS_ALPHA_ARG2, /* 6, D3DTSS_ALPHAARG2 */
WINED3D_TSS_BUMPENV_MAT00, /* 7, D3DTSS_BUMPENVMAT00 */
WINED3D_TSS_BUMPENV_MAT01, /* 8, D3DTSS_BUMPENVMAT01 */
WINED3D_TSS_BUMPENV_MAT10, /* 9, D3DTSS_BUMPENVMAT10 */
WINED3D_TSS_BUMPENV_MAT11, /* 10, D3DTSS_BUMPENVMAT11 */
WINED3D_TSS_TEXCOORD_INDEX, /* 11, D3DTSS_TEXCOORDINDEX */
WINED3D_TSS_INVALID, /* 12, unused */
WINED3D_TSS_INVALID, /* 13, unused */
WINED3D_TSS_INVALID, /* 14, unused */
WINED3D_TSS_INVALID, /* 15, unused */
WINED3D_TSS_INVALID, /* 16, unused */
WINED3D_TSS_INVALID, /* 17, unused */
WINED3D_TSS_INVALID, /* 18, unused */
WINED3D_TSS_INVALID, /* 19, unused */
WINED3D_TSS_INVALID, /* 20, unused */
WINED3D_TSS_INVALID, /* 21, unused */
WINED3D_TSS_BUMPENV_LSCALE, /* 22, D3DTSS_BUMPENVLSCALE */
WINED3D_TSS_BUMPENV_LOFFSET, /* 23, D3DTSS_BUMPENVLOFFSET */
WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
WINED3D_TSS_INVALID, /* 25, unused */
WINED3D_TSS_COLOR_ARG0, /* 26, D3DTSS_COLORARG0 */
WINED3D_TSS_ALPHA_ARG0, /* 27, D3DTSS_ALPHAARG0 */
WINED3D_TSS_RESULT_ARG, /* 28, D3DTSS_RESULTARG */
WINED3D_TSS_INVALID, /* 29, unused */
WINED3D_TSS_INVALID, /* 30, unused */
WINED3D_TSS_INVALID, /* 31, unused */
WINED3D_TSS_CONSTANT, /* 32, D3DTSS_CONSTANT */
};
{
{
return D3D_OK;
}
return D3D_OK;
}
{
{
return D3D_OK;
}
return D3D_OK;
}
{
return D3D_OK;
}
{
return D3D_OK;
}
{
return hr;
}
{
/* The d3d9 palette API is non-functional on Windows. Getters and setters are implemented,
* and some drivers allow the creation of P8 surfaces. These surfaces can be copied to
* other P8 surfaces with StretchRect, but cannot be converted to (A)RGB.
*
* Some older(dx7) cards may have support for P8 textures, but games cannot rely on this. */
return D3D_OK;
}
{
return D3DERR_INVALIDCALL;
}
static HRESULT WINAPI d3d9_device_SetCurrentTexturePalette(IDirect3DDevice9Ex *iface, UINT palette_idx)
{
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_GetCurrentTexturePalette(IDirect3DDevice9Ex *iface, UINT *palette_idx)
{
return D3DERR_INVALIDCALL;
}
{
return D3D_OK;
}
{
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetSoftwareVertexProcessing(IDirect3DDevice9Ex *iface, BOOL software)
{
return D3D_OK;
}
{
return ret;
}
{
return hr;
}
{
float ret;
return ret;
}
{
TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
return hr;
}
{
TRACE("iface %p, primitive_type %#x, base_vertex_idx %u, min_vertex_idx %u,\n"
"vertex_count %u, start_idx %u, primitive_count %u.\n",
return hr;
}
{
};
/* The caller is responsible for wined3d locking */
{
{
hr = wined3d_buffer_create_vb(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
{
return hr;
}
if (device->vertex_buffer)
device->vertex_buffer_pos = 0;
}
return D3D_OK;
}
{
TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
if (!primitive_count)
{
WARN("primitive_count is 0, returning D3D_OK\n");
return D3D_OK;
}
goto done;
vb_pos = 0;
else
goto done;
goto done;
done:
return hr;
}
/* The caller is responsible for wined3d locking */
{
{
hr = wined3d_buffer_create_ib(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
{
return hr;
}
if (device->index_buffer)
device->index_buffer_pos = 0;
}
return D3D_OK;
}
{
TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, vertex_count %u, primitive_count %u,\n"
"index_data %p, index_format %#x, vertex_data %p, vertex_stride %u.\n",
if (!primitive_count)
{
WARN("primitive_count is 0, returning D3D_OK\n");
return D3D_OK;
}
goto done;
vb_pos = 0;
else
goto done;
goto done;
ib_pos = 0;
else
goto done;
hr = wined3d_device_set_stream_source(device->wined3d_device, 0, device->vertex_buffer, 0, vertex_stride);
goto done;
hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / idx_fmt_size, idx_count);
done:
return hr;
}
{
struct d3d9_vertex_declaration *decl_impl = unsafe_impl_from_IDirect3DVertexDeclaration9(declaration);
TRACE("iface %p, src_start_idx %u, dst_idx %u, vertex_count %u, dst_buffer %p, declaration %p, flags %#x.\n",
return hr;
}
{
if (!declaration)
{
WARN("Caller passed a NULL declaration, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
return hr;
}
{
struct d3d9_vertex_declaration *decl_impl = unsafe_impl_from_IDirect3DVertexDeclaration9(declaration);
return D3D_OK;
}
{
if (!declaration) return D3DERR_INVALIDCALL;
{
}
else
{
*declaration = NULL;
}
return D3D_OK;
}
static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9_device *device, DWORD fvf)
{
low = 0;
{
TRACE("%d ", p);
{
}
low = p + 1;
else
high = p - 1;
}
return NULL;
return NULL;
{
fvf_decls = HeapReAlloc(GetProcessHeap(), 0, fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow));
if (!fvf_decls)
{
return NULL;
}
}
++device->fvf_decl_count;
return wined3d_declaration;
}
{
if (!fvf)
{
return D3D_OK;
}
{
return D3DERR_DRIVERINTERNALERROR;
}
return D3D_OK;
}
{
{
}
else
{
*fvf = 0;
}
return D3D_OK;
}
{
if (!object)
return E_OUTOFMEMORY;
{
return hr;
}
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetVertexShader(IDirect3DDevice9Ex *iface, IDirect3DVertexShader9 *shader)
{
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_GetVertexShader(IDirect3DDevice9Ex *iface, IDirect3DVertexShader9 **shader)
{
{
}
else
{
}
return D3D_OK;
}
{
{
WARN("Trying to access %u constants, but d3d9 only supports %u\n",
return D3DERR_INVALIDCALL;
}
return hr;
}
{
{
WARN("Trying to access %u constants, but d3d9 only supports %u\n",
return D3DERR_INVALIDCALL;
}
return hr;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
TRACE("iface %p, stream_idx %u, buffer %p, offset %u, stride %u.\n",
return hr;
}
{
TRACE("iface %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
if (!buffer)
return D3DERR_INVALIDCALL;
hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer, offset, stride);
{
}
else
{
}
return hr;
}
static HRESULT WINAPI d3d9_device_SetStreamSourceFreq(IDirect3DDevice9Ex *iface, UINT stream_idx, UINT freq)
{
return hr;
}
static HRESULT WINAPI d3d9_device_GetStreamSourceFreq(IDirect3DDevice9Ex *iface, UINT stream_idx, UINT *freq)
{
return hr;
}
static HRESULT WINAPI d3d9_device_SetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 *buffer)
{
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **buffer)
{
if (!buffer)
return D3DERR_INVALIDCALL;
{
}
else
{
}
return D3D_OK;
}
{
if (!object)
{
FIXME("Failed to allocate pixel shader memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetPixelShader(IDirect3DDevice9Ex *iface, IDirect3DPixelShader9 *shader)
{
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_GetPixelShader(IDirect3DDevice9Ex *iface, IDirect3DPixelShader9 **shader)
{
if (!shader) return D3DERR_INVALIDCALL;
{
}
else
{
}
return D3D_OK;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
return hr;
}
{
FIXME("iface %p, handle %#x, segment_count %p, patch_info %p unimplemented.\n",
return D3D_OK;
}
{
FIXME("iface %p, handle %#x, segment_count %p, patch_info %p unimplemented.\n",
return D3D_OK;
}
{
return D3DERR_INVALIDCALL;
}
static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUERYTYPE type, IDirect3DQuery9 **query)
{
if (!object)
return E_OUTOFMEMORY;
{
return hr;
}
return D3D_OK;
}
{
FIXME("iface %p, width %u, height %u, rows %p, columns %p stub!\n",
return E_NOTIMPL;
}
UINT rect_count, IDirect3DVertexBuffer9 *dst_descs, D3DCOMPOSERECTSOP operation, INT offset_x, INT offset_y)
{
FIXME("iface %p, src_surface %p, dst_surface %p, src_descs %p, rect_count %u,\n"
"dst_descs %p, operation %#x, offset_x %u, offset_y %u stub!\n",
return E_NOTIMPL;
}
{
TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p, flags %#x.\n",
return hr;
}
{
return E_NOTIMPL;
}
{
return E_NOTIMPL;
}
{
return E_NOTIMPL;
}
{
FIXME("iface %p, resources %p, resource_count %u stub!\n",
return E_NOTIMPL;
}
static HRESULT WINAPI d3d9_device_SetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT max_latency)
{
return E_NOTIMPL;
}
static HRESULT WINAPI d3d9_device_GetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT *max_latency)
{
*max_latency = 2;
return E_NOTIMPL;
}
{
static int i;
if (!i++)
return D3D_OK;
}
UINT width, UINT height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality,
{
FIXME("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u,\n"
"lockable %#x, surface %p, shared_handle %p, usage %#x stub!\n",
if (shared_handle)
return E_NOTIMPL;
}
{
FIXME("iface %p, width %u, height %u, format %#x, pool %#x, surface %p, shared_handle %p, usage %#x stub!\n",
return E_NOTIMPL;
}
UINT width, UINT height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality,
{
FIXME("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u,\n"
"discard %#x, surface %p, shared_handle %p, usage %#x stub!\n",
if (shared_handle)
return E_NOTIMPL;
}
{
if (mode)
{
}
if (device->vertex_buffer)
{
device->vertex_buffer_size = 0;
}
if (device->index_buffer)
{
device->index_buffer_size = 0;
}
return hr;
}
{
TRACE("iface %p, swapchain_idx %u, mode %p, rotation %p.\n",
return D3DERR_INVALIDCALL;
(enum wined3d_display_rotation *)rotation);
{
}
return hr;
}
{
/* IUnknown */
/* IDirect3DDevice9 */
/* IDirect3DDevice9Ex */
};
static inline struct d3d9_device *device_from_device_parent(struct wined3d_device_parent *device_parent)
{
}
struct wined3d_device *device)
{
}
{
}
static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
#endif
)
{
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, flags %#x, surface %p.\n",
#ifdef VBOX_WITH_WDDM
)))
#else
#endif
{
return hr;
}
return hr;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
{
TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n",
if (container_parent == device_parent)
texture_desc = *desc;
#ifdef VBOX_WITH_WDDM
#else
#endif
{
return hr;
}
return hr;
}
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
#endif
)
{
TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
"format %#x, pool %#x, usage %#x, volume %p\n",
/* Allocate the storage for the device */
if (!object)
{
FIXME("Allocation of memory failed\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
#ifdef VBOX_WITH_WDDM
#endif
);
{
return hr;
}
return hr;
}
{
{
return hr;
}
return hr;
}
{
};
#if defined(VBOX) && defined(RT_ARCH_AMD64)
#endif
static void setup_fpu(void)
{
#else
FIXME("FPU setup not implemented for this platform.\n");
#endif
}
#ifdef VBOX_WITH_WDDM
#else
#endif
, D3DDISPLAYMODEEX *mode)
{
if (mode)
FIXME("Ignoring display mode.\n");
{
return hr;
}
{
}
if (flags & D3DCREATE_MULTITHREADED)
#ifndef VBOX_WITH_WDDM
if (!parameters->Windowed)
{
if (!focus_window)
{
return hr;
}
for (i = 0; i < count; ++i)
{
}
}
#else
{
ERR("non-windowed mode unsupported!");
}
#endif
if (!swapchain_desc)
{
ERR("Failed to allocate wined3d parameters.\n");
return E_OUTOFMEMORY;
}
for (i = 0; i < count; ++i)
{
#ifdef VBOX_WITH_WDDM
#else
#endif
}
{
#ifndef VBOX_WITH_WDDM
#endif
return hr;
}
for (i = 0; i < count; ++i)
{
#ifndef VBOX_WITH_WDDM
#else
#endif
}
/* Initialize the converted declaration array. This creates a valid pointer
* and when adding decls HeapReAlloc() can be used without further checking. */
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
#ifndef VBOX_WITH_WDDM
#endif
return E_OUTOFMEMORY;
}
return D3D_OK;
}
#ifdef VBOX_WITH_WDDM
const VBOXBOX3D *pSrcBoxArg,
const VBOXPOINT3D *pDstPoin3D)
{
hr = wined3d_device_blt_vol(device->wined3d_device, src->wined3d_volume, dst->wined3d_volume, (struct wined3d_box*)pSrcBoxArg, pDstPoin3D);
return hr;
}
const VBOXBOX3D *pSrcBoxArg,
const VBOXPOINT3D *pDstPoin3D)
{
struct d3d9_texture *src = unsafe_impl_from_IDirect3DBaseTexture9((IDirect3DBaseTexture9*)pSourceTexture);
struct d3d9_texture *dst = unsafe_impl_from_IDirect3DBaseTexture9((IDirect3DBaseTexture9*)pDestinationTexture);
hr = wined3d_device_blt_voltex(device->wined3d_device, src->wined3d_texture, dst->wined3d_texture, (struct wined3d_box*)pSrcBoxArg, pDstPoin3D);
return hr;
}
{
{
}
if (wined3d_refs)
{
while (wined3d_device_decref(wined3d_device)) {}
}
return D3D_OK;
}
#endif