VulkanRenderer: Fix unitybuild causing #define issue because of Windows.h

This commit is contained in:
SirLynix 2023-04-12 14:13:34 +02:00
parent f034e71ba4
commit d717335bca
31 changed files with 652 additions and 739 deletions

View File

@ -14,120 +14,117 @@
#include <Nazara/VulkanRenderer/Wrapper/CommandPool.hpp>
#include <vulkan/vulkan_core.h>
namespace Nz
namespace Nz::Vk
{
namespace Vk
class CommandBuffer
{
class CommandBuffer
{
friend CommandPool;
friend CommandPool;
public:
inline CommandBuffer();
CommandBuffer(const CommandBuffer&) = delete;
inline CommandBuffer(CommandBuffer&& commandBuffer);
~CommandBuffer() = default;
public:
inline CommandBuffer();
CommandBuffer(const CommandBuffer&) = delete;
inline CommandBuffer(CommandBuffer&& commandBuffer) noexcept;
~CommandBuffer() = default;
inline bool Begin(const VkCommandBufferBeginInfo& info);
inline bool Begin(VkCommandBufferUsageFlags flags = 0);
inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo);
inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics);
inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics);
inline bool Begin(const VkCommandBufferBeginInfo& info);
inline bool Begin(VkCommandBufferUsageFlags flags = 0);
inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo);
inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics);
inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics);
inline void BeginDebugRegion(const char* label);
inline void BeginDebugRegion(const char* label, Color color);
inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
inline void BeginDebugRegion(const char* label);
inline void BeginDebugRegion(const char* label, Color color);
inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets);
inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets);
inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets);
inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType);
inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline);
inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset);
inline void BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset);
inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets);
inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets);
inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets);
inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType);
inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline);
inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset);
inline void BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset);
inline void BlitImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageBlit& region, VkFilter filter);
inline void BlitImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, UInt32 regionCount, const VkImageBlit* regions, VkFilter filter);
inline void BlitImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageBlit& region, VkFilter filter);
inline void BlitImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, UInt32 regionCount, const VkImageBlit* regions, VkFilter filter);
inline void ClearAttachment(const VkClearAttachment& attachment, const VkClearRect& rect);
inline void ClearAttachments(UInt32 attachmentCount, const VkClearAttachment* attachments, UInt32 rectCount, const VkClearRect* rects);
inline void ClearAttachment(const VkClearAttachment& attachment, const VkClearRect& rect);
inline void ClearAttachments(UInt32 attachmentCount, const VkClearAttachment* attachments, UInt32 rectCount, const VkClearRect* rects);
inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, const VkImageSubresourceRange& range);
inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, UInt32 rangeCount, const VkImageSubresourceRange* ranges);
inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, const VkImageSubresourceRange& range);
inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, UInt32 rangeCount, const VkImageSubresourceRange* ranges);
inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range);
inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges);
inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range);
inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges);
inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth = 1);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, Int32 x, Int32 y, Int32 z, UInt32 width, UInt32 height, UInt32 depth);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 width, UInt32 height, UInt32 depth = 1);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkBufferImageCopy& region);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 regionCount, const VkBufferImageCopy* regions);
inline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageCopy& region);
inline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, UInt32 regionCount, const VkImageCopy* regions);
inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth = 1);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, Int32 x, Int32 y, Int32 z, UInt32 width, UInt32 height, UInt32 depth);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 width, UInt32 height, UInt32 depth = 1);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkBufferImageCopy& region);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 regionCount, const VkBufferImageCopy* regions);
inline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageCopy& region);
inline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, UInt32 regionCount, const VkImageCopy* regions);
inline void Dispatch(UInt32 groupCountX, UInt32 groupCountY, UInt32 groupCountZ);
inline void Dispatch(UInt32 groupCountX, UInt32 groupCountY, UInt32 groupCountZ);
inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0);
inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0);
inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0);
inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0);
inline bool End();
inline bool End();
inline void EndDebugRegion();
inline void EndRenderPass();
inline void EndDebugRegion();
inline void EndRenderPass();
inline void Free();
inline void Free();
inline VkResult GetLastErrorCode() const;
inline CommandPool& GetPool();
inline VkResult GetLastErrorCode() const;
inline CommandPool& GetPool();
inline void ImageBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout, VkImage image, const VkImageSubresourceRange& subresourceRange);
inline void ImageBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout, VkImage image, const VkImageSubresourceRange& subresourceRange);
inline void InsertDebugLabel(const char* label);
inline void InsertDebugLabel(const char* label, Color color);
inline void InsertDebugLabel(const char* label);
inline void InsertDebugLabel(const char* label, Color color);
inline void MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
inline void MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
inline void NextSubpass(VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
inline void NextSubpass(VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier);
inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier);
inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers);
inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier);
inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier);
inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers);
inline void SetScissor(const Recti& scissorRegion);
inline void SetScissor(const VkRect2D& scissorRegion);
inline void SetScissor(UInt32 firstScissor, UInt32 scissorCount, const VkRect2D* scissors);
inline void SetViewport(const Rectf& viewport, float minDepth, float maxDepth);
inline void SetViewport(const VkViewport& viewport);
inline void SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports);
inline void SetScissor(const Recti& scissorRegion);
inline void SetScissor(const VkRect2D& scissorRegion);
inline void SetScissor(UInt32 firstScissor, UInt32 scissorCount, const VkRect2D* scissors);
inline void SetViewport(const Rectf& viewport, float minDepth, float maxDepth);
inline void SetViewport(const VkViewport& viewport);
inline void SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports);
inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout);
inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange);
inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout);
inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange);
inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout);
inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange);
inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout);
inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange);
CommandBuffer& operator=(const CommandBuffer&) = delete;
CommandBuffer& operator=(CommandBuffer&& commandBuffer) noexcept;
CommandBuffer& operator=(const CommandBuffer&) = delete;
CommandBuffer& operator=(CommandBuffer&& commandBuffer) noexcept;
inline operator VkCommandBuffer() const;
inline operator VkCommandBuffer() const;
private:
inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle);
private:
inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle);
CommandPool* m_pool;
VkCommandBuffer m_handle;
VkResult m_lastErrorCode;
};
CommandPool* m_pool;
VkCommandBuffer m_handle;
VkResult m_lastErrorCode;
};
class AutoCommandBuffer : public AutoFree<CommandBuffer>
{
public:
using AutoFree::AutoFree;
class AutoCommandBuffer : public AutoFree<CommandBuffer>
{
public:
using AutoFree::AutoFree;
operator VkCommandBuffer() const { return Get(); }
};
}
operator VkCommandBuffer() const { return Get(); }
};
}
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl>

