VulkanRenderer: Fix 32bits compilation

This commit is contained in:
Lynix 2023-01-02 22:11:00 +01:00
parent ed9035318f
commit cc1246dcac
8 changed files with 20 additions and 12 deletions

View File

@ -48,6 +48,8 @@ namespace Nz
inline VkVertexInputRate ToVulkan(VertexInputRate inputRate); inline VkVertexInputRate ToVulkan(VertexInputRate inputRate);
NAZARA_VULKANRENDERER_API std::string TranslateVulkanError(VkResult code); NAZARA_VULKANRENDERER_API std::string TranslateVulkanError(VkResult code);
template<typename T> UInt64 VulkanHandleToInteger(T handle);
} }
#include <Nazara/VulkanRenderer/Utils.inl> #include <Nazara/VulkanRenderer/Utils.inl>

View File

@ -497,6 +497,18 @@ namespace Nz
NazaraError("Unhandled VertexInputRate 0x" + NumberToString(UnderlyingCast(inputRate), 16)); NazaraError("Unhandled VertexInputRate 0x" + NumberToString(UnderlyingCast(inputRate), 16));
return {}; return {};
} }
template<typename T>
UInt64 VulkanHandleToInteger(T handle)
{
if constexpr (std::is_pointer_v<T>)
return static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(handle));
else
{
static_assert(std::is_integral_v<T>);
return static_cast<UInt64>(handle);
}
}
} }
#include <Nazara/VulkanRenderer/DebugOff.hpp> #include <Nazara/VulkanRenderer/DebugOff.hpp>

View File

@ -86,13 +86,7 @@ namespace Nz::Vk
template<typename T> template<typename T>
void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(T&& name) void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(T&& name)
{ {
UInt64 objectHandle; return m_device->SetDebugName(ObjectType, VulkanHandleToInteger(m_handle), std::forward<T>(name));
if constexpr (std::is_pointer_v<VkType>)
objectHandle = static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_handle));
else
objectHandle = static_cast<UInt64>(m_handle);
return m_device->SetDebugName(ObjectType, objectHandle, std::forward<T>(name));
} }
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType> template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>

View File

@ -61,7 +61,7 @@ namespace Nz
inline void Pipeline::SetDebugName(std::string_view name) inline void Pipeline::SetDebugName(std::string_view name)
{ {
return m_device->SetDebugName(VK_OBJECT_TYPE_PIPELINE, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_handle)), name); return m_device->SetDebugName(VK_OBJECT_TYPE_PIPELINE, VulkanHandleToInteger(m_handle), name);
} }
inline Pipeline::operator VkPipeline() const inline Pipeline::operator VkPipeline() const

View File

@ -139,7 +139,7 @@ namespace Nz
void VulkanBuffer::UpdateDebugName(std::string_view name) void VulkanBuffer::UpdateDebugName(std::string_view name)
{ {
return m_device.SetDebugName(VK_OBJECT_TYPE_BUFFER, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_buffer)), name); return m_device.SetDebugName(VK_OBJECT_TYPE_BUFFER, VulkanHandleToInteger(m_buffer), name);
} }
} }

View File

@ -10,7 +10,7 @@ namespace Nz
{ {
void VulkanCommandBuffer::UpdateDebugName(std::string_view name) void VulkanCommandBuffer::UpdateDebugName(std::string_view name)
{ {
return m_owner.m_device->SetDebugName(VK_OBJECT_TYPE_COMMAND_BUFFER, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(static_cast<VkCommandBuffer>(m_commandBuffer))), name); return m_owner.m_device->SetDebugName(VK_OBJECT_TYPE_COMMAND_BUFFER, VulkanHandleToInteger(static_cast<VkCommandBuffer>(m_commandBuffer)), name);
} }
void VulkanCommandBuffer::Release() void VulkanCommandBuffer::Release()

View File

@ -139,7 +139,7 @@ namespace Nz
void VulkanShaderBinding::UpdateDebugName(std::string_view name) void VulkanShaderBinding::UpdateDebugName(std::string_view name)
{ {
return m_owner.m_device->SetDebugName(VK_OBJECT_TYPE_DESCRIPTOR_SET, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(static_cast<VkDescriptorSet>(m_descriptorSet))), name); return m_owner.m_device->SetDebugName(VK_OBJECT_TYPE_DESCRIPTOR_SET, VulkanHandleToInteger(static_cast<VkDescriptorSet>(m_descriptorSet)), name);
} }
void VulkanShaderBinding::Release() void VulkanShaderBinding::Release()

View File

@ -420,7 +420,7 @@ namespace Nz
void VulkanTexture::UpdateDebugName(std::string_view name) void VulkanTexture::UpdateDebugName(std::string_view name)
{ {
return m_device.SetDebugName(VK_OBJECT_TYPE_IMAGE, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_image)), name); return m_device.SetDebugName(VK_OBJECT_TYPE_IMAGE, VulkanHandleToInteger(m_image), name);
} }
void VulkanTexture::InitViewForFormat(PixelFormat pixelFormat, VkImageViewCreateInfo& createImageView) void VulkanTexture::InitViewForFormat(PixelFormat pixelFormat, VkImageViewCreateInfo& createImageView)