vkd3d: Introduce a softer form of assertion.

Triggering an ERR() instead of aborting the program.
This commit is contained in:
Giovanni Mascellani 2024-05-14 10:32:33 +02:00 committed by Henri Verbeet
parent a484063cd2
commit d7fc2693c4
Notes: Henri Verbeet 2024-07-29 13:23:46 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/867
3 changed files with 13 additions and 7 deletions

View File

@ -46,6 +46,12 @@
#define STATIC_ASSERT(e) extern void __VKD3D_STATIC_ASSERT__(int [(e) ? 1 : -1])
#define VKD3D_ASSERT(cond) \
do { \
if (!(cond)) \
ERR("Failed assertion: %s\n", #cond); \
} while (0)
#define MEMBER_SIZE(t, m) sizeof(((t *)0)->m)
#define VKD3D_MAKE_TAG(ch0, ch1, ch2, ch3) \

View File

@ -341,7 +341,7 @@ static unsigned int vkd3d_check_extensions(const VkExtensionProperties *extensio
++extension_count;
}
assert(!optional_user_extension_count || user_extension_supported);
VKD3D_ASSERT(!optional_user_extension_count || user_extension_supported);
for (i = 0; i < optional_user_extension_count; ++i)
{
if (has_extension(extensions, count, optional_user_extensions[i]))
@ -403,7 +403,7 @@ static unsigned int vkd3d_enable_extensions(const char *extensions[],
{
extension_count = vkd3d_append_extension(extensions, extension_count, user_extensions[i]);
}
assert(!optional_user_extension_count || user_extension_supported);
VKD3D_ASSERT(!optional_user_extension_count || user_extension_supported);
for (i = 0; i < optional_user_extension_count; ++i)
{
if (!user_extension_supported[i])
@ -1507,7 +1507,7 @@ static bool d3d12_device_supports_typed_uav_load_additional_formats(const struct
for (i = 0; i < ARRAY_SIZE(additional_formats); ++i)
{
format = vkd3d_get_format(device, additional_formats[i], false);
assert(format);
VKD3D_ASSERT(format);
VK_CALL(vkGetPhysicalDeviceFormatProperties(device->vk_physical_device, format->vk_format, &properties));
if (!((properties.linearTilingFeatures | properties.optimalTilingFeatures) & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
@ -2547,7 +2547,7 @@ static void device_init_descriptor_pool_sizes(struct d3d12_device *device)
return;
}
assert(ARRAY_SIZE(device->vk_pool_sizes) >= 6);
VKD3D_ASSERT(ARRAY_SIZE(device->vk_pool_sizes) >= 6);
pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
pool_sizes[0].descriptorCount = min(limits->uniform_buffer_max_descriptors,
VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE);
@ -5254,7 +5254,7 @@ struct d3d12_device *unsafe_impl_from_ID3D12Device9(ID3D12Device9 *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d12_device_vtbl);
VKD3D_ASSERT(iface->lpVtbl == &d3d12_device_vtbl);
return impl_from_ID3D12Device9(iface);
}

View File

@ -153,7 +153,7 @@ static const D3D12_ROOT_SIGNATURE_DESC * STDMETHODCALLTYPE d3d12_root_signature_
TRACE("iface %p.\n", iface);
assert(deserializer->desc.d3d12.Version == D3D_ROOT_SIGNATURE_VERSION_1_0);
VKD3D_ASSERT(deserializer->desc.d3d12.Version == D3D_ROOT_SIGNATURE_VERSION_1_0);
return &deserializer->desc.d3d12.u.Desc_1_0;
}
@ -354,7 +354,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_versioned_root_signature_deserializer_Get
}
}
assert(deserializer->other_desc.d3d12.Version == version);
VKD3D_ASSERT(deserializer->other_desc.d3d12.Version == version);
*desc = &deserializer->other_desc.d3d12;
return S_OK;
}