View File

@ -23,7 +23,7 @@ namespace Nz
{
}
inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) :
inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) noexcept :
m_pool(commandBuffer.m_pool),
m_handle(commandBuffer.m_handle),
m_lastErrorCode(commandBuffer.m_lastErrorCode)

View File

@ -7,158 +7,155 @@
#include <cassert>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
namespace Nz::Vk
{
namespace Vk
inline DescriptorSet::DescriptorSet() :
m_pool(nullptr),
m_handle(VK_NULL_HANDLE)
{
inline DescriptorSet::DescriptorSet() :
m_pool(nullptr),
m_handle(VK_NULL_HANDLE)
}
inline DescriptorSet::DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle) :
m_pool(&pool),
m_handle(handle)
{
}
inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) noexcept :
m_pool(descriptorSet.m_pool),
m_handle(descriptorSet.m_handle)
{
descriptorSet.m_handle = VK_NULL_HANDLE;
}
inline void DescriptorSet::Free()
{
if (m_handle)
{
assert(m_pool);
m_pool->GetDevice()->vkFreeDescriptorSets(*m_pool->GetDevice(), *m_pool, 1, &m_handle);
}
}
inline DescriptorSet::DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle) :
m_pool(&pool),
m_handle(handle)
{
}
inline bool DescriptorSet::IsValid() const
{
return m_handle != VK_NULL_HANDLE;
}
inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) noexcept :
m_pool(descriptorSet.m_pool),
m_handle(descriptorSet.m_handle)
{
descriptorSet.m_handle = VK_NULL_HANDLE;
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
{
return WriteCombinedImageSamplerDescriptor(binding, 0, sampler, imageView, imageLayout);
}
inline void DescriptorSet::Free()
{
if (m_handle)
{
assert(m_pool);
m_pool->GetDevice()->vkFreeDescriptorSets(*m_pool->GetDevice(), *m_pool, 1, &m_handle);
}
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, const VkDescriptorImageInfo& imageInfo)
{
return WriteCombinedImageSamplerDescriptor(binding, 0, imageInfo);
}
inline bool DescriptorSet::IsValid() const
{
return m_handle != VK_NULL_HANDLE;
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
{
VkDescriptorImageInfo imageInfo = {
sampler,
imageView,
imageLayout
};
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
{
return WriteCombinedImageSamplerDescriptor(binding, 0, sampler, imageView, imageLayout);
}
return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo);
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, const VkDescriptorImageInfo& imageInfo)
{
return WriteCombinedImageSamplerDescriptor(binding, 0, imageInfo);
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorImageInfo& imageInfo)
{
return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo);
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
{
VkDescriptorImageInfo imageInfo = {
sampler,
imageView,
imageLayout
};
inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo)
{
return WriteCombinedImageSamplerDescriptors(binding, 0U, descriptorCount, imageInfo);
}
return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo);
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo)
{
VkWriteDescriptorSet writeDescriptorSet = {
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
nullptr,
m_handle,
binding,
arrayElement,
descriptorCount,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
imageInfo,
nullptr,
nullptr
};
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorImageInfo& imageInfo)
{
return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo);
}
return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr);
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo)
{
return WriteCombinedImageSamplerDescriptors(binding, 0U, descriptorCount, imageInfo);
}
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
{
return WriteUniformDescriptor(binding, 0U, buffer, offset, range);
}
inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo)
{
VkWriteDescriptorSet writeDescriptorSet = {
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
nullptr,
m_handle,
binding,
arrayElement,
descriptorCount,
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
imageInfo,
nullptr,
nullptr
};
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo)
{
return WriteUniformDescriptors(binding, 0U, 1U, &bufferInfo);
}
return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr);
}
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
{
VkDescriptorBufferInfo bufferInfo = {
buffer,
offset,
range
};
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
{
return WriteUniformDescriptor(binding, 0U, buffer, offset, range);
}
return WriteUniformDescriptor(binding, arrayElement, bufferInfo);
}
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo)
{
return WriteUniformDescriptors(binding, 0U, 1U, &bufferInfo);
}
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo)
{
return WriteUniformDescriptors(binding, arrayElement, 1U, &bufferInfo);
}
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
{
VkDescriptorBufferInfo bufferInfo = {
buffer,
offset,
range
};
inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo)
{
return WriteUniformDescriptors(binding, 0U, descriptorCount, bufferInfo);
}
return WriteUniformDescriptor(binding, arrayElement, bufferInfo);
}
inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo)
{
VkWriteDescriptorSet writeDescriptorSet = {
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
nullptr,
m_handle,
binding,
arrayElement,
descriptorCount,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
nullptr,
bufferInfo,
nullptr
};
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo)
{
return WriteUniformDescriptors(binding, arrayElement, 1U, &bufferInfo);
}
return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr);
}
inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo)
{
return WriteUniformDescriptors(binding, 0U, descriptorCount, bufferInfo);
}
inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) noexcept
{
std::swap(m_handle, descriptorSet.m_handle);
std::swap(m_pool, descriptorSet.m_pool);
inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo)
{
VkWriteDescriptorSet writeDescriptorSet = {
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
nullptr,
m_handle,
binding,
arrayElement,
descriptorCount,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
nullptr,
bufferInfo,
nullptr
};
return *this;
}
return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr);
}
inline DescriptorSet::operator bool() const
{
return IsValid();
}
inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) noexcept
{
std::swap(m_handle, descriptorSet.m_handle);
std::swap(m_pool, descriptorSet.m_pool);
return *this;
}
inline DescriptorSet::operator bool() const
{
return IsValid();
}
inline DescriptorSet::operator VkDescriptorSet() const
{
return m_handle;
}
inline DescriptorSet::operator VkDescriptorSet() const
{
return m_handle;
}
}

