d3d10/effect: Parse through value expressions.

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-11-19 17:52:45 +03:00 committed by Alexandre Julliard
parent 58c8cafb10
commit 0f95263086
3 changed files with 114 additions and 0 deletions

View file

@ -52,6 +52,7 @@ enum d3d10_effect_object_operation
D3D10_EOO_CONST_INDEX = 3,
D3D10_EOO_VAR_INDEX = 4,
D3D10_EOO_INDEX_EXPRESSION = 5,
D3D10_EOO_VALUE_EXPRESSION = 6,
D3D10_EOO_ANONYMOUS_SHADER = 7,
};

View file

@ -289,6 +289,10 @@ struct d3d10_effect_prop_dependency
struct d3d10_effect_variable *v;
struct d3d10_effect_preshader index;
} index_expr;
struct
{
struct d3d10_effect_preshader value;
} value_expr;
};
};
@ -392,6 +396,9 @@ static void d3d10_effect_clear_prop_dependencies(struct d3d10_effect_prop_depend
case D3D10_EOO_INDEX_EXPRESSION:
d3d10_effect_preshader_clear(&dep->index_expr.index);
break;
case D3D10_EOO_VALUE_EXPRESSION:
d3d10_effect_preshader_clear(&dep->value_expr.value);
break;
}
}
heap_free(d->entries);
@ -2632,6 +2639,34 @@ static HRESULT parse_fx10_property_assignment(const char *data, size_t data_size
return d3d10_effect_add_prop_dependency(d, &dep);
case D3D10_EOO_VALUE_EXPRESSION:
if (value_offset >= data_size || !require_space(value_offset, 1, sizeof(uint32_t), data_size))
{
WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size);
return E_FAIL;
}
data_ptr = data + value_offset;
read_dword(&data_ptr, &blob_size);
if (!require_space(value_offset, 1, sizeof(uint32_t) + blob_size, data_size))
{
WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size);
return E_FAIL;
}
dep.id = id;
dep.idx = idx;
dep.operation = operation;
if (FAILED(hr = parse_fx10_preshader(data_ptr, blob_size, effect, &dep.value_expr.value)))
{
WARN("Failed to parse preshader, hr %#x.\n", hr);
return hr;
}
return d3d10_effect_add_prop_dependency(d, &dep);
case D3D10_EOO_ANONYMOUS_SHADER:
/* Anonymous shader */

View file

