2004-12-09 12:42:34 +01:00
|
|
|
|
/*
|
|
|
|
|
* WINED3D draw functions
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2002-2004 Jason Edmeades
|
|
|
|
|
* Copyright 2002-2004 Raphael Junqueira
|
2005-07-13 16:15:54 +02:00
|
|
|
|
* Copyright 2004 Christian Costa
|
2005-07-11 16:25:54 +02:00
|
|
|
|
* Copyright 2005 Oliver Stieber
|
2006-11-17 13:24:04 +01:00
|
|
|
|
* Copyright 2006 Henri Verbeet
|
2007-02-14 17:56:29 +01:00
|
|
|
|
* Copyright 2007 Stefan D<EFBFBD>singer for CodeWeavers
|
2004-12-09 12:42:34 +01:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-12-09 12:42:34 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
|
|
|
|
|
|
2005-09-27 12:49:59 +02:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
#if 0 /* TODO */
|
2005-08-19 12:05:00 +02:00
|
|
|
|
extern IWineD3DVertexShaderImpl* VertexShaders[64];
|
|
|
|
|
extern IWineD3DVertexDeclarationImpl* VertexShaderDeclarations[64];
|
|
|
|
|
extern IWineD3DPixelShaderImpl* PixelShaders[64];
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
|
|
#undef GL_VERSION_1_4 /* To be fixed, caused by mesa headers */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Issues the glBegin call for gl given the primitive type and count */
|
2006-10-12 08:23:55 +02:00
|
|
|
|
static DWORD primitiveToGl(WINED3DPRIMITIVETYPE PrimitiveType,
|
2004-12-09 12:42:34 +01:00
|
|
|
|
DWORD NumPrimitives,
|
|
|
|
|
GLenum *primType)
|
|
|
|
|
{
|
|
|
|
|
DWORD NumVertexes = NumPrimitives;
|
|
|
|
|
|
|
|
|
|
switch (PrimitiveType) {
|
2006-10-12 08:23:55 +02:00
|
|
|
|
case WINED3DPT_POINTLIST:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("POINTS\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
|
*primType = GL_POINTS;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
NumVertexes = NumPrimitives;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-12 08:23:55 +02:00
|
|
|
|
case WINED3DPT_LINELIST:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("LINES\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
|
*primType = GL_LINES;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
NumVertexes = NumPrimitives * 2;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-12 08:23:55 +02:00
|
|
|
|
case WINED3DPT_LINESTRIP:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("LINE_STRIP\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
|
*primType = GL_LINE_STRIP;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
NumVertexes = NumPrimitives + 1;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-12 08:23:55 +02:00
|
|
|
|
case WINED3DPT_TRIANGLELIST:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("TRIANGLES\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
|
*primType = GL_TRIANGLES;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
NumVertexes = NumPrimitives * 3;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-12 08:23:55 +02:00
|
|
|
|
case WINED3DPT_TRIANGLESTRIP:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("TRIANGLE_STRIP\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
|
*primType = GL_TRIANGLE_STRIP;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
NumVertexes = NumPrimitives + 2;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-12 08:23:55 +02:00
|
|
|
|
case WINED3DPT_TRIANGLEFAN:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("TRIANGLE_FAN\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
|
*primType = GL_TRIANGLE_FAN;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
NumVertexes = NumPrimitives + 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
FIXME("Unhandled primitive\n");
|
|
|
|
|
*primType = GL_POINTS;
|
|
|
|
|
break;
|
2005-07-13 16:15:54 +02:00
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
return NumVertexes;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-07 08:24:24 +02:00
|
|
|
|
static BOOL fixed_get_input(
|
|
|
|
|
BYTE usage, BYTE usage_idx,
|
|
|
|
|
unsigned int* regnum) {
|
|
|
|
|
|
|
|
|
|
*regnum = -1;
|
|
|
|
|
|
|
|
|
|
/* Those positions must have the order in the
|
|
|
|
|
* named part of the strided data */
|
|
|
|
|
|
2007-02-13 23:12:14 +01:00
|
|
|
|
if ((usage == WINED3DDECLUSAGE_POSITION || usage == WINED3DDECLUSAGE_POSITIONT) && usage_idx == 0)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 0;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_BLENDWEIGHT && usage_idx == 0)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 1;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_BLENDINDICES && usage_idx == 0)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 2;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_NORMAL && usage_idx == 0)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 3;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_PSIZE && usage_idx == 0)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 4;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_COLOR && usage_idx == 0)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 5;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_COLOR && usage_idx == 1)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 6;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_TEXCOORD && usage_idx < WINED3DDP_MAXTEXCOORD)
|
2006-07-07 08:24:24 +02:00
|
|
|
|
*regnum = 7 + usage_idx;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if ((usage == WINED3DDECLUSAGE_POSITION || usage == WINED3DDECLUSAGE_POSITIONT) && usage_idx == 1)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 7 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_NORMAL && usage_idx == 1)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 8 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_TANGENT && usage_idx == 0)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 9 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_BINORMAL && usage_idx == 0)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 10 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_TESSFACTOR && usage_idx == 0)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 11 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_FOG && usage_idx == 0)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 12 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_DEPTH && usage_idx == 0)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 13 + WINED3DDP_MAXTEXCOORD;
|
2007-02-13 23:12:14 +01:00
|
|
|
|
else if (usage == WINED3DDECLUSAGE_SAMPLE && usage_idx == 0)
|
2006-10-12 08:24:43 +02:00
|
|
|
|
*regnum = 14 + WINED3DDP_MAXTEXCOORD;
|
2006-07-07 08:24:24 +02:00
|
|
|
|
|
|
|
|
|
if (*regnum < 0) {
|
|
|
|
|
FIXME("Unsupported input stream [usage=%s, usage_idx=%u]\n",
|
|
|
|
|
debug_d3ddeclusage(usage), usage_idx);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-12 08:51:58 +02:00
|
|
|
|
void primitiveDeclarationConvertToStridedData(
|
|
|
|
|
IWineD3DDevice *iface,
|
|
|
|
|
BOOL useVertexShaderFunction,
|
|
|
|
|
WineDirect3DVertexStridedData *strided,
|
2006-06-21 15:01:38 +02:00
|
|
|
|
BOOL *fixup) {
|
2006-06-12 08:51:58 +02:00
|
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
|
/* We need to deal with frequency data!*/
|
|
|
|
|
|
|
|
|
|
BYTE *data = NULL;
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2007-02-13 23:12:29 +01:00
|
|
|
|
IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
|
2005-07-07 22:45:39 +02:00
|
|
|
|
int i;
|
2005-12-09 11:23:52 +01:00
|
|
|
|
WINED3DVERTEXELEMENT *element;
|
2005-07-07 22:45:39 +02:00
|
|
|
|
DWORD stride;
|
2006-03-22 20:47:54 +01:00
|
|
|
|
int reg;
|
2007-01-06 18:31:43 +01:00
|
|
|
|
char isPreLoaded[MAX_STREAMS];
|
|
|
|
|
DWORD preLoadStreams[MAX_STREAMS], numPreloadStreams = 0;
|
|
|
|
|
|
|
|
|
|
memset(isPreLoaded, 0, sizeof(isPreLoaded));
|
2005-07-07 22:45:39 +02:00
|
|
|
|
|
2007-03-12 23:22:00 +01:00
|
|
|
|
/* Check for transformed vertices, disable vertex shader if present */
|
|
|
|
|
strided->u.s.position_transformed = FALSE;
|
|
|
|
|
for (i = 0; i < vertexDeclaration->declarationWNumElements - 1; ++i) {
|
|
|
|
|
element = vertexDeclaration->pDeclarationWine + i;
|
|
|
|
|
|
|
|
|
|
if (element->Usage == WINED3DDECLUSAGE_POSITIONT) {
|
|
|
|
|
strided->u.s.position_transformed = TRUE;
|
|
|
|
|
useVertexShaderFunction = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-09 11:23:52 +01:00
|
|
|
|
/* Translate the declaration into strided data */
|
|
|
|
|
for (i = 0 ; i < vertexDeclaration->declarationWNumElements - 1; ++i) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
GLint streamVBO = 0;
|
2006-07-07 08:24:24 +02:00
|
|
|
|
BOOL stride_used;
|
|
|
|
|
unsigned int idx;
|
2005-12-09 11:23:52 +01:00
|
|
|
|
|
|
|
|
|
element = vertexDeclaration->pDeclarationWine + i;
|
2006-09-17 22:26:18 +02:00
|
|
|
|
TRACE("%p Element %p (%d of %d)\n", vertexDeclaration->pDeclarationWine,
|
|
|
|
|
element, i + 1, vertexDeclaration->declarationWNumElements - 1);
|
|
|
|
|
|
|
|
|
|
if (This->stateBlock->streamSource[element->Stream] == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
|
if (This->stateBlock->streamIsUP) {
|
|
|
|
|
TRACE("Stream is up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
|
2006-06-21 15:01:38 +02:00
|
|
|
|
streamVBO = 0;
|
2005-07-07 22:45:39 +02:00
|
|
|
|
data = (BYTE *)This->stateBlock->streamSource[element->Stream];
|
|
|
|
|
} else {
|
2005-07-24 19:11:33 +02:00
|
|
|
|
TRACE("Stream isn't up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
|
2007-01-06 18:31:43 +01:00
|
|
|
|
if(!isPreLoaded[element->Stream]) {
|
|
|
|
|
preLoadStreams[numPreloadStreams] = element->Stream;
|
|
|
|
|
numPreloadStreams++;
|
|
|
|
|
isPreLoaded[element->Stream] = 1;
|
|
|
|
|
}
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[element->Stream], 0, &streamVBO);
|
|
|
|
|
if(fixup) {
|
|
|
|
|
if( streamVBO != 0) *fixup = TRUE;
|
2007-03-12 23:22:00 +01:00
|
|
|
|
else if(*fixup && !useVertexShaderFunction) {
|
2007-02-20 22:42:34 +01:00
|
|
|
|
/* This may be bad with the fixed function pipeline */
|
|
|
|
|
FIXME("Missing fixed and unfixed vertices, expect graphics glitches\n");
|
|
|
|
|
}
|
2006-06-21 15:01:38 +02:00
|
|
|
|
}
|
2005-07-07 22:45:39 +02:00
|
|
|
|
}
|
2005-07-11 16:25:54 +02:00
|
|
|
|
stride = This->stateBlock->streamStride[element->Stream];
|
2005-07-07 22:45:39 +02:00
|
|
|
|
data += element->Offset;
|
2006-03-22 20:47:54 +01:00
|
|
|
|
reg = element->Reg;
|
2005-12-09 11:23:52 +01:00
|
|
|
|
|
|
|
|
|
TRACE("Offset %d Stream %d UsageIndex %d\n", element->Offset, element->Stream, element->UsageIndex);
|
2006-03-22 20:47:54 +01:00
|
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
|
if (useVertexShaderFunction)
|
|
|
|
|
stride_used = vshader_get_input(This->stateBlock->vertexShader,
|
|
|
|
|
element->Usage, element->UsageIndex, &idx);
|
|
|
|
|
else
|
|
|
|
|
stride_used = fixed_get_input(element->Usage, element->UsageIndex, &idx);
|
|
|
|
|
|
2006-07-07 08:24:24 +02:00
|
|
|
|
if (stride_used) {
|
2007-03-12 23:21:49 +01:00
|
|
|
|
TRACE("Loaded %s array %u [usage=%s, usage_idx=%u, "
|
|
|
|
|
"stream=%u, offset=%u, stride=%u, VBO=%u]\n",
|
|
|
|
|
useVertexShaderFunction? "shader": "fixed function", idx,
|
|
|
|
|
debug_d3ddeclusage(element->Usage), element->UsageIndex,
|
|
|
|
|
element->Stream, element->Offset, stride, streamVBO);
|
|
|
|
|
|
|
|
|
|
strided->u.input[idx].lpData = data;
|
|
|
|
|
strided->u.input[idx].dwType = element->Type;
|
|
|
|
|
strided->u.input[idx].dwStride = stride;
|
|
|
|
|
strided->u.input[idx].VBO = streamVBO;
|
|
|
|
|
strided->u.input[idx].streamNo = element->Stream;
|
2005-07-07 22:45:39 +02:00
|
|
|
|
}
|
2007-03-12 23:21:49 +01:00
|
|
|
|
}
|
2007-01-06 18:31:43 +01:00
|
|
|
|
/* 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 < numPreloadStreams; i++) {
|
2007-03-12 23:21:49 +01:00
|
|
|
|
IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[preLoadStreams[i]]);
|
2007-01-06 18:31:43 +01:00
|
|
|
|
}
|
2005-07-07 22:45:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-16 23:58:29 +01:00
|
|
|
|
void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDirect3DVertexStridedData *strided, GLint streamVBO, UINT streamNo) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
int numBlends;
|
|
|
|
|
int numTextures;
|
|
|
|
|
int textureNo;
|
|
|
|
|
int coordIdxInfo = 0x00; /* Information on number of coords supplied */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
int numCoords[8]; /* Holding place for WINED3DFVF_TEXTUREFORMATx */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
|
/* Either 3 or 4 floats depending on the FVF */
|
|
|
|
|
/* FIXME: Can blending data be in a different stream to the position data?
|
|
|
|
|
and if so using the fixed pipeline how do we handle it */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_POSITION_MASK) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.position.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT3;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.position.dwStride = stride;
|
|
|
|
|
strided->u.s.position.VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.position.streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += 3 * sizeof(float);
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_XYZRHW) {
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT4;
|
2006-07-07 15:15:20 +02:00
|
|
|
|
strided->u.s.position_transformed = TRUE;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(float);
|
2006-07-07 15:15:20 +02:00
|
|
|
|
} else
|
|
|
|
|
strided->u.s.position_transformed = FALSE;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */
|
|
|
|
|
/** do we have to Check This->stateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
numBlends = 1 + (((thisFVF & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1);
|
|
|
|
|
if(thisFVF & WINED3DFVF_LASTBETA_UBYTE4) numBlends--;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if ((thisFVF & WINED3DFVF_XYZB5 ) > WINED3DFVF_XYZRHW) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
TRACE("Setting blend Weights to %p\n", data);
|
|
|
|
|
strided->u.s.blendWeights.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.blendWeights.dwType = WINED3DDECLTYPE_FLOAT1 + numBlends - 1;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.blendWeights.dwStride = stride;
|
|
|
|
|
strided->u.s.blendWeights.VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.blendWeights.streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += numBlends * sizeof(FLOAT);
|
|
|
|
|
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_LASTBETA_UBYTE4) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.blendMatrixIndices.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.blendMatrixIndices.dwType = WINED3DDECLTYPE_UBYTE4;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.blendMatrixIndices.dwStride= stride;
|
|
|
|
|
strided->u.s.blendMatrixIndices.VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.blendMatrixIndices.streamNo= streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(DWORD);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Normal is always 3 floats */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_NORMAL) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.normal.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.normal.dwType = WINED3DDECLTYPE_FLOAT3;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.normal.dwStride = stride;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.normal.VBO = streamVBO;
|
|
|
|
|
strided->u.s.normal.streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += 3 * sizeof(FLOAT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pointsize is a single float */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_PSIZE) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.pSize.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.pSize.dwType = WINED3DDECLTYPE_FLOAT1;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.pSize.dwStride = stride;
|
|
|
|
|
strided->u.s.pSize.VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.pSize.streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(FLOAT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Diffuse is 4 unsigned bytes */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_DIFFUSE) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.diffuse.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.diffuse.dwType = WINED3DDECLTYPE_SHORT4;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.diffuse.dwStride = stride;
|
|
|
|
|
strided->u.s.diffuse.VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.diffuse.streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(DWORD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Specular is 4 unsigned bytes */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (thisFVF & WINED3DFVF_SPECULAR) {
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.specular.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.specular.dwType = WINED3DDECLTYPE_SHORT4;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.specular.dwStride = stride;
|
|
|
|
|
strided->u.s.specular.VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.specular.streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(DWORD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Texture coords */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
numTextures = (thisFVF & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
|
|
|
|
coordIdxInfo = (thisFVF & 0x00FF0000) >> 16; /* 16 is from definition of WINED3DFVF_TEXCOORDSIZE1, and is 8 (0-7 stages) * 2bits long */
|
2006-06-21 15:01:38 +02:00
|
|
|
|
|
|
|
|
|
/* numTextures indicates the number of texture coordinates supplied */
|
|
|
|
|
/* However, the first set may not be for stage 0 texture - it all */
|
2006-10-11 03:52:50 +02:00
|
|
|
|
/* depends on WINED3DTSS_TEXCOORDINDEX. */
|
2006-06-21 15:01:38 +02:00
|
|
|
|
/* The number of bytes for each coordinate set is based off */
|
2006-10-31 09:16:08 +01:00
|
|
|
|
/* WINED3DFVF_TEXCOORDSIZEn, which are the bottom 2 bits */
|
2006-06-21 15:01:38 +02:00
|
|
|
|
|
|
|
|
|
/* So, for each supplied texture extract the coords */
|
|
|
|
|
for (textureNo = 0; textureNo < numTextures; ++textureNo) {
|
|
|
|
|
|
|
|
|
|
strided->u.s.texCoords[textureNo].lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT1;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
strided->u.s.texCoords[textureNo].dwStride = stride;
|
|
|
|
|
strided->u.s.texCoords[textureNo].VBO = streamVBO;
|
2007-01-16 23:58:29 +01:00
|
|
|
|
strided->u.s.texCoords[textureNo].streamNo = streamNo;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
numCoords[textureNo] = coordIdxInfo & 0x03;
|
|
|
|
|
|
|
|
|
|
/* Always one set */
|
|
|
|
|
data += sizeof(float);
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT1) {
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT2;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(float);
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT2) {
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT3;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(float);
|
2006-10-31 09:16:08 +01:00
|
|
|
|
if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT3) {
|
2006-10-11 03:54:22 +02:00
|
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT4;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
data += sizeof(float);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
coordIdxInfo = coordIdxInfo >> 2; /* Drop bottom two bits */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-02 21:07:39 +01:00
|
|
|
|
void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, BOOL *fixup) {
|
2007-02-19 15:26:31 +01:00
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
|
2006-06-21 15:01:38 +02:00
|
|
|
|
GLint streamVBO = 0;
|
2007-02-19 15:26:31 +01:00
|
|
|
|
DWORD stride = This->stateBlock->streamStride[0];
|
|
|
|
|
BYTE *data = NULL;
|
|
|
|
|
DWORD thisFVF = 0;
|
|
|
|
|
|
|
|
|
|
/* Retrieve appropriate FVF */
|
|
|
|
|
thisFVF = This->stateBlock->fvf;
|
|
|
|
|
/* Handle memory passed directly as well as vertex buffers */
|
|
|
|
|
if (This->stateBlock->streamIsUP) {
|
|
|
|
|
streamVBO = 0;
|
|
|
|
|
data = (BYTE *)This->stateBlock->streamSource[0];
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
2007-02-19 15:26:31 +01:00
|
|
|
|
/* The for loop should iterate through here only once per stream, so we don't need magic to prevent double loading
|
|
|
|
|
* buffers
|
|
|
|
|
*/
|
|
|
|
|
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[0], 0, &streamVBO);
|
|
|
|
|
if(fixup) {
|
|
|
|
|
if(streamVBO != 0 ) *fixup = TRUE;
|
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
2007-02-19 15:26:31 +01:00
|
|
|
|
VTRACE(("FVF for stream 0 is %lx\n", thisFVF));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2007-02-19 15:26:31 +01:00
|
|
|
|
/* Now convert the stream into pointers */
|
|
|
|
|
primitiveConvertFVFtoOffset(thisFVF, stride, data, strided, streamVBO, 0);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2007-02-19 15:26:31 +01:00
|
|
|
|
/* Now call PreLoad on the vertex buffer. In the very rare case
|
2007-01-06 18:31:43 +01:00
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2007-02-19 15:26:31 +01:00
|
|
|
|
if(!This->stateBlock->streamIsUP) {
|
|
|
|
|
IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[0]);
|
2007-01-06 18:31:43 +01:00
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
|
static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum glPrimitiveType,
|
2007-01-02 21:07:39 +01:00
|
|
|
|
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) {
|
2005-08-19 12:05:00 +02:00
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2007-02-19 15:25:32 +01:00
|
|
|
|
if (idxSize != 0 /* This crashes sometimes!*/) {
|
2006-10-01 05:20:10 +02:00
|
|
|
|
TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex);
|
2005-08-19 12:05:00 +02:00
|
|
|
|
idxData = idxData == (void *)-1 ? NULL : idxData;
|
|
|
|
|
#if 1
|
|
|
|
|
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
|
|
|
|
|
(const char *)idxData+(idxSize * startIdx));
|
|
|
|
|
#else /* using drawRangeElements may be faster */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
|
glDrawRangeElements(glPrimitiveType, minIndex, minIndex + numberOfVertices - 1, numberOfVertices,
|
|
|
|
|
idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
|
|
|
|
|
(const char *)idxData+(idxSize * startIdx));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
#endif
|
|
|
|
|
checkGLcall("glDrawRangeElements");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
/* Note first is now zero as we shuffled along earlier */
|
2005-08-19 12:05:00 +02:00
|
|
|
|
TRACE("(%p) : glDrawArrays(%x, 0, %d)\n", This, glPrimitiveType, numberOfVertices);
|
2007-01-02 21:07:39 +01:00
|
|
|
|
glDrawArrays(glPrimitiveType, startVertex, numberOfVertices);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
checkGLcall("glDrawArrays");
|
|
|
|
|
|
|
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
|
|
return;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-13 16:15:54 +02:00
|
|
|
|
/*
|
2004-12-09 12:42:34 +01:00
|
|
|
|
* Actually draw using the supplied information.
|
|
|
|
|
* Slower GL version which extracts info about each vertex in turn
|
|
|
|
|
*/
|
2007-01-02 21:07:39 +01:00
|
|
|
|
|
2006-05-06 16:58:57 +02:00
|
|
|
|
static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
|
2005-08-19 12:05:00 +02:00
|
|
|
|
UINT NumVertexes, GLenum glPrimType,
|
2007-01-02 21:07:39 +01:00
|
|
|
|
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
|
|
unsigned int textureNo = 0;
|
2006-06-27 23:44:26 +02:00
|
|
|
|
unsigned int texture_idx = 0;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
const short *pIdxBufS = NULL;
|
|
|
|
|
const long *pIdxBufL = NULL;
|
|
|
|
|
LONG vx_index;
|
|
|
|
|
float x = 0.0f, y = 0.0f, z = 0.0f; /* x,y,z coordinates */
|
|
|
|
|
float rhw = 0.0f; /* rhw */
|
|
|
|
|
DWORD diffuseColor = 0xFFFFFFFF; /* Diffuse Color */
|
|
|
|
|
DWORD specularColor = 0; /* Specular Color */
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2007-01-17 00:06:34 +01:00
|
|
|
|
UINT *streamOffset = This->stateBlock->streamOffset;
|
2007-01-06 18:19:55 +01:00
|
|
|
|
LONG SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2007-01-17 00:06:34 +01:00
|
|
|
|
BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
|
|
|
|
|
BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("Using slow vertex array code\n");
|
|
|
|
|
|
|
|
|
|
/* Variable Initialization */
|
2007-02-19 15:25:32 +01:00
|
|
|
|
if (idxSize != 0) {
|
|
|
|
|
/* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer.
|
|
|
|
|
* If the index buffer has no vbo(not supported or other reason), or with user pointer drawing
|
|
|
|
|
* idxData will be != NULL
|
|
|
|
|
*/
|
|
|
|
|
if(idxData == NULL) {
|
|
|
|
|
idxData = ((IWineD3DIndexBufferImpl *) This->stateBlock->pIndexData)->resource.allocatedMemory;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
if (idxSize == 2) pIdxBufS = (const short *) idxData;
|
|
|
|
|
else pIdxBufL = (const long *) idxData;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-17 00:06:34 +01:00
|
|
|
|
/* Adding the stream offset once is cheaper than doing it every iteration. Do not modify the strided data, it is a pointer
|
|
|
|
|
* to the strided Data in the device and might be needed intact on the next draw
|
|
|
|
|
*/
|
|
|
|
|
for (textureNo = 0, texture_idx = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
|
|
|
|
|
if(sd->u.s.texCoords[textureNo].lpData) {
|
|
|
|
|
texCoords[textureNo] = sd->u.s.texCoords[textureNo].lpData + streamOffset[sd->u.s.texCoords[textureNo].streamNo];
|
|
|
|
|
} else {
|
|
|
|
|
texCoords[textureNo] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(sd->u.s.diffuse.lpData) {
|
|
|
|
|
diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
|
|
|
|
|
}
|
|
|
|
|
if(sd->u.s.specular.lpData) {
|
|
|
|
|
specular = sd->u.s.specular.lpData + streamOffset[sd->u.s.specular.streamNo];
|
|
|
|
|
}
|
|
|
|
|
if(sd->u.s.normal.lpData) {
|
|
|
|
|
normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
|
|
|
|
|
}
|
|
|
|
|
if(sd->u.s.position.lpData) {
|
|
|
|
|
position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
/* Start drawing in GL */
|
|
|
|
|
VTRACE(("glBegin(%x)\n", glPrimType));
|
|
|
|
|
glBegin(glPrimType);
|
|
|
|
|
|
2007-01-16 23:43:28 +01:00
|
|
|
|
/* Default settings for data that is not passed */
|
|
|
|
|
if (sd->u.s.normal.lpData == NULL) {
|
|
|
|
|
glNormal3f(0, 0, 1);
|
|
|
|
|
}
|
|
|
|
|
if(sd->u.s.diffuse.lpData != NULL) {
|
|
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
if(sd->u.s.specular.lpData != NULL) {
|
|
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
|
|
|
|
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
|
/* We shouldn't start this function if any VBO is involved. Should I put a safety check here?
|
|
|
|
|
* Guess it's not necessary(we crash then anyway) and would only eat CPU time
|
|
|
|
|
*/
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
/* For each primitive */
|
2005-07-30 21:06:14 +02:00
|
|
|
|
for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
|
|
/* Initialize diffuse color */
|
|
|
|
|
diffuseColor = 0xFFFFFFFF;
|
|
|
|
|
|
2007-01-16 23:43:28 +01:00
|
|
|
|
/* Blending data and Point sizes are not supported by this function. They are not supported by the fixed
|
|
|
|
|
* function pipeline at all. A Fixme for them is printed after decoding the vertex declaration
|
|
|
|
|
*/
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
/* For indexed data, we need to go a few more strides in */
|
|
|
|
|
if (idxData != NULL) {
|
|
|
|
|
|
|
|
|
|
/* Indexed so work out the number of strides to skip */
|
|
|
|
|
if (idxSize == 2) {
|
2006-10-01 05:20:10 +02:00
|
|
|
|
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
|
2007-01-06 18:19:55 +01:00
|
|
|
|
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
2006-10-01 05:20:10 +02:00
|
|
|
|
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index]));
|
2007-01-06 18:19:55 +01:00
|
|
|
|
SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Texture coords --------------------------- */
|
2006-06-27 23:44:26 +02:00
|
|
|
|
for (textureNo = 0, texture_idx = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
|
|
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) {
|
|
|
|
|
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
|
|
|
|
continue ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Query tex coords */
|
|
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
|
|
|
|
|
2006-10-11 03:52:50 +02:00
|
|
|
|
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
|
2005-11-07 12:13:26 +01:00
|
|
|
|
float *ptrToCoords = NULL;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
float s = 0.0, t = 0.0, r = 0.0, q = 0.0;
|
|
|
|
|
|
|
|
|
|
if (coordIdx > 7) {
|
|
|
|
|
VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
|
2006-07-16 22:03:15 +02:00
|
|
|
|
++texture_idx;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
continue;
|
2005-11-07 12:13:26 +01:00
|
|
|
|
} else if (coordIdx < 0) {
|
|
|
|
|
FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
|
2006-07-16 22:03:15 +02:00
|
|
|
|
++texture_idx;
|
2005-11-07 12:13:26 +01:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-17 00:06:34 +01:00
|
|
|
|
ptrToCoords = (float *)(texCoords[coordIdx] + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
|
|
|
|
|
if (texCoords[coordIdx] == NULL) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
|
2006-07-16 22:03:15 +02:00
|
|
|
|
++texture_idx;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
continue;
|
|
|
|
|
} else {
|
|
|
|
|
|
2006-10-11 03:54:22 +02:00
|
|
|
|
int coordsToUse = sd->u.s.texCoords[coordIdx].dwType + 1; /* 0 == WINED3DDECLTYPE_FLOAT1 etc */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
|
|
/* The coords to supply depend completely on the fvf / vertex shader */
|
|
|
|
|
switch (coordsToUse) {
|
|
|
|
|
case 4: q = ptrToCoords[3]; /* drop through */
|
|
|
|
|
case 3: r = ptrToCoords[2]; /* drop through */
|
|
|
|
|
case 2: t = ptrToCoords[1]; /* drop through */
|
2005-07-13 16:15:54 +02:00
|
|
|
|
case 1: s = ptrToCoords[0];
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Projected is more 'fun' - Move the last coord to the 'q'
|
2006-10-11 03:52:50 +02:00
|
|
|
|
parameter (see comments under WINED3DTSS_TEXTURETRANSFORMFLAGS */
|
2006-10-13 05:36:09 +02:00
|
|
|
|
if ((This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] != WINED3DTTFF_DISABLE) &&
|
|
|
|
|
(This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED)) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2006-10-13 05:36:09 +02:00
|
|
|
|
if (This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
switch (coordsToUse) {
|
|
|
|
|
case 0: /* Drop Through */
|
|
|
|
|
case 1:
|
2006-10-13 05:36:09 +02:00
|
|
|
|
FIXME("WINED3DTTFF_PROJECTED but only zero or one coordinate?\n");
|
2004-12-09 12:42:34 +01:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
q = t;
|
|
|
|
|
t = 0.0;
|
|
|
|
|
coordsToUse = 4;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
q = r;
|
|
|
|
|
r = 0.0;
|
|
|
|
|
coordsToUse = 4;
|
|
|
|
|
break;
|
|
|
|
|
case 4: /* Nop here */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2006-10-11 03:52:50 +02:00
|
|
|
|
FIXME("Unexpected WINED3DTSS_TEXTURETRANSFORMFLAGS value of %d\n",
|
2006-10-13 05:36:09 +02:00
|
|
|
|
This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (coordsToUse) { /* Supply the provided texture coords */
|
2006-10-13 05:36:09 +02:00
|
|
|
|
case WINED3DTTFF_COUNT1:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
VTRACE(("tex:%d, s=%f\n", textureNo, s));
|
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
|
GL_EXTCALL(glMultiTexCoord1fARB(texture_idx, s));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
|
|
|
|
glTexCoord1f(s);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2006-10-13 05:36:09 +02:00
|
|
|
|
case WINED3DTTFF_COUNT2:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f\n", textureNo, s, t));
|
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
|
GL_EXTCALL(glMultiTexCoord2fARB(texture_idx, s, t));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
|
|
|
|
glTexCoord2f(s, t);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2006-10-13 05:36:09 +02:00
|
|
|
|
case WINED3DTTFF_COUNT3:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f, r=%f\n", textureNo, s, t, r));
|
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
|
GL_EXTCALL(glMultiTexCoord3fARB(texture_idx, s, t, r));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
|
|
|
|
glTexCoord3f(s, t, r);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2006-10-13 05:36:09 +02:00
|
|
|
|
case WINED3DTTFF_COUNT4:
|
2004-12-09 12:42:34 +01:00
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f, r=%f, q=%f\n", textureNo, s, t, r, q));
|
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
|
GL_EXTCALL(glMultiTexCoord4fARB(texture_idx, s, t, r, q));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
|
|
|
|
glTexCoord4f(s, t, r, q);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
FIXME("Should not get here as coordsToUse is two bits only (%x)!\n", coordsToUse);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-12-19 22:37:37 +01:00
|
|
|
|
if (/*!GL_SUPPORT(NV_REGISTER_COMBINERS) || This->stateBlock->textures[textureNo]*/TRUE) ++texture_idx;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} /* End of textures */
|
|
|
|
|
|
|
|
|
|
/* Diffuse -------------------------------- */
|
2007-01-17 00:06:34 +01:00
|
|
|
|
if (diffuse) {
|
|
|
|
|
DWORD *ptrToCoords = (DWORD *)(diffuse + (SkipnStrides * sd->u.s.diffuse.dwStride));
|
2007-01-16 23:43:28 +01:00
|
|
|
|
diffuseColor = ptrToCoords[0];
|
|
|
|
|
VTRACE(("diffuseColor=%lx\n", diffuseColor));
|
|
|
|
|
|
|
|
|
|
glColor4ub(D3DCOLOR_B_R(diffuseColor),
|
2005-11-15 13:03:13 +01:00
|
|
|
|
D3DCOLOR_B_G(diffuseColor),
|
|
|
|
|
D3DCOLOR_B_B(diffuseColor),
|
|
|
|
|
D3DCOLOR_B_A(diffuseColor));
|
2006-04-21 10:01:34 +02:00
|
|
|
|
VTRACE(("glColor4ub: r,g,b,a=%lu,%lu,%lu,%lu\n",
|
2005-11-15 13:03:13 +01:00
|
|
|
|
D3DCOLOR_B_R(diffuseColor),
|
|
|
|
|
D3DCOLOR_B_G(diffuseColor),
|
|
|
|
|
D3DCOLOR_B_B(diffuseColor),
|
|
|
|
|
D3DCOLOR_B_A(diffuseColor)));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Specular ------------------------------- */
|
2007-01-17 00:06:34 +01:00
|
|
|
|
if (specular) {
|
|
|
|
|
DWORD *ptrToCoords = (DWORD *)(specular + (SkipnStrides * sd->u.s.specular.dwStride));
|
2007-01-16 23:43:28 +01:00
|
|
|
|
specularColor = ptrToCoords[0];
|
|
|
|
|
VTRACE(("specularColor=%lx\n", specularColor));
|
|
|
|
|
|
2007-03-22 17:32:48 +01:00
|
|
|
|
/* special case where the fog density is stored in the specular alpha channel */
|
2006-06-12 13:25:10 +02:00
|
|
|
|
if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
|
2006-10-30 03:41:42 +01:00
|
|
|
|
(This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4 )&&
|
|
|
|
|
This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
|
2006-06-12 13:25:10 +02:00
|
|
|
|
if(GL_SUPPORT(EXT_FOG_COORD)) {
|
|
|
|
|
GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
|
|
|
|
|
} else {
|
|
|
|
|
static BOOL warned = FALSE;
|
|
|
|
|
if(!warned) {
|
|
|
|
|
/* TODO: Use the fog table code from old ddraw */
|
|
|
|
|
FIXME("Implement fog for transformed vertices in software\n");
|
|
|
|
|
warned = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 10:01:34 +02:00
|
|
|
|
VTRACE(("glSecondaryColor4ub: r,g,b=%lu,%lu,%lu\n",
|
2005-11-15 13:03:13 +01:00
|
|
|
|
D3DCOLOR_B_R(specularColor),
|
|
|
|
|
D3DCOLOR_B_G(specularColor),
|
|
|
|
|
D3DCOLOR_B_B(specularColor)));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
|
|
|
|
GL_EXTCALL(glSecondaryColor3ubEXT)(
|
2005-11-15 13:03:13 +01:00
|
|
|
|
D3DCOLOR_B_R(specularColor),
|
|
|
|
|
D3DCOLOR_B_G(specularColor),
|
|
|
|
|
D3DCOLOR_B_B(specularColor));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
} else {
|
2005-07-13 16:15:54 +02:00
|
|
|
|
/* Do not worry if specular colour missing and disable request */
|
|
|
|
|
VTRACE(("Specular color extensions not supplied\n"));
|
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Normal -------------------------------- */
|
2007-01-17 00:06:34 +01:00
|
|
|
|
if (normal != NULL) {
|
|
|
|
|
float *ptrToCoords = (float *)(normal + (SkipnStrides * sd->u.s.normal.dwStride));
|
2007-01-16 23:43:28 +01:00
|
|
|
|
|
|
|
|
|
VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", ptrToCoords[0], ptrToCoords[1], ptrToCoords[2]));
|
|
|
|
|
glNormal3f(ptrToCoords[0], ptrToCoords[1], ptrToCoords[2]);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
2005-07-13 16:15:54 +02:00
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
/* Position -------------------------------- */
|
2007-01-17 00:06:34 +01:00
|
|
|
|
if (position) {
|
|
|
|
|
float *ptrToCoords = (float *)(position + (SkipnStrides * sd->u.s.position.dwStride));
|
2007-01-16 23:43:28 +01:00
|
|
|
|
x = ptrToCoords[0];
|
|
|
|
|
y = ptrToCoords[1];
|
|
|
|
|
z = ptrToCoords[2];
|
|
|
|
|
rhw = 1.0;
|
|
|
|
|
VTRACE(("x,y,z=%f,%f,%f\n", x,y,z));
|
|
|
|
|
|
|
|
|
|
/* RHW follows, only if transformed, ie 4 floats were provided */
|
|
|
|
|
if (sd->u.s.position_transformed) {
|
|
|
|
|
rhw = ptrToCoords[3];
|
|
|
|
|
VTRACE(("rhw=%f\n", rhw));
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-09 18:16:13 +02:00
|
|
|
|
if (1.0f == rhw || ((rhw < eps) && (rhw > -eps))) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z));
|
|
|
|
|
glVertex3f(x, y, z);
|
|
|
|
|
} else {
|
|
|
|
|
GLfloat w = 1.0 / rhw;
|
|
|
|
|
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw));
|
|
|
|
|
glVertex4f(x*w, y*w, z*w, w);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For non indexed mode, step onto next parts */
|
|
|
|
|
if (idxData == NULL) {
|
2005-07-30 21:06:14 +02:00
|
|
|
|
++SkipnStrides;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
checkGLcall("glEnd and previous calls");
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-17 13:24:00 +01:00
|
|
|
|
static void check_fbo_status(IWineD3DDevice *iface) {
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
|
|
|
|
|
GLenum status = GL_EXTCALL(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
|
|
|
|
|
switch(status) {
|
|
|
|
|
case GL_FRAMEBUFFER_COMPLETE_EXT: TRACE("FBO complete.\n"); break;
|
|
|
|
|
default: TRACE("FBO status %#x.\n", status); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-17 13:24:04 +01:00
|
|
|
|
static void depth_blt(IWineD3DDevice *iface, GLuint texture) {
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2006-12-25 17:12:50 +01:00
|
|
|
|
GLint old_binding = 0;
|
2006-11-17 13:24:04 +01:00
|
|
|
|
|
|
|
|
|
glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDisable(GL_ALPHA_TEST);
|
|
|
|
|
glDisable(GL_STENCIL_TEST);
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
glDepthFunc(GL_ALWAYS);
|
|
|
|
|
|
|
|
|
|
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
|
2006-12-25 17:12:50 +01:00
|
|
|
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
2006-11-17 13:24:04 +01:00
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
|
2006-11-27 20:50:43 +01:00
|
|
|
|
This->shader_backend->shader_select_depth_blt(iface);
|
2006-11-17 13:24:04 +01:00
|
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLE_STRIP);
|
|
|
|
|
glVertex2f(-1.0f, -1.0f);
|
|
|
|
|
glVertex2f(1.0f, -1.0f);
|
|
|
|
|
glVertex2f(-1.0f, 1.0f);
|
|
|
|
|
glVertex2f(1.0f, 1.0f);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2006-12-25 17:12:50 +01:00
|
|
|
|
glBindTexture(GL_TEXTURE_2D, old_binding);
|
|
|
|
|
|
2006-11-17 13:24:04 +01:00
|
|
|
|
glPopAttrib();
|
2007-01-06 18:14:12 +01:00
|
|
|
|
|
|
|
|
|
/* Reselect the old shaders. There doesn't seem to be any glPushAttrib bit for arb shaders,
|
|
|
|
|
* and this seems easier and more efficient than providing the shader backend with a private
|
|
|
|
|
* storage to read and restore the old shader settings
|
|
|
|
|
*/
|
2007-03-12 23:22:00 +01:00
|
|
|
|
This->shader_backend->shader_select(iface, use_ps(This), use_vs(This));
|
2006-11-17 13:24:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void depth_copy(IWineD3DDevice *iface) {
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *)This->depthStencilBuffer;
|
|
|
|
|
|
2006-11-18 17:08:17 +01:00
|
|
|
|
/* Only copy the depth buffer if there is one. */
|
|
|
|
|
if (!depth_stencil) return;
|
|
|
|
|
|
2006-11-17 13:24:04 +01:00
|
|
|
|
/* TODO: Make this work for modes other than FBO */
|
|
|
|
|
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return;
|
|
|
|
|
|
|
|
|
|
if (This->render_offscreen) {
|
|
|
|
|
static GLuint tmp_texture = 0;
|
2006-12-25 17:12:50 +01:00
|
|
|
|
GLint old_binding = 0;
|
2006-11-17 13:24:04 +01:00
|
|
|
|
|
|
|
|
|
TRACE("Copying onscreen depth buffer to offscreen surface\n");
|
|
|
|
|
|
|
|
|
|
if (!tmp_texture) {
|
|
|
|
|
glGenTextures(1, &tmp_texture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Note that we use depth_blt here as well, rather than glCopyTexImage2D
|
|
|
|
|
* directly on the FBO texture. That's because we need to flip. */
|
|
|
|
|
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
|
2006-12-25 17:12:50 +01:00
|
|
|
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
2006-11-17 13:24:04 +01:00
|
|
|
|
glBindTexture(GL_TEXTURE_2D, tmp_texture);
|
|
|
|
|
glCopyTexImage2D(depth_stencil->glDescription.target,
|
|
|
|
|
depth_stencil->glDescription.level,
|
|
|
|
|
depth_stencil->glDescription.glFormatInternal,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
depth_stencil->currentDesc.Width,
|
|
|
|
|
depth_stencil->currentDesc.Height,
|
|
|
|
|
0);
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
|
2006-12-25 17:12:50 +01:00
|
|
|
|
glBindTexture(GL_TEXTURE_2D, old_binding);
|
2006-11-17 13:24:04 +01:00
|
|
|
|
|
|
|
|
|
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, This->fbo));
|
|
|
|
|
checkGLcall("glBindFramebuffer()");
|
|
|
|
|
depth_blt(iface, tmp_texture);
|
|
|
|
|
checkGLcall("depth_blt");
|
|
|
|
|
} else {
|
|
|
|
|
TRACE("Copying offscreen surface to onscreen depth buffer\n");
|
|
|
|
|
|
|
|
|
|
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
|
|
|
|
|
checkGLcall("glBindFramebuffer()");
|
|
|
|
|
depth_blt(iface, depth_stencil->glDescription.textureName);
|
|
|
|
|
checkGLcall("depth_blt");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
|
static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
|
2007-02-14 17:56:29 +01:00
|
|
|
|
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex,
|
|
|
|
|
ULONG startIdx, ULONG startVertex) {
|
|
|
|
|
UINT numInstances = 0;
|
|
|
|
|
int numInstancedAttribs = 0, i, j;
|
|
|
|
|
UINT instancedData[sizeof(sd->u.input) / sizeof(sd->u.input[0]) /* 16 */];
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
|
|
|
|
|
IWineD3DStateBlockImpl *stateblock = This->stateBlock;
|
|
|
|
|
|
2007-02-19 15:25:32 +01:00
|
|
|
|
if (idxSize == 0) {
|
2007-02-14 17:56:29 +01:00
|
|
|
|
/* This is a nasty thing. MSDN says no hardware supports that and apps have to use software vertex processing.
|
|
|
|
|
* We don't support this for now
|
|
|
|
|
*
|
|
|
|
|
* Shouldn't be too hard to support with opengl, in theory just call glDrawArrays instead of drawElements.
|
|
|
|
|
* But the StreamSourceFreq value has a different meaning in that situation.
|
|
|
|
|
*/
|
|
|
|
|
FIXME("Non-indexed instanced drawing is not supported\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex);
|
|
|
|
|
idxData = idxData == (void *)-1 ? NULL : idxData;
|
|
|
|
|
|
|
|
|
|
/* First, figure out how many instances we have to draw */
|
|
|
|
|
for(i = 0; i < MAX_STREAMS; i++) {
|
|
|
|
|
/* Look at all non-instanced streams */
|
2007-02-14 23:30:16 +01:00
|
|
|
|
if(!(stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INSTANCEDATA) &&
|
2007-02-14 17:56:29 +01:00
|
|
|
|
stateblock->streamSource[i]) {
|
|
|
|
|
int inst = stateblock->streamFreq[i];
|
|
|
|
|
|
|
|
|
|
if(numInstances && inst != numInstances) {
|
|
|
|
|
ERR("Two streams specify a different number of instances. Got %d, new is %d\n", numInstances, inst);
|
|
|
|
|
}
|
|
|
|
|
numInstances = inst;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < sizeof(sd->u.input) / sizeof(sd->u.input[0]); i++) {
|
2007-02-14 23:30:16 +01:00
|
|
|
|
if(stateblock->streamFlags[sd->u.input[i].streamNo] & WINED3DSTREAMSOURCE_INSTANCEDATA) {
|
2007-02-14 17:56:29 +01:00
|
|
|
|
instancedData[numInstancedAttribs] = i;
|
|
|
|
|
numInstancedAttribs++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now draw numInstances instances :-) */
|
|
|
|
|
for(i = 0; i < numInstances; i++) {
|
|
|
|
|
/* Specify the instanced attributes using immediate mode calls */
|
|
|
|
|
for(j = 0; j < numInstancedAttribs; j++) {
|
|
|
|
|
BYTE *ptr = sd->u.input[instancedData[j]].lpData +
|
|
|
|
|
sd->u.input[instancedData[j]].dwStride * i +
|
|
|
|
|
stateblock->streamOffset[sd->u.input[instancedData[j]].streamNo];
|
|
|
|
|
if(sd->u.input[instancedData[j]].VBO) {
|
|
|
|
|
IWineD3DVertexBufferImpl *vb = (IWineD3DVertexBufferImpl *) stateblock->streamSource[sd->u.input[instancedData[j]].streamNo];
|
|
|
|
|
ptr += (long) vb->resource.allocatedMemory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(sd->u.input[instancedData[j]].dwType) {
|
|
|
|
|
case WINED3DDECLTYPE_FLOAT1:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib1fvARB(instancedData[j], (float *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_FLOAT2:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib2fvARB(instancedData[j], (float *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_FLOAT3:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib3fvARB(instancedData[j], (float *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_FLOAT4:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4fvARB(instancedData[j], (float *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WINED3DDECLTYPE_UBYTE4:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4NubvARB(instancedData[j], ptr));
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_UBYTE4N:
|
|
|
|
|
case WINED3DDECLTYPE_D3DCOLOR:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4NubvARB(instancedData[j], ptr));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WINED3DDECLTYPE_SHORT2:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4svARB(instancedData[j], (GLshort *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_SHORT4:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4svARB(instancedData[j], (GLshort *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WINED3DDECLTYPE_SHORT2N:
|
|
|
|
|
{
|
|
|
|
|
GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1};
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4NsvARB(instancedData[j], s));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case WINED3DDECLTYPE_USHORT2N:
|
|
|
|
|
{
|
|
|
|
|
GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1};
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4NusvARB(instancedData[j], s));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case WINED3DDECLTYPE_SHORT4N:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4NsvARB(instancedData[j], (GLshort *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_USHORT4N:
|
|
|
|
|
GL_EXTCALL(glVertexAttrib4NusvARB(instancedData[j], (GLushort *) ptr));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WINED3DDECLTYPE_UDEC3:
|
|
|
|
|
FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
|
|
|
|
|
/*glVertexAttrib3usvARB(instancedData[j], (GLushort *) ptr); Does not exist */
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_DEC3N:
|
|
|
|
|
FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
|
|
|
|
|
/*glVertexAttrib3NusvARB(instancedData[j], (GLushort *) ptr); Does not exist */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WINED3DDECLTYPE_FLOAT16_2:
|
|
|
|
|
/* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
|
|
|
|
|
* byte float according to the IEEE standard
|
|
|
|
|
*/
|
|
|
|
|
FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
|
|
|
|
|
break;
|
|
|
|
|
case WINED3DDECLTYPE_FLOAT16_4:
|
|
|
|
|
FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WINED3DDECLTYPE_UNUSED:
|
|
|
|
|
default:
|
|
|
|
|
ERR("Unexpected declaration in instanced attributes\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
|
|
|
|
|
(const char *)idxData+(idxSize * startIdx));
|
|
|
|
|
checkGLcall("glDrawElements");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-10 00:55:08 +01:00
|
|
|
|
struct coords {
|
|
|
|
|
int x, y, z;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void blt_to_drawable(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *surface) {
|
|
|
|
|
struct coords coords[4];
|
|
|
|
|
int low_coord;
|
|
|
|
|
|
|
|
|
|
/* TODO: This could be supported for lazy unlocking */
|
|
|
|
|
if(!(surface->Flags & SFLAG_INTEXTURE)) {
|
|
|
|
|
/* It is ok at init to be nowhere */
|
|
|
|
|
if(!(surface->Flags & SFLAG_INSYSMEM)) {
|
|
|
|
|
ERR("Blitting surfaces from sysmem not supported yet\n");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
|
ActivateContext(This, This->render_targets[0], CTXUSAGE_BLIT);
|
|
|
|
|
|
|
|
|
|
if(surface->glDescription.target == GL_TEXTURE_2D) {
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, surface->glDescription.textureName);
|
|
|
|
|
checkGLcall("GL_TEXTURE_2D, This->glDescription.textureName)");
|
|
|
|
|
|
|
|
|
|
coords[0].x = 0; coords[0].y = 0; coords[0].z = 0;
|
|
|
|
|
coords[1].x = 0; coords[1].y = 1; coords[1].z = 0;
|
|
|
|
|
coords[2].x = 1; coords[2].y = 1; coords[2].z = 0;
|
|
|
|
|
coords[3].x = 1; coords[3].y = 0; coords[3].z = 0;
|
|
|
|
|
|
|
|
|
|
low_coord = 0;
|
|
|
|
|
} else {
|
|
|
|
|
/* Must be a cube map */
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
checkGLcall("glDisable(GL_TEXTURE_2D)");
|
|
|
|
|
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
|
checkGLcall("glEnable(surface->glDescription.target)");
|
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, surface->glDescription.textureName);
|
|
|
|
|
checkGLcall("GL_TEXTURE_CUBE_MAP_ARB, This->glDescription.textureName)");
|
|
|
|
|
|
|
|
|
|
switch(surface->glDescription.target) {
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
|
|
|
|
coords[0].x = 1; coords[0].y = -1; coords[0].z = 1;
|
|
|
|
|
coords[1].x = 1; coords[1].y = 1; coords[1].z = 1;
|
|
|
|
|
coords[2].x = 1; coords[2].y = 1; coords[2].z = -1;
|
|
|
|
|
coords[3].x = 1; coords[3].y = -1; coords[3].z = -1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
|
|
|
|
coords[0].x = -1; coords[0].y = -1; coords[0].z = 1;
|
|
|
|
|
coords[1].x = -1; coords[1].y = 1; coords[1].z = 1;
|
|
|
|
|
coords[2].x = -1; coords[2].y = 1; coords[2].z = -1;
|
|
|
|
|
coords[3].x = -1; coords[3].y = -1; coords[3].z = -1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
|
|
|
|
coords[0].x = -1; coords[0].y = 1; coords[0].z = 1;
|
|
|
|
|
coords[1].x = 1; coords[1].y = 1; coords[1].z = 1;
|
|
|
|
|
coords[2].x = 1; coords[2].y = 1; coords[2].z = -1;
|
|
|
|
|
coords[3].x = -1; coords[3].y = 1; coords[3].z = -1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
|
|
|
|
coords[0].x = -1; coords[0].y = -1; coords[0].z = 1;
|
|
|
|
|
coords[1].x = 1; coords[1].y = -1; coords[1].z = 1;
|
|
|
|
|
coords[2].x = 1; coords[2].y = -1; coords[2].z = -1;
|
|
|
|
|
coords[3].x = -1; coords[3].y = -1; coords[3].z = -1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
|
|
|
|
coords[0].x = -1; coords[0].y = -1; coords[0].z = 1;
|
|
|
|
|
coords[1].x = 1; coords[1].y = -1; coords[1].z = 1;
|
|
|
|
|
coords[2].x = 1; coords[2].y = -1; coords[2].z = 1;
|
|
|
|
|
coords[3].x = -1; coords[3].y = -1; coords[3].z = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
|
|
|
|
coords[0].x = -1; coords[0].y = -1; coords[0].z = -1;
|
|
|
|
|
coords[1].x = 1; coords[1].y = -1; coords[1].z = -1;
|
|
|
|
|
coords[2].x = 1; coords[2].y = -1; coords[2].z = -1;
|
|
|
|
|
coords[3].x = -1; coords[3].y = -1; coords[3].z = -1;
|
|
|
|
|
|
|
|
|
|
default:
|
2007-03-14 09:17:46 +01:00
|
|
|
|
ERR("Unexpected texture target\n");
|
2007-03-10 00:55:08 +01:00
|
|
|
|
LEAVE_GL();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
low_coord = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(This->render_offscreen) {
|
|
|
|
|
coords[0].y = coords[0].y == 1 ? low_coord : 1;
|
|
|
|
|
coords[1].y = coords[1].y == 1 ? low_coord : 1;
|
|
|
|
|
coords[2].y = coords[2].y == 1 ? low_coord : 1;
|
|
|
|
|
coords[3].y = coords[3].y == 1 ? low_coord : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
glTexCoord3iv((GLint *) &coords[0]);
|
|
|
|
|
glVertex2i(0, 0);
|
|
|
|
|
|
|
|
|
|
glTexCoord3iv((GLint *) &coords[1]);
|
|
|
|
|
glVertex2i(0, surface->pow2Height);
|
|
|
|
|
|
|
|
|
|
glTexCoord3iv((GLint *) &coords[2]);
|
|
|
|
|
glVertex2i(surface->pow2Width, surface->pow2Height);
|
|
|
|
|
|
|
|
|
|
glTexCoord3iv((GLint *) &coords[3]);
|
|
|
|
|
glVertex2i(surface->pow2Width, 0);
|
|
|
|
|
glEnd();
|
|
|
|
|
checkGLcall("glEnd");
|
|
|
|
|
|
|
|
|
|
if(surface->glDescription.target != GL_TEXTURE_2D) {
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
checkGLcall("glEnable(GL_TEXTURE_2D)");
|
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
|
checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
|
|
|
|
|
}
|
|
|
|
|
LEAVE_GL();
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
/* Routine common to the draw primitive and draw indexed primitive routines */
|
|
|
|
|
void drawPrimitive(IWineD3DDevice *iface,
|
2006-05-06 16:58:57 +02:00
|
|
|
|
int PrimitiveType,
|
|
|
|
|
long NumPrimitives,
|
|
|
|
|
/* for Indexed: */
|
|
|
|
|
long StartVertexIndex,
|
|
|
|
|
UINT numberOfVertices,
|
|
|
|
|
long StartIdx,
|
|
|
|
|
short idxSize,
|
|
|
|
|
const void *idxData,
|
2007-01-02 21:13:28 +01:00
|
|
|
|
int minIndex) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2005-01-17 14:44:57 +01:00
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2007-03-06 21:47:45 +01:00
|
|
|
|
IWineD3DSwapChain *swapchain;
|
|
|
|
|
IWineD3DBaseTexture *texture = NULL;
|
|
|
|
|
IWineD3DSurfaceImpl *target;
|
2007-02-12 19:18:36 +01:00
|
|
|
|
int i;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2007-01-06 18:41:43 +01:00
|
|
|
|
/* Signals other modules that a drawing is in progress and the stateblock finalized */
|
|
|
|
|
This->isInDraw = TRUE;
|
|
|
|
|
|
2006-06-04 16:42:57 +02:00
|
|
|
|
/* Invalidate the back buffer memory so LockRect will read it the next time */
|
2007-02-13 20:21:32 +01:00
|
|
|
|
for(i = 0; i < GL_LIMITS(buffers); i++) {
|
2007-03-06 21:47:45 +01:00
|
|
|
|
target = (IWineD3DSurfaceImpl *) This->render_targets[i];
|
2007-03-10 00:55:08 +01:00
|
|
|
|
|
2007-03-06 21:47:45 +01:00
|
|
|
|
/* TODO: Only do all that if we're going to change anything
|
|
|
|
|
* Texture container dirtification does not work quite right yet
|
|
|
|
|
*/
|
|
|
|
|
if(target /*&& target->Flags & (SFLAG_INTEXTURE | SFLAG_INSYSMEM)*/) {
|
|
|
|
|
swapchain = NULL;
|
|
|
|
|
texture = NULL;
|
|
|
|
|
|
|
|
|
|
if(i == 0) {
|
|
|
|
|
IWineD3DSurface_GetContainer((IWineD3DSurface *) target, &IID_IWineD3DSwapChain, (void **)&swapchain);
|
2007-03-10 00:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Need the surface in the drawable! */
|
|
|
|
|
if(!(target->Flags & SFLAG_INDRAWABLE) && (swapchain || wined3d_settings.offscreen_rendering_mode != ORM_FBO)) {
|
|
|
|
|
blt_to_drawable(This, target);
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-06 21:47:45 +01:00
|
|
|
|
if(swapchain) {
|
|
|
|
|
/* Onscreen target. Invalidate system memory copy and texture copy */
|
|
|
|
|
target->Flags &= ~(SFLAG_INSYSMEM | SFLAG_INTEXTURE);
|
|
|
|
|
target->Flags |= SFLAG_INDRAWABLE;
|
|
|
|
|
IWineD3DSwapChain_Release(swapchain);
|
|
|
|
|
} else if(wined3d_settings.offscreen_rendering_mode != ORM_FBO) {
|
|
|
|
|
/* Non-FBO target: Invalidate system copy, texture copy and dirtify the container */
|
|
|
|
|
IWineD3DSurface_GetContainer((IWineD3DSurface *) target, &IID_IWineD3DBaseTexture, (void **)&texture);
|
|
|
|
|
|
|
|
|
|
if(texture) {
|
|
|
|
|
IWineD3DBaseTexture_SetDirty(texture, TRUE);
|
|
|
|
|
IWineD3DTexture_Release(texture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target->Flags &= ~(SFLAG_INSYSMEM | SFLAG_INTEXTURE);
|
|
|
|
|
target->Flags |= SFLAG_INDRAWABLE;
|
|
|
|
|
} else {
|
|
|
|
|
/* FBO offscreen target. Invalidate system memory copy */
|
|
|
|
|
target->Flags &= ~SFLAG_INSYSMEM;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Must be an fbo render target */
|
|
|
|
|
target->Flags &= ~SFLAG_INSYSMEM;
|
|
|
|
|
target->Flags |= SFLAG_INTEXTURE;
|
|
|
|
|
}
|
2006-06-04 16:42:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
|
/* Ok, we will be updating the screen from here onwards so grab the lock */
|
|
|
|
|
ENTER_GL();
|
|
|
|
|
|
2007-02-12 19:18:36 +01:00
|
|
|
|
ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
|
2007-01-06 18:11:21 +01:00
|
|
|
|
|
2006-12-25 17:12:45 +01:00
|
|
|
|
if (TRACE_ON(d3d_draw) && wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
|
|
|
|
|
check_fbo_status(iface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (This->depth_copy_state == WINED3D_DCS_COPY) {
|
|
|
|
|
depth_copy(iface);
|
|
|
|
|
}
|
|
|
|
|
This->depth_copy_state = WINED3D_DCS_INITIAL;
|
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
|
{
|
|
|
|
|
GLenum glPrimType;
|
|
|
|
|
/* Ok, Work out which primitive is requested and how many vertexes that
|
|
|
|
|
will be */
|
|
|
|
|
UINT calculatedNumberOfindices = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
|
|
|
|
|
if (numberOfVertices == 0 )
|
|
|
|
|
numberOfVertices = calculatedNumberOfindices;
|
2006-07-04 11:08:39 +02:00
|
|
|
|
|
2007-02-14 17:56:29 +01:00
|
|
|
|
if (This->useDrawStridedSlow) {
|
|
|
|
|
/* Immediate mode drawing */
|
2007-01-06 18:28:42 +01:00
|
|
|
|
drawStridedSlow(iface, &This->strided_streams, calculatedNumberOfindices,
|
|
|
|
|
glPrimType, idxData, idxSize, minIndex, StartIdx, StartVertexIndex);
|
2007-02-14 17:56:29 +01:00
|
|
|
|
} else if(This->instancedDraw) {
|
|
|
|
|
/* Instancing emulation with mixing immediate mode and arrays */
|
|
|
|
|
drawStridedInstanced(iface, &This->strided_streams, calculatedNumberOfindices, glPrimType,
|
|
|
|
|
idxData, idxSize, minIndex, StartIdx, StartVertexIndex);
|
|
|
|
|
} else {
|
|
|
|
|
/* Simple array draw call */
|
2007-01-06 18:28:42 +01:00
|
|
|
|
drawStridedFast(iface, calculatedNumberOfindices, glPrimType,
|
|
|
|
|
idxData, idxSize, minIndex, StartIdx, StartVertexIndex);
|
2007-02-14 17:56:29 +01:00
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finshed updating the screen, restore lock */
|
|
|
|
|
LEAVE_GL();
|
|
|
|
|
TRACE("Done all gl drawing\n");
|
|
|
|
|
|
|
|
|
|
/* Diagnostics */
|
2005-09-27 12:49:59 +02:00
|
|
|
|
#ifdef SHOW_FRAME_MAKEUP
|
2004-12-09 12:42:34 +01:00
|
|
|
|
{
|
2005-09-27 12:49:59 +02:00
|
|
|
|
static long int primCounter = 0;
|
|
|
|
|
/* NOTE: set primCounter to the value reported by drawprim
|
|
|
|
|
before you want to to write frame makeup to /tmp */
|
|
|
|
|
if (primCounter >= 0) {
|
2006-04-06 19:36:02 +02:00
|
|
|
|
WINED3DLOCKED_RECT r;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
char buffer[80];
|
2006-03-08 00:11:28 +01:00
|
|
|
|
IWineD3DSurface_LockRect(This->renderTarget, &r, NULL, WINED3DLOCK_READONLY);
|
2006-10-01 05:20:10 +02:00
|
|
|
|
sprintf(buffer, "/tmp/backbuffer_%d.tga", primCounter);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
TRACE("Saving screenshot %s\n", buffer);
|
2005-07-30 21:06:14 +02:00
|
|
|
|
IWineD3DSurface_SaveSnapshot(This->renderTarget, buffer);
|
|
|
|
|
IWineD3DSurface_UnlockRect(This->renderTarget);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
2005-09-27 12:49:59 +02:00
|
|
|
|
#ifdef SHOW_TEXTURE_MAKEUP
|
2004-12-09 12:42:34 +01:00
|
|
|
|
{
|
2005-07-30 21:06:14 +02:00
|
|
|
|
IWineD3DSurface *pSur;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
int textureNo;
|
|
|
|
|
for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
|
|
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
2006-10-01 05:20:10 +02:00
|
|
|
|
sprintf(buffer, "/tmp/texture_%p_%d_%d.tga", This->stateBlock->textures[textureNo], primCounter, textureNo);
|
2005-07-30 21:06:14 +02:00
|
|
|
|
TRACE("Saving texture %s\n", buffer);
|
2006-03-09 23:21:16 +01:00
|
|
|
|
if (IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo]) == WINED3DRTYPE_TEXTURE) {
|
2005-09-27 12:49:59 +02:00
|
|
|
|
IWineD3DTexture_GetSurfaceLevel((IWineD3DTexture *)This->stateBlock->textures[textureNo], 0, &pSur);
|
|
|
|
|
IWineD3DSurface_SaveSnapshot(pSur, buffer);
|
|
|
|
|
IWineD3DSurface_Release(pSur);
|
|
|
|
|
} else {
|
|
|
|
|
FIXME("base Texture isn't of type texture %d\n", IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo]));
|
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2006-10-01 05:20:10 +02:00
|
|
|
|
TRACE("drawprim #%d\n", primCounter);
|
2005-09-27 12:49:59 +02:00
|
|
|
|
++primCounter;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2007-01-06 18:41:43 +01:00
|
|
|
|
|
|
|
|
|
/* Control goes back to the device, stateblock values may change again */
|
|
|
|
|
This->isInDraw = FALSE;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
}
|