device.c revision 91563ca66c54f5974bd78d4a8e51e1a690c03e0f
/*
* IWineD3DDevice implementation
*
* Copyright 2002 Lionel Ulmer
* Copyright 2002-2005 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2006-2008 Stefan Dösinger for CodeWeavers
* Copyright 2006-2008 Henri Verbeet
* Copyright 2007 Andrew Riedi
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* 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 <stdio.h>
#ifdef HAVE_FLOAT_H
# include <float.h>
#endif
#include "wined3d_private.h"
/* Define the default light parameters as specified by MSDN */
const WINED3DLIGHT WINED3D_default_light = {
WINED3DLIGHT_DIRECTIONAL, /* Type */
{ 1.0f, 1.0f, 1.0f, 0.0f }, /* Diffuse r,g,b,a */
{ 0.0f, 0.0f, 0.0f, 0.0f }, /* Specular r,g,b,a */
{ 0.0f, 0.0f, 0.0f, 0.0f }, /* Ambient r,g,b,a, */
{ 0.0f, 0.0f, 0.0f }, /* Position x,y,z */
{ 0.0f, 0.0f, 1.0f }, /* Direction x,y,z */
0.0f, /* Range */
0.0f, /* Falloff */
0.0f, 0.0f, 0.0f, /* Attenuation 0,1,2 */
0.0f, /* Theta */
0.0f /* Phi */
};
/**********************************************************
* Global variable / Constants follow
**********************************************************/
const float identity[] =
{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
}; /* When needed for comparisons */
/* Note that except for WINED3DPT_POINTLIST and WINED3DPT_LINELIST these
* actually have the same values in GL and D3D. */
{
switch(primitive_type)
{
case WINED3DPT_POINTLIST:
return GL_POINTS;
case WINED3DPT_LINELIST:
return GL_LINES;
case WINED3DPT_LINESTRIP:
return GL_LINE_STRIP;
case WINED3DPT_TRIANGLELIST:
return GL_TRIANGLES;
case WINED3DPT_TRIANGLESTRIP:
return GL_TRIANGLE_STRIP;
case WINED3DPT_TRIANGLEFAN:
return GL_TRIANGLE_FAN;
case WINED3DPT_LINELIST_ADJ:
return GL_LINES_ADJACENCY_ARB;
case WINED3DPT_LINESTRIP_ADJ:
return GL_LINE_STRIP_ADJACENCY_ARB;
return GL_TRIANGLES_ADJACENCY_ARB;
return GL_TRIANGLE_STRIP_ADJACENCY_ARB;
default:
return GL_NONE;
}
}
{
switch(primitive_type)
{
case GL_POINTS:
return WINED3DPT_POINTLIST;
case GL_LINES:
return WINED3DPT_LINELIST;
case GL_LINE_STRIP:
return WINED3DPT_LINESTRIP;
case GL_TRIANGLES:
return WINED3DPT_TRIANGLELIST;
case GL_TRIANGLE_STRIP:
return WINED3DPT_TRIANGLESTRIP;
case GL_TRIANGLE_FAN:
return WINED3DPT_TRIANGLEFAN;
case GL_LINES_ADJACENCY_ARB:
return WINED3DPT_LINELIST_ADJ;
return WINED3DPT_LINESTRIP_ADJ;
return WINED3DPT_TRIANGLELIST_ADJ;
return WINED3DPT_TRIANGLESTRIP_ADJ;
default:
return WINED3DPT_UNDEFINED;
}
}
{
else
{
*regnum = ~0U;
return FALSE;
}
return TRUE;
}
/* Context activation is done by the caller. */
{
/* We need to deal with frequency data! */
IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
unsigned int i;
stream_info->use_map = 0;
stream_info->swizzle_map = 0;
/* Check for transformed vertices, disable vertex shader if present. */
/* Translate the declaration into strided data. */
for (i = 0; i < declaration->element_count; ++i)
{
GLuint buffer_object = 0;
unsigned int idx;
{
TRACE("Stream %u is UP, %p\n", element->input_slot, This->stateBlock->streamSource[element->input_slot]);
buffer_object = 0;
}
else
{
TRACE("Stream %u isn't UP, %p\n", element->input_slot, This->stateBlock->streamSource[element->input_slot]);
/* 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. */
{
buffer_object = 0;
data = buffer_get_sysmem((struct wined3d_buffer *)This->stateBlock->streamSource[element->input_slot]);
{
FIXME("System memory vertex data load offset is negative!\n");
}
}
if (fixup)
{
else if (*fixup && !use_vshader
{
if (!warned)
{
/* This may be bad with the fixed function pipeline. */
FIXME("Missing vbo streams with unfixed colors or transformed position, expect problems\n");
}
}
}
}
TRACE("offset %u input_slot %u usage_idx %d\n", element->offset, element->input_slot, element->usage_idx);
if (use_vshader)
{
if (element->output_slot == ~0U)
{
/* TODO: Assuming vertexdeclarations are usually used with the
* same or a similar shader, it might be worth it to store the
* last used output slot and try that one first. */
}
else
{
stride_used = TRUE;
}
}
else
{
{
WARN("Skipping unsupported fixed function element of format %s and usage %s\n",
stride_used = FALSE;
}
else
{
}
}
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",
{
}
}
}
This->num_buffer_queries = 0;
{
/* PreLoad all the vertex buffers. */
{
struct wined3d_stream_info_element *element;
struct wined3d_buffer *buffer;
struct wined3d_event_query *query;
if (!(map & 1)) continue;
/* If PreLoad dropped the buffer object, update the stream info. */
{
element->buffer_object = 0;
}
if(query)
{
}
}
}
}
{
e->format_desc = format_desc;
e->stream_idx = 0;
e->buffer_object = 0;
}
{
unsigned int i;
stream_info_element_from_strided(gl_info, &strided->position, &stream_info->elements[WINED3D_FFP_POSITION]);
stream_info_element_from_strided(gl_info, &strided->normal, &stream_info->elements[WINED3D_FFP_NORMAL]);
stream_info_element_from_strided(gl_info, &strided->diffuse, &stream_info->elements[WINED3D_FFP_DIFFUSE]);
stream_info_element_from_strided(gl_info, &strided->specular, &stream_info->elements[WINED3D_FFP_SPECULAR]);
for (i = 0; i < WINED3DDP_MAXTEXCOORD; ++i)
{
}
{
{
}
}
}
{
TRACE("Strided Data:\n");
}
/* Context activation is done by the caller. */
{
if (device->up_strided)
{
/* Note: this is a ddraw fixed-function code path. */
TRACE("=============================== Strided Input ================================\n");
}
else
{
TRACE("============================= Vertex Declaration =============================\n");
}
{
{
TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n");
}
else
{
}
}
else
{
{
}
else
{
}
}
}
{
enum WINED3DSRGB srgb;
}
{
unsigned int i;
if (use_vs(stateblock))
{
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
{
}
}
if (use_ps(stateblock))
{
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{
}
}
else
{
{
if (ffu_map & 1)
}
}
}
{
struct wined3d_context **new_array;
else new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, sizeof(*new_array) * (device->numContexts + 1));
if (!new_array)
{
ERR("Failed to grow the context array.\n");
return FALSE;
}
return TRUE;
}
{
struct wined3d_context **new_array;
UINT i;
for (i = 0; i < device->numContexts; ++i)
{
{
break;
}
}
if (!found)
{
return;
}
if (!--device->numContexts)
{
return;
}
memmove(&device->contexts[i], &device->contexts[i + 1], (device->numContexts - i) * sizeof(*device->contexts));
new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, device->numContexts * sizeof(*device->contexts));
if (!new_array)
{
ERR("Failed to shrink context array. Oh well.\n");
return;
}
}
/**********************************************************
* IUnknown parts follows
**********************************************************/
static HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface,REFIID riid,LPVOID *ppobj)
{
return S_OK;
}
return E_NOINTERFACE;
}
return refCount;
}
if (!refCount) {
UINT i;
}
/* TODO: Clean up all the surfaces and textures! */
/* NOTE: You must release the parent if the object was created via a callback
** ***************************/
{
{
FIXME("Leftover resource %p with type %s (%#x).\n",
}
}
}
return refCount;
}
/**********************************************************
* IWineD3DDevice implementation follows
**********************************************************/
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, struct wined3d_buffer_desc *desc,
const void *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops, IWineD3DBuffer **buffer)
{
struct wined3d_buffer *object;
if (!object)
{
ERR("Failed to allocate memory\n");
return E_OUTOFMEMORY;
}
FIXME("Ignoring access flags (pool)\n");
{
return hr;
}
return WINED3D_OK;
}
{
struct wined3d_buffer *object;
TRACE("iface %p, size %u, usage %#x, pool %#x, buffer %p, parent %p, parent_ops %p.\n",
if (Pool == WINED3DPOOL_SCRATCH)
{
/* The d3d9 testsuit shows that this is not allowed. It doesn't make much sense
* anyway, SCRATCH vertex buffers aren't usable anywhere
*/
WARN("Vertex buffer in D3DPOOL_SCRATCH requested, returning WINED3DERR_INVALIDCALL\n");
*ppVertexBuffer = NULL;
return WINED3DERR_INVALIDCALL;
}
if (!object)
{
ERR("Out of memory\n");
*ppVertexBuffer = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
{
struct wined3d_buffer *object;
/* Allocate the storage for the device */
if (!object)
{
ERR("Out of memory\n");
*ppIndexBuffer = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
parent, parent_ops);
{
return hr;
}
return WINED3D_OK;
}
{
if(!object)
{
ERR("Failed to allocate stateblock memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height,
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
#endif
)
{
TRACE("iface %p, width %u, height %u, format %s (%#x), lockable %#x, discard %#x, level %u\n",
TRACE("surface %p, usage %s (%#x), pool %s (%#x), multisample_type %#x, multisample_quality %u\n",
ppSurface, debug_d3dusage(Usage), Usage, debug_d3dpool(Pool), Pool, MultiSample, MultisampleQuality);
{
ERR("OpenGL surfaces are not available without OpenGL.\n");
return WINED3DERR_NOTAVAILABLE;
}
if (!object)
{
ERR("Failed to allocate surface memory.\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
#ifdef VBOX_WITH_WDDM
#endif
);
{
return hr;
}
return hr;
}
{
struct wined3d_rendertarget_view *object;
TRACE("iface %p, resource %p, parent %p, rendertarget_view %p.\n",
if (!object)
{
ERR("Failed to allocate memory\n");
return E_OUTOFMEMORY;
}
return WINED3D_OK;
}
#ifdef VBOX_WITH_WDDM
, void **pavClientMem
#endif
)
{
TRACE("Format %#x (%s), Pool %#x, ppTexture %p, parent %p\n",
if (!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
#ifdef VBOX_WITH_WDDM
#endif
);
{
return hr;
}
return WINED3D_OK;
}
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool,
IWineD3DVolumeTexture **ppVolumeTexture, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
{
if (!object)
{
ERR("Out of memory\n");
*ppVolumeTexture = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = volumetexture_init(object, Width, Height, Depth, Levels, This, Usage, Format, Pool, parent, parent_ops);
{
*ppVolumeTexture = NULL;
return hr;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface, UINT Width, UINT Height,
{
if (!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength, UINT Levels,
#ifdef VBOX_WITH_WDDM
, void **pavClientMem
#endif
)
{
if (!object)
{
ERR("Out of memory\n");
*ppCubeTexture = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
#ifdef VBOX_WITH_WDDM
#endif
);
{
*ppCubeTexture = NULL;
return hr;
}
return WINED3D_OK;
}
{
if (!object)
{
ERR("Failed to allocate query memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
{
TRACE("iface %p, present_parameters %p, swapchain %p, parent %p, surface_type %#x.\n",
if (!object)
{
ERR("Failed to allocate swapchain memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
/** NOTE: These are ahead of the other getters and setters to save using a forward declaration **/
return This->NumberOfSwapChains;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, UINT iSwapChain, IWineD3DSwapChain **pSwapChain) {
return WINED3D_OK;
} else {
TRACE("Swapchain out of range\n");
*pSwapChain = NULL;
return WINED3DERR_INVALIDCALL;
}
}
IWineD3DVertexDeclaration **declaration, IUnknown *parent, const struct wined3d_parent_ops *parent_ops,
{
TRACE("iface %p, declaration %p, parent %p, elements %p, element_count %u.\n",
if(!object)
{
ERR("Failed to allocate vertex declaration memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
struct wined3d_fvf_convert_state
{
const struct wined3d_gl_info *gl_info;
};
{
const struct wined3d_format_desc *format_desc;
}
static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the GL info, which has the type table */
{
(fvf & WINED3DFVF_LASTBETA_D3DCOLOR) ||
struct wined3d_fvf_convert_state state;
unsigned int size;
unsigned int idx;
if (has_blend_idx) num_blends--;
/* Compute declaration size */
if (has_pos)
{
else
}
if (has_blend && (num_blends > 0))
{
else
{
switch (num_blends)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
}
}
}
if (has_blend_idx)
{
if ((fvf & WINED3DFVF_LASTBETA_UBYTE4)
else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
else
}
if (has_normal) append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_NORMAL, 0);
if (has_specular) append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_COLOR, 1);
{
{
break;
break;
break;
break;
}
}
return size;
}
{
unsigned int size;
if (size == ~0U) return E_OUTOFMEMORY;
hr = IWineD3DDevice_CreateVertexDeclaration(iface, declaration, parent, parent_ops, elements, size);
return hr;
}
const struct wined3d_parent_ops *parent_ops)
{
if (!object)
{
ERR("Failed to allocate shader memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
const struct wined3d_parent_ops *parent_ops)
{
struct wined3d_geometryshader *object;
if (!object)
{
ERR("Failed to allocate shader memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
const struct wined3d_parent_ops *parent_ops)
{
if (!object)
{
ERR("Failed to allocate shader memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
{
TRACE("iface %p, flags %#x, entries %p, palette %p, parent %p.\n",
if (!object)
{
ERR("Failed to allocate palette memory.\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
if(hbm)
{
}
else
{
/* Create a 32x32 white surface to indicate that wined3d is used, but the specified image
* couldn't be loaded
*/
}
#ifdef VBOX_WITH_WDDM
hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *)This, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
#else
hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *)This, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
#endif
ERR("Wine logo requested, but failed to create surface\n");
goto out;
}
if(dcb) {
} else {
/* Fill the surface with a white color to show that wined3d is there */
}
out:
}
/* Context activation is done by the caller. */
{
unsigned int i;
/* Under DirectX you can have texture stage operations even if no texture is
bound, whereas opengl will only do texture operations when a valid texture is
bound. We emulate this by creating dummy textures and binding them to each
texture stage, but disable all stages by default. Hence if a stage is enabled
then the default texture will kick in until replaced by a SetTexture call */
ENTER_GL();
{
/* The dummy texture does not have client storage backing */
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
{
/* Make appropriate texture active */
checkGLcall("glActiveTextureARB");
/* Generate an opengl texture name */
checkGLcall("glGenTextures");
/* Generate a dummy 2d texture (not using 1d because they cause many
* DRI drivers fall back to sw) */
checkGLcall("glBindTexture");
checkGLcall("glTexImage2D");
}
{
/* Reenable because if supported it is enabled by default */
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
LEAVE_GL();
}
/* Context activation is done by the caller. */
static void destroy_dummy_textures(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info)
{
ENTER_GL();
checkGLcall("glDeleteTextures(gl_info->limits.textures, device->dummyTextureName)");
LEAVE_GL();
}
{
#ifndef VBOX_WITH_WDDM
{
return E_FAIL;
}
#else
ERR("should not be here");
#endif
return WINED3D_OK;
}
{
#ifndef VBOX_WITH_WDDM
#else
ERR("should not be here");
#endif
}
{
struct wined3d_context *context;
unsigned int i;
/* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
NULL);
WARN("Failed to create stateblock\n");
goto err_out;
}
ERR("Out of memory!\n");
hr = E_OUTOFMEMORY;
goto err_out;
}
ERR("Out of memory!\n");
hr = E_OUTOFMEMORY;
goto err_out;
}
for (i = 0; i < 256; ++i) {
}
This->currentPalette = 0;
/* Initialize the texture unit mapping to a 1:1 mapping */
{
{
} else {
}
}
/* Setup the implicit swapchain. This also initializes a context. */
TRACE("Creating implicit swapchain\n");
{
WARN("Failed to create implicit swapchain\n");
goto err_out;
}
This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
if(!This->swapchains) {
ERR("Out of memory!\n");
goto err_out;
}
}
else {
}
/* Depth Stencil support */
}
TRACE("Shader private data couldn't be allocated\n");
goto err_out;
}
TRACE("Fragment pipeline private data couldn't be allocated\n");
goto err_out;
}
TRACE("Blitter private data couldn't be allocated\n");
goto err_out;
}
/* Set up some starting GL setup */
/* Setup all the devices defaults */
ENTER_GL();
/* Initialize the current view state */
checkGLcall("glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights)");
switch(wined3d_settings.offscreen_rendering_mode) {
case ORM_FBO:
break;
case ORM_BACKBUFFER:
{
if (context_get_current()->aux_buffers > 0)
{
TRACE("Using auxilliary buffer for offscreen rendering\n");
} else {
TRACE("Using back buffer for offscreen rendering\n");
}
}
}
LEAVE_GL();
/* Clear the screen */
WINED3DCLEAR_TARGET | pPresentationParameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0,
0x00, 1.0f, 0);
if(wined3d_settings.logo) {
}
This->highest_dirty_ps_const = 0;
This->highest_dirty_vs_const = 0;
return WINED3D_OK;
This->NumberOfSwapChains = 0;
}
This->NumberOfPalettes = 0;
if(swapchain) {
}
if(This->stateBlock) {
}
}
if (This->fragment_priv) {
}
if (This->shader_priv) {
}
return hr;
}
{
/* Setup the implicit swapchain */
TRACE("Creating implicit swapchain\n");
{
WARN("Failed to create implicit swapchain\n");
goto err_out;
}
This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
if(!This->swapchains) {
ERR("Out of memory!\n");
goto err_out;
}
return WINED3D_OK;
return hr;
}
{
return WINED3D_OK;
}
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
int sampler;
UINT i;
/* I don't think that the interface guarantees that the device is destroyed from the same thread
* it was created. Thus make sure a context is active for the glDelete* calls
*/
/* Unload resources */
TRACE("Deleting high order patches\n");
for(i = 0; i < PATCHMAP_SIZE; i++) {
struct WineD3DRectPatch *patch;
}
}
/* Delete the mouse cursor texture */
if(This->cursorTexture) {
ENTER_GL();
LEAVE_GL();
This->cursorTexture = 0;
}
}
}
/* Destroy the depth blt resources, they will be invalid after the reset. Also free shader
* private data, it might contain opengl pointers
*/
if(This->depth_blt_texture) {
ENTER_GL();
LEAVE_GL();
This->depth_blt_texture = 0;
}
if (This->depth_blt_rb) {
ENTER_GL();
LEAVE_GL();
This->depth_blt_rb = 0;
This->depth_blt_rb_w = 0;
This->depth_blt_rb_h = 0;
}
/* Release the update stateblock */
}
{ /* because were not doing proper internal refcounts releasing the primary state block
causes recursion with the extra checks in ResourceReleased, to avoid this we have
to set this->stateBlock = NULL; first */
/* Release the stateblock */
if(IWineD3DStateBlock_Release(stateBlock) > 0){
}
}
/* Destroy the shader backend. Note that this has to happen after all shaders are destroyed. */
/* Release the buffers (with sanity checks)*/
}
TRACE("Setting rendertarget to NULL\n");
if (This->auto_depth_stencil_buffer) {
{
}
}
for(i=0; i < This->NumberOfSwapChains; i++) {
TRACE("Releasing the implicit swapchain %d\n", i);
}
}
This->NumberOfSwapChains = 0;
This->NumberOfPalettes = 0;
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface, D3DCB_DESTROYSWAPCHAINFN D3DCB_DestroySwapChain) {
unsigned int i;
for(i=0; i < This->NumberOfSwapChains; i++) {
TRACE("Releasing the implicit swapchain %d\n", i);
}
}
This->NumberOfSwapChains = 0;
return WINED3D_OK;
}
/* Enables thread safety in the wined3d device and its resources. Called by DirectDraw
* from SetCooperativeLevel if DDSCL_MULTITHREADED is specified, and by d3d8/9 from
* CreateDevice if D3DCREATE_MULTITHREADED is passed.
*
* There is no way to deactivate thread safety once it is enabled.
*/
/*For now just store the flag(needed in case of ddraw) */
}
const WINED3DDISPLAYMODE* pMode) {
const struct wined3d_format_desc *format_desc = getFormatDescEntry(pMode->Format, &This->adapter->gl_info);
TRACE("(%p)->(%d,%p) Mode=%dx%dx@%d, %s\n", This, iSwapChain, pMode, pMode->Width, pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
/* Resize the screen even without a window:
* The app could have unset it with SetCooperativeLevel, but not called
* RestoreDisplayMode first. Then the release will call RestoreDisplayMode,
* but we don't have any hwnd
*/
if (pMode->RefreshRate != 0) {
}
/* Only change the mode if necessary */
(pMode->RefreshRate == 0) ) {
return WINED3D_OK;
}
if (ret != DISP_CHANGE_SUCCESSFUL) {
if(devmode.dmDisplayFrequency != 0) {
WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate\n");
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL;
}
if(ret != DISP_CHANGE_SUCCESSFUL) {
return WINED3DERR_NOTAVAILABLE;
}
}
/* Store the new values */
/* And finally clip mouse to our screen */
return WINED3D_OK;
}
return WINED3D_OK;
}
#ifndef VBOX_WITH_WDDM
/* return simulated texture memory left */
#else
ERR("Should not be here!");
return 0;
#endif
}
/*****
* Get / Set Stream Source
*****/
{
if (StreamNumber >= MAX_STREAMS) {
return WINED3DERR_INVALIDCALL;
} else if(OffsetInBytes & 0x3) {
return WINED3DERR_INVALIDCALL;
}
TRACE("(%p) : StreamNo: %u, OldStream (%p), NewStream (%p), OffsetInBytes %u, NewStride %u\n", This, StreamNumber, oldSrc, pStreamData, OffsetInBytes, Stride);
if(oldSrc == pStreamData &&
TRACE("Application is setting the old values over, nothing to do\n");
return WINED3D_OK;
}
if (pStreamData) {
}
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
if (pStreamData != NULL) {
}
}
return WINED3D_OK;
}
{
if (StreamNumber >= MAX_STREAMS) {
return WINED3DERR_INVALIDCALL;
}
if (pOffset) {
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSourceFreq(IWineD3DDevice *iface, UINT StreamNumber, UINT Divider) {
/* Verify input at least in d3d9 this is invalid*/
WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
if( Divider == 0 ){
WARN("Divider is 0, returning D3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
This->updateStateBlock->streamFlags[StreamNumber] = Divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA );
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSourceFreq(IWineD3DDevice *iface, UINT StreamNumber, UINT* Divider) {
*Divider = This->updateStateBlock->streamFreq[StreamNumber] | This->updateStateBlock->streamFlags[StreamNumber];
return WINED3D_OK;
}
/*****
* Get / Set & Multiply Transform
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE d3dts, CONST WINED3DMATRIX* lpmatrix) {
/* Most of this routine, comments included copied from ddraw tree initially: */
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
/*
* If the new matrix is the same as the current one,
* we cut off any further processing. this seems to be a reasonable
* optimization because as was noticed, some apps (warcraft3 for example)
* tend towards setting the same matrix repeatedly for some reason.
*
* From here on we assume that the new matrix is different, wherever it matters.
*/
TRACE("The app is setting the same matrix over again\n");
return WINED3D_OK;
} else {
}
/*
ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
where ViewMat = Camera space, WorldMat = world space.
In OpenGL, camera and world space is combined into GL_MODELVIEW
matrix. The Projection matrix stay projection matrix.
*/
/* Capture the times we can just ignore the change for now */
/* Handled by the state manager */
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, WINED3DMATRIX* pMatrix) {
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, CONST WINED3DMATRIX* pMatrix) {
/* Note: Using 'updateStateBlock' rather than 'stateblock' in the code
* below means it will be recorded in a state block change, but it
* works regardless where it is recorded.
* If this is found to be wrong, change to StateBlock.
*/
if (State <= HIGHEST_TRANSFORMSTATE)
{
} else {
FIXME("Unhandled transform state!!\n");
}
/* Apply change via set transform - will reapply to eg. lights this way */
}
/*****
* Get / Set Light
*****/
/* Note lights are real special cases. Although the device caps state only eg. 8 are supported,
you can reference any indexes you want as long as that number max are enabled at any
one point in time! Therefore since the indexes can be anything, we need a hashmap of them.
However, this causes stateblock problems. When capturing the state block, I duplicate the hashmap,
but when recording, just build a chain pretty much of commands to be replayed. */
static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD Index, CONST WINED3DLIGHT* pLight) {
float rho;
struct list *e;
/* Check the parameter range. Need for speed most wanted sets junk lights which confuse
* the gl driver.
*/
if(!pLight) {
WARN("Light pointer = NULL, returning WINED3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
case WINED3DLIGHT_POINT:
case WINED3DLIGHT_SPOT:
case WINED3DLIGHT_GLSPOT:
/* Incorrect attenuation values can cause the gl driver to crash. Happens with Need for speed
* most wanted
*/
{
WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
break;
case WINED3DLIGHT_DIRECTIONAL:
/* Ignores attenuation */
break;
default:
WARN("Light type out of range, returning WINED3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
{
}
if(!object) {
TRACE("Adding new light\n");
if(!object) {
ERR("Out of memory error when allocating a light\n");
return E_OUTOFMEMORY;
}
}
/* Initialize the object */
TRACE("Light %d setting to type %d, Diffuse(%f,%f,%f,%f), Specular(%f,%f,%f,%f), Ambient(%f,%f,%f,%f)\n", Index, pLight->Type,
TRACE("... Pos(%f,%f,%f), Dirn(%f,%f,%f)\n", pLight->Position.x, pLight->Position.y, pLight->Position.z,
TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n", pLight->Range, pLight->Falloff, pLight->Theta, pLight->Phi);
/* Save away the information */
case WINED3DLIGHT_POINT:
/* Position */
/* FIXME: Range */
break;
case WINED3DLIGHT_DIRECTIONAL:
/* Direction */
break;
case WINED3DLIGHT_SPOT:
/* Position */
/* Direction */
/*
* opengl-ish and d3d-ish spot lights use too different models for the
* light "intensity" as a function of the angle towards the main light direction,
* so we only can approximate very roughly.
* however spot lights are rather rarely used in games (if ever used at all).
* furthermore if still used, probably nobody pays attention to such details.
*/
/* Falloff = 0 is easy, because d3d's and opengl's spot light equations have the
* falloff resp. exponent parameter as an exponent, so the spot light lighting
* will always be 1.0 for both of them, and we don't have to care for the
* rest of the rather complex calculation
*/
} else {
}
{
}
/* FIXME: Range */
break;
default:
}
/* Update the live definitions if the light is currently assigned a glIndex */
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD Index, WINED3DLIGHT *pLight)
{
struct list *e;
{
}
TRACE("Light information requested but light not defined\n");
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
/*****
* Get / Set Light Enable
* (Note for consistency, renamed d3dx function by adding the 'set' prefix)
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, DWORD Index, BOOL Enable)
{
struct list *e;
{
}
/* Special case - enabling an undefined light creates one with a strict set of parms! */
TRACE("Light enabled requested but light not defined, so defining one!\n");
/* Search for it again! Should be fairly quick as near head of list */
{
}
FIXME("Adding default lights has failed dismally\n");
return WINED3DERR_INVALIDCALL;
}
}
if(!Enable) {
if(!This->isRecordingState) {
}
} else {
TRACE("Light already disabled, nothing to do\n");
}
} else {
/* nop */
TRACE("Nothing to do as light was enabled\n");
} else {
int i;
/* Find a free gl light */
for(i = 0; i < This->maxConcurrentLights; i++) {
break;
}
}
/* Our tests show that Windows returns D3D_OK in this situation, even with
* D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices. This
* is consistent among ddraw, d3d8 and d3d9. GetLightEnable returns TRUE
* as well for those lights.
*
* TODO: Test how this affects rendering
*/
WARN("Too many concurrently active lights\n");
return WINED3D_OK;
}
/* i == lightInfo->glIndex */
if(!This->isRecordingState) {
}
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetLightEnable(IWineD3DDevice *iface, DWORD Index,BOOL* pEnable)
{
struct list *e;
{
}
TRACE("Light enabled state requested but light not defined\n");
return WINED3DERR_INVALIDCALL;
}
/* true is 128 according to SetLightEnable */
return WINED3D_OK;
}
/*****
* Get / Set Clip Planes
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetClipPlane(IWineD3DDevice *iface, DWORD Index, CONST float *pPlane) {
/* Validate Index */
{
TRACE("Application has requested clipplane this device doesn't support\n");
return WINED3DERR_INVALIDCALL;
}
TRACE("Application is setting old values over, nothing to do\n");
return WINED3D_OK;
}
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetClipPlane(IWineD3DDevice *iface, DWORD Index, float *pPlane) {
/* Validate Index */
{
TRACE("Application has requested clipplane this device doesn't support\n");
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
/*****
* Get / Set Clip Plane Status
* WARNING: This code relies on the fact that D3DCLIPSTATUS8 == D3DCLIPSTATUS9
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetClipStatus(IWineD3DDevice *iface, CONST WINED3DCLIPSTATUS* pClipStatus) {
if (NULL == pClipStatus) {
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, WINED3DCLIPSTATUS* pClipStatus) {
if (NULL == pClipStatus) {
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
/*****
* Get / Set Material
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONST WINED3DMATERIAL* pMaterial) {
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL* pMaterial) {
return WINED3D_OK;
}
/*****
* Get / Set Indices
*****/
{
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
if(oldIdxs != pIndexData) {
if(pIndexData) {
}
if(oldIdxs) {
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetIndexBuffer(IWineD3DDevice *iface, IWineD3DBuffer **ppIndexData)
{
/* up ref count on ppindexdata */
if (*ppIndexData) {
}else{
}
return WINED3D_OK;
}
/* Method to offer d3d9 a simple way to set the base vertex index without messing with the index buffer */
TRACE("Application is setting the old value over, nothing to do\n");
return WINED3D_OK;
}
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
/* The base vertex index affects the stream sources */
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetBaseVertexIndex(IWineD3DDevice *iface, INT* base_index) {
return WINED3D_OK;
}
/*****
* Get / Set Viewports
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetViewport(IWineD3DDevice *iface, CONST WINED3DVIEWPORT* pViewport) {
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetViewport(IWineD3DDevice *iface, WINED3DVIEWPORT* pViewport) {
return WINED3D_OK;
}
/*****
* Get / Set Render States
* TODO: Verify against dx9 definitions
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, WINED3DRENDERSTATETYPE State, DWORD Value) {
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
/* Compared here and not before the assignment to allow proper stateblock recording */
TRACE("Application is setting the old value over, nothing to do\n");
} else {
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderState(IWineD3DDevice *iface, WINED3DRENDERSTATETYPE State, DWORD *pValue) {
return WINED3D_OK;
}
/*****
* Get / Set Sampler States
* TODO: Verify against dx9 definitions
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD Value) {
TRACE("(%p) : Sampler %#x, Type %s (%#x), Value %#x\n",
}
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
/**
* SetSampler is designed to allow for more than the standard up to 8 textures
* and Geforce has stopped supporting more than 6 standard textures in openGL.
* So I have to use ARB for Gforce. (maybe if the sampler > 4 then use ARB?)
*
*
* There are two new settings for GForce
* the sampler one:
* GL_MAX_TEXTURE_IMAGE_UNITS_ARB
* and the texture one:
* GL_MAX_TEXTURE_COORDS_ARB.
* Ok GForce say it's ok to use glTexParameter/glGetTexParameter(...).
******************/
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
TRACE("Application is setting the old value over, nothing to do\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD* Value) {
TRACE("(%p) : Sampler %#x, Type %s (%#x)\n",
}
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
return WINED3D_OK;
}
TRACE("App is setting the old scissor rectangle over, nothing to do\n");
return WINED3D_OK;
}
if(This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
TRACE("(%p)Returning a Scissor Rect of %d:%d-%d:%d\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
/* Checked after the assignment to allow proper stateblock recording */
TRACE("Application is setting the old declaration over, nothing to do\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppDecl) {
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface, IWineD3DVertexShader* pShader) {
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
/* Checked here to allow proper stateblock recording */
TRACE("App is setting the old shader over, nothing to do\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShader(IWineD3DDevice *iface, IWineD3DVertexShader** ppShader) {
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
TRACE("(iface %p, srcData %p, start %d, count %d)\n",
{
ERR("incorrect vertex shader const data: start(%u), srcData(0x%p), count(%u)", start, srcData, count);
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
{
ERR("incorrect vertex shader const data: start(%u), dstData(0x%p), count(%u)", start, dstData, count);
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
TRACE("(iface %p, srcData %p, start %d, count %d)\n",
{
ERR("incorrect vertex shader const data: start(%u), srcData(0x%p), count(%u)", start, srcData, count);
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
int *dstData,
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
{
ERR("incorrect vertex shader const data: start(%u), dstData(0x%p), count(%u)", start, dstData, count);
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
UINT i;
TRACE("(iface %p, srcData %p, start %d, count %d)\n",
/* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */
if (srcData == NULL || start + count > This->d3d_vshader_constantF || start > This->d3d_vshader_constantF)
{
ERR("incorrect vertex shader const data: start(%u), srcData(0x%p), count(%u)", start, srcData, count);
return WINED3DERR_INVALIDCALL;
}
memcpy(&This->updateStateBlock->vertexShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
for (i = 0; i < count; i++)
}
if (!This->isRecordingState)
{
}
return WINED3D_OK;
}
float *dstData,
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
{
ERR("incorrect vertex shader const data: start(%u), dstData(0x%p), count(%u)", start, dstData, count);
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
DWORD i;
for(i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i)
{
}
}
{
if (i != WINED3D_UNMAPPED_STAGE && i != stage)
{
}
if (j != WINED3D_UNMAPPED_STAGE && j != unit)
{
}
}
int i;
This->fixed_function_usage_map = 0;
for (i = 0; i < MAX_TEXTURES; ++i) {
if (color_op == WINED3DTOP_DISABLE) {
/* Not used, and disable higher stages */
break;
}
|| ((color_arg3 == WINED3DTA_TEXTURE) && (color_op == WINED3DTOP_MULTIPLYADD || color_op == WINED3DTOP_LERP))
|| ((alpha_arg3 == WINED3DTA_TEXTURE) && (alpha_op == WINED3DTOP_MULTIPLYADD || alpha_op == WINED3DTOP_LERP))) {
}
if ((color_op == WINED3DTOP_BUMPENVMAP || color_op == WINED3DTOP_BUMPENVMAPLUMINANCE) && i < MAX_TEXTURES - 1) {
}
}
}
static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
{
unsigned int i, tex;
{
{
if (!(ffu_map & 1)) continue;
if (This->texUnitMap[i] != i) {
device_map_stage(This, i, i);
}
}
return;
}
/* Now work out the mapping */
tex = 0;
{
if (!(ffu_map & 1)) continue;
}
++tex;
}
}
{
const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type =
unsigned int i;
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
{
device_map_stage(This, i, i);
{
}
}
}
}
{
/* Not currently used */
if (current_mapping < MAX_FRAGMENT_SAMPLERS) {
/* Used by a fragment sampler */
if (!pshader_sampler_tokens) {
/* No pixel shader, check fixed function */
return current_mapping >= MAX_TEXTURES || !(This->fixed_function_usage_map & (1 << current_mapping));
}
/* Pixel shader, check the shader's sampler map */
return !pshader_sampler_tokens[current_mapping];
}
/* Used by a vertex sampler */
}
static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct wined3d_gl_info *gl_info)
{
int i;
if (ps) {
/* Note that we only care if a sampler is sampled or not, not the sampler's specific type.
* Otherwise we'd need to call shader_update_samplers() here for 1.x pixelshaders. */
}
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
if (vshader_sampler_type[i])
{
{
/* Already mapped somewhere */
continue;
}
while (start >= 0) {
{
--start;
break;
}
--start;
}
}
}
}
{
/*
* Rules are:
* -> Pixel shaders need a 1:1 map. In theory the shader input could be mapped too, but
* that would be really messy and require shader recompilation
* -> When the mapping of a stage is changed, sampler and ALL texture stage states have
* to be reset. Because of that try to work with a 1:1 mapping as much as possible
*/
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader) {
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
}
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
TRACE("App is setting the old pixel shader over, nothing to do\n");
return WINED3D_OK;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader **ppShader) {
return WINED3DERR_INVALIDCALL;
}
}
return WINED3D_OK;
}
TRACE("(iface %p, srcData %p, start %u, count %u)\n",
{
ERR("incorrect pixel shader const data: start(%u), srcData(0x%p), count(%u)", start, srcData, count);
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
{
ERR("incorrect pixel shader const data: start(%u), dstData(0x%p), count(%u)", start, dstData, count);
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
TRACE("(iface %p, srcData %p, start %u, count %u)\n",
{
ERR("incorrect pixel shader const data: start(%u), srcData(0x%p), count(%u)", start, srcData, count);
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
int *dstData,
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
{
ERR("incorrect pixel shader const data: start(%u), dstData(0x%p), count(%u)", start, dstData, count);
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
UINT i;
TRACE("(iface %p, srcData %p, start %d, count %d)\n",
/* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */
if (srcData == NULL || start + count > This->d3d_pshader_constantF || start > This->d3d_pshader_constantF)
{
ERR("incorrect pixel shader const data: start(%u), srcData(0x%p), count(%u)", start, srcData, count);
return WINED3DERR_INVALIDCALL;
}
memcpy(&This->updateStateBlock->pixelShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
for (i = 0; i < count; i++)
}
if (!This->isRecordingState)
{
}
return WINED3D_OK;
}
float *dstData,
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
{
ERR("incorrect pixel shader const data: start(%u), dstData(0x%p), count(%u)", start, dstData, count);
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
/* Context activation is done by the caller. */
{
unsigned int i;
{
WARN(" lighting state not saved yet... Some strange stuff may happen !\n");
}
{
ERR("Source has no position mask\n");
return WINED3DERR_INVALIDCALL;
}
/* We might access VBOs from this code, so hold the lock */
ENTER_GL();
}
/* Get a pointer into the destination vbo(create one if none exists) and
* write correct opengl data into it. It's cheap and allows us to run drawStridedFast
*/
{
}
if (dest->buffer_object)
{
unsigned char extrabytes = 0;
/* If the destination vertex buffer has D3DFVF_XYZ position(non-rhw), native d3d writes RHW position, where the RHW
* gets written into the 4 bytes after the Z position. In the case of a dest buffer that only has D3DFVF_XYZ data,
* this may write 4 extra bytes beyond the area that should be written
*/
dest_conv_addr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwCount * get_flexible_vertex_size(DestFVF) + extrabytes);
if(!dest_conv_addr) {
ERR("Out of memory\n");
/* Continue without storing converted vertices */
}
}
/* Should I clip?
* a) WINED3DRS_CLIPPING is enabled
* b) WINED3DVOP_CLIP is passed
*/
/*
* The clipping code is not quite correct. Some things need
* to be checked against IDirect3DDevice3 (!), d3d8 and d3d9,
* so disable clipping for now.
* (The graphics in Half-Life are broken, and my processvertices
* test crashes with IDirect3DDevice3)
doClip = TRUE;
*/
if(!warned) {
FIXME("Clipping is broken and disabled for now\n");
}
&view_mat);
&proj_mat);
&world_mat);
TRACE("View mat:\n");
TRACE("Proj mat:\n");
TRACE("World mat:\n");
/* Get the viewport */
TRACE("Viewport: X=%d, Y=%d, Width=%d, Height=%d, MinZ=%f, MaxZ=%f\n",
for (i = 0; i < dwCount; i+= 1) {
unsigned int tex_index;
/* The position first */
float x, y, z, rhw;
/* Multiplication with world, view and projection matrix */
/* WARNING: The following things are taken from d3d7 and were not yet checked
* against d3d8 or d3d9!
*/
/* Clipping conditions: From msdn
*
* A vertex is clipped if it does not match the following requirements
* -rhw < x <= rhw
* -rhw < y <= rhw
* 0 < z <= rhw
* 0 < rhw ( Not in d3d7, but tested in d3d7)
*
* If clipping is on is determined by the D3DVOP_CLIP flag in D3D7, and
* by the D3DRS_CLIPPING in D3D9(according to the msdn, not checked)
*
*/
if( !doClip ||
/* "Normal" viewport transformation (not clipped)
* 1) The values are divided by rhw
* 2) The y axis is negative, so multiply it with -1
* 3) Screen coordinates go from -(Width/2) to +(Width/2) and
* -(Height/2) to +(Height/2). The z range is MinZ to MaxZ
* 4) Multiply x with Width/2 and add Width/2
* 5) The same for the height
* 6) Add the viewpoint X and Y to the 2D coordinates and
* The minimum Z value to z
* 7) rhw = 1 / rhw Reciprocal of Homogeneous W....
*
* Well, basically it's simply a linear transformation into viewport
* coordinates
*/
x /= rhw;
y /= rhw;
z /= rhw;
y *= -1;
} else {
/* That vertex got clipped
* Contrary to OpenGL it is not dropped completely, it just
* undergoes a different calculation.
*/
TRACE("Vertex got clipped\n");
x += rhw;
y += rhw;
x /= 2;
y /= 2;
/* Msdn mentions that Direct3D9 keeps a list of clipped vertices
* outside of the main vertex buffer memory. That needs some more
* investigation...
*/
}
( (float *) dest_ptr)[0] = x;
( (float *) dest_ptr)[1] = y;
( (float *) dest_ptr)[2] = z;
dest_ptr += 3 * sizeof(float);
dest_ptr += sizeof(float);
}
if(dest_conv) {
float w = 1 / rhw;
( (float *) dest_conv)[0] = x * w;
( (float *) dest_conv)[1] = y * w;
( (float *) dest_conv)[2] = z * w;
( (float *) dest_conv)[3] = w;
dest_conv += 3 * sizeof(float);
dest_conv += sizeof(float);
}
}
}
if (DestFVF & WINED3DFVF_PSIZE) {
}
if (DestFVF & WINED3DFVF_NORMAL) {
/* AFAIK this should go into the lighting information */
FIXME("Didn't expect the destination to have a normal\n");
if(dest_conv) {
}
}
if (DestFVF & WINED3DFVF_DIFFUSE) {
{
if(!warned) {
ERR("No diffuse color in source, but destination has one\n");
}
if(dest_conv) {
}
}
else {
if(dest_conv) {
}
}
}
if (DestFVF & WINED3DFVF_SPECULAR)
{
/* What's the color value in the feedback buffer? */
{
if(!warned) {
ERR("No specular color in source, but destination has one\n");
}
if(dest_conv) {
}
}
else {
if(dest_conv) {
}
}
}
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_TEXCOORD0 + tex_index];
{
ERR("No source texture, but destination requests one\n");
}
else {
if(dest_conv) {
copy_and_next(dest_conv, tex_coord, GET_TEXCOORD_SIZE_FROM_FVF(DestFVF, tex_index) * sizeof(float));
}
}
}
}
if(dest_conv) {
checkGLcall("glBindBufferARB(GL_ARRAY_BUFFER_ARB)");
checkGLcall("glBufferSubDataARB(GL_ARRAY_BUFFER_ARB)");
}
LEAVE_GL();
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, UINT SrcStartIndex, UINT DestIndex,
{
struct wined3d_stream_info stream_info;
struct wined3d_context *context;
TRACE("(%p)->(%d,%d,%d,%p,%p,%d\n", This, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
if(pVertexDecl) {
ERR("Output vertex declaration not implemented yet\n");
}
/* Need any context to write to the vbo. */
/* ProcessVertices reads from vertex buffers, which have to be assigned. DrawPrimitive and DrawPrimitiveUP
* control the streamIsUP flag, thus restore it afterwards.
*/
if(vbo || SrcStartIndex) {
unsigned int i;
/* ProcessVertices can't convert FROM a vbo, and vertex buffers used to source into ProcessVertices are
* unlikely to ever be used for drawing. Release vbos in those buffers and fix up the stream_info structure
*
* Also get the start index in, but only loop over all elements if there's something to add at all.
*/
{
struct wined3d_stream_info_element *e;
e = &stream_info.elements[i];
if (e->buffer_object)
{
e->buffer_object = 0;
ENTER_GL();
vb->buffer_object = 0;
LEAVE_GL();
}
}
}
return hr;
}
/*****
* Get / Set Texture Stage States
* TODO: Verify against dx9 definitions
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
{
WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n",
return WINED3D_OK;
}
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
/* Checked after the assignments to allow proper stateblock recording */
TRACE("App is setting the old value over, nothing to do\n");
return WINED3D_OK;
}
This->StateTable[STATE_TEXTURESTAGE(0, Type)].representative == STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP)) {
/* Colorop change above lowest disabled stage? That won't change anything in the gl setup
* Changes in other states are important on disabled stages too
*/
return WINED3D_OK;
}
if(Type == WINED3DTSS_COLOROP) {
unsigned int i;
/* Previously enabled stage disabled now. Make sure to dirtify all enabled stages above Stage,
* they have to be disabled
*
* The current stage is dirtified below.
*/
TRACE("Additionally dirtifying stage %u\n", i);
}
/* Previously disabled stage enabled. Stages above it may need enabling
* stage must be lowest_disabled_stage here, if it's bigger success is returned above,
* and stages below the lowest disabled stage can't be enabled(because they are enabled already).
*
* Again stage Stage doesn't need to be dirtified here, it is handled below.
*/
{
break;
}
TRACE("Additionally dirtifying stage %u due to enable\n", i);
}
TRACE("New lowest disabled: %u\n", i);
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
TRACE("(%p) : requesting Stage %d, Type %d getting %d\n", This, Stage, Type, This->updateStateBlock->textureState[Stage][Type]);
return WINED3D_OK;
}
/*****
* Get / Set Texture
*****/
{
/* Windows accepts overflowing this array... we do not. */
{
#ifdef DEBUG_misha
#else
#endif
return WINED3D_OK;
}
/* SetTexture isn't allowed on textures in WINED3DPOOL_SCRATCH */
{
WARN("Rejecting attempt to set scratch texture.\n");
return WINED3DERR_INVALIDCALL;
}
{
TRACE("App is setting the same texture again, nothing to do.\n");
return WINED3D_OK;
}
if (This->isRecordingState)
{
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
if (texture)
{
{
}
{
/* The source arguments for color and alpha ops have different
* meanings when a NULL texture is bound, so the COLOROP and
* ALPHAOP have to be dirtified. */
}
}
if (prev)
{
{
}
{
unsigned int i;
/* Search for other stages the texture is bound to. Shouldn't
* happen if applications bind textures to a single stage only. */
TRACE("Searching for other stages the texture is bound to.\n");
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
{
TRACE("Texture is also bound to stage %u.\n", i);
t->baseTexture.sampler = i;
break;
}
}
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture** ppTexture) {
}
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
if (*ppTexture)
return WINED3D_OK;
}
/*****
* Get Back Buffer
*****/
{
TRACE("iface %p, swapchain_idx %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
{
return hr;
}
{
return hr;
}
return WINED3D_OK;
}
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, WINED3DDISPLAYMODE* pMode) {
if(iSwapChain > 0) {
if (hr == WINED3D_OK) {
} else {
}
} else {
/* Don't read the real display mode,
but return the stored mode instead. X11 can't change the color
depth, and some apps are pretty angry if they SetDisplayMode from
24 to 16 bpp and find out that GetDisplayMode still returns 24 bpp
Also don't relay to the swapchain because with ddraw it's possible
that there isn't a swapchain at all */
pMode->RefreshRate = 0;
hr = WINED3D_OK;
}
return hr;
}
/*****
* Stateblock related functions
*****/
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IWineD3DStateBlock** ppStateBlock) {
if (!This->isRecordingState) {
*ppStateBlock = NULL;
return WINED3DERR_INVALIDCALL;
}
/* IWineD3DStateBlock_AddRef(*ppStateBlock); don't need to do this, since we should really just release UpdateStateBlock first */
return WINED3D_OK;
}
/*****
* Scene related functions
*****/
/* At the moment we have no need for any functionality at the beginning
of a scene */
TRACE("Already in Scene, returning WINED3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
{
struct wined3d_context *context;
TRACE("Not in scene, returning WINED3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
/* We only have to do this if we need to read the, swapbuffers performs a flush for us */
wglFlush();
/* No checkGLcall here to avoid locking the lock just for checking a call that hardly ever
* fails. */
return WINED3D_OK;
}
{
int i;
for(i = 0 ; i < swapchains ; i ++) {
}
return WINED3D_OK;
}
{
/* partial viewport*/
return FALSE;
/* partial scissor rect */
return FALSE;
/* partial clear rect */
return FALSE;
return TRUE;
}
/* Not called from the VTable (internal subroutine) */
HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
{
const RECT *scissor_rect = stateblock->renderState[WINED3DRS_SCISSORTESTENABLE] ? &stateblock->scissorRect : NULL;
GLbitfield glMask = 0;
unsigned int i;
struct wined3d_context *context;
/* When we're clearing parts of the drawable, make sure that the target surface is well up to date in the
* drawable. After the clear we'll mark the drawable up to date, so we have to make sure that this is true
* for the cleared parts, and the untouched parts.
*
* If we're clearing the whole target there is no need to copy it into the drawable, it will be overwritten
* anyway. If we're not clearing the color buffer we don't have to copy either since we're not going to set
* the drawable up to date. We have to check all settings that limit the clear area though. Do not bother
* checking all this if the dest surface is in the drawable anyway.
*/
{
}
{
{
ENTER_GL();
LEAVE_GL();
}
else
{
ENTER_GL();
LEAVE_GL();
}
}
{
WARN("Invalid context, skipping clear.\n");
return WINED3D_OK;
}
ENTER_GL();
/* Only set the values up once, as they are not changing */
if (Flags & WINED3DCLEAR_STENCIL)
{
{
}
glStencilMask(~0U);
checkGLcall("glClearStencil");
}
if (Flags & WINED3DCLEAR_ZBUFFER)
{
if (!(depth_stencil->Flags & location) && !is_full_clear(depth_stencil, vp, scissor_rect, clear_rect))
glClearDepth(Z);
checkGLcall("glClearDepth");
}
if (Flags & WINED3DCLEAR_TARGET)
{
checkGLcall("glClearColor");
}
}
if (context->render_offscreen)
{
} else {
}
checkGLcall("glScissor");
checkGLcall("glClear");
} else {
/* Now process each rect in turn */
for (i = 0; i < Count; i++) {
}
/* Tests show that rectangles where x1 > x2 or y1 > y2 are ignored silently.
* The rectangle is not cleared, no error is returned, but further rectanlges are
* still cleared if they are valid
*/
TRACE("Rectangle with negative dimensions, ignoring\n");
continue;
}
if (context->render_offscreen)
{
} else {
}
checkGLcall("glScissor");
checkGLcall("glClear");
}
}
if (Flags & WINED3DCLEAR_TARGET)
{
}
if (Flags & WINED3DCLEAR_ZBUFFER) {
/* Note that WINED3DCLEAR_ZBUFFER implies a depth stencil exists on the device */
}
LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Count, CONST WINED3DRECT* pRects,
WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
/* TODO: What about depth stencil buffers without stencil bits? */
return WINED3DERR_INVALIDCALL;
}
}
/*****
* Drawing functions
*****/
{
}
{
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UINT StartVertex, UINT vertex_count)
{
return WINED3DERR_INVALIDCALL;
}
/* The index buffer is not needed here, but restore it, otherwise it is hell to keep track of */
}
}
/* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */
drawPrimitive(iface, vertex_count, StartVertex /* start_idx */, 0 /* indxSize */, NULL /* indxData */);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface, UINT startIndex, UINT index_count)
{
if (!pIB) {
/* D3D9 returns D3DERR_INVALIDCALL when DrawIndexedPrimitive is called
* without an index buffer set. (The first time at least...)
* D3D8 simply dies, but I doubt it can do much harm to return
* D3DERR_INVALIDCALL there as well. */
return WINED3DERR_INVALIDCALL;
}
return WINED3DERR_INVALIDCALL;
}
}
idxStride = 2;
} else {
idxStride = 4;
}
}
return WINED3D_OK;
}
{
TRACE("(%p) : vertex count %u, pVtxData %p, stride %u\n",
return WINED3DERR_INVALIDCALL;
}
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */
/* TODO: Only mark dirty if drawing from a different UP address */
/* MSDN specifies stream zero settings must be set to NULL */
/* stream zero settings set to null at end, as per the msdn. No need to mark dirty here, the app has to set
* the new stream sources or use UP drawing again
*/
return WINED3D_OK;
}
{
int idxStride;
TRACE("(%p) : index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u.\n",
return WINED3DERR_INVALIDCALL;
}
if (IndexDataFormat == WINED3DFMT_R16_UINT) {
idxStride = 2;
} else {
idxStride = 4;
}
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */
/* Set to 0 as per msdn. Do it now due to the stream source loading during drawPrimitive */
/* Mark the state dirty until we have nicer tracking of the stream source pointers */
/* MSDN specifies stream zero settings and index buffer must be set to NULL */
if(ib) {
}
/* No need to mark the stream source state dirty here. Either the app calls UP drawing again, or it has to call
* SetStreamSource to specify a vertex buffer
*/
return WINED3D_OK;
}
{
/* Mark the state dirty until we have nicer tracking
* its fine to change baseVertexIndex because that call is only called by ddraw which does not need
* that value.
*/
return WINED3D_OK;
}
{
/* Mark the state dirty until we have nicer tracking
* its fine to change baseVertexIndex because that call is only called by ddraw which does not need
* that value.
*/
return WINED3D_OK;
}
/* This is a helper function for UpdateTexture, there is no UpdateVolume method in D3D. */
{
TRACE("iface %p, src_volume %p, dst_volume %p.\n",
/* TODO: Implement direct loading into the gl volume instead of using memcpy and
* dirtification to improve loading performance.
*/
return hr;
}
} else {
}
return hr;
}
{
unsigned int level_count, i;
/* Verify that the source and destination textures are non-NULL. */
if (!src_texture || !dst_texture)
{
WARN("Source and destination textures must be non-NULL, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (src_texture == dst_texture)
{
WARN("Source and destination are the same object, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
/* Verify that the source and destination textures are the same type. */
{
WARN("Source and destination have different types, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
/* Check that both textures have the identical numbers of levels. */
{
WARN("Source and destination have different level counts, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
/* Make sure that the destination texture is loaded. */
/* Update every surface level of the texture. */
switch (type)
{
case WINED3DRTYPE_TEXTURE:
{
for (i = 0; i < level_count; ++i)
{
{
return hr;
}
}
break;
}
case WINED3DRTYPE_CUBETEXTURE:
{
for (i = 0; i < level_count; ++i)
{
/* Update each cube face. */
{
face, i, &src_surface);
face, i, &dst_surface);
{
return hr;
}
}
}
break;
}
{
for (i = 0; i < level_count; ++i)
{
{
return hr;
}
}
break;
}
default:
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *iface,UINT iSwapChain, IWineD3DSurface *pDestSurface) {
if(hr == WINED3D_OK) {
}
return hr;
}
DWORD i;
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
WARN("Sampler state %u has minfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
}
WARN("Sampler state %u has magfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
}
WARN("Non-filterable texture and mag filter enabled on samper %u, returning E_FAIL\n", i);
return E_FAIL;
}
WARN("Non-filterable texture and min filter enabled on samper %u, returning E_FAIL\n", i);
return E_FAIL;
}
WARN("Non-filterable texture and mip filter enabled on samper %u, returning E_FAIL\n", i);
return E_FAIL;
}
}
/* return a sensible default */
*pNumPasses = 1;
TRACE("returning D3D_OK\n");
return WINED3D_OK;
}
{
int i;
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
{
}
}
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
int j;
if (PaletteNumber >= MAX_PALETTES) {
return WINED3DERR_INVALIDCALL;
}
do {
NewSize *= 2;
} while(PaletteNumber >= NewSize);
palettes = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->palettes, sizeof(PALETTEENTRY*) * NewSize);
if (!palettes) {
ERR("Out of memory!\n");
return E_OUTOFMEMORY;
}
}
ERR("Out of memory!\n");
return E_OUTOFMEMORY;
}
}
for (j = 0; j < 256; ++j) {
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
int j;
/* What happens in such situation isn't documented; Native seems to silently abort
on such conditions. Return Invalid Call. */
ERR("(%p) : (%u) Nonexistent palette. NumberOfPalettes %u\n", This, PaletteNumber, This->NumberOfPalettes);
return WINED3DERR_INVALIDCALL;
}
for (j = 0; j < 256; ++j) {
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetCurrentTexturePalette(IWineD3DDevice *iface, UINT PaletteNumber) {
/* Native appears to silently abort on attempt to make an uninitialized palette current and render.
(tested with reference rasterizer). Return Invalid Call. */
ERR("(%p) : (%u) Nonexistent palette. NumberOfPalettes %u\n", This, PaletteNumber, This->NumberOfPalettes);
return WINED3DERR_INVALIDCALL;
}
/*TODO: stateblocks */
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetCurrentTexturePalette(IWineD3DDevice *iface, UINT* PaletteNumber) {
if (PaletteNumber == NULL) {
return WINED3DERR_INVALIDCALL;
}
/*TODO: stateblocks */
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetSoftwareVertexProcessing(IWineD3DDevice *iface, BOOL bSoftware) {
if (!warned)
{
}
return WINED3D_OK;
}
if (!warned)
{
}
return This->softwareVertexProcessing;
}
{
TRACE("iface %p, swapchain_idx %u, raster_status %p.\n",
{
return hr;
}
{
return hr;
}
return WINED3D_OK;
}
{
if(nSegments != 0.0f) {
if (!warned)
{
}
}
return WINED3D_OK;
}
{
if (!warned)
{
}
return 0.0f;
}
{
const struct wined3d_format_desc *src_format;
const struct wined3d_format_desc *dst_format;
struct wined3d_context *context;
const unsigned char *data;
struct wined3d_format_desc dummy_desc;
TRACE("iface %p, src_surface %p, src_rect %s, dst_surface %p, dst_point %s",
if (src_impl->resource.pool != WINED3DPOOL_SYSTEMMEM || dst_impl->resource.pool != WINED3DPOOL_DEFAULT)
{
WARN("source %p must be SYSTEMMEM and dest %p must be DEFAULT, returning WINED3DERR_INVALIDCALL\n",
return WINED3DERR_INVALIDCALL;
}
{
WARN("Source and destination surfaces should have the same format.\n");
return WINED3DERR_INVALIDCALL;
}
/* This call loads the OpenGL surface directly, instead of copying the
* surface to the destination's sysmem copy. If surface conversion is
* needed, use BltFast instead to copy in sysmem and use regular surface
* loading. */
if (convert != NO_CONVERSION)
ENTER_GL();
checkGLcall("glActiveTextureARB");
LEAVE_GL();
/* Make sure the surface is loaded and up to date */
ENTER_GL();
{
if (src_rect)
{
}
TRACE("glCompressedTexSubImage2DARB, target %#x, level %d, x %d, y %d, w %d, h %d, "
if (row_length == src_pitch)
{
}
else
{
/* glCompressedTexSubImage2DARB() ignores pixel store state, so we
* can't use the unpack row length like below. */
{
y += src_format->block_height;
}
}
checkGLcall("glCompressedTexSubImage2DARB");
}
else
{
if (src_rect)
{
}
TRACE("glTexSubImage2D, target %#x, level %d, x %d, y %d, w %d, h %d, format %#x, type %#x, data %p.\n",
checkGLcall("glTexSubImage2D");
}
LEAVE_GL();
if (sampler != WINED3D_UNMAPPED_STAGE)
{
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UINT Handle, CONST float* pNumSegs, CONST WINED3DRECTPATCH_INFO* pRectPatchInfo) {
struct WineD3DRectPatch *patch;
unsigned int i;
struct list *e;
if(!(Handle || pRectPatchInfo)) {
/* TODO: Write a test for the return value, thus the FIXME */
FIXME("Both Handle and pRectPatchInfo are NULL\n");
return WINED3DERR_INVALIDCALL;
}
if(Handle) {
i = PATCHMAP_HASHFUNC(Handle);
break;
}
}
if(!found) {
TRACE("Patch does not exist. Creating a new one\n");
} else {
}
} else {
/* Since opengl does not load tesselated vertex attributes into numbered vertex
* attributes we have to tesselate, read back, and draw. This needs a patch
* management structure instance. Create one.
*
* A possible improvement is to check if a vertex shader is used, and if not directly
* draw the patch.
*/
FIXME("Drawing an uncached patch. This is slow\n");
}
TRACE("Tesselation density or patch info changed, retesselating\n");
if(pRectPatchInfo) {
}
WARN("Patch tesselation failed\n");
/* Do not release the handle to store the params of the patch */
if(!Handle) {
}
return hr;
}
}
IWineD3DDevice_DrawPrimitiveStrided(iface, patch->numSegs[0] * patch->numSegs[1] * 2 * 3, &patch->strided);
/* Destroy uncached patches */
if(!Handle) {
}
return WINED3D_OK;
}
{
FIXME("iface %p, handle %#x, segment_count %p, patch_info %p stub!\n",
return WINED3D_OK;
}
int i;
struct WineD3DRectPatch *patch;
struct list *e;
i = PATCHMAP_HASHFUNC(Handle);
return WINED3D_OK;
}
}
/* TODO: Write a test for the return value */
FIXME("Attempt to destroy nonexistent patch\n");
return WINED3DERR_INVALIDCALL;
}
{
struct wined3d_context *context;
if (!surface_is_offscreen(surface))
{
ENTER_GL();
}
else
{
ENTER_GL();
}
if (rect) {
if(surface_is_offscreen(surface)) {
} else {
}
checkGLcall("glScissor");
} else {
}
checkGLcall("glClear");
LEAVE_GL();
if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
}
{
if (surface->resource.pool != WINED3DPOOL_DEFAULT && surface->resource.pool != WINED3DPOOL_SYSTEMMEM) {
FIXME("call to colorfill with non WINED3DPOOL_DEFAULT or WINED3DPOOL_SYSTEMMEM surface\n");
return WINED3DERR_INVALIDCALL;
}
return WINED3D_OK;
} else {
/* Just forward this to the DirectDraw blitting engine */
}
}
{
{
return;
}
{
FIXME("Only supported on surface resources\n");
return;
}
{
}
else
{
WINED3DCOLOR c;
WARN("Converting to WINED3DCOLOR, this might give incorrect results\n");
/* Just forward this to the DirectDraw blitting engine */
BltFx.u5.dwFillColor = color_convert_argb_to_fmt(c, ((IWineD3DSurfaceImpl *)surface)->resource.format_desc->format);
hr = IWineD3DSurface_Blt(surface, NULL, NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
{
}
}
}
/* rendertarget and depth stencil functions */
static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice* iface,DWORD RenderTargetIndex, IWineD3DSurface **ppRenderTarget) {
{
ERR("(%p) : Only %d render targets are supported.\n",
return WINED3DERR_INVALIDCALL;
}
/* Note inc ref on returned surface */
if(*ppRenderTarget != NULL)
return WINED3D_OK;
}
{
{
return hr;
}
{
ERR("Trying to set a front buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage.\n");
return WINED3DERR_INVALIDCALL;
}
if (back_impl)
{
{
ERR("Trying to set a back buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage.\n");
return WINED3DERR_INVALIDCALL;
}
if (!swapchain->backBuffer)
{
swapchain->backBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*swapchain->backBuffer));
if (!swapchain->backBuffer)
{
ERR("Failed to allocate back buffer array memory.\n");
return E_OUTOFMEMORY;
}
}
}
{
if (swapchain->frontBuffer)
{
}
if (front)
{
}
}
{
if (swapchain->backBuffer[0])
{
}
if (back)
{
}
else
{
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice* iface, IWineD3DSurface **ppZStencilSurface) {
if(*ppZStencilSurface != NULL) {
/* Note inc ref on returned surface */
return WINED3D_OK;
} else {
return WINED3DERR_NOTFOUND;
}
}
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
#ifndef VBOX_WITH_WDDM
#endif
TRACE("(%p) : src_surface %p, src_rect_in %p, dst_surface %p, dst_rect_in %p, filter %s (0x%08x)\n",
This, src_surface, src_rect_in, dst_surface, dst_rect_in, debug_d3dtexturefiltertype(filter), filter);
src_rect = *src_rect_in;
dst_rect = *dst_rect_in;
switch (filter) {
case WINED3DTEXF_LINEAR:
break;
default:
case WINED3DTEXF_NONE:
case WINED3DTEXF_POINT:
break;
}
/* Make sure the drawables are up-to-date. Note that loading the
* destination surface isn't strictly required if we overwrite the
* entire surface. */
if (!surface_is_offscreen(src_surface)) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
else if (!surface_is_offscreen(dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
{
WARN("Invalid context, skipping blit.\n");
return;
}
if (!surface_is_offscreen(src_surface))
{
#ifndef VBOX_WITH_WDDM
UINT h;
#ifdef DEBUG_leo
{
DebugBreak();
}
#endif
}
else
#endif
{
}
ENTER_GL();
checkGLcall("glReadBuffer()");
} else {
ENTER_GL();
checkGLcall("glReadBuffer()");
}
LEAVE_GL();
/* Attach dst surface to dst fbo */
if (!surface_is_offscreen(dst_surface))
{
#ifndef VBOX_WITH_WDDM
UINT h;
#ifdef DEBUG_leo
{
DebugBreak();
}
#endif
}
else
#endif
{
/* Screen coords = window coords, surface height = window height */
}
ENTER_GL();
}
else
{
ENTER_GL();
}
checkGLcall("glBlitFramebuffer()");
LEAVE_GL();
if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget,
BOOL set_viewport) {
{
WARN("(%p) : Unsupported target %u set, returning WINED3DERR_INVALIDCALL(only %u supported)\n",
return WINED3DERR_INVALIDCALL;
}
/* MSDN says that null disables the render target
but a device must always be associated with a render target
nope MSDN says that we return invalid call to a null rendertarget with an index of 0
*/
FIXME("Trying to set render target 0 to NULL\n");
return WINED3DERR_INVALIDCALL;
}
if (pRenderTarget && !(((IWineD3DSurfaceImpl *)pRenderTarget)->resource.usage & WINED3DUSAGE_RENDERTARGET)) {
FIXME("(%p)Trying to set the render target to a surface(%p) that wasn't created with a usage of WINED3DUSAGE_RENDERTARGET\n",This ,pRenderTarget);
return WINED3DERR_INVALIDCALL;
}
/* If we are trying to set what we already have, don't bother */
TRACE("Trying to do a NOP SetRenderTarget operation\n");
return WINED3D_OK;
}
if(This->render_targets[RenderTargetIndex]) IWineD3DSurface_Release(This->render_targets[RenderTargetIndex]);
/* Render target 0 is special */
if(RenderTargetIndex == 0 && set_viewport) {
/* Finally, reset the viewport and scissor rect as the MSDN states.
* Tests show that stateblock recording is ignored, the change goes
* directly into the primary stateblock.
*/
This->stateBlock->viewport.Height = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height;
This->stateBlock->viewport.Width = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Width;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface *pNewZStencil) {
TRACE("(%p) Swapping z-buffer. Old = %p, new = %p\n",This, This->stencilBufferTarget, pNewZStencil);
TRACE("Trying to do a NOP SetRenderTarget operation\n");
} else {
/** OpenGL doesn't support 'sharing' of the stencilBuffer so we may incur an extra memory overhead
* depending on the renter target implementation being used.
* A shared context implementation will share all buffers between all rendertargets (including swapchains),
* implementations that use separate pbuffers for different swapchains or rendertargets will have to duplicate the
* stencil buffer and incur an extra memory overhead
******************************************************/
if (This->stencilBufferTarget) {
if (((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
} else {
struct wined3d_context *context = context_acquire(This, This->render_targets[0], CTXUSAGE_RESOURCELOAD);
}
}
/* should we be calling the parent or the wined3d surface? */
hr = WINED3D_OK;
/* Swapping NULL / non NULL depth stencil affects the depth and tests */
}
}
return hr;
}
/* TODO: the use of Impl is deprecated. */
/* some basic validation checks */
if(This->cursorTexture) {
ENTER_GL();
LEAVE_GL();
This->cursorTexture = 0;
}
else
if(pCursorBitmap) {
/* MSDN: Cursor must be A8R8G8B8 */
{
return WINED3DERR_INVALIDCALL;
}
/* MSDN: Cursor must be smaller than the display mode */
ERR("(%p) : Surface(%p) is %dx%d pixels, but screen res is %dx%d\n", This, pSur, pSur->currentDesc.Width, pSur->currentDesc.Height, This->ddraw_width, This->ddraw_height);
return WINED3DERR_INVALIDCALL;
}
if (!This->haveHardwareCursor) {
/* TODO: MSDN: Cursor sizes must be a power of 2 */
/* Do not store the surface's pointer because the application may
* release it after setting the cursor image. Windows doesn't
* addref the set surface, so we can't do this either without
* creating circular refcount dependencies. Copy out the gl texture
* instead.
*/
{
const struct wined3d_format_desc *format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, gl_info);
struct wined3d_context *context;
INT i;
/* Reformat the texture memory (pitch and width can be
* different) */
for(i = 0; i < height; i++)
ENTER_GL();
{
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
/* Make sure that a proper texture unit is selected */
checkGLcall("glActiveTextureARB");
if (sampler != WINED3D_UNMAPPED_STAGE)
{
}
/* Create a new cursor texture */
checkGLcall("glGenTextures");
checkGLcall("glBindTexture");
/* Copy the bitmap memory into the cursor texture */
checkGLcall("glTexImage2D");
{
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
LEAVE_GL();
}
else
{
FIXME("A cursor texture was not returned.\n");
This->cursorTexture = 0;
}
}
else
{
/* Draw a hardware cursor */
/* Create and clear maskBits because it is not needed for
* 32-bit cursors. 32x32 bits split into 32-bit chunks == 32
* chunks. */
);
/* Create our cursor and clean up. */
}
}
return WINED3D_OK;
}
static void WINAPI IWineD3DDeviceImpl_SetCursorPosition(IWineD3DDevice* iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
return;
}
/*
* When ShowCursor is first called it should make the cursor appear at the OS's last
* known cursor position. Because of this, some applications just repetitively call
* ShowCursor in order to update the cursor's position. This behavior is undocumented.
*/
GetCursorPos(&pt);
if (This->haveHardwareCursor) {
if (bShow)
else
}
else
{
if (This->cursorTexture)
}
return oldVisible;
}
}
return S_OK;
}
{
return WINED3D_OK;
}
static HRESULT updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters)
{
/* Reallocate proper memory for the front and back buffer and adjust their sizes */
/* Release the DC */
/* Release the DIB section */
}
{
} else {
}
if (surface->texture_name)
{
IWineD3DDeviceImpl *This = device; /* <- to make the below texture_gl_delete macro work and avoid other modifications */
ENTER_GL();
LEAVE_GL();
surface->texture_name = 0;
}
} else {
}
surface->resource.size = IWineD3DSurface_GetPitch((IWineD3DSurface *) surface) * surface->pow2Width;
/* Put all surfaces into sysmem - the drawable might disappear if the backbuffer was rendered
* to a FBO */
{
return E_OUTOFMEMORY;
}
return WINED3D_OK;
}
return S_OK;
}
static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRESENT_PARAMETERS *pp)
{
/* All Windowed modes are supported, as is leaving the current mode */
for(i = 0; i < count; i++) {
memset(&m, 0, sizeof(m));
ERR("EnumAdapterModes failed\n");
}
/* Mode found, it is supported */
return TRUE;
}
}
/* Mode not found -> not supported */
return FALSE;
}
#ifndef VBOX_WITH_WDDM
#endif
)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
}
ENTER_GL();
if(This->depth_blt_texture) {
This->depth_blt_texture = 0;
}
if (This->depth_blt_rb) {
This->depth_blt_rb = 0;
This->depth_blt_rb_w = 0;
This->depth_blt_rb_h = 0;
}
LEAVE_GL();
while (This->numContexts)
{
}
#ifndef VBOX_WITH_WDDM
swapchain->num_contexts = 0;
#endif
}
static HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
{
struct wined3d_context *context;
#ifndef VBOX_WITH_WDDM
/* Recreate the primary swapchain's context */
{
ERR("Failed to allocate memory for swapchain context array.\n");
return E_OUTOFMEMORY;
}
#endif
target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
{
WARN("Failed to create context.\n");
#ifndef VBOX_WITH_WDDM
#endif
return E_FAIL;
}
#ifndef VBOX_WITH_WDDM
#endif
{
goto err;
}
{
goto err;
}
{
goto err;
}
return WINED3D_OK;
err:
#ifndef VBOX_WITH_WDDM
swapchain->num_contexts = 0;
#endif
return hr;
}
static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters) {
#ifdef VBOX_WITH_WDDM
/* todo: implement multi-swapchain handlling!!! */
Assert(0);
#endif
ERR("Failed to get the first implicit swapchain\n");
return hr;
}
WARN("Rejecting Reset() call because the requested display mode is not supported\n");
return WINED3DERR_INVALIDCALL;
}
/* Is it necessary to recreate the gl context? Actually every setting can be changed
* on an existing gl context, so there's no real need for recreation.
*
* TODO: Figure out how Reset influences resources in D3DPOOL_DEFAULT, D3DPOOL_SYSTEMMEMORY and D3DPOOL_MANAGED
*
* TODO: Figure out what happens to explicit swapchains, or if we have more than one implicit swapchain
*/
TRACE("New params:\n");
TRACE("EnableAutoDepthStencil = %s\n", pPresentationParameters->EnableAutoDepthStencil ? "true" : "false");
/* No special treatment of these parameters. Just store them */
swapchain->presentParms.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
/* What to do about these? */
if(pPresentationParameters->BackBufferCount != 0 &&
ERR("Cannot change the back buffer count yet\n");
}
ERR("Cannot change the back buffer format yet\n");
}
ERR("Cannot change the device window yet\n");
}
TRACE("Creating the depth stencil buffer\n");
ERR("Failed to create the depth stencil buffer\n");
return WINED3DERR_INVALIDCALL;
}
}
/* Reset the depth stencil */
else
TRACE("Resetting stateblock\n");
#ifndef VBOX_WITH_WDDM
#endif
);
if(pPresentationParameters->Windowed) {
mode.RefreshRate = 0;
} else {
}
/* Should Width == 800 && Height == 0 set 800x600? */
if(pPresentationParameters->BackBufferWidth != 0 && pPresentationParameters->BackBufferHeight != 0 &&
{
UINT i;
if(!pPresentationParameters->Windowed) {
}
{
return hr;
}
{
return hr;
}
}
if(This->auto_depth_stencil_buffer) {
hr = updateSurfaceDesc((IWineD3DSurfaceImpl *)This->auto_depth_stencil_buffer, pPresentationParameters);
{
return hr;
}
}
}
{
if (!pPresentationParameters->Windowed)
{
/* switch from windowed to fs */
} else {
#ifndef VBOX_WITH_WDDM
/* Fullscreen -> fullscreen mode change */
TRUE);
#else
ERR("reset: fullscreen unexpected!");
#endif
}
}
{
/* Fullscreen -> windowed switch */
}
} else if(!pPresentationParameters->Windowed) {
/* If we're in fullscreen, and the mode wasn't changed, we have to get the window back into
* the right position. Some applications(Battlefield 2, Guild Wars) move it and then call
* Reset to clear up their mess. Guild Wars also loses the device during that.
*/
}
/* Note: No parent needed for initial internal stateblock */
hr = IWineD3DDevice_CreateStateBlock(iface, WINED3DSBT_INIT, (IWineD3DStateBlock **)&This->stateBlock, NULL);
}
{
#ifndef VBOX_WITH_WDDM
#endif
{
TRACE("Single buffered rendering\n");
}
#ifndef VBOX_WITH_WDDM
{
TRACE("Rendering to FBO. Backbuffer %ux%u, window %ux%u\n",
}
#endif
else
{
TRACE("Rendering directly to GL_BACK\n");
}
}
/* All done. There is no need to reload resources or shaders, this will happen automatically on the
* first use
*/
return hr;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetDialogBoxMode(IWineD3DDevice *iface, BOOL enable_dialogs)
{
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetCreationParameters(IWineD3DDevice *iface, WINED3DDEVICE_CREATION_PARAMETERS *pParameters) {
return WINED3D_OK;
}
static void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice * iface, UINT iSwapChain, DWORD Flags, CONST WINED3DGAMMARAMP* pRamp) {
TRACE("Relaying to swapchain\n");
}
}
static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT iSwapChain, WINED3DGAMMARAMP* pRamp) {
TRACE("Relaying to swapchain\n");
}
}
/** ********************************************************
* Notification functions
** ********************************************************/
/** This function must be called in the release of a resource when ref == 0,
* the contents of resource must still be correct,
* any handles to other resource held by the caller must be closed
* (e.g. a texture should release all held surfaces because telling the device that it's been released.)
*****************************************************/
{
list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
}
{
}
{
int counter;
switch (type) {
/* TODO: check front and back buffers, rendertargets etc.. possibly swapchains? */
case WINED3DRTYPE_SURFACE: {
unsigned int i;
if (This->d3d_initialized)
{
{
}
}
}
}
break;
}
case WINED3DRTYPE_TEXTURE:
case WINED3DRTYPE_CUBETEXTURE:
if (This->stateBlock != NULL && This->stateBlock->textures[counter] == (IWineD3DBaseTexture *)resource) {
WARN("Texture being released is still by a stateblock, Stage = %u Texture = %p\n", counter, resource);
}
WARN("Texture being released is still by a stateblock, Stage = %u Texture = %p\n", counter, resource);
}
}
}
break;
case WINED3DRTYPE_VOLUME:
/* TODO: nothing really? */
break;
case WINED3DRTYPE_BUFFER:
{
int streamNumber;
TRACE("Cleaning up stream pointers\n");
/* FINDOUT: should a warn be generated if were recording and updateStateBlock->streamSource is lost?
FINDOUT: should changes.streamSource[StreamNumber] be set ?
*/
/* Set changed flag? */
}
}
if (This->stateBlock != NULL ) { /* only happens if there is an error in the application, or on reset/release (because we don't manage internal tracking properly) */
}
}
}
}
}
}
}
}
break;
default:
break;
}
/* Remove the resource from the resourceStore */
TRACE("Resource released\n");
}
static HRESULT WINAPI IWineD3DDeviceImpl_EnumResources(IWineD3DDevice *iface, D3DCB_ENUMRESOURCES pCallback, void *pData) {
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry) {
TRACE("Canceling enumeration\n");
break;
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetSurfaceFromDC(IWineD3DDevice *iface, HDC dc, IWineD3DSurface **surface)
{
{
if (type == WINED3DRTYPE_SURFACE)
{
{
return WINED3D_OK;
}
}
}
return WINED3DERR_INVALIDCALL;
}
static HRESULT WINAPI IWineD3DDeviceImpl_AddSwapChain(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain)
{
VOID *pvNewBuf = HeapReAlloc(GetProcessHeap(), 0, This->swapchains, (This->NumberOfSwapChains + 1) * sizeof(IWineD3DSwapChain *));
if(!pvNewBuf) {
ERR("Out of memory!\n");
return E_OUTOFMEMORY;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_RemoveSwapChain(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain)
{
int i;
for (i = 0; i < This->NumberOfSwapChains; ++i)
{
{
break;
}
}
if (i == This->NumberOfSwapChains)
{
return E_INVALIDARG;
}
if (This->NumberOfSwapChains)
{
IWineD3DSwapChain **pvNewBuf = (IWineD3DSwapChain **)HeapAlloc(GetProcessHeap(), 0, (This->NumberOfSwapChains) * sizeof(IWineD3DSwapChain *));
if(!pvNewBuf) {
ERR("Out of memory!\n");
return E_OUTOFMEMORY;
}
if (i) {
}
if (i < This->NumberOfSwapChains) {
memcpy (pvNewBuf + i, This->swapchains +i+1, (This->NumberOfSwapChains - i)*sizeof(IWineD3DSwapChain *));
}
}
else
{
while (This->numContexts)
{
}
}
return WINED3D_OK;
}
#ifdef VBOX_WITH_WDDM
{
struct wined3d_context *context;
int i;
/* first call swapchain flush to ensure all swapchain-pending data gets flushed */
for (i = 0; i < This->NumberOfSwapChains; ++i)
{
}
for (i = 0; i < This->numContexts; ++i)
{
{
wglFlush();
}
else
{
WARN("Invalid context, skipping flush.\n");
}
}
return WINED3D_OK;
}
/* context activation is done by the caller */
{
unsigned int i;
ENTER_GL();
{
/* Make appropriate texture active */
checkGLcall("glActiveTextureARB");
/* don't do glGet GL_TEXTURE_BINDING_xxx just ensure nothing is bound to IWineD3DSurfaceImpl::texture_target,
* and dirtify the state later */
if (texture_target == GL_TEXTURE_2D)
else
}
/* restore tha active texture unit */
checkGLcall("glActiveTextureARB");
LEAVE_GL();
/* dirtify */
{
if (active_sampler != WINED3D_UNMAPPED_STAGE)
{
}
}
/* do flush to ensure this all goes to host */
wglFlush();
}
#endif
/**********************************************************
* IWineD3DDevice VTbl follows
**********************************************************/
static const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
{
/*** IUnknown methods ***/
/*** IWineD3DDevice methods ***/
/*** Creation methods**/
/*** Odd functions **/
/*** Getters and setters **/
/*** State block ***/
/*** Scene management ***/
/*** Drawing ***/
/*** object tracking ***/
/* VBox extensions */
#ifdef VBOX_WITH_WDDM
/* VBox WDDM extensions */
#endif
};
{
const struct fragment_pipeline *fragment_pipeline;
struct shader_caps shader_caps;
struct fragment_caps ffp_caps;
unsigned int i;
/* Get the initial screen setup for ddraw. */
{
return hr;
}
/* Save the creation parameters. */
{
return hr;
}
return WINED3D_OK;
}
struct wined3d_context *context;
UINT i;
for(i = 0; i < This->numContexts; i++) {
}
}
{
/* The drawable size of a fbo target is the opengl texture size, which is the power of two size. */
}
{
#ifdef VBOX_WITH_WDDM
#else
#endif
/* 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. */
}
#ifndef VBOX_WITH_WDDM
{
if (device->filter_messages)
{
TRACE("Filtering message: window %p, message %#x, wparam %#lx, lparam %#lx.\n",
}
if (message == WM_DESTROY)
{
}
}
#endif