View File

@ -21,17 +21,24 @@
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#include <wayland-client.h>
#include <vulkan/vulkan_wayland.h>
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
#include <windows.h>
typedef struct HINSTANCE__* HINSTANCE;
typedef struct HWND__* HWND;
typedef struct HMONITOR__* HMONITOR;
typedef void* HANDLE;
typedef /*_Null_terminated_*/ const wchar_t* LPCWSTR;
typedef unsigned long DWORD;
typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
#include <vulkan/vulkan_win32.h>
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
#include <xcb/xcb.h>
struct xcb_connection_t;
typedef uint32_t xcb_window_t;
typedef uint32_t xcb_visualid_t;
#include <vulkan/vulkan_xcb.h>
#endif
@ -48,72 +55,69 @@ typedef unsigned long VisualID;
#include <vulkan/vulkan_xlib.h>
#endif
namespace Nz
namespace Nz::Vk
{
namespace Vk
class NAZARA_VULKANRENDERER_API Instance
{
class NAZARA_VULKANRENDERER_API Instance
{
public:
Instance();
Instance(const Instance&) = delete;
Instance(Instance&&) = delete;
~Instance();
public:
Instance();
Instance(const Instance&) = delete;
Instance(Instance&&) = delete;
~Instance();
bool Create(RenderAPIValidationLevel validationLevel, const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
inline bool Create(RenderAPIValidationLevel validationLevel, const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator = nullptr);
inline void Destroy();
bool Create(RenderAPIValidationLevel validationLevel, const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
inline bool Create(RenderAPIValidationLevel validationLevel, const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator = nullptr);
inline void Destroy();
bool EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* physicalDevices) const;
bool EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* physicalDevices) const;
inline PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* name) const;
inline PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* name) const;
inline UInt32 GetApiVersion() const;
inline VkResult GetLastErrorCode() const;
inline UInt32 GetApiVersion() const;
inline VkResult GetLastErrorCode() const;
bool GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector<VkExtensionProperties>* extensionProperties) const;
inline VkPhysicalDeviceFeatures GetPhysicalDeviceFeatures(VkPhysicalDevice device) const;
inline VkFormatProperties GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) const;
inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) const;
inline VkPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) const;
inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device) const;
bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties) const;
inline PFN_vkVoidFunction GetProcAddr(const char* name) const;
inline RenderAPIValidationLevel GetValidationLevel() const;
bool GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector<VkExtensionProperties>* extensionProperties) const;
inline VkPhysicalDeviceFeatures GetPhysicalDeviceFeatures(VkPhysicalDevice device) const;
inline VkFormatProperties GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) const;
inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) const;
inline VkPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) const;
inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device) const;
bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties) const;
inline PFN_vkVoidFunction GetProcAddr(const char* name) const;
inline RenderAPIValidationLevel GetValidationLevel() const;
void InstallDebugMessageCallback();
void InstallDebugMessageCallback();
inline bool IsExtensionLoaded(const std::string& extensionName) const;
inline bool IsLayerLoaded(const std::string& layerName) const;
inline bool IsValid() const;
inline bool IsExtensionLoaded(const std::string& extensionName) const;
inline bool IsLayerLoaded(const std::string& layerName) const;
inline bool IsValid() const;
Instance& operator=(const Instance&) = delete;
Instance& operator=(Instance&&) = delete;
Instance& operator=(const Instance&) = delete;
Instance& operator=(Instance&&) = delete;
inline operator VkInstance();
inline operator VkInstance();
// Vulkan functions
// Vulkan functions
#define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) PFN_##func func;
#define NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func)
#include <Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp>
private:
void DestroyInstance();
void ResetPointers();
private:
void DestroyInstance();
void ResetPointers();
struct InternalData;
struct InternalData;
std::unique_ptr<InternalData> m_internalData;
std::unordered_set<std::string> m_loadedExtensions;
std::unordered_set<std::string> m_loadedLayers;
VkAllocationCallbacks m_allocator;
VkInstance m_instance;
mutable VkResult m_lastErrorCode;
RenderAPIValidationLevel m_validationLevel;
UInt32 m_apiVersion;
};
}
std::unique_ptr<InternalData> m_internalData;
std::unordered_set<std::string> m_loadedExtensions;
std::unordered_set<std::string> m_loadedLayers;
VkAllocationCallbacks m_allocator;
VkInstance m_instance;
mutable VkResult m_lastErrorCode;
RenderAPIValidationLevel m_validationLevel;
UInt32 m_apiVersion;
};
}
#include <Nazara/VulkanRenderer/Wrapper/Instance.inl>

