device.c revision 3afb377509fa36b98d85bf48c86eeb7225c999c9
756N/A#include "d3d9_private.h"
756N/A#ifdef VBOX_WITH_WDDM
2086N/A# include "../../common/VBoxVideoTools.h"
756N/A return D3DFMT_UNKNOWN;
2086N/A return WINED3DFMT_UNKNOWN;
756N/Astatic UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
756N/A switch(primitive_type)
756N/A case D3DPT_POINTLIST:
756N/A return primitive_count;
756N/A case D3DPT_LINELIST:
756N/A case D3DPT_LINESTRIP:
756N/A case D3DPT_TRIANGLELIST:
case D3DPT_TRIANGLESTRIP:
case D3DPT_TRIANGLEFAN:
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
static HRESULT WINAPI d3d9_device_QueryInterface(IDirect3DDevice9Ex *iface, REFIID riid, void **out)
return S_OK;
return E_NOINTERFACE;
return S_OK;
return E_NOINTERFACE;
return refcount;
#ifdef VBOX
# ifndef VBOX_WITH_WDDM
return wined3d_refs;
if (!refcount)
#ifdef VBOX
return refcount;
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 hr;
static HRESULT WINAPI d3d9_device_GetDisplayMode(IDirect3DDevice9Ex *iface, UINT swapchain, D3DDISPLAYMODE *mode)
return hr;
return D3D_OK;
if (!bitmap)
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,
return hr;
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;
return hr;
return hr;
return hr;
return hr;
return hr;
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)
wined3d_device_get_gamma_ramp(device->wined3d_device, swapchain, (struct wined3d_gamma_ramp *)ramp);
#ifdef VBOX_WITH_WDDM
return hr;
return hr;
return hr;
return hr;
//#pragma comment(linker, "/export:VBoxWineExD3DDev9CreateTexture=_VBoxWineExD3DDev9CreateTexture@40")
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)
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;
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;
#ifdef VBOX_WITH_WDDM
NULL);
TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
if (shared_handle)
return D3DERR_INVALIDCALL;
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
return hr;
if (set_mem)
return D3D_OK;
#ifdef VBOX_WITH_WDDM
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
return hr;
return D3D_OK;
#ifdef VBOX_WITH_WDDM
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;
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
return hr;
return D3D_OK;
if (shared_handle)
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
return hr;
return D3D_OK;
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
return D3DERR_OUTOFVIDEOMEMORY;
#ifdef VBOX_WITH_WDDM
return hr;
return D3D_OK;
static HRESULT WINAPI d3d9_device_CreateRenderTarget(IDirect3DDevice9Ex *iface, UINT width, UINT height,
if (shared_handle)
if (lockable)
#ifdef VBOX_WITH_WDDM
, NULL
static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *iface, UINT width, UINT height,
if (shared_handle)
if (discard)
#ifdef VBOX_WITH_WDDM
, NULL
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)
goto done;
if (src_rect)
goto done;
if (dst_rect)
goto done;
goto done;
hr = wined3d_surface_blt(dst->wined3d_surface, dst_rect, src->wined3d_surface, src_rect, 0, NULL, filter);
done:
return hr;
const struct wined3d_color c =
return D3DERR_INVALIDCALL;
/* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
return hr;
if (shared_handle)
return D3DERR_INVALIDCALL;
#ifdef VBOX_WITH_WDDM
, NULL
static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface)
return D3DERR_INVALIDCALL;
return hr;
static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 **surface)
if (!surface)
return D3DERR_INVALIDCALL;
return D3DERR_INVALIDCALL;
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;
return hr;
return hr;
return hr;
const struct wined3d_color c =
hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
return hr;
return D3D_OK;
return D3D_OK;
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)
return D3D_OK;
return D3D_OK;
static HRESULT WINAPI d3d9_device_SetMaterial(IDirect3DDevice9Ex *iface, const D3DMATERIAL9 *material)
return D3D_OK;
return D3D_OK;
static HRESULT WINAPI d3d9_device_SetLight(IDirect3DDevice9Ex *iface, DWORD index, const D3DLIGHT9 *light)
return hr;
static HRESULT WINAPI d3d9_device_GetLight(IDirect3DDevice9Ex *iface, DWORD index, D3DLIGHT9 *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;
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;
return D3D_OK;
static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 *texture)
return hr;
return D3D_OK;
return D3D_OK;
return D3D_OK;
return D3D_OK;
return D3D_OK;
return D3D_OK;
return hr;
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;
return hr;
return hr;
hr = wined3d_buffer_create_vb(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
return hr;
return D3D_OK;
if (!primitive_count)
return D3D_OK;
goto done;
vb_pos = 0;
goto done;
goto done;
done:
return hr;
hr = wined3d_buffer_create_ib(device->wined3d_device, size, WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY,
return hr;
return D3D_OK;
if (!primitive_count)
return D3D_OK;
goto done;
vb_pos = 0;
goto done;
goto done;
ib_pos = 0;
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)
return D3DERR_INVALIDCALL;
return hr;
struct d3d9_vertex_declaration *decl_impl = unsafe_impl_from_IDirect3DVertexDeclaration9(declaration);
return D3D_OK;
return D3D_OK;
static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9_device *device, DWORD fvf)
low = 0;
return NULL;
return NULL;
fvf_decls = HeapReAlloc(GetProcessHeap(), 0, fvf_decls, sizeof(*fvf_decls) * (device->fvf_decl_size + grow));
if (!fvf_decls)
return NULL;
return wined3d_declaration;
if (!fvf)
return D3D_OK;
return D3DERR_DRIVERINTERNALERROR;
return D3D_OK;
*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)
return D3D_OK;
return D3DERR_INVALIDCALL;
return hr;
return D3DERR_INVALIDCALL;
return hr;
return hr;
return hr;
return hr;
return hr;
return hr;
if (!buffer)
return D3DERR_INVALIDCALL;
hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer, offset, stride);
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;
return D3D_OK;
if (!object)
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)
return D3D_OK;
return hr;
return hr;
return hr;
return hr;
return hr;
return hr;
return D3D_OK;
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;
return E_NOTIMPL;
UINT rect_count, IDirect3DVertexBuffer9 *dst_descs, D3DCOMPOSERECTSOP operation, INT offset_x, INT offset_y)
return E_NOTIMPL;
return hr;
return E_NOTIMPL;
return E_NOTIMPL;
return E_NOTIMPL;
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)
return E_NOTIMPL;
return D3D_OK;
UINT width, UINT height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality,
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,
if (shared_handle)
return E_NOTIMPL;
if (mode)
return hr;
return D3DERR_INVALIDCALL;
return hr;
static inline struct d3d9_device *device_from_device_parent(struct wined3d_device_parent *device_parent)
static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, flags %#x, surface %p.\n",
#ifdef VBOX_WITH_WDDM
return hr;
return hr;
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
#ifdef VBOX_WITH_WDDM
return hr;
return hr;
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
#ifdef VBOX_WITH_WDDM
return hr;
return hr;
return hr;
return hr;
static void setup_fpu(void)
#ifdef VBOX_WITH_WDDM
if (mode)
return hr;
#ifndef VBOX_WITH_WDDM
if (!focus_window)
return hr;
for (i = 0; i < count; ++i)
if (!swapchain_desc)
return E_OUTOFMEMORY;
for (i = 0; i < count; ++i)
#ifdef VBOX_WITH_WDDM
#ifndef VBOX_WITH_WDDM
return hr;
for (i = 0; i < count; ++i)
#ifndef VBOX_WITH_WDDM
#ifndef VBOX_WITH_WDDM
return E_OUTOFMEMORY;
return D3D_OK;
#ifdef VBOX_WITH_WDDM
hr = wined3d_device_blt_vol(device->wined3d_device, src->wined3d_volume, dst->wined3d_volume, (struct wined3d_box*)pSrcBoxArg, pDstPoin3D);
return hr;
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)
return D3D_OK;