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
, 0);
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
, 0);
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
, 0);
123 index_count
= count
* primitive_size
;
125 if (buffer
->index_size
< index_count
)
127 unsigned int new_size
= max(buffer
->index_size
* 2, index_count
);
128 struct wined3d_buffer
*new_buffer
;
129 struct wined3d_buffer_desc desc
;
131 desc
.byte_width
= new_size
* sizeof(*indices
);
132 desc
.usage
= WINED3DUSAGE_DYNAMIC
| WINED3DUSAGE_WRITEONLY
| WINED3DUSAGE_STATICDECL
;
133 desc
.bind_flags
= WINED3D_BIND_INDEX_BUFFER
;
134 desc
.access
= WINED3D_RESOURCE_ACCESS_GPU
135 | WINED3D_RESOURCE_ACCESS_MAP_R
| WINED3D_RESOURCE_ACCESS_MAP_W
;
137 desc
.structure_byte_stride
= 0;
139 if (FAILED(hr
= wined3d_buffer_create(device
->wined3d_device
, &desc
,
140 NULL
, NULL
, &ddraw_null_wined3d_parent_ops
, &new_buffer
)))
143 buffer
->index_size
= new_size
;
144 if (buffer
->index_buffer
)
145 wined3d_buffer_decref(buffer
->index_buffer
);
146 buffer
->index_buffer
= new_buffer
;
149 else if (buffer
->index_size
- index_count
< index_pos
)
154 box
.left
= index_pos
* sizeof(*indices
);
155 box
.right
= (index_pos
+ index_count
) * sizeof(*indices
);
156 if (FAILED(hr
= wined3d_resource_map(wined3d_buffer_get_resource(buffer
->index_buffer
), 0, &map_desc
,
157 &box
, WINED3D_MAP_WRITE
| (index_pos
? WINED3D_MAP_NOOVERWRITE
: WINED3D_MAP_DISCARD
))))
159 indices
= map_desc
.data
;
161 for (i
= 0; i
< count
; ++i
)
163 D3DTRIANGLE
*ci
= (D3DTRIANGLE
*)instr
;
164 TRACE(" v1: %d v2: %d v3: %d\n",ci
->u1
.v1
, ci
->u2
.v2
, ci
->u3
.v3
);
169 if (ci
->wFlags
& D3DTRIFLAG_EDGEENABLE1
)
170 TRACE("EDGEENABLE1 ");
171 if (ci
->wFlags
& D3DTRIFLAG_EDGEENABLE2
)
172 TRACE("EDGEENABLE2 ");
173 if (ci
->wFlags
& D3DTRIFLAG_EDGEENABLE1
)
174 TRACE("EDGEENABLE3 ");
176 if (ci
->wFlags
== D3DTRIFLAG_EVEN
)
178 if (ci
->wFlags
== D3DTRIFLAG_ODD
)
180 if (ci
->wFlags
== D3DTRIFLAG_START
)
182 if ((ci
->wFlags
> 0) && (ci
->wFlags
< 30))
183 TRACE("STARTFLAT(%u) ", ci
->wFlags
);
187 switch (primitive_size
)
190 indices
[(i
* primitive_size
) + 2] = ci
->u3
.v3
;
193 indices
[(i
* primitive_size
) + 1] = ci
->u2
.v2
;
194 indices
[(i
* primitive_size
) ] = ci
->u1
.v1
;
199 wined3d_resource_unmap(wined3d_buffer_get_resource(buffer
->index_buffer
), 0);
201 wined3d_device_set_stream_source(device
->wined3d_device
, 0,
202 buffer
->dst_vertex_buffer
, 0, sizeof(D3DTLVERTEX
));
203 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
204 ddraw_find_decl(device
->ddraw
, D3DFVF_TLVERTEX
));
205 wined3d_device_set_index_buffer(device
->wined3d_device
, buffer
->index_buffer
, WINED3DFMT_R16_UINT
, 0);
206 wined3d_device_draw_indexed_primitive(device
->wined3d_device
, index_pos
, index_count
);
208 buffer
->index_pos
= index_pos
+ index_count
;
212 case D3DOP_MATRIXLOAD
:
213 WARN("MATRIXLOAD-s (%u)\n", count
);
214 instr
+= count
* size
;
217 case D3DOP_MATRIXMULTIPLY
:
218 TRACE("MATRIXMULTIPLY (%d)\n", count
);
219 for (i
= 0; i
< count
; ++i
)
221 D3DMATRIXMULTIPLY
*ci
= (D3DMATRIXMULTIPLY
*)instr
;
222 D3DMATRIX
*a
, *b
, *c
;
224 a
= ddraw_get_object(&device
->handle_table
, ci
->hDestMatrix
- 1, DDRAW_HANDLE_MATRIX
);
225 b
= ddraw_get_object(&device
->handle_table
, ci
->hSrcMatrix1
- 1, DDRAW_HANDLE_MATRIX
);
226 c
= ddraw_get_object(&device
->handle_table
, ci
->hSrcMatrix2
- 1, DDRAW_HANDLE_MATRIX
);
230 ERR("Invalid matrix handle (a %#x -> %p, b %#x -> %p, c %#x -> %p).\n",
231 ci
->hDestMatrix
, a
, ci
->hSrcMatrix1
, b
, ci
->hSrcMatrix2
, c
);
235 TRACE("dst %p, src1 %p, src2 %p.\n", a
, b
, c
);
236 multiply_matrix(a
, c
, b
);
243 case D3DOP_STATETRANSFORM
:
244 TRACE("STATETRANSFORM (%d)\n", count
);
245 for (i
= 0; i
< count
; ++i
)
247 D3DSTATE
*ci
= (D3DSTATE
*)instr
;
250 m
= ddraw_get_object(&device
->handle_table
, ci
->u2
.dwArg
[0] - 1, DDRAW_HANDLE_MATRIX
);
253 ERR("Invalid matrix handle %#x.\n", ci
->u2
.dwArg
[0]);
257 if (ci
->u1
.dtstTransformStateType
== D3DTRANSFORMSTATE_WORLD
)
258 device
->world
= ci
->u2
.dwArg
[0];
259 if (ci
->u1
.dtstTransformStateType
== D3DTRANSFORMSTATE_VIEW
)
260 device
->view
= ci
->u2
.dwArg
[0];
261 if (ci
->u1
.dtstTransformStateType
== D3DTRANSFORMSTATE_PROJECTION
)
262 device
->proj
= ci
->u2
.dwArg
[0];
263 IDirect3DDevice3_SetTransform(&device
->IDirect3DDevice3_iface
,
264 ci
->u1
.dtstTransformStateType
, m
);
271 case D3DOP_STATELIGHT
:
272 TRACE("STATELIGHT (%d)\n", count
);
273 for (i
= 0; i
< count
; ++i
)
275 D3DSTATE
*ci
= (D3DSTATE
*)instr
;
277 if (FAILED(IDirect3DDevice3_SetLightState(&device
->IDirect3DDevice3_iface
,
278 ci
->u1
.dlstLightStateType
, ci
->u2
.dwArg
[0])))
279 WARN("Failed to set light state.\n");
285 case D3DOP_STATERENDER
:
286 TRACE("STATERENDER (%d)\n", count
);
287 for (i
= 0; i
< count
; ++i
)
289 D3DSTATE
*ci
= (D3DSTATE
*)instr
;
291 if (FAILED(IDirect3DDevice3_SetRenderState(&device
->IDirect3DDevice3_iface
,
292 ci
->u1
.drstRenderStateType
, ci
->u2
.dwArg
[0])))
293 WARN("Failed to set render state.\n");
299 case D3DOP_PROCESSVERTICES
:
300 TRACE("PROCESSVERTICES (%d)\n", count
);
302 for (i
= 0; i
< count
; ++i
)
304 D3DPROCESSVERTICES
*ci
= (D3DPROCESSVERTICES
*)instr
;
305 DWORD op
= ci
->dwFlags
& D3DPROCESSVERTICES_OPMASK
;
307 TRACE(" start %u, dest %u, count %u, flags %#x.\n",
308 ci
->wStart
, ci
->wDest
, ci
->dwCount
, ci
->dwFlags
);
310 if (ci
->dwFlags
& D3DPROCESSVERTICES_UPDATEEXTENTS
)
311 FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n");
312 if (ci
->dwFlags
& D3DPROCESSVERTICES_NOCOLOR
)
313 FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n");
317 case D3DPROCESSVERTICES_TRANSFORMLIGHT
:
318 case D3DPROCESSVERTICES_TRANSFORM
:
319 wined3d_device_set_stream_source(device
->wined3d_device
, 0,
320 buffer
->src_vertex_buffer
, buffer
->src_vertex_pos
, sizeof(D3DVERTEX
));
321 if (op
== D3DPROCESSVERTICES_TRANSFORMLIGHT
)
323 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
324 ddraw_find_decl(device
->ddraw
, D3DFVF_VERTEX
));
325 wined3d_device_set_render_state(device
->wined3d_device
,
326 WINED3D_RS_LIGHTING
, TRUE
);
330 wined3d_device_set_vertex_declaration(device
->wined3d_device
,
331 ddraw_find_decl(device
->ddraw
, D3DFVF_LVERTEX
));
332 wined3d_device_set_render_state(device
->wined3d_device
,
333 WINED3D_RS_LIGHTING
, FALSE
);
336 wined3d_device_process_vertices(device
->wined3d_device
, ci
->wStart
, ci
->wDest
,
337 ci
->dwCount
, buffer
->dst_vertex_buffer
, NULL
, 0, D3DFVF_TLVERTEX
);
340 case D3DPROCESSVERTICES_COPY
:
341 box
.left
= (buffer
->src_vertex_pos
+ ci
->wStart
) * sizeof(D3DTLVERTEX
);
342 box
.right
= box
.left
+ ci
->dwCount
* sizeof(D3DTLVERTEX
);
343 box
.top
= box
.front
= 0;
344 box
.bottom
= box
.back
= 1;
345 wined3d_device_copy_sub_resource_region(device
->wined3d_device
,
346 wined3d_buffer_get_resource(buffer
->dst_vertex_buffer
), 0,
347 ci
->wDest
* sizeof(D3DTLVERTEX
), 0, 0,
348 wined3d_buffer_get_resource(buffer
->src_vertex_buffer
), 0, &box
);
352 FIXME("Unhandled vertex processing op %#x.\n", op
);
360 case D3DOP_TEXTURELOAD
:
361 TRACE("TEXTURELOAD (%u)\n", count
);
363 for (i
= 0; i
< count
; ++i
)
365 D3DTEXTURELOAD
*ci
= (D3DTEXTURELOAD
*)instr
;
366 struct ddraw_surface
*dst
, *src
;
370 if (!(dst
= ddraw_get_object(&device
->handle_table
,
371 ci
->hDestTexture
- 1, DDRAW_HANDLE_SURFACE
)))
373 WARN("Invalid destination texture handle %#x.\n", ci
->hDestTexture
);
376 if (!(src
= ddraw_get_object(&device
->handle_table
,
377 ci
->hSrcTexture
- 1, DDRAW_HANDLE_SURFACE
)))
379 WARN("Invalid source texture handle %#x.\n", ci
->hSrcTexture
);
383 IDirect3DTexture2_Load(&dst
->IDirect3DTexture2_iface
, &src
->IDirect3DTexture2_iface
);
388 TRACE("EXIT (%u)\n", count
);
392 case D3DOP_BRANCHFORWARD
:
393 TRACE("BRANCHFORWARD (%d)\n", count
);
394 for (i
= 0; i
< count
; ++i
)
396 D3DBRANCH
*ci
= (D3DBRANCH
*)instr
;
398 if ((buffer
->data
.dsStatus
.dwStatus
& ci
->dwMask
) == ci
->dwValue
)
402 TRACE(" Branch to %d\n", ci
->dwOffset
);
404 instr
= (char*)current
+ ci
->dwOffset
;
413 TRACE(" Branch to %d\n", ci
->dwOffset
);
415 instr
= (char*)current
+ ci
->dwOffset
;
426 WARN("SPAN-s (%u)\n", count
);
427 instr
+= count
* size
;
430 case D3DOP_SETSTATUS
:
431 TRACE("SETSTATUS (%d)\n", count
);
432 for (i
= 0; i
< count
; ++i
)
434 buffer
->data
.dsStatus
= *(D3DSTATUS
*)instr
;
440 ERR("Unhandled OpCode %#x.\n",current
->bOpcode
);
441 instr
+= count
* size
;
450 static inline struct d3d_execute_buffer
*impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer
*iface
)
452 return CONTAINING_RECORD(iface
, struct d3d_execute_buffer
, IDirect3DExecuteBuffer_iface
);
455 static HRESULT WINAPI
d3d_execute_buffer_QueryInterface(IDirect3DExecuteBuffer
*iface
, REFIID iid
, void **out
)
457 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
459 if (IsEqualGUID(&IID_IDirect3DExecuteBuffer
, iid
)
460 || IsEqualGUID(&IID_IUnknown
, iid
))
462 IDirect3DExecuteBuffer_AddRef(iface
);
467 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
470 return E_NOINTERFACE
;
473 /*****************************************************************************
474 * IDirect3DExecuteBuffer::AddRef
476 * A normal AddRef method, nothing special
481 *****************************************************************************/
482 static ULONG WINAPI
d3d_execute_buffer_AddRef(IDirect3DExecuteBuffer
*iface
)
484 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
485 ULONG ref
= InterlockedIncrement(&buffer
->ref
);
487 TRACE("%p increasing refcount to %u.\n", buffer
, ref
);
492 /*****************************************************************************
493 * IDirect3DExecuteBuffer::Release
495 * A normal Release method, nothing special
500 *****************************************************************************/
501 static ULONG WINAPI
d3d_execute_buffer_Release(IDirect3DExecuteBuffer
*iface
)
503 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
504 ULONG ref
= InterlockedDecrement(&buffer
->ref
);
506 TRACE("%p decreasing refcount to %u.\n", buffer
, ref
);
510 if (buffer
->need_free
)
511 heap_free(buffer
->desc
.lpData
);
512 if (buffer
->index_buffer
)
513 wined3d_buffer_decref(buffer
->index_buffer
);
514 if (buffer
->dst_vertex_buffer
)
516 wined3d_buffer_decref(buffer
->src_vertex_buffer
);
517 wined3d_buffer_decref(buffer
->dst_vertex_buffer
);
525 /*****************************************************************************
526 * IDirect3DExecuteBuffer::Initialize
528 * Initializes the Execute Buffer. This method exists for COM compliance
529 * Nothing to do here.
534 *****************************************************************************/
535 static HRESULT WINAPI
d3d_execute_buffer_Initialize(IDirect3DExecuteBuffer
*iface
,
536 IDirect3DDevice
*device
, D3DEXECUTEBUFFERDESC
*desc
)
538 TRACE("iface %p, device %p, desc %p.\n", iface
, device
, desc
);
543 /*****************************************************************************
544 * IDirect3DExecuteBuffer::Lock
546 * Locks the buffer, so the app can write into it.
549 * Desc: Pointer to return the buffer description. This Description contains
550 * a pointer to the buffer data.
553 * This implementation always returns D3D_OK
555 *****************************************************************************/
556 static HRESULT WINAPI
d3d_execute_buffer_Lock(IDirect3DExecuteBuffer
*iface
, D3DEXECUTEBUFFERDESC
*desc
)
558 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
561 TRACE("iface %p, desc %p.\n", iface
, desc
);
563 dwSize
= desc
->dwSize
;
564 memcpy(desc
, &buffer
->desc
, dwSize
);
568 TRACE(" Returning description :\n");
569 _dump_D3DEXECUTEBUFFERDESC(desc
);
574 /*****************************************************************************
575 * IDirect3DExecuteBuffer::Unlock
577 * Unlocks the buffer. We don't have anything to do here
580 * This implementation always returns D3D_OK
582 *****************************************************************************/
583 static HRESULT WINAPI
d3d_execute_buffer_Unlock(IDirect3DExecuteBuffer
*iface
)
585 TRACE("iface %p.\n", iface
);
590 /*****************************************************************************
591 * IDirect3DExecuteBuffer::SetExecuteData
593 * Sets the execute data. This data is used to describe the buffer's content
596 * Data: Pointer to a D3DEXECUTEDATA structure containing the data to
601 * DDERR_OUTOFMEMORY if the vertex buffer allocation failed
603 *****************************************************************************/
604 static HRESULT WINAPI
d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer
*iface
, D3DEXECUTEDATA
*data
)
606 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
607 struct wined3d_map_desc map_desc
;
608 struct wined3d_box box
= {0};
611 TRACE("iface %p, data %p.\n", iface
, data
);
613 /* Skip past previous vertex data. */
614 buffer
->src_vertex_pos
+= buffer
->data
.dwVertexCount
;
616 if (buffer
->vertex_size
< data
->dwVertexCount
)
618 unsigned int new_size
= max(data
->dwVertexCount
, buffer
->vertex_size
* 2);
619 struct wined3d_buffer
*src_buffer
, *dst_buffer
;
620 struct wined3d_buffer_desc desc
;
622 desc
.byte_width
= new_size
* sizeof(D3DVERTEX
);
624 desc
.bind_flags
= WINED3D_BIND_VERTEX_BUFFER
;
625 desc
.access
= WINED3D_RESOURCE_ACCESS_CPU
| WINED3D_RESOURCE_ACCESS_MAP_R
| WINED3D_RESOURCE_ACCESS_MAP_W
;
627 desc
.structure_byte_stride
= 0;
629 if (FAILED(hr
= wined3d_buffer_create(buffer
->d3ddev
->wined3d_device
, &desc
,
630 NULL
, NULL
, &ddraw_null_wined3d_parent_ops
, &src_buffer
)))
633 desc
.byte_width
= new_size
* sizeof(D3DTLVERTEX
);
634 desc
.usage
= WINED3DUSAGE_STATICDECL
;
635 desc
.access
= WINED3D_RESOURCE_ACCESS_GPU
| WINED3D_RESOURCE_ACCESS_MAP_R
| WINED3D_RESOURCE_ACCESS_MAP_W
;
637 if (FAILED(hr
= wined3d_buffer_create(buffer
->d3ddev
->wined3d_device
, &desc
,
638 NULL
, NULL
, &ddraw_null_wined3d_parent_ops
, &dst_buffer
)))
640 wined3d_buffer_decref(src_buffer
);
644 if (buffer
->dst_vertex_buffer
)
646 wined3d_buffer_decref(buffer
->src_vertex_buffer
);
647 wined3d_buffer_decref(buffer
->dst_vertex_buffer
);
649 buffer
->src_vertex_buffer
= src_buffer
;
650 buffer
->dst_vertex_buffer
= dst_buffer
;
651 buffer
->vertex_size
= new_size
;
652 buffer
->src_vertex_pos
= 0;
654 else if (buffer
->vertex_size
- data
->dwVertexCount
< buffer
->src_vertex_pos
)
656 buffer
->src_vertex_pos
= 0;
659 if (data
->dwVertexCount
)
661 box
.left
= buffer
->src_vertex_pos
* sizeof(D3DVERTEX
);
662 box
.right
= box
.left
+ data
->dwVertexCount
* sizeof(D3DVERTEX
);
663 if (FAILED(hr
= wined3d_resource_map(wined3d_buffer_get_resource(buffer
->src_vertex_buffer
),
664 0, &map_desc
, &box
, WINED3D_MAP_WRITE
)))
667 memcpy(map_desc
.data
, ((BYTE
*)buffer
->desc
.lpData
) + data
->dwVertexOffset
,
668 data
->dwVertexCount
* sizeof(D3DVERTEX
));
670 wined3d_resource_unmap(wined3d_buffer_get_resource(buffer
->src_vertex_buffer
), 0);
673 memcpy(&buffer
->data
, data
, data
->dwSize
);
676 _dump_executedata(data
);
681 /*****************************************************************************
682 * IDirect3DExecuteBuffer::GetExecuteData
684 * Returns the data in the execute buffer
687 * Data: Pointer to a D3DEXECUTEDATA structure used to return data
692 *****************************************************************************/
693 static HRESULT WINAPI
d3d_execute_buffer_GetExecuteData(IDirect3DExecuteBuffer
*iface
, D3DEXECUTEDATA
*data
)
695 struct d3d_execute_buffer
*buffer
= impl_from_IDirect3DExecuteBuffer(iface
);
698 TRACE("iface %p, data %p.\n", iface
, data
);
700 dwSize
= data
->dwSize
;
701 memcpy(data
, &buffer
->data
, dwSize
);
705 TRACE("Returning data :\n");
706 _dump_executedata(data
);
712 /*****************************************************************************
713 * IDirect3DExecuteBuffer::Validate
715 * DirectX 5 SDK: "The IDirect3DExecuteBuffer::Validate method is not
716 * currently implemented"
722 * DDERR_UNSUPPORTED, because it's not implemented in Windows.
724 *****************************************************************************/
725 static HRESULT WINAPI
d3d_execute_buffer_Validate(IDirect3DExecuteBuffer
*iface
,
726 DWORD
*offset
, LPD3DVALIDATECALLBACK callback
, void *context
, DWORD reserved
)
728 TRACE("iface %p, offset %p, callback %p, context %p, reserved %#x.\n",
729 iface
, offset
, callback
, context
, reserved
);
731 WARN("Not implemented.\n");
733 return DDERR_UNSUPPORTED
; /* Unchecked */
736 /*****************************************************************************
737 * IDirect3DExecuteBuffer::Optimize
739 * DirectX5 SDK: "The IDirect3DExecuteBuffer::Optimize method is not
740 * currently supported"
743 * Dummy: Seems to be an unused dummy ;)
746 * DDERR_UNSUPPORTED, because it's not implemented in Windows.
748 *****************************************************************************/
749 static HRESULT WINAPI
d3d_execute_buffer_Optimize(IDirect3DExecuteBuffer
*iface
, DWORD reserved
)
751 TRACE("iface %p, reserved %#x.\n", iface
, reserved
);
753 WARN("Not implemented.\n");
755 return DDERR_UNSUPPORTED
; /* Unchecked */
758 static const struct IDirect3DExecuteBufferVtbl d3d_execute_buffer_vtbl
=
760 d3d_execute_buffer_QueryInterface
,
761 d3d_execute_buffer_AddRef
,
762 d3d_execute_buffer_Release
,
763 d3d_execute_buffer_Initialize
,
764 d3d_execute_buffer_Lock
,
765 d3d_execute_buffer_Unlock
,
766 d3d_execute_buffer_SetExecuteData
,
767 d3d_execute_buffer_GetExecuteData
,
768 d3d_execute_buffer_Validate
,
769 d3d_execute_buffer_Optimize
,
772 HRESULT
d3d_execute_buffer_init(struct d3d_execute_buffer
*execute_buffer
,
773 struct d3d_device
*device
, D3DEXECUTEBUFFERDESC
*desc
)
775 execute_buffer
->IDirect3DExecuteBuffer_iface
.lpVtbl
= &d3d_execute_buffer_vtbl
;
776 execute_buffer
->ref
= 1;
777 execute_buffer
->d3ddev
= device
;
779 /* Initializes memory */
780 memcpy(&execute_buffer
->desc
, desc
, desc
->dwSize
);
782 /* No buffer given */
783 if (!(execute_buffer
->desc
.dwFlags
& D3DDEB_LPDATA
))
784 execute_buffer
->desc
.lpData
= NULL
;
786 /* No buffer size given */
787 if (!(execute_buffer
->desc
.dwFlags
& D3DDEB_BUFSIZE
))
788 execute_buffer
->desc
.dwBufferSize
= 0;
790 /* Create buffer if asked */
791 if (!execute_buffer
->desc
.lpData
&& execute_buffer
->desc
.dwBufferSize
)
793 execute_buffer
->need_free
= TRUE
;
794 if (!(execute_buffer
->desc
.lpData
= heap_alloc_zero(execute_buffer
->desc
.dwBufferSize
)))
796 ERR("Failed to allocate execute buffer data.\n");
797 return DDERR_OUTOFMEMORY
;
801 execute_buffer
->desc
.dwFlags
|= D3DDEB_LPDATA
;
806 struct d3d_execute_buffer
*unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer
*iface
)
810 assert(iface
->lpVtbl
== &d3d_execute_buffer_vtbl
);
812 return impl_from_IDirect3DExecuteBuffer(iface
);