1 /* Direct3D ExecuteBuffer
2 * Copyright (c) 1998-2004 Lionel ULMER
3 * Copyright (c) 2002-2004 Christian Costa
4 * Copyright (c) 2006 Stefan Dösinger
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
24 #include "ddraw_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
28 /*****************************************************************************
30 * _dump_D3DEXECUTEBUFFERDESC
32 * Debug functions which write the executebuffer data to the console
34 *****************************************************************************/
36 static void _dump_executedata(const D3DEXECUTEDATA
*lpData
) {
37 TRACE("dwSize : %d\n", lpData
->dwSize
);
38 TRACE("Vertex Offset : %d Count : %d\n", lpData
->dwVertexOffset
, lpData
->dwVertexCount
);
39 TRACE("Instruction Offset : %d Length : %d\n", lpData
->dwInstructionOffset
, lpData
->dwInstructionLength
);
40 TRACE("HVertex Offset : %d\n", lpData
->dwHVertexOffset
);
43 static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC
*lpDesc
) {
44 TRACE("dwSize : %d\n", lpDesc
->dwSize
);
45 TRACE("dwFlags : %x\n", lpDesc
->dwFlags
);
46 TRACE("dwCaps : %x\n", lpDesc
->dwCaps
);
47 TRACE("dwBufferSize : %d\n", lpDesc
->dwBufferSize
);
48 TRACE("lpData : %p\n", lpDesc
->lpData
);
51 HRESULT
d3d_execute_buffer_execute(struct d3d_execute_buffer
*buffer
,
52 struct d3d_device
*device
, struct d3d_viewport
*viewport
)
54 DWORD is
= buffer
->data
.dwInstructionOffset
;
55 char *instr
= (char *)buffer
->desc
.lpData
+ is
;
56 unsigned int i
, primitive_size
;
57 struct wined3d_map_desc map_desc
;
58 struct wined3d_box box
= {0};
61 if (viewport
->active_device
!= device
)
63 WARN("Viewport %p active device is %p.\n",
64 viewport
, viewport
->active_device
);
65 return DDERR_INVALIDPARAMS
;
68 /* Activate the viewport */
69 viewport_activate(viewport
, FALSE
);
71 TRACE("ExecuteData :\n");
73 _dump_executedata(&(buffer
->data
));
77 D3DINSTRUCTION
*current
= (D3DINSTRUCTION
*)instr
;
81 count
= current
->wCount
;
82 size
= current
->bSize
;
83 instr
+= sizeof(*current
);
86 switch (current
->bOpcode
)
90 const D3DPOINT
*p
= (D3DPOINT
*)instr
;
91 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_POINTLIST
);
92 wined3d_device_set_stream_source(device
->wined3d_device
, 0,
93 buffer
->dst_vertex_buffer
, 0, sizeof(D3DTLVERTEX
));
94 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
95 ddraw_find_decl(device
->ddraw
, D3DFVF_TLVERTEX
));
97 for (i
= 0; i
< count
; ++i
)
98 wined3d_device_draw_primitive(device
->wined3d_device
, p
[i
].wFirst
, p
[i
].wCount
);
100 instr
+= sizeof(*p
) * count
;
106 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_LINELIST
);
111 unsigned int index_pos
= buffer
->index_pos
, index_count
;
112 TRACE("TRIANGLE (%d)\n", count
);
119 wined3d_device_set_primitive_type(device
->wined3d_device
, WINED3D_PT_TRIANGLELIST
);
123 index_count
= count
* primitive_size
;
125 if (buffer
->index_size
< index_count
)
127 struct wined3d_buffer
*new_buffer
;
128 unsigned int new_size
= max(buffer
->index_size
* 2, index_count
);
130 hr
= wined3d_buffer_create_ib(device
->wined3d_device
, new_size
* sizeof(*indices
),
131 WINED3DUSAGE_DYNAMIC
| WINED3DUSAGE_WRITEONLY
, WINED3D_POOL_DEFAULT
,
132 NULL
, &ddraw_null_wined3d_parent_ops
, &new_buffer
);
136 buffer
->index_size
= new_size
;
137 if (buffer
->index_buffer
)
138 wined3d_buffer_decref(buffer
->index_buffer
);
139 buffer
->index_buffer
= new_buffer
;
142 else if (buffer
->index_size
- index_count
< index_pos
)
147 box
.left
= index_pos
* sizeof(*indices
);
148 box
.right
= (index_pos
+ index_count
) * sizeof(*indices
);
149 hr
= wined3d_resource_map(wined3d_buffer_get_resource(buffer
->index_buffer
), 0,
150 &map_desc
, &box
, index_pos
? WINED3D_MAP_NOOVERWRITE
: WINED3D_MAP_DISCARD
);
153 indices
= map_desc
.data
;
155 for (i
= 0; i
< count
; ++i
)
157 D3DTRIANGLE
*ci
= (D3DTRIANGLE
*)instr
;
158 TRACE(" v1: %d v2: %d v3: %d\n",ci
->u1
.v1
, ci
->u2
.v2
, ci
->u3
.v3
);
163 if (ci
->wFlags
& D3DTRIFLAG_EDGEENABLE1
)
164 TRACE("EDGEENABLE1 ");
165 if (ci
->wFlags
& D3DTRIFLAG_EDGEENABLE2
)
166 TRACE("EDGEENABLE2 ");
167 if (ci
->wFlags
& D3DTRIFLAG_EDGEENABLE1
)
168 TRACE("EDGEENABLE3 ");
170 if (ci
->wFlags
== D3DTRIFLAG_EVEN
)
172 if (ci
->wFlags
== D3DTRIFLAG_ODD
)
174 if (ci
->wFlags
== D3DTRIFLAG_START
)
176 if ((ci
->wFlags
> 0) && (ci
->wFlags
< 30))
177 TRACE("STARTFLAT(%u) ", ci
->wFlags
);
181 switch (primitive_size
)
184 indices
[(i
* primitive_size
) + 2] = ci
->u3
.v3
;
187 indices
[(i
* primitive_size
) + 1] = ci
->u2
.v2
;
188 indices
[(i
* primitive_size
) ] = ci
->u1
.v1
;
193 wined3d_resource_unmap(wined3d_buffer_get_resource(buffer
->index_buffer
), 0);
195 wined3d_device_set_stream_source(device
->wined3d_device
, 0,
196 buffer
->dst_vertex_buffer
, 0, sizeof(D3DTLVERTEX
));
197 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
198 ddraw_find_decl(device
->ddraw
, D3DFVF_TLVERTEX
));
199 wined3d_device_set_index_buffer(device
->wined3d_device
, buffer
->index_buffer
, WINED3DFMT_R16_UINT
, 0);
200 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, index_pos
, index_count
);
202 buffer
->index_pos
= index_pos
+ index_count
;
206 case D3DOP_MATRIXLOAD
:
207 WARN("MATRIXLOAD-s (%u)\n", count
);
208 instr
+= count
* size
;
211 case D3DOP_MATRIXMULTIPLY
:
212 TRACE("MATRIXMULTIPLY (%d)\n", count
);
213 for (i
= 0; i
< count
; ++i
)
215 D3DMATRIXMULTIPLY
*ci
= (D3DMATRIXMULTIPLY
*)instr
;
216 D3DMATRIX
*a
, *b
, *c
;
218 a
= ddraw_get_object(&device
->handle_table
, ci
->hDestMatrix
- 1, DDRAW_HANDLE_MATRIX
);
219 b
= ddraw_get_object(&device
->handle_table
, ci
->hSrcMatrix1
- 1, DDRAW_HANDLE_MATRIX
);
220 c
= ddraw_get_object(&device
->handle_table
, ci
->hSrcMatrix2
- 1, DDRAW_HANDLE_MATRIX
);
224 ERR("Invalid matrix handle (a %#x -> %p, b %#x -> %p, c %#x -> %p).\n",
225 ci
->hDestMatrix
, a
, ci
->hSrcMatrix1
, b
, ci
->hSrcMatrix2
, c
);
229 TRACE("dst %p, src1 %p, src2 %p.\n", a
, b
, c
);
230 multiply_matrix(a
, c
, b
);
237 case D3DOP_STATETRANSFORM
:
238 TRACE("STATETRANSFORM (%d)\n", count
);
239 for (i
= 0; i
< count
; ++i
)
241 D3DSTATE
*ci
= (D3DSTATE
*)instr
;
244 m
= ddraw_get_object(&device
->handle_table
, ci
->u2
.dwArg
[0] - 1, DDRAW_HANDLE_MATRIX
);
247 ERR("Invalid matrix handle %#x.\n", ci
->u2
.dwArg
[0]);
251 if (ci
->u1
.dtstTransformStateType
== D3DTRANSFORMSTATE_WORLD
)
252 device
->world
= ci
->u2
.dwArg
[0];
253 if (ci
->u1
.dtstTransformStateType
== D3DTRANSFORMSTATE_VIEW
)
254 device
->view
= ci
->u2
.dwArg
[0];
255 if (ci
->u1
.dtstTransformStateType
== D3DTRANSFORMSTATE_PROJECTION
)
256 device
->proj
= ci
->u2
.dwArg
[0];
257 IDirect3DDevice3_SetTransform(&device
->IDirect3DDevice3_iface
,
258 ci
->u1
.dtstTransformStateType
, m
);
265 case D3DOP_STATELIGHT
:
266 TRACE("STATELIGHT (%d)\n", count
);
267 for (i
= 0; i
< count
; ++i
)
269 D3DSTATE
*ci
= (D3DSTATE
*)instr
;
271 if (FAILED(IDirect3DDevice3_SetLightState(&device
->IDirect3DDevice3_iface
,
272 ci
->u1
.dlstLightStateType
, ci
->u2
.dwArg
[0])))
273 WARN("Failed to set light state.\n");
279 case D3DOP_STATERENDER
:
280 TRACE("STATERENDER (%d)\n", count
);
281 for (i
= 0; i
< count
; ++i
)
283 D3DSTATE
*ci
= (D3DSTATE
*)instr
;
285 if (FAILED(IDirect3DDevice3_SetRenderState(&device
->IDirect3DDevice3_iface
,
286 ci
->u1
.drstRenderStateType
, ci
->u2
.dwArg
[0])))
287 WARN("Failed to set render state.\n");
293 case D3DOP_PROCESSVERTICES
:
294 TRACE("PROCESSVERTICES (%d)\n", count
);
296 for (i
= 0; i
< count
; ++i
)
298 D3DPROCESSVERTICES
*ci
= (D3DPROCESSVERTICES
*)instr
;
299 DWORD op
= ci
->dwFlags
& D3DPROCESSVERTICES_OPMASK
;
301 TRACE(" start %u, dest %u, count %u, flags %#x.\n",
302 ci
->wStart
, ci
->wDest
, ci
->dwCount
, ci
->dwFlags
);
304 if (ci
->dwFlags
& D3DPROCESSVERTICES_UPDATEEXTENTS
)
305 FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n");
306 if (ci
->dwFlags
& D3DPROCESSVERTICES_NOCOLOR
)
307 FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n");
311 case D3DPROCESSVERTICES_TRANSFORMLIGHT
:
312 case D3DPROCESSVERTICES_TRANSFORM
:
313 wined3d_device_set_stream_source(device
->wined3d_device
, 0,
314 buffer
->src_vertex_buffer
, buffer
->src_vertex_pos
, sizeof(D3DVERTEX
));
315 if (op
== D3DPROCESSVERTICES_TRANSFORMLIGHT
)
317 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
318 ddraw_find_decl(device
->ddraw
, D3DFVF_VERTEX
));
319 wined3d_device_set_render_state(device
->wined3d_device
,
320 WINED3D_RS_LIGHTING
, TRUE
);
324 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
325 ddraw_find_decl(device
->ddraw
, D3DFVF_LVERTEX
));
326 wined3d_device_set_render_state(device
->wined3d_device
,
327 WINED3D_RS_LIGHTING
, FALSE
);
330 wined3d_device_process_vertices(device
->wined3d_device
, ci
->wStart
, ci
->wDest
,
331 ci
->dwCount
, buffer
->dst_vertex_buffer
, NULL
, 0, D3DFVF_TLVERTEX
);
334 case D3DPROCESSVERTICES_COPY
:
335 box
.left
= (buffer
->src_vertex_pos
+ ci
->wStart
) * sizeof(D3DTLVERTEX
);
336 box
.right
= box
.left
+ ci
->dwCount
* sizeof(D3DTLVERTEX
);
337 box
.top
= box
.front
= 0;
338 box
.bottom
= box
.back
= 1;
339 wined3d_device_copy_sub_resource_region(device
->wined3d_device
,
340 wined3d_buffer_get_resource(buffer
->dst_vertex_buffer
), 0,
341 ci
->wDest
* sizeof(D3DTLVERTEX
), 0, 0,
342 wined3d_buffer_get_resource(buffer
->src_vertex_buffer
), 0, &box
);
346 FIXME("Unhandled vertex processing op %#x.\n", op
);
354 case D3DOP_TEXTURELOAD
:
355 TRACE("TEXTURELOAD (%u)\n", count
);
357 for (i
= 0; i
< count
; ++i
)
359 D3DTEXTURELOAD
*ci
= (D3DTEXTURELOAD
*)instr
;
360 struct ddraw_surface
*dst
, *src
;
364 if (!(dst
= ddraw_get_object(&device
->handle_table
,
365 ci
->hDestTexture
- 1, DDRAW_HANDLE_SURFACE
)))
367 WARN("Invalid destination texture handle %#x.\n", ci
->hDestTexture
);
370 if (!(src
= ddraw_get_object(&device
->handle_table
,
371 ci
->hSrcTexture
- 1, DDRAW_HANDLE_SURFACE
)))
373 WARN("Invalid source texture handle %#x.\n", ci
->hSrcTexture
);
377 IDirect3DTexture2_Load(&dst
->IDirect3DTexture2_iface
, &src
->IDirect3DTexture2_iface
);
382 TRACE("EXIT (%u)\n", count
);
386 case D3DOP_BRANCHFORWARD
:
387 TRACE("BRANCHFORWARD (%d)\n", count
);
388 for (i
= 0; i
< count
; ++i
)
390 D3DBRANCH
*ci
= (D3DBRANCH
*)instr
;
392 if ((buffer
->data
.dsStatus
.dwStatus
& ci
->dwMask
) == ci
->dwValue
)
396 TRACE(" Branch to %d\n", ci
->dwOffset
);
398 instr
= (char*)current
+ ci
->dwOffset
;
407 TRACE(" Branch to %d\n", ci
->dwOffset
);
409 instr
= (char*)current
+ ci
->dwOffset
;
420 WARN("SPAN-s (%u)\n", count
);
421 instr
+= count
* size
;
424 case D3DOP_SETSTATUS
:
425 TRACE("SETSTATUS (%d)\n", count
);
426 for (i
= 0; i
< count
; ++i
)
428 buffer
->data
.dsStatus
= *(D3DSTATUS
*)instr
;
434 ERR("Unhandled OpCode %#x.\n",current
->bOpcode
);
435 instr
+= count
* size
;
444 static inline struct d3d_execute_buffer
*impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer
*iface
)
446 return CONTAINING_RECORD(iface
, struct d3d_execute_buffer
, IDirect3DExecuteBuffer_iface
);
449 static HRESULT WINAPI
d3d_execute_buffer_QueryInterface(IDirect3DExecuteBuffer
*iface
, REFIID iid
, void **out
)
451 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
453 if (IsEqualGUID(&IID_IDirect3DExecuteBuffer
, iid
)
454 || IsEqualGUID(&IID_IUnknown
, iid
))
456 IDirect3DExecuteBuffer_AddRef(iface
);
461 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
464 return E_NOINTERFACE
;
467 /*****************************************************************************
468 * IDirect3DExecuteBuffer::AddRef
470 * A normal AddRef method, nothing special
475 *****************************************************************************/
476 static ULONG WINAPI
d3d_execute_buffer_AddRef(IDirect3DExecuteBuffer
*iface
)
478 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
479 ULONG ref
= InterlockedIncrement(&buffer
->ref
);
481 TRACE("%p increasing refcount to %u.\n", buffer
, ref
);
486 /*****************************************************************************
487 * IDirect3DExecuteBuffer::Release
489 * A normal Release method, nothing special
494 *****************************************************************************/
495 static ULONG WINAPI
d3d_execute_buffer_Release(IDirect3DExecuteBuffer
*iface
)
497 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
498 ULONG ref
= InterlockedDecrement(&buffer
->ref
);
500 TRACE("%p decreasing refcount to %u.\n", buffer
, ref
);
504 if (buffer
->need_free
)
505 HeapFree(GetProcessHeap(), 0, buffer
->desc
.lpData
);
506 if (buffer
->index_buffer
)
507 wined3d_buffer_decref(buffer
->index_buffer
);
508 if (buffer
->dst_vertex_buffer
)
510 wined3d_buffer_decref(buffer
->src_vertex_buffer
);
511 wined3d_buffer_decref(buffer
->dst_vertex_buffer
);
513 HeapFree(GetProcessHeap(), 0, buffer
);
519 /*****************************************************************************
520 * IDirect3DExecuteBuffer::Initialize
522 * Initializes the Execute Buffer. This method exists for COM compliance
523 * Nothing to do here.
528 *****************************************************************************/
529 static HRESULT WINAPI
d3d_execute_buffer_Initialize(IDirect3DExecuteBuffer
*iface
,
530 IDirect3DDevice
*device
, D3DEXECUTEBUFFERDESC
*desc
)
532 TRACE("iface %p, device %p, desc %p.\n", iface
, device
, desc
);
537 /*****************************************************************************
538 * IDirect3DExecuteBuffer::Lock
540 * Locks the buffer, so the app can write into it.
543 * Desc: Pointer to return the buffer description. This Description contains
544 * a pointer to the buffer data.
547 * This implementation always returns D3D_OK
549 *****************************************************************************/
550 static HRESULT WINAPI
d3d_execute_buffer_Lock(IDirect3DExecuteBuffer
*iface
, D3DEXECUTEBUFFERDESC
*desc
)
552 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
555 TRACE("iface %p, desc %p.\n", iface
, desc
);
557 dwSize
= desc
->dwSize
;
558 memcpy(desc
, &buffer
->desc
, dwSize
);
562 TRACE(" Returning description :\n");
563 _dump_D3DEXECUTEBUFFERDESC(desc
);
568 /*****************************************************************************
569 * IDirect3DExecuteBuffer::Unlock
571 * Unlocks the buffer. We don't have anything to do here
574 * This implementation always returns D3D_OK
576 *****************************************************************************/
577 static HRESULT WINAPI
d3d_execute_buffer_Unlock(IDirect3DExecuteBuffer
*iface
)
579 TRACE("iface %p.\n", iface
);
584 /*****************************************************************************
585 * IDirect3DExecuteBuffer::SetExecuteData
587 * Sets the execute data. This data is used to describe the buffer's content
590 * Data: Pointer to a D3DEXECUTEDATA structure containing the data to
595 * DDERR_OUTOFMEMORY if the vertex buffer allocation failed
597 *****************************************************************************/
598 static HRESULT WINAPI
d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer
*iface
, D3DEXECUTEDATA
*data
)
600 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
601 struct wined3d_map_desc map_desc
;
602 struct wined3d_box box
= {0};
605 TRACE("iface %p, data %p.\n", iface
, data
);
607 /* Skip past previous vertex data. */
608 buffer
->src_vertex_pos
+= buffer
->data
.dwVertexCount
;
610 if (buffer
->vertex_size
< data
->dwVertexCount
)
612 unsigned int new_size
= max(data
->dwVertexCount
, buffer
->vertex_size
* 2);
613 struct wined3d_buffer
*src_buffer
, *dst_buffer
;
615 hr
= wined3d_buffer_create_vb(buffer
->d3ddev
->wined3d_device
, new_size
* sizeof(D3DVERTEX
),
616 WINED3DUSAGE_DYNAMIC
| WINED3DUSAGE_WRITEONLY
, WINED3D_POOL_SYSTEM_MEM
,
617 NULL
, &ddraw_null_wined3d_parent_ops
, &src_buffer
);
621 hr
= wined3d_buffer_create_vb(buffer
->d3ddev
->wined3d_device
, new_size
* sizeof(D3DTLVERTEX
),
622 WINED3DUSAGE_STATICDECL
, WINED3D_POOL_DEFAULT
,
623 NULL
, &ddraw_null_wined3d_parent_ops
, &dst_buffer
);
626 wined3d_buffer_decref(src_buffer
);
630 if (buffer
->dst_vertex_buffer
)
632 wined3d_buffer_decref(buffer
->src_vertex_buffer
);
633 wined3d_buffer_decref(buffer
->dst_vertex_buffer
);
635 buffer
->src_vertex_buffer
= src_buffer
;
636 buffer
->dst_vertex_buffer
= dst_buffer
;
637 buffer
->vertex_size
= new_size
;
638 buffer
->src_vertex_pos
= 0;
640 else if (buffer
->vertex_size
- data
->dwVertexCount
< buffer
->src_vertex_pos
)
642 buffer
->src_vertex_pos
= 0;
645 if (data
->dwVertexCount
)
647 box
.left
= buffer
->src_vertex_pos
* sizeof(D3DVERTEX
);
648 box
.right
= box
.left
+ data
->dwVertexCount
* sizeof(D3DVERTEX
);
649 hr
= wined3d_resource_map(wined3d_buffer_get_resource(buffer
->src_vertex_buffer
), 0,
650 &map_desc
, &box
, buffer
->src_vertex_pos
? WINED3D_MAP_NOOVERWRITE
: WINED3D_MAP_DISCARD
);
654 memcpy(map_desc
.data
, ((BYTE
*)buffer
->desc
.lpData
) + data
->dwVertexOffset
,
655 data
->dwVertexCount
* sizeof(D3DVERTEX
));
657 wined3d_resource_unmap(wined3d_buffer_get_resource(buffer
->src_vertex_buffer
), 0);
660 memcpy(&buffer
->data
, data
, data
->dwSize
);
663 _dump_executedata(data
);
668 /*****************************************************************************
669 * IDirect3DExecuteBuffer::GetExecuteData
671 * Returns the data in the execute buffer
674 * Data: Pointer to a D3DEXECUTEDATA structure used to return data
679 *****************************************************************************/
680 static HRESULT WINAPI
d3d_execute_buffer_GetExecuteData(IDirect3DExecuteBuffer
*iface
, D3DEXECUTEDATA
*data
)
682 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
685 TRACE("iface %p, data %p.\n", iface
, data
);
687 dwSize
= data
->dwSize
;
688 memcpy(data
, &buffer
->data
, dwSize
);
692 TRACE("Returning data :\n");
693 _dump_executedata(data
);
699 /*****************************************************************************
700 * IDirect3DExecuteBuffer::Validate
702 * DirectX 5 SDK: "The IDirect3DExecuteBuffer::Validate method is not
703 * currently implemented"
709 * DDERR_UNSUPPORTED, because it's not implemented in Windows.
711 *****************************************************************************/
712 static HRESULT WINAPI
d3d_execute_buffer_Validate(IDirect3DExecuteBuffer
*iface
,
713 DWORD
*offset
, LPD3DVALIDATECALLBACK callback
, void *context
, DWORD reserved
)
715 TRACE("iface %p, offset %p, callback %p, context %p, reserved %#x.\n",
716 iface
, offset
, callback
, context
, reserved
);
718 WARN("Not implemented.\n");
720 return DDERR_UNSUPPORTED
; /* Unchecked */
723 /*****************************************************************************
724 * IDirect3DExecuteBuffer::Optimize
726 * DirectX5 SDK: "The IDirect3DExecuteBuffer::Optimize method is not
727 * currently supported"
730 * Dummy: Seems to be an unused dummy ;)
733 * DDERR_UNSUPPORTED, because it's not implemented in Windows.
735 *****************************************************************************/
736 static HRESULT WINAPI
d3d_execute_buffer_Optimize(IDirect3DExecuteBuffer
*iface
, DWORD reserved
)
738 TRACE("iface %p, reserved %#x.\n", iface
, reserved
);
740 WARN("Not implemented.\n");
742 return DDERR_UNSUPPORTED
; /* Unchecked */
745 static const struct IDirect3DExecuteBufferVtbl d3d_execute_buffer_vtbl
=
747 d3d_execute_buffer_QueryInterface
,
748 d3d_execute_buffer_AddRef
,
749 d3d_execute_buffer_Release
,
750 d3d_execute_buffer_Initialize
,
751 d3d_execute_buffer_Lock
,
752 d3d_execute_buffer_Unlock
,
753 d3d_execute_buffer_SetExecuteData
,
754 d3d_execute_buffer_GetExecuteData
,
755 d3d_execute_buffer_Validate
,
756 d3d_execute_buffer_Optimize
,
759 HRESULT
d3d_execute_buffer_init(struct d3d_execute_buffer
*execute_buffer
,
760 struct d3d_device
*device
, D3DEXECUTEBUFFERDESC
*desc
)
762 execute_buffer
->IDirect3DExecuteBuffer_iface
.lpVtbl
= &d3d_execute_buffer_vtbl
;
763 execute_buffer
->ref
= 1;
764 execute_buffer
->d3ddev
= device
;
766 /* Initializes memory */
767 memcpy(&execute_buffer
->desc
, desc
, desc
->dwSize
);
769 /* No buffer given */
770 if (!(execute_buffer
->desc
.dwFlags
& D3DDEB_LPDATA
))
771 execute_buffer
->desc
.lpData
= NULL
;
773 /* No buffer size given */
774 if (!(execute_buffer
->desc
.dwFlags
& D3DDEB_BUFSIZE
))
775 execute_buffer
->desc
.dwBufferSize
= 0;
777 /* Create buffer if asked */
778 if (!execute_buffer
->desc
.lpData
&& execute_buffer
->desc
.dwBufferSize
)
780 execute_buffer
->need_free
= TRUE
;
781 execute_buffer
->desc
.lpData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, execute_buffer
->desc
.dwBufferSize
);
782 if (!execute_buffer
->desc
.lpData
)
784 ERR("Failed to allocate execute buffer data.\n");
785 return DDERR_OUTOFMEMORY
;
789 execute_buffer
->desc
.dwFlags
|= D3DDEB_LPDATA
;
794 struct d3d_execute_buffer
*unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer
*iface
)
798 assert(iface
->lpVtbl
== &d3d_execute_buffer_vtbl
);
800 return impl_from_IDirect3DExecuteBuffer(iface
);