d3dx9: Handle D3DXCONSTTABLE_LARGEADDRESSAWARE flag.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2022-02-18 11:14:29 +01:00 committed by Alexandre Julliard
parent 514bac00cc
commit 67f6073b9e
2 changed files with 40 additions and 4 deletions

View file

@ -681,11 +681,13 @@ HRESULT WINAPI D3DXPreprocessShaderFromResourceW(HMODULE module, const WCHAR *re
}
struct ID3DXConstantTableImpl {
struct ID3DXConstantTableImpl
{
ID3DXConstantTable ID3DXConstantTable_iface;
LONG ref;
char *ctab;
DWORD size;
DWORD flags;
D3DXCONSTANTTABLE_DESC desc;
struct ctab_constant *constants;
};
@ -860,6 +862,9 @@ static inline struct ctab_constant *get_valid_constant(struct ID3DXConstantTable
if (c) return c;
}
if (table->flags & D3DXCONSTTABLE_LARGEADDRESSAWARE)
return NULL;
return get_constant_by_name(table, NULL, handle);
}
@ -1959,9 +1964,10 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
const D3DXSHADER_CONSTANTINFO *constant_info;
DWORD i;
TRACE("byte_code %p, flags %x, constant_table %p\n", byte_code, flags, constant_table);
TRACE("byte_code %p, flags %#x, constant_table %p.\n", byte_code, flags, constant_table);
if (constant_table) *constant_table = NULL;
if (constant_table)
*constant_table = NULL;
if (!byte_code || !constant_table)
{
@ -1975,7 +1981,8 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
return D3D_OK;
}
if (flags) FIXME("Flags (%#x) are not handled, yet!\n", flags);
if (flags & ~D3DXCONSTTABLE_LARGEADDRESSAWARE)
FIXME("Flags %#x not handled.\n", flags);
hr = D3DXFindShaderComment(byte_code, MAKEFOURCC('C','T','A','B'), &data, &size);
if (hr != D3D_OK)
@ -2014,6 +2021,7 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
object->size = size;
memcpy(object->ctab, data, object->size);
object->flags = flags;
object->desc.Creator = ctab_header->Creator ? object->ctab + ctab_header->Creator : NULL;
object->desc.Version = ctab_header->Version;
object->desc.Constants = ctab_header->Constants;

View file

@ -556,6 +556,34 @@ static void test_get_shader_constant_table_ex(void)
ID3DXConstantTable_Release(constant_table);
hr = D3DXGetShaderConstantTableEx(shader_with_ctab_constants, D3DXCONSTTABLE_LARGEADDRESSAWARE, &constant_table);
ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
ok(!!constant_table, "Unexpected constant table %p.\n", constant_table);
hr = ID3DXConstantTable_GetDesc(constant_table, &desc);
ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
ok(!strcmp(desc.Creator, "Wine project"), "Unexpected Creator %s.\n", debugstr_a(desc.Creator));
ok(desc.Version == D3DVS_VERSION(3, 0), "Unexpected Version %#x.\n", desc.Version);
ok(desc.Constants == 3, "Unexpected Constants %u.\n", desc.Constants);
constant = ID3DXConstantTable_GetConstant(constant_table, NULL, 0);
ok(!!constant, "No constant found.\n");
hr = ID3DXConstantTable_GetConstantDesc(constant_table, constant, &constant_desc, &nb);
ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
ok(!strcmp(constant_desc.Name, "Constant1"), "Unexpected Name %s.\n", debugstr_a(constant_desc.Name));
ok(constant_desc.Class == D3DXPC_VECTOR, "Unexpected Class %u.\n", constant_desc.Class);
ok(constant_desc.Type == D3DXPT_FLOAT, "Unexpected Type %u.\n", constant_desc.Type);
ok(constant_desc.Rows == 1, "Unexpected Rows %u.\n", constant_desc.Rows);
ok(constant_desc.Columns == 4, "Unexpected Columns %u.\n", constant_desc.Columns);
if (0)
{
/* Native d3dx crashes with this. */
hr = ID3DXConstantTable_GetConstantDesc(constant_table, "Constant3", &constant_desc, &nb);
}
ID3DXConstantTable_Release(constant_table);
hr = D3DXGetShaderConstantTableEx(fx_shader_with_ctab, 0, &constant_table);
ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
ok(!constant_table, "D3DXGetShaderConstantTableEx() returned a non-NULL constant table.\n");