device.c revision 4237d5a79f48789aacc67dc43378d2d7813a39f4
/*
* IDirect3DDevice8 implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2004 Christian Costa
*
* 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 <math.h>
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "d3d8_private.h"
{
/* 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_R16G16_UNORM: return D3DFMT_G16R16;
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_R10G11B11_SNORM: return D3DFMT_W11V11U10;
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_VERTEXDATA: return D3DFMT_VERTEXDATA;
case WINED3DFMT_R16_UINT: return D3DFMT_INDEX16;
case WINED3DFMT_R32_UINT: return D3DFMT_INDEX32;
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_G16R16: return WINED3DFMT_R16G16_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_W11V11U10: return WINED3DFMT_R10G11B11_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_VERTEXDATA: return WINED3DFMT_VERTEXDATA;
case D3DFMT_INDEX16: return WINED3DFMT_R16_UINT;
case D3DFMT_INDEX32: return WINED3DFMT_R32_UINT;
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;
}
}
static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
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);
}
/* Handle table functions */
static DWORD d3d8_allocate_handle(struct d3d8_handle_table *t, void *object, enum d3d8_handle_type type)
{
struct d3d8_handle_entry *entry;
if (t->free_entries)
{
/* Use a free handle */
entry = t->free_entries;
{
return D3D8_INVALID_HANDLE;
}
return index;
}
if (!(t->entry_count < t->table_size))
{
/* Grow the table */
if (!new_entries)
{
ERR("Failed to grow the handle table.\n");
return D3D8_INVALID_HANDLE;
}
t->entries = new_entries;
t->table_size = new_size;
}
return t->entry_count++;
}
static void *d3d8_free_handle(struct d3d8_handle_table *t, DWORD handle, enum d3d8_handle_type type)
{
struct d3d8_handle_entry *entry;
void *object;
{
return NULL;
}
{
return NULL;
}
t->free_entries = entry;
return object;
}
{
struct d3d8_handle_entry *entry;
{
return NULL;
}
{
return NULL;
}
}
{
}
{
TRACE("iface %p, riid %s, out %p.\n",
{
return S_OK;
}
return E_NOINTERFACE;
}
{
return ref;
}
{
if (device->inDestruction)
return 0;
if (!ref)
{
unsigned i;
for (i = 0; i < device->numConvertedDecls; ++i)
{
}
if (device->vertex_buffer)
if (device->index_buffer)
}
return ref;
}
{
{
TRACE("Device is lost.\n");
return D3DERR_DEVICENOTRESET;
}
return D3D_OK;
}
{
return hr;
}
static HRESULT WINAPI d3d8_device_ResourceManagerDiscardBytes(IDirect3DDevice8 *iface, DWORD byte_count)
{
if (byte_count)
FIXME("Byte count ignored.\n");
return D3D_OK;
}
{
if (!d3d8)
return D3DERR_INVALIDCALL;
}
{
if (!caps)
return D3DERR_INVALIDCALL;
return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
return hr;
}
{
struct wined3d_display_mode wined3d_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 d3d8_device_SetCursorPosition(IDirect3DDevice8 *iface, UINT x, UINT y, DWORD flags)
{
}
{
return ret;
}
{
struct wined3d_swapchain_desc desc;
struct d3d8_swapchain *object;
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
return D3D_OK;
}
{
struct wined3d_resource_desc desc;
{
struct d3d8_surface *surface;
{
{
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_DEVICELOST;
}
return D3D_OK;
}
{
return D3DERR_DEVICELOST;
}
{
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
return D3DERR_DEVICELOST;
}
}
return D3D_OK;
}
{
struct wined3d_swapchain_desc swapchain_desc;
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 %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
return hr;
}
{
struct d3d8_surface *surface_impl;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
{
}
return hr;
}
static HRESULT WINAPI d3d8_device_GetRasterStatus(IDirect3DDevice8 *iface, D3DRASTER_STATUS *raster_status)
{
hr = wined3d_device_get_raster_status(device->wined3d_device, 0, (struct wined3d_raster_status *)raster_status);
return hr;
}
static void WINAPI d3d8_device_SetGammaRamp(IDirect3DDevice8 *iface, DWORD flags, const D3DGAMMARAMP *ramp)
{
/* Note: D3DGAMMARAMP is compatible with struct wined3d_gamma_ramp. */
wined3d_device_set_gamma_ramp(device->wined3d_device, 0, flags, (const struct wined3d_gamma_ramp *)ramp);
}
{
/* Note: D3DGAMMARAMP is compatible with struct wined3d_gamma_ramp. */
}
{
struct d3d8_texture *object;
TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
}
{
struct d3d8_texture *object;
TRACE("iface %p, width %u, height %u, depth %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
}
{
struct d3d8_texture *object;
TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return hr;
}
{
struct d3d8_vertexbuffer *object;
TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p.\n",
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
}
{
struct d3d8_indexbuffer *object;
TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p.\n",
if (!object)
return D3DERR_OUTOFVIDEOMEMORY;
{
return hr;
}
return D3D_OK;
}
{
struct d3d8_surface *object;
TRACE("device %p, width %u, height %u, format %#x, flags %#x, surface %p,\n"
"\tusage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
{
FIXME("Failed to allocate surface memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
{
return hr;
}
return D3D_OK;
}
{
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, lockable %#x, surface %p.\n",
if (lockable)
}
{
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, surface %p.\n",
/* TODO: Verify that Discard is false */
}
/* IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */
{
TRACE("iface %p, width %u, height %u, format %#x, surface %p.\n",
}
{
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, src_surface %p, src_rects %p, rect_count %u, dst_surface %p, dst_points %p.\n",
/* Check that the source texture is in WINED3D_POOL_SYSTEM_MEM and the
* destination texture is in WINED3D_POOL_DEFAULT. */
{
return D3DERR_INVALIDCALL;
}
{
return D3DERR_INVALIDCALL;
}
/* Check that the source and destination formats match */
{
WARN("Source %p format must match the destination %p format, returning D3DERR_INVALIDCALL.\n",
return D3DERR_INVALIDCALL;
}
else if (WINED3DFMT_UNKNOWN == dst_format)
{
TRACE("Converting destination surface from WINED3DFMT_UNKNOWN to the source format.\n");
if (FAILED(hr = wined3d_surface_update_desc(dst->wined3d_surface, wined3d_desc.width, wined3d_desc.height,
{
return hr;
}
}
/* Quick if complete copy ... */
{
}
else
{
unsigned int i;
/* Copy rect by rect */
if (src_rects && dst_points)
{
for (i = 0; i < rect_count; ++i)
{
dst_points[i].x + w, dst_points[i].y + h};
}
}
else
{
for (i = 0; i < rect_count; ++i)
{
}
}
}
return WINED3D_OK;
}
{
return hr;
}
static HRESULT WINAPI d3d8_device_GetFrontBuffer(IDirect3DDevice8 *iface, IDirect3DSurface8 *dst_surface)
{
if (!dst_surface)
{
WARN("Invalid destination surface passed.\n");
return D3DERR_INVALIDCALL;
}
return hr;
}
{
if (ds_impl)
{
struct wined3d_resource *wined3d_resource;
/* If no render target is passed in check the size against the current RT */
if (!render_target)
{
{
return D3DERR_NOTFOUND;
}
}
else
{
WARN("Depth stencil is smaller than the render target, returning D3DERR_INVALIDCALL\n");
return D3DERR_INVALIDCALL;
}
}
wined3d_device_set_depth_stencil(device->wined3d_device, ds_impl ? ds_impl->wined3d_surface : NULL);
if (render_target)
{
}
return hr;
}
static HRESULT WINAPI d3d8_device_GetRenderTarget(IDirect3DDevice8 *iface, IDirect3DSurface8 **render_target)
{
struct wined3d_surface *wined3d_surface;
struct d3d8_surface *surface_impl;
if (!render_target)
return D3DERR_INVALIDCALL;
{
}
else
{
ERR("Failed to get wined3d render target.\n");
*render_target = NULL;
}
return hr;
}
static HRESULT WINAPI d3d8_device_GetDepthStencilSurface(IDirect3DDevice8 *iface, IDirect3DSurface8 **depth_stencil)
{
struct wined3d_surface *wined3d_surface;
struct d3d8_surface *surface_impl;
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 d3d8_device_SetViewport(IDirect3DDevice8 *iface, const D3DVIEWPORT8 *viewport)
{
/* Note: D3DVIEWPORT8 is compatible with struct wined3d_viewport. */
return D3D_OK;
}
{
/* Note: D3DVIEWPORT8 is compatible with struct wined3d_viewport. */
return D3D_OK;
}
static HRESULT WINAPI d3d8_device_SetMaterial(IDirect3DDevice8 *iface, const D3DMATERIAL8 *material)
{
/* Note: D3DMATERIAL8 is compatible with struct wined3d_material. */
return D3D_OK;
}
{
/* Note: D3DMATERIAL8 is compatible with struct wined3d_material. */
return D3D_OK;
}
static HRESULT WINAPI d3d8_device_SetLight(IDirect3DDevice8 *iface, DWORD index, const D3DLIGHT8 *light)
{
/* Note: D3DLIGHT8 is compatible with struct wined3d_light. */
return hr;
}
{
/* Note: D3DLIGHT8 is compatible with struct wined3d_light. */
return hr;
}
{
return hr;
}
static HRESULT WINAPI d3d8_device_GetLightEnable(IDirect3DDevice8 *iface, DWORD index, BOOL *enable)
{
return hr;
}
static HRESULT WINAPI d3d8_device_SetClipPlane(IDirect3DDevice8 *iface, DWORD index, const float *plane)
{
hr = wined3d_device_set_clip_plane(device->wined3d_device, index, (const struct wined3d_vec4 *)plane);
return hr;
}
{
return hr;
}
{
switch (state)
{
case D3DRS_ZBIAS:
break;
default:
}
return D3D_OK;
}
{
switch (state)
{
case D3DRS_ZBIAS:
break;
default:
}
return D3D_OK;
}
{
return hr;
}
{
struct wined3d_stateblock *stateblock;
/* Tell wineD3D to endstateblock before anything else (in case we run out
* of memory later and cause locking problems)
*/
{
WARN("IWineD3DDevice_EndStateBlock returned an error\n");
return hr;
}
if (*token == D3D8_INVALID_HANDLE)
{
ERR("Failed to create a handle\n");
return E_FAIL;
}
++*token;
return hr;
}
{
struct wined3d_stateblock *stateblock;
if (!token)
return D3D_OK;
if (!stateblock)
{
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
struct wined3d_stateblock *stateblock;
if (!stateblock)
{
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
struct wined3d_stateblock *stateblock;
if (!stateblock)
{
return D3DERR_INVALIDCALL;
}
{
}
return D3D_OK;
}
{
struct wined3d_stateblock *stateblock;
if (type != D3DSBT_ALL
&& type != D3DSBT_PIXELSTATE
&& type != D3DSBT_VERTEXSTATE)
{
WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n");
return D3DERR_INVALIDCALL;
}
hr = wined3d_stateblock_create(device->wined3d_device, (enum wined3d_stateblock_type)type, &stateblock);
{
return hr;
}
if (*handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate a handle.\n");
return E_FAIL;
}
++*handle;
return hr;
}
static HRESULT WINAPI d3d8_device_SetClipStatus(IDirect3DDevice8 *iface, const D3DCLIPSTATUS8 *clip_status)
{
/* FIXME: Verify that D3DCLIPSTATUS8 ~= struct wined3d_clip_status. */
hr = wined3d_device_set_clip_status(device->wined3d_device, (const struct wined3d_clip_status *)clip_status);
return hr;
}
static HRESULT WINAPI d3d8_device_GetClipStatus(IDirect3DDevice8 *iface, D3DCLIPSTATUS8 *clip_status)
{
hr = wined3d_device_get_clip_status(device->wined3d_device, (struct wined3d_clip_status *)clip_status);
return hr;
}
static HRESULT WINAPI d3d8_device_GetTexture(IDirect3DDevice8 *iface, DWORD stage, IDirect3DBaseTexture8 **texture)
{
struct wined3d_texture *wined3d_texture;
struct d3d8_texture *texture_impl;
if (!texture)
return D3DERR_INVALIDCALL;
{
}
else
{
}
return D3D_OK;
}
static HRESULT WINAPI d3d8_device_SetTexture(IDirect3DDevice8 *iface, DWORD stage, IDirect3DBaseTexture8 *texture)
{
struct d3d8_texture *texture_impl;
return hr;
}
static const struct tss_lookup
{
}
tss_lookup[] =
{
};
{
const struct tss_lookup *l;
{
return D3D_OK;
}
l = &tss_lookup[Type];
if (l->sampler_state)
else
return D3D_OK;
}
{
const struct tss_lookup *l;
{
return D3D_OK;
}
l = &tss_lookup[type];
if (l->sampler_state)
else
return D3D_OK;
}
{
return hr;
}
{
return D3D_OK;
}
{
/* GPUs stopped supporting palettized textures with the Shader Model 1 generation. Wined3d
* does not have a d3d8/9-style palette API */
return D3D_OK;
}
{
return D3DERR_INVALIDCALL;
}
static HRESULT WINAPI d3d8_device_SetCurrentTexturePalette(IDirect3DDevice8 *iface, UINT palette_idx)
{
return D3D_OK;
}
static HRESULT WINAPI d3d8_device_GetCurrentTexturePalette(IDirect3DDevice8 *iface, UINT *palette_idx)
{
return D3DERR_INVALIDCALL;
}
{
TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
return hr;
}
{
TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, vertex_count %u, start_idx %u, primitive_count %u.\n",
return hr;
}
static const struct wined3d_parent_ops d3d8_null_wined3d_parent_ops =
{
};
/* The caller is responsible for wined3d locking */
{
{
struct wined3d_buffer *buffer;
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 */
{
{
struct wined3d_buffer *buffer;
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;
}
{
TRACE("iface %p, src_start_idx %u, dst_idx %u, vertex_count %u, dst_buffer %p, flags %#x.\n",
return hr;
}
{
struct d3d8_vertex_shader *object;
TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#x.\n",
if (!object)
{
*shader = 0;
return E_OUTOFMEMORY;
}
if (handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate vertex shader handle.\n");
*shader = 0;
return E_OUTOFMEMORY;
}
{
*shader = 0;
return hr;
}
*shader = shader_handle;
return D3D_OK;
}
static struct d3d8_vertex_declaration *d3d8_device_get_fvf_declaration(struct d3d8_device *device, DWORD fvf)
{
struct d3d8_vertex_declaration *d3d8_declaration;
low = 0;
{
TRACE("%d ", p);
{
return convertedDecls[p].declaration;
}
low = p + 1;
else
high = p - 1;
}
return NULL;
{
return NULL;
}
{
if (!convertedDecls)
{
return NULL;
}
}
return d3d8_declaration;
}
{
struct d3d8_vertex_shader *shader_impl;
if (VS_HIGHESTFIXEDFXF >= shader)
{
return D3D_OK;
}
TRACE("Setting shader\n");
if (!(shader_impl = d3d8_get_object(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS)))
{
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
struct d3d8_vertex_declaration *d3d8_declaration;
{
}
else
{
*shader = 0;
}
return D3D_OK;
}
{
struct d3d8_vertex_shader *shader_impl;
if (!(shader_impl = d3d8_free_handle(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS)))
{
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
TRACE("iface %p, start_register %u, data %p, count %u.\n",
{
WARN("Trying to access %u constants, but d3d8 only supports %u\n",
return D3DERR_INVALIDCALL;
}
return hr;
}
{
TRACE("iface %p, start_register %u, data %p, count %u.\n",
{
WARN("Trying to access %u constants, but d3d8 only supports %u\n",
return D3DERR_INVALIDCALL;
}
return hr;
}
{
struct d3d8_vertex_declaration *declaration;
struct d3d8_vertex_shader *shader_impl;
TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
shader_impl = d3d8_get_object(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
if (!shader_impl)
{
return D3DERR_INVALIDCALL;
}
if (!data)
{
return D3D_OK;
}
/* MSDN claims that if *data_size is smaller than the required size
* we should write the required size and return D3DERR_MOREDATA.
* That's not actually true. */
return D3DERR_INVALIDCALL;
return D3D_OK;
}
{
TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
if (!(shader_impl = d3d8_get_object(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS)))
{
return D3DERR_INVALIDCALL;
}
if (!shader_impl->wined3d_shader)
{
*data_size = 0;
return D3D_OK;
}
return hr;
}
{
/* WineD3D takes an INT(due to d3d9), but d3d8 uses UINTs. Do I have to add a check here that
* the UINT doesn't cause an overflow in the INT? It seems rather unlikely because such large
* vertex buffers can't be created to address them with an index that requires the 32nd bit
* (4 Byte minimum vertex size * 2^31-1 -> 8 gb buffer. The index sign would be the least
* problem)
*/
return D3D_OK;
}
{
struct wined3d_buffer *wined3d_buffer;
struct d3d8_indexbuffer *buffer_impl;
if (!buffer)
return D3DERR_INVALIDCALL;
/* The case from UINT to INT is safe because d3d8 will never set negative values */
{
}
else
{
}
return D3D_OK;
}
{
struct d3d8_pixel_shader *object;
if (!shader)
return D3DERR_INVALIDCALL;
if (!object)
return E_OUTOFMEMORY;
if (handle == D3D8_INVALID_HANDLE)
{
ERR("Failed to allocate pixel shader handle.\n");
return E_OUTOFMEMORY;
}
{
*shader = 0;
return hr;
}
*shader = shader_handle;
return D3D_OK;
}
{
struct d3d8_pixel_shader *shader_impl;
if (!shader)
{
return D3D_OK;
}
if (!(shader_impl = d3d8_get_object(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS)))
{
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
struct wined3d_shader *object;
if (!shader)
return D3DERR_INVALIDCALL;
{
struct d3d8_pixel_shader *d3d8_shader;
}
else
{
*shader = 0;
}
return D3D_OK;
}
{
struct d3d8_pixel_shader *shader_impl;
if (!(shader_impl = d3d8_free_handle(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS)))
{
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
{
TRACE("iface %p, start_register %u, data %p, count %u.\n",
return hr;
}
{
TRACE("iface %p, start_register %u, data %p, count %u.\n",
return hr;
}
{
TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
if (!(shader_impl = d3d8_get_object(&device->handle_table, shader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS)))
{
return D3DERR_INVALIDCALL;
}
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;
}
{
TRACE("iface %p, stream_idx %u, buffer %p, stride %u.\n",
return hr;
}
{
struct d3d8_vertexbuffer *buffer_impl;
TRACE("iface %p, stream_idx %u, buffer %p, stride %p.\n",
if (!buffer)
return D3DERR_INVALIDCALL;
hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer, 0, stride);
{
}
else
{
}
return hr;
}
static const struct IDirect3DDevice8Vtbl d3d8_device_vtbl =
{
};
static inline struct d3d8_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,
{
struct d3d8_surface *d3d_surface;
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, flags %#x, surface %p.\n",
{
return hr;
}
return hr;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
{
struct wined3d_resource_desc texture_desc;
struct d3d8_surface *d3d_surface;
struct wined3d_texture *texture;
TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n",
texture_desc = *desc;
WINED3D_SURFACE_MAPPABLE, &device->IDirect3DDevice8_iface, &d3d8_null_wined3d_parent_ops, &texture)))
{
return hr;
}
return hr;
}
{
struct d3d8_volume *object;
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;
}
{
return hr;
}
return hr;
}
{
struct d3d8_swapchain *d3d_swapchain;
{
return hr;
}
return hr;
}
static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops =
{
};
static void setup_fpu(void)
{
#elif defined(RT_ARCH_AMD64)
unsigned int currentControl = 0;
#else
FIXME("FPU setup not implemented for this platform.\n");
#endif
}
HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter,
{
struct wined3d_swapchain_desc swapchain_desc;
{
ERR("Failed to allocate handle table memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
if (!parameters->Windowed)
{
if (!focus_window)
{
return hr;
}
if (!device_window)
}
if (flags & D3DCREATE_MULTITHREADED)
{
return hr;
}
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
hr = E_OUTOFMEMORY;
goto err;
}
return D3D_OK;
err:
return hr;
}