2008-10-20 15:28:08 +02:00
|
|
|
/*
|
2009-09-09 18:12:38 +02:00
|
|
|
* Copyright 2008-2009 Henri Verbeet for CodeWeavers
|
2008-10-20 15:28:08 +02: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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "d3d10_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
|
|
|
|
|
|
|
|
#define WINE_D3D10_TO_STR(x) case x: return #x
|
|
|
|
|
|
|
|
const char *debug_d3d10_driver_type(D3D10_DRIVER_TYPE driver_type)
|
|
|
|
{
|
|
|
|
switch(driver_type)
|
|
|
|
{
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_HARDWARE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_REFERENCE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_NULL);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_SOFTWARE);
|
2014-01-27 10:07:53 +01:00
|
|
|
WINE_D3D10_TO_STR(D3D10_DRIVER_TYPE_WARP);
|
2008-10-20 15:28:08 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D10_DRIVER_TYPE %#x\n", driver_type);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-09 18:12:38 +02:00
|
|
|
const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c)
|
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVC_SCALAR);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVC_VECTOR);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_ROWS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_COLUMNS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVC_OBJECT);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVC_STRUCT);
|
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D10_SHADER_VARIABLE_CLASS %#x.\n", c);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-09 18:12:39 +02:00
|
|
|
const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t)
|
|
|
|
{
|
|
|
|
switch (t)
|
|
|
|
{
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_VOID);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_BOOL);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_INT);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_FLOAT);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_STRING);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1D);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2D);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE3D);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_SAMPLER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_PIXELSHADER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_VERTEXSHADER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_UINT);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_UINT8);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_GEOMETRYSHADER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_RASTERIZER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCIL);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_BLEND);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_BUFFER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_CBUFFER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TBUFFER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1DARRAY);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DARRAY);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_RENDERTARGETVIEW);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCILVIEW);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMSARRAY);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBEARRAY);
|
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D10_SHADER_VARIABLE_TYPE %#x.\n", t);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-14 20:45:25 +01:00
|
|
|
const char *debug_d3d10_device_state_types(D3D10_DEVICE_STATE_TYPES t)
|
|
|
|
{
|
|
|
|
switch (t)
|
|
|
|
{
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_SO_BUFFERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_OM_RENDER_TARGETS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_DEPTH_STENCIL_STATE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_BLEND_STATE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_VS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_VS_SAMPLERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_VS_SHADER_RESOURCES);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_VS_CONSTANT_BUFFERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_GS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_GS_SAMPLERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_GS_SHADER_RESOURCES);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_GS_CONSTANT_BUFFERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_PS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_PS_SAMPLERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_PS_SHADER_RESOURCES);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_PS_CONSTANT_BUFFERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_IA_VERTEX_BUFFERS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_IA_INDEX_BUFFER);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_IA_INPUT_LAYOUT);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_IA_PRIMITIVE_TOPOLOGY);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_RS_VIEWPORTS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_RS_SCISSOR_RECTS);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_RS_RASTERIZER_STATE);
|
|
|
|
WINE_D3D10_TO_STR(D3D10_DST_PREDICATION);
|
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D10_DEVICE_STATE_TYPES %#x.\n", t);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-20 15:28:08 +02:00
|
|
|
#undef WINE_D3D10_TO_STR
|
2009-09-08 16:38:00 +02:00
|
|
|
|
|
|
|
void *d3d10_rb_alloc(size_t size)
|
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *d3d10_rb_realloc(void *ptr, size_t size)
|
|
|
|
{
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void d3d10_rb_free(void *ptr)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
2010-07-19 21:48:36 +02:00
|
|
|
|
2011-12-11 21:43:29 +01:00
|
|
|
void skip_dword_unknown(const char *location, const char **ptr, unsigned int count)
|
2010-07-19 21:48:36 +02:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
DWORD d;
|
|
|
|
|
2011-12-11 21:43:29 +01:00
|
|
|
FIXME("Skipping %u unknown DWORDs (%s):\n", count, location);
|
2010-07-19 21:48:36 +02:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
read_dword(ptr, &d);
|
|
|
|
FIXME("\t0x%08x\n", d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void write_dword_unknown(char **ptr, DWORD d)
|
|
|
|
{
|
|
|
|
FIXME("Writing unknown DWORD 0x%08x\n", d);
|
|
|
|
write_dword(ptr, d);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
|
|
|
HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
|
|
|
|
{
|
|
|
|
const char *ptr = data;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
DWORD chunk_count;
|
|
|
|
DWORD total_size;
|
|
|
|
unsigned int i;
|
|
|
|
DWORD tag;
|
|
|
|
|
2010-07-19 21:48:41 +02:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
WARN("No data supplied.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-07-19 21:48:36 +02:00
|
|
|
read_dword(&ptr, &tag);
|
|
|
|
TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
|
|
|
|
|
|
|
|
if (tag != TAG_DXBC)
|
|
|
|
{
|
|
|
|
WARN("Wrong tag.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checksum? */
|
2011-12-11 21:43:29 +01:00
|
|
|
skip_dword_unknown("DXBC header", &ptr, 4);
|
2010-07-19 21:48:36 +02:00
|
|
|
|
2011-12-11 21:43:29 +01:00
|
|
|
skip_dword_unknown("DXBC header", &ptr, 1);
|
2010-07-19 21:48:36 +02:00
|
|
|
|
|
|
|
read_dword(&ptr, &total_size);
|
|
|
|
TRACE("total size: %#x\n", total_size);
|
|
|
|
|
2010-07-19 21:48:41 +02:00
|
|
|
if (data_size != total_size)
|
|
|
|
{
|
|
|
|
WARN("Wrong size supplied.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-07-19 21:48:36 +02:00
|
|
|
read_dword(&ptr, &chunk_count);
|
|
|
|
TRACE("chunk count: %#x\n", chunk_count);
|
|
|
|
|
|
|
|
for (i = 0; i < chunk_count; ++i)
|
|
|
|
{
|
|
|
|
DWORD chunk_tag, chunk_size;
|
|
|
|
const char *chunk_ptr;
|
|
|
|
DWORD chunk_offset;
|
|
|
|
|
|
|
|
read_dword(&ptr, &chunk_offset);
|
|
|
|
TRACE("chunk %u at offset %#x\n", i, chunk_offset);
|
|
|
|
|
2016-05-24 19:46:44 +02:00
|
|
|
if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
|
2016-05-24 19:46:42 +02:00
|
|
|
{
|
|
|
|
WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-07-19 21:48:36 +02:00
|
|
|
chunk_ptr = data + chunk_offset;
|
|
|
|
|
|
|
|
read_dword(&chunk_ptr, &chunk_tag);
|
|
|
|
read_dword(&chunk_ptr, &chunk_size);
|
|
|
|
|
2016-05-24 19:46:44 +02:00
|
|
|
if (!require_space(chunk_ptr - data, 1, chunk_size, data_size))
|
2016-05-24 19:46:42 +02:00
|
|
|
{
|
|
|
|
WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", chunk_size, data_size, chunk_offset);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-07-19 21:48:36 +02:00
|
|
|
hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx);
|
|
|
|
if (FAILED(hr)) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|