View File

@ -7,143 +7,140 @@
#include <cassert>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
namespace Nz::Vk
{
namespace Vk
inline bool Instance::Create(RenderAPIValidationLevel validationLevel, const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator)
{
inline bool Instance::Create(RenderAPIValidationLevel validationLevel, const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator)
VkApplicationInfo appInfo =
{
VkApplicationInfo appInfo =
{
VK_STRUCTURE_TYPE_APPLICATION_INFO,
nullptr,
appName.data(),
appVersion,
engineName.data(),
engineVersion,
apiVersion
};
VK_STRUCTURE_TYPE_APPLICATION_INFO,
nullptr,
appName.data(),
appVersion,
engineName.data(),
engineVersion,
apiVersion
};
VkInstanceCreateInfo instanceInfo =
{
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
nullptr,
0,
&appInfo,
static_cast<UInt32>(layers.size()),
(!layers.empty()) ? layers.data() : nullptr,
static_cast<UInt32>(extensions.size()),
(!extensions.empty()) ? extensions.data() : nullptr
};
VkInstanceCreateInfo instanceInfo =
{
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
nullptr,
0,
&appInfo,
static_cast<UInt32>(layers.size()),
(!layers.empty()) ? layers.data() : nullptr,
static_cast<UInt32>(extensions.size()),
(!extensions.empty()) ? extensions.data() : nullptr
};
return Create(validationLevel, instanceInfo, allocator);
return Create(validationLevel, instanceInfo, allocator);
}
inline void Instance::Destroy()
{
if (m_instance)
{
DestroyInstance();
ResetPointers();
}
}
inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) const
{
PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name);
if (!func)
NazaraError("Failed to get " + std::string(name) + " address");
return func;
}
inline UInt32 Instance::GetApiVersion() const
{
return m_apiVersion;
}
inline VkResult Instance::GetLastErrorCode() const
{
return m_lastErrorCode;
}
inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) const
{
PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name);
if (!func)
NazaraError("Failed to get " + std::string(name) + " address");
return func;
}
inline RenderAPIValidationLevel Instance::GetValidationLevel() const
{
return m_validationLevel;
}
inline bool Instance::IsExtensionLoaded(const std::string& extensionName) const
{
return m_loadedExtensions.count(extensionName) > 0;
}
inline bool Instance::IsLayerLoaded(const std::string& layerName) const
{
return m_loadedLayers.count(layerName) > 0;
}
inline bool Instance::IsValid() const
{
return m_instance != nullptr;
}
inline Instance::operator VkInstance()
{
return m_instance;
}
inline VkPhysicalDeviceFeatures Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device) const
{
VkPhysicalDeviceFeatures features;
vkGetPhysicalDeviceFeatures(device, &features);
return features;
}
inline VkFormatProperties Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) const
{
VkFormatProperties formatProperties;
vkGetPhysicalDeviceFormatProperties(device, format, &formatProperties);
return formatProperties;
}
inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) const
{
m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to get physical device image format properties: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
inline void Instance::Destroy()
{
if (m_instance)
{
DestroyInstance();
ResetPointers();
}
}
return true;
}
inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) const
{
PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name);
if (!func)
NazaraError("Failed to get " + std::string(name) + " address");
inline VkPhysicalDeviceMemoryProperties Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) const
{
VkPhysicalDeviceMemoryProperties memoryProperties;
vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties);
return func;
}
return memoryProperties;
}
inline UInt32 Instance::GetApiVersion() const
{
return m_apiVersion;
}
inline VkPhysicalDeviceProperties Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device) const
{
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(device, &properties);
inline VkResult Instance::GetLastErrorCode() const
{
return m_lastErrorCode;
}
inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) const
{
PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name);
if (!func)
NazaraError("Failed to get " + std::string(name) + " address");
return func;
}
inline RenderAPIValidationLevel Instance::GetValidationLevel() const
{
return m_validationLevel;
}
inline bool Instance::IsExtensionLoaded(const std::string& extensionName) const
{
return m_loadedExtensions.count(extensionName) > 0;
}
inline bool Instance::IsLayerLoaded(const std::string& layerName) const
{
return m_loadedLayers.count(layerName) > 0;
}
inline bool Instance::IsValid() const
{
return m_instance != nullptr;
}
inline Instance::operator VkInstance()
{
return m_instance;
}
inline VkPhysicalDeviceFeatures Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device) const
{
VkPhysicalDeviceFeatures features;
vkGetPhysicalDeviceFeatures(device, &features);
return features;
}
inline VkFormatProperties Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) const
{
VkFormatProperties formatProperties;
vkGetPhysicalDeviceFormatProperties(device, format, &formatProperties);
return formatProperties;
}
inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) const
{
m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to get physical device image format properties: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
return true;
}
inline VkPhysicalDeviceMemoryProperties Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) const
{
VkPhysicalDeviceMemoryProperties memoryProperties;
vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties);
return memoryProperties;
}
inline VkPhysicalDeviceProperties Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device) const
{
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(device, &properties);
return properties;
}
return properties;
}
}

