Commit 7e1ad91e authored by Rico Schüller's avatar Rico Schüller Committed by Alexandre Julliard

d3d10: Improve parse_fx10_type().

parent 22d8fc08
...@@ -352,6 +352,8 @@ static HRESULT parse_fx10_type(struct d3d10_effect_type *t, const char *ptr, con ...@@ -352,6 +352,8 @@ static HRESULT parse_fx10_type(struct d3d10_effect_type *t, const char *ptr, con
{ {
DWORD unknown0; DWORD unknown0;
DWORD offset; DWORD offset;
DWORD typeinfo;
unsigned int i;
read_dword(&ptr, &offset); read_dword(&ptr, &offset);
TRACE("Type name at offset %#x.\n", offset); TRACE("Type name at offset %#x.\n", offset);
...@@ -378,84 +380,102 @@ static HRESULT parse_fx10_type(struct d3d10_effect_type *t, const char *ptr, con ...@@ -378,84 +380,102 @@ static HRESULT parse_fx10_type(struct d3d10_effect_type *t, const char *ptr, con
read_dword(&ptr, &t->size_packed); read_dword(&ptr, &t->size_packed);
TRACE("Packed size %#x.\n", t->size_packed); TRACE("Packed size %#x.\n", t->size_packed);
if (unknown0 == 1) switch (unknown0)
{ {
DWORD tmp; case 1:
t->member_count = 0;
t->member_count = 0; read_dword(&ptr, &typeinfo);
t->column_count = (typeinfo & D3D10_FX10_TYPE_COLUMN_MASK) >> D3D10_FX10_TYPE_COLUMN_SHIFT;
t->row_count = (typeinfo & D3D10_FX10_TYPE_ROW_MASK) >> D3D10_FX10_TYPE_ROW_SHIFT;
t->basetype = d3d10_variable_type((typeinfo & D3D10_FX10_TYPE_BASETYPE_MASK) >> D3D10_FX10_TYPE_BASETYPE_SHIFT, FALSE);
t->type_class = d3d10_variable_class((typeinfo & D3D10_FX10_TYPE_CLASS_MASK) >> D3D10_FX10_TYPE_CLASS_SHIFT, typeinfo & D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK);
read_dword(&ptr, &tmp); TRACE("Type description: %#x.\n", typeinfo);
t->column_count = (tmp & D3D10_FX10_TYPE_COLUMN_MASK) >> D3D10_FX10_TYPE_COLUMN_SHIFT; TRACE("\tcolumns: %u.\n", t->column_count);
t->row_count = (tmp & D3D10_FX10_TYPE_ROW_MASK) >> D3D10_FX10_TYPE_ROW_SHIFT; TRACE("\trows: %u.\n", t->row_count);
t->basetype = d3d10_variable_type((tmp & D3D10_FX10_TYPE_BASETYPE_MASK) >> D3D10_FX10_TYPE_BASETYPE_SHIFT, FALSE); TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
t->type_class = d3d10_variable_class((tmp & D3D10_FX10_TYPE_CLASS_MASK) >> D3D10_FX10_TYPE_CLASS_SHIFT, tmp & D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK); TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
TRACE("\tunknown bits: %#x.\n", typeinfo & ~(D3D10_FX10_TYPE_COLUMN_MASK | D3D10_FX10_TYPE_ROW_MASK
| D3D10_FX10_TYPE_BASETYPE_MASK | D3D10_FX10_TYPE_CLASS_MASK | D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK));
break;
TRACE("Type description: %#x.\n", tmp); case 2:
TRACE("\tcolumns: %u.\n", t->column_count); TRACE("Type is an object.\n");
TRACE("\trows: %u.\n", t->row_count);
TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
TRACE("\tunknown bits: %#x.\n", tmp & ~(D3D10_FX10_TYPE_COLUMN_MASK | D3D10_FX10_TYPE_ROW_MASK
| D3D10_FX10_TYPE_BASETYPE_MASK | D3D10_FX10_TYPE_CLASS_MASK | D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK));
}
else if (unknown0 == 3)
{
unsigned int i;
TRACE("Type is a structure.\n"); t->member_count = 0;
t->column_count = 0;
t->row_count = 0;
t->type_class = D3D10_SVC_OBJECT;
read_dword(&ptr, &t->member_count); read_dword(&ptr, &typeinfo);
TRACE("Member count: %u.\n", t->member_count); t->basetype = d3d10_variable_type(typeinfo, TRUE);
t->column_count = 0; TRACE("Type description: %#x.\n", typeinfo);
t->row_count = 0; TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
t->basetype = 0; TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
t->type_class = D3D10_SVC_STRUCT; break;
t->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, t->member_count * sizeof(*t->members)); case 3:
if (!t->members) TRACE("Type is a structure.\n");
{
ERR("Failed to allocate members memory.\n");
return E_OUTOFMEMORY;
}
for (i = 0; i < t->member_count; ++i) read_dword(&ptr, &t->member_count);
{ TRACE("Member count: %u.\n", t->member_count);
struct d3d10_effect_type_member *typem = &t->members[i];
read_dword(&ptr, &offset); t->column_count = 0;
TRACE("Member name at offset %#x.\n", offset); t->row_count = 0;
t->basetype = 0;
t->type_class = D3D10_SVC_STRUCT;
if (!copy_name(data + offset, &typem->name)) t->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, t->member_count * sizeof(*t->members));
if (!t->members)
{ {
ERR("Failed to copy name.\n"); ERR("Failed to allocate members memory.\n");
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
TRACE("Member name: %s.\n", debugstr_a(typem->name));
read_dword(&ptr, &offset);
TRACE("Member semantic at offset %#x.\n", offset);
if (!copy_name(data + offset, &typem->semantic)) for (i = 0; i < t->member_count; ++i)
{ {
ERR("Failed to copy semantic.\n"); struct d3d10_effect_type_member *typem = &t->members[i];
return E_OUTOFMEMORY;
read_dword(&ptr, &offset);
TRACE("Member name at offset %#x.\n", offset);
if (!copy_name(data + offset, &typem->name))
{
ERR("Failed to copy name.\n");
return E_OUTOFMEMORY;
}
TRACE("Member name: %s.\n", debugstr_a(typem->name));
read_dword(&ptr, &offset);
TRACE("Member semantic at offset %#x.\n", offset);
if (!copy_name(data + offset, &typem->semantic))
{
ERR("Failed to copy semantic.\n");
return E_OUTOFMEMORY;
}
TRACE("Member semantic: %s.\n", debugstr_a(typem->semantic));
read_dword(&ptr, &typem->buffer_offset);
TRACE("Member offset in struct: %#x.\n", typem->buffer_offset);
read_dword(&ptr, &offset);
TRACE("Member type info at offset %#x.\n", offset);
typem->type = get_fx10_type(t->effect, data, offset);
if (!typem->type)
{
ERR("Failed to get variable type.\n");
return E_FAIL;
}
} }
TRACE("Member semantic: %s.\n", debugstr_a(typem->semantic)); break;
read_dword(&ptr, &typem->buffer_offset);
TRACE("Member offset in struct: %#x.\n", typem->buffer_offset);
read_dword(&ptr, &offset);
TRACE("Member type info at offset %#x.\n", offset);
typem->type = get_fx10_type(t->effect, data, offset); default:
if (!typem->type) FIXME("Unhandled case %#x.\n", unknown0);
{ return E_FAIL;
ERR("Failed to get variable type.\n");
return E_FAIL;
}
}
} }
if (t->element_count) if (t->element_count)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment