d3d10/effect: Validate shared constant buffer types against the pool.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3d1e7b0ed8
commit
099aa57f23
|
@ -269,7 +269,7 @@ struct d3d10_effect
|
||||||
DWORD local_buffer_count;
|
DWORD local_buffer_count;
|
||||||
DWORD variable_count;
|
DWORD variable_count;
|
||||||
DWORD local_variable_count;
|
DWORD local_variable_count;
|
||||||
DWORD sharedbuffers_count;
|
DWORD shared_buffer_count;
|
||||||
DWORD shared_object_count;
|
DWORD shared_object_count;
|
||||||
DWORD technique_count;
|
DWORD technique_count;
|
||||||
DWORD index_offset;
|
DWORD index_offset;
|
||||||
|
|
|
@ -2013,7 +2013,7 @@ static HRESULT parse_fx10_technique(const char *data, size_t data_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size,
|
static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size,
|
||||||
const char **ptr, struct d3d10_effect_variable *v)
|
const char **ptr, BOOL local, struct d3d10_effect_variable *v)
|
||||||
{
|
{
|
||||||
DWORD offset, default_value_offset;
|
DWORD offset, default_value_offset;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -2039,17 +2039,20 @@ static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size,
|
||||||
read_dword(ptr, &v->flag);
|
read_dword(ptr, &v->flag);
|
||||||
TRACE("Variable flag: %#x.\n", v->flag);
|
TRACE("Variable flag: %#x.\n", v->flag);
|
||||||
|
|
||||||
if (default_value_offset)
|
if (local)
|
||||||
FIXME("Set default variable value.\n");
|
|
||||||
|
|
||||||
read_dword(ptr, &v->annotation_count);
|
|
||||||
TRACE("Variable has %u annotations.\n", v->annotation_count);
|
|
||||||
|
|
||||||
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect,
|
|
||||||
v->annotation_count, &v->annotations)))
|
|
||||||
{
|
{
|
||||||
ERR("Failed to parse variable annotations, hr %#x.\n", hr);
|
if (default_value_offset)
|
||||||
return hr;
|
FIXME("Set default variable value.\n");
|
||||||
|
|
||||||
|
read_dword(ptr, &v->annotation_count);
|
||||||
|
TRACE("Variable has %u annotations.\n", v->annotation_count);
|
||||||
|
|
||||||
|
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect,
|
||||||
|
v->annotation_count, &v->annotations)))
|
||||||
|
{
|
||||||
|
ERR("Failed to parse variable annotations, hr %#x.\n", hr);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
|
if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
|
||||||
|
@ -2313,9 +2316,10 @@ static HRESULT create_variable_buffer(struct d3d10_effect_variable *v, D3D10_CBU
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
|
static HRESULT parse_fx10_buffer(const char *data, size_t data_size, const char **ptr,
|
||||||
const char **ptr, struct d3d10_effect_variable *l)
|
BOOL local, struct d3d10_effect_variable *l)
|
||||||
{
|
{
|
||||||
|
const char *prefix = local ? "Local" : "Shared";
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
DWORD offset;
|
DWORD offset;
|
||||||
D3D10_CBUFFER_TYPE d3d10_cbuffer_type;
|
D3D10_CBUFFER_TYPE d3d10_cbuffer_type;
|
||||||
|
@ -2333,20 +2337,20 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
|
||||||
l->type->effect = l->effect;
|
l->type->effect = l->effect;
|
||||||
|
|
||||||
read_dword(ptr, &offset);
|
read_dword(ptr, &offset);
|
||||||
TRACE("Local buffer name at offset %#x.\n", offset);
|
TRACE("%s buffer name at offset %#x.\n", prefix, offset);
|
||||||
|
|
||||||
if (!fx10_copy_string(data, data_size, offset, &l->name))
|
if (!fx10_copy_string(data, data_size, offset, &l->name))
|
||||||
{
|
{
|
||||||
ERR("Failed to copy name.\n");
|
ERR("Failed to copy name.\n");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
TRACE("Local buffer name: %s.\n", debugstr_a(l->name));
|
TRACE("%s buffer name: %s.\n", prefix, debugstr_a(l->name));
|
||||||
|
|
||||||
read_dword(ptr, &l->data_size);
|
read_dword(ptr, &l->data_size);
|
||||||
TRACE("Local buffer data size: %#x.\n", l->data_size);
|
TRACE("%s buffer data size: %#x.\n", prefix, l->data_size);
|
||||||
|
|
||||||
read_dword(ptr, &d3d10_cbuffer_type);
|
read_dword(ptr, &d3d10_cbuffer_type);
|
||||||
TRACE("Local buffer type: %#x.\n", d3d10_cbuffer_type);
|
TRACE("%s buffer type: %#x.\n", prefix, d3d10_cbuffer_type);
|
||||||
|
|
||||||
switch(d3d10_cbuffer_type)
|
switch(d3d10_cbuffer_type)
|
||||||
{
|
{
|
||||||
|
@ -2374,19 +2378,22 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
read_dword(ptr, &l->type->member_count);
|
read_dword(ptr, &l->type->member_count);
|
||||||
TRACE("Local buffer member count: %#x.\n", l->type->member_count);
|
TRACE("%s buffer member count: %#x.\n", prefix, l->type->member_count);
|
||||||
|
|
||||||
read_dword(ptr, &l->explicit_bind_point);
|
read_dword(ptr, &l->explicit_bind_point);
|
||||||
TRACE("Local buffer explicit bind point: %#x.\n", l->explicit_bind_point);
|
TRACE("%s buffer explicit bind point: %#x.\n", prefix, l->explicit_bind_point);
|
||||||
|
|
||||||
read_dword(ptr, &l->annotation_count);
|
if (local)
|
||||||
TRACE("Local buffer has %u annotations.\n", l->annotation_count);
|
|
||||||
|
|
||||||
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, l->effect,
|
|
||||||
l->annotation_count, &l->annotations)))
|
|
||||||
{
|
{
|
||||||
ERR("Failed to parse buffer annotations, hr %#x.\n", hr);
|
read_dword(ptr, &l->annotation_count);
|
||||||
return hr;
|
TRACE("Local buffer has %u annotations.\n", l->annotation_count);
|
||||||
|
|
||||||
|
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, l->effect,
|
||||||
|
l->annotation_count, &l->annotations)))
|
||||||
|
{
|
||||||
|
ERR("Failed to parse buffer annotations, hr %#x.\n", hr);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(l->members = heap_calloc(l->type->member_count, sizeof(*l->members))))
|
if (!(l->members = heap_calloc(l->type->member_count, sizeof(*l->members))))
|
||||||
|
@ -2409,7 +2416,7 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
|
||||||
v->buffer = l;
|
v->buffer = l;
|
||||||
v->effect = l->effect;
|
v->effect = l->effect;
|
||||||
|
|
||||||
if (FAILED(hr = parse_fx10_numeric_variable(data, data_size, ptr, v)))
|
if (FAILED(hr = parse_fx10_numeric_variable(data, data_size, ptr, local, v)))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2480,7 +2487,7 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
|
||||||
}
|
}
|
||||||
l->type->stride = l->type->size_unpacked = (stride + 0xf) & ~0xf;
|
l->type->stride = l->type->size_unpacked = (stride + 0xf) & ~0xf;
|
||||||
|
|
||||||
TRACE("Constant buffer:\n");
|
TRACE("%s constant buffer:\n", prefix);
|
||||||
TRACE("\tType name: %s.\n", debugstr_a(l->type->name));
|
TRACE("\tType name: %s.\n", debugstr_a(l->type->name));
|
||||||
TRACE("\tElement count: %u.\n", l->type->element_count);
|
TRACE("\tElement count: %u.\n", l->type->element_count);
|
||||||
TRACE("\tMember count: %u.\n", l->type->member_count);
|
TRACE("\tMember count: %u.\n", l->type->member_count);
|
||||||
|
@ -2490,7 +2497,7 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
|
||||||
TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
|
TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
|
||||||
TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
|
TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
|
||||||
|
|
||||||
if (l->type->size_unpacked)
|
if (local && l->type->size_unpacked)
|
||||||
{
|
{
|
||||||
if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
|
if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -2565,7 +2572,18 @@ static BOOL d3d10_effect_types_match(const struct d3d10_effect_type *t1,
|
||||||
static HRESULT d3d10_effect_validate_shared_variable(const struct d3d10_effect *effect,
|
static HRESULT d3d10_effect_validate_shared_variable(const struct d3d10_effect *effect,
|
||||||
const struct d3d10_effect_variable *v)
|
const struct d3d10_effect_variable *v)
|
||||||
{
|
{
|
||||||
ID3D10EffectVariable *sv = effect->pool->lpVtbl->GetVariableByName(effect->pool, v->name);
|
ID3D10EffectVariable *sv;
|
||||||
|
|
||||||
|
switch (v->type->basetype)
|
||||||
|
{
|
||||||
|
case D3D10_SVT_CBUFFER:
|
||||||
|
case D3D10_SVT_TBUFFER:
|
||||||
|
sv = (ID3D10EffectVariable *)effect->pool->lpVtbl->GetConstantBufferByName(
|
||||||
|
effect->pool, v->name);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sv = effect->pool->lpVtbl->GetVariableByName(effect->pool, v->name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!sv->lpVtbl->IsValid(sv))
|
if (!sv->lpVtbl->IsValid(sv))
|
||||||
{
|
{
|
||||||
|
@ -2632,7 +2650,7 @@ static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD d
|
||||||
l->effect = e;
|
l->effect = e;
|
||||||
l->buffer = &null_local_buffer;
|
l->buffer = &null_local_buffer;
|
||||||
|
|
||||||
if (FAILED(hr = parse_fx10_local_buffer(data, data_size, &ptr, l)))
|
if (FAILED(hr = parse_fx10_buffer(data, data_size, &ptr, TRUE, l)))
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2648,6 +2666,23 @@ static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD d
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < e->shared_buffer_count; ++i)
|
||||||
|
{
|
||||||
|
struct d3d10_effect_variable b = { 0 };
|
||||||
|
|
||||||
|
b.effect = e;
|
||||||
|
|
||||||
|
if (FAILED(hr = parse_fx10_buffer(data, data_size, &ptr, FALSE, &b)))
|
||||||
|
{
|
||||||
|
d3d10_effect_variable_destroy(&b);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = d3d10_effect_validate_shared_variable(e, &b);
|
||||||
|
d3d10_effect_variable_destroy(&b);
|
||||||
|
if (FAILED(hr)) return hr;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < e->shared_object_count; ++i)
|
for (i = 0; i < e->shared_object_count; ++i)
|
||||||
{
|
{
|
||||||
struct d3d10_effect_variable o = { 0 };
|
struct d3d10_effect_variable o = { 0 };
|
||||||
|
@ -2703,8 +2738,8 @@ static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_s
|
||||||
read_dword(&ptr, &e->local_variable_count);
|
read_dword(&ptr, &e->local_variable_count);
|
||||||
TRACE("Object count: %u\n", e->local_variable_count);
|
TRACE("Object count: %u\n", e->local_variable_count);
|
||||||
|
|
||||||
read_dword(&ptr, &e->sharedbuffers_count);
|
read_dword(&ptr, &e->shared_buffer_count);
|
||||||
TRACE("Pool buffer count: %u\n", e->sharedbuffers_count);
|
TRACE("Pool buffer count: %u\n", e->shared_buffer_count);
|
||||||
|
|
||||||
read_dword(&ptr, &unused);
|
read_dword(&ptr, &unused);
|
||||||
TRACE("Pool variable count: %u\n", unused);
|
TRACE("Pool variable count: %u\n", unused);
|
||||||
|
@ -2748,7 +2783,7 @@ static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_s
|
||||||
read_dword(&ptr, &e->anonymous_shader_count);
|
read_dword(&ptr, &e->anonymous_shader_count);
|
||||||
TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
|
TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
|
||||||
|
|
||||||
if (!e->pool && e->shared_object_count)
|
if (!e->pool && (e->shared_object_count || e->shared_buffer_count))
|
||||||
{
|
{
|
||||||
WARN("Effect requires a pool to load.\n");
|
WARN("Effect requires a pool to load.\n");
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
|
@ -6330,6 +6330,12 @@ cbuffer l_cb
|
||||||
float f0 : COLOR0;
|
float f0 : COLOR0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
shared cbuffer s_cb
|
||||||
|
{
|
||||||
|
float f1 : COLOR0;
|
||||||
|
float f2 : COLOR1;
|
||||||
|
};
|
||||||
|
|
||||||
cbuffer l_cb2
|
cbuffer l_cb2
|
||||||
{
|
{
|
||||||
float f3;
|
float f3;
|
||||||
|
@ -6351,25 +6357,27 @@ technique10 tech_child
|
||||||
#endif
|
#endif
|
||||||
static DWORD fx_test_pool_child[] =
|
static DWORD fx_test_pool_child[] =
|
||||||
{
|
{
|
||||||
0x43425844, 0x22800afa, 0xe318151b, 0xcb3e7d52, 0x186ecbe3, 0x00000001, 0x00000249, 0x00000001,
|
0x43425844, 0xa11d7cb2, 0x41f20697, 0x14a62983, 0x43b9f39c, 0x00000001, 0x0000029f, 0x00000001,
|
||||||
0x00000024, 0x30315846, 0x0000021d, 0xfeff1001, 0x00000002, 0x00000002, 0x00000000, 0x00000000,
|
0x00000024, 0x30315846, 0x00000273, 0xfeff1001, 0x00000002, 0x00000002, 0x00000000, 0x00000001,
|
||||||
0x00000000, 0x00000003, 0x00000001, 0x000000f1, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
0x00000002, 0x00000003, 0x00000001, 0x00000103, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x62635f6c,
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x62635f6c,
|
||||||
0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000,
|
0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000,
|
||||||
0x66000009, 0x4f430030, 0x30524f4c, 0x635f6c00, 0x66003262, 0x6c420033, 0x53646e65, 0x65746174,
|
0x66000009, 0x4f430030, 0x30524f4c, 0x635f6c00, 0x66003262, 0x5f730033, 0x66006263, 0x32660031,
|
||||||
0x00003e00, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000200, 0x625f7300,
|
0x4c4f4300, 0x0031524f, 0x6e656c42, 0x61745364, 0x50006574, 0x02000000, 0x00000000, 0x00000000,
|
||||||
0x646e656c, 0x74617473, 0x65740065, 0x72757478, 0x00720065, 0x00020000, 0x00000000, 0x00000000,
|
0x00000000, 0x00000000, 0x02000000, 0x73000000, 0x656c625f, 0x7473646e, 0x00657461, 0x74786574,
|
||||||
0x00000000, 0x00000000, 0x00090000, 0x5f730000, 0x74786574, 0x00657275, 0x65786950, 0x6168536c,
|
0x00657275, 0x00000084, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000009,
|
||||||
0x00726564, 0x000000a0, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000005,
|
0x65745f73, 0x72757478, 0x69500065, 0x536c6578, 0x65646168, 0x00b20072, 0x00020000, 0x00000000,
|
||||||
0x74007370, 0x5f686365, 0x6c696863, 0x30500064, 0x00000100, 0x00000200, 0x00000000, 0x00000100,
|
0x00000000, 0x00000000, 0x00000000, 0x00050000, 0x73700000, 0x63657400, 0x68635f68, 0x00646c69,
|
||||||
0x00000200, 0x00000000, 0x00000400, 0x00001000, 0x00000000, 0x00000100, 0xffffff00, 0x000000ff,
|
0x01003050, 0x02000000, 0x00000000, 0x01000000, 0x02000000, 0x00000000, 0x04000000, 0x10000000,
|
||||||
0x00002b00, 0x00000f00, 0x00002e00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003500,
|
0x00000000, 0x01000000, 0xff000000, 0x00ffffff, 0x2b000000, 0x0f000000, 0x2e000000, 0x00000000,
|
||||||
0x00001000, 0x00000000, 0x00000100, 0xffffff00, 0x000000ff, 0x00003b00, 0x00000f00, 0x00000000,
|
0x00000000, 0x00000000, 0x00000000, 0x35000000, 0x10000000, 0x00000000, 0x01000000, 0xff000000,
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00006500, 0x00004900, 0x00000000, 0xffffff00,
|
0x00ffffff, 0x3b000000, 0x0f000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
0x000096ff, 0x00007a00, 0x00000000, 0xffffff00, 0x0000c8ff, 0x0000ac00, 0x00000000, 0xffffff00,
|
0x3e000000, 0x10000000, 0x00000000, 0x02000000, 0xff000000, 0x43ffffff, 0x0f000000, 0x2e000000,
|
||||||
0x0000cbff, 0x00000100, 0x00000000, 0x0000d600, 0x00000300, 0x00000000, 0x00000700, 0x00000000,
|
0x00000000, 0x00000000, 0x00000000, 0x46000000, 0x0f000000, 0x49000000, 0x04000000, 0x00000000,
|
||||||
0x00000200, 0x0000c800, 0x00000600, 0x00000000, 0x00000100, 0x0000d900, 0x00000800, 0x00000000,
|
0x00000000, 0x77000000, 0x5b000000, 0x00000000, 0xff000000, 0xa8ffffff, 0x8c000000, 0x00000000,
|
||||||
0x00000100, 0x0000e500, 0x00000000,
|
0xff000000, 0xdaffffff, 0xbe000000, 0x00000000, 0xff000000, 0xddffffff, 0x01000000, 0x00000000,
|
||||||
|
0xe8000000, 0x03000000, 0x00000000, 0x07000000, 0x00000000, 0x02000000, 0xda000000, 0x06000000,
|
||||||
|
0x00000000, 0x01000000, 0xeb000000, 0x08000000, 0x00000000, 0x01000000, 0xf7000000, 0x00000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_effect_pool(void)
|
static void test_effect_pool(void)
|
||||||
|
|
Loading…
Reference in New Issue