mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
tests: Do not crash if the render target doesn't support MSAA 8.
This currently happens on MoltenVK.
This commit is contained in:
parent
6dfdbb5c26
commit
d640b213b2
Notes:
Alexandre Julliard
2023-09-22 22:47:46 +02:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/354
@ -32402,6 +32402,7 @@ static void test_shader_get_render_target_sample_count(void)
|
||||
struct test_context_desc desc;
|
||||
struct test_context context;
|
||||
ID3D12CommandQueue *queue;
|
||||
struct vec4 sample_count;
|
||||
HRESULT hr;
|
||||
|
||||
static const float black[4];
|
||||
@ -32422,20 +32423,28 @@ static void test_shader_get_render_target_sample_count(void)
|
||||
0x0100003e,
|
||||
};
|
||||
static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
|
||||
static const struct vec4 sample_count = {8.0f, 8.0f, 8.0f, 8.0f};
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
desc.sample_desc.Count = 8;
|
||||
desc.no_pipeline = true;
|
||||
desc.check_multisampling = true;
|
||||
if (!init_test_context(&context, &desc))
|
||||
return;
|
||||
command_list = context.list;
|
||||
queue = context.queue;
|
||||
bug_if(is_mvk_device(context.device))
|
||||
ok(context.render_target_desc.SampleDesc.Count == 8, "Failed to create render target with MSAA 8, got %u.\n",
|
||||
context.render_target_desc.SampleDesc.Count);
|
||||
|
||||
sample_count.x = context.render_target_desc.SampleDesc.Count;
|
||||
sample_count.y = context.render_target_desc.SampleDesc.Count;
|
||||
sample_count.z = context.render_target_desc.SampleDesc.Count;
|
||||
sample_count.w = context.render_target_desc.SampleDesc.Count;
|
||||
|
||||
init_pipeline_state_desc(&pso_desc, context.root_signature,
|
||||
context.render_target_desc.Format, NULL, &ps, NULL);
|
||||
pso_desc.SampleDesc.Count = desc.sample_desc.Count;
|
||||
pso_desc.SampleDesc.Count = context.render_target_desc.SampleDesc.Count;
|
||||
hr = ID3D12Device_CreateGraphicsPipelineState(context.device, &pso_desc,
|
||||
&IID_ID3D12PipelineState, (void **)&context.pipeline_state);
|
||||
ok(hr == S_OK, "Failed to create pipeline, hr %#x.\n", hr);
|
||||
|
@ -934,6 +934,7 @@ struct test_context_desc
|
||||
unsigned int rt_width, rt_height, rt_array_size;
|
||||
DXGI_FORMAT rt_format;
|
||||
DXGI_SAMPLE_DESC sample_desc;
|
||||
bool check_multisampling;
|
||||
unsigned int rt_descriptor_count;
|
||||
unsigned int root_signature_flags;
|
||||
bool no_render_target;
|
||||
@ -965,6 +966,24 @@ struct test_context
|
||||
RECT scissor_rect;
|
||||
};
|
||||
|
||||
#define check_multisample_support(a, b, c) check_multisample_support_(__LINE__, a, b, c)
|
||||
static unsigned int check_multisample_support_(unsigned int line, ID3D12Device *device,
|
||||
DXGI_FORMAT format, unsigned int sample_count)
|
||||
{
|
||||
D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS format_support =
|
||||
{
|
||||
.Format = format,
|
||||
.SampleCount = sample_count,
|
||||
};
|
||||
HRESULT hr;
|
||||
|
||||
hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
|
||||
&format_support, sizeof(format_support));
|
||||
ok_(line)(hr == S_OK, "Cannot check feature support, hr %#x.\n", hr);
|
||||
|
||||
return format_support.NumQualityLevels;
|
||||
}
|
||||
|
||||
#define create_render_target(context, a, b, c) create_render_target_(__LINE__, context, a, b, c)
|
||||
static void create_render_target_(unsigned int line, struct test_context *context,
|
||||
const struct test_context_desc *desc, ID3D12Resource **render_target,
|
||||
@ -994,6 +1013,22 @@ static void create_render_target_(unsigned int line, struct test_context *contex
|
||||
clear_value.Color[1] = 1.0f;
|
||||
clear_value.Color[2] = 1.0f;
|
||||
clear_value.Color[3] = 1.0f;
|
||||
|
||||
if (desc && desc->check_multisampling)
|
||||
{
|
||||
for (; resource_desc.SampleDesc.Count != 1; resource_desc.SampleDesc.Count /= 2)
|
||||
{
|
||||
unsigned int quality_level_count = check_multisample_support_(line, context->device,
|
||||
resource_desc.Format, resource_desc.SampleDesc.Count);
|
||||
|
||||
if (quality_level_count != 0)
|
||||
{
|
||||
resource_desc.SampleDesc.Quality = min(resource_desc.SampleDesc.Quality, quality_level_count - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hr = ID3D12Device_CreateCommittedResource(context->device,
|
||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
|
||||
D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value,
|
||||
|
Loading…
Reference in New Issue
Block a user