1999-01-03 18:00:19 +01:00
|
|
|
/* Direct3D ExecuteBuffer
|
2004-08-02 20:26:53 +02:00
|
|
|
* Copyright (c) 1998-2004 Lionel ULMER
|
|
|
|
* Copyright (c) 2002-2004 Christian Costa
|
2008-10-18 19:19:45 +02:00
|
|
|
* Copyright (c) 2006 Stefan Dösinger
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
2006-06-09 19:36:12 +02:00
|
|
|
#include "wine/port.h"
|
2001-10-14 18:18:52 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
#include "ddraw_private.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* _dump_executedata
|
|
|
|
* _dump_D3DEXECUTEBUFFERDESC
|
|
|
|
*
|
|
|
|
* Debug functions which write the executebuffer data to the console
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2007-04-21 23:16:34 +02:00
|
|
|
static void _dump_executedata(const D3DEXECUTEDATA *lpData) {
|
2007-12-04 23:27:33 +01:00
|
|
|
TRACE("dwSize : %d\n", lpData->dwSize);
|
|
|
|
TRACE("Vertex Offset : %d Count : %d\n", lpData->dwVertexOffset, lpData->dwVertexCount);
|
|
|
|
TRACE("Instruction Offset : %d Length : %d\n", lpData->dwInstructionOffset, lpData->dwInstructionLength);
|
|
|
|
TRACE("HVertex Offset : %d\n", lpData->dwHVertexOffset);
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2007-04-21 23:16:34 +02:00
|
|
|
static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC *lpDesc) {
|
2007-12-04 23:27:33 +01:00
|
|
|
TRACE("dwSize : %d\n", lpDesc->dwSize);
|
|
|
|
TRACE("dwFlags : %x\n", lpDesc->dwFlags);
|
|
|
|
TRACE("dwCaps : %x\n", lpDesc->dwCaps);
|
|
|
|
TRACE("dwBufferSize : %d\n", lpDesc->dwBufferSize);
|
|
|
|
TRACE("lpData : %p\n", lpDesc->lpData);
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer,
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *device, struct d3d_viewport *viewport)
|
2002-11-24 23:14:40 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
DWORD is = buffer->data.dwInstructionOffset;
|
|
|
|
char *instr = (char *)buffer->desc.lpData + is;
|
2016-11-13 22:12:47 +01:00
|
|
|
unsigned int i, primitive_size;
|
2016-10-30 15:02:21 +01:00
|
|
|
struct wined3d_map_desc map_desc;
|
|
|
|
struct wined3d_box box = {0};
|
|
|
|
HRESULT hr;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2012-04-09 20:43:40 +02:00
|
|
|
if (viewport->active_device != device)
|
2011-04-19 00:08:00 +02:00
|
|
|
{
|
|
|
|
WARN("Viewport %p active device is %p.\n",
|
2012-03-14 22:04:32 +01:00
|
|
|
viewport, viewport->active_device);
|
2011-04-19 00:08:00 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
|
|
|
|
/* Activate the viewport */
|
2012-03-14 22:04:32 +01:00
|
|
|
viewport_activate(viewport, FALSE);
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("ExecuteData :\n");
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
2012-04-10 22:06:21 +02:00
|
|
|
_dump_executedata(&(buffer->data));
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2013-01-13 22:08:05 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
D3DINSTRUCTION *current = (D3DINSTRUCTION *)instr;
|
2017-01-24 22:15:28 +01:00
|
|
|
BYTE size;
|
|
|
|
WORD count;
|
|
|
|
|
|
|
|
count = current->wCount;
|
|
|
|
size = current->bSize;
|
|
|
|
instr += sizeof(*current);
|
2016-11-13 22:12:47 +01:00
|
|
|
primitive_size = 0;
|
|
|
|
|
|
|
|
switch (current->bOpcode)
|
|
|
|
{
|
|
|
|
case D3DOP_POINT:
|
|
|
|
{
|
|
|
|
const D3DPOINT *p = (D3DPOINT *)instr;
|
2017-05-18 15:20:01 +02:00
|
|
|
wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_POINTLIST, 0);
|
2016-11-13 22:12:47 +01:00
|
|
|
wined3d_device_set_stream_source(device->wined3d_device, 0,
|
|
|
|
buffer->dst_vertex_buffer, 0, sizeof(D3DTLVERTEX));
|
|
|
|
wined3d_device_set_vertex_declaration(device->wined3d_device,
|
|
|
|
ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX));
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
wined3d_device_draw_primitive(device->wined3d_device, p[i].wFirst, p[i].wCount);
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2016-11-13 22:12:47 +01:00
|
|
|
instr += sizeof(*p) * count;
|
|
|
|
break;
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2016-11-13 22:12:47 +01:00
|
|
|
case D3DOP_LINE:
|
|
|
|
primitive_size = 2;
|
2017-05-18 15:20:01 +02:00
|
|
|
wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_LINELIST, 0);
|
2016-11-13 22:12:47 +01:00
|
|
|
/* Drop through. */
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_TRIANGLE:
|
|
|
|
{
|
2016-10-30 15:02:21 +01:00
|
|
|
WORD *indices;
|
2016-11-13 22:12:47 +01:00
|
|
|
unsigned int index_pos = buffer->index_pos, index_count;
|
2016-10-30 15:02:21 +01:00
|
|
|
TRACE("TRIANGLE (%d)\n", count);
|
2012-04-10 22:06:21 +02:00
|
|
|
|
2016-10-30 15:02:21 +01:00
|
|
|
if (!count)
|
|
|
|
break;
|
|
|
|
|
2016-11-13 22:12:47 +01:00
|
|
|
if (!primitive_size)
|
|
|
|
{
|
2017-05-18 15:20:01 +02:00
|
|
|
wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_TRIANGLELIST, 0);
|
2016-11-13 22:12:47 +01:00
|
|
|
primitive_size = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
index_count = count * primitive_size;
|
|
|
|
|
|
|
|
if (buffer->index_size < index_count)
|
2012-04-10 22:06:21 +02:00
|
|
|
{
|
2016-11-13 22:12:47 +01:00
|
|
|
unsigned int new_size = max(buffer->index_size * 2, index_count);
|
2018-02-06 00:34:15 +01:00
|
|
|
struct wined3d_buffer *new_buffer;
|
|
|
|
struct wined3d_buffer_desc desc;
|
|
|
|
|
|
|
|
desc.byte_width = new_size * sizeof(*indices);
|
|
|
|
desc.usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_STATICDECL;
|
|
|
|
desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
|
2019-01-25 18:15:08 +01:00
|
|
|
desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_W;
|
2018-02-06 00:34:15 +01:00
|
|
|
desc.misc_flags = 0;
|
|
|
|
desc.structure_byte_stride = 0;
|
2016-10-30 15:02:21 +01:00
|
|
|
|
2018-02-06 00:34:15 +01:00
|
|
|
if (FAILED(hr = wined3d_buffer_create(device->wined3d_device, &desc,
|
|
|
|
NULL, NULL, &ddraw_null_wined3d_parent_ops, &new_buffer)))
|
2016-10-30 15:02:21 +01:00
|
|
|
return hr;
|
|
|
|
|
|
|
|
buffer->index_size = new_size;
|
|
|
|
if (buffer->index_buffer)
|
|
|
|
wined3d_buffer_decref(buffer->index_buffer);
|
|
|
|
buffer->index_buffer = new_buffer;
|
2016-11-13 22:12:45 +01:00
|
|
|
index_pos = 0;
|
|
|
|
}
|
2016-11-13 22:12:47 +01:00
|
|
|
else if (buffer->index_size - index_count < index_pos)
|
2016-11-13 22:12:45 +01:00
|
|
|
{
|
|
|
|
index_pos = 0;
|
2012-04-10 22:06:21 +02:00
|
|
|
}
|
|
|
|
|
2016-11-13 22:12:45 +01:00
|
|
|
box.left = index_pos * sizeof(*indices);
|
2016-11-13 22:12:47 +01:00
|
|
|
box.right = (index_pos + index_count) * sizeof(*indices);
|
2018-02-18 19:08:34 +01:00
|
|
|
if (FAILED(hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0, &map_desc,
|
|
|
|
&box, WINED3D_MAP_WRITE | (index_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))))
|
2016-10-30 15:02:21 +01:00
|
|
|
return hr;
|
|
|
|
indices = map_desc.data;
|
|
|
|
|
2013-01-16 08:51:45 +01:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DTRIANGLE *ci = (D3DTRIANGLE *)instr;
|
2016-10-30 15:02:21 +01:00
|
|
|
TRACE(" v1: %d v2: %d v3: %d\n",ci->u1.v1, ci->u2.v2, ci->u3.v3);
|
|
|
|
TRACE(" Flags : ");
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
/* Wireframe */
|
|
|
|
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1)
|
|
|
|
TRACE("EDGEENABLE1 ");
|
|
|
|
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2)
|
|
|
|
TRACE("EDGEENABLE2 ");
|
|
|
|
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1)
|
|
|
|
TRACE("EDGEENABLE3 ");
|
|
|
|
/* Strips / Fans */
|
|
|
|
if (ci->wFlags == D3DTRIFLAG_EVEN)
|
|
|
|
TRACE("EVEN ");
|
|
|
|
if (ci->wFlags == D3DTRIFLAG_ODD)
|
|
|
|
TRACE("ODD ");
|
|
|
|
if (ci->wFlags == D3DTRIFLAG_START)
|
|
|
|
TRACE("START ");
|
|
|
|
if ((ci->wFlags > 0) && (ci->wFlags < 30))
|
|
|
|
TRACE("STARTFLAT(%u) ", ci->wFlags);
|
|
|
|
TRACE("\n");
|
|
|
|
}
|
2016-11-13 22:12:47 +01:00
|
|
|
|
|
|
|
switch (primitive_size)
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
indices[(i * primitive_size) + 2] = ci->u3.v3;
|
|
|
|
/* Drop through. */
|
|
|
|
case 2:
|
|
|
|
indices[(i * primitive_size) + 1] = ci->u2.v2;
|
|
|
|
indices[(i * primitive_size) ] = ci->u1.v1;
|
|
|
|
}
|
2003-05-20 19:49:40 +02:00
|
|
|
instr += size;
|
2012-05-24 18:27:40 +02:00
|
|
|
}
|
2016-10-30 15:02:21 +01:00
|
|
|
|
|
|
|
wined3d_resource_unmap(wined3d_buffer_get_resource(buffer->index_buffer), 0);
|
|
|
|
|
|
|
|
wined3d_device_set_stream_source(device->wined3d_device, 0,
|
|
|
|
buffer->dst_vertex_buffer, 0, sizeof(D3DTLVERTEX));
|
|
|
|
wined3d_device_set_vertex_declaration(device->wined3d_device,
|
|
|
|
ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX));
|
|
|
|
wined3d_device_set_index_buffer(device->wined3d_device, buffer->index_buffer, WINED3DFMT_R16_UINT, 0);
|
2016-11-13 22:12:47 +01:00
|
|
|
wined3d_device_draw_indexed_primitive(device->wined3d_device, index_pos, index_count);
|
2016-11-13 22:12:45 +01:00
|
|
|
|
2016-11-13 22:12:47 +01:00
|
|
|
buffer->index_pos = index_pos + index_count;
|
2016-11-13 22:12:45 +01:00
|
|
|
break;
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2017-01-24 22:15:28 +01:00
|
|
|
case D3DOP_MATRIXLOAD:
|
|
|
|
WARN("MATRIXLOAD-s (%u)\n", count);
|
|
|
|
instr += count * size;
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_MATRIXMULTIPLY:
|
|
|
|
TRACE("MATRIXMULTIPLY (%d)\n", count);
|
2010-07-29 12:56:58 +02:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DMATRIXMULTIPLY *ci = (D3DMATRIXMULTIPLY *)instr;
|
|
|
|
D3DMATRIX *a, *b, *c;
|
|
|
|
|
2012-04-09 20:43:40 +02:00
|
|
|
a = ddraw_get_object(&device->handle_table, ci->hDestMatrix - 1, DDRAW_HANDLE_MATRIX);
|
|
|
|
b = ddraw_get_object(&device->handle_table, ci->hSrcMatrix1 - 1, DDRAW_HANDLE_MATRIX);
|
|
|
|
c = ddraw_get_object(&device->handle_table, ci->hSrcMatrix2 - 1, DDRAW_HANDLE_MATRIX);
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
if (!a || !b || !c)
|
|
|
|
{
|
|
|
|
ERR("Invalid matrix handle (a %#x -> %p, b %#x -> %p, c %#x -> %p).\n",
|
|
|
|
ci->hDestMatrix, a, ci->hSrcMatrix1, b, ci->hSrcMatrix2, c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("dst %p, src1 %p, src2 %p.\n", a, b, c);
|
|
|
|
multiply_matrix(a, c, b);
|
2006-06-29 14:15:03 +02:00
|
|
|
}
|
2003-05-20 19:49:40 +02:00
|
|
|
|
2006-06-29 14:15:03 +02:00
|
|
|
instr += size;
|
2014-04-29 10:41:02 +02:00
|
|
|
}
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_STATETRANSFORM:
|
|
|
|
TRACE("STATETRANSFORM (%d)\n", count);
|
2010-07-29 12:56:58 +02:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DSTATE *ci = (D3DSTATE *)instr;
|
|
|
|
D3DMATRIX *m;
|
|
|
|
|
2012-04-09 20:43:40 +02:00
|
|
|
m = ddraw_get_object(&device->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATRIX);
|
2010-07-29 12:56:58 +02:00
|
|
|
if (!m)
|
|
|
|
{
|
|
|
|
ERR("Invalid matrix handle %#x.\n", ci->u2.dwArg[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_WORLD)
|
2012-04-09 20:43:40 +02:00
|
|
|
device->world = ci->u2.dwArg[0];
|
2010-07-29 12:56:58 +02:00
|
|
|
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_VIEW)
|
2012-04-09 20:43:40 +02:00
|
|
|
device->view = ci->u2.dwArg[0];
|
2010-07-29 12:56:58 +02:00
|
|
|
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_PROJECTION)
|
2012-04-09 20:43:40 +02:00
|
|
|
device->proj = ci->u2.dwArg[0];
|
2016-10-01 19:39:28 +02:00
|
|
|
IDirect3DDevice3_SetTransform(&device->IDirect3DDevice3_iface,
|
2010-07-29 12:56:58 +02:00
|
|
|
ci->u1.dtstTransformStateType, m);
|
2006-06-29 14:15:03 +02:00
|
|
|
}
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
2014-04-29 10:41:02 +02:00
|
|
|
break;
|
2008-05-07 01:06:06 +02:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_STATELIGHT:
|
|
|
|
TRACE("STATELIGHT (%d)\n", count);
|
2013-01-15 08:46:51 +01:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DSTATE *ci = (D3DSTATE *)instr;
|
2003-05-20 19:49:40 +02:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
if (FAILED(IDirect3DDevice3_SetLightState(&device->IDirect3DDevice3_iface,
|
|
|
|
ci->u1.dlstLightStateType, ci->u2.dwArg[0])))
|
|
|
|
WARN("Failed to set light state.\n");
|
2008-05-07 01:06:06 +02:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_STATERENDER:
|
2014-04-29 13:31:54 +02:00
|
|
|
TRACE("STATERENDER (%d)\n", count);
|
2013-01-15 08:46:51 +01:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DSTATE *ci = (D3DSTATE *)instr;
|
2009-09-01 09:09:37 +02:00
|
|
|
|
2014-04-29 13:31:54 +02:00
|
|
|
if (FAILED(IDirect3DDevice3_SetRenderState(&device->IDirect3DDevice3_iface,
|
|
|
|
ci->u1.drstRenderStateType, ci->u2.dwArg[0])))
|
|
|
|
WARN("Failed to set render state.\n");
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 13:31:54 +02:00
|
|
|
instr += size;
|
2014-04-29 10:41:02 +02:00
|
|
|
}
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DOP_PROCESSVERTICES:
|
|
|
|
TRACE("PROCESSVERTICES (%d)\n", count);
|
|
|
|
|
2013-01-15 08:46:52 +01:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DPROCESSVERTICES *ci = (D3DPROCESSVERTICES *)instr;
|
2014-04-29 10:41:04 +02:00
|
|
|
DWORD op = ci->dwFlags & D3DPROCESSVERTICES_OPMASK;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:04 +02:00
|
|
|
TRACE(" start %u, dest %u, count %u, flags %#x.\n",
|
|
|
|
ci->wStart, ci->wDest, ci->dwCount, ci->dwFlags);
|
|
|
|
|
|
|
|
if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
|
|
|
|
FIXME("D3DPROCESSVERTICES_UPDATEEXTENTS not implemented.\n");
|
|
|
|
if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
|
|
|
|
FIXME("D3DPROCESSVERTICES_NOCOLOR not implemented.\n");
|
|
|
|
|
|
|
|
switch (op)
|
2010-08-19 18:57:50 +02:00
|
|
|
{
|
2014-04-29 10:41:04 +02:00
|
|
|
case D3DPROCESSVERTICES_TRANSFORMLIGHT:
|
2016-11-13 22:12:44 +01:00
|
|
|
case D3DPROCESSVERTICES_TRANSFORM:
|
|
|
|
wined3d_device_set_stream_source(device->wined3d_device, 0,
|
2016-11-13 22:12:46 +01:00
|
|
|
buffer->src_vertex_buffer, buffer->src_vertex_pos, sizeof(D3DVERTEX));
|
2016-11-13 22:12:44 +01:00
|
|
|
if (op == D3DPROCESSVERTICES_TRANSFORMLIGHT)
|
2014-04-29 10:41:04 +02:00
|
|
|
{
|
2016-11-13 22:12:44 +01:00
|
|
|
wined3d_device_set_vertex_declaration(device->wined3d_device,
|
|
|
|
ddraw_find_decl(device->ddraw, D3DFVF_VERTEX));
|
|
|
|
wined3d_device_set_render_state(device->wined3d_device,
|
|
|
|
WINED3D_RS_LIGHTING, TRUE);
|
2014-04-29 10:41:04 +02:00
|
|
|
}
|
2016-11-13 22:12:44 +01:00
|
|
|
else
|
2014-04-29 10:41:04 +02:00
|
|
|
{
|
2016-11-13 22:12:44 +01:00
|
|
|
wined3d_device_set_vertex_declaration(device->wined3d_device,
|
|
|
|
ddraw_find_decl(device->ddraw, D3DFVF_LVERTEX));
|
|
|
|
wined3d_device_set_render_state(device->wined3d_device,
|
|
|
|
WINED3D_RS_LIGHTING, FALSE);
|
2014-04-29 10:41:04 +02:00
|
|
|
}
|
2016-10-30 15:02:21 +01:00
|
|
|
|
2016-11-13 22:12:44 +01:00
|
|
|
wined3d_device_process_vertices(device->wined3d_device, ci->wStart, ci->wDest,
|
|
|
|
ci->dwCount, buffer->dst_vertex_buffer, NULL, 0, D3DFVF_TLVERTEX);
|
2014-04-29 10:41:04 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DPROCESSVERTICES_COPY:
|
2016-11-13 22:12:46 +01:00
|
|
|
box.left = (buffer->src_vertex_pos + ci->wStart) * sizeof(D3DTLVERTEX);
|
|
|
|
box.right = box.left + ci->dwCount * sizeof(D3DTLVERTEX);
|
2016-11-13 22:12:44 +01:00
|
|
|
box.top = box.front = 0;
|
|
|
|
box.bottom = box.back = 1;
|
|
|
|
wined3d_device_copy_sub_resource_region(device->wined3d_device,
|
|
|
|
wined3d_buffer_get_resource(buffer->dst_vertex_buffer), 0,
|
|
|
|
ci->wDest * sizeof(D3DTLVERTEX), 0, 0,
|
2018-05-18 16:08:45 +02:00
|
|
|
wined3d_buffer_get_resource(buffer->src_vertex_buffer), 0, &box, 0);
|
2014-04-29 10:41:04 +02:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:04 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled vertex processing op %#x.\n", op);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
instr += size;
|
|
|
|
}
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2017-01-24 22:15:28 +01:00
|
|
|
case D3DOP_TEXTURELOAD:
|
2017-02-06 14:12:11 +01:00
|
|
|
TRACE("TEXTURELOAD (%u)\n", count);
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DTEXTURELOAD *ci = (D3DTEXTURELOAD *)instr;
|
|
|
|
struct ddraw_surface *dst, *src;
|
|
|
|
|
|
|
|
instr += size;
|
|
|
|
|
|
|
|
if (!(dst = ddraw_get_object(&device->handle_table,
|
|
|
|
ci->hDestTexture - 1, DDRAW_HANDLE_SURFACE)))
|
|
|
|
{
|
|
|
|
WARN("Invalid destination texture handle %#x.\n", ci->hDestTexture);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!(src = ddraw_get_object(&device->handle_table,
|
|
|
|
ci->hSrcTexture - 1, DDRAW_HANDLE_SURFACE)))
|
|
|
|
{
|
|
|
|
WARN("Invalid source texture handle %#x.\n", ci->hSrcTexture);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirect3DTexture2_Load(&dst->IDirect3DTexture2_iface, &src->IDirect3DTexture2_iface);
|
|
|
|
}
|
2017-01-24 22:15:28 +01:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2017-01-24 22:15:28 +01:00
|
|
|
case D3DOP_EXIT:
|
|
|
|
TRACE("EXIT (%u)\n", count);
|
|
|
|
instr += size;
|
|
|
|
goto end_of_buffer;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_BRANCHFORWARD:
|
|
|
|
TRACE("BRANCHFORWARD (%d)\n", count);
|
2013-01-16 08:51:46 +01:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
D3DBRANCH *ci = (D3DBRANCH *)instr;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
if ((buffer->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue)
|
|
|
|
{
|
|
|
|
if (!ci->bNegate)
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE(" Branch to %d\n", ci->dwOffset);
|
2008-02-18 02:36:35 +01:00
|
|
|
if (ci->dwOffset) {
|
|
|
|
instr = (char*)current + ci->dwOffset;
|
|
|
|
break;
|
|
|
|
}
|
2017-01-24 22:15:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ci->bNegate)
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE(" Branch to %d\n", ci->dwOffset);
|
2008-02-18 02:36:35 +01:00
|
|
|
if (ci->dwOffset) {
|
|
|
|
instr = (char*)current + ci->dwOffset;
|
|
|
|
break;
|
|
|
|
}
|
2017-01-24 22:15:28 +01:00
|
|
|
}
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2017-01-24 22:15:28 +01:00
|
|
|
instr += size;
|
2014-04-29 10:41:02 +02:00
|
|
|
}
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2017-01-24 22:15:28 +01:00
|
|
|
case D3DOP_SPAN:
|
|
|
|
WARN("SPAN-s (%u)\n", count);
|
|
|
|
instr += count * size;
|
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2014-04-29 10:41:02 +02:00
|
|
|
case D3DOP_SETSTATUS:
|
|
|
|
TRACE("SETSTATUS (%d)\n", count);
|
2013-01-17 10:24:25 +01:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
buffer->data.dsStatus = *(D3DSTATUS *)instr;
|
|
|
|
instr += size;
|
|
|
|
}
|
2014-04-29 10:41:02 +02:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2017-01-24 22:15:28 +01:00
|
|
|
default:
|
|
|
|
ERR("Unhandled OpCode %#x.\n",current->bOpcode);
|
|
|
|
instr += count * size;
|
|
|
|
break;
|
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2002-11-24 23:14:40 +01:00
|
|
|
end_of_buffer:
|
2011-04-19 00:08:00 +02:00
|
|
|
return D3D_OK;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
static inline struct d3d_execute_buffer *impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer *iface)
|
2011-07-08 12:26:57 +02:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_execute_buffer, IDirect3DExecuteBuffer_iface);
|
2011-07-08 12:26:57 +02:00
|
|
|
}
|
|
|
|
|
2014-04-29 10:41:05 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_QueryInterface(IDirect3DExecuteBuffer *iface, REFIID iid, void **out)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2014-04-29 10:41:05 +02:00
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2014-04-29 10:41:05 +02:00
|
|
|
if (IsEqualGUID(&IID_IDirect3DExecuteBuffer, iid)
|
|
|
|
|| IsEqualGUID(&IID_IUnknown, iid))
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirect3DExecuteBuffer_AddRef(iface);
|
2014-04-29 10:41:05 +02:00
|
|
|
*out = iface;
|
|
|
|
return S_OK;
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
2014-04-29 10:41:05 +02:00
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
|
|
|
|
*out = NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return E_NOINTERFACE;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::AddRef
|
|
|
|
*
|
|
|
|
* A normal AddRef method, nothing special
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static ULONG WINAPI d3d_execute_buffer_AddRef(IDirect3DExecuteBuffer *iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
struct d3d_execute_buffer *buffer = impl_from_IDirect3DExecuteBuffer(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&buffer->ref);
|
2005-01-09 18:29:21 +01:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", buffer, ref);
|
2005-01-09 18:29:21 +01:00
|
|
|
|
|
|
|
return ref;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::Release
|
|
|
|
*
|
|
|
|
* A normal Release method, nothing special
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static ULONG WINAPI d3d_execute_buffer_Release(IDirect3DExecuteBuffer *iface)
|
2002-11-21 22:04:16 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
struct d3d_execute_buffer *buffer = impl_from_IDirect3DExecuteBuffer(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&buffer->ref);
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", buffer, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
|
|
|
if (buffer->need_free)
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(buffer->desc.lpData);
|
2016-10-30 15:02:21 +01:00
|
|
|
if (buffer->index_buffer)
|
|
|
|
wined3d_buffer_decref(buffer->index_buffer);
|
|
|
|
if (buffer->dst_vertex_buffer)
|
2016-11-13 22:12:44 +01:00
|
|
|
{
|
|
|
|
wined3d_buffer_decref(buffer->src_vertex_buffer);
|
2016-10-30 15:02:21 +01:00
|
|
|
wined3d_buffer_decref(buffer->dst_vertex_buffer);
|
2016-11-13 22:12:44 +01:00
|
|
|
}
|
2018-02-13 10:32:47 +01:00
|
|
|
heap_free(buffer);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2005-01-09 18:29:21 +01:00
|
|
|
return ref;
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::Initialize
|
|
|
|
*
|
|
|
|
* Initializes the Execute Buffer. This method exists for COM compliance
|
|
|
|
* Nothing to do here.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_Initialize(IDirect3DExecuteBuffer *iface,
|
2010-08-19 18:57:50 +02:00
|
|
|
IDirect3DDevice *device, D3DEXECUTEBUFFERDESC *desc)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, device %p, desc %p.\n", iface, device, desc);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::Lock
|
|
|
|
*
|
|
|
|
* Locks the buffer, so the app can write into it.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Desc: Pointer to return the buffer description. This Description contains
|
|
|
|
* a pointer to the buffer data.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* This implementation always returns D3D_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_Lock(IDirect3DExecuteBuffer *iface, D3DEXECUTEBUFFERDESC *desc)
|
2002-11-21 22:04:16 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
struct d3d_execute_buffer *buffer = impl_from_IDirect3DExecuteBuffer(iface);
|
2002-11-21 22:04:16 +01:00
|
|
|
DWORD dwSize;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
dwSize = desc->dwSize;
|
|
|
|
memcpy(desc, &buffer->desc, dwSize);
|
2009-09-01 09:09:37 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE(" Returning description :\n");
|
2012-04-10 22:06:21 +02:00
|
|
|
_dump_D3DEXECUTEBUFFERDESC(desc);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::Unlock
|
|
|
|
*
|
|
|
|
* Unlocks the buffer. We don't have anything to do here
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* This implementation always returns D3D_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_Unlock(IDirect3DExecuteBuffer *iface)
|
2002-11-21 22:04:16 +01:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::SetExecuteData
|
|
|
|
*
|
|
|
|
* Sets the execute data. This data is used to describe the buffer's content
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Data: Pointer to a D3DEXECUTEDATA structure containing the data to
|
|
|
|
* assign
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_OUTOFMEMORY if the vertex buffer allocation failed
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_SetExecuteData(IDirect3DExecuteBuffer *iface, D3DEXECUTEDATA *data)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
struct d3d_execute_buffer *buffer = impl_from_IDirect3DExecuteBuffer(iface);
|
2016-11-13 22:12:44 +01:00
|
|
|
struct wined3d_map_desc map_desc;
|
|
|
|
struct wined3d_box box = {0};
|
|
|
|
HRESULT hr;
|
2018-04-05 12:59:14 +02:00
|
|
|
DWORD buf_size = buffer->desc.dwBufferSize, copy_size;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2018-04-05 12:59:13 +02:00
|
|
|
if (data->dwSize != sizeof(*data))
|
|
|
|
{
|
|
|
|
WARN("data->dwSize is %u, returning DDERR_INVALIDPARAMS.\n", data->dwSize);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2016-11-13 22:12:46 +01:00
|
|
|
/* Skip past previous vertex data. */
|
|
|
|
buffer->src_vertex_pos += buffer->data.dwVertexCount;
|
|
|
|
|
2016-10-30 15:02:21 +01:00
|
|
|
if (buffer->vertex_size < data->dwVertexCount)
|
|
|
|
{
|
|
|
|
unsigned int new_size = max(data->dwVertexCount, buffer->vertex_size * 2);
|
2016-11-13 22:12:44 +01:00
|
|
|
struct wined3d_buffer *src_buffer, *dst_buffer;
|
2018-02-06 23:41:30 +01:00
|
|
|
struct wined3d_buffer_desc desc;
|
2016-11-13 22:12:44 +01:00
|
|
|
|
2018-02-06 23:41:30 +01:00
|
|
|
desc.byte_width = new_size * sizeof(D3DVERTEX);
|
2018-02-06 23:41:31 +01:00
|
|
|
desc.usage = 0;
|
2018-02-06 23:41:30 +01:00
|
|
|
desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
|
2018-02-18 19:08:35 +01:00
|
|
|
desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
|
2018-02-06 23:41:30 +01:00
|
|
|
desc.misc_flags = 0;
|
|
|
|
desc.structure_byte_stride = 0;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_buffer_create(buffer->d3ddev->wined3d_device, &desc,
|
|
|
|
NULL, NULL, &ddraw_null_wined3d_parent_ops, &src_buffer)))
|
2016-11-13 22:12:44 +01:00
|
|
|
return hr;
|
2016-10-30 15:02:21 +01:00
|
|
|
|
2018-02-06 23:41:30 +01:00
|
|
|
desc.byte_width = new_size * sizeof(D3DTLVERTEX);
|
|
|
|
desc.usage = WINED3DUSAGE_STATICDECL;
|
2019-01-25 18:15:08 +01:00
|
|
|
desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_W;
|
2018-02-06 23:41:30 +01:00
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_buffer_create(buffer->d3ddev->wined3d_device, &desc,
|
|
|
|
NULL, NULL, &ddraw_null_wined3d_parent_ops, &dst_buffer)))
|
2016-11-13 22:12:44 +01:00
|
|
|
{
|
|
|
|
wined3d_buffer_decref(src_buffer);
|
2016-10-30 15:02:21 +01:00
|
|
|
return hr;
|
2016-11-13 22:12:44 +01:00
|
|
|
}
|
2016-10-30 15:02:21 +01:00
|
|
|
|
|
|
|
if (buffer->dst_vertex_buffer)
|
2016-11-13 22:12:44 +01:00
|
|
|
{
|
|
|
|
wined3d_buffer_decref(buffer->src_vertex_buffer);
|
2016-10-30 15:02:21 +01:00
|
|
|
wined3d_buffer_decref(buffer->dst_vertex_buffer);
|
2016-11-13 22:12:44 +01:00
|
|
|
}
|
|
|
|
buffer->src_vertex_buffer = src_buffer;
|
2016-10-30 15:02:21 +01:00
|
|
|
buffer->dst_vertex_buffer = dst_buffer;
|
|
|
|
buffer->vertex_size = new_size;
|
2016-11-13 22:12:46 +01:00
|
|
|
buffer->src_vertex_pos = 0;
|
|
|
|
}
|
|
|
|
else if (buffer->vertex_size - data->dwVertexCount < buffer->src_vertex_pos)
|
|
|
|
{
|
|
|
|
buffer->src_vertex_pos = 0;
|
2016-10-30 15:02:21 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2018-04-05 12:59:14 +02:00
|
|
|
if (data->dwVertexCount && (!buf_size || data->dwVertexOffset < buf_size))
|
2016-11-13 22:12:44 +01:00
|
|
|
{
|
2016-11-13 22:12:46 +01:00
|
|
|
box.left = buffer->src_vertex_pos * sizeof(D3DVERTEX);
|
|
|
|
box.right = box.left + data->dwVertexCount * sizeof(D3DVERTEX);
|
2018-02-06 23:41:31 +01:00
|
|
|
if (FAILED(hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->src_vertex_buffer),
|
2018-02-18 19:08:34 +01:00
|
|
|
0, &map_desc, &box, WINED3D_MAP_WRITE)))
|
2016-11-13 22:12:44 +01:00
|
|
|
return hr;
|
|
|
|
|
2018-04-05 12:59:14 +02:00
|
|
|
copy_size = data->dwVertexCount * sizeof(D3DVERTEX);
|
|
|
|
if (buf_size)
|
|
|
|
copy_size = min(copy_size, buf_size - data->dwVertexOffset);
|
|
|
|
|
|
|
|
memcpy(map_desc.data, ((BYTE *)buffer->desc.lpData) + data->dwVertexOffset, copy_size);
|
2016-11-13 22:12:44 +01:00
|
|
|
|
|
|
|
wined3d_resource_unmap(wined3d_buffer_get_resource(buffer->src_vertex_buffer), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&buffer->data, data, data->dwSize);
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
2012-04-10 22:06:21 +02:00
|
|
|
_dump_executedata(data);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::GetExecuteData
|
|
|
|
*
|
|
|
|
* Returns the data in the execute buffer
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Data: Pointer to a D3DEXECUTEDATA structure used to return data
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_GetExecuteData(IDirect3DExecuteBuffer *iface, D3DEXECUTEDATA *data)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
struct d3d_execute_buffer *buffer = impl_from_IDirect3DExecuteBuffer(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2018-04-05 12:59:13 +02:00
|
|
|
/* Tests show that dwSize is ignored. */
|
|
|
|
memcpy(data, &buffer->data, sizeof(*data));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("Returning data :\n");
|
2012-04-10 22:06:21 +02:00
|
|
|
_dump_executedata(data);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
return DD_OK;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::Validate
|
|
|
|
*
|
|
|
|
* DirectX 5 SDK: "The IDirect3DExecuteBuffer::Validate method is not
|
|
|
|
* currently implemented"
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED, because it's not implemented in Windows.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_Validate(IDirect3DExecuteBuffer *iface,
|
2010-08-19 18:57:50 +02:00
|
|
|
DWORD *offset, LPD3DVALIDATECALLBACK callback, void *context, DWORD reserved)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, offset %p, callback %p, context %p, reserved %#x.\n",
|
|
|
|
iface, offset, callback, context, reserved);
|
|
|
|
|
|
|
|
WARN("Not implemented.\n");
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_UNSUPPORTED; /* Unchecked */
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DExecuteBuffer::Optimize
|
|
|
|
*
|
|
|
|
* DirectX5 SDK: "The IDirect3DExecuteBuffer::Optimize method is not
|
|
|
|
* currently supported"
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Dummy: Seems to be an unused dummy ;)
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED, because it's not implemented in Windows.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-04-10 22:06:21 +02:00
|
|
|
static HRESULT WINAPI d3d_execute_buffer_Optimize(IDirect3DExecuteBuffer *iface, DWORD reserved)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, reserved %#x.\n", iface, reserved);
|
|
|
|
|
|
|
|
WARN("Not implemented.\n");
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_UNSUPPORTED; /* Unchecked */
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2010-08-19 18:57:45 +02:00
|
|
|
static const struct IDirect3DExecuteBufferVtbl d3d_execute_buffer_vtbl =
|
2002-11-21 22:04:16 +01:00
|
|
|
{
|
2012-04-10 22:06:21 +02:00
|
|
|
d3d_execute_buffer_QueryInterface,
|
|
|
|
d3d_execute_buffer_AddRef,
|
|
|
|
d3d_execute_buffer_Release,
|
|
|
|
d3d_execute_buffer_Initialize,
|
|
|
|
d3d_execute_buffer_Lock,
|
|
|
|
d3d_execute_buffer_Unlock,
|
|
|
|
d3d_execute_buffer_SetExecuteData,
|
|
|
|
d3d_execute_buffer_GetExecuteData,
|
|
|
|
d3d_execute_buffer_Validate,
|
|
|
|
d3d_execute_buffer_Optimize,
|
2002-11-21 22:04:16 +01:00
|
|
|
};
|
2010-08-19 18:57:45 +02:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
HRESULT d3d_execute_buffer_init(struct d3d_execute_buffer *execute_buffer,
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *device, D3DEXECUTEBUFFERDESC *desc)
|
2010-08-19 18:57:45 +02:00
|
|
|
{
|
2011-07-08 12:26:57 +02:00
|
|
|
execute_buffer->IDirect3DExecuteBuffer_iface.lpVtbl = &d3d_execute_buffer_vtbl;
|
2010-08-19 18:57:45 +02:00
|
|
|
execute_buffer->ref = 1;
|
|
|
|
execute_buffer->d3ddev = device;
|
|
|
|
|
|
|
|
/* Initializes memory */
|
|
|
|
memcpy(&execute_buffer->desc, desc, desc->dwSize);
|
|
|
|
|
|
|
|
/* No buffer given */
|
|
|
|
if (!(execute_buffer->desc.dwFlags & D3DDEB_LPDATA))
|
|
|
|
execute_buffer->desc.lpData = NULL;
|
|
|
|
|
|
|
|
/* No buffer size given */
|
|
|
|
if (!(execute_buffer->desc.dwFlags & D3DDEB_BUFSIZE))
|
|
|
|
execute_buffer->desc.dwBufferSize = 0;
|
|
|
|
|
|
|
|
/* Create buffer if asked */
|
|
|
|
if (!execute_buffer->desc.lpData && execute_buffer->desc.dwBufferSize)
|
|
|
|
{
|
|
|
|
execute_buffer->need_free = TRUE;
|
2018-02-13 10:32:47 +01:00
|
|
|
if (!(execute_buffer->desc.lpData = heap_alloc_zero(execute_buffer->desc.dwBufferSize)))
|
2010-08-19 18:57:45 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate execute buffer data.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
execute_buffer->desc.dwFlags |= D3DDEB_LPDATA;
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
2011-07-08 12:28:27 +02:00
|
|
|
|
2012-04-10 22:06:21 +02:00
|
|
|
struct d3d_execute_buffer *unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer *iface)
|
2011-07-08 12:28:27 +02:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d_execute_buffer_vtbl);
|
|
|
|
|
|
|
|
return impl_from_IDirect3DExecuteBuffer(iface);
|
|
|
|
}
|