d3d10/effect: Handle static variable assignments for object fields in state objects.

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:
Nikolay Sivov 2021-10-08 08:13:33 +03:00 committed by Alexandre Julliard
parent ab5b335c13
commit e37f781cc2
2 changed files with 182 additions and 41 deletions

View File

@ -1669,13 +1669,59 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset,
return TRUE;
}
static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info)
{
switch (property_info->type)
{
case D3D10_SVT_RASTERIZER:
case D3D10_SVT_DEPTHSTENCIL:
case D3D10_SVT_BLEND:
case D3D10_SVT_RENDERTARGETVIEW:
case D3D10_SVT_DEPTHSTENCILVIEW:
case D3D10_SVT_VERTEXSHADER:
case D3D10_SVT_PIXELSHADER:
case D3D10_SVT_GEOMETRYSHADER:
case D3D10_SVT_TEXTURE:
return TRUE;
default:
return FALSE;
}
}
static BOOL is_object_property_type_matching(const struct d3d10_effect_state_property_info *property_info,
const struct d3d10_effect_variable *v)
{
if (property_info->type == v->type->basetype) return TRUE;
switch (v->type->basetype)
{
case D3D10_SVT_TEXTURE1D:
case D3D10_SVT_TEXTURE1DARRAY:
case D3D10_SVT_TEXTURE2D:
case D3D10_SVT_TEXTURE2DARRAY:
case D3D10_SVT_TEXTURE2DMS:
case D3D10_SVT_TEXTURE2DMSARRAY:
case D3D10_SVT_TEXTURE3D:
case D3D10_SVT_TEXTURECUBE:
if (property_info->type == D3D10_SVT_TEXTURE) return TRUE;
/* fallthrough */
default:
return FALSE;
}
}
static BOOL parse_fx10_state_group(const char *data, size_t data_size,
const char **ptr, enum d3d10_effect_container_type container_type, void *container)
const char **ptr, enum d3d10_effect_container_type container_type,
struct d3d10_effect *effect, void *container)
{
const struct d3d10_effect_state_property_info *property_info;
struct d3d10_effect_variable *variable;
UINT value_offset, operation;
const char *name;
size_t name_len;
unsigned int i;
DWORD count;
void *dst;
UINT idx;
UINT id;
@ -1710,19 +1756,62 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size,
return FALSE;
}
dst = (char *)container + property_info->offset;
switch (operation)
{
case D3D10_EOO_CONST:
/* Constant values output directly to backing store. */
if (!read_value_list(data, data_size, value_offset, property_info->type, idx,
property_info->size, (char *)container + property_info->offset))
property_info->size, dst))
{
ERR("Failed to read values for property %#x.\n", id);
return FALSE;
}
break;
case D3D10_EOO_VAR:
/* Variable. */
if (!fx10_get_string(data, data_size, value_offset, &name, &name_len))
{
WARN("Failed to get variable name.\n");
return E_FAIL;
}
TRACE("Variable name %s.\n", debugstr_a(name));
if (!(variable = d3d10_effect_get_variable_by_name(effect, name)))
{
WARN("Couldn't find variable %s.\n", debugstr_a(name));
return FALSE;
}
if (is_object_property(property_info))
{
if (variable->type->element_count)
{
WARN("Unexpected array variable value %s.\n", debugstr_a(name));
return FALSE;
}
if (!is_object_property_type_matching(property_info, variable))
{
WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
variable->type->basetype, property_info->type);
return FALSE;
}
*(void **)dst = variable;
}
else
{
FIXME("Assigning variables to numeric fields is not supported.\n");
return FALSE;
}
break;
default:
FIXME("Unhandled operation %#x.\n", operation);
return E_FAIL;
@ -2329,7 +2418,7 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size);
if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var),
&var->u.state.desc))
var->effect, &var->u.state.desc))
{
ERR("Failed to read property list.\n");
return E_FAIL;

View File

@ -4126,6 +4126,26 @@ SamplerState sampler0
Texture = NULL; /* 0x37 */
};
Texture t0;
Texture1D t1;
Texture1DArray t1a;
Texture2D t2;
Texture2DArray t2a;
Texture2DMS<float4, 4> t2dms;
Texture2DMSArray <float4, 4> t2dmsa;
Texture3D t3;
TextureCube tq;
SamplerState sampler1 { Texture = t0; };
SamplerState sampler2 { Texture = t1; };
SamplerState sampler2a { Texture = t1a; };
SamplerState sampler3 { Texture = t2; };
SamplerState sampler3a { Texture = t2a; };
SamplerState sampler4 { Texture = t2dms; };
SamplerState sampler4a { Texture = t2dmsa; };
SamplerState sampler5 { Texture = t3; };
SamplerState sampler6 { Texture = tq; };
technique10 tech0
{
pass pass0
@ -4138,10 +4158,10 @@ technique10 tech0
#endif
static DWORD fx_test_state_groups[] =
{
0x43425844, 0xf231bc81, 0x3edcd6f4, 0x932fe6e0, 0x86fbdec1, 0x00000001, 0x0000078f, 0x00000001,
0x00000024, 0x30315846, 0x00000763, 0xfeff1001, 0x00000000, 0x00000000, 0x00000004, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x0000035f, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x74736152,
0x43425844, 0x6465b74f, 0x34238546, 0x33c65cd8, 0xec32db01, 0x00000001, 0x00000b8c, 0x00000001,
0x00000024, 0x30315846, 0x00000b60, 0xfeff1001, 0x00000000, 0x00000000, 0x00000016, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000540, 0x00000000, 0x00000009, 0x00000001, 0x00000001,
0x00000001, 0x0000000a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x74736152,
0x7a697265, 0x74537265, 0x00657461, 0x00000004, 0x00000002, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000004, 0x74736172, 0x6174735f, 0x01006574, 0x02000000, 0x02000000, 0x01000000,
0x02000000, 0x02000000, 0x01000000, 0x04000000, 0x01000000, 0x01000000, 0x02000000, 0xfc000000,
@ -4166,39 +4186,71 @@ static DWORD fx_test_state_groups[] =
0x01000000, 0x02000000, 0xff000000, 0x01ffffff, 0x03000000, 0x04000000, 0x01000000, 0x02000000,
0x08000000, 0x04000000, 0x01000000, 0x00000000, 0x013f8000, 0x00000000, 0x01400000, 0x00000000,
0x01404000, 0x00000000, 0x01408000, 0x03000000, 0x06000000, 0x01000000, 0x03000000, 0x05000000,
0x01000000, 0x02000000, 0x00000000, 0x74000000, 0x30686365, 0x73617000, 0x04003073, 0x01000000,
0x00000000, 0x013f0000, 0x9a000000, 0x013f1999, 0x33000000, 0x013f3333, 0xcd000000, 0x013f4ccc,
0x03000000, 0xff000000, 0x010000ff, 0x01000000, 0x00000000, 0x303f8000, 0x14000000, 0x00000000,
0xff000000, 0x0affffff, 0x0c000000, 0x00000000, 0x01000000, 0x3b000000, 0x0d000000, 0x00000000,
0x01000000, 0x47000000, 0x0e000000, 0x00000000, 0x01000000, 0x53000000, 0x0f000000, 0x00000000,
0x01000000, 0x5f000000, 0x10000000, 0x00000000, 0x01000000, 0x6b000000, 0x11000000, 0x00000000,
0x01000000, 0x77000000, 0x12000000, 0x00000000, 0x01000000, 0x83000000, 0x13000000, 0x00000000,
0x01000000, 0x8f000000, 0x14000000, 0x00000000, 0x01000000, 0x9b000000, 0x15000000, 0x00000000,
0x01000000, 0xa7000000, 0x00000000, 0xe1000000, 0xc5000000, 0x00000000, 0xff000000, 0x0effffff,
0x16000000, 0x00000000, 0x01000000, 0xea000000, 0x17000000, 0x00000000, 0x01000000, 0xf6000000,
0x18000000, 0x00000000, 0x01000000, 0x02000000, 0x19000001, 0x00000000, 0x01000000, 0x0e000000,
0x1a000001, 0x00000000, 0x01000000, 0x1a000000, 0x1b000001, 0x00000000, 0x01000000, 0x26000000,
0x1c000001, 0x00000000, 0x01000000, 0x32000000, 0x1d000001, 0x00000000, 0x01000000, 0x3e000000,
0x1e000001, 0x00000000, 0x01000000, 0x4a000000, 0x1f000001, 0x00000000, 0x01000000, 0x56000000,
0x20000001, 0x00000000, 0x01000000, 0x62000000, 0x21000001, 0x00000000, 0x01000000, 0x6e000000,
0x22000001, 0x00000000, 0x01000000, 0x7a000000, 0x23000001, 0x00000000, 0x01000000, 0x86000000,
0x00000001, 0xb9000000, 0x9d000001, 0x00000001, 0xff000000, 0x0bffffff, 0x24000000, 0x00000000,
0x01000000, 0xc5000000, 0x25000001, 0x00000000, 0x01000000, 0xd1000000, 0x25000001, 0x07000000,
0x01000000, 0xdd000000, 0x26000001, 0x00000000, 0x01000000, 0xe9000000, 0x27000001, 0x00000000,
0x01000000, 0xf5000000, 0x28000001, 0x00000000, 0x01000000, 0x01000000, 0x29000002, 0x00000000,
0x01000000, 0x0d000000, 0x2a000002, 0x00000000, 0x01000000, 0x19000000, 0x2b000002, 0x00000000,
0x01000000, 0x25000000, 0x2c000002, 0x00000000, 0x01000000, 0x31000000, 0x2c000002, 0x07000000,
0x01000000, 0x3d000000, 0x00000002, 0x72000000, 0x56000002, 0x00000002, 0xff000000, 0x0bffffff,
0x2d000000, 0x00000000, 0x01000000, 0x7b000000, 0x2e000002, 0x00000000, 0x01000000, 0x87000000,
0x2f000002, 0x00000000, 0x01000000, 0x93000000, 0x30000002, 0x00000000, 0x01000000, 0x9f000000,
0x31000002, 0x00000000, 0x01000000, 0xab000000, 0x32000002, 0x00000000, 0x01000000, 0xb7000000,
0x33000002, 0x00000000, 0x01000000, 0xc3000000, 0x34000002, 0x00000000, 0x01000000, 0xcf000000,
0x35000002, 0x00000000, 0x01000000, 0xf3000000, 0x36000002, 0x00000000, 0x01000000, 0xff000000,
0x37000002, 0x00000000, 0x01000000, 0x0b000000, 0x00000003, 0x17000000, 0x01000003, 0x00000000,
0x1d000000, 0x06000003, 0x00000000, 0x0a000000, 0x00000000, 0x01000000, 0x23000000, 0x0b000003,
0x00000000, 0x01000000, 0x47000000, 0x02000003, 0x00000000, 0x02000000, 0xb9000000, 0x09000001,
0x00000000, 0x01000000, 0x53000000, 0x01000003, 0x00000000, 0x02000000, 0xe1000000, 0x00000000,
0x00000000, 0x02000000, 0x30000000, 0x00000000,
0x01000000, 0x02000000, 0x00000000, 0x74000000, 0x75747865, 0x17006572, 0x02000003, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x09000000, 0x74000000, 0x65540030, 0x72757478, 0x00443165,
0x0000033e, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000a, 0x54003174,
0x75747865, 0x44316572, 0x61727241, 0x03670079, 0x00020000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x000b0000, 0x31740000, 0x65540061, 0x72757478, 0x00443265, 0x00000396, 0x00000002,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x54003274, 0x75747865, 0x44326572,
0x61727241, 0x03bf0079, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000d0000,
0x32740000, 0x65540061, 0x72757478, 0x4d443265, 0x03ee0053, 0x00020000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x000e0000, 0x32740000, 0x00736d64, 0x74786554, 0x32657275, 0x41534d44,
0x79617272, 0x00041c00, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000f00,
0x64327400, 0x0061736d, 0x74786554, 0x33657275, 0x04500044, 0x00020000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00100000, 0x33740000, 0x78655400, 0x65727574, 0x65627543, 0x00047900,
0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001100, 0x00717400, 0x706d6173,
0x3172656c, 0x6d617300, 0x72656c70, 0x61730032, 0x656c706d, 0x00613272, 0x706d6173, 0x3372656c,
0x6d617300, 0x72656c70, 0x73006133, 0x6c706d61, 0x00347265, 0x706d6173, 0x3472656c, 0x61730061,
0x656c706d, 0x73003572, 0x6c706d61, 0x00367265, 0x68636574, 0x61700030, 0x00307373, 0x00000004,
0x00000001, 0x3f000000, 0x00000001, 0x3f19999a, 0x00000001, 0x3f333333, 0x00000001, 0x3f4ccccd,
0x00000001, 0x00000003, 0x0000ffff, 0x00000001, 0x00000001, 0x3f800000, 0x00000030, 0x00000014,
0x00000000, 0xffffffff, 0x0000000a, 0x0000000c, 0x00000000, 0x00000001, 0x0000003b, 0x0000000d,
0x00000000, 0x00000001, 0x00000047, 0x0000000e, 0x00000000, 0x00000001, 0x00000053, 0x0000000f,
0x00000000, 0x00000001, 0x0000005f, 0x00000010, 0x00000000, 0x00000001, 0x0000006b, 0x00000011,
0x00000000, 0x00000001, 0x00000077, 0x00000012, 0x00000000, 0x00000001, 0x00000083, 0x00000013,
0x00000000, 0x00000001, 0x0000008f, 0x00000014, 0x00000000, 0x00000001, 0x0000009b, 0x00000015,
0x00000000, 0x00000001, 0x000000a7, 0x00000000, 0x000000e1, 0x000000c5, 0x00000000, 0xffffffff,
0x0000000e, 0x00000016, 0x00000000, 0x00000001, 0x000000ea, 0x00000017, 0x00000000, 0x00000001,
0x000000f6, 0x00000018, 0x00000000, 0x00000001, 0x00000102, 0x00000019, 0x00000000, 0x00000001,
0x0000010e, 0x0000001a, 0x00000000, 0x00000001, 0x0000011a, 0x0000001b, 0x00000000, 0x00000001,
0x00000126, 0x0000001c, 0x00000000, 0x00000001, 0x00000132, 0x0000001d, 0x00000000, 0x00000001,
0x0000013e, 0x0000001e, 0x00000000, 0x00000001, 0x0000014a, 0x0000001f, 0x00000000, 0x00000001,
0x00000156, 0x00000020, 0x00000000, 0x00000001, 0x00000162, 0x00000021, 0x00000000, 0x00000001,
0x0000016e, 0x00000022, 0x00000000, 0x00000001, 0x0000017a, 0x00000023, 0x00000000, 0x00000001,
0x00000186, 0x00000000, 0x000001b9, 0x0000019d, 0x00000000, 0xffffffff, 0x0000000b, 0x00000024,
0x00000000, 0x00000001, 0x000001c5, 0x00000025, 0x00000000, 0x00000001, 0x000001d1, 0x00000025,
0x00000007, 0x00000001, 0x000001dd, 0x00000026, 0x00000000, 0x00000001, 0x000001e9, 0x00000027,
0x00000000, 0x00000001, 0x000001f5, 0x00000028, 0x00000000, 0x00000001, 0x00000201, 0x00000029,
0x00000000, 0x00000001, 0x0000020d, 0x0000002a, 0x00000000, 0x00000001, 0x00000219, 0x0000002b,
0x00000000, 0x00000001, 0x00000225, 0x0000002c, 0x00000000, 0x00000001, 0x00000231, 0x0000002c,
0x00000007, 0x00000001, 0x0000023d, 0x00000000, 0x00000272, 0x00000256, 0x00000000, 0xffffffff,
0x0000000b, 0x0000002d, 0x00000000, 0x00000001, 0x0000027b, 0x0000002e, 0x00000000, 0x00000001,
0x00000287, 0x0000002f, 0x00000000, 0x00000001, 0x00000293, 0x00000030, 0x00000000, 0x00000001,
0x0000029f, 0x00000031, 0x00000000, 0x00000001, 0x000002ab, 0x00000032, 0x00000000, 0x00000001,
0x000002b7, 0x00000033, 0x00000000, 0x00000001, 0x000002c3, 0x00000034, 0x00000000, 0x00000001,
0x000002cf, 0x00000035, 0x00000000, 0x00000001, 0x000002f3, 0x00000036, 0x00000000, 0x00000001,
0x000002ff, 0x00000037, 0x00000000, 0x00000001, 0x0000030b, 0x00000000, 0x0000033b, 0x0000031f,
0x00000000, 0xffffffff, 0x00000000, 0x00000364, 0x00000348, 0x00000000, 0xffffffff, 0x00000000,
0x00000392, 0x00000376, 0x00000000, 0xffffffff, 0x00000000, 0x000003bc, 0x000003a0, 0x00000000,
0xffffffff, 0x00000000, 0x000003ea, 0x000003ce, 0x00000000, 0xffffffff, 0x00000000, 0x00000416,
0x000003fa, 0x00000000, 0xffffffff, 0x00000000, 0x00000449, 0x0000042d, 0x00000000, 0xffffffff,
0x00000000, 0x00000476, 0x0000045a, 0x00000000, 0xffffffff, 0x00000000, 0x000004a1, 0x00000485,
0x00000000, 0xffffffff, 0x00000000, 0x000004a4, 0x00000256, 0x00000000, 0xffffffff, 0x00000001,
0x00000037, 0x00000000, 0x00000002, 0x0000033b, 0x00000000, 0x000004ad, 0x00000256, 0x00000000,
0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000364, 0x00000000, 0x000004b6,
0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000392,
0x00000000, 0x000004c0, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000,
0x00000002, 0x000003bc, 0x00000000, 0x000004c9, 0x00000256, 0x00000000, 0xffffffff, 0x00000001,
0x00000037, 0x00000000, 0x00000002, 0x000003ea, 0x00000000, 0x000004d3, 0x00000256, 0x00000000,
0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000416, 0x00000000, 0x000004dc,
0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000449,
0x00000000, 0x000004e6, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000,
0x00000002, 0x00000476, 0x00000000, 0x000004ef, 0x00000256, 0x00000000, 0xffffffff, 0x00000001,
0x00000037, 0x00000000, 0x00000002, 0x000004a1, 0x00000000, 0x000004f8, 0x00000001, 0x00000000,
0x000004fe, 0x00000006, 0x00000000, 0x0000000a, 0x00000000, 0x00000001, 0x00000504, 0x0000000b,
0x00000000, 0x00000001, 0x00000528, 0x00000002, 0x00000000, 0x00000002, 0x000001b9, 0x00000009,
0x00000000, 0x00000001, 0x00000534, 0x00000001, 0x00000000, 0x00000002, 0x000000e1, 0x00000000,
0x00000000, 0x00000002, 0x00000030,
};
static void test_effect_state_groups(void)
@ -4244,7 +4296,7 @@ static void test_effect_state_groups(void)
effect_desc.ConstantBuffers);
ok(effect_desc.SharedConstantBuffers == 0, "Unexpected shared constant buffers count %u.\n",
effect_desc.SharedConstantBuffers);
ok(effect_desc.GlobalVariables == 4, "Unexpected global variables count %u.\n",
ok(effect_desc.GlobalVariables == 22, "Unexpected global variables count %u.\n",
effect_desc.GlobalVariables);
ok(effect_desc.SharedGlobalVariables == 0, "Unexpected shared global variables count %u.\n",
effect_desc.SharedGlobalVariables);