mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
d3dx9: Parse effect parameter type definition.
This commit is contained in:
parent
9c09f14270
commit
20dc97296b
3 changed files with 223 additions and 5 deletions
|
@ -50,4 +50,8 @@ HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer,
|
|||
const PixelFormatDesc *get_format_info(D3DFORMAT format);
|
||||
const PixelFormatDesc *get_format_info_idx(int idx);
|
||||
|
||||
/* debug helpers */
|
||||
const char *debug_d3dxparameter_class(D3DXPARAMETER_CLASS c);
|
||||
const char *debug_d3dxparameter_type(D3DXPARAMETER_TYPE t);
|
||||
|
||||
#endif /* __WINE_D3DX9_36_PRIVATE_H */
|
||||
|
|
|
@ -34,10 +34,18 @@ struct d3dx_parameter
|
|||
{
|
||||
struct ID3DXBaseEffectImpl *base;
|
||||
|
||||
D3DXPARAMETER_CLASS class;
|
||||
D3DXPARAMETER_TYPE type;
|
||||
UINT rows;
|
||||
UINT columns;
|
||||
UINT element_count;
|
||||
UINT annotation_count;
|
||||
UINT member_count;
|
||||
DWORD flags;
|
||||
UINT bytes;
|
||||
|
||||
D3DXHANDLE *annotation_handles;
|
||||
D3DXHANDLE *member_handles;
|
||||
};
|
||||
|
||||
struct ID3DXBaseEffectImpl
|
||||
|
@ -122,6 +130,15 @@ static void free_parameter(D3DXHANDLE handle)
|
|||
HeapFree(GetProcessHeap(), 0, param->annotation_handles);
|
||||
}
|
||||
|
||||
if (param->member_handles)
|
||||
{
|
||||
for (i = 0; i < param->element_count; ++i)
|
||||
{
|
||||
free_parameter(param->member_handles[i]);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, param->member_handles);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, param);
|
||||
}
|
||||
|
||||
|
@ -2375,20 +2392,157 @@ static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
|
|||
ID3DXEffectCompilerImpl_CompileShader,
|
||||
};
|
||||
|
||||
static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr, struct d3dx_parameter *parent)
|
||||
{
|
||||
DWORD offset;
|
||||
HRESULT hr;
|
||||
D3DXHANDLE *member_handles = NULL;
|
||||
UINT i;
|
||||
|
||||
if (!parent)
|
||||
{
|
||||
read_dword(ptr, ¶m->type);
|
||||
TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
|
||||
|
||||
read_dword(ptr, ¶m->class);
|
||||
TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
|
||||
|
||||
read_dword(ptr, &offset);
|
||||
TRACE("Type name offset: %#x\n", offset);
|
||||
/* todo: Parse name */
|
||||
|
||||
read_dword(ptr, &offset);
|
||||
TRACE("Type semantic offset: %#x\n", offset);
|
||||
/* todo: Parse semantic */
|
||||
|
||||
read_dword(ptr, ¶m->element_count);
|
||||
TRACE("Elements: %u\n", param->element_count);
|
||||
|
||||
switch (param->class)
|
||||
{
|
||||
case D3DXPC_VECTOR:
|
||||
read_dword(ptr, ¶m->columns);
|
||||
TRACE("Columns: %u\n", param->columns);
|
||||
|
||||
read_dword(ptr, ¶m->rows);
|
||||
TRACE("Rows: %u\n", param->rows);
|
||||
|
||||
/* sizeof(DWORD) * rows * columns */
|
||||
param->bytes = 4 * param->rows * param->columns;
|
||||
break;
|
||||
|
||||
case D3DXPC_SCALAR:
|
||||
case D3DXPC_MATRIX_ROWS:
|
||||
case D3DXPC_MATRIX_COLUMNS:
|
||||
read_dword(ptr, ¶m->rows);
|
||||
TRACE("Rows: %u\n", param->rows);
|
||||
|
||||
read_dword(ptr, ¶m->columns);
|
||||
TRACE("Columns: %u\n", param->columns);
|
||||
|
||||
/* sizeof(DWORD) * rows * columns */
|
||||
param->bytes = 4 * param->rows * param->columns;
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* elements */
|
||||
param->type = parent->type;
|
||||
param->class = parent->class;
|
||||
param->element_count = 0;
|
||||
param->annotation_count = 0;
|
||||
param->member_count = parent->member_count;
|
||||
param->bytes = parent->bytes;
|
||||
param->flags = parent->flags;
|
||||
param->rows = parent->rows;
|
||||
param->columns = parent->columns;
|
||||
}
|
||||
|
||||
if (param->element_count)
|
||||
{
|
||||
unsigned int param_bytes = 0;
|
||||
|
||||
member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
|
||||
if (!member_handles)
|
||||
{
|
||||
ERR("Out of memory\n");
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
for (i = 0; i < param->element_count; ++i)
|
||||
{
|
||||
struct d3dx_parameter *member;
|
||||
|
||||
member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
|
||||
if (!member)
|
||||
{
|
||||
ERR("Out of memory\n");
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
member_handles[i] = get_parameter_handle(member);
|
||||
member->base = param->base;
|
||||
|
||||
hr = d3dx9_parse_effect_typedef(member, data, ptr, param);
|
||||
if (hr != D3D_OK)
|
||||
{
|
||||
WARN("Failed to parse member\n");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
param_bytes += member->bytes;
|
||||
}
|
||||
|
||||
param->bytes = param_bytes;
|
||||
}
|
||||
|
||||
param->member_handles = member_handles;
|
||||
|
||||
return D3D_OK;
|
||||
|
||||
err_out:
|
||||
|
||||
if (member_handles)
|
||||
{
|
||||
for (i = 0; i < param->element_count; ++i)
|
||||
{
|
||||
free_parameter(member_handles[i]);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, member_handles);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr)
|
||||
{
|
||||
DWORD offset;
|
||||
const char *ptr2;
|
||||
HRESULT hr;
|
||||
|
||||
anno->flags = D3DX_PARAMETER_ANNOTATION;
|
||||
|
||||
read_dword(ptr, &offset);
|
||||
TRACE("Typedef offset: %#x\n", offset);
|
||||
/* todo: Parse typedef */
|
||||
ptr2 = data + offset;
|
||||
hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL);
|
||||
if (hr != D3D_OK)
|
||||
{
|
||||
WARN("Failed to parse type definition\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
read_dword(ptr, &offset);
|
||||
TRACE("Value offset: %#x\n", offset);
|
||||
/* todo: Parse value */
|
||||
|
||||
anno->flags &= D3DX_PARAMETER_ANNOTATION;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
|
@ -2398,14 +2552,14 @@ static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const
|
|||
HRESULT hr;
|
||||
unsigned int i;
|
||||
D3DXHANDLE *annotation_handles = NULL;
|
||||
const char *ptr2;
|
||||
|
||||
read_dword(ptr, &offset);
|
||||
TRACE("Typedef offset: %#x\n", offset);
|
||||
/* todo: Parse typedef */
|
||||
ptr2 = data + offset;
|
||||
|
||||
read_dword(ptr, &offset);
|
||||
TRACE("Value offset: %#x\n", offset);
|
||||
/* todo: Parse value */
|
||||
|
||||
read_dword(ptr, ¶m->flags);
|
||||
TRACE("Flags: %#x\n", param->flags);
|
||||
|
@ -2413,6 +2567,15 @@ static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const
|
|||
read_dword(ptr, ¶m->annotation_count);
|
||||
TRACE("Annotation count: %u\n", param->annotation_count);
|
||||
|
||||
hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL);
|
||||
if (hr != D3D_OK)
|
||||
{
|
||||
WARN("Failed to parse type definition\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* todo: Parse value */
|
||||
|
||||
if (param->annotation_count)
|
||||
{
|
||||
annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "wine/debug.h"
|
||||
#include "d3dx9_36_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
|
||||
|
||||
/************************************************************
|
||||
* pixel format table providing info about number of bytes per pixel,
|
||||
|
@ -161,3 +162,53 @@ const PixelFormatDesc *get_format_info_idx(int idx)
|
|||
return NULL;
|
||||
return &formats[idx];
|
||||
}
|
||||
|
||||
#define WINE_D3DX_TO_STR(x) case x: return #x
|
||||
|
||||
const char *debug_d3dxparameter_class(D3DXPARAMETER_CLASS c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
WINE_D3DX_TO_STR(D3DXPC_SCALAR);
|
||||
WINE_D3DX_TO_STR(D3DXPC_VECTOR);
|
||||
WINE_D3DX_TO_STR(D3DXPC_MATRIX_ROWS);
|
||||
WINE_D3DX_TO_STR(D3DXPC_MATRIX_COLUMNS);
|
||||
WINE_D3DX_TO_STR(D3DXPC_OBJECT);
|
||||
WINE_D3DX_TO_STR(D3DXPC_STRUCT);
|
||||
default:
|
||||
FIXME("Unrecognized D3DXPARAMETER_CLASS %#x.\n", c);
|
||||
return "unrecognized";
|
||||
}
|
||||
}
|
||||
|
||||
const char *debug_d3dxparameter_type(D3DXPARAMETER_TYPE t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
WINE_D3DX_TO_STR(D3DXPT_VOID);
|
||||
WINE_D3DX_TO_STR(D3DXPT_BOOL);
|
||||
WINE_D3DX_TO_STR(D3DXPT_INT);
|
||||
WINE_D3DX_TO_STR(D3DXPT_FLOAT);
|
||||
WINE_D3DX_TO_STR(D3DXPT_STRING);
|
||||
WINE_D3DX_TO_STR(D3DXPT_TEXTURE);
|
||||
WINE_D3DX_TO_STR(D3DXPT_TEXTURE1D);
|
||||
WINE_D3DX_TO_STR(D3DXPT_TEXTURE2D);
|
||||
WINE_D3DX_TO_STR(D3DXPT_TEXTURE3D);
|
||||
WINE_D3DX_TO_STR(D3DXPT_TEXTURECUBE);
|
||||
WINE_D3DX_TO_STR(D3DXPT_SAMPLER);
|
||||
WINE_D3DX_TO_STR(D3DXPT_SAMPLER1D);
|
||||
WINE_D3DX_TO_STR(D3DXPT_SAMPLER2D);
|
||||
WINE_D3DX_TO_STR(D3DXPT_SAMPLER3D);
|
||||
WINE_D3DX_TO_STR(D3DXPT_SAMPLERCUBE);
|
||||
WINE_D3DX_TO_STR(D3DXPT_PIXELSHADER);
|
||||
WINE_D3DX_TO_STR(D3DXPT_VERTEXSHADER);
|
||||
WINE_D3DX_TO_STR(D3DXPT_PIXELFRAGMENT);
|
||||
WINE_D3DX_TO_STR(D3DXPT_VERTEXFRAGMENT);
|
||||
WINE_D3DX_TO_STR(D3DXPT_UNSUPPORTED);
|
||||
default:
|
||||
FIXME("Unrecognized D3DXPARAMETER_TYP %#x.\n", t);
|
||||
return "unrecognized";
|
||||
}
|
||||
}
|
||||
|
||||
#undef WINE_D3DX_TO_STR
|
||||
|
|
Loading…
Reference in a new issue