1 /* Direct3D ExecuteBuffer
4 This files contains the implementation of Direct3DExecuteBuffer. */
11 #include "wine/obj_base.h"
17 #include "d3d_private.h"
19 DEFAULT_DEBUG_CHANNEL(ddraw)
23 /* Structure to store the 'semi transformed' vertices */
51 static ICOM_VTABLE(IDirect3DExecuteBuffer) executebuffer_vtable;
53 /*******************************************************************************
54 * ExecuteBuffer static functions
56 void _dump_d3dstatus(LPD3DSTATUS lpStatus) {
60 void _dump_executedata(LPD3DEXECUTEDATA lpData) {
61 DUMP("dwSize : %ld\n", lpData->dwSize);
62 DUMP("Vertex Offset : %ld Count : %ld\n", lpData->dwVertexOffset, lpData->dwVertexCount);
63 DUMP("Instruction Offset : %ld Length : %ld\n", lpData->dwInstructionOffset, lpData->dwInstructionLength);
64 DUMP("HVertex Offset : %ld\n", lpData->dwHVertexOffset);
65 _dump_d3dstatus(&(lpData->dsStatus));
68 #define DO_VERTEX(index) \
70 glTexCoord2f(vx[index].u, \
72 glNormal3f(vx[index].nx, \
75 glVertex4f(vx[index].x, \
80 TRACE(ddraw, " V: %f %f %f %f (%f %f %f) (%f %f)\n", \
81 vx[index].x, vx[index].y, vx[index].z, vx[index].w, \
82 vx[index].nx, vx[index].ny, vx[index].nz, \
83 vx[index].u, vx[index].v); \
86 #define DO_LVERTEX(index) \
88 DWORD col = l_vx[index].c; \
90 glColor3f(((col >> 16) & 0xFF) / 255.0, \
91 ((col >> 8) & 0xFF) / 255.0, \
92 ((col >> 0) & 0xFF) / 255.0); \
93 glTexCoord2f(l_vx[index].u, \
95 glVertex4f(l_vx[index].x, \
100 TRACE(ddraw, " LV: %f %f %f %f (%02lx %02lx %02lx) (%f %f)\n", \
101 l_vx[index].x, l_vx[index].y, l_vx[index].z, l_vx[index].w, \
102 ((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF), \
103 l_vx[index].u, l_vx[index].v); \
106 #define DO_TLVERTEX(index) \
108 D3DTLVERTEX *vx = &(tl_vx[index]); \
109 DWORD col = vx->c.color; \
111 glColor3f(((col >> 16) & 0xFF) / 255.0, \
112 ((col >> 8) & 0xFF) / 255.0, \
113 ((col >> 0) & 0xFF) / 255.0); \
114 glTexCoord2f(vx->u.tu, vx->v.tv); \
115 if (vx->r.rhw < 0.01) \
116 glVertex3f(vx->x.sx, \
120 glVertex4f(vx->x.sx / vx->r.rhw, \
121 vx->y.sy / vx->r.rhw, \
122 vx->z.sz / vx->r.rhw, \
124 TRACE(ddraw, " TLV: %f %f %f (%02lx %02lx %02lx) (%f %f) (%f)\n", \
125 vx->x.sx, vx->y.sy, vx->z.sz, \
126 ((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF), \
127 vx->u.tu, vx->v.tv, vx->r.rhw); \
130 #define TRIANGLE_LOOP(macro) \
132 glBegin(GL_TRIANGLES); { \
133 for (i = 0; i < count; i++) { \
134 LPD3DTRIANGLE ci = (LPD3DTRIANGLE) instr; \
136 TRACE(ddraw, " v1: %d v2: %d v3: %d\n", \
137 ci->v1.v1, ci->v2.v2, ci->v3.v3); \
138 TRACE(ddraw, " Flags : "); \
139 if (TRACE_ON(ddraw)) { \
141 if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) \
142 DUMP("EDGEENABLE1 "); \
143 if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2) \
144 DUMP("EDGEENABLE2 "); \
145 if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1) \
146 DUMP("EDGEENABLE3 "); \
148 /* Strips / Fans */ \
149 if (ci->wFlags == D3DTRIFLAG_EVEN) \
151 if (ci->wFlags == D3DTRIFLAG_ODD) \
153 if (ci->wFlags == D3DTRIFLAG_START) \
155 if ((ci->wFlags > 0) && (ci->wFlags < 30)) \
156 DUMP("STARTFLAT(%d) ", ci->wFlags); \
160 /* Draw the triangle */ \
171 static void execute(LPDIRECT3DEXECUTEBUFFER lpBuff,
172 LPDIRECT3DDEVICE dev,
173 LPDIRECT3DVIEWPORT vp) {
174 IDirect3DExecuteBufferImpl* ilpBuff=(IDirect3DExecuteBufferImpl*)lpBuff;
175 IDirect3DViewport2Impl* ivp=(IDirect3DViewport2Impl*)vp;
176 /* DWORD bs = ilpBuff->desc.dwBufferSize; */
177 DWORD vs = ilpBuff->data.dwVertexOffset;
178 /* DWORD vc = ilpBuff->data.dwVertexCount; */
179 DWORD is = ilpBuff->data.dwInstructionOffset;
180 /* DWORD il = ilpBuff->data.dwInstructionLength; */
182 void *instr = ilpBuff->desc.lpData + is;
183 OpenGL_IDirect3DDevice *odev = (OpenGL_IDirect3DDevice *) dev;
185 TRACE(ddraw, "ExecuteData : \n");
187 _dump_executedata(&(ilpBuff->data));
190 LPD3DINSTRUCTION current = (LPD3DINSTRUCTION) instr;
194 count = current->wCount;
195 size = current->bSize;
196 instr += sizeof(D3DINSTRUCTION);
198 switch (current->bOpcode) {
200 TRACE(ddraw, "POINT-s (%d)\n", count);
202 instr += count * size;
206 TRACE(ddraw, "LINE-s (%d)\n", count);
208 instr += count * size;
211 case D3DOP_TRIANGLE: {
213 float z_inv_matrix[16] = {
220 OGL_Vertex *vx = (OGL_Vertex *) ilpBuff->vertex_data;
221 OGL_LVertex *l_vx = (OGL_LVertex *) ilpBuff->vertex_data;
222 D3DTLVERTEX *tl_vx = (D3DTLVERTEX *) ilpBuff->vertex_data;
224 TRACE(ddraw, "TRIANGLE (%d)\n", count);
226 switch (ilpBuff->vertex_type) {
228 /* This time, there is lighting */
229 glEnable(GL_LIGHTING);
231 /* Use given matrixes */
232 glMatrixMode(GL_MODELVIEW);
233 glLoadIdentity(); /* The model transformation was done during the
234 transformation phase */
235 glMatrixMode(GL_PROJECTION);
236 TRACE(ddraw, " Projection Matrix : (%p)\n", odev->proj_mat);
237 dump_mat(odev->proj_mat);
238 TRACE(ddraw, " View Matrix : (%p)\n", odev->view_mat);
239 dump_mat(odev->view_mat);
241 glLoadMatrixf((float *) z_inv_matrix);
242 glMultMatrixf((float *) odev->proj_mat);
243 glMultMatrixf((float *) odev->view_mat);
248 glDisable(GL_LIGHTING);
250 /* Use given matrixes */
251 glMatrixMode(GL_MODELVIEW);
252 glLoadIdentity(); /* The model transformation was done during the
253 transformation phase */
254 glMatrixMode(GL_PROJECTION);
256 TRACE(ddraw, " Projection Matrix : (%p)\n", odev->proj_mat);
257 dump_mat(odev->proj_mat);
258 TRACE(ddraw, " View Matrix : (%p)\n", odev->view_mat);
259 dump_mat(odev->view_mat);
261 glLoadMatrixf((float *) z_inv_matrix);
262 glMultMatrixf((float *) odev->proj_mat);
263 glMultMatrixf((float *) odev->view_mat);
266 case D3DVT_TLVERTEX: {
267 GLdouble height, width, minZ, maxZ;
269 /* First, disable lighting */
270 glDisable(GL_LIGHTING);
272 /* Then do not put any transformation matrixes */
273 glMatrixMode(GL_MODELVIEW);
275 glMatrixMode(GL_PROJECTION);
279 ERR(ddraw, "No current viewport !\n");
280 /* Using standard values */
286 height = (GLdouble) ivp->viewport.vp1.dwHeight;
287 width = (GLdouble) ivp->viewport.vp1.dwWidth;
288 minZ = (GLdouble) ivp->viewport.vp1.dvMinZ;
289 maxZ = (GLdouble) ivp->viewport.vp1.dvMaxZ;
292 /* I do not know why, but many Dx 3.0 games have minZ = maxZ = 0.0 */
298 glOrtho(0.0, width, height, 0.0, -minZ, -maxZ);
302 ERR(ddraw, "Unhandled vertex type !\n");
306 switch (ilpBuff->vertex_type) {
308 TRIANGLE_LOOP(DO_VERTEX);
312 TRIANGLE_LOOP(DO_LVERTEX);
316 TRIANGLE_LOOP(DO_TLVERTEX);
320 ERR(ddraw, "Unhandled vertex type !\n");
325 case D3DOP_MATRIXLOAD: {
326 TRACE(ddraw, "MATRIXLOAD-s (%d)\n", count);
328 instr += count * size;
331 case D3DOP_MATRIXMULTIPLY: {
333 TRACE(ddraw, "MATRIXMULTIPLY (%d)\n", count);
335 for (i = 0; i < count; i++) {
336 LPD3DMATRIXMULTIPLY ci = (LPD3DMATRIXMULTIPLY) instr;
337 LPD3DMATRIX a = (LPD3DMATRIX) ci->hDestMatrix;
338 LPD3DMATRIX b = (LPD3DMATRIX) ci->hSrcMatrix1;
339 LPD3DMATRIX c = (LPD3DMATRIX) ci->hSrcMatrix2;
341 TRACE(ddraw, " Dest : %08lx Src1 : %08lx Src2 : %08lx\n",
342 ci->hDestMatrix, ci->hSrcMatrix1, ci->hSrcMatrix2);
344 /* Do the multiplication..
345 As I am VERY lazy, I let OpenGL do the multiplication for me */
346 glMatrixMode(GL_PROJECTION);
347 /* Save the current matrix */
349 /* Load Matrix one and do the multiplication */
350 glLoadMatrixf((float *) c);
351 glMultMatrixf((float *) b);
352 glGetFloatv(GL_PROJECTION_MATRIX, (float *) a);
353 /* Restore the current matrix */
360 case D3DOP_STATETRANSFORM: {
362 TRACE(ddraw, "STATETRANSFORM (%d)\n", count);
364 for (i = 0; i < count; i++) {
365 LPD3DSTATE ci = (LPD3DSTATE) instr;
367 /* Handle the state transform */
368 switch (ci->t.dtstTransformStateType) {
369 case D3DTRANSFORMSTATE_WORLD: {
370 TRACE(ddraw, " WORLD (%p)\n", (D3DMATRIX*) ci->v.dwArg[0]);
371 odev->world_mat = (D3DMATRIX*) ci->v.dwArg[0];
374 case D3DTRANSFORMSTATE_VIEW: {
375 TRACE(ddraw, " VIEW (%p)\n", (D3DMATRIX*) ci->v.dwArg[0]);
376 odev->view_mat = (D3DMATRIX*) ci->v.dwArg[0];
379 case D3DTRANSFORMSTATE_PROJECTION: {
380 TRACE(ddraw, " PROJECTION (%p)\n", (D3DMATRIX*) ci->v.dwArg[0]);
381 odev->proj_mat = (D3DMATRIX*) ci->v.dwArg[0];
385 ERR(ddraw, " Unhandled state transformation !! (%d)\n", (int) ci->t.dtstTransformStateType);
394 case D3DOP_STATELIGHT: {
396 TRACE(ddraw, "STATELIGHT (%d)\n", count);
398 for (i = 0; i < count; i++) {
399 LPD3DSTATE ci = (LPD3DSTATE) instr;
401 /* Handle the state transform */
402 switch (ci->t.dlstLightStateType) {
403 case D3DLIGHTSTATE_MATERIAL: {
404 IDirect3DMaterial2Impl* mat = (IDirect3DMaterial2Impl*) ci->v.dwArg[0];
405 TRACE(ddraw, " MATERIAL\n");
410 TRACE(ddraw, " bad Material Handle\n");
414 case D3DLIGHTSTATE_AMBIENT: {
416 DWORD dwLightState = ci->v.dwArg[0];
417 TRACE(ddraw, " AMBIENT\n");
419 light[0] = ((dwLightState >> 16) & 0xFF) / 255.0;
420 light[1] = ((dwLightState >> 8) & 0xFF) / 255.0;
421 light[2] = ((dwLightState >> 0) & 0xFF) / 255.0;
423 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light);
425 TRACE(ddraw, " R:%02lx G:%02lx B:%02lx A:%02lx\n",
426 ((dwLightState >> 16) & 0xFF),
427 ((dwLightState >> 8) & 0xFF),
428 ((dwLightState >> 0) & 0xFF),
429 ((dwLightState >> 24) & 0xFF));
432 case D3DLIGHTSTATE_COLORMODEL: {
433 TRACE(ddraw, " COLORMODEL\n");
436 case D3DLIGHTSTATE_FOGMODE: {
437 TRACE(ddraw, " FOGMODE\n");
440 case D3DLIGHTSTATE_FOGSTART: {
441 TRACE(ddraw, " FOGSTART\n");
444 case D3DLIGHTSTATE_FOGEND: {
445 TRACE(ddraw, " FOGEND\n");
448 case D3DLIGHTSTATE_FOGDENSITY: {
449 TRACE(ddraw, " FOGDENSITY\n");
453 ERR(ddraw, " Unhandled light state !! (%d)\n", (int) ci->t.dlstLightStateType);
460 case D3DOP_STATERENDER: {
462 TRACE(ddraw, "STATERENDER (%d)\n", count);
464 for (i = 0; i < count; i++) {
465 LPD3DSTATE ci = (LPD3DSTATE) instr;
467 /* Handle the state transform */
468 set_render_state(ci->t.drstRenderStateType, ci->v.dwArg[0], &(odev->rs));
474 case D3DOP_PROCESSVERTICES: {
476 TRACE(ddraw, "PROCESSVERTICES (%d)\n", count);
478 for (i = 0; i < count; i++) {
479 LPD3DPROCESSVERTICES ci = (LPD3DPROCESSVERTICES) instr;
481 TRACE(ddraw, " Start : %d Dest : %d Count : %ld\n",
482 ci->wStart, ci->wDest, ci->dwCount);
483 TRACE(ddraw, " Flags : ");
484 if (TRACE_ON(ddraw)) {
485 if (ci->dwFlags & D3DPROCESSVERTICES_COPY)
487 if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
489 if (ci->dwFlags == D3DPROCESSVERTICES_OPMASK)
491 if (ci->dwFlags & D3DPROCESSVERTICES_TRANSFORM)
493 if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT)
494 DUMP("TRANSFORMLIGHT ");
495 if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
496 DUMP("UPDATEEXTENTS ");
500 /* This is where doing Direct3D on top on OpenGL is quite difficult.
501 This method transforms a set of vertices using the CURRENT state
502 (lighting, projection, ...) but does not rasterize them.
503 They will oinly be put on screen later (with the POINT / LINE and
504 TRIANGLE op-codes). The problem is that you can have a triangle
505 with each point having been transformed using another state...
507 In this implementation, I will emulate only ONE thing : each
508 vertex can have its own "WORLD" transformation (this is used in the
509 TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the
510 execute buffer use the same state.
512 If I find applications that change other states, I will try to do a
513 more 'fine-tuned' state emulation (but I may become quite tricky if
514 it changes a light position in the middle of a triangle).
516 In this case, a 'direct' approach (i.e. without using OpenGL, but
517 writing our own 3D rasterizer) would be easier. */
519 /* The current method (with the hypothesis that only the WORLD matrix
520 will change between two points) is like this :
521 - I transform 'manually' all the vertices with the current WORLD
522 matrix and store them in the vertex buffer
523 - during the rasterization phase, the WORLD matrix will be set to
524 the Identity matrix */
526 /* Enough for the moment */
527 if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
529 D3DVERTEX *src = ((LPD3DVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
530 OGL_Vertex *dst = ((OGL_Vertex *) (ilpBuff->vertex_data)) + ci->wDest;
531 D3DMATRIX *mat = odev->world_mat;
533 TRACE(ddraw, " World Matrix : (%p)\n", mat);
536 ilpBuff->vertex_type = D3DVT_VERTEX;
538 for (nb = 0; nb < ci->dwCount; nb++) {
539 /* For the moment, no normal transformation... */
540 dst->nx = src->nx.nx;
541 dst->ny = src->ny.ny;
542 dst->nz = src->nz.nz;
547 /* Now, the matrix multiplication */
548 dst->x = (src->x.x * mat->_11) + (src->y.y * mat->_21) + (src->z.z * mat->_31) + (1.0 * mat->_41);
549 dst->y = (src->x.x * mat->_12) + (src->y.y * mat->_22) + (src->z.z * mat->_32) + (1.0 * mat->_42);
550 dst->z = (src->x.x * mat->_13) + (src->y.y * mat->_23) + (src->z.z * mat->_33) + (1.0 * mat->_43);
551 dst->w = (src->x.x * mat->_14) + (src->y.y * mat->_24) + (src->z.z * mat->_34) + (1.0 * mat->_44);
556 } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
558 D3DLVERTEX *src = ((LPD3DLVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
559 OGL_LVertex *dst = ((OGL_LVertex *) (ilpBuff->vertex_data)) + ci->wDest;
560 D3DMATRIX *mat = odev->world_mat;
562 TRACE(ddraw, " World Matrix : (%p)\n", mat);
565 ilpBuff->vertex_type = D3DVT_LVERTEX;
567 for (nb = 0; nb < ci->dwCount; nb++) {
568 dst->c = src->c.color;
569 dst->sc = src->s.specular;
573 /* Now, the matrix multiplication */
574 dst->x = (src->x.x * mat->_11) + (src->y.y * mat->_21) + (src->z.z * mat->_31) + (1.0 * mat->_41);
575 dst->y = (src->x.x * mat->_12) + (src->y.y * mat->_22) + (src->z.z * mat->_32) + (1.0 * mat->_42);
576 dst->z = (src->x.x * mat->_13) + (src->y.y * mat->_23) + (src->z.z * mat->_33) + (1.0 * mat->_43);
577 dst->w = (src->x.x * mat->_14) + (src->y.y * mat->_24) + (src->z.z * mat->_34) + (1.0 * mat->_44);
582 } else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) {
583 D3DTLVERTEX *src = ((LPD3DTLVERTEX) (ilpBuff->desc.lpData + vs)) + ci->wStart;
584 D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (ilpBuff->vertex_data)) + ci->wDest;
586 ilpBuff->vertex_type = D3DVT_TLVERTEX;
588 memcpy(dst, src, ci->dwCount * sizeof(D3DTLVERTEX));
590 ERR(ddraw, "Unhandled vertex processing !\n");
597 case D3DOP_TEXTURELOAD: {
598 TRACE(ddraw, "TEXTURELOAD-s (%d)\n", count);
600 instr += count * size;
604 TRACE(ddraw, "EXIT (%d)\n", count);
605 /* We did this instruction */
611 case D3DOP_BRANCHFORWARD: {
613 TRACE(ddraw, "BRANCHFORWARD (%d)\n", count);
615 for (i = 0; i < count; i++) {
616 LPD3DBRANCH ci = (LPD3DBRANCH) instr;
618 if ((ilpBuff->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) {
620 TRACE(ddraw," Should branch to %ld\n", ci->dwOffset);
624 TRACE(ddraw," Should branch to %ld\n", ci->dwOffset);
633 TRACE(ddraw, "SPAN-s (%d)\n", count);
635 instr += count * size;
638 case D3DOP_SETSTATUS: {
640 TRACE(ddraw, "SETSTATUS (%d)\n", count);
642 for (i = 0; i < count; i++) {
643 LPD3DSTATUS ci = (LPD3DSTATUS) instr;
645 ilpBuff->data.dsStatus = *ci;
652 ERR(ddraw, "Unhandled OpCode !!!\n");
653 /* Try to save ... */
654 instr += count * size;
662 /*******************************************************************************
663 * ExecuteBuffer Creation functions
665 LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(IDirect3DDeviceImpl* d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc)
667 IDirect3DExecuteBufferImpl* eb;
669 eb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DExecuteBufferImpl));
671 eb->lpvtbl = &executebuffer_vtable;
674 /* Initializes memory */
677 /* No buffer given */
678 if (!(eb->desc.dwFlags & D3DDEB_LPDATA))
679 eb->desc.lpData = NULL;
681 /* No buffer size given */
682 if (!(lpDesc->dwFlags & D3DDEB_BUFSIZE))
683 eb->desc.dwBufferSize = 0;
685 /* Create buffer if asked */
686 if ((eb->desc.lpData == NULL) && (eb->desc.dwBufferSize > 0)) {
687 eb->need_free = TRUE;
688 eb->desc.lpData = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,eb->desc.dwBufferSize);
690 eb->need_free = FALSE;
693 /* No vertices for the moment */
694 eb->vertex_data = NULL;
696 eb->desc.dwFlags |= D3DDEB_LPDATA;
698 eb->execute = execute;
700 return (LPDIRECT3DEXECUTEBUFFER)eb;
703 /*******************************************************************************
704 * IDirect3ExecuteBuffer methods
707 static HRESULT WINAPI IDirect3DExecuteBufferImpl_QueryInterface(LPDIRECT3DEXECUTEBUFFER iface,
711 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
714 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
715 FIXME(ddraw, "(%p)->(%s,%p): stub\n", This, xrefiid,ppvObj);
722 static ULONG WINAPI IDirect3DExecuteBufferImpl_AddRef(LPDIRECT3DEXECUTEBUFFER iface)
724 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
725 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", This, This->ref );
727 return ++(This->ref);
732 static ULONG WINAPI IDirect3DExecuteBufferImpl_Release(LPDIRECT3DEXECUTEBUFFER iface)
734 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
735 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", This, This->ref );
737 if (!--(This->ref)) {
738 if ((This->desc.lpData != NULL) && This->need_free)
739 HeapFree(GetProcessHeap(),0,This->desc.lpData);
741 if (This->vertex_data != NULL)
742 HeapFree(GetProcessHeap(),0,This->vertex_data);
744 HeapFree(GetProcessHeap(),0,This);
751 static HRESULT WINAPI IDirect3DExecuteBufferImpl_Initialize(LPDIRECT3DEXECUTEBUFFER iface,
752 LPDIRECT3DDEVICE lpDirect3DDevice,
753 LPD3DEXECUTEBUFFERDESC lpDesc)
755 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
756 FIXME(ddraw, "(%p)->(%p,%p): stub\n", This, lpDirect3DDevice, lpDesc);
761 static HRESULT WINAPI IDirect3DExecuteBufferImpl_Lock(LPDIRECT3DEXECUTEBUFFER iface,
762 LPD3DEXECUTEBUFFERDESC lpDesc)
764 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
765 TRACE(ddraw, "(%p)->(%p)\n", This, lpDesc);
767 /* Copies the buffer description */
768 *lpDesc = This->desc;
773 static HRESULT WINAPI IDirect3DExecuteBufferImpl_Unlock(LPDIRECT3DEXECUTEBUFFER iface)
775 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
776 TRACE(ddraw, "(%p)->()\n", This);
781 static HRESULT WINAPI IDirect3DExecuteBufferImpl_SetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
782 LPD3DEXECUTEDATA lpData)
784 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
787 TRACE(ddraw, "(%p)->(%p)\n", This, lpData);
789 This->data = *lpData;
791 /* Get the number of vertices in the execute buffer */
792 nbvert = This->data.dwVertexCount;
794 /* Prepares the transformed vertex buffer */
795 if (This->vertex_data != NULL)
796 HeapFree(GetProcessHeap(), 0, This->vertex_data);
797 This->vertex_data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,nbvert * sizeof(OGL_Vertex));
800 if (TRACE_ON(ddraw)) {
801 _dump_executedata(lpData);
807 static HRESULT WINAPI IDirect3DExecuteBufferImpl_GetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
808 LPD3DEXECUTEDATA lpData)
810 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
811 TRACE(ddraw, "(%p)->(%p): stub\n", This, lpData);
813 *lpData = This->data;
818 static HRESULT WINAPI IDirect3DExecuteBufferImpl_Validate(LPDIRECT3DEXECUTEBUFFER iface,
820 LPD3DVALIDATECALLBACK lpFunc,
824 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
825 TRACE(ddraw, "(%p)->(%p,%p,%p,%lu)\n", This, lpdwOffset, lpFunc, lpUserArg, dwReserved);
830 static HRESULT WINAPI IDirect3DExecuteBufferImpl_Optimize(LPDIRECT3DEXECUTEBUFFER iface,
833 ICOM_THIS(IDirect3DExecuteBufferImpl,iface);
834 TRACE(ddraw, "(%p)->(%lu)\n", This, dwReserved);
840 /*******************************************************************************
841 * IDirect3DLight VTable
843 static ICOM_VTABLE(IDirect3DExecuteBuffer) executebuffer_vtable = {
844 /*** IUnknown methods ***/
845 IDirect3DExecuteBufferImpl_QueryInterface,
846 IDirect3DExecuteBufferImpl_AddRef,
847 IDirect3DExecuteBufferImpl_Release,
848 /*** IDirect3DExecuteBuffer methods ***/
849 IDirect3DExecuteBufferImpl_Initialize,
850 IDirect3DExecuteBufferImpl_Lock,
851 IDirect3DExecuteBufferImpl_Unlock,
852 IDirect3DExecuteBufferImpl_SetExecuteData,
853 IDirect3DExecuteBufferImpl_GetExecuteData,
854 IDirect3DExecuteBufferImpl_Validate,
855 IDirect3DExecuteBufferImpl_Optimize
858 #endif /* HAVE_MESAGL */