View File

@ -17,7 +17,3 @@ extern "C"
}
#endif
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -625,7 +625,3 @@ namespace Nz
Vk::Instance Vulkan::s_instance;
ParameterList Vulkan::s_initializationParameters;
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -143,6 +143,7 @@ namespace Nz
}
}
// vma includes vulkan.h which includes system headers
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#elif defined(NAZARA_PLATFORM_LINUX)

View File

@ -18,6 +18,3 @@ namespace Nz
m_owner.Release(*this);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -290,7 +290,3 @@ namespace Nz
m_commandBuffer.ImageBarrier(ToVulkan(srcStageMask), ToVulkan(dstStageMask), VkDependencyFlags(0), ToVulkan(srcAccessMask), ToVulkan(dstAccessMask), ToVulkan(oldLayout), ToVulkan(newLayout), vkTexture.GetImage(), vkTexture.GetSubresourceRange());
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -76,7 +76,3 @@ namespace Nz
TryToShrink();
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -54,7 +54,3 @@ namespace Nz
m_pipeline.SetDebugName(name);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -140,7 +140,3 @@ namespace Nz
return formatProperties.optimalTilingFeatures & flags; //< Assume optimal tiling
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -12,7 +12,3 @@ namespace Nz
GetFramebuffer().SetDebugName(name);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -91,7 +91,3 @@ namespace Nz
}
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -139,7 +139,3 @@ namespace Nz
return m_renderPass.SetDebugName(name);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -328,7 +328,3 @@ namespace Nz
m_pipelineCreateInfo.stateData->colorBlendState = BuildColorBlendInfo(m_pipelineInfo, m_pipelineCreateInfo.colorBlendAttachmentState);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -159,7 +159,3 @@ namespace Nz
TryToShrink();
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -64,7 +64,3 @@ namespace Nz
return m_deviceInfos;
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -147,7 +147,3 @@ namespace Nz
m_owner.Release(*this);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -147,7 +147,3 @@ namespace Nz
m_shaderModule.SetDebugName(name);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -15,6 +15,11 @@
#include <array>
#include <stdexcept>
#ifdef VK_USE_PLATFORM_WIN32_KHR
#include <Windows.h>
#include <vulkan/vulkan_win32.h>
#endif
#ifdef VK_USE_PLATFORM_METAL_EXT
#include <objc/runtime.h>
#include <vulkan/vulkan_metal.h>