@ -7947,6 +7947,83 @@ static void test_effect_index_expression(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
#if 0
float4 g_var;
float4 g_var2;
technique10 tech
{
pass p0
{
SetBlendState( NULL, g_var + 0.1f + g_var2, 0 );
}
pass p1
{
SetBlendState( NULL, g_var.x + g_var2 + g_var.y, 0 );
}
}
#endif
static DWORD fx_test_value_expression[] =
{
0x43425844, 0xe517f17c, 0xe44eaede, 0xe4fd1240, 0xc67d5084, 0x00000001, 0x0000047c, 0x00000001,
0x00000024, 0x30315846, 0x00000450, 0xfeff1001, 0x00000001, 0x00000002, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000330, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x6f6c4724,
0x736c6162, 0x6f6c6600, 0x00347461, 0x0000000d, 0x00000001, 0x00000000, 0x00000010, 0x00000010,
0x00000010, 0x0000210a, 0x61765f67, 0x5f670072, 0x32726176, 0x63657400, 0x30700068, 0x00016000,
0x42584400, 0x312ce543, 0xc3ebc897, 0xea47c0a2, 0x8a710323, 0x000001d2, 0x00016000, 0x00000300,
0x00002c00, 0x0000d400, 0x0000f000, 0x41544300, 0x0000a042, 0x00001c00, 0x00007700, 0x58040000,
0x00000246, 0x00001c00, 0x00010000, 0x00007400, 0x00004400, 0x00000200, 0x00000100, 0x00004c00,
0x00000000, 0x00005c00, 0x01000200, 0x00000100, 0x00006400, 0x00000000, 0x765f6700, 0xab007261,
0x030001ab, 0x04000100, 0x00000100, 0x00000000, 0x765f6700, 0x00327261, 0x030001ab, 0x04000100,
0x00000100, 0x00000000, 0x00787400, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53,
0x65646168, 0x6f432072, 0x6c69706d, 0x31207265, 0x00312e30, 0x494c43ab, 0x00001434, 0x00000400,
0xcccccd00, 0x0000003d, 0x00000000, 0x00000000, 0x4c584600, 0x00006843, 0x00000200, 0x40000400,
0x00000220, 0x00000000, 0x00000200, 0x00000000, 0x00000000, 0x00000200, 0x00000400, 0x00000000,
0x00000700, 0x00000000, 0x40000400, 0x000002a0, 0x00000000, 0x00000100, 0x00000000, 0x00000000,
0x00000700, 0x00000000, 0x00000000, 0x00000400, 0x00000000, 0xf0f0f000, 0x0f0f0ff0, 0x00ffff0f,
0x00000100, 0x00000200, 0x00000000, 0x00000100, 0x00000200, 0x00000000, 0x00317000, 0x00000150,
0x43425844, 0xc6a29e4c, 0x6292ed35, 0xd90bb8cb, 0x50dcd25f, 0x00000001, 0x00000150, 0x00000003,
0x0000002c, 0x000000d4, 0x000000e0, 0x42415443, 0x000000a0, 0x0000001c, 0x00000077, 0x46580400,
0x00000002, 0x0000001c, 0x00000100, 0x00000074, 0x00000044, 0x00000002, 0x00000001, 0x0000004c,
0x00000000, 0x0000005c, 0x00010002, 0x00000001, 0x00000064, 0x00000000, 0x61765f67, 0xabab0072,
0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x61765f67, 0xab003272, 0x00030001, 0x00040001,
0x00000001, 0x00000000, 0x4d007874, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x34494c43, 0x00000004, 0x00000000,
0x434c5846, 0x00000068, 0x00000002, 0xa0400004, 0x00000002, 0x00000000, 0x00000002, 0x00000000,
0x00000000, 0x00000002, 0x00000004, 0x00000000, 0x00000007, 0x00000000, 0xa0400004, 0x00000002,
0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000004,
0x00000000, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff, 0x00000001, 0x00000002, 0x00000000, 0x00000001,
0x00000002, 0x00000000, 0x00000004, 0x00000020, 0x00000000, 0x00000002, 0xffffffff, 0x00000000,
0x00000030, 0x00000014, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000036,
0x00000014, 0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x0000003d, 0x00000002,
0x00000000, 0x00000042, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x00000045,
0x0000000b, 0x00000000, 0x00000001, 0x000001a9, 0x00000002, 0x00000000, 0x00000001, 0x000001b5,
0x000001c1, 0x00000003, 0x00000000, 0x0000000a, 0x00000000, 0x00000006, 0x000001c4, 0x0000000b,
0x00000000, 0x00000001, 0x00000318, 0x00000002, 0x00000000, 0x00000001, 0x00000324,
};
static void test_effect_value_expression(void)
{
ID3D10Effect *effect;
ID3D10Device *device;
ULONG refcount;
HRESULT hr;
if (!(device = create_device()))
{
skip("Failed to create device, skipping tests.\n");
return;
}
hr = create_effect(fx_test_value_expression, 0, device, NULL, &effect);
ok(SUCCEEDED(hr), "Failed to create an effect, hr %#x.\n", hr);
effect->lpVtbl->Release(effect);
refcount = ID3D10Device_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
}
START_TEST(effect)
{
test_effect_constant_buffer_type();
@ -7972,4 +8049,5 @@ START_TEST(effect)
test_effect_raw_value();
test_effect_dynamic_numeric_field();
test_effect_index_expression();
test_effect_value_expression();
}