mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
tests/hlsl: Test SM6.6 dynamic resources.
This commit is contained in:
committed by
Henri Verbeet
parent
d380bc196f
commit
f47f712164
Notes:
Henri Verbeet
2025-11-24 19:12:37 +01:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1812
@@ -123,3 +123,138 @@ u[2:3], space 0, uav 1
|
|||||||
[test]
|
[test]
|
||||||
todo(msl) draw quad
|
todo(msl) draw quad
|
||||||
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
|
% Test SM 6.6 dynamic resources on SRVs
|
||||||
|
[require]
|
||||||
|
shader model >= 6.6
|
||||||
|
descriptors
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
uniform uint idx;
|
||||||
|
|
||||||
|
float4 main() : SV_Target
|
||||||
|
{
|
||||||
|
Texture2D<float> t = ResourceDescriptorHeap[idx];
|
||||||
|
return t.Load(uint3(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 uint 0
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
uniform 0 uint 1
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
uniform 0 uint 2
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
t[1:3], space 0, srv 0
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 uint 0
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
uniform 0 uint 1
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
uniform 0 uint 2
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
t[1:2], space 0, srv 1
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 uint 0
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
uniform 0 uint 1
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
t[1:3], space 0, srv 0
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
float4 main(float4 pos : SV_Position) : SV_Target
|
||||||
|
{
|
||||||
|
uint idx = floor(pos.x);
|
||||||
|
idx %= 3;
|
||||||
|
Texture2D<float> t = ResourceDescriptorHeap[NonUniformResourceIndex(idx)];
|
||||||
|
return t.Load(uint3(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
probe (1, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
probe (2, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
% Test SM 6.6 dynamic resources on UAVs
|
||||||
|
[pixel shader]
|
||||||
|
uniform uint idx;
|
||||||
|
|
||||||
|
float4 main() : SV_Target
|
||||||
|
{
|
||||||
|
RWTexture2D<float> u = ResourceDescriptorHeap[idx];
|
||||||
|
return u[uint2(0, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 uint 3
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
uniform 0 uint 4
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
uniform 0 uint 5
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
u[1:3], space 0, uav 1
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 uint 0
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
uniform 0 uint 1
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
uniform 0 uint 2
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
u[1:2], space 0, uav 2
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 uint 0
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
uniform 0 uint 1
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|
||||||
|
[descriptors]
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
float4 main(float4 pos : SV_Position) : SV_Target
|
||||||
|
{
|
||||||
|
uint idx = floor(pos.x);
|
||||||
|
idx %= 3;
|
||||||
|
RWTexture2D<float> u = ResourceDescriptorHeap[NonUniformResourceIndex(idx + 3)];
|
||||||
|
return u[uint2(0, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
todo draw quad
|
||||||
|
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
|
||||||
|
probe (1, 0) f32(2.0, 2.0, 2.0, 2.0)
|
||||||
|
probe (2, 0) f32(3.0, 3.0, 3.0, 3.0)
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ static const char *const sm_strings_dot[] =
|
|||||||
[SHADER_MODEL_5_1] = "5.1",
|
[SHADER_MODEL_5_1] = "5.1",
|
||||||
[SHADER_MODEL_6_0] = "6.0",
|
[SHADER_MODEL_6_0] = "6.0",
|
||||||
[SHADER_MODEL_6_2] = "6.2",
|
[SHADER_MODEL_6_2] = "6.2",
|
||||||
|
[SHADER_MODEL_6_6] = "6.6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const sm_strings_underscore[] =
|
static const char *const sm_strings_underscore[] =
|
||||||
@@ -95,6 +96,7 @@ static const char *const sm_strings_underscore[] =
|
|||||||
[SHADER_MODEL_5_1] = "5_1",
|
[SHADER_MODEL_5_1] = "5_1",
|
||||||
[SHADER_MODEL_6_0] = "6_0",
|
[SHADER_MODEL_6_0] = "6_0",
|
||||||
[SHADER_MODEL_6_2] = "6_2",
|
[SHADER_MODEL_6_2] = "6_2",
|
||||||
|
[SHADER_MODEL_6_6] = "6_6",
|
||||||
};
|
};
|
||||||
|
|
||||||
void fatal_error(const char *format, ...)
|
void fatal_error(const char *format, ...)
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ enum shader_model
|
|||||||
SHADER_MODEL_5_1,
|
SHADER_MODEL_5_1,
|
||||||
SHADER_MODEL_6_0,
|
SHADER_MODEL_6_0,
|
||||||
SHADER_MODEL_6_2,
|
SHADER_MODEL_6_2,
|
||||||
SHADER_MODEL_MAX = SHADER_MODEL_6_2,
|
SHADER_MODEL_6_6,
|
||||||
|
SHADER_MODEL_MAX = SHADER_MODEL_6_6,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum shader_type
|
enum shader_type
|
||||||
|
|||||||
@@ -276,6 +276,9 @@ static ID3D12RootSignature *d3d12_runner_create_root_signature(struct d3d12_shad
|
|||||||
root_signature_desc.pStaticSamplers = static_samplers;
|
root_signature_desc.pStaticSamplers = static_samplers;
|
||||||
root_signature_desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
|
root_signature_desc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
|
||||||
|
|
||||||
|
if (runner->r.minimum_shader_model >= SHADER_MODEL_6_6)
|
||||||
|
root_signature_desc.Flags |= D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED;
|
||||||
|
|
||||||
/* Native d3d12 doesn't like an empty root descriptor table. */
|
/* Native d3d12 doesn't like an empty root descriptor table. */
|
||||||
if (runner->r.descriptor_count)
|
if (runner->r.descriptor_count)
|
||||||
{
|
{
|
||||||
@@ -477,8 +480,9 @@ static bool d3d12_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, root_signature);
|
/* With dynamic resources descriptor heaps must be set before the root signature. */
|
||||||
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &runner->heap);
|
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &runner->heap);
|
||||||
|
ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, root_signature);
|
||||||
if (runner->r.uniform_count)
|
if (runner->r.uniform_count)
|
||||||
ID3D12GraphicsCommandList_SetComputeRoot32BitConstants(command_list, uniform_index,
|
ID3D12GraphicsCommandList_SetComputeRoot32BitConstants(command_list, uniform_index,
|
||||||
runner->r.uniform_count, runner->r.uniforms, 0);
|
runner->r.uniform_count, runner->r.uniforms, 0);
|
||||||
@@ -902,11 +906,13 @@ static bool d3d12_runner_draw(struct shader_runner *r, D3D_PRIMITIVE_TOPOLOGY pr
|
|||||||
|
|
||||||
fb_width = ~0u;
|
fb_width = ~0u;
|
||||||
fb_height = ~0u;
|
fb_height = ~0u;
|
||||||
|
|
||||||
|
/* With dynamic resources descriptor heaps must be set before the root signature. */
|
||||||
|
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &runner->heap);
|
||||||
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, test_context->root_signature);
|
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, test_context->root_signature);
|
||||||
if (runner->r.uniform_count)
|
if (runner->r.uniform_count)
|
||||||
ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, uniform_index,
|
ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, uniform_index,
|
||||||
runner->r.uniform_count, runner->r.uniforms, 0);
|
runner->r.uniform_count, runner->r.uniforms, 0);
|
||||||
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &runner->heap);
|
|
||||||
for (i = 0; i < runner->r.resource_count; ++i)
|
for (i = 0; i < runner->r.resource_count; ++i)
|
||||||
{
|
{
|
||||||
struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]);
|
struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]);
|
||||||
@@ -1176,14 +1182,37 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner,
|
|||||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS);
|
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool device_supports_shader_model_6_0(ID3D12Device *device)
|
static enum shader_model get_supported_shader_model(ID3D12Device *device)
|
||||||
{
|
{
|
||||||
D3D12_FEATURE_DATA_SHADER_MODEL sm = {D3D_SHADER_MODEL_6_0};
|
D3D12_FEATURE_DATA_SHADER_MODEL sm_feature;
|
||||||
|
D3D_SHADER_MODEL sm;
|
||||||
|
unsigned int i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_SHADER_MODEL, &sm, sizeof(sm));
|
static const D3D_SHADER_MODEL d3d_shader_models[] =
|
||||||
ok(hr == S_OK, "Failed to check feature shader model support, hr %#x.\n", hr);
|
{
|
||||||
return sm.HighestShaderModel >= D3D_SHADER_MODEL_6_0;
|
[SHADER_MODEL_5_1] = D3D_SHADER_MODEL_5_1,
|
||||||
|
[SHADER_MODEL_6_0] = D3D_SHADER_MODEL_6_0,
|
||||||
|
[SHADER_MODEL_6_2] = D3D_SHADER_MODEL_6_2,
|
||||||
|
[SHADER_MODEL_6_6] = D3D_SHADER_MODEL_6_6,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = ARRAY_SIZE(d3d_shader_models) - 1; i != UINT_MAX; --i)
|
||||||
|
{
|
||||||
|
if (!(sm = d3d_shader_models[i]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sm_feature.HighestShaderModel = sm;
|
||||||
|
|
||||||
|
hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_SHADER_MODEL, &sm_feature, sizeof(sm_feature));
|
||||||
|
/* Might return E_INVALIDARG is the runtime doesn't know about modern SMs. */
|
||||||
|
ok(hr == S_OK || hr == E_INVALIDARG, "Failed to check feature shader model support, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
if (hr == S_OK && sm_feature.HighestShaderModel >= sm)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
fatal_error("Maximum shader model is smaller than 5.1.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_shader_tests_for_model_range(void *dxc_compiler,
|
static void run_shader_tests_for_model_range(void *dxc_compiler,
|
||||||
@@ -1204,7 +1233,9 @@ static void run_shader_tests_for_model_range(void *dxc_compiler,
|
|||||||
return;
|
return;
|
||||||
device = runner.test_context.device;
|
device = runner.test_context.device;
|
||||||
|
|
||||||
if (minimum_shader_model >= SHADER_MODEL_6_0 && !device_supports_shader_model_6_0(device))
|
maximum_shader_model = min(maximum_shader_model, get_supported_shader_model(device));
|
||||||
|
|
||||||
|
if (minimum_shader_model >= SHADER_MODEL_6_0 && maximum_shader_model < SHADER_MODEL_6_0)
|
||||||
{
|
{
|
||||||
skip("The device does not support shader model 6.0.\n");
|
skip("The device does not support shader model 6.0.\n");
|
||||||
destroy_test_context(&runner.test_context);
|
destroy_test_context(&runner.test_context);
|
||||||
|
|||||||
Reference in New Issue
Block a user