1999-01-03 18:00:19 +01:00
|
|
|
/* Direct3D ExecuteBuffer
|
|
|
|
(c) 1998 Lionel ULMER
|
|
|
|
|
|
|
|
This files contains the implementation of Direct3DExecuteBuffer. */
|
|
|
|
|
|
|
|
|
1999-02-28 13:27:56 +01:00
|
|
|
#include <string.h>
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "config.h"
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "winerror.h"
|
1999-02-02 17:14:23 +01:00
|
|
|
#include "wine/obj_base.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "heap.h"
|
|
|
|
#include "ddraw.h"
|
|
|
|
#include "d3d.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "mesa_private.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)(x)->private)
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(ddraw);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
/* Structure to store the 'semi transformed' vertices */
|
|
|
|
typedef struct {
|
|
|
|
D3DVALUE x;
|
|
|
|
D3DVALUE y;
|
|
|
|
D3DVALUE z;
|
|
|
|
D3DVALUE w;
|
|
|
|
|
|
|
|
D3DVALUE nx;
|
|
|
|
D3DVALUE ny;
|
|
|
|
D3DVALUE nz;
|
|
|
|
|
|
|
|
D3DVALUE u;
|
|
|
|
D3DVALUE v;
|
|
|
|
} OGL_Vertex;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
D3DVALUE x;
|
|
|
|
D3DVALUE y;
|
|
|
|
D3DVALUE z;
|
|
|
|
D3DVALUE w;
|
|
|
|
|
|
|
|
D3DCOLOR c;
|
|
|
|
D3DCOLOR sc;
|
|
|
|
|
|
|
|
D3DVALUE u;
|
|
|
|
D3DVALUE v;
|
|
|
|
} OGL_LVertex;
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static ICOM_VTABLE(IDirect3DExecuteBuffer) executebuffer_vtable;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* ExecuteBuffer static functions
|
|
|
|
*/
|
|
|
|
void _dump_d3dstatus(LPD3DSTATUS lpStatus) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void _dump_executedata(LPD3DEXECUTEDATA lpData) {
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("dwSize : %ld\n", lpData->dwSize);
|
|
|
|
DPRINTF("Vertex Offset : %ld Count : %ld\n", lpData->dwVertexOffset, lpData->dwVertexCount);
|
|
|
|
DPRINTF("Instruction Offset : %ld Length : %ld\n", lpData->dwInstructionOffset, lpData->dwInstructionLength);
|
|
|
|
DPRINTF("HVertex Offset : %ld\n", lpData->dwHVertexOffset);
|
1999-01-03 18:00:19 +01:00
|
|
|
_dump_d3dstatus(&(lpData->dsStatus));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DO_VERTEX(index) \
|
1999-01-23 13:29:44 +01:00
|
|
|
{ \
|
|
|
|
glTexCoord2f(vx[index].u, \
|
|
|
|
vx[index].v); \
|
|
|
|
glNormal3f(vx[index].nx, \
|
|
|
|
vx[index].ny, \
|
|
|
|
vx[index].nz); \
|
|
|
|
glVertex4f(vx[index].x, \
|
|
|
|
vx[index].y, \
|
|
|
|
vx[index].z, \
|
|
|
|
vx[index].w); \
|
|
|
|
\
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" V: %f %f %f %f (%f %f %f) (%f %f)\n", \
|
1999-01-23 13:29:44 +01:00
|
|
|
vx[index].x, vx[index].y, vx[index].z, vx[index].w, \
|
|
|
|
vx[index].nx, vx[index].ny, vx[index].nz, \
|
|
|
|
vx[index].u, vx[index].v); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DO_LVERTEX(index) \
|
|
|
|
{ \
|
|
|
|
DWORD col = l_vx[index].c; \
|
|
|
|
\
|
|
|
|
glColor3f(((col >> 16) & 0xFF) / 255.0, \
|
|
|
|
((col >> 8) & 0xFF) / 255.0, \
|
|
|
|
((col >> 0) & 0xFF) / 255.0); \
|
|
|
|
glTexCoord2f(l_vx[index].u, \
|
|
|
|
l_vx[index].v); \
|
|
|
|
glVertex4f(l_vx[index].x, \
|
|
|
|
l_vx[index].y, \
|
|
|
|
l_vx[index].z, \
|
|
|
|
l_vx[index].w); \
|
|
|
|
\
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" LV: %f %f %f %f (%02lx %02lx %02lx) (%f %f)\n", \
|
1999-01-23 13:29:44 +01:00
|
|
|
l_vx[index].x, l_vx[index].y, l_vx[index].z, l_vx[index].w, \
|
|
|
|
((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF), \
|
|
|
|
l_vx[index].u, l_vx[index].v); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DO_TLVERTEX(index) \
|
|
|
|
{ \
|
|
|
|
D3DTLVERTEX *vx = &(tl_vx[index]); \
|
2000-12-03 04:16:05 +01:00
|
|
|
DWORD col = vx->u5.color; \
|
1999-01-23 13:29:44 +01:00
|
|
|
\
|
|
|
|
glColor3f(((col >> 16) & 0xFF) / 255.0, \
|
|
|
|
((col >> 8) & 0xFF) / 255.0, \
|
|
|
|
((col >> 0) & 0xFF) / 255.0); \
|
2000-12-03 04:16:05 +01:00
|
|
|
glTexCoord2f(vx->u7.tu, vx->u8.tv); \
|
|
|
|
if (vx->u4.rhw < 0.01) \
|
|
|
|
glVertex3f(vx->u1.sx, \
|
|
|
|
vx->u2.sy, \
|
|
|
|
vx->u3.sz); \
|
1999-01-23 13:29:44 +01:00
|
|
|
else \
|
2000-12-03 04:16:05 +01:00
|
|
|
glVertex4f(vx->u1.sx / vx->u4.rhw, \
|
|
|
|
vx->u2.sy / vx->u4.rhw, \
|
|
|
|
vx->u3.sz / vx->u4.rhw, \
|
|
|
|
1.0 / vx->u4.rhw); \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" TLV: %f %f %f (%02lx %02lx %02lx) (%f %f) (%f)\n", \
|
2000-12-03 04:16:05 +01:00
|
|
|
vx->u1.sx, vx->u2.sy, vx->u3.sz, \
|
1999-01-23 13:29:44 +01:00
|
|
|
((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF), \
|
2000-12-03 04:16:05 +01:00
|
|
|
vx->u7.tu, vx->u8.tv, vx->u4.rhw); \
|
1999-01-23 13:29:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define TRIANGLE_LOOP(macro) \
|
|
|
|
{ \
|
|
|
|
glBegin(GL_TRIANGLES); { \
|
|
|
|
for (i = 0; i < count; i++) { \
|
|
|
|
LPD3DTRIANGLE ci = (LPD3DTRIANGLE) instr; \
|
|
|
|
\
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" v1: %d v2: %d v3: %d\n", \
|
2000-12-03 04:16:05 +01:00
|
|
|
ci->u1.v1, ci->u2.v2, ci->u3.v3); \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Flags : "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
if (TRACE_ON(ddraw)) { \
|
|
|
|
/* Wireframe */ \
|
|
|
|
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("EDGEENABLE1 "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("EDGEENABLE2 "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("EDGEENABLE3 "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
\
|
|
|
|
/* Strips / Fans */ \
|
|
|
|
if (ci->wFlags == D3DTRIFLAG_EVEN) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("EVEN "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
if (ci->wFlags == D3DTRIFLAG_ODD) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("ODD "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
if (ci->wFlags == D3DTRIFLAG_START) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("START "); \
|
1999-01-23 13:29:44 +01:00
|
|
|
if ((ci->wFlags > 0) && (ci->wFlags < 30)) \
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("STARTFLAT(%d) ", ci->wFlags); \
|
|
|
|
DPRINTF("\n"); \
|
1999-01-23 13:29:44 +01:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* Draw the triangle */ \
|
2000-12-03 04:16:05 +01:00
|
|
|
macro(ci->u1.v1); \
|
|
|
|
macro(ci->u2.v2); \
|
|
|
|
macro(ci->u3.v3); \
|
1999-01-23 13:29:44 +01:00
|
|
|
\
|
|
|
|
instr += size; \
|
|
|
|
} \
|
|
|
|
} glEnd(); \
|
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
static void execute(LPDIRECT3DEXECUTEBUFFER lpBuff,
|
|
|
|
LPDIRECT3DDEVICE dev,
|
|
|
|
LPDIRECT3DVIEWPORT vp) {
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DExecuteBufferImpl* ilpBuff=(IDirect3DExecuteBufferImpl*)lpBuff;
|
|
|
|
IDirect3DViewport2Impl* ivp=(IDirect3DViewport2Impl*)vp;
|
|
|
|
/* DWORD bs = ilpBuff->desc.dwBufferSize; */
|
|
|
|
DWORD vs = ilpBuff->data.dwVertexOffset;
|
|
|
|
/* DWORD vc = ilpBuff->data.dwVertexCount; */
|
|
|
|
DWORD is = ilpBuff->data.dwInstructionOffset;
|
|
|
|
/* DWORD il = ilpBuff->data.dwInstructionLength; */
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
void *instr = ilpBuff->desc.lpData + is;
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE((IDirect3DDeviceImpl*)dev);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("ExecuteData : \n");
|
1999-01-23 13:29:44 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
1999-03-27 17:56:13 +01:00
|
|
|
_dump_executedata(&(ilpBuff->data));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
while (1) {
|
|
|
|
LPD3DINSTRUCTION current = (LPD3DINSTRUCTION) instr;
|
|
|
|
BYTE size;
|
|
|
|
WORD count;
|
|
|
|
|
|
|
|
count = current->wCount;
|
|
|
|
size = current->bSize;
|
|
|
|
instr += sizeof(D3DINSTRUCTION);
|
|
|
|
|
|
|
|
switch (current->bOpcode) {
|
|
|
|
case D3DOP_POINT: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("POINT-s (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
instr += count * size;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_LINE: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("LINE-s (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
instr += count * size;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_TRIANGLE: {
|
|
|
|
int i;
|
1999-01-23 13:29:44 +01:00
|
|
|
float z_inv_matrix[16] = {
|
|
|
|
1.0, 0.0, 0.0, 0.0,
|
|
|
|
0.0, 1.0, 0.0, 0.0,
|
|
|
|
0.0, 0.0, -1.0, 0.0,
|
|
|
|
0.0, 0.0, 1.0, 1.0
|
|
|
|
};
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
OGL_Vertex *vx = (OGL_Vertex *) ilpBuff->vertex_data;
|
|
|
|
OGL_LVertex *l_vx = (OGL_LVertex *) ilpBuff->vertex_data;
|
|
|
|
D3DTLVERTEX *tl_vx = (D3DTLVERTEX *) ilpBuff->vertex_data;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("TRIANGLE (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
switch (ilpBuff->vertex_type) {
|
1999-01-23 13:29:44 +01:00
|
|
|
case D3DVT_VERTEX:
|
|
|
|
/* This time, there is lighting */
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Use given matrixes */
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity(); /* The model transformation was done during the
|
|
|
|
transformation phase */
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Projection Matrix : (%p)\n", odev->proj_mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
dump_mat(odev->proj_mat);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" View Matrix : (%p)\n", odev->view_mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
dump_mat(odev->view_mat);
|
|
|
|
|
|
|
|
glLoadMatrixf((float *) z_inv_matrix);
|
|
|
|
glMultMatrixf((float *) odev->proj_mat);
|
1999-01-03 18:00:19 +01:00
|
|
|
glMultMatrixf((float *) odev->view_mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
break;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
case D3DVT_LVERTEX:
|
|
|
|
/* No lighting */
|
|
|
|
glDisable(GL_LIGHTING);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
/* Use given matrixes */
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity(); /* The model transformation was done during the
|
|
|
|
transformation phase */
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Projection Matrix : (%p)\n", odev->proj_mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
dump_mat(odev->proj_mat);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" View Matrix : (%p)\n", odev->view_mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
dump_mat(odev->view_mat);
|
|
|
|
|
|
|
|
glLoadMatrixf((float *) z_inv_matrix);
|
|
|
|
glMultMatrixf((float *) odev->proj_mat);
|
|
|
|
glMultMatrixf((float *) odev->view_mat);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DVT_TLVERTEX: {
|
|
|
|
GLdouble height, width, minZ, maxZ;
|
|
|
|
|
|
|
|
/* First, disable lighting */
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
|
|
|
/* Then do not put any transformation matrixes */
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (ivp == NULL) {
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("No current viewport !\n");
|
1999-01-23 13:29:44 +01:00
|
|
|
/* Using standard values */
|
|
|
|
height = 640.0;
|
|
|
|
width = 480.0;
|
|
|
|
minZ = -10.0;
|
|
|
|
maxZ = 10.0;
|
|
|
|
} else {
|
1999-03-27 17:56:13 +01:00
|
|
|
height = (GLdouble) ivp->viewport.vp1.dwHeight;
|
|
|
|
width = (GLdouble) ivp->viewport.vp1.dwWidth;
|
|
|
|
minZ = (GLdouble) ivp->viewport.vp1.dvMinZ;
|
|
|
|
maxZ = (GLdouble) ivp->viewport.vp1.dvMaxZ;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
if (minZ == maxZ) {
|
|
|
|
/* I do not know why, but many Dx 3.0 games have minZ = maxZ = 0.0 */
|
|
|
|
minZ = 0.0;
|
|
|
|
maxZ = 1.0;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
1999-01-23 13:29:44 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
glOrtho(0.0, width, height, 0.0, -minZ, -maxZ);
|
|
|
|
} break;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Unhandled vertex type !\n");
|
1999-01-23 13:29:44 +01:00
|
|
|
break;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
1999-01-23 13:29:44 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
switch (ilpBuff->vertex_type) {
|
1999-01-23 13:29:44 +01:00
|
|
|
case D3DVT_VERTEX:
|
|
|
|
TRIANGLE_LOOP(DO_VERTEX);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DVT_LVERTEX:
|
|
|
|
TRIANGLE_LOOP(DO_LVERTEX);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DVT_TLVERTEX:
|
|
|
|
TRIANGLE_LOOP(DO_TLVERTEX);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Unhandled vertex type !\n");
|
1999-01-23 13:29:44 +01:00
|
|
|
}
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_MATRIXLOAD: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("MATRIXLOAD-s (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
instr += count * size;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_MATRIXMULTIPLY: {
|
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("MATRIXMULTIPLY (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DMATRIXMULTIPLY ci = (LPD3DMATRIXMULTIPLY) instr;
|
|
|
|
LPD3DMATRIX a = (LPD3DMATRIX) ci->hDestMatrix;
|
|
|
|
LPD3DMATRIX b = (LPD3DMATRIX) ci->hSrcMatrix1;
|
|
|
|
LPD3DMATRIX c = (LPD3DMATRIX) ci->hSrcMatrix2;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Dest : %08lx Src1 : %08lx Src2 : %08lx\n",
|
1999-01-03 18:00:19 +01:00
|
|
|
ci->hDestMatrix, ci->hSrcMatrix1, ci->hSrcMatrix2);
|
|
|
|
|
|
|
|
/* Do the multiplication..
|
|
|
|
As I am VERY lazy, I let OpenGL do the multiplication for me */
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
/* Save the current matrix */
|
|
|
|
glPushMatrix();
|
|
|
|
/* Load Matrix one and do the multiplication */
|
1999-01-23 13:29:44 +01:00
|
|
|
glLoadMatrixf((float *) c);
|
|
|
|
glMultMatrixf((float *) b);
|
|
|
|
glGetFloatv(GL_PROJECTION_MATRIX, (float *) a);
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Restore the current matrix */
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_STATETRANSFORM: {
|
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("STATETRANSFORM (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DSTATE ci = (LPD3DSTATE) instr;
|
|
|
|
|
|
|
|
/* Handle the state transform */
|
2000-12-03 04:16:05 +01:00
|
|
|
switch (ci->u1.dtstTransformStateType) {
|
1999-01-03 18:00:19 +01:00
|
|
|
case D3DTRANSFORMSTATE_WORLD: {
|
2000-12-03 04:16:05 +01:00
|
|
|
TRACE(" WORLD (%p)\n", (D3DMATRIX*) ci->u2.dwArg[0]);
|
|
|
|
odev->world_mat = (D3DMATRIX*) ci->u2.dwArg[0];
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DTRANSFORMSTATE_VIEW: {
|
2000-12-03 04:16:05 +01:00
|
|
|
TRACE(" VIEW (%p)\n", (D3DMATRIX*) ci->u2.dwArg[0]);
|
|
|
|
odev->view_mat = (D3DMATRIX*) ci->u2.dwArg[0];
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DTRANSFORMSTATE_PROJECTION: {
|
2000-12-03 04:16:05 +01:00
|
|
|
TRACE(" PROJECTION (%p)\n", (D3DMATRIX*) ci->u2.dwArg[0]);
|
|
|
|
odev->proj_mat = (D3DMATRIX*) ci->u2.dwArg[0];
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
2000-12-03 04:16:05 +01:00
|
|
|
ERR(" Unhandled state transformation !! (%d)\n", (int) ci->u1.dtstTransformStateType);
|
1999-01-03 18:00:19 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_STATELIGHT: {
|
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("STATELIGHT (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DSTATE ci = (LPD3DSTATE) instr;
|
|
|
|
|
|
|
|
/* Handle the state transform */
|
2000-12-03 04:16:05 +01:00
|
|
|
switch (ci->u1.dlstLightStateType) {
|
1999-01-03 18:00:19 +01:00
|
|
|
case D3DLIGHTSTATE_MATERIAL: {
|
2000-12-03 04:16:05 +01:00
|
|
|
IDirect3DMaterial2Impl* mat = (IDirect3DMaterial2Impl*) ci->u2.dwArg[0];
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" MATERIAL\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
if (mat != NULL) {
|
|
|
|
mat->activate(mat);
|
|
|
|
} else {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" bad Material Handle\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
} break ;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_AMBIENT: {
|
|
|
|
float light[4];
|
2000-12-03 04:16:05 +01:00
|
|
|
DWORD dwLightState = ci->u2.dwArg[0];
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" AMBIENT\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
light[0] = ((dwLightState >> 16) & 0xFF) / 255.0;
|
|
|
|
light[1] = ((dwLightState >> 8) & 0xFF) / 255.0;
|
|
|
|
light[2] = ((dwLightState >> 0) & 0xFF) / 255.0;
|
|
|
|
light[3] = 1.0;
|
|
|
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light);
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" R:%02lx G:%02lx B:%02lx A:%02lx\n",
|
1999-01-03 18:00:19 +01:00
|
|
|
((dwLightState >> 16) & 0xFF),
|
|
|
|
((dwLightState >> 8) & 0xFF),
|
|
|
|
((dwLightState >> 0) & 0xFF),
|
|
|
|
((dwLightState >> 24) & 0xFF));
|
|
|
|
} break ;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_COLORMODEL: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" COLORMODEL\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
} break ;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_FOGMODE: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" FOGMODE\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
} break ;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_FOGSTART: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" FOGSTART\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
} break ;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_FOGEND: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" FOGEND\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
} break ;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_FOGDENSITY: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" FOGDENSITY\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
} break ;
|
|
|
|
|
|
|
|
default:
|
2000-12-03 04:16:05 +01:00
|
|
|
ERR(" Unhandled light state !! (%d)\n", (int) ci->u1.dlstLightStateType);
|
1999-01-03 18:00:19 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_STATERENDER: {
|
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("STATERENDER (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DSTATE ci = (LPD3DSTATE) instr;
|
|
|
|
|
|
|
|
/* Handle the state transform */
|
2000-12-03 04:16:05 +01:00
|
|
|
set_render_state(ci->u1.drstRenderStateType, ci->u2.dwArg[0], &(odev->rs));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_PROCESSVERTICES: {
|
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("PROCESSVERTICES (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DPROCESSVERTICES ci = (LPD3DPROCESSVERTICES) instr;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Start : %d Dest : %d Count : %ld\n",
|
1999-01-03 18:00:19 +01:00
|
|
|
ci->wStart, ci->wDest, ci->dwCount);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Flags : ");
|
1999-01-03 18:00:19 +01:00
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
if (ci->dwFlags & D3DPROCESSVERTICES_COPY)
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("COPY ");
|
1999-01-03 18:00:19 +01:00
|
|
|
if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("NOCOLOR ");
|
1999-01-03 18:00:19 +01:00
|
|
|
if (ci->dwFlags == D3DPROCESSVERTICES_OPMASK)
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("OPMASK ");
|
1999-01-03 18:00:19 +01:00
|
|
|
if (ci->dwFlags & D3DPROCESSVERTICES_TRANSFORM)
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("TRANSFORM ");
|
1999-01-03 18:00:19 +01:00
|
|
|
if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT)
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("TRANSFORMLIGHT ");
|
1999-01-03 18:00:19 +01:00
|
|
|
if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
|
1999-06-26 21:09:08 +02:00
|
|
|
DPRINTF("UPDATEEXTENTS ");
|
|
|
|
DPRINTF("\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This is where doing Direct3D on top on OpenGL is quite difficult.
|
|
|
|
This method transforms a set of vertices using the CURRENT state
|
|
|
|
(lighting, projection, ...) but does not rasterize them.
|
|
|
|
They will oinly be put on screen later (with the POINT / LINE and
|
|
|
|
TRIANGLE op-codes). The problem is that you can have a triangle
|
|
|
|
with each point having been transformed using another state...
|
|
|
|
|
|
|
|
In this implementation, I will emulate only ONE thing : each
|
|
|
|
vertex can have its own "WORLD" transformation (this is used in the
|
|
|
|
TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the
|
|
|
|
execute buffer use the same state.
|
|
|
|
|
|
|
|
If I find applications that change other states, I will try to do a
|
|
|
|
more 'fine-tuned' state emulation (but I may become quite tricky if
|
|
|
|
it changes a light position in the middle of a triangle).
|
|
|
|
|
|
|
|
In this case, a 'direct' approach (i.e. without using OpenGL, but
|
|
|
|
writing our own 3D rasterizer) would be easier. */
|
|
|
|
|
|
|
|
/* The current method (with the hypothesis that only the WORLD matrix
|
|
|
|
will change between two points) is like this :
|
|
|
|
- I transform 'manually' all the vertices with the current WORLD
|
|
|
|
matrix and store them in the vertex buffer
|
|
|
|
- during the rasterization phase, the WORLD matrix will be set to
|
|
|
|
the Identity matrix */
|
|
|
|
|
|
|
|
/* Enough for the moment */
|
|
|
|
if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
|
1999-01-23 13:29:44 +01:00
|
|
|
int nb;
|
1999-03-27 17:56:13 +01:00
|
|
|
D3DVERTEX *src = ((LPD3DVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
|
|
|
|
OGL_Vertex *dst = ((OGL_Vertex *) (ilpBuff->vertex_data)) + ci->wDest;
|
1999-01-23 13:29:44 +01:00
|
|
|
D3DMATRIX *mat = odev->world_mat;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" World Matrix : (%p)\n", mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
dump_mat(mat);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
ilpBuff->vertex_type = D3DVT_VERTEX;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
for (nb = 0; nb < ci->dwCount; nb++) {
|
|
|
|
/* For the moment, no normal transformation... */
|
2000-12-03 04:16:05 +01:00
|
|
|
dst->nx = src->u4.nx;
|
|
|
|
dst->ny = src->u5.ny;
|
|
|
|
dst->nz = src->u6.nz;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
2000-12-03 04:16:05 +01:00
|
|
|
dst->u = src->u7.tu;
|
|
|
|
dst->v = src->u8.tv;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
/* Now, the matrix multiplication */
|
2000-12-03 04:16:05 +01:00
|
|
|
dst->x = (src->u1.x * mat->_11) + (src->u2.y * mat->_21) + (src->u3.z * mat->_31) + (1.0 * mat->_41);
|
|
|
|
dst->y = (src->u1.x * mat->_12) + (src->u2.y * mat->_22) + (src->u3.z * mat->_32) + (1.0 * mat->_42);
|
|
|
|
dst->z = (src->u1.x * mat->_13) + (src->u2.y * mat->_23) + (src->u3.z * mat->_33) + (1.0 * mat->_43);
|
|
|
|
dst->w = (src->u1.x * mat->_14) + (src->u2.y * mat->_24) + (src->u3.z * mat->_34) + (1.0 * mat->_44);
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
src++;
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
} else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
|
|
|
|
int nb;
|
1999-03-27 17:56:13 +01:00
|
|
|
D3DLVERTEX *src = ((LPD3DLVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
|
|
|
|
OGL_LVertex *dst = ((OGL_LVertex *) (ilpBuff->vertex_data)) + ci->wDest;
|
1999-01-23 13:29:44 +01:00
|
|
|
D3DMATRIX *mat = odev->world_mat;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" World Matrix : (%p)\n", mat);
|
1999-01-23 13:29:44 +01:00
|
|
|
dump_mat(mat);
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
ilpBuff->vertex_type = D3DVT_LVERTEX;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
for (nb = 0; nb < ci->dwCount; nb++) {
|
2000-12-03 04:16:05 +01:00
|
|
|
dst->c = src->u4.color;
|
|
|
|
dst->sc = src->u5.specular;
|
|
|
|
dst->u = src->u6.tu;
|
|
|
|
dst->v = src->u7.tv;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
/* Now, the matrix multiplication */
|
2000-12-03 04:16:05 +01:00
|
|
|
dst->x = (src->u1.x * mat->_11) + (src->u2.y * mat->_21) + (src->u3.z * mat->_31) + (1.0 * mat->_41);
|
|
|
|
dst->y = (src->u1.x * mat->_12) + (src->u2.y * mat->_22) + (src->u3.z * mat->_32) + (1.0 * mat->_42);
|
|
|
|
dst->z = (src->u1.x * mat->_13) + (src->u2.y * mat->_23) + (src->u3.z * mat->_33) + (1.0 * mat->_43);
|
|
|
|
dst->w = (src->u1.x * mat->_14) + (src->u2.y * mat->_24) + (src->u3.z * mat->_34) + (1.0 * mat->_44);
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
src++;
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
} else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) {
|
1999-03-27 17:56:13 +01:00
|
|
|
D3DTLVERTEX *src = ((LPD3DTLVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
|
|
|
|
D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (ilpBuff->vertex_data)) + ci->wDest;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
ilpBuff->vertex_type = D3DVT_TLVERTEX;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
memcpy(dst, src, ci->dwCount * sizeof(D3DTLVERTEX));
|
|
|
|
} else {
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Unhandled vertex processing !\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_TEXTURELOAD: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("TEXTURELOAD-s (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
instr += count * size;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_EXIT: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("EXIT (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
/* We did this instruction */
|
|
|
|
instr += size;
|
|
|
|
/* Exit this loop */
|
|
|
|
goto end_of_buffer;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_BRANCHFORWARD: {
|
1999-01-23 13:29:44 +01:00
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("BRANCHFORWARD (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DBRANCH ci = (LPD3DBRANCH) instr;
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if ((ilpBuff->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) {
|
1999-01-23 13:29:44 +01:00
|
|
|
if (!ci->bNegate) {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Should branch to %ld\n", ci->dwOffset);
|
1999-01-23 13:29:44 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ci->bNegate) {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" Should branch to %ld\n", ci->dwOffset);
|
1999-01-23 13:29:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_SPAN: {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("SPAN-s (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
instr += count * size;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DOP_SETSTATUS: {
|
1999-01-23 13:29:44 +01:00
|
|
|
int i;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("SETSTATUS (%d)\n", count);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-23 13:29:44 +01:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
LPD3DSTATUS ci = (LPD3DSTATUS) instr;
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
ilpBuff->data.dsStatus = *ci;
|
1999-01-23 13:29:44 +01:00
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Unhandled OpCode !!!\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Try to save ... */
|
|
|
|
instr += count * size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end_of_buffer:
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* ExecuteBuffer Creation functions
|
|
|
|
*/
|
1999-03-27 17:56:13 +01:00
|
|
|
LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(IDirect3DDeviceImpl* d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DExecuteBufferImpl* eb;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
eb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DExecuteBufferImpl));
|
1999-01-03 18:00:19 +01:00
|
|
|
eb->ref = 1;
|
1999-10-31 02:59:23 +01:00
|
|
|
ICOM_VTBL(eb) = &executebuffer_vtable;
|
1999-01-03 18:00:19 +01:00
|
|
|
eb->d3ddev = d3ddev;
|
|
|
|
|
|
|
|
/* Initializes memory */
|
|
|
|
eb->desc = *lpDesc;
|
|
|
|
|
|
|
|
/* No buffer given */
|
|
|
|
if (!(eb->desc.dwFlags & D3DDEB_LPDATA))
|
|
|
|
eb->desc.lpData = NULL;
|
|
|
|
|
|
|
|
/* No buffer size given */
|
|
|
|
if (!(lpDesc->dwFlags & D3DDEB_BUFSIZE))
|
|
|
|
eb->desc.dwBufferSize = 0;
|
|
|
|
|
|
|
|
/* Create buffer if asked */
|
|
|
|
if ((eb->desc.lpData == NULL) && (eb->desc.dwBufferSize > 0)) {
|
|
|
|
eb->need_free = TRUE;
|
|
|
|
eb->desc.lpData = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,eb->desc.dwBufferSize);
|
|
|
|
} else {
|
|
|
|
eb->need_free = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No vertices for the moment */
|
|
|
|
eb->vertex_data = NULL;
|
|
|
|
|
|
|
|
eb->desc.dwFlags |= D3DDEB_LPDATA;
|
|
|
|
|
|
|
|
eb->execute = execute;
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
return (LPDIRECT3DEXECUTEBUFFER)eb;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
1999-03-27 17:56:13 +01:00
|
|
|
* IDirect3ExecuteBuffer methods
|
1999-01-03 18:00:19 +01:00
|
|
|
*/
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_QueryInterface(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppvObj)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-01-18 06:09:49 +01:00
|
|
|
FIXME("(%p)->(%s,%p): stub\n", This, debugstr_guid(riid),ppvObj);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static ULONG WINAPI IDirect3DExecuteBufferImpl_AddRef(LPDIRECT3DEXECUTEBUFFER iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->()incrementing from %lu.\n", This, This->ref );
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
return ++(This->ref);
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static ULONG WINAPI IDirect3DExecuteBufferImpl_Release(LPDIRECT3DEXECUTEBUFFER iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (!--(This->ref)) {
|
|
|
|
if ((This->desc.lpData != NULL) && This->need_free)
|
|
|
|
HeapFree(GetProcessHeap(),0,This->desc.lpData);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (This->vertex_data != NULL)
|
|
|
|
HeapFree(GetProcessHeap(),0,This->vertex_data);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-01-03 18:00:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
return This->ref;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_Initialize(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPDIRECT3DDEVICE lpDirect3DDevice,
|
|
|
|
LPD3DEXECUTEBUFFERDESC lpDesc)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n", This, lpDirect3DDevice, lpDesc);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_Lock(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPD3DEXECUTEBUFFERDESC lpDesc)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, lpDesc);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Copies the buffer description */
|
1999-03-27 17:56:13 +01:00
|
|
|
*lpDesc = This->desc;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_Unlock(LPDIRECT3DEXECUTEBUFFER iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->()\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_SetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPD3DEXECUTEDATA lpData)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-01-03 18:00:19 +01:00
|
|
|
DWORD nbvert;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, lpData);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
This->data = *lpData;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Get the number of vertices in the execute buffer */
|
1999-03-27 17:56:13 +01:00
|
|
|
nbvert = This->data.dwVertexCount;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Prepares the transformed vertex buffer */
|
1999-03-27 17:56:13 +01:00
|
|
|
if (This->vertex_data != NULL)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->vertex_data);
|
|
|
|
This->vertex_data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,nbvert * sizeof(OGL_Vertex));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
_dump_executedata(lpData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_GetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPD3DEXECUTEDATA lpData)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p): stub\n", This, lpData);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
*lpData = This->data;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_Validate(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPDWORD lpdwOffset,
|
|
|
|
LPD3DVALIDATECALLBACK lpFunc,
|
|
|
|
LPVOID lpUserArg,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p,%p,%p,%lu)\n", This, lpdwOffset, lpFunc, lpUserArg, dwReserved);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DExecuteBufferImpl_Optimize(LPDIRECT3DEXECUTEBUFFER iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%lu)\n", This, dwReserved);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirect3DLight VTable
|
|
|
|
*/
|
1999-05-22 13:41:38 +02:00
|
|
|
static ICOM_VTABLE(IDirect3DExecuteBuffer) executebuffer_vtable =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IUnknown methods ***/
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DExecuteBufferImpl_QueryInterface,
|
|
|
|
IDirect3DExecuteBufferImpl_AddRef,
|
|
|
|
IDirect3DExecuteBufferImpl_Release,
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IDirect3DExecuteBuffer methods ***/
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DExecuteBufferImpl_Initialize,
|
|
|
|
IDirect3DExecuteBufferImpl_Lock,
|
|
|
|
IDirect3DExecuteBufferImpl_Unlock,
|
|
|
|
IDirect3DExecuteBufferImpl_SetExecuteData,
|
|
|
|
IDirect3DExecuteBufferImpl_GetExecuteData,
|
|
|
|
IDirect3DExecuteBufferImpl_Validate,
|
|
|
|
IDirect3DExecuteBufferImpl_Optimize
|
1999-01-03 18:00:19 +01:00
|
|
|
};
|