d3d10/effect: Validate shared object 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
e44e7673b9
commit
3d1e7b0ed8
|
@ -270,7 +270,7 @@ struct d3d10_effect
|
|||
DWORD variable_count;
|
||||
DWORD local_variable_count;
|
||||
DWORD sharedbuffers_count;
|
||||
DWORD sharedobjects_count;
|
||||
DWORD shared_object_count;
|
||||
DWORD technique_count;
|
||||
DWORD index_offset;
|
||||
DWORD texture_count;
|
||||
|
|
|
@ -50,6 +50,7 @@ static inline struct d3d10_effect *impl_from_ID3D10EffectPool(ID3D10EffectPool *
|
|||
}
|
||||
|
||||
static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl;
|
||||
static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v);
|
||||
|
||||
static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl;
|
||||
static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl;
|
||||
|
@ -2096,8 +2097,8 @@ static HRESULT create_state_object(struct d3d10_effect_variable *v)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT parse_fx10_local_variable(const char *data, size_t data_size,
|
||||
const char **ptr, struct d3d10_effect_variable *v)
|
||||
static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
|
||||
const char **ptr, BOOL shared_type_desc, struct d3d10_effect_variable *v)
|
||||
{
|
||||
unsigned int i;
|
||||
HRESULT hr;
|
||||
|
@ -2119,6 +2120,9 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size,
|
|||
read_dword(ptr, &v->explicit_bind_point);
|
||||
TRACE("Variable explicit bind point %#x.\n", v->explicit_bind_point);
|
||||
|
||||
/* Shared variable description contains only type information. */
|
||||
if (shared_type_desc) return S_OK;
|
||||
|
||||
switch (v->type->basetype)
|
||||
{
|
||||
case D3D10_SVT_TEXTURE:
|
||||
|
@ -2534,6 +2538,50 @@ static void d3d10_effect_type_destroy(struct wine_rb_entry *entry, void *context
|
|||
heap_free(t);
|
||||
}
|
||||
|
||||
static BOOL d3d10_effect_types_match(const struct d3d10_effect_type *t1,
|
||||
const struct d3d10_effect_type *t2)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (strcmp(t1->name, t2->name)) return FALSE;
|
||||
if (t1->basetype != t2->basetype) return FALSE;
|
||||
if (t1->type_class != t2->type_class) return FALSE;
|
||||
if (t1->element_count != t2->element_count) return FALSE;
|
||||
if (t1->element_count) return d3d10_effect_types_match(t1->elementtype, t2->elementtype);
|
||||
if (t1->member_count != t2->member_count) return FALSE;
|
||||
if (t1->column_count != t2->column_count) return FALSE;
|
||||
if (t1->row_count != t2->row_count) return FALSE;
|
||||
|
||||
for (i = 0; i < t1->member_count; ++i)
|
||||
{
|
||||
if (strcmp(t1->members[i].name, t2->members[i].name)) return FALSE;
|
||||
if (t1->members[i].buffer_offset != t2->members[i].buffer_offset) return FALSE;
|
||||
if (!d3d10_effect_types_match(t1->members[i].type, t2->members[i].type)) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HRESULT d3d10_effect_validate_shared_variable(const struct d3d10_effect *effect,
|
||||
const struct d3d10_effect_variable *v)
|
||||
{
|
||||
ID3D10EffectVariable *sv = effect->pool->lpVtbl->GetVariableByName(effect->pool, v->name);
|
||||
|
||||
if (!sv->lpVtbl->IsValid(sv))
|
||||
{
|
||||
WARN("Variable %s wasn't found in the pool.\n", debugstr_a(v->name));
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (!d3d10_effect_types_match(impl_from_ID3D10EffectVariable(sv)->type, v->type))
|
||||
{
|
||||
WARN("Variable %s type does not match pool type.\n", debugstr_a(v->name));
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD data_size)
|
||||
{
|
||||
const char *ptr;
|
||||
|
@ -2596,10 +2644,27 @@ static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD d
|
|||
v->ID3D10EffectVariable_iface.lpVtbl = &d3d10_effect_variable_vtbl;
|
||||
v->buffer = &null_local_buffer;
|
||||
|
||||
if (FAILED(hr = parse_fx10_local_variable(data, data_size, &ptr, v)))
|
||||
if (FAILED(hr = parse_fx10_object_variable(data, data_size, &ptr, FALSE, v)))
|
||||
return hr;
|
||||
}
|
||||
|
||||
for (i = 0; i < e->shared_object_count; ++i)
|
||||
{
|
||||
struct d3d10_effect_variable o = { 0 };
|
||||
|
||||
o.effect = e;
|
||||
|
||||
if (FAILED(hr = parse_fx10_object_variable(data, data_size, &ptr, TRUE, &o)))
|
||||
{
|
||||
d3d10_effect_variable_destroy(&o);
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = d3d10_effect_validate_shared_variable(e, &o);
|
||||
d3d10_effect_variable_destroy(&o);
|
||||
if (FAILED(hr)) return hr;
|
||||
}
|
||||
|
||||
for (i = 0; i < e->technique_count; ++i)
|
||||
{
|
||||
struct d3d10_effect_technique *t = &e->techniques[i];
|
||||
|
@ -2644,8 +2709,8 @@ static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_s
|
|||
read_dword(&ptr, &unused);
|
||||
TRACE("Pool variable count: %u\n", unused);
|
||||
|
||||
read_dword(&ptr, &e->sharedobjects_count);
|
||||
TRACE("Pool objects count: %u\n", e->sharedobjects_count);
|
||||
read_dword(&ptr, &e->shared_object_count);
|
||||
TRACE("Pool objects count: %u\n", e->shared_object_count);
|
||||
|
||||
read_dword(&ptr, &e->technique_count);
|
||||
TRACE("Technique count: %u\n", e->technique_count);
|
||||
|
@ -2683,6 +2748,12 @@ static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_s
|
|||
read_dword(&ptr, &e->anonymous_shader_count);
|
||||
TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
|
||||
|
||||
if (!e->pool && e->shared_object_count)
|
||||
{
|
||||
WARN("Effect requires a pool to load.\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return parse_fx10_body(e, ptr, data_size - (ptr - data));
|
||||
}
|
||||
|
||||
|
|
|
@ -6335,11 +6335,15 @@ cbuffer l_cb2
|
|||
float f3;
|
||||
};
|
||||
|
||||
shared BlendState s_blendstate;
|
||||
shared Texture s_texture;
|
||||
shared PixelShader ps;
|
||||
|
||||
technique10 tech_child
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
SetPixelShader(NULL);
|
||||
SetPixelShader(ps);
|
||||
SetVertexShader(NULL);
|
||||
SetGeometryShader(NULL);
|
||||
}
|
||||
|
@ -6347,19 +6351,25 @@ technique10 tech_child
|
|||
#endif
|
||||
static DWORD fx_test_pool_child[] =
|
||||
{
|
||||
0x43425844, 0x5addae59, 0x62b6f327, 0x0ca7b6a5, 0x61338a81, 0x00000001, 0x00000198, 0x00000001,
|
||||
0x00000024, 0x30315846, 0x0000016c, 0xfeff1001, 0x00000002, 0x00000002, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000001, 0x00000070, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x43425844, 0x22800afa, 0xe318151b, 0xcb3e7d52, 0x186ecbe3, 0x00000001, 0x00000249, 0x00000001,
|
||||
0x00000024, 0x30315846, 0x0000021d, 0xfeff1001, 0x00000002, 0x00000002, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000003, 0x00000001, 0x000000f1, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x62635f6c,
|
||||
0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000,
|
||||
0x66000009, 0x4f430030, 0x30524f4c, 0x635f6c00, 0x66003262, 0x65740033, 0x635f6863, 0x646c6968,
|
||||
0x00305000, 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 0x00000001,
|
||||
0x00000002, 0x00000000, 0x00000004, 0x00000010, 0x00000000, 0x00000001, 0xffffffff, 0x00000000,
|
||||
0x0000002b, 0x0000000f, 0x0000002e, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000035,
|
||||
0x00000010, 0x00000000, 0x00000001, 0xffffffff, 0x00000000, 0x0000003b, 0x0000000f, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000003e, 0x00000001, 0x00000000, 0x00000049,
|
||||
0x00000003, 0x00000000, 0x00000007, 0x00000000, 0x00000001, 0x0000004c, 0x00000006, 0x00000000,
|
||||
0x00000001, 0x00000058, 0x00000008, 0x00000000, 0x00000001, 0x00000064,
|
||||
0x66000009, 0x4f430030, 0x30524f4c, 0x635f6c00, 0x66003262, 0x6c420033, 0x53646e65, 0x65746174,
|
||||
0x00003e00, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000200, 0x625f7300,
|
||||
0x646e656c, 0x74617473, 0x65740065, 0x72757478, 0x00720065, 0x00020000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00090000, 0x5f730000, 0x74786574, 0x00657275, 0x65786950, 0x6168536c,
|
||||
0x00726564, 0x000000a0, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000005,
|
||||
0x74007370, 0x5f686365, 0x6c696863, 0x30500064, 0x00000100, 0x00000200, 0x00000000, 0x00000100,
|
||||
0x00000200, 0x00000000, 0x00000400, 0x00001000, 0x00000000, 0x00000100, 0xffffff00, 0x000000ff,
|
||||
0x00002b00, 0x00000f00, 0x00002e00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003500,
|
||||
0x00001000, 0x00000000, 0x00000100, 0xffffff00, 0x000000ff, 0x00003b00, 0x00000f00, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00006500, 0x00004900, 0x00000000, 0xffffff00,
|
||||
0x000096ff, 0x00007a00, 0x00000000, 0xffffff00, 0x0000c8ff, 0x0000ac00, 0x00000000, 0xffffff00,
|
||||
0x0000cbff, 0x00000100, 0x00000000, 0x0000d600, 0x00000300, 0x00000000, 0x00000700, 0x00000000,
|
||||
0x00000200, 0x0000c800, 0x00000600, 0x00000000, 0x00000100, 0x0000d900, 0x00000800, 0x00000000,
|
||||
0x00000100, 0x0000e500, 0x00000000,
|
||||
};
|
||||
|
||||
static void test_effect_pool(void)
|
||||
|
|
Loading…
Reference in New Issue