mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Add tests for a domain shader using a single patch constant input value.
This specifically tests the case where "count" would end up being one for arrayed builtins in needs_private_io_variable(). Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
db10a63a2e
commit
462bbfaa74
175
tests/d3d12.c
175
tests/d3d12.c
@ -29567,6 +29567,180 @@ static void test_domain_shader_inputs(void)
|
||||
destroy_test_context(&context);
|
||||
}
|
||||
|
||||
static void test_domain_shader_one_patch_constant_input(void)
|
||||
{
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc;
|
||||
ID3D12GraphicsCommandList *command_list;
|
||||
D3D12_STREAM_OUTPUT_BUFFER_VIEW sobv;
|
||||
D3D12_INPUT_LAYOUT_DESC input_layout;
|
||||
struct test_context_desc desc;
|
||||
struct resource_readback rb;
|
||||
struct test_context context;
|
||||
ID3D12Resource *so_buffer;
|
||||
ID3D12CommandQueue *queue;
|
||||
unsigned int x, y;
|
||||
HRESULT hr;
|
||||
|
||||
#if 0
|
||||
struct data
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
};
|
||||
|
||||
data vs_main()
|
||||
{
|
||||
data d;
|
||||
d.position = float4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
return d;
|
||||
}
|
||||
|
||||
struct patch_constant_data
|
||||
{
|
||||
float tess_factor[2] : SV_TessFactor;
|
||||
};
|
||||
|
||||
void patch_constant(OutputPatch<data, 1> control_points,
|
||||
uint prim_id : SV_PrimitiveID,
|
||||
out patch_constant_data output)
|
||||
{
|
||||
output.tess_factor[0] = 2.0f;
|
||||
output.tess_factor[1] = 1.0f;
|
||||
}
|
||||
|
||||
[domain("isoline")]
|
||||
[outputcontrolpoints(1)]
|
||||
[partitioning("integer")]
|
||||
[outputtopology("line")]
|
||||
[patchconstantfunc("patch_constant")]
|
||||
data hs_main(InputPatch<data, 1> input)
|
||||
{
|
||||
return input[0];
|
||||
}
|
||||
|
||||
[domain("isoline")]
|
||||
void ds_main(float tess_factor[2] : SV_TessFactor,
|
||||
const OutputPatch<data, 1> patch,
|
||||
out float4 position : SV_Position)
|
||||
{
|
||||
position = float4(patch[0].position.xyz, tess_factor[1]);
|
||||
}
|
||||
#endif
|
||||
static const DWORD vs_code[] =
|
||||
{
|
||||
0x43425844, 0xcb24c840, 0x8a22891b, 0xcf0dbe1d, 0x7b0a4fdb, 0x00000001, 0x000000b8, 0x00000003,
|
||||
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
|
||||
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
|
||||
0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x58454853, 0x00000040, 0x00010050, 0x00000010,
|
||||
0x0100086a, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x08000036, 0x001020f2, 0x00000000,
|
||||
0x00004002, 0x3f800000, 0x40000000, 0x40400000, 0x40800000, 0x0100003e,
|
||||
};
|
||||
static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)};
|
||||
static const DWORD hs_code[] =
|
||||
{
|
||||
0x43425844, 0x36132cb6, 0x45a8f125, 0x2ff97810, 0xf60e439e, 0x00000001, 0x000001f4, 0x00000004,
|
||||
0x00000030, 0x00000064, 0x00000098, 0x000000e8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
|
||||
0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x505f5653, 0x7469736f,
|
||||
0x006e6f69, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001,
|
||||
0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x47534350, 0x00000048,
|
||||
0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000010, 0x00000003, 0x00000000, 0x00000e01,
|
||||
0x00000038, 0x00000001, 0x0000000f, 0x00000003, 0x00000001, 0x00000e01, 0x545f5653, 0x46737365,
|
||||
0x6f746361, 0xabab0072, 0x58454853, 0x00000104, 0x00030050, 0x00000041, 0x01000071, 0x01000893,
|
||||
0x01000894, 0x01000895, 0x01000896, 0x01001097, 0x0100086a, 0x00001835, 0x0000000a, 0x40000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, 0x01000072,
|
||||
0x0400005f, 0x002010f2, 0x00000001, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x06000036,
|
||||
0x001020f2, 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x02000099,
|
||||
0x00000002, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x00000016, 0x04000067,
|
||||
0x00102012, 0x00000001, 0x00000015, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000000,
|
||||
0x00000002, 0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x07000036, 0x00902012, 0x0010000a,
|
||||
0x00000000, 0x0090900a, 0x0010000a, 0x00000000, 0x0100003e,
|
||||
};
|
||||
static const D3D12_SHADER_BYTECODE hs = {hs_code, sizeof(hs_code)};
|
||||
static const DWORD ds_code[] =
|
||||
{
|
||||
0x43425844, 0x3ac40533, 0x2aa65785, 0x41df1859, 0xb3b2294b, 0x00000001, 0x00000164, 0x00000004,
|
||||
0x00000030, 0x00000064, 0x000000b4, 0x000000e8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
|
||||
0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000070f, 0x505f5653, 0x7469736f,
|
||||
0x006e6f69, 0x47534350, 0x00000048, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000010,
|
||||
0x00000003, 0x00000000, 0x00000001, 0x00000038, 0x00000001, 0x0000000f, 0x00000003, 0x00000001,
|
||||
0x00000101, 0x545f5653, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000002c, 0x00000001,
|
||||
0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653,
|
||||
0x7469736f, 0x006e6f69, 0x58454853, 0x00000074, 0x00040050, 0x0000001d, 0x01000893, 0x01000895,
|
||||
0x0100086a, 0x04000061, 0x0011b012, 0x00000001, 0x00000015, 0x0400005f, 0x00219072, 0x00000001,
|
||||
0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000000,
|
||||
0x00219246, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x0011b00a, 0x00000001,
|
||||
0x0100003e,
|
||||
};
|
||||
static const D3D12_SHADER_BYTECODE ds = {ds_code, sizeof(ds_code)};
|
||||
static const D3D12_SO_DECLARATION_ENTRY so_declaration[] =
|
||||
{
|
||||
{0, "SV_POSITION", 0, 0, 4, 0},
|
||||
};
|
||||
static const float reference[][4] =
|
||||
{
|
||||
{1.0f, 2.0f, 3.0f, 1.0f},
|
||||
{1.0f, 2.0f, 3.0f, 1.0f},
|
||||
{1.0f, 2.0f, 3.0f, 1.0f},
|
||||
{1.0f, 2.0f, 3.0f, 1.0f},
|
||||
};
|
||||
static const unsigned int stride = sizeof(*reference);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.root_signature_flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT
|
||||
| D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT;
|
||||
desc.no_pipeline = true;
|
||||
if (!init_test_context(&context, &desc))
|
||||
return;
|
||||
command_list = context.list;
|
||||
queue = context.queue;
|
||||
|
||||
memset(&input_layout, 0, sizeof(input_layout));
|
||||
|
||||
init_pipeline_state_desc(&pso_desc, context.root_signature, DXGI_FORMAT_UNKNOWN, &vs, NULL, &input_layout);
|
||||
pso_desc.HS = hs;
|
||||
pso_desc.DS = ds;
|
||||
memset(&pso_desc.PS, 0, sizeof(pso_desc.PS));
|
||||
pso_desc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH;
|
||||
pso_desc.StreamOutput.NumEntries = ARRAY_SIZE(so_declaration);
|
||||
pso_desc.StreamOutput.pSODeclaration = so_declaration;
|
||||
pso_desc.StreamOutput.pBufferStrides = &stride;
|
||||
pso_desc.StreamOutput.NumStrides = 1;
|
||||
pso_desc.StreamOutput.RasterizedStream = D3D12_SO_NO_RASTERIZED_STREAM;
|
||||
hr = ID3D12Device_CreateGraphicsPipelineState(context.device, &pso_desc,
|
||||
&IID_ID3D12PipelineState, (void **)&context.pipeline_state);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
so_buffer = create_default_buffer(context.device, 1024,
|
||||
D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_STREAM_OUT);
|
||||
sobv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(so_buffer);
|
||||
sobv.SizeInBytes = 1024;
|
||||
sobv.BufferFilledSizeLocation = sobv.BufferLocation + sobv.SizeInBytes;
|
||||
|
||||
ID3D12GraphicsCommandList_SOSetTargets(command_list, 0, 1, &sobv);
|
||||
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
|
||||
ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
|
||||
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST);
|
||||
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
|
||||
ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
|
||||
ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0);
|
||||
|
||||
transition_resource_state(command_list, so_buffer,
|
||||
D3D12_RESOURCE_STATE_STREAM_OUT, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
get_buffer_readback_with_command_list(so_buffer, DXGI_FORMAT_UNKNOWN, &rb, queue, command_list);
|
||||
for (y = 0; y < ARRAY_SIZE(reference); ++y)
|
||||
{
|
||||
const float *elems = get_readback_data(&rb, y, 0, 0, stride);
|
||||
for (x = 0; x < ARRAY_SIZE(*reference); ++x)
|
||||
{
|
||||
ok(compare_float(reference[y][x], elems[x], 0),
|
||||
"Got unexpected value %.8e for [%u][%u], expected %.8e.\n", elems[x], y, x, reference[y][x]);
|
||||
}
|
||||
}
|
||||
release_resource_readback(&rb);
|
||||
|
||||
ID3D12Resource_Release(so_buffer);
|
||||
destroy_test_context(&context);
|
||||
}
|
||||
|
||||
static void test_render_a8(void)
|
||||
{
|
||||
static const float black[] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
@ -35970,6 +36144,7 @@ START_TEST(d3d12)
|
||||
run_test(test_line_tessellation);
|
||||
run_test(test_tessellation_primitive_id);
|
||||
run_test(test_domain_shader_inputs);
|
||||
run_test(test_domain_shader_one_patch_constant_input);
|
||||
run_test(test_render_a8);
|
||||
run_test(test_cpu_descriptors_lifetime);
|
||||
run_test(test_clip_distance);
|
||||
|
Loading…
Reference in New Issue
Block a user