device.c revision 554f00fe75489f3f3ce7fbb6d126ce1d2c5c922c
/*
* 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
*
* 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
*/
/*
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun 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.0, 1.0, 1.0, 0.0 }, /* Diffuse r,g,b,a */
{ 0.0, 0.0, 0.0, 0.0 }, /* Specular r,g,b,a */
{ 0.0, 0.0, 0.0, 0.0 }, /* Ambient r,g,b,a, */
{ 0.0, 0.0, 0.0 }, /* Position x,y,z */
{ 0.0, 0.0, 1.0 }, /* Direction x,y,z */
0.0, /* Range */
0.0, /* Falloff */
0.0, 0.0, 0.0, /* Attenuation 0,1,2 */
0.0, /* Theta */
0.0 /* Phi */
};
/**********************************************************
* Global variable / Constants follow
**********************************************************/
/* 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;
}
{
/* We need to deal with frequency data! */
IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
unsigned int i;
/* 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",
{
}
}
}
/* Now call PreLoad on all the vertex buffers. In the very rare case
* that the buffers stopps converting PreLoad will dirtify the VDECL again.
* The vertex buffer can now use the strided structure in the device instead of finding its
* own again.
*
* NULL streams won't be recorded in the array, UP streams won't be either. A stream is only
* once in there. */
for (i = 0; i < stream_count; ++i)
{
}
}
{
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(strided->format, &This->adapter->gl_info);
e->format_desc = format_desc;
e->stream_idx = 0;
e->buffer_object = 0;
}
{
unsigned int i;
stream_info_element_from_strided(This, &strided->position, &stream_info->elements[WINED3D_FFP_POSITION]);
stream_info_element_from_strided(This, &strided->normal, &stream_info->elements[WINED3D_FFP_NORMAL]);
stream_info_element_from_strided(This, &strided->diffuse, &stream_info->elements[WINED3D_FFP_DIFFUSE]);
stream_info_element_from_strided(This, &strided->specular, &stream_info->elements[WINED3D_FFP_SPECULAR]);
for (i = 0; i < WINED3DDP_MAXTEXCOORD; ++i)
{
}
{
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && stream_info->elements[i].format_desc->format == WINED3DFMT_A8R8G8B8)
{
}
}
}
/**********************************************************
* 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
** ***************************/
}
}
return refCount;
}
/**********************************************************
* IWineD3DDevice implementation follows
**********************************************************/
return WINED3D_OK;
}
{
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
struct wined3d_buffer *object;
if (!object)
{
ERR("Failed to allocate memory\n");
return E_OUTOFMEMORY;
}
FIXME("Ignoring access flags (pool)\n");
{
return hr;
}
TRACE("size %#x, usage=%#x, format %s, memory @ %p, iface @ %p\n", object->resource.size, object->resource.usage,
if (data)
{
{
return hr;
}
{
return hr;
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Size, DWORD Usage,
{
/* Dummy format for now */
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_VERTEXDATA, &This->adapter->gl_info);
struct wined3d_buffer *object;
if(Size == 0) {
WARN("Size 0 requested, returning WINED3DERR_INVALIDCALL\n");
*ppVertexBuffer = NULL;
return WINED3DERR_INVALIDCALL;
} else 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;
}
hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, Size, Usage, format_desc, Pool, parent);
{
*ppVertexBuffer = NULL;
return hr;
}
TRACE("(%p) : Size=%d, Usage=0x%08x, FVF=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->resource.allocatedMemory, object);
/* Observations show that drawStridedSlow is faster on dynamic VBs than converting +
* drawStridedFast (half-life 2).
*
* Basically converting the vertices in the buffer is quite expensive, and observations
* show that drawStridedSlow is faster than converting + uploading + drawStridedFast.
* Therefore do not create a VBO for WINED3DUSAGE_DYNAMIC buffers.
*
* Direct3D7 has another problem: Its vertexbuffer api doesn't offer a way to specify
* the range of vertices being locked, so each lock will require the whole buffer to be transformed.
* Moreover geometry data in dx7 is quite simple, so drawStridedSlow isn't a big hit. A plus
* is that the vertex buffers fvf can be trusted in dx7. So only create non-converted vbos for
* dx7 apps.
* There is a IDirect3DVertexBuffer7::Optimize call after which the buffer can't be locked any
* more. In this call we can convert dx7 buffers too.
*/
conv = ((FVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) || (FVF & (WINED3DFVF_DIFFUSE | WINED3DFVF_SPECULAR));
if(!GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) {
TRACE("Not creating a vbo because GL_ARB_vertex_buffer is not supported\n");
} else if(Pool == WINED3DPOOL_SYSTEMMEM) {
TRACE("Not creating a vbo because the vertex buffer is in system memory\n");
} else if(Usage & WINED3DUSAGE_DYNAMIC) {
TRACE("Not creating a vbo because the buffer has dynamic usage\n");
TRACE("Not creating a vbo because dxVersion is 7 and the fvf needs conversion\n");
} else {
}
return WINED3D_OK;
}
{
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
struct wined3d_buffer *object;
/* Allocate the storage for the device */
if (!object)
{
ERR("Out of memory\n");
*ppIndexBuffer = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, Length, Usage, format_desc, Pool, parent);
{
*ppIndexBuffer = NULL;
return hr;
}
if(Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) && GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) {
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, WINED3DSTATEBLOCKTYPE Type, IWineD3DStateBlock** ppStateBlock, IUnknown *parent) {
unsigned int i, j;
if(!object)
{
ERR("Out of memory\n");
*ppStateBlock = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
for(i = 0; i < LIGHTMAP_SIZE; i++) {
}
if (FAILED(temp_result))
{
return temp_result;
}
/* Special case - Used during initialization to produce a placeholder stateblock
so other functions called can update a state block */
{
/* Don't bother increasing the reference count otherwise a device will never
be freed due to circular dependencies */
return WINED3D_OK;
}
/* Otherwise, might as well set the whole state block to the appropriate values */
else
/* Reset the ref and type after kludging it */
if (Type == WINED3DSBT_ALL) {
TRACE("ALL => Pretend everything has changed\n");
/* Lights are not part of the changed / set structure */
for(j = 0; j < LIGHTMAP_SIZE; j++) {
struct list *e;
}
}
for(j = 1; j <= WINEHIGHEST_RENDER_STATE; j++) {
}
/* TODO: Filter unused transforms between TEXTURE8 and WORLD0? */
for(j = 1; j <= HIGHEST_TRANSFORMSTATE; j++) {
}
for(j = 0; j < GL_LIMITS(vshader_constantsF); j++) {
object->contained_vs_consts_f[j] = j;
}
for(j = 0; j < MAX_CONST_I; j++) {
object->contained_vs_consts_i[j] = j;
}
for(j = 0; j < MAX_CONST_B; j++) {
object->contained_vs_consts_b[j] = j;
}
for(j = 0; j < GL_LIMITS(pshader_constantsF); j++) {
object->contained_ps_consts_f[j] = j;
}
for(j = 0; j < MAX_CONST_I; j++) {
object->contained_ps_consts_i[j] = j;
}
for(j = 0; j < MAX_CONST_B; j++) {
object->contained_ps_consts_b[j] = j;
}
for(i = 0; i < MAX_TEXTURES; i++) {
for (j = 0; j <= WINED3D_HIGHEST_TEXTURE_STATE; ++j)
{
}
}
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
for(j = 1; j <= WINED3D_HIGHEST_SAMPLER_STATE; j++) {
}
}
for(i = 0; i < MAX_STREAMS; i++) {
if(object->streamSource[i]) {
}
}
if(object->pIndexData) {
}
if(object->vertexShader) {
}
if(object->pixelShader) {
}
} else if (Type == WINED3DSBT_PIXELSTATE) {
TRACE("PIXELSTATE => Pretend all pixel shates have changed\n");
/* Pixel Shader Constants */
for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i) {
object->contained_ps_consts_f[i] = i;
}
for (i = 0; i < MAX_CONST_B; ++i) {
object->contained_ps_consts_b[i] = i;
}
for (i = 0; i < MAX_CONST_I; ++i) {
object->contained_ps_consts_i[i] = i;
}
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
}
for (j = 0; j < MAX_TEXTURES; j++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
}
}
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++) {
for (i =0; i < NUM_SAVEDPIXELSTATES_S;i++) {
}
}
if(object->pixelShader) {
}
/* Pixel state blocks do not contain vertex buffers. Set them to NULL to avoid wrong refcounting
* on them. This makes releasing the buffer easier
*/
for(i = 0; i < MAX_STREAMS; i++) {
}
} else if (Type == WINED3DSBT_VERTEXSTATE) {
TRACE("VERTEXSTATE => Pretend all vertex shates have changed\n");
/* Vertex Shader Constants */
for (i = 0; i < GL_LIMITS(vshader_constantsF); ++i) {
object->contained_vs_consts_f[i] = i;
}
for (i = 0; i < MAX_CONST_B; ++i) {
object->contained_vs_consts_b[i] = i;
}
for (i = 0; i < MAX_CONST_I; ++i) {
object->contained_vs_consts_i[i] = i;
}
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
}
for (j = 0; j < MAX_TEXTURES; j++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
}
}
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++){
for (i =0; i < NUM_SAVEDVERTEXSTATES_S;i++) {
}
}
for(j = 0; j < LIGHTMAP_SIZE; j++) {
struct list *e;
}
}
for(i = 0; i < MAX_STREAMS; i++) {
if(object->streamSource[i]) {
}
}
if(object->vertexShader) {
}
} else {
}
return WINED3D_OK;
}
WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, WINED3DSURFTYPE Impl, IUnknown *parent)
{
unsigned int Size = 1;
if(MultisampleQuality > 0) {
}
/** FIXME: Check that the format is supported
* by the device.
*******************************/
/** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
* it is based around 4x4 pixel blocks it requires padding, so allocate enough
* space!
*********************************/
if (WINED3DFMT_UNKNOWN == Format) {
Size = 0;
} else if (Format == WINED3DFMT_DXT1) {
/* DXT1 is half byte per pixel */
Format == WINED3DFMT_ATI2N) {
} else {
/* The pitch is a multiple of 4 bytes */
Size = ((Width * glDesc->byte_count) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
}
/** Create and initialise the surface resource **/
if (!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
/* Look at the implementation and set the correct Vtable */
switch(Impl)
{
case SURFACE_OPENGL:
/* Check if a 3D adapter is available when creating gl surfaces */
{
ERR("OpenGL surfaces are not available without opengl\n");
return WINED3DERR_NOTAVAILABLE;
}
break;
case SURFACE_GDI:
break;
default:
/* To be sure to catch this */
return WINED3DERR_INVALIDCALL;
}
hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_SURFACE, This, Size, Usage, glDesc, Pool, parent);
{
return hr;
}
/* "Standalone" surface */
/* Flags */
/** Quick lockable sanity check TODO: remove this after surfaces, usage and lockability have been debugged properly
* this function is too deep to need to care about things like this.
* Levels need to be checked too, and possibly Type since they all affect what can be done.
* ****************************************/
switch(Pool) {
case WINED3DPOOL_SCRATCH:
if(!Lockable)
FIXME("Create surface called with a pool of SCRATCH and a Lockable of FALSE "
"which are mutually exclusive, setting lockable to TRUE\n");
break;
case WINED3DPOOL_SYSTEMMEM:
"this is acceptable but unexpected (I can't know how the surface can be usable!)\n");
case WINED3DPOOL_MANAGED:
"Usage of DYNAMIC which are mutually exclusive, not doing "
"anything just telling you.\n");
break;
case WINED3DPOOL_DEFAULT: /*TODO: Create offscreen plain can cause this check to fail..., find out if it should */
WARN("Creating a surface with a POOL of DEFAULT with Lockable true, that doesn't specify DYNAMIC usage.\n");
break;
default:
break;
};
FIXME("Trying to create a render target that isn't in the default pool\n");
}
/* mark the texture as dirty so that it gets loaded first time around*/
TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n",
(WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
/* Call the private setup routine */
{
return hr;
}
return hr;
}
{
struct wined3d_rendertarget_view *object;
if (!object)
{
ERR("Failed to allocate memory\n");
return E_OUTOFMEMORY;
}
return WINED3D_OK;
}
{
TRACE("Format %#x (%s), Pool %#x, ppTexture %p, parent %p\n",
if (!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
return hr;
}
return WINED3D_OK;
}
{
if (!object)
{
ERR("Out of memory\n");
*ppVolumeTexture = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
*ppVolumeTexture = NULL;
return hr;
}
return WINED3D_OK;
}
{
if(!GL_SUPPORT(EXT_TEXTURE3D)) {
return WINED3DERR_INVALIDCALL;
}
if (!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
return hr;
}
/** Note: Volume textures cannot be dxtn, hence no need to check here **/
return WINED3D_OK;
}
{
if (!object)
{
ERR("Out of memory\n");
*ppCubeTexture = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
*ppCubeTexture = NULL;
return hr;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent) {
const IWineD3DQueryVtbl *vtable;
/* Just a check to see if we support this type of query */
switch(Type) {
hr = WINED3D_OK;
else
WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n");
break;
case WINED3DQUERYTYPE_EVENT:
/* Half-Life 2 needs this query. It does not render the main menu correctly otherwise
* Pretend to support it, faking this query does not do much harm except potentially lowering performance
*/
}
hr = WINED3D_OK;
break;
case WINED3DQUERYTYPE_VCACHE:
default:
/* Use the base Query vtable until we have a special one for each query */
}
return hr;
}
if(!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
/* allocated the 'extended' data based on the type of query requested */
switch(Type){
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryOcclusionData));
if(GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
ENTER_GL();
LEAVE_GL();
break;
}
case WINED3DQUERYTYPE_EVENT:
ENTER_GL();
if(GL_SUPPORT(APPLE_FENCE)) {
checkGLcall("glGenFencesAPPLE");
} else if(GL_SUPPORT(NV_FENCE)) {
checkGLcall("glGenFencesNV");
}
LEAVE_GL();
break;
case WINED3DQUERYTYPE_VCACHE:
default:
object->extendedData = 0;
}
return WINED3D_OK;
}
/*****************************************************************************
* IWineD3DDeviceImpl_SetupFullscreenWindow
*
* Helper function that modifies a HWND's Style and ExStyle for proper
* fullscreen use.
*
* Params:
* iface: Pointer to the IWineD3DDevice interface
* window: Window to setup
*
*****************************************************************************/
style &= ~WS_CAPTION;
style &= ~WS_THICKFRAME;
/* Make sure the window is managed, otherwise we won't get keyboard input */
return style;
}
/* Filter out window decorations */
exStyle &= ~WS_EX_WINDOWEDGE;
exStyle &= ~WS_EX_CLIENTEDGE;
return exStyle;
}
static void IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h) {
/* Don't do anything if an original style is stored.
* That shouldn't happen
*/
ERR("(%p): Want to change the window parameters of HWND %p, but "
}
/* Get the parameters and save them */
TRACE("Old style was %08x,%08x, setting to %08x,%08x\n",
/* Inform the window about the update. */
w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW);
}
/*****************************************************************************
* IWineD3DDeviceImpl_RestoreWindow
*
* Helper function that restores a windows' properties when taking it out
* of fullscreen mode
*
* Params:
* iface: Pointer to the IWineD3DDevice interface
* window: Window to setup
*
*****************************************************************************/
/* This could be a DDSCL_NORMAL -> DDSCL_NORMAL
* switch, do nothing
*/
TRACE("(%p): Restoring window settings of window %p to %08x, %08x\n",
/* Only restore the style if the application didn't modify it during the fullscreen phase.
* Some applications change it before calling Reset() when switching between windowed and
* fullscreen modes(HL2), some depend on the original style(Eve Online)
*/
}
/* Delete the old values */
/* Inform the window about the update */
0, 0, 0, 0, /* Pos, Size, ignored */
}
/* example at http://www.fairyengine.com/articles/dxmultiviews.htm */
{
const struct GlPixelFormatDesc *format_desc;
/** FIXME: Test under windows to find out what the life cycle of a swap chain is,
* does a device hold a reference to a swap chain giving them a lifetime of the device
* or does the swap chain notify the device of its destruction.
*******************************/
/* Check the params */
ERR("App requested %d back buffers, this is not supported for now\n", pPresentationParameters->BackBufferCount);
return WINED3DERR_INVALIDCALL;
FIXME("The app requests more than one back buffer, this can't be supported properly. Please configure the application to use double buffering(=1 back buffer) if possible\n");
}
if(!object)
{
ERR("Out of memory\n");
*ppSwapChain = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
switch(surface_type) {
case SURFACE_GDI:
break;
case SURFACE_OPENGL:
break;
case SURFACE_UNKNOWN:
FIXME("Caller tried to create a SURFACE_UNKNOWN swapchain\n");
return WINED3DERR_INVALIDCALL;
}
/*********************
* Lookup the window Handle and the relating X window handle
********************/
/* Setup hwnd we are using, plus which display this equates to */
if (!object->win_handle) {
}
}
return WINED3DERR_NOTAVAILABLE;
}
/* Get info on the current display setup */
if (pPresentationParameters->Windowed &&
((pPresentationParameters->BackBufferWidth == 0) ||
(pPresentationParameters->BackBufferHeight == 0) ||
if (pPresentationParameters->BackBufferWidth == 0) {
}
if (pPresentationParameters->BackBufferHeight == 0) {
}
}
}
/* Put the correct figures in the presentation parameters */
TRACE("Copying across presentation parameters\n");
TRACE("calling rendertarget CB\n");
if(surface_type == SURFACE_OPENGL) {
}
} else {
ERR("Failed to create the front buffer\n");
goto error;
}
/*********************
* Windowed / Fullscreen
*******************/
/**
* TODO: MSDN says that we are only allowed one fullscreen swapchain per device,
* so we should really check to see if there is a fullscreen swapchain already
* I think Windows and X have different ideas about fullscreen, does a single head count as full screen?
**************************************/
if (!pPresentationParameters->Windowed) {
/* Change the display settings */
}
/**
* Create an opengl context for the display visual
* NOTE: the visual is chosen as the window is created and the glcontext cannot
* use different properties after that point in time. FIXME: How to handle when requested format
* doesn't match actual visual? Cannot choose one here - code removed as it ONLY works if the one
* it chooses is identical to the one already being used!
**********************************/
/** FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat **/
ERR("Failed to create the context array\n");
hr = E_OUTOFMEMORY;
goto error;
}
if(surface_type == SURFACE_OPENGL) {
object->context[0] = CreateContext(This, (IWineD3DSurfaceImpl *) object->frontBuffer, object->win_handle, FALSE /* pbuffer */, pPresentationParameters);
ERR("Failed to create a new context\n");
goto error;
} else {
TRACE("Context created (HWND=%p, glContext=%p)\n",
}
}
/*********************
* Create the back, front and stencil buffers
*******************/
UINT i;
object->backBuffer = HeapAlloc(GetProcessHeap(), 0, sizeof(IWineD3DSurface *) * object->presentParms.BackBufferCount);
if(!object->backBuffer) {
ERR("Out of memory\n");
hr = E_OUTOFMEMORY;
goto error;
}
TRACE("calling rendertarget CB\n");
} else {
ERR("Cannot create new back buffer\n");
goto error;
}
if(surface_type == SURFACE_OPENGL) {
ENTER_GL();
checkGLcall("glDrawBuffer(GL_BACK)");
LEAVE_GL();
}
}
} else {
/* Single buffering - draw to front buffer */
if(surface_type == SURFACE_OPENGL) {
ENTER_GL();
checkGLcall("glDrawBuffer(GL_FRONT)");
LEAVE_GL();
}
}
/* Under directX swapchains share the depth stencil, so only create one depth-stencil */
TRACE("Creating depth stencil buffer\n");
} else {
ERR("Failed to create the auto depth stencil\n");
goto error;
}
}
}
TRACE("FrontBuf @ %p, BackBuf @ %p, DepthStencil %d\n",object->frontBuffer, object->backBuffer ? object->backBuffer[0] : NULL, pPresentationParameters->EnableAutoDepthStencil);
return WINED3D_OK;
if (displaymode_set) {
/* Change the display settings */
}
if (object->backBuffer) {
UINT i;
if(object->backBuffer[i]) {
if (IUnknown_Release(bufferParent) > 0) {
}
}
}
}
if(object->frontBuffer) {
if (IUnknown_Release(bufferParent) > 0) {
}
}
return hr;
}
/** 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;
}
}
/*****
* Vertex Declaration
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppVertexDeclaration,
TRACE("(%p) : directXVersion %u, elements %p, element_count %d, ppDecl=%p\n",
if(!object)
{
ERR("Out of memory\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
}
return hr;
}
static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the GL info, which has the type table */
unsigned int offset;
(fvf & WINED3DFVF_LASTBETA_D3DCOLOR) ||
unsigned int size;
if (has_blend_idx) num_blends--;
/* Compute declaration size */
/* convert the declaration */
if (!elements) return ~0U;
idx = 0;
if (has_pos) {
}
}
else {
}
idx++;
}
if (has_blend && (num_blends > 0)) {
else {
switch(num_blends) {
default:
}
}
idx++;
}
if (has_blend_idx) {
if (fvf & WINED3DFVF_LASTBETA_UBYTE4 ||
else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
else
idx++;
}
if (has_normal) {
idx++;
}
if (has_psize) {
idx++;
}
if (has_diffuse) {
idx++;
}
if (has_specular) {
idx++;
}
switch (numcoords) {
break;
break;
break;
break;
}
idx++;
}
/* Now compute offsets, and initialize the rest of the fields */
{
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(elements[idx].format, &This->adapter->gl_info);
}
return size;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *Parent, DWORD Fvf) {
unsigned int size;
if (size == ~0U) return WINED3DERR_OUTOFVIDEOMEMORY;
return WINED3D_OK;
}
{
if (!pFunction) return WINED3DERR_INVALIDCALL;
if (!object)
{
ERR("Out of memory\n");
*ppVertexShader = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
*ppVertexShader = NULL;
return hr;
}
return hr;
}
{
if (!pFunction) return WINED3DERR_INVALIDCALL;
if (!object)
{
ERR("Out of memory\n");
*ppPixelShader = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
{
*ppPixelShader = NULL;
return hr;
}
return hr;
}
{
/* Create the new object */
if(!object) {
ERR("Out of memory when allocating memory for a IWineD3DPalette implementation\n");
return E_OUTOFMEMORY;
}
return E_OUTOFMEMORY;
}
hr = IWineD3DPalette_SetEntries((IWineD3DPalette *) object, 0, 0, IWineD3DPaletteImpl_Size(Flags), PalEnt);
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
*/
}
hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *) This, bm.bmWidth, bm.bmHeight, WINED3DFMT_R5G6B5,
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:
if(dcb) {
}
if(hbm) {
}
return;
}
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();
if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) {
/* 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");
}
if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) {
/* Reenable because if supported it is enabled by default */
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
LEAVE_GL();
}
{
unsigned int i;
/* TODO: Test if OpenGL is compiled in and loaded */
/* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
NULL);
WARN("Failed to create stateblock\n");
goto err_out;
}
This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DSurface *) * GL_LIMITS(buffers));
This->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLenum) * GL_LIMITS(buffers));
ERR("Out of memory!\n");
goto err_out;
}
ERR("Out of memory!\n");
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 */
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:
case ORM_PBUFFER:
break;
case ORM_BACKBUFFER:
{
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.0, 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;
}
static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyDepthStencilSurface, D3DCB_DESTROYSWAPCHAINFN D3DCB_DestroySwapChain) {
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 palette conversion shader if it is around */
if(This->paletteConversionShader) {
ENTER_GL();
LEAVE_GL();
This->paletteConversionShader = 0;
}
/* Delete the pbuffer context if there is any */
/* 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)*/
}
/* This check is a bit silly, it should be in swapchain_release FIXME("(%p) Something's still holding the renderTarget\n",This); */
}
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) */
return;
}
const WINED3DDISPLAYMODE* pMode) {
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;
}
/* return simulated texture memory left */
}
/*****
* 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;
/* Tests show true = 128...not clear why */
}
/* 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
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DBuffer* pIndexData, WINED3DFORMAT fmt) {
/* 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_GetIndices(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",
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
return WINED3DERR_INVALIDCALL;
return WINED3D_OK;
}
TRACE("(iface %p, srcData %p, start %d, count %d)\n",
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
int *dstData,
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
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)
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",
return WINED3DERR_INVALIDCALL;
return WINED3D_OK;
}
DWORD i;
for(i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i)
{
}
}
if (i != -1 && i != stage) {
}
if (j != -1 && 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) {
}
}
}
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);
if (i < MAX_TEXTURES) {
}
}
}
}
{
if (current_mapping == -1) {
/* Not currently used */
return TRUE;
}
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 */
return !vshader_sampler_tokens[current_mapping];
}
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) {
int vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
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
*/
if (ps) {
} else {
}
if (vs) {
}
}
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",
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
return WINED3DERR_INVALIDCALL;
return WINED3D_OK;
}
TRACE("(iface %p, srcData %p, start %u, count %u)\n",
for (i = 0; i < cnt; i++)
}
return WINED3D_OK;
}
int *dstData,
TRACE("(iface %p, dstData %p, start %d, count %d)\n",
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)
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",
return WINED3DERR_INVALIDCALL;
return WINED3D_OK;
}
{
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(!color_d) {
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(!color_s) {
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];
if(!tex_coord) {
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;
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.
*/
{
if (e->buffer_object)
{
e->buffer_object = 0;
ENTER_GL();
vb->buffer_object = 0;
LEAVE_GL();
}
}
}
}
/*****
* 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);
if (Stage >= MAX_TEXTURES) {
WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring\n", Stage, MAX_TEXTURES - 1);
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
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture* pTexture) {
}
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
/* SetTexture isn't allowed on textures in WINED3DPOOL_SCRATCH */
{
return WINED3DERR_INVALIDCALL;
}
/* Handle recording of state blocks */
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
if(oldTexture == pTexture) {
TRACE("App is setting the same texture again, nothing to do\n");
return WINED3D_OK;
}
/** NOTE: MSDN says that setTexture increases the reference count,
* and that the application must set the texture back to null (or have a leaky application),
* This means we should pass the refcount up to the parent
*******************************/
{
}
/* 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(bindCount == 1) {
}
/* More than one assignment? Doesn't matter, we only need one gl texture unit to use for uploading */
}
if (NULL != oldTexture) {
}
int i;
/* Have to do a search for the other sampler(s) where the texture is bound to
* Shouldn't happen as long as apps bind a texture only to one stage
*/
TRACE("Searcing for other sampler / stage id where the texture is bound to\n");
for(i = 0; i < MAX_COMBINED_SAMPLERS; 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
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UINT iSwapChain, UINT BackBuffer, WINED3DBACKBUFFER_TYPE Type,
TRACE("(%p) : BackBuf %d Type %d SwapChain %d returning %p\n", This, BackBuffer, Type, iSwapChain, *ppBackBuffer);
if (hr == WINED3D_OK) {
} else {
*ppBackBuffer = NULL;
}
return hr;
}
}
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) {
unsigned int i, j;
if (!This->isRecordingState) {
*ppStateBlock = NULL;
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
{
{
if (!(map & 1)) continue;
}
}
for (i = 0; i <= HIGHEST_TRANSFORMSTATE >> 5; ++i)
{
{
if (!(map & 1)) continue;
}
}
for(i = 0; i < GL_LIMITS(vshader_constantsF); i++) {
}
}
for(i = 0; i < MAX_CONST_I; i++) {
{
}
}
for(i = 0; i < MAX_CONST_B; i++) {
{
}
}
for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i)
{
{
}
}
for(i = 0; i < MAX_CONST_I; i++) {
{
}
}
for(i = 0; i < MAX_CONST_B; i++) {
{
}
}
for(i = 0; i < MAX_TEXTURES; i++) {
{
if (!(map & 1)) continue;
}
}
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){
{
if (!(map & 1)) continue;
}
}
/* 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;
}
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 */
glFlush();
/* 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;
}
/* Not called from the VTable (internal subroutine) */
HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
GLbitfield glMask = 0;
unsigned int i;
/* 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.
*/
while(1) {
break;
}
break;
}
break;
}
break;
}
}
ENTER_GL();
/* Only set the values up once, as they are not changing */
if (Flags & WINED3DCLEAR_STENCIL) {
checkGLcall("glClearStencil");
glStencilMask(0xFFFFFFFF);
}
if (Flags & WINED3DCLEAR_ZBUFFER) {
glClearDepth(Z);
checkGLcall("glClearDepth");
}
}
}
}
if (Flags & WINED3DCLEAR_TARGET) {
D3DCOLOR_A(Color));
checkGLcall("glClearColor");
/* Clear ALL colors! */
}
}
if(This->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(This->render_offscreen) {
} else {
}
checkGLcall("glScissor");
checkGLcall("glClear");
}
}
/* Restore the old values (why..?) */
if (Flags & WINED3DCLEAR_STENCIL) {
}
if (Flags & WINED3DCLEAR_TARGET) {
/* Dirtify the target surface for now. If the surface is locked regularly, and an up to date sysmem copy exists,
* it is most likely more efficient to perform a clear on the sysmem copy too instead of downloading it
*/
}
if (Flags & WINED3DCLEAR_ZBUFFER) {
/* Note that WINED3DCLEAR_ZBUFFER implies a depth stencil exists on the device */
}
LEAVE_GL();
if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)target, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
glFlush();
}
}
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 */
return WINED3D_OK;
}
{
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;
}
}
TRACE("(%p) : min %u, vertex count %u, startIdx %u, index count %u\n",
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;
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface, UINT MinVertexIndex,
{
int idxStride;
TRACE("(%p) : MinVtxIdx %u, NumVIdx %u, 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.
*/
drawPrimitive(iface, vertex_count, 0 /* numindices */, 0 /* start_idx */, idxSize, pIndexData, 0 /* minindex */);
return WINED3D_OK;
}
static HRESULT IWineD3DDeviceImpl_UpdateVolume(IWineD3DDevice *iface, IWineD3DVolume *pSourceVolume, IWineD3DVolume *pDestinationVolume) {
/* This is a helper function for UpdateTexture, there is no public UpdateVolume method in d3d. Since it's
* not callable by the app directly no parameter validation checks are needed here.
*/
/* TODO: Implement direct loading into the gl volume instead of using memcpy and
* dirtification to improve loading performance.
*/
return hr;
}
} else {
}
return hr;
}
/* Yet another way to update a texture, some apps use this to load default textures instead of using surface/texture lock/unlock */
static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture (IWineD3DDevice *iface, IWineD3DBaseTexture *pSourceTexture, IWineD3DBaseTexture *pDestinationTexture){
int i ,levels;
/* TODO: think about moving the code into IWineD3DBaseTexture */
/* verify that the source and destination textures aren't NULL */
WARN("(%p) : source (%p) and destination (%p) textures must not be NULL, returning WINED3DERR_INVALIDCALL\n",
}
if (pSourceTexture == pDestinationTexture) {
WARN("(%p) : source (%p) and destination (%p) textures must be different, returning WINED3DERR_INVALIDCALL\n",
}
/* Verify that the source and destination textures are the same type */
if (sourceType != destinationType) {
WARN("(%p) Sorce and destination types must match, returning WINED3DERR_INVALIDCALL\n",
This);
}
/* check that both textures have the identical numbers of levels */
if (IWineD3DBaseTexture_GetLevelCount(pDestinationTexture) != IWineD3DBaseTexture_GetLevelCount(pSourceTexture)) {
WARN("(%p) : source (%p) and destination (%p) textures must have identical numbers of levels, returning WINED3DERR_INVALIDCALL\n", This, pSourceTexture, pDestinationTexture);
}
if (WINED3D_OK == hr) {
/* Make sure that the destination texture is loaded */
/* Update every surface level of the texture */
switch (sourceType) {
case WINED3DRTYPE_TEXTURE:
{
for (i = 0 ; i < levels ; ++i) {
if (WINED3D_OK != hr) {
return hr;
}
}
}
break;
case WINED3DRTYPE_CUBETEXTURE:
{
for (i = 0 ; i < levels ; ++i) {
/* Update each cube face */
for (faceType = WINED3DCUBEMAP_FACE_POSITIVE_X; faceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++faceType){
hr = IWineD3DCubeTexture_GetCubeMapSurface((IWineD3DCubeTexture *)pSourceTexture, faceType, i, &srcSurface);
if (WINED3D_OK != hr) {
} else {
}
hr = IWineD3DCubeTexture_GetCubeMapSurface((IWineD3DCubeTexture *)pDestinationTexture, faceType, i, &destSurface);
if (WINED3D_OK != hr) {
} else {
}
if (WINED3D_OK != hr) {
return hr;
}
}
}
}
break;
{
for (i = 0 ; i < levels ; ++i) {
if (WINED3D_OK != hr) {
return hr;
}
}
}
break;
default:
}
}
return hr;
}
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;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface, UINT iSwapChain, WINED3DRASTER_STATUS* pRasterStatus) {
if(hr == WINED3D_OK){
}else{
}
return hr;
}
if(nSegments != 0.0f) {
if (!warned)
{
}
}
return WINED3D_OK;
}
if (!warned)
{
}
return 0.0f;
}
static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, IWineD3DSurface *pSourceSurface, CONST RECT* pSourceRect, IWineD3DSurface *pDestinationSurface, CONST POINT* pDestPoint) {
/** TODO: remove casts to IWineD3DSurfaceImpl
* NOTE: move code to surface to accomplish this
****************************************/
int offset = 0;
int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
int sampler;
int bpp;
TRACE("(%p) : Source (%p) Rect (%p) Destination (%p) Point(%p)\n", This, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
WARN("source %p must be SYSTEMMEM and dest %p must be DEFAULT, returning WINED3DERR_INVALIDCALL\n", pSourceSurface, pDestinationSurface);
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) {
pDestPoint ? pDestPoint->x : 0,
pDestPoint ? pDestPoint->y : 0,
pSourceSurface, pSourceRect, 0);
}
if (destFormat == WINED3DFMT_UNKNOWN) {
TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", This);
/* Get the update surface description */
}
ENTER_GL();
checkGLcall("glActiveTextureARB");
LEAVE_GL();
/* Make sure the surface is loaded and up to date */
/* this needs to be done in lines if the sourceRect != the sourceWidth */
/* This function doesn't support compressed textures
the pitch is just bytesPerPixel * width */
/* TODO: do we ever get 3bpp?, would a shift and an add be quicker than a mul (well maybe a cycle or two) */
}
/* TODO DXT formats */
}
TRACE("(%p) glTexSubImage2D, level %d, left %d, top %d, width %d, height %d, fmt %#x, type %#x, memory %p+%#x\n",
/* Sanity check */
/* need to lock the surface to get the data */
FIXME("Surfaces has no allocated memory, but should be an in memory only surface\n");
}
ENTER_GL();
/* TODO: Cube and volume support */
if(rowoffset != 0){
/* not a whole row so we have to do it a line at a time */
int j;
/* hopefully using pointer addition will be quicker than using a point + j * rowoffset */
const unsigned char* data =((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
{
}
} else { /* Full width, so just write out the whole texture */
const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
if (WINED3DFMT_DXT1 == destFormat ||
WINED3DFMT_DXT2 == destFormat ||
WINED3DFMT_DXT3 == destFormat ||
WINED3DFMT_DXT4 == destFormat ||
WINED3DFMT_DXT5 == destFormat) {
/* FIXME: The easy way to do this is to lock the destination, and copy the bits across */
FIXME("Updating part of a compressed texture is not supported at the moment\n");
} if (destFormat != srcFormat) {
FIXME("Updating mixed format compressed texture is not curretly support\n");
} else {
}
} else {
FIXME("Attempting to update a DXT compressed texture without hardware support\n");
}
} else {
}
}
checkGLcall("glTexSubImage2D");
LEAVE_GL();
if (sampler != -1) {
}
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;
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawTriPatch(IWineD3DDevice *iface, UINT Handle, CONST float* pNumSegs, CONST WINED3DTRIPATCH_INFO* pTriPatchInfo) {
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;
}
return swapchain;
}
return NULL;
}
{
if (swapchain) {
ENTER_GL();
checkGLcall("glDrawBuffer()");
} else {
ENTER_GL();
GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0));
checkGLcall("glFramebufferRenderbufferEXT");
}
if (rect) {
if(!swapchain) {
} else {
}
checkGLcall("glScissor");
} else {
}
checkGLcall("glClear");
} else {
checkGLcall("glBindFramebuffer()");
}
checkGLcall("glDrawBuffer()");
}
LEAVE_GL();
}
unsigned int r, g, b, a;
return color;
b = (color & 0x000000ff) >> 0;
switch(destfmt)
{
case WINED3DFMT_R5G6B5:
if(r == 0xff && g == 0xff && b == 0xff) return 0xffff;
r = (r * 32) / 256;
g = (g * 64) / 256;
b = (b * 32) / 256;
ret = r << 11;
ret |= g << 5;
ret |= b;
return ret;
case WINED3DFMT_X1R5G5B5:
case WINED3DFMT_A1R5G5B5:
a = (a * 2) / 256;
r = (r * 32) / 256;
g = (g * 32) / 256;
b = (b * 32) / 256;
ret = a << 15;
ret |= r << 10;
ret |= g << 5;
ret |= b << 0;
return ret;
case WINED3DFMT_A8_UNORM:
TRACE("Returning %08x\n", a);
return a;
case WINED3DFMT_X4R4G4B4:
case WINED3DFMT_A4R4G4B4:
a = (a * 16) / 256;
r = (r * 16) / 256;
g = (g * 16) / 256;
b = (b * 16) / 256;
ret = a << 12;
ret |= r << 8;
ret |= g << 4;
ret |= b << 0;
return ret;
case WINED3DFMT_R3G3B2:
r = (r * 8) / 256;
g = (g * 8) / 256;
b = (b * 4) / 256;
ret = r << 5;
ret |= g << 2;
ret |= b << 0;
return ret;
case WINED3DFMT_X8B8G8R8:
ret = a << 24;
ret |= b << 16;
ret |= g << 8;
ret |= r << 0;
return ret;
case WINED3DFMT_A2R10G10B10:
a = (a * 4) / 256;
r = (r * 1024) / 256;
g = (g * 1024) / 256;
b = (b * 1024) / 256;
ret = a << 30;
ret |= r << 20;
ret |= g << 10;
ret |= b << 0;
return ret;
a = (a * 4) / 256;
r = (r * 1024) / 256;
g = (g * 1024) / 256;
b = (b * 1024) / 256;
ret = a << 30;
ret |= b << 20;
ret |= g << 10;
ret |= r << 0;
return ret;
default:
return 0;
}
}
static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, IWineD3DSurface *pSurface, CONST WINED3DRECT* pRect, WINED3DCOLOR color) {
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 = argb_to_fmt(c, ((IWineD3DSurfaceImpl *)surface)->resource.format_desc->format);
{
}
}
}
/* rendertarget and depth stencil functions */
static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice* iface,DWORD RenderTargetIndex, IWineD3DSurface **ppRenderTarget) {
return WINED3DERR_INVALIDCALL;
}
/* Note inc ref on returned surface */
if(*ppRenderTarget != NULL)
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *iface, IWineD3DSurface *Front, IWineD3DSurface *Back) {
if(hr != WINED3D_OK) {
ERR("Can't get the swapchain\n");
return hr;
}
/* Make sure to release the swapchain */
ERR("Trying to set a front buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage\n");
return WINED3DERR_INVALIDCALL;
}
ERR("Trying to set a back buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage\n");
return WINED3DERR_INVALIDCALL;
}
if(Swapchain->frontBuffer)
{
}
if(Swapchain->frontBuffer) {
}
}
/* We need memory for the back buffer array - only one back buffer this way */
if(!Swapchain->backBuffer) {
ERR("Out of memory\n");
return E_OUTOFMEMORY;
}
}
/* What to do about the context here in the case of multithreading? Not sure.
* This function is called by IDirect3D7::CreateDevice so in theory its initialization code
*/
ENTER_GL();
if(!Swapchain->backBuffer[0]) {
/* GL was told to draw to the front buffer at creation,
* undo that
*/
checkGLcall("glDrawBuffer(GL_BACK)");
/* Set the backbuffer count to 1 because other code uses it to fing the back buffers */
} else if (!Back) {
/* That makes problems - disable for now */
/* glDrawBuffer(GL_FRONT); */
checkGLcall("glDrawBuffer(GL_FRONT)");
/* We have lost our back buffer, set this to 0 to avoid confusing other code */
}
LEAVE_GL();
if(Swapchain->backBuffer[0])
{
}
if(Swapchain->backBuffer[0]) {
} 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;
}
}
IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
{
TRACE("(%p) : src_surface %p, src_rect %p, dst_surface %p, dst_rect %p, filter %s (0x%08x), flip %u\n",
This, src_surface, src_rect, dst_surface, dst_rect, debug_d3dtexturefiltertype(filter), filter, flip);
switch (filter) {
case WINED3DTEXF_LINEAR:
break;
default:
case WINED3DTEXF_NONE:
case WINED3DTEXF_POINT:
break;
}
/* Attach src surface to src fbo */
if (src_swapchain) {
/* Make sure the drawable is up to date. In the offscreen case
* attach_surface_fbo() implicitly takes care of this. */
UINT h;
} else {
}
ENTER_GL();
checkGLcall("glReadBuffer()");
} else {
ENTER_GL();
checkGLcall("glReadBuffer()");
GL_EXTCALL(glFramebufferRenderbufferEXT(GL_READ_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0));
checkGLcall("glFramebufferRenderbufferEXT");
}
LEAVE_GL();
/* Attach dst surface to dst fbo */
if (dst_swapchain) {
/* Make sure the drawable is up to date. In the offscreen case
* attach_surface_fbo() implicitly takes care of this. */
UINT h;
} else {
/* Screen coords = window coords, surface height = window height */
}
ENTER_GL();
checkGLcall("glDrawBuffer()");
} else {
/* No src or dst swapchain? Make sure some context is active(multithreading) */
if(!src_swapchain) {
}
ENTER_GL();
checkGLcall("glDrawBuffer()");
GL_EXTCALL(glFramebufferRenderbufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0));
checkGLcall("glFramebufferRenderbufferEXT");
}
if (flip) {
checkGLcall("glBlitFramebuffer()");
} else {
checkGLcall("glBlitFramebuffer()");
}
} else {
checkGLcall("glBindFramebuffer()");
}
/* If we switched from GL_BACK to GL_FRONT above, we need to switch back here */
checkGLcall("glDrawBuffer()");
}
LEAVE_GL();
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget) {
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) {
/* Finally, reset the viewport as the MSDN states. */
viewport.X = 0;
viewport.Y = 0;
/* Make sure the viewport state is dirty, because the render_offscreen thing affects it.
* SetViewport may catch NOP viewport changes, which would occur when switching between equally sized targets
*/
}
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 {
}
}
/* 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.
*/
{
/* Reformat the texture memory (pitch and width can be
* different) */
for(i = 0; i < height; i++)
ENTER_GL();
if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) {
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
/* Make sure that a proper texture unit is selected */
checkGLcall("glActiveTextureARB");
if (sampler != -1) {
}
/* Create a new cursor texture */
checkGLcall("glGenTextures");
checkGLcall("glBindTexture");
/* Copy the bitmap memory into the cursor texture */
checkGLcall("glTexImage2D");
if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) {
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. */
);
1, &maskBits);
/* 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;
}
/* TODO: Implement wrapping of the WndProc so that mimimize and maximize can be monitored and the states adjusted. */
case WINED3D_OK:
return WINED3D_OK;
case WINED3DERR_DEVICELOST:
{
LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry) {
return WINED3DERR_DEVICENOTRESET;
}
return WINED3DERR_DEVICELOST;
}
return WINED3DERR_DRIVERINTERNALERROR;
}
/* Unknown state */
return WINED3DERR_DRIVERINTERNALERROR;
}
/** FIXME: Resource tracking needs to be done,
* The closes we can do to this is set the priorities of all managed textures low
* and then reset them.
***********************************************************/
return WINED3D_OK;
}
static void 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 {
}
ENTER_GL();
LEAVE_GL();
}
} else {
}
surface->resource.size = IWineD3DSurface_GetPitch((IWineD3DSurface *) surface) * surface->pow2Width;
/* INDRAWABLE is a sane place for implicit targets after the reset, INSYSMEM is more appropriate for depth stencils. */
} else {
}
}
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;
}
UINT i;
}
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();
ENTER_GL();
/* Textures are recreated below */
checkGLcall("glDeleteTextures(1, &This->dummyTextureName[i])");
This->dummyTextureName[i] = 0;
}
LEAVE_GL();
while(This->numContexts) {
}
swapchain->num_contexts = 0;
}
/* Recreate the primary swapchain's context */
if(swapchain->backBuffer) {
} else {
}
ERR("Failed to recreate shader private data\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;
}
return WINED3D_OK;
return hr;
}
static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters) {
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
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) {
}
}
if(This->auto_depth_stencil_buffer) {
}
}
/* switch from windowed to fs */
} else {
/* Fullscreen -> fullscreen mode change */
TRUE);
}
/* 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.
*/
}
TRACE("Resetting stateblock\n");
/* Note: No parent needed for initial internal stateblock */
hr = IWineD3DDevice_CreateStateBlock(iface, WINED3DSBT_INIT, (IWineD3DStateBlock **)&This->stateBlock, NULL);
}
/* 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 bEnableDialogs) {
/** FIXME: always true at the moment **/
if(!bEnableDialogs) {
}
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");
}
return;
}
static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT iSwapChain, WINED3DGAMMARAMP* pRamp) {
TRACE("Relaying to swapchain\n");
}
return;
}
/** ********************************************************
* 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;
/* Cleanup any FBO attachments if d3d is enabled */
if(This->d3d_initialized) {
IWineD3DSwapChainImpl *swapchain = This->swapchains ? (IWineD3DSwapChainImpl *) This->swapchains[0] : NULL;
TRACE("Last active render target destroyed\n");
/* Find a replacement surface for the currently active back buffer. The context manager does not do NULL
* checks, so switch to a valid target as long as the currently set surface is still valid. Use the
* surface of the implicit swpchain. If that is the same as the destroyed surface the device is destroyed
* and the lastActiveRenderTarget member shouldn't matter
*/
if(swapchain) {
TRACE("Activating primary back buffer\n");
/* Single buffering environment */
TRACE("Activating primary front buffer\n");
} else {
TRACE("Device is being destroyed, setting lastActiveRenderTarget = 0xdeadbabe\n");
/* Implicit render target destroyed, that means the device is being destroyed
* whatever we set here, it shouldn't matter
*/
}
} else {
/* May happen during ddraw uninitialization */
TRACE("Render target set, but swapchain does not exist!\n");
}
}
}
}
}
}
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;
}
/**********************************************************
* IWineD3DDevice VTbl follows
**********************************************************/
{
/*** IUnknown methods ***/
/*** IWineD3DDevice methods ***/
/*** Creation methods**/
/*** Odd functions **/
/*** Getters and setters **/
/*** State block ***/
/*** Scene management ***/
/*** Drawing ***/
/*** object tracking ***/
};
};
};
};
};
};
};
UINT i;
if(!rep) return;
for(i = 0; i < This->numContexts; i++) {
}
}
/* The drawable size of a pbuffer render target is the current pbuffer size
*/
}
/* The drawable size of a fbo target is the opengl texture size, which is the power of two size
*/
}
/* 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. The back buffer of the swapchain is stored as the
* surface the context belongs to.
*/
}