View File

@ -501,6 +501,7 @@ namespace Nz
}
}
// vma includes vulkan.h which includes system headers
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#elif defined(NAZARA_PLATFORM_LINUX)

View File

@ -42,7 +42,3 @@ namespace Nz
throw std::runtime_error("failed to instantiate Vulkan framebuffer: " + TranslateVulkanError(m_framebuffer.GetLastErrorCode()));
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -40,7 +40,3 @@ namespace Nz
return m_sampler.SetDebugName(name);
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -103,7 +103,3 @@ namespace Nz
m_nextAllocationIndex = 0;
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -8,7 +8,3 @@
namespace Nz
{
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -51,7 +51,3 @@ namespace Nz
}
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -49,7 +49,3 @@ namespace Nz
}
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif

View File

@ -300,6 +300,7 @@ namespace Nz
}
}
// vma includes vulkan.h which includes system headers
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#elif defined(NAZARA_PLATFORM_LINUX)

View File

@ -12,331 +12,324 @@
#include <sstream>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
namespace Nz::Vk
{
namespace Vk
namespace
{
namespace
VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessengerCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData)
{
VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessengerCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData)
Instance& instance = *static_cast<Instance*>(pUserData);
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)
{
Instance& instance = *static_cast<Instance*>(pUserData);
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)
{
RenderAPIValidationLevel validationLevel = instance.GetValidationLevel();
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) && validationLevel < RenderAPIValidationLevel::Debug)
return VK_FALSE;
RenderAPIValidationLevel validationLevel = instance.GetValidationLevel();
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) && validationLevel < RenderAPIValidationLevel::Debug)
return VK_FALSE;
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) && validationLevel < RenderAPIValidationLevel::Verbose)
return VK_FALSE;
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) && validationLevel < RenderAPIValidationLevel::Verbose)
return VK_FALSE;
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) && validationLevel < RenderAPIValidationLevel::Warnings)
return VK_FALSE;
}
std::stringstream ss;
ss << "Vulkan log: ";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT)
ss << "[Verbose]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
ss << "[Info]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
ss << "[Warning]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
ss << "[Error]";
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT)
ss << "[General]";
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)
ss << "[Performance]";
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)
ss << "[Validation]";
ss << "[" << pCallbackData->messageIdNumber;
if (pCallbackData->pMessageIdName)
ss << ":" << pCallbackData->pMessageIdName;
ss << "]: " << pCallbackData->pMessage;
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
NazaraError(ss.str());
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
NazaraWarning(ss.str());
else
NazaraNotice(ss.str());
return VK_FALSE; //< Should the Vulkan call be aborted
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) && validationLevel < RenderAPIValidationLevel::Warnings)
return VK_FALSE;
}
VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT /*objectType*/,
uint64_t /*object*/,
size_t /*location*/,
int32_t messageCode,
const char* pLayerPrefix,
const char* pMessage,
void* /*pUserData*/)
{
std::stringstream ss;
ss << "Vulkan log: ";
std::stringstream ss;
ss << "Vulkan log: ";
if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT)
ss << "[Info]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT)
ss << "[Verbose]";
if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT)
ss << "[Warning]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
ss << "[Info]";
if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
ss << "[Error]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
ss << "[Warning]";
if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)
ss << "[Performance]";
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
ss << "[Error]";
if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT)
ss << "[Debug]";
ss << "[" << messageCode << "]";
if (pLayerPrefix)
ss << "[layer " << pLayerPrefix << "]";
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT)
ss << "[General]";
ss << ": " << pMessage;
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)
ss << "[Performance]";
if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
NazaraError(ss.str());
else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT)
NazaraWarning(ss.str());
else
NazaraNotice(ss.str());
if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)
ss << "[Validation]";
return VK_FALSE; //< Should the Vulkan call be aborted
}
}
ss << "[" << pCallbackData->messageIdNumber;
if (pCallbackData->pMessageIdName)
ss << ":" << pCallbackData->pMessageIdName;
struct Instance::InternalData
{
DebugReportCallbackEXT debugCallback;
DebugUtilsMessengerEXT debugMessenger;
};
ss << "]: " << pCallbackData->pMessage;
Instance::Instance() :
m_instance(nullptr)
{
}
Instance::~Instance()
{
if (m_instance)
DestroyInstance();
}
bool Instance::Create(RenderAPIValidationLevel validationLevel, const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator)
{
m_lastErrorCode = Loader::vkCreateInstance(&createInfo, allocator, &m_instance);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan instance: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
m_apiVersion = createInfo.pApplicationInfo->apiVersion;
m_validationLevel = validationLevel;
// Store the allocator to access them when needed
if (allocator)
m_allocator = *allocator;
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
NazaraError(ss.str());
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
NazaraWarning(ss.str());
else
m_allocator.pfnAllocation = nullptr;
NazaraNotice(ss.str());
// Parse extensions and layers
for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i)
m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]);
return VK_FALSE; //< Should the Vulkan call be aborted
}
for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i)
m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]);
VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT /*objectType*/,
uint64_t /*object*/,
size_t /*location*/,
int32_t messageCode,
const char* pLayerPrefix,
const char* pMessage,
void* /*pUserData*/)
{
std::stringstream ss;
ss << "Vulkan log: ";
// And now load everything
try
{
ErrorFlags flags(ErrorMode::ThrowException, true);
if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT)
ss << "[Info]";
if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT)
ss << "[Warning]";
if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
ss << "[Error]";
if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)
ss << "[Performance]";
if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT)
ss << "[Debug]";
ss << "[" << messageCode << "]";
if (pLayerPrefix)
ss << "[layer " << pLayerPrefix << "]";
ss << ": " << pMessage;
if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
NazaraError(ss.str());
else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT)
NazaraWarning(ss.str());
else
NazaraNotice(ss.str());
return VK_FALSE; //< Should the Vulkan call be aborted
}
}
struct Instance::InternalData
{
DebugReportCallbackEXT debugCallback;
DebugUtilsMessengerEXT debugMessenger;
};
Instance::Instance() :
m_instance(nullptr)
{
}
Instance::~Instance()
{
if (m_instance)
DestroyInstance();
}
bool Instance::Create(RenderAPIValidationLevel validationLevel, const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator)
{
m_lastErrorCode = Loader::vkCreateInstance(&createInfo, allocator, &m_instance);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan instance: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
m_apiVersion = createInfo.pApplicationInfo->apiVersion;
m_validationLevel = validationLevel;
// Store the allocator to access them when needed
if (allocator)
m_allocator = *allocator;
else
m_allocator.pfnAllocation = nullptr;
// Parse extensions and layers
for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i)
m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]);
for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i)
m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]);
// And now load everything
try
{
ErrorFlags flags(ErrorMode::ThrowException, true);
#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) if (IsExtensionLoaded(#ext)) { \
NazaraDebug(#ext " extension is supported");
NazaraDebug(#ext " extension is supported");
#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() }
#define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) func = reinterpret_cast<PFN_##func>(GetProcAddr(#func)); \
if (!func) \
NazaraWarning("failed to get a function pointer for " #func " despite its being reported as supported");
if (!func) \
NazaraWarning("failed to get a function pointer for " #func " despite its being reported as supported");
#define NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(func, coreVersion, suffix, extName) \
if (m_apiVersion >= coreVersion) \
func = reinterpret_cast<PFN_##func>(GetProcAddr(#func)); \
else if (IsExtensionLoaded("VK_" #suffix "_" #extName)) \
func = reinterpret_cast<PFN_##func##suffix>(GetProcAddr(#func #suffix));
if (m_apiVersion >= coreVersion) \
func = reinterpret_cast<PFN_##func>(GetProcAddr(#func)); \
else if (IsExtensionLoaded("VK_" #suffix "_" #extName)) \
func = reinterpret_cast<PFN_##func##suffix>(GetProcAddr(#func #suffix));
#include <Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp>
}
catch (const std::exception& e)
{
NazaraError(std::string("Failed to query instance function: ") + e.what());
return false;
}
m_internalData = std::make_unique<InternalData>();
InstallDebugMessageCallback();
return true;
}
catch (const std::exception& e)
{
NazaraError(std::string("Failed to query instance function: ") + e.what());
return false;
}
bool Instance::EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* devices) const
m_internalData = std::make_unique<InternalData>();
InstallDebugMessageCallback();
return true;
}
bool Instance::EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* devices) const
{
NazaraAssert(devices, "Invalid device vector");
// First, query physical device count
UInt32 deviceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t
m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0)
{
NazaraAssert(devices, "Invalid device vector");
// First, query physical device count
UInt32 deviceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t
m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0)
{
NazaraError("Failed to query physical device count: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
// Now we can get the list of the available physical device
devices->resize(deviceCount);
m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query physical devices: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
return true;
NazaraError("Failed to query physical device count: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
bool Instance::GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector<VkExtensionProperties>* extensionProperties) const
// Now we can get the list of the available physical device
devices->resize(deviceCount);
m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraAssert(extensionProperties, "Invalid extension properties vector");
// First, query extension count
UInt32 extensionPropertyCount = 0;
m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query extension properties count: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
if (extensionPropertyCount == 0)
return true; //< No extension available
// Now we can get the list of the available extensions
extensionProperties->resize(extensionPropertyCount);
m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, extensionProperties->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query extension properties count: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
return true;
NazaraError("Failed to query physical devices: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties) const
return true;
}
bool Instance::GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector<VkExtensionProperties>* extensionProperties) const
{
NazaraAssert(extensionProperties, "Invalid extension properties vector");
// First, query extension count
UInt32 extensionPropertyCount = 0;
m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraAssert(queueFamilyProperties, "Invalid family properties vector");
// First, query physical device count
UInt32 queueFamiliesCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, nullptr);
if (queueFamiliesCount == 0)
{
NazaraError("Failed to query physical device count");
return false;
}
// Now we can get the list of the available physical device
queueFamilyProperties->resize(queueFamiliesCount);
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, queueFamilyProperties->data());
return true;
NazaraError("Failed to query extension properties count: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
void Instance::InstallDebugMessageCallback()
if (extensionPropertyCount == 0)
return true; //< No extension available
// Now we can get the list of the available extensions
extensionProperties->resize(extensionPropertyCount);
m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, extensionProperties->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraAssert(m_internalData, "Instance must be created before callbacks are installed");
NazaraError("Failed to query extension properties count: " + TranslateVulkanError(m_lastErrorCode));
return false;
}
if (Vk::DebugUtilsMessengerEXT::IsSupported(*this))
return true;
}
bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties) const
{
NazaraAssert(queueFamilyProperties, "Invalid family properties vector");
// First, query physical device count
UInt32 queueFamiliesCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, nullptr);
if (queueFamiliesCount == 0)
{
NazaraError("Failed to query physical device count");
return false;
}
// Now we can get the list of the available physical device
queueFamilyProperties->resize(queueFamiliesCount);
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, queueFamilyProperties->data());
return true;
}
void Instance::InstallDebugMessageCallback()
{
NazaraAssert(m_internalData, "Instance must be created before callbacks are installed");
if (Vk::DebugUtilsMessengerEXT::IsSupported(*this))
{
VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = {};
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
callbackCreateInfo.pfnUserCallback = &DebugMessengerCallback;
callbackCreateInfo.pUserData = this;
if (!m_internalData->debugMessenger.Create(*this, callbackCreateInfo))
{
VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = {};
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
callbackCreateInfo.pfnUserCallback = &DebugMessengerCallback;
callbackCreateInfo.pUserData = this;
if (!m_internalData->debugMessenger.Create(*this, callbackCreateInfo))
{
NazaraWarning("failed to install debug message callback");
return;
}
}
else if (Vk::DebugReportCallbackEXT::IsSupported(*this))
{
NazaraWarning(VK_EXT_DEBUG_UTILS_EXTENSION_NAME " is not supported, falling back on " VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
VkDebugReportCallbackCreateInfoEXT callbackCreateInfo = {};
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
callbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
callbackCreateInfo.pfnCallback = &DebugReportCallback;
callbackCreateInfo.pUserData = this;
if (!m_internalData->debugCallback.Create(*this, callbackCreateInfo))
{
NazaraWarning("failed to install debug message callback");
return;
}
}
else
{
NazaraWarning(VK_EXT_DEBUG_UTILS_EXTENSION_NAME " nor " VK_EXT_DEBUG_REPORT_EXTENSION_NAME " are not supported, cannot install debug message callback");
NazaraWarning("failed to install debug message callback");
return;
}
}
else if (Vk::DebugReportCallbackEXT::IsSupported(*this))
{
NazaraWarning(VK_EXT_DEBUG_UTILS_EXTENSION_NAME " is not supported, falling back on " VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
VkDebugReportCallbackCreateInfoEXT callbackCreateInfo = {};
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
callbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
callbackCreateInfo.pfnCallback = &DebugReportCallback;
callbackCreateInfo.pUserData = this;
if (!m_internalData->debugCallback.Create(*this, callbackCreateInfo))
{
NazaraWarning("failed to install debug message callback");
return;
}
}
else
{
NazaraWarning(VK_EXT_DEBUG_UTILS_EXTENSION_NAME " nor " VK_EXT_DEBUG_REPORT_EXTENSION_NAME " are not supported, cannot install debug message callback");
return;
}
void Instance::DestroyInstance()
{
assert(m_instance != VK_NULL_HANDLE);
}
m_internalData.reset();
void Instance::DestroyInstance()
{
assert(m_instance != VK_NULL_HANDLE);
if (vkDestroyInstance)
vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr);
}
m_internalData.reset();
void Instance::ResetPointers()
{
assert(m_instance != VK_NULL_HANDLE);
m_instance = VK_NULL_HANDLE;
if (vkDestroyInstance)
vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr);
}
void Instance::ResetPointers()
{
assert(m_instance != VK_NULL_HANDLE);
m_instance = VK_NULL_HANDLE;
#define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) func = nullptr;
#define NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func)
#include <Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp>
}
}
}
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <Nazara/Core/AntiWindows.hpp>
#endif