- Use faster vertex arrays (rather than processing vertexes one by
one), whenever possible. - Less trace in the slower form by default.
This commit is contained in:
parent
f89ea6499d
commit
3d1b725900
|
@ -29,6 +29,16 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
||||
|
||||
/* Some #defines for additional diagnostics */
|
||||
|
||||
/* Per-vertex trace: */
|
||||
#if 0
|
||||
#define VTRACE(A) TRACE A
|
||||
#else
|
||||
#define VTRACE(A)
|
||||
#endif
|
||||
|
||||
|
||||
static VERTEXSHADER8* VertexShaders[64];
|
||||
static PIXELSHADER8* PixelShaders[64];
|
||||
|
||||
|
@ -45,13 +55,13 @@ static PIXELSHADER8* PixelShaders[64];
|
|||
* Utility functions or macros
|
||||
*/
|
||||
#define conv_mat(mat,gl_mat) \
|
||||
{ \
|
||||
do { \
|
||||
TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
|
||||
TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
|
||||
TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
|
||||
TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
|
||||
memcpy(gl_mat, (mat), 16 * sizeof(float)); \
|
||||
};
|
||||
} while (0)
|
||||
|
||||
#define VERTEX_SHADER(Handle) \
|
||||
((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(VertexShaders) / sizeof(VERTEXSHADER8*)) ? NULL : VertexShaders[Handle]) : VertexShaders[Handle - VS_HIGHESTFIXEDFXF])
|
||||
|
@ -74,10 +84,7 @@ static const float idmatrix[16] = {
|
|||
};
|
||||
|
||||
|
||||
/* Routine common to the draw primitive and draw indexed primitive routines
|
||||
Doesnt use gl pointer arrays as I dont believe we can support the blending
|
||||
coordinates that way. */
|
||||
|
||||
/* Routine common to the draw primitive and draw indexed primitive routines */
|
||||
void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
||||
int PrimitiveType,
|
||||
long NumPrimitives,
|
||||
|
@ -91,9 +98,9 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
long StartVertexIndex,
|
||||
long StartIdx,
|
||||
short idxBytes,
|
||||
const void *idxData) {
|
||||
const void *idxData,
|
||||
int minIndex) {
|
||||
|
||||
int vx_index;
|
||||
int NumVertexes = NumPrimitives;
|
||||
VERTEXSHADER8* vertex_shader = NULL;
|
||||
VSHADERINPUTDATA8 vertex_shader_input;
|
||||
|
@ -122,7 +129,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
|
||||
{
|
||||
int skip = This->StateBlock.stream_stride[0];
|
||||
|
||||
GLenum primType = GL_POINTS;
|
||||
BOOL normal;
|
||||
BOOL isRHW;
|
||||
BOOL isPtSize;
|
||||
|
@ -137,6 +144,8 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
const long *pIdxBufL = NULL;
|
||||
const void *curPos;
|
||||
BOOL isLightingOn = FALSE;
|
||||
BOOL enableTexture = FALSE;
|
||||
int vx_index;
|
||||
|
||||
float x=0.0, y=0.0, z=0.0; /* x,y,z coordinates */
|
||||
float nx=0.0, ny=0.0, nz=0.0; /* normal x,y,z coordinates */
|
||||
|
@ -155,7 +164,6 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
/* Check vertex formats expected ? */
|
||||
normal = fvf & D3DFVF_NORMAL;
|
||||
isRHW = fvf & D3DFVF_XYZRHW;
|
||||
/*numBlends = 5 - ((~fvf) & 0xe);*/ /* There must be a simpler way? */
|
||||
numBlends = ((fvf & D3DFVF_POSITION_MASK) >> 1) - 2; /* WARNING can be < 0 because -2 */
|
||||
isLastUByte4 = fvf & D3DFVF_LASTBETA_UBYTE4;
|
||||
isPtSize = fvf & D3DFVF_PSIZE;
|
||||
|
@ -163,7 +171,6 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
isSpecular = fvf & D3DFVF_SPECULAR;
|
||||
numTextures = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
||||
|
||||
|
||||
TRACE("Drawing with FVF = %x, (n?%d, rhw?%d, ptSize(%d), diffuse?%d, specular?%d, numTextures=%d, numBlends=%d)\n",
|
||||
fvf, normal, isRHW, isPtSize, isDiffuse, isSpecular, numTextures, numBlends);
|
||||
|
||||
|
@ -175,7 +182,6 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
TRACE("Enabled lighting as no normals supplied, old state = %d\n", isLightingOn);
|
||||
}
|
||||
|
||||
|
||||
if (isRHW) {
|
||||
double height, width, minZ, maxZ;
|
||||
/*
|
||||
|
@ -214,38 +220,38 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
/* Set OpenGL to the appropriate Primitive Type */
|
||||
switch (PrimitiveType) {
|
||||
case D3DPT_POINTLIST:
|
||||
TRACE("glBegin, Start POINTS\n");
|
||||
glBegin(GL_POINTS);
|
||||
TRACE("POINTS\n");
|
||||
primType = GL_POINTS;
|
||||
NumVertexes = NumPrimitives;
|
||||
break;
|
||||
|
||||
case D3DPT_LINELIST:
|
||||
TRACE("glBegin, Start LINES\n");
|
||||
glBegin(GL_LINES);
|
||||
TRACE("LINES\n");
|
||||
primType = GL_LINES;
|
||||
NumVertexes = NumPrimitives * 2;
|
||||
break;
|
||||
|
||||
case D3DPT_LINESTRIP:
|
||||
TRACE("glBegin, Start LINE_STRIP\n");
|
||||
glBegin(GL_LINE_STRIP);
|
||||
TRACE("LINE_STRIP\n");
|
||||
primType = GL_LINE_STRIP;
|
||||
NumVertexes = NumPrimitives + 1;
|
||||
break;
|
||||
|
||||
case D3DPT_TRIANGLELIST:
|
||||
TRACE("glBegin, Start TRIANGLES\n");
|
||||
glBegin(GL_TRIANGLES);
|
||||
TRACE("TRIANGLES\n");
|
||||
primType = GL_TRIANGLES;
|
||||
NumVertexes = NumPrimitives * 3;
|
||||
break;
|
||||
|
||||
case D3DPT_TRIANGLESTRIP:
|
||||
TRACE("glBegin, Start TRIANGLE_STRIP\n");
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
TRACE("TRIANGLE_STRIP\n");
|
||||
primType = GL_TRIANGLE_STRIP;
|
||||
NumVertexes = NumPrimitives + 2;
|
||||
break;
|
||||
|
||||
case D3DPT_TRIANGLEFAN:
|
||||
TRACE("glBegin, Start TRIANGLE_FAN\n");
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
TRACE("TRIANGLE_FAN\n");
|
||||
primType = GL_TRIANGLE_FAN;
|
||||
NumVertexes = NumPrimitives + 2;
|
||||
break;
|
||||
|
||||
|
@ -254,6 +260,18 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
break;
|
||||
}
|
||||
|
||||
/* Fixme, Ideally, only use this per-vertex code for software HAL
|
||||
but until opengl supports all the functions returned to setup
|
||||
vertex arrays, we need to drop down to the slow mechanism for
|
||||
certain functions */
|
||||
|
||||
if (isPtSize || isDiffuse || useVertexShaderFunction==TRUE || (numBlends > 0)) {
|
||||
FIXME("Using slow per-vertex code\n");
|
||||
|
||||
/* Enable this one to be able to debug what is going on, but it is slower
|
||||
than the pointer/array version */
|
||||
VTRACE(("glBegin(%x)\n", primType));
|
||||
glBegin(primType);
|
||||
|
||||
/* Draw the primitives */
|
||||
curVtx = vertexBufData + (StartVertexIndex * skip);
|
||||
|
@ -264,10 +282,10 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
curPos = curVtx;
|
||||
} else {
|
||||
if (idxBytes == 2) {
|
||||
TRACE("Idx for vertex %d = %d = %d\n", vx_index, pIdxBufS[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index]));
|
||||
VTRACE(("Idx for vertex %d = %d = %d\n", vx_index, pIdxBufS[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index])));
|
||||
curPos = curVtx + ((pIdxBufS[StartIdx+vx_index]) * skip);
|
||||
} else {
|
||||
TRACE("Idx for vertex %d = %ld = %d\n", vx_index, pIdxBufL[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index]));
|
||||
VTRACE(("Idx for vertex %d = %ld = %d\n", vx_index, pIdxBufL[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index])));
|
||||
curPos = curVtx + ((pIdxBufL[StartIdx+vx_index]) * skip);
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +297,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
curPos = curPos + sizeof(float);
|
||||
z = *(float *)curPos;
|
||||
curPos = curPos + sizeof(float);
|
||||
/*TRACE("x,y,z=%f,%f,%f\n", x,y,z);*/
|
||||
VTRACE(("x,y,z=%f,%f,%f\n", x,y,z));
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
vertex_shader_input.V[D3DVSDE_POSITION].x = x;
|
||||
|
@ -287,25 +305,29 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
vertex_shader_input.V[D3DVSDE_POSITION].z = z;
|
||||
vertex_shader_input.V[D3DVSDE_POSITION].w = 1.0f;
|
||||
}
|
||||
|
||||
/* RHW follows, only if transformed */
|
||||
if (isRHW) {
|
||||
rhw = *(float *)curPos;
|
||||
curPos = curPos + sizeof(float);
|
||||
/*TRACE("rhw=%f\n", rhw);*/
|
||||
VTRACE(("rhw=%f\n", rhw));
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
vertex_shader_input.V[D3DVSDE_POSITION].w = rhw;
|
||||
}
|
||||
}
|
||||
/* FIXME: Skip Blending data */
|
||||
|
||||
/* Blending data */
|
||||
if (numBlends > 0) {
|
||||
UINT i;
|
||||
D3DSHADERVECTOR skippedBlend = { 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
DWORD skippedBlendLastUByte4 = 0;
|
||||
|
||||
for (i = 0; i < ((FALSE == isLastUByte4) ? numBlends : numBlends - 1); ++i) {
|
||||
((float*)&skippedBlend)[i] = *(float *)curPos;
|
||||
curPos = curPos + sizeof(float);
|
||||
}
|
||||
|
||||
if (isLastUByte4) {
|
||||
skippedBlendLastUByte4 = *(DWORD*)curPos;
|
||||
curPos = curPos + sizeof(DWORD);
|
||||
|
@ -316,6 +338,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].y = skippedBlend.y;
|
||||
vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].z = skippedBlend.z;
|
||||
vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].w = skippedBlend.w;
|
||||
|
||||
if (isLastUByte4) {
|
||||
vertex_shader_input.V[D3DVSDE_BLENDINDICES].x = (float) skippedBlendLastUByte4;
|
||||
vertex_shader_input.V[D3DVSDE_BLENDINDICES].y = (float) skippedBlendLastUByte4;
|
||||
|
@ -324,6 +347,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Vertex Normal Data (untransformed only) */
|
||||
if (normal) {
|
||||
nx = *(float *)curPos;
|
||||
|
@ -332,7 +356,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
curPos = curPos + sizeof(float);
|
||||
nz = *(float *)curPos;
|
||||
curPos = curPos + sizeof(float);
|
||||
/*TRACE("nx,ny,nz=%f,%f,%f\n", nx,ny,nz);*/
|
||||
VTRACE(("nx,ny,nz=%f,%f,%f\n", nx,ny,nz));
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
vertex_shader_input.V[D3DVSDE_NORMAL].x = nx;
|
||||
|
@ -341,9 +365,10 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
vertex_shader_input.V[D3DVSDE_NORMAL].w = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (isPtSize) {
|
||||
ptSize = *(float *)curPos;
|
||||
/*TRACE("ptSize=%f\n", ptSize);*/
|
||||
VTRACE(("ptSize=%f\n", ptSize));
|
||||
curPos = curPos + sizeof(float);
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
|
@ -353,9 +378,10 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
vertex_shader_input.V[D3DVSDE_PSIZE].w = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (isDiffuse) {
|
||||
diffuseColor = *(DWORD *)curPos;
|
||||
/*TRACE("diffuseColor=%lx\n", diffuseColor);*/
|
||||
VTRACE(("diffuseColor=%lx\n", diffuseColor));
|
||||
curPos = curPos + sizeof(DWORD);
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
|
@ -365,9 +391,10 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
vertex_shader_input.V[D3DVSDE_DIFFUSE].w = (float) (((diffuseColor >> 24) & 0xFF) / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (isSpecular) {
|
||||
specularColor = *(DWORD *)curPos;
|
||||
/*TRACE("specularColor=%lx\n", specularColor);*/
|
||||
VTRACE(("specularColor=%lx\n", specularColor));
|
||||
curPos = curPos + sizeof(DWORD);
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
|
@ -390,6 +417,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
FIXME("Program using more concurrent textures than this opengl implementation support\n");
|
||||
break ;
|
||||
}
|
||||
|
||||
/* Query tex coords */
|
||||
if (This->StateBlock.textures[textureNo] != NULL) {
|
||||
switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) This->StateBlock.textures[textureNo])) {
|
||||
|
@ -398,7 +426,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
curPos = curPos + sizeof(float);
|
||||
t = *(float *)curPos;
|
||||
curPos = curPos + sizeof(float);
|
||||
TRACE("tex:%d, s,t=%f,%f\n", textureNo, s,t);
|
||||
VTRACE(("tex:%d, s,t=%f,%f\n", textureNo, s,t));
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].x = s;
|
||||
|
@ -421,7 +449,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
curPos = curPos + sizeof(float);
|
||||
r = *(float *)curPos;
|
||||
curPos = curPos + sizeof(float);
|
||||
TRACE("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s,t,r);
|
||||
VTRACE(("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s,t,r));
|
||||
|
||||
if (TRUE == useVertexShaderFunction) {
|
||||
vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].x = s;
|
||||
|
@ -443,7 +471,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
}
|
||||
} else {
|
||||
/* Note I have seen a program actually do this, so just hide it and continue */
|
||||
TRACE("Very odd - texture requested in FVF but not bound!\n");
|
||||
VTRACE(("Very odd - texture requested in FVF but not bound!\n"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -495,7 +523,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
/*TRACE_VECTOR(vs_o.oT[textureNo]);*/
|
||||
s = vs_o.oT[textureNo].x;
|
||||
t = vs_o.oT[textureNo].y;
|
||||
TRACE("tex:%d, s,t=%f,%f\n", textureNo, s,t);
|
||||
VTRACE(("tex:%d, s,t=%f,%f\n", textureNo, s,t));
|
||||
if (This->isMultiTexture) {
|
||||
glMultiTexCoord2fARB(GL_TEXTURE0_ARB + textureNo, s, t);
|
||||
checkGLcall("glMultiTexCoord2fARB");
|
||||
|
@ -510,7 +538,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
s = vs_o.oT[textureNo].x;
|
||||
t = vs_o.oT[textureNo].y;
|
||||
r = vs_o.oT[textureNo].z;
|
||||
TRACE("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s,t,r);
|
||||
VTRACE(("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s,t,r));
|
||||
if (This->isMultiTexture) {
|
||||
glMultiTexCoord3fARB(GL_TEXTURE0_ARB + textureNo, s, t, r);
|
||||
checkGLcall("glMultiTexCoord2fARB");
|
||||
|
@ -529,11 +557,11 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
}
|
||||
|
||||
if (1.0f == rhw || rhw < 0.01f) {
|
||||
/*TRACE("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z);*/
|
||||
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z));
|
||||
glVertex3f(x, y, z);
|
||||
checkGLcall("glVertex3f");
|
||||
} else {
|
||||
/*TRACE("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw);*/
|
||||
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw));
|
||||
glVertex4f(x / rhw, y / rhw, z / rhw, 1.0f / rhw);
|
||||
checkGLcall("glVertex4f");
|
||||
}
|
||||
|
@ -545,35 +573,27 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
|
||||
/* Handle these vertexes */
|
||||
if (isDiffuse) {
|
||||
/*
|
||||
glColor4f(((diffuseColor >> 16) & 0xFF) / 255.0f,
|
||||
((diffuseColor >> 8) & 0xFF) / 255.0f,
|
||||
((diffuseColor >> 0) & 0xFF) / 255.0f,
|
||||
((diffuseColor >> 24) & 0xFF) / 255.0f);
|
||||
*/
|
||||
glColor4ub((diffuseColor >> 16) & 0xFF,
|
||||
(diffuseColor >> 8) & 0xFF,
|
||||
(diffuseColor >> 0) & 0xFF,
|
||||
(diffuseColor >> 24) & 0xFF);
|
||||
/*
|
||||
TRACE("glColor4f: r,g,b,a=%f,%f,%f,%f\n",
|
||||
VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n",
|
||||
((diffuseColor >> 16) & 0xFF) / 255.0f,
|
||||
((diffuseColor >> 8) & 0xFF) / 255.0f,
|
||||
((diffuseColor >> 0) & 0xFF) / 255.0f,
|
||||
((diffuseColor >> 24) & 0xFF) / 255.0f);
|
||||
*/
|
||||
((diffuseColor >> 24) & 0xFF) / 255.0f));
|
||||
}
|
||||
|
||||
if (normal) {
|
||||
/*TRACE("Vertex: glVertex:x,y,z=%f,%f,%f / glNormal:nx,ny,nz=%f,%f,%f\n", x,y,z,nx,ny,nz);*/
|
||||
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / glNormal:nx,ny,nz=%f,%f,%f\n", x,y,z,nx,ny,nz));
|
||||
glNormal3f(nx, ny, nz);
|
||||
glVertex3f(x, y, z);
|
||||
} else {
|
||||
if (1.0f == rhw || rhw < 0.01f) {
|
||||
/*TRACE("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z);*/
|
||||
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z));
|
||||
glVertex3f(x, y, z);
|
||||
} else {
|
||||
/*TRACE("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw);*/
|
||||
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw));
|
||||
glVertex4f(x / rhw, y / rhw, z / rhw, 1.0f / rhw);
|
||||
}
|
||||
}
|
||||
|
@ -587,6 +607,159 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface,
|
|||
glEnd();
|
||||
checkGLcall("glEnd and previous calls");
|
||||
|
||||
} else {
|
||||
FIXME("Using fast vertex array code\n");
|
||||
|
||||
/* Faster version, harder to debug */
|
||||
/* Shuffle to the beginning of the vertexes to render and index from there */
|
||||
curVtx = vertexBufData + (StartVertexIndex * skip);
|
||||
curPos = curVtx;
|
||||
|
||||
/* Set up the vertex pointers */
|
||||
if (isRHW) {
|
||||
glVertexPointer(4, GL_FLOAT, skip, curPos);
|
||||
checkGLcall("glVertexPointer(4, ...)");
|
||||
curPos += 4*sizeof(float);
|
||||
} else {
|
||||
glVertexPointer(3, GL_FLOAT, skip, curPos);
|
||||
checkGLcall("glVertexPointer(3, ...)");
|
||||
curPos += 3*sizeof(float);
|
||||
}
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
|
||||
|
||||
if (numBlends>0) {
|
||||
/* no such functionality in the fixed function GL pipeline */
|
||||
/* FIXME: Wont get here as will drop to slow method */
|
||||
FIXME("Cannot handle blending data here in openGl\n");
|
||||
}
|
||||
|
||||
|
||||
if (normal) {
|
||||
glNormalPointer(GL_FLOAT, skip, curPos);
|
||||
checkGLcall("glNormalPointer");
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
|
||||
curPos += 3*sizeof(float);
|
||||
} else {
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
checkGLcall("glDisableClientState(GL_NORMAL_ARRAY)");
|
||||
glNormal3f(0, 0, 1);
|
||||
checkGLcall("glNormal3f(0, 0, 1)");
|
||||
}
|
||||
|
||||
if (isPtSize) {
|
||||
/* no such functionality in the fixed function GL pipeline */
|
||||
/* FIXME: Wont get here as will drop to slow method */
|
||||
FIXME("Cannot change ptSize here in openGl\n");
|
||||
curPos = curPos + sizeof(float);
|
||||
}
|
||||
|
||||
if (isDiffuse) {
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, skip, curPos);
|
||||
checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
|
||||
curPos += sizeof(DWORD);
|
||||
}
|
||||
else {
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
checkGLcall("glDisableClientState(GL_COLOR_ARRAY)");
|
||||
glColor4f(1, 1, 1, 1);
|
||||
checkGLcall("glColor4f(1, 1, 1, 1)");
|
||||
}
|
||||
|
||||
/* Requires secondary color extensions to compile... */
|
||||
#if 0
|
||||
if (isSpecular) {
|
||||
/* FIXME: check for GL_EXT_secondary_color */
|
||||
glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, skip, curPos);
|
||||
checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, skip, curPos)");
|
||||
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
|
||||
curPos += sizeof(DWORD);
|
||||
} else {
|
||||
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
|
||||
glSecondaryColor3fEXT(0, 0, 0);
|
||||
checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ToDo: Texture coords */
|
||||
for (textureNo = 0;textureNo<numTextures; textureNo++) {
|
||||
|
||||
/* Query tex coords */
|
||||
glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
|
||||
if (This->StateBlock.textures[textureNo] != NULL) {
|
||||
enableTexture = TRUE;
|
||||
switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) This->StateBlock.textures[textureNo])) {
|
||||
case D3DRTYPE_TEXTURE:
|
||||
glTexCoordPointer(2, GL_FLOAT, skip, curPos);
|
||||
checkGLcall("glTexCoordPointer(2, ...)");
|
||||
curPos += 2*sizeof(float);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_TEXTURE_COORD_ARRAY);");
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VOLUMETEXTURE:
|
||||
glTexCoordPointer(3, GL_FLOAT, skip, curPos);
|
||||
checkGLcall("glTexCoordPointer(3, ...)");
|
||||
curPos += 3*sizeof(float);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_TEXTURE_COORD_ARRAY);");
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Unhandled texture type\n");
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
checkGLcall("glDisableClientState(GL_TEXTURE_COORD_ARRAY);");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* Note I have seen a program actually do this, so just hide it and continue */
|
||||
TRACE("Very odd - texture requested in FVF but not bound!\n");
|
||||
glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1);
|
||||
checkGLcall("glMultiTexCoord4f(... , 0, 0, 0, 1)");
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
checkGLcall("glDisableClientState(GL_TEXTURE_COORD_ARRAY);");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Finally do the drawing */
|
||||
if (isIndexed) {
|
||||
|
||||
TRACE("glElements(%x, %d, %d, ...)\n", primType, NumVertexes, minIndex);
|
||||
if (idxBytes==2) {
|
||||
#if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */
|
||||
glDrawElements(primType, NumVertexes, GL_UNSIGNED_SHORT, idxData+(2 * StartIdx));
|
||||
#else
|
||||
glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes,
|
||||
GL_UNSIGNED_SHORT, idxData+(2 * StartIdx));
|
||||
#endif
|
||||
} else {
|
||||
#if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */
|
||||
glDrawElements(primType, NumVertexes, GL_UNSIGNED_INT, idxData+(4 * StartIdx));
|
||||
#else
|
||||
glDrawRangeElements(primType, minIndex, minIndex+NumVertexes-1, NumVertexes,
|
||||
GL_UNSIGNED_INT, idxData+(2 * StartIdx));
|
||||
#endif
|
||||
}
|
||||
checkGLcall("glDrawRangeElements");
|
||||
|
||||
} else {
|
||||
|
||||
/* Note first is now zero as we shuffled along earlier */
|
||||
TRACE("glDrawArrays(%x, %ld, %d)\n", primType, StartIdx, NumVertexes);
|
||||
glDrawArrays(primType, 0, NumVertexes);
|
||||
checkGLcall("glDrawArrays");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* If no normals, restore previous lighting state */
|
||||
if (!normal) {
|
||||
if (isLightingOn) glEnable(GL_LIGHTING);
|
||||
|
@ -1432,19 +1605,20 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DT
|
|||
will able to do it quickly, only by changing the macro conv_mat. */
|
||||
|
||||
switch (d3dts) {
|
||||
case D3DTS_WORLDMATRIX(0): {
|
||||
case D3DTS_WORLDMATRIX(0):
|
||||
conv_mat(lpmatrix, &This->StateBlock.transforms[D3DTS_WORLDMATRIX(0)]);
|
||||
} break;
|
||||
break;
|
||||
|
||||
case D3DTS_VIEW: {
|
||||
case D3DTS_VIEW:
|
||||
conv_mat(lpmatrix, &This->StateBlock.transforms[D3DTS_VIEW]);
|
||||
} break;
|
||||
break;
|
||||
|
||||
case D3DTS_PROJECTION: {
|
||||
case D3DTS_PROJECTION:
|
||||
conv_mat(lpmatrix, &This->StateBlock.transforms[D3DTS_PROJECTION]);
|
||||
} break;
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Unhandled transform state!!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3277,7 +3451,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3D
|
|||
TRACE("(%p) : Type=%d, Start=%d, Count=%d\n", This, PrimitiveType, StartVertex, PrimitiveCount);
|
||||
|
||||
DrawPrimitiveI(iface, PrimitiveType, PrimitiveCount, FALSE,
|
||||
This->StateBlock.VertexShader, ((IDirect3DVertexBuffer8Impl *)pVB)->allocatedMemory, StartVertex, -1, 0, NULL);
|
||||
This->StateBlock.VertexShader, ((IDirect3DVertexBuffer8Impl *)pVB)->allocatedMemory, StartVertex, -1, 0, NULL, 0);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -3303,7 +3477,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 ifa
|
|||
}
|
||||
|
||||
DrawPrimitiveI(iface, PrimitiveType, primCount, TRUE, This->StateBlock.VertexShader, ((IDirect3DVertexBuffer8Impl *)pVB)->allocatedMemory,
|
||||
This->StateBlock.baseVertexIndex, startIndex, idxStride, ((IDirect3DIndexBuffer8Impl *) pIB)->allocatedMemory);
|
||||
This->StateBlock.baseVertexIndex, startIndex, idxStride, ((IDirect3DIndexBuffer8Impl *) pIB)->allocatedMemory,
|
||||
minIndex);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -3317,7 +3492,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D
|
|||
This->StateBlock.stream_source[0] = NULL;
|
||||
This->StateBlock.stream_stride[0] = VertexStreamZeroStride;
|
||||
DrawPrimitiveI(iface, PrimitiveType, PrimitiveCount, FALSE, This->StateBlock.VertexShader, pVertexStreamZeroData,
|
||||
0, 0, 0, NULL);
|
||||
0, 0, 0, NULL, 0);
|
||||
This->StateBlock.stream_stride[0] = 0;
|
||||
|
||||
/*stream zero settings set to null at end */
|
||||
|
@ -3342,7 +3517,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 i
|
|||
This->StateBlock.stream_source[0] = NULL;
|
||||
This->StateBlock.stream_stride[0] = VertexStreamZeroStride;
|
||||
DrawPrimitiveI(iface, PrimitiveType, PrimitiveCount, TRUE, This->StateBlock.VertexShader, pVertexStreamZeroData,
|
||||
This->StateBlock.baseVertexIndex, 0, idxStride, pIndexData);
|
||||
This->StateBlock.baseVertexIndex, 0, idxStride, pIndexData, MinVertexIndex);
|
||||
|
||||
/*stream zero settings set to null at end */
|
||||
This->StateBlock.stream_stride[0] = 0;
|
||||
|
@ -3915,6 +4090,7 @@ void CreateStateBlock(LPDIRECT3DDEVICE8 iface) {
|
|||
|
||||
/* Texture Stage States - Put directly into state block, we will call function below */
|
||||
for (i=0; i<This->TextureUnits;i++) {
|
||||
memcpy(&This->StateBlock.transforms[D3DTS_TEXTURE0+i], &idmatrix, sizeof(idmatrix));
|
||||
This->StateBlock.texture_state[i][D3DTSS_COLOROP ] = (i==0)? D3DTOP_MODULATE : D3DTOP_DISABLE;
|
||||
This->StateBlock.texture_state[i][D3DTSS_COLORARG1 ] = D3DTA_TEXTURE;
|
||||
This->StateBlock.texture_state[i][D3DTSS_COLORARG2 ] = D3DTA_CURRENT;
|
||||
|
|
Loading…
Reference in New Issue