vkd3d: Replace assert() with VKD3D_ASSERT() in resource.c.

This commit is contained in:
Giovanni Mascellani 2024-07-29 14:42:09 +02:00 committed by Henri Verbeet
parent 150bf69da9
commit 02b898bec0
Notes: Henri Verbeet 2024-07-29 19:19:22 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/967

View File

@ -312,7 +312,7 @@ static ULONG STDMETHODCALLTYPE d3d12_heap_AddRef(ID3D12Heap *iface)
TRACE("%p increasing refcount to %u.\n", heap, refcount); TRACE("%p increasing refcount to %u.\n", heap, refcount);
assert(!heap->is_private); VKD3D_ASSERT(!heap->is_private);
return refcount; return refcount;
} }
@ -443,7 +443,7 @@ struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface)
{ {
if (!iface) if (!iface)
return NULL; return NULL;
assert(iface->lpVtbl == &d3d12_heap_vtbl); VKD3D_ASSERT(iface->lpVtbl == &d3d12_heap_vtbl);
return impl_from_ID3D12Heap(iface); return impl_from_ID3D12Heap(iface);
} }
@ -950,8 +950,8 @@ HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
bool tiled; bool tiled;
HRESULT hr; HRESULT hr;
assert(desc->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER); VKD3D_ASSERT(desc->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER);
assert(d3d12_resource_validate_desc(desc, device) == S_OK); VKD3D_ASSERT(d3d12_resource_validate_desc(desc, device) == S_OK);
if (!desc->MipLevels) if (!desc->MipLevels)
{ {
@ -1044,7 +1044,7 @@ static bool d3d12_resource_validate_box(const struct d3d12_resource *resource,
depth = d3d12_resource_desc_get_depth(&resource->desc, mip_level); depth = d3d12_resource_desc_get_depth(&resource->desc, mip_level);
vkd3d_format = resource->format; vkd3d_format = resource->format;
assert(vkd3d_format); VKD3D_ASSERT(vkd3d_format);
width_mask = vkd3d_format->block_width - 1; width_mask = vkd3d_format->block_width - 1;
height_mask = vkd3d_format->block_height - 1; height_mask = vkd3d_format->block_height - 1;
@ -1162,7 +1162,7 @@ static bool d3d12_resource_init_tiles(struct d3d12_resource *resource, struct d3
if (d3d12_resource_is_buffer(resource)) if (d3d12_resource_is_buffer(resource))
{ {
assert(subresource_count == 1); VKD3D_ASSERT(subresource_count == 1);
VK_CALL(vkGetBufferMemoryRequirements(device->vk_device, resource->u.vk_buffer, &requirements)); VK_CALL(vkGetBufferMemoryRequirements(device->vk_device, resource->u.vk_buffer, &requirements));
if (requirements.alignment > D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES) if (requirements.alignment > D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES)
@ -1381,7 +1381,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource2 *iface
static void *d3d12_resource_get_map_ptr(struct d3d12_resource *resource) static void *d3d12_resource_get_map_ptr(struct d3d12_resource *resource)
{ {
assert(resource->heap->map_ptr); VKD3D_ASSERT(resource->heap->map_ptr);
return (uint8_t *)resource->heap->map_ptr + resource->heap_offset; return (uint8_t *)resource->heap->map_ptr + resource->heap_offset;
} }
@ -1771,7 +1771,7 @@ struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface)
{ {
if (!iface) if (!iface)
return NULL; return NULL;
assert(iface->lpVtbl == (ID3D12ResourceVtbl *)&d3d12_resource_vtbl); VKD3D_ASSERT(iface->lpVtbl == (ID3D12ResourceVtbl *)&d3d12_resource_vtbl);
return impl_from_ID3D12Resource(iface); return impl_from_ID3D12Resource(iface);
} }
@ -2406,7 +2406,7 @@ static struct vkd3d_view *vkd3d_view_create(uint32_t magic, VkDescriptorType vk_
{ {
struct vkd3d_view *view; struct vkd3d_view *view;
assert(magic); VKD3D_ASSERT(magic);
if (!(view = vkd3d_desc_object_cache_get(&device->view_desc_cache))) if (!(view = vkd3d_desc_object_cache_get(&device->view_desc_cache)))
{ {
@ -2536,7 +2536,7 @@ static void d3d12_desc_write_vk_heap_null_descriptor(struct d3d12_descriptor_hea
writes->vk_descriptor_writes[i].pTexelBufferView = &writes->null_vk_buffer_view; writes->vk_descriptor_writes[i].pTexelBufferView = &writes->null_vk_buffer_view;
break; break;
default: default:
assert(false); VKD3D_ASSERT(false);
break; break;
} }
if (++i < ARRAY_SIZE(writes->vk_descriptor_writes) - 1) if (++i < ARRAY_SIZE(writes->vk_descriptor_writes) - 1)
@ -2725,7 +2725,7 @@ void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src, struc
{ {
struct d3d12_desc tmp; struct d3d12_desc tmp;
assert(dst != src); VKD3D_ASSERT(dst != src);
tmp.s.u.object = d3d12_desc_get_object_ref(src, device); tmp.s.u.object = d3d12_desc_get_object_ref(src, device);
descriptor_heap_write_atomic(dst_heap, dst, &tmp, device); descriptor_heap_write_atomic(dst_heap, dst, &tmp, device);
@ -2748,7 +2748,7 @@ static VkDeviceSize vkd3d_get_required_texel_buffer_alignment(const struct d3d12
if (properties->storageTexelBufferOffsetSingleTexelAlignment if (properties->storageTexelBufferOffsetSingleTexelAlignment
&& properties->uniformTexelBufferOffsetSingleTexelAlignment) && properties->uniformTexelBufferOffsetSingleTexelAlignment)
{ {
assert(!vkd3d_format_is_compressed(format)); VKD3D_ASSERT(!vkd3d_format_is_compressed(format));
return min(format->byte_count, alignment); return min(format->byte_count, alignment);
} }
@ -2848,7 +2848,7 @@ static bool vkd3d_create_buffer_view_for_resource(struct d3d12_device *device,
return false; return false;
} }
assert(d3d12_resource_is_buffer(resource)); VKD3D_ASSERT(d3d12_resource_is_buffer(resource));
return vkd3d_create_buffer_view(device, magic, resource->u.vk_buffer, return vkd3d_create_buffer_view(device, magic, resource->u.vk_buffer,
format, offset * element_size, size * element_size, view); format, offset * element_size, size * element_size, view);
@ -2979,7 +2979,7 @@ static VkComponentSwizzle swizzle_vk_component(const VkComponentMapping *compone
break; break;
} }
assert(component != VK_COMPONENT_SWIZZLE_IDENTITY); VKD3D_ASSERT(component != VK_COMPONENT_SWIZZLE_IDENTITY);
return component; return component;
} }
@ -3511,8 +3511,8 @@ static void vkd3d_create_buffer_uav(struct d3d12_desc *descriptor, struct d3d12_
{ {
const struct vkd3d_format *format; const struct vkd3d_format *format;
assert(d3d12_resource_is_buffer(counter_resource)); VKD3D_ASSERT(d3d12_resource_is_buffer(counter_resource));
assert(desc->u.Buffer.StructureByteStride); VKD3D_ASSERT(desc->u.Buffer.StructureByteStride);
format = vkd3d_get_format(device, DXGI_FORMAT_R32_UINT, false); format = vkd3d_get_format(device, DXGI_FORMAT_R32_UINT, false);
if (!vkd3d_create_vk_buffer_view(device, counter_resource->u.vk_buffer, format, if (!vkd3d_create_vk_buffer_view(device, counter_resource->u.vk_buffer, format,
@ -3632,7 +3632,7 @@ bool vkd3d_create_raw_buffer_view(struct d3d12_device *device,
} }
resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, gpu_address); resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, gpu_address);
assert(d3d12_resource_is_buffer(resource)); VKD3D_ASSERT(d3d12_resource_is_buffer(resource));
return vkd3d_create_vk_buffer_view(device, resource->u.vk_buffer, format, return vkd3d_create_vk_buffer_view(device, resource->u.vk_buffer, format,
gpu_address - resource->gpu_address, VK_WHOLE_SIZE, vk_buffer_view); gpu_address - resource->gpu_address, VK_WHOLE_SIZE, vk_buffer_view);
} }
@ -3904,7 +3904,7 @@ void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_dev
vkd3d_desc.layer_count = resource->desc.DepthOrArraySize; vkd3d_desc.layer_count = resource->desc.DepthOrArraySize;
} }
assert(d3d12_resource_is_texture(resource)); VKD3D_ASSERT(d3d12_resource_is_texture(resource));
if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_RTV, resource->u.vk_image, &vkd3d_desc, &view)) if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_RTV, resource->u.vk_image, &vkd3d_desc, &view))
return; return;
@ -3990,7 +3990,7 @@ void d3d12_dsv_desc_create_dsv(struct d3d12_dsv_desc *dsv_desc, struct d3d12_dev
} }
} }
assert(d3d12_resource_is_texture(resource)); VKD3D_ASSERT(d3d12_resource_is_texture(resource));
if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_DSV, resource->u.vk_image, &vkd3d_desc, &view)) if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_DSV, resource->u.vk_image, &vkd3d_desc, &view))
return; return;
@ -4559,7 +4559,7 @@ struct d3d12_query_heap *unsafe_impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface
{ {
if (!iface) if (!iface)
return NULL; return NULL;
assert(iface->lpVtbl == &d3d12_query_heap_vtbl); VKD3D_ASSERT(iface->lpVtbl == &d3d12_query_heap_vtbl);
return impl_from_ID3D12QueryHeap(iface); return impl_from_ID3D12QueryHeap(iface);
} }