mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing release compilation issue
This commit is contained in:
@@ -39,10 +39,10 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
||||||
new_sprite.SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
|
new_sprite.SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
|
||||||
m_current_depth++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sprite->SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
|
sprite->SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
|
||||||
|
m_current_depth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)
|
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace mlx
|
|||||||
public:
|
public:
|
||||||
GPUBuffer() = default;
|
GPUBuffer() = default;
|
||||||
|
|
||||||
void Init(BufferType type, VkDeviceSize size, VkBufferUsageFlags usage, CPUBuffer data, std::string_view debug_name);
|
void Init(BufferType type, VkDeviceSize size, VkBufferUsageFlags usage, CPUBuffer data, [[maybe_unused]] std::string_view debug_name);
|
||||||
void Destroy() noexcept;
|
void Destroy() noexcept;
|
||||||
|
|
||||||
bool CopyFrom(const GPUBuffer& buffer) noexcept;
|
bool CopyFrom(const GPUBuffer& buffer) noexcept;
|
||||||
@@ -43,7 +43,7 @@ namespace mlx
|
|||||||
void* p_map = nullptr;
|
void* p_map = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VmaAllocationCreateInfo alloc_info, std::string_view debug_name);
|
void CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VmaAllocationCreateInfo alloc_info, [[maybe_unused]] std::string_view debug_name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VkBufferUsageFlags m_usage = 0;
|
VkBufferUsageFlags m_usage = 0;
|
||||||
@@ -52,7 +52,7 @@ namespace mlx
|
|||||||
class VertexBuffer : public GPUBuffer
|
class VertexBuffer : public GPUBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline void Init(std::uint32_t size, VkBufferUsageFlags additional_flags, std::string_view debug_name) { GPUBuffer::Init(BufferType::LowDynamic, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | additional_flags, {}, std::move(debug_name)); }
|
inline void Init(std::uint32_t size, VkBufferUsageFlags additional_flags, [[maybe_unused]] std::string_view debug_name) { GPUBuffer::Init(BufferType::LowDynamic, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | additional_flags, {}, std::move(debug_name)); }
|
||||||
void SetData(CPUBuffer data);
|
void SetData(CPUBuffer data);
|
||||||
inline void Bind(VkCommandBuffer cmd) const noexcept { VkDeviceSize offset = 0; RenderCore::Get().vkCmdBindVertexBuffers(cmd, 0, 1, &m_buffer, &offset); }
|
inline void Bind(VkCommandBuffer cmd) const noexcept { VkDeviceSize offset = 0; RenderCore::Get().vkCmdBindVertexBuffers(cmd, 0, 1, &m_buffer, &offset); }
|
||||||
};
|
};
|
||||||
@@ -60,7 +60,7 @@ namespace mlx
|
|||||||
class IndexBuffer : public GPUBuffer
|
class IndexBuffer : public GPUBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline void Init(std::uint32_t size, VkBufferUsageFlags additional_flags, std::string_view debug_name) { GPUBuffer::Init(BufferType::LowDynamic, size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | additional_flags, {}, std::move(debug_name)); }
|
inline void Init(std::uint32_t size, VkBufferUsageFlags additional_flags, [[maybe_unused]] std::string_view debug_name) { GPUBuffer::Init(BufferType::LowDynamic, size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | additional_flags, {}, std::move(debug_name)); }
|
||||||
void SetData(CPUBuffer data);
|
void SetData(CPUBuffer data);
|
||||||
inline void Bind(VkCommandBuffer cmd) const noexcept { RenderCore::Get().vkCmdBindIndexBuffer(cmd, m_buffer, 0, VK_INDEX_TYPE_UINT32); }
|
inline void Bind(VkCommandBuffer cmd) const noexcept { RenderCore::Get().vkCmdBindIndexBuffer(cmd, m_buffer, 0, VK_INDEX_TYPE_UINT32); }
|
||||||
};
|
};
|
||||||
@@ -68,7 +68,7 @@ namespace mlx
|
|||||||
class UniformBuffer
|
class UniformBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Init(std::uint32_t size, std::string_view debug_name);
|
void Init(std::uint32_t size, [[maybe_unused]] std::string_view debug_name);
|
||||||
void SetData(CPUBuffer data, std::size_t frame_index);
|
void SetData(CPUBuffer data, std::size_t frame_index);
|
||||||
void Destroy() noexcept;
|
void Destroy() noexcept;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace mlx
|
|||||||
public:
|
public:
|
||||||
Image() = default;
|
Image() = default;
|
||||||
|
|
||||||
inline void Init(VkImage image, VkFormat format, std::uint32_t width, std::uint32_t height, VkImageLayout layout, std::string_view debug_name) noexcept
|
inline void Init(VkImage image, VkFormat format, std::uint32_t width, std::uint32_t height, VkImageLayout layout, [[maybe_unused]] std::string_view debug_name) noexcept
|
||||||
{
|
{
|
||||||
m_image = image;
|
m_image = image;
|
||||||
m_format = format;
|
m_format = format;
|
||||||
@@ -71,7 +71,7 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DepthImage() = default;
|
DepthImage() = default;
|
||||||
inline void Init(std::uint32_t width, std::uint32_t height, bool is_multisampled, std::string_view debug_name)
|
inline void Init(std::uint32_t width, std::uint32_t height, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
std::vector<VkFormat> candidates = { VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT };
|
std::vector<VkFormat> candidates = { VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT };
|
||||||
@@ -87,12 +87,12 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture() = default;
|
Texture() = default;
|
||||||
Texture(CPUBuffer pixels, std::uint32_t width, std::uint32_t height, VkFormat format, bool is_multisampled, std::string_view debug_name)
|
Texture(CPUBuffer pixels, std::uint32_t width, std::uint32_t height, VkFormat format, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
Init(std::move(pixels), width, height, format, is_multisampled, std::move(debug_name));
|
Init(std::move(pixels), width, height, format, is_multisampled, std::move(debug_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(CPUBuffer pixels, std::uint32_t width, std::uint32_t height, VkFormat format, bool is_multisampled, std::string_view debug_name);
|
void Init(CPUBuffer pixels, std::uint32_t width, std::uint32_t height, VkFormat format, bool is_multisampled, [[maybe_unused]] std::string_view debug_name);
|
||||||
|
|
||||||
void SetPixel(int x, int y, std::uint32_t color) noexcept;
|
void SetPixel(int x, int y, std::uint32_t color) noexcept;
|
||||||
int GetPixel(int x, int y) noexcept;
|
int GetPixel(int x, int y) noexcept;
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
constexpr const int MAX_FRAMES_IN_FLIGHT = 3;
|
constexpr const int MAX_FRAMES_IN_FLIGHT = 3;
|
||||||
|
|
||||||
|
#if defined(DEBUG) && defined(VK_EXT_debug_utils)
|
||||||
|
#define MLX_HAS_DEBUG_UTILS_FUNCTIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
class RenderCore
|
class RenderCore
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -31,12 +35,6 @@ namespace mlx
|
|||||||
#undef MLX_VULKAN_INSTANCE_FUNCTION
|
#undef MLX_VULKAN_INSTANCE_FUNCTION
|
||||||
#undef MLX_VULKAN_DEVICE_FUNCTION
|
#undef MLX_VULKAN_DEVICE_FUNCTION
|
||||||
|
|
||||||
#if defined(DEBUG) && defined(VK_EXT_debug_utils)
|
|
||||||
inline static constexpr bool HAS_DEBUG_UTILS_FUNCTIONS = true;
|
|
||||||
#else
|
|
||||||
inline static constexpr bool HAS_DEBUG_UTILS_FUNCTIONS = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~RenderCore();
|
~RenderCore();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace mlx
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
auto res = m_textures.try_emplace(z, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(z));
|
auto res = m_textures.try_emplace(z, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(z));
|
||||||
#else
|
#else
|
||||||
auto res = m_textures.try_emplace(z, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, {});
|
auto res = m_textures.try_emplace(z, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, std::string_view{});
|
||||||
#endif
|
#endif
|
||||||
res.first->second.SetPixel(x, y, color);
|
res.first->second.SetPixel(x, y, color);
|
||||||
return (res.second ? &res.first->second : nullptr);
|
return (res.second ? &res.first->second : nullptr);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
void GPUBuffer::Init(BufferType type, VkDeviceSize size, VkBufferUsageFlags usage, CPUBuffer data, std::string_view debug_name)
|
void GPUBuffer::Init(BufferType type, VkDeviceSize size, VkBufferUsageFlags usage, CPUBuffer data, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
VmaAllocationCreateInfo alloc_info{};
|
VmaAllocationCreateInfo alloc_info{};
|
||||||
@@ -36,7 +36,7 @@ namespace mlx
|
|||||||
PushToGPU();
|
PushToGPU();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUBuffer::CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VmaAllocationCreateInfo alloc_info, std::string_view debug_name)
|
void GPUBuffer::CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VmaAllocationCreateInfo alloc_info, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
VkBufferCreateInfo bufferInfo{};
|
VkBufferCreateInfo bufferInfo{};
|
||||||
@@ -183,7 +183,7 @@ namespace mlx
|
|||||||
staging.Destroy();
|
staging.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniformBuffer::Init(std::uint32_t size, std::string_view debug_name)
|
void UniformBuffer::Init(std::uint32_t size, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
|
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
void Image::Init(ImageType type, std::uint32_t width, std::uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, bool is_multisampled, std::string_view debug_name)
|
void Image::Init(ImageType type, std::uint32_t width, std::uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
m_type = type;
|
m_type = type;
|
||||||
@@ -56,16 +56,13 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
m_image_view = kvfCreateImageView(RenderCore::Get().GetDevice(), m_image, m_format, type, aspect_flags, layer_count);
|
m_image_view = kvfCreateImageView(RenderCore::Get().GetDevice(), m_image, m_format, type, aspect_flags, layer_count);
|
||||||
#ifdef DEBUG
|
#ifdef MLX_HAS_DEBUG_UTILS_FUNCTIONS
|
||||||
if constexpr(RenderCore::HAS_DEBUG_UTILS_FUNCTIONS)
|
VkDebugUtilsObjectNameInfoEXT name_info{};
|
||||||
{
|
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||||
VkDebugUtilsObjectNameInfoEXT name_info{};
|
name_info.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
|
||||||
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
name_info.objectHandle = reinterpret_cast<std::uint64_t>(m_image_view);
|
||||||
name_info.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
|
name_info.pObjectName = m_debug_name.c_str();
|
||||||
name_info.objectHandle = reinterpret_cast<std::uint64_t>(m_image_view);
|
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
||||||
name_info.pObjectName = m_debug_name.c_str();
|
|
||||||
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +151,7 @@ namespace mlx
|
|||||||
m_image = VK_NULL_HANDLE;
|
m_image = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::Init(CPUBuffer pixels, std::uint32_t width, std::uint32_t height, VkFormat format, bool is_multisampled, std::string_view debug_name)
|
void Texture::Init(CPUBuffer pixels, std::uint32_t width, std::uint32_t height, VkFormat format, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
Image::Init(ImageType::Color, width, height, format, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, is_multisampled, std::move(debug_name));
|
Image::Init(ImageType::Color, width, height, format, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, is_multisampled, std::move(debug_name));
|
||||||
@@ -229,7 +226,11 @@ namespace mlx
|
|||||||
#endif
|
#endif
|
||||||
m_staging_buffer.emplace();
|
m_staging_buffer.emplace();
|
||||||
std::size_t size = m_width * m_height * kvfFormatSize(m_format);
|
std::size_t size = m_width * m_height * kvfFormatSize(m_format);
|
||||||
m_staging_buffer->Init(BufferType::Staging, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, {}, m_debug_name);
|
#ifdef DEBUG
|
||||||
|
m_staging_buffer->Init(BufferType::Staging, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, {}, m_debug_name);
|
||||||
|
#else
|
||||||
|
m_staging_buffer->Init(BufferType::Staging, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, {}, {});
|
||||||
|
#endif
|
||||||
|
|
||||||
VkImageLayout old_layout = m_layout;
|
VkImageLayout old_layout = m_layout;
|
||||||
VkCommandBuffer cmd = kvfCreateCommandBuffer(RenderCore::Get().GetDevice());
|
VkCommandBuffer cmd = kvfCreateCommandBuffer(RenderCore::Get().GetDevice());
|
||||||
|
|||||||
@@ -64,15 +64,14 @@ namespace mlx
|
|||||||
kvfCheckVk(vmaCreateBuffer(m_allocator, binfo, vinfo, &buffer, &allocation, nullptr));
|
kvfCheckVk(vmaCreateBuffer(m_allocator, binfo, vinfo, &buffer, &allocation, nullptr));
|
||||||
if(name != nullptr)
|
if(name != nullptr)
|
||||||
{
|
{
|
||||||
if constexpr(RenderCore::HAS_DEBUG_UTILS_FUNCTIONS)
|
#ifdef MLX_HAS_DEBUG_UTILS_FUNCTIONS
|
||||||
{
|
|
||||||
VkDebugUtilsObjectNameInfoEXT name_info{};
|
VkDebugUtilsObjectNameInfoEXT name_info{};
|
||||||
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||||
name_info.objectType = VK_OBJECT_TYPE_BUFFER;
|
name_info.objectType = VK_OBJECT_TYPE_BUFFER;
|
||||||
name_info.objectHandle = reinterpret_cast<std::uint64_t>(buffer);
|
name_info.objectHandle = reinterpret_cast<std::uint64_t>(buffer);
|
||||||
name_info.pObjectName = name;
|
name_info.pObjectName = name;
|
||||||
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
||||||
}
|
#endif
|
||||||
vmaSetAllocationName(m_allocator, allocation, name);
|
vmaSetAllocationName(m_allocator, allocation, name);
|
||||||
}
|
}
|
||||||
DebugLog("Graphics Allocator : created new buffer '%'", name);
|
DebugLog("Graphics Allocator : created new buffer '%'", name);
|
||||||
@@ -99,15 +98,14 @@ namespace mlx
|
|||||||
kvfCheckVk(vmaCreateImage(m_allocator, iminfo, vinfo, &image, &allocation, nullptr));
|
kvfCheckVk(vmaCreateImage(m_allocator, iminfo, vinfo, &image, &allocation, nullptr));
|
||||||
if(name != nullptr)
|
if(name != nullptr)
|
||||||
{
|
{
|
||||||
if constexpr(RenderCore::HAS_DEBUG_UTILS_FUNCTIONS)
|
#ifdef MLX_HAS_DEBUG_UTILS_FUNCTIONS
|
||||||
{
|
|
||||||
VkDebugUtilsObjectNameInfoEXT name_info{};
|
VkDebugUtilsObjectNameInfoEXT name_info{};
|
||||||
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||||
name_info.objectType = VK_OBJECT_TYPE_IMAGE;
|
name_info.objectType = VK_OBJECT_TYPE_IMAGE;
|
||||||
name_info.objectHandle = reinterpret_cast<std::uint64_t>(image);
|
name_info.objectHandle = reinterpret_cast<std::uint64_t>(image);
|
||||||
name_info.pObjectName = name;
|
name_info.pObjectName = name;
|
||||||
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
||||||
}
|
#endif
|
||||||
vmaSetAllocationName(m_allocator, allocation, name);
|
vmaSetAllocationName(m_allocator, allocation, name);
|
||||||
}
|
}
|
||||||
DebugLog("Graphics Allocator : created new image '%'", name);
|
DebugLog("Graphics Allocator : created new image '%'", name);
|
||||||
|
|||||||
Reference in New Issue
Block a user