Minor fixes

This commit is contained in:
SirLynix 2024-01-13 15:10:53 +01:00 committed by Jérôme Leclercq
parent f45c2c5008
commit 5c7059c8fc
32 changed files with 101 additions and 108 deletions

View File

@ -25,7 +25,7 @@ namespace Nz
OpenGLCommandPool(OpenGLCommandPool&&) noexcept = default; OpenGLCommandPool(OpenGLCommandPool&&) noexcept = default;
~OpenGLCommandPool() = default; ~OpenGLCommandPool() = default;
CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) override; CommandBufferPtr BuildCommandBuffer(const FunctionRef<void(CommandBufferBuilder& builder)>& callback) override;
void UpdateDebugName(std::string_view name) override; void UpdateDebugName(std::string_view name) override;

View File

@ -90,7 +90,7 @@ namespace Nz::GL
EnsureContext(); EnsureContext();
if (m_context->glObjectLabel) if (m_context->glObjectLabel)
m_context->glObjectLabel(ObjectType, m_objectId, SafeCast<GLsizei>(name.size()), name.data()); m_context->glObjectLabel(ObjectType, m_objectId, SafeCaster(name.size()), name.data());
} }
} }

View File

@ -96,7 +96,7 @@ namespace Nz::GL
const Context& context = EnsureDeviceContext(); const Context& context = EnsureDeviceContext();
if (context.glObjectLabel) if (context.glObjectLabel)
context.glObjectLabel(ObjectType, m_objectId, SafeCast<GLsizei>(name.size()), name.data()); context.glObjectLabel(ObjectType, m_objectId, SafeCaster(name.size()), name.data());
} }
} }

View File

@ -51,7 +51,7 @@ namespace Nz::GL
if (activeUniformCount > 0) if (activeUniformCount > 0)
{ {
uniformIndices.resize(static_cast<std::size_t>(activeUniformCount)); uniformIndices.resize(SafeCaster(activeUniformCount));
context.glGetActiveUniformBlockiv(m_objectId, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, uniformIndices.data()); context.glGetActiveUniformBlockiv(m_objectId, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, uniformIndices.data());
} }

View File

@ -10,7 +10,7 @@
#include <NazaraUtils/Prerequisites.hpp> #include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/Renderer/CommandBuffer.hpp> #include <Nazara/Renderer/CommandBuffer.hpp>
#include <Nazara/Renderer/Config.hpp> #include <Nazara/Renderer/Config.hpp>
#include <functional> #include <NazaraUtils/FunctionRef.hpp>
namespace Nz namespace Nz
{ {
@ -24,7 +24,7 @@ namespace Nz
CommandPool(CommandPool&&) = default; CommandPool(CommandPool&&) = default;
virtual ~CommandPool(); virtual ~CommandPool();
virtual CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) = 0; virtual CommandBufferPtr BuildCommandBuffer(const FunctionRef<void(CommandBufferBuilder& builder)>& callback) = 0;
virtual void UpdateDebugName(std::string_view name) = 0; virtual void UpdateDebugName(std::string_view name) = 0;

View File

@ -28,7 +28,7 @@ namespace Nz
VulkanCommandPool(VulkanCommandPool&&) noexcept = default; VulkanCommandPool(VulkanCommandPool&&) noexcept = default;
~VulkanCommandPool() = default; ~VulkanCommandPool() = default;
CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) override; CommandBufferPtr BuildCommandBuffer(const FunctionRef<void(CommandBufferBuilder& builder)>& callback) override;
void UpdateDebugName(std::string_view name) override; void UpdateDebugName(std::string_view name) override;

View File

@ -97,7 +97,7 @@ namespace Nz
{ {
auto& libcurl = m_webService.GetCurlLibrary(); auto& libcurl = m_webService.GetCurlLibrary();
curl_off_t maxSize = SafeCast<curl_off_t>(maxFileSize); curl_off_t maxSize = SafeCaster(maxFileSize);
libcurl.easy_setopt(m_curlHandle, CURLOPT_MAXFILESIZE_LARGE, maxSize); libcurl.easy_setopt(m_curlHandle, CURLOPT_MAXFILESIZE_LARGE, maxSize);
} }
#else #else

View File

@ -217,7 +217,7 @@ namespace Nz
inline void OpenGLCommandBuffer::Execute(const GL::Context* context, const InsertDebugLabelCommand& command) inline void OpenGLCommandBuffer::Execute(const GL::Context* context, const InsertDebugLabelCommand& command)
{ {
if (context->glDebugMessageInsert) if (context->glDebugMessageInsert)
context->glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION, SafeCast<GLsizei>(command.label.size()), command.label.data()); context->glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION, SafeCaster(command.label.size()), command.label.data());
} }
inline void OpenGLCommandBuffer::Execute(const GL::Context* context, const MemoryBarrier& command) inline void OpenGLCommandBuffer::Execute(const GL::Context* context, const MemoryBarrier& command)
@ -277,7 +277,7 @@ namespace Nz
if (command.framebuffer->GetType() == FramebufferType::Texture) if (command.framebuffer->GetType() == FramebufferType::Texture)
{ {
const OpenGLFboFramebuffer& fboFramebuffer = static_cast<const OpenGLFboFramebuffer&>(*command.framebuffer); const OpenGLFboFramebuffer& fboFramebuffer = SafeCast<const OpenGLFboFramebuffer&>(*command.framebuffer);
invalidateAttachments = NazaraStackVector(GLenum, colorBufferCount + 1); invalidateAttachments = NazaraStackVector(GLenum, colorBufferCount + 1);

View File

@ -10,7 +10,7 @@
namespace Nz namespace Nz
{ {
CommandBufferPtr OpenGLCommandPool::BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) CommandBufferPtr OpenGLCommandPool::BuildCommandBuffer(const FunctionRef<void(CommandBufferBuilder& builder)>& callback)
{ {
CommandBufferPtr commandBuffer; CommandBufferPtr commandBuffer;
for (std::size_t i = 0; i < m_commandPools.size(); ++i) for (std::size_t i = 0; i < m_commandPools.size(); ++i)
@ -30,7 +30,7 @@ namespace Nz
assert(commandBuffer); assert(commandBuffer);
} }
OpenGLCommandBufferBuilder builder(static_cast<OpenGLCommandBuffer&>(*commandBuffer.get())); OpenGLCommandBufferBuilder builder(SafeCast<OpenGLCommandBuffer&>(*commandBuffer.get()));
callback(builder); callback(builder);
return commandBuffer; return commandBuffer;
@ -68,7 +68,7 @@ namespace Nz
void OpenGLCommandPool::Release(CommandBuffer& binding) void OpenGLCommandPool::Release(CommandBuffer& binding)
{ {
OpenGLCommandBuffer& openglBinding = static_cast<OpenGLCommandBuffer&>(binding); OpenGLCommandBuffer& openglBinding = SafeCast<OpenGLCommandBuffer&>(binding);
std::size_t poolIndex = openglBinding.GetPoolIndex(); std::size_t poolIndex = openglBinding.GetPoolIndex();
std::size_t bindingIndex = openglBinding.GetBindingIndex(); std::size_t bindingIndex = openglBinding.GetBindingIndex();

View File

@ -22,14 +22,14 @@ namespace Nz
if (!device.GetEnabledFeatures().computeShaders) if (!device.GetEnabledFeatures().computeShaders)
throw std::runtime_error("compute shaders are not enabled on the device"); throw std::runtime_error("compute shaders are not enabled on the device");
OpenGLRenderPipelineLayout& pipelineLayout = static_cast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout); OpenGLRenderPipelineLayout& pipelineLayout = SafeCast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout);
if (!m_program.Create(device)) if (!m_program.Create(device))
throw std::runtime_error("failed to create program"); throw std::runtime_error("failed to create program");
NazaraAssert(m_pipelineInfo.shaderModule, "invalid shader module"); NazaraAssert(m_pipelineInfo.shaderModule, "invalid shader module");
OpenGLShaderModule& shaderModule = static_cast<OpenGLShaderModule&>(*m_pipelineInfo.shaderModule); OpenGLShaderModule& shaderModule = SafeCast<OpenGLShaderModule&>(*m_pipelineInfo.shaderModule);
std::vector<OpenGLShaderModule::ExplicitBinding> explicitBindings; std::vector<OpenGLShaderModule::ExplicitBinding> explicitBindings;
nzsl::ShaderStageTypeFlags stageFlags = shaderModule.Attach(m_program, pipelineLayout.GetBindingMapping(), &explicitBindings); nzsl::ShaderStageTypeFlags stageFlags = shaderModule.Attach(m_program, pipelineLayout.GetBindingMapping(), &explicitBindings);

View File

@ -91,7 +91,7 @@ namespace Nz
for (std::size_t i = 0; i < m_attachments.size(); ++i) for (std::size_t i = 0; i < m_attachments.size(); ++i)
{ {
assert(m_attachments[i]); assert(m_attachments[i]);
const OpenGLTexture& glTexture = static_cast<const OpenGLTexture&>(*m_attachments[i]); const OpenGLTexture& glTexture = SafeCast<const OpenGLTexture&>(*m_attachments[i]);
PixelFormat textureFormat = glTexture.GetFormat(); PixelFormat textureFormat = glTexture.GetFormat();
@ -187,7 +187,7 @@ namespace Nz
for (std::size_t i = 0; i < m_colorAttachmentCount; ++i) for (std::size_t i = 0; i < m_colorAttachmentCount; ++i)
fboDrawBuffers[i] = GLenum(GL_COLOR_ATTACHMENT0 + i); fboDrawBuffers[i] = GLenum(GL_COLOR_ATTACHMENT0 + i);
framebuffer.DrawBuffers(SafeCast<GLsizei>(m_colorAttachmentCount), fboDrawBuffers.data()); framebuffer.DrawBuffers(SafeCaster(m_colorAttachmentCount), fboDrawBuffers.data());
} }
else else
{ {

View File

@ -46,7 +46,7 @@ namespace Nz
void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags /*queueTypeFlags*/) void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags /*queueTypeFlags*/)
{ {
OpenGLCommandBuffer* oglCommandBuffer = static_cast<OpenGLCommandBuffer*>(commandBuffer); OpenGLCommandBuffer* oglCommandBuffer = SafeCast<OpenGLCommandBuffer*>(commandBuffer);
oglCommandBuffer->Execute(); oglCommandBuffer->Execute();
} }
} }

View File

@ -22,7 +22,7 @@ namespace Nz
{ {
ValidatePipelineInfo(device, m_pipelineInfo); ValidatePipelineInfo(device, m_pipelineInfo);
OpenGLRenderPipelineLayout& pipelineLayout = static_cast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout); OpenGLRenderPipelineLayout& pipelineLayout = SafeCast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout);
if (!m_program.Create(device)) if (!m_program.Create(device))
throw std::runtime_error("failed to create program"); throw std::runtime_error("failed to create program");
@ -38,7 +38,7 @@ namespace Nz
for (const auto& shaderModulePtr : m_pipelineInfo.shaderModules) for (const auto& shaderModulePtr : m_pipelineInfo.shaderModules)
{ {
OpenGLShaderModule& shaderModule = static_cast<OpenGLShaderModule&>(*shaderModulePtr); OpenGLShaderModule& shaderModule = SafeCast<OpenGLShaderModule&>(*shaderModulePtr);
stageFlags |= shaderModule.Attach(m_program, pipelineLayout.GetBindingMapping(), &explicitBindings); stageFlags |= shaderModule.Attach(m_program, pipelineLayout.GetBindingMapping(), &explicitBindings);
} }

View File

@ -138,7 +138,7 @@ namespace Nz
void OpenGLRenderPipelineLayout::Release(ShaderBinding& binding) void OpenGLRenderPipelineLayout::Release(ShaderBinding& binding)
{ {
OpenGLShaderBinding& vulkanBinding = static_cast<OpenGLShaderBinding&>(binding); OpenGLShaderBinding& vulkanBinding = SafeCast<OpenGLShaderBinding&>(binding);
std::size_t poolIndex = vulkanBinding.GetPoolIndex(); std::size_t poolIndex = vulkanBinding.GetPoolIndex();
std::size_t bindingIndex = vulkanBinding.GetBindingIndex(); std::size_t bindingIndex = vulkanBinding.GetBindingIndex();

View File

@ -102,7 +102,7 @@ namespace Nz
storageDescriptor.offset = arg.offset; storageDescriptor.offset = arg.offset;
storageDescriptor.size = arg.range; storageDescriptor.size = arg.range;
if (OpenGLBuffer* glBuffer = static_cast<OpenGLBuffer*>(arg.buffer)) if (OpenGLBuffer* glBuffer = SafeCast<OpenGLBuffer*>(arg.buffer))
{ {
if (glBuffer->GetType() != BufferType::Storage) if (glBuffer->GetType() != BufferType::Storage)
throw std::runtime_error("expected storage buffer"); throw std::runtime_error("expected storage buffer");
@ -115,7 +115,7 @@ namespace Nz
else if constexpr (std::is_same_v<T, TextureBinding>) else if constexpr (std::is_same_v<T, TextureBinding>)
{ {
auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, binding.bindingIndex); auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, binding.bindingIndex);
if (const OpenGLTexture* glTexture = static_cast<const OpenGLTexture*>(arg.texture)) if (const OpenGLTexture* glTexture = SafeCast<const OpenGLTexture*>(arg.texture))
{ {
std::optional<GLTextureFormat> format = DescribeTextureFormat(glTexture->GetFormat()); std::optional<GLTextureFormat> format = DescribeTextureFormat(glTexture->GetFormat());
if (!format) if (!format)
@ -151,7 +151,7 @@ namespace Nz
uboDescriptor.offset = arg.offset; uboDescriptor.offset = arg.offset;
uboDescriptor.size = arg.range; uboDescriptor.size = arg.range;
if (OpenGLBuffer* glBuffer = static_cast<OpenGLBuffer*>(arg.buffer)) if (OpenGLBuffer* glBuffer = SafeCast<OpenGLBuffer*>(arg.buffer))
{ {
if (glBuffer->GetType() != BufferType::Uniform) if (glBuffer->GetType() != BufferType::Uniform)
throw std::runtime_error("expected uniform buffer"); throw std::runtime_error("expected uniform buffer");
@ -177,13 +177,13 @@ namespace Nz
{ {
auto& textureDescriptor = m_owner.GetSampledTextureDescriptor(m_poolIndex, m_bindingIndex, bindingIndex); auto& textureDescriptor = m_owner.GetSampledTextureDescriptor(m_poolIndex, m_bindingIndex, bindingIndex);
if (const OpenGLTexture* glTexture = static_cast<const OpenGLTexture*>(textureBinding.texture)) if (const OpenGLTexture* glTexture = SafeCast<const OpenGLTexture*>(textureBinding.texture))
{ {
// TODO: Add texture view emulation // TODO: Add texture view emulation
textureDescriptor.texture = glTexture->GetTexture().GetObjectId(); textureDescriptor.texture = glTexture->GetTexture().GetObjectId();
if (const OpenGLTextureSampler* glSampler = static_cast<const OpenGLTextureSampler*>(textureBinding.sampler)) if (const OpenGLTextureSampler* glSampler = SafeCast<const OpenGLTextureSampler*>(textureBinding.sampler))
textureDescriptor.sampler = glSampler->GetSampler(glTexture->GetLevelCount() > 1).GetObjectId(); textureDescriptor.sampler = glSampler->GetSampler(glTexture->GetLevelCount() > 1).GetObjectId();
else else
textureDescriptor.sampler = 0; textureDescriptor.sampler = 0;

View File

@ -118,7 +118,7 @@ namespace Nz
bool OpenGLTexture::Copy(const Texture& source, const Boxui& srcBox, const Vector3ui& dstPos) bool OpenGLTexture::Copy(const Texture& source, const Boxui& srcBox, const Vector3ui& dstPos)
{ {
const OpenGLTexture& glTexture = static_cast<const OpenGLTexture&>(source); const OpenGLTexture& glTexture = SafeCast<const OpenGLTexture&>(source);
const GL::Context& context = m_texture.EnsureDeviceContext(); const GL::Context& context = m_texture.EnsureDeviceContext();
return context.CopyTexture(glTexture, *this, srcBox, dstPos); return context.CopyTexture(glTexture, *this, srcBox, dstPos);

View File

@ -312,7 +312,7 @@ namespace Nz::GL
glClearDepthf = [](GLfloat depth) glClearDepthf = [](GLfloat depth)
{ {
const EGLContextBase* context = static_cast<const EGLContextBase*>(GetCurrentContext()); const EGLContextBase* context = SafeCast<const EGLContextBase*>(GetCurrentContext());
assert(context); assert(context);
context->fallbacks.glClearDepth(depth); context->fallbacks.glClearDepth(depth);
}; };

View File

@ -143,7 +143,7 @@ namespace Nz::GL
context = std::make_shared<EGLContextBase>(device, *this); context = std::make_shared<EGLContextBase>(device, *this);
#endif #endif
if (!context->Create(params, static_cast<EGLContextBase*>(shareContext))) if (!context->Create(params, SafeCast<EGLContextBase*>(shareContext)))
{ {
NazaraError("failed to create context"); NazaraError("failed to create context");
return {}; return {};
@ -193,7 +193,7 @@ namespace Nz::GL
return {}; return {};
} }
if (!context->Create(params, handle, static_cast<EGLContextBase*>(shareContext))) if (!context->Create(params, handle, SafeCast<EGLContextBase*>(shareContext)))
{ {
NazaraError("failed to create context"); NazaraError("failed to create context");
return {}; return {};

View File

@ -254,7 +254,7 @@ namespace Nz::GL
glClearDepthf = [](GLfloat depth) glClearDepthf = [](GLfloat depth)
{ {
const WGLContext* context = static_cast<const WGLContext*>(GetCurrentContext()); const WGLContext* context = SafeCast<const WGLContext*>(GetCurrentContext());
assert(context); assert(context);
context->fallbacks.glClearDepth(depth); context->fallbacks.glClearDepth(depth);
}; };
@ -328,7 +328,7 @@ namespace Nz::GL
int pixelFormat = 0; int pixelFormat = 0;
if (m_params.sampleCount > 1) if (m_params.sampleCount > 1)
{ {
const WGLContext* currentContext = static_cast<const WGLContext*>(GetCurrentContext()); //< Pay TLS cost only once const WGLContext* currentContext = SafeCast<const WGLContext*>(GetCurrentContext()); //< Pay TLS cost only once
if (currentContext) if (currentContext)
{ {
// WGL_ARB_pixel_format and WGL_EXT_pixel_format are the same, except for the symbol // WGL_ARB_pixel_format and WGL_EXT_pixel_format are the same, except for the symbol

View File

@ -96,7 +96,7 @@ namespace Nz::GL
std::shared_ptr<Context> WGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const std::shared_ptr<Context> WGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const
{ {
auto context = std::make_shared<WGLContext>(device, *this); auto context = std::make_shared<WGLContext>(device, *this);
if (!context->Create(&m_baseContext, params, static_cast<WGLContext*>(shareContext))) if (!context->Create(&m_baseContext, params, SafeCast<WGLContext*>(shareContext)))
{ {
NazaraError("failed to create context"); NazaraError("failed to create context");
return {}; return {};
@ -114,7 +114,7 @@ namespace Nz::GL
std::shared_ptr<Context> WGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const std::shared_ptr<Context> WGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const
{ {
auto context = std::make_shared<WGLContext>(device, *this); auto context = std::make_shared<WGLContext>(device, *this);
if (!context->Create(&m_baseContext, params, handle, static_cast<WGLContext*>(shareContext))) if (!context->Create(&m_baseContext, params, handle, SafeCast<WGLContext*>(shareContext)))
{ {
NazaraError("failed to create context"); NazaraError("failed to create context");
return {}; return {};

View File

@ -88,7 +88,7 @@ namespace Nz
for (auto& drawCall : m_drawCalls) for (auto& drawCall : m_drawCalls)
{ {
builder.BindVertexBuffer(0, *drawCall.vertexBuffer); builder.BindVertexBuffer(0, *drawCall.vertexBuffer);
builder.Draw(SafeCast<UInt32>(drawCall.vertexCount)); builder.Draw(SafeCaster(drawCall.vertexCount));
} }
} }

View File

@ -9,6 +9,7 @@
#include <Nazara/Core/Log.hpp> #include <Nazara/Core/Log.hpp>
#include <Nazara/Renderer/RendererImpl.hpp> #include <Nazara/Renderer/RendererImpl.hpp>
#include <NazaraUtils/EnumArray.hpp> #include <NazaraUtils/EnumArray.hpp>
#include <NazaraUtils/TypeTraits.hpp>
#include <frozen/string.h> #include <frozen/string.h>
#include <frozen/unordered_map.h> #include <frozen/unordered_map.h>
#include <filesystem> #include <filesystem>
@ -80,10 +81,12 @@ namespace Nz
void Renderer::LoadBackend(const Config& config) void Renderer::LoadBackend(const Config& config)
{ {
using FactoryFunc = FunctionPtr<std::unique_ptr<RendererImpl>()>;
struct RendererImplementations struct RendererImplementations
{ {
#ifdef NAZARA_RENDERER_EMBEDDEDBACKENDS #ifdef NAZARA_RENDERER_EMBEDDEDBACKENDS
std::function<std::unique_ptr<RendererImpl>()> factory; FactoryFunc factory;
#else #else
std::filesystem::path fileName; std::filesystem::path fileName;
#endif #endif
@ -97,20 +100,20 @@ namespace Nz
preferredAPI = RenderAPI::OpenGL; preferredAPI = RenderAPI::OpenGL;
#ifdef NAZARA_RENDERER_EMBEDDEDBACKENDS #ifdef NAZARA_RENDERER_EMBEDDEDBACKENDS
auto RegisterImpl = [&](RenderAPI api, auto ComputeScore, std::function<std::unique_ptr<RendererImpl>()> factory) auto RegisterImpl = [&]<typename T>(RenderAPI api, auto ComputeScore, TypeTag<T> RendererTag)
{ {
int score = ComputeScore(); int score = ComputeScore();
if (score >= 0) if (score >= 0)
{ {
auto& impl = implementations.emplace_back(); auto& impl = implementations.emplace_back();
impl.factory = std::move(factory); impl.factory = []() -> std::unique_ptr<RendererImpl> { return std::make_unique<T>(); };
impl.score = (preferredAPI == api) ? std::numeric_limits<int>::max() : score; impl.score = (preferredAPI == api) ? std::numeric_limits<int>::max() : score;
} }
}; };
RegisterImpl(RenderAPI::OpenGL, [] { return 50; }, [] { return std::make_unique<OpenGLRenderer>(); }); RegisterImpl(RenderAPI::OpenGL, [] { return 50; }, TypeTag<OpenGLRenderer>{});
#ifndef NAZARA_PLATFORM_WEB #ifndef NAZARA_PLATFORM_WEB
RegisterImpl(RenderAPI::Vulkan, [] { return 100; }, [] { return std::make_unique<VulkanRenderer>(); }); RegisterImpl(RenderAPI::Vulkan, [] { return 100; }, TypeTag<VulkanRenderer>{});
#endif #endif
#else #else
@ -202,7 +205,7 @@ namespace Nz
m_rendererLib = std::move(chosenLib); m_rendererLib = std::move(chosenLib);
#endif #endif
NazaraDebug("Using " + m_rendererImpl->QueryAPIString() + " as renderer"); NazaraDebug("Using {0} as renderer", m_rendererImpl->QueryAPIString());
} }
Renderer* Renderer::s_instance = nullptr; Renderer* Renderer::s_instance = nullptr;

View File

@ -144,11 +144,11 @@ namespace Nz
std::string appName = parameters.GetStringParameter("VkAppInfo_OverrideApplicationName").GetValueOr("Another application made with Nazara Engine"); std::string appName = parameters.GetStringParameter("VkAppInfo_OverrideApplicationName").GetValueOr("Another application made with Nazara Engine");
std::string engineName = parameters.GetStringParameter("VkAppInfo_OverrideEngineName").GetValueOr("Nazara Engine - Vulkan Renderer"); std::string engineName = parameters.GetStringParameter("VkAppInfo_OverrideEngineName").GetValueOr("Nazara Engine - Vulkan Renderer");
UInt32 appVersion = SafeCast<UInt32>(parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion").GetValueOr(VK_MAKE_API_VERSION(0, 1, 0, 0))); UInt32 appVersion = SafeCaster(parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion").GetValueOr(VK_MAKE_API_VERSION(0, 1, 0, 0)));
UInt32 engineVersion = SafeCast<UInt32>(parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion").GetValueOr(VK_MAKE_API_VERSION(0, 1, 0, 0))); UInt32 engineVersion = SafeCaster(parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion").GetValueOr(VK_MAKE_API_VERSION(0, 1, 0, 0)));
if (auto result = parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion")) if (auto result = parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion"))
targetApiVersion = SafeCast<UInt32>(result.GetValue()); targetApiVersion = SafeCaster(result.GetValue());
if (Vk::Loader::vkEnumerateInstanceVersion) if (Vk::Loader::vkEnumerateInstanceVersion)
{ {
@ -171,7 +171,7 @@ namespace Nz
targetApiVersion targetApiVersion
}; };
VkInstanceCreateFlags createFlags = SafeCast<VkInstanceCreateFlags>(parameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags").GetValueOr(0)); VkInstanceCreateFlags createFlags = SafeCaster(parameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags").GetValueOr(0));
std::vector<const char*> enabledLayers; std::vector<const char*> enabledLayers;

View File

@ -11,7 +11,7 @@
namespace Nz namespace Nz
{ {
CommandBufferPtr VulkanCommandPool::BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) CommandBufferPtr VulkanCommandPool::BuildCommandBuffer(const FunctionRef<void(CommandBufferBuilder& builder)>& callback)
{ {
Vk::AutoCommandBuffer commandBuffer = m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); Vk::AutoCommandBuffer commandBuffer = m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY);
@ -57,7 +57,7 @@ namespace Nz
void VulkanCommandPool::Release(CommandBuffer& binding) void VulkanCommandPool::Release(CommandBuffer& binding)
{ {
VulkanCommandBuffer& vulkanBinding = static_cast<VulkanCommandBuffer&>(binding); VulkanCommandBuffer& vulkanBinding = SafeCast<VulkanCommandBuffer&>(binding);
std::size_t poolIndex = vulkanBinding.GetPoolIndex(); std::size_t poolIndex = vulkanBinding.GetPoolIndex();
std::size_t bindingIndex = vulkanBinding.GetBindingIndex(); std::size_t bindingIndex = vulkanBinding.GetBindingIndex();

View File

@ -19,7 +19,7 @@ namespace Nz
if (!device.GetEnabledFeatures().computeShaders) if (!device.GetEnabledFeatures().computeShaders)
throw std::runtime_error("compute shaders are not enabled on the device"); throw std::runtime_error("compute shaders are not enabled on the device");
VulkanShaderModule& vulkanModule = static_cast<VulkanShaderModule&>(*m_pipelineInfo.shaderModule); VulkanShaderModule& vulkanModule = SafeCast<VulkanShaderModule&>(*m_pipelineInfo.shaderModule);
const VulkanShaderModule::Stage* computeStage = nullptr; const VulkanShaderModule::Stage* computeStage = nullptr;
for (const auto& stage : vulkanModule.GetStages()) for (const auto& stage : vulkanModule.GetStages())
{ {
@ -42,7 +42,7 @@ namespace Nz
createInfo.stage.pName = computeStage->name.data(); createInfo.stage.pName = computeStage->name.data();
createInfo.stage.stage = ToVulkan(computeStage->stage); createInfo.stage.stage = ToVulkan(computeStage->stage);
VulkanRenderPipelineLayout& pipelineLayout = *static_cast<VulkanRenderPipelineLayout*>(m_pipelineInfo.pipelineLayout.get()); VulkanRenderPipelineLayout& pipelineLayout = *SafeCast<VulkanRenderPipelineLayout*>(m_pipelineInfo.pipelineLayout.get());
createInfo.layout = pipelineLayout.GetPipelineLayout(); createInfo.layout = pipelineLayout.GetPipelineLayout();
if (!m_pipeline.CreateCompute(device, createInfo)) if (!m_pipeline.CreateCompute(device, createInfo))

View File

@ -74,7 +74,7 @@ namespace Nz
void VulkanRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) void VulkanRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags)
{ {
VulkanCommandBuffer& vkCommandBuffer = *static_cast<VulkanCommandBuffer*>(commandBuffer); VulkanCommandBuffer& vkCommandBuffer = *SafeCast<VulkanCommandBuffer*>(commandBuffer);
return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(), queueTypeFlags); return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(), queueTypeFlags);
} }

View File

@ -205,7 +205,7 @@ namespace Nz
{ {
assert(stagePtr); assert(stagePtr);
VulkanShaderModule& vulkanModule = static_cast<VulkanShaderModule&>(*stagePtr); VulkanShaderModule& vulkanModule = SafeCast<VulkanShaderModule&>(*stagePtr);
for (auto& stage : vulkanModule.GetStages()) for (auto& stage : vulkanModule.GetStages())
{ {
VkPipelineShaderStageCreateInfo& createInfo = shaderStageCreateInfos.emplace_back(); VkPipelineShaderStageCreateInfo& createInfo = shaderStageCreateInfos.emplace_back();
@ -227,7 +227,7 @@ namespace Nz
for (const auto& bufferData : pipelineInfo.vertexBuffers) for (const auto& bufferData : pipelineInfo.vertexBuffers)
{ {
std::uint32_t binding = std::uint32_t(bufferData.binding); std::uint32_t binding = SafeCaster(bufferData.binding);
for (const auto& componentInfo : bufferData.declaration->GetComponents()) for (const auto& componentInfo : bufferData.declaration->GetComponents())
{ {
@ -237,7 +237,7 @@ namespace Nz
auto& bufferAttribute = vertexAttributes.emplace_back(); auto& bufferAttribute = vertexAttributes.emplace_back();
bufferAttribute.binding = binding; bufferAttribute.binding = binding;
bufferAttribute.location = locationIndex++; bufferAttribute.location = locationIndex++;
bufferAttribute.offset = std::uint32_t(componentInfo.offset); bufferAttribute.offset = SafeCaster(componentInfo.offset);
bufferAttribute.format = ToVulkan(componentInfo.type); bufferAttribute.format = ToVulkan(componentInfo.type);
} }
} }
@ -252,8 +252,8 @@ namespace Nz
for (const auto& bufferData : pipelineInfo.vertexBuffers) for (const auto& bufferData : pipelineInfo.vertexBuffers)
{ {
auto& bufferBinding = vertexBindings.emplace_back(); auto& bufferBinding = vertexBindings.emplace_back();
bufferBinding.binding = std::uint32_t(bufferData.binding); bufferBinding.binding = SafeCaster(bufferData.binding);
bufferBinding.stride = std::uint32_t(bufferData.declaration->GetStride()); bufferBinding.stride = SafeCaster(bufferData.declaration->GetStride());
bufferBinding.inputRate = ToVulkan(bufferData.declaration->GetInputRate()); bufferBinding.inputRate = ToVulkan(bufferData.declaration->GetInputRate());
} }
@ -265,10 +265,10 @@ namespace Nz
VkPipelineVertexInputStateCreateInfo createInfo = {}; VkPipelineVertexInputStateCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
createInfo.vertexAttributeDescriptionCount = std::uint32_t(vertexAttributes.size()); createInfo.vertexAttributeDescriptionCount = SafeCaster(vertexAttributes.size());
createInfo.pVertexAttributeDescriptions = vertexAttributes.data(); createInfo.pVertexAttributeDescriptions = vertexAttributes.data();
createInfo.vertexBindingDescriptionCount = std::uint32_t(bindingDescriptions.size()); createInfo.vertexBindingDescriptionCount = SafeCaster(bindingDescriptions.size());
createInfo.pVertexBindingDescriptions = bindingDescriptions.data(); createInfo.pVertexBindingDescriptions = bindingDescriptions.data();
return createInfo; return createInfo;
@ -295,7 +295,7 @@ namespace Nz
createInfo.stateData->vertexInputState = BuildVertexInputInfo(pipelineInfo, createInfo.vertexAttributesDescription, createInfo.vertexBindingDescription); createInfo.stateData->vertexInputState = BuildVertexInputInfo(pipelineInfo, createInfo.vertexAttributesDescription, createInfo.vertexBindingDescription);
createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); createInfo.pipelineInfo.stageCount = SafeCaster(createInfo.shaderStages.size());
createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); createInfo.pipelineInfo.pStages = createInfo.shaderStages.data();
createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState; createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState;
createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState; createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState;
@ -306,7 +306,7 @@ namespace Nz
createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState; createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState;
createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState; createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState;
VulkanRenderPipelineLayout& pipelineLayout = *static_cast<VulkanRenderPipelineLayout*>(pipelineInfo.pipelineLayout.get()); VulkanRenderPipelineLayout& pipelineLayout = *SafeCast<VulkanRenderPipelineLayout*>(pipelineInfo.pipelineLayout.get());
createInfo.pipelineInfo.layout = pipelineLayout.GetPipelineLayout(); createInfo.pipelineInfo.layout = pipelineLayout.GetPipelineLayout();
return createInfo; return createInfo;

View File

@ -20,7 +20,7 @@ namespace Nz
for (auto& pool : m_descriptorPools) for (auto& pool : m_descriptorPools)
{ {
if (!pool.freeBindings.TestAll()) if (!pool.freeBindings.TestAll())
NazaraWarning("Not all ShaderBinding have been released!"); NazaraWarning("not all ShaderBinding have been released!");
} }
} }
@ -43,7 +43,7 @@ namespace Nz
ShaderBindingPtr bindingPtr = AllocateFromPool(newPoolIndex, setIndex); ShaderBindingPtr bindingPtr = AllocateFromPool(newPoolIndex, setIndex);
if (!bindingPtr) if (!bindingPtr)
throw std::runtime_error("Failed to allocate shader binding"); throw std::runtime_error("failed to allocate shader binding");
return bindingPtr; return bindingPtr;
} }
@ -81,7 +81,7 @@ namespace Nz
setLayouts[i] = *m_descriptorSetLayouts[i]; setLayouts[i] = *m_descriptorSetLayouts[i];
} }
if (!m_pipelineLayout.Create(*m_device, UInt32(setLayouts.size()), setLayouts.data())) if (!m_pipelineLayout.Create(*m_device, SafeCaster(setLayouts.size()), setLayouts.data()))
return false; return false;
return true; return true;
@ -108,7 +108,7 @@ namespace Nz
DescriptorPool pool; DescriptorPool pool;
pool.descriptorPool = std::make_unique<Vk::DescriptorPool>(); pool.descriptorPool = std::make_unique<Vk::DescriptorPool>();
if (!pool.descriptorPool->Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) if (!pool.descriptorPool->Create(*m_device, MaxSet, SafeCaster(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT))
throw std::runtime_error("failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode())); throw std::runtime_error("failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode()));
pool.freeBindings.Resize(MaxSet, true); pool.freeBindings.Resize(MaxSet, true);
@ -128,7 +128,7 @@ namespace Nz
Vk::DescriptorSet descriptorSet = pool.descriptorPool->AllocateDescriptorSet(*m_descriptorSetLayouts[setIndex]); Vk::DescriptorSet descriptorSet = pool.descriptorPool->AllocateDescriptorSet(*m_descriptorSetLayouts[setIndex]);
if (!descriptorSet) if (!descriptorSet)
{ {
NazaraWarning("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode())); NazaraWarningFmt("failed to allocate descriptor set: {}", TranslateVulkanError(pool.descriptorPool->GetLastErrorCode()));
return {}; return {};
} }
@ -140,7 +140,7 @@ namespace Nz
void VulkanRenderPipelineLayout::Release(ShaderBinding& binding) void VulkanRenderPipelineLayout::Release(ShaderBinding& binding)
{ {
VulkanShaderBinding& vulkanBinding = static_cast<VulkanShaderBinding&>(binding); VulkanShaderBinding& vulkanBinding = SafeCast<VulkanShaderBinding&>(binding);
std::size_t poolIndex = vulkanBinding.GetPoolIndex(); std::size_t poolIndex = vulkanBinding.GetPoolIndex();
std::size_t bindingIndex = vulkanBinding.GetBindingIndex(); std::size_t bindingIndex = vulkanBinding.GetBindingIndex();

View File

@ -117,7 +117,7 @@ namespace Nz
} }
else if constexpr (std::is_same_v<T, UniformBufferBinding>) else if constexpr (std::is_same_v<T, UniformBufferBinding>)
{ {
VulkanBuffer* vkBuffer = static_cast<VulkanBuffer*>(arg.buffer); VulkanBuffer* vkBuffer = SafeCast<VulkanBuffer*>(arg.buffer);
VkDescriptorBufferInfo& bufferInfo = bufferBinding.emplace_back(); VkDescriptorBufferInfo& bufferInfo = bufferBinding.emplace_back();
bufferInfo.buffer = (vkBuffer) ? vkBuffer->GetBuffer() : VK_NULL_HANDLE; bufferInfo.buffer = (vkBuffer) ? vkBuffer->GetBuffer() : VK_NULL_HANDLE;

View File

@ -304,42 +304,32 @@ namespace Nz
bool VulkanTexture::Copy(const Texture& source, const Boxui& srcBox, const Vector3ui& dstPos) bool VulkanTexture::Copy(const Texture& source, const Boxui& srcBox, const Vector3ui& dstPos)
{ {
const VulkanTexture& sourceTexture = static_cast<const VulkanTexture&>(source); const VulkanTexture& sourceTexture = SafeCast<const VulkanTexture&>(source);
Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Graphics); Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Graphics);
if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT))
return false; return false;
VkImageSubresourceLayers subresourceLayers = { //< FIXME VkImageSubresourceLayers srcSubresourceLayers = sourceTexture.BuildSubresourceLayers(0);
VK_IMAGE_ASPECT_COLOR_BIT, VkImageSubresourceRange srcSubresourceRange = sourceTexture.BuildSubresourceRange(0, 1);
0, //< mipLevel VkImageSubresourceLayers dstSubresourceLayers = BuildSubresourceLayers(0);
0, //< baseArrayLayer VkImageSubresourceRange dstSubresourceRange = BuildSubresourceRange(0, 1);
1 //< layerCount
};
VkImageSubresourceRange subresourceRange = { //< FIXME
VK_IMAGE_ASPECT_COLOR_BIT,
0, //< baseMipLevel
1, //< levelCount
subresourceLayers.baseArrayLayer, //< baseArrayLayer
subresourceLayers.layerCount //< layerCount
};
VkImageCopy region = { VkImageCopy region = {
subresourceLayers, .srcSubresource = srcSubresourceLayers,
VkOffset3D { static_cast<Int32>(srcBox.x), static_cast<Int32>(srcBox.y), static_cast<Int32>(srcBox.z) }, .srcOffset = VkOffset3D { SafeCast<Int32>(srcBox.x), SafeCast<Int32>(srcBox.y), SafeCast<Int32>(srcBox.z) },
subresourceLayers, .dstSubresource = dstSubresourceLayers,
VkOffset3D { static_cast<Int32>(dstPos.x), static_cast<Int32>(dstPos.y), static_cast<Int32>(dstPos.z) }, .dstOffset = VkOffset3D { SafeCast<Int32>(dstPos.x), SafeCast<Int32>(dstPos.y), SafeCast<Int32>(dstPos.z) },
VkExtent3D { static_cast<UInt32>(srcBox.width), static_cast<UInt32>(srcBox.height), static_cast<UInt32>(srcBox.depth) } .extent = VkExtent3D { SafeCast<UInt32>(srcBox.width), SafeCast<UInt32>(srcBox.height), SafeCast<UInt32>(srcBox.depth) }
}; };
copyCommandBuffer->SetImageLayout(sourceTexture.GetImage(), VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, subresourceRange); copyCommandBuffer->SetImageLayout(sourceTexture.GetImage(), VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, srcSubresourceRange);
copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subresourceRange); copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, dstSubresourceRange);
copyCommandBuffer->CopyImage(sourceTexture.GetImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, region); copyCommandBuffer->CopyImage(sourceTexture.GetImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, region);
copyCommandBuffer->SetImageLayout(sourceTexture.GetImage(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, subresourceRange); copyCommandBuffer->SetImageLayout(sourceTexture.GetImage(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, srcSubresourceRange);
copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, subresourceRange); copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, dstSubresourceRange);
if (!copyCommandBuffer->End()) if (!copyCommandBuffer->End())
return false; return false;
@ -455,14 +445,14 @@ namespace Nz
VkImageSubresourceLayers subresourceLayers = BuildSubresourceLayers(level, baseLayer, layerCount); VkImageSubresourceLayers subresourceLayers = BuildSubresourceLayers(level, baseLayer, layerCount);
VkBufferImageCopy region = { VkBufferImageCopy region = {
0, .bufferOffset = 0,
0, .bufferRowLength = 0,
0, .bufferImageHeight = 0,
subresourceLayers, .imageSubresource = subresourceLayers,
{ // imageOffset .imageOffset = {
SafeCast<Int32>(copyBox.x), SafeCast<Int32>(copyBox.y), SafeCast<Int32>(copyBox.z) SafeCast<Int32>(copyBox.x), SafeCast<Int32>(copyBox.y), SafeCast<Int32>(copyBox.z)
}, },
{ // imageExtent .imageExtent = {
copyBox.width, copyBox.height, copyBox.depth copyBox.width, copyBox.height, copyBox.depth
} }
}; };

View File

@ -15,27 +15,27 @@ namespace Nz
VulkanFramebuffer(FramebufferType::Texture) VulkanFramebuffer(FramebufferType::Texture)
{ {
assert(renderPass); assert(renderPass);
const VulkanRenderPass& vkRenderPass = static_cast<const VulkanRenderPass&>(*renderPass); const VulkanRenderPass& vkRenderPass = SafeCast<const VulkanRenderPass&>(*renderPass);
StackArray<VkImageView> imageViews = NazaraStackArrayNoInit(VkImageView, attachments.size()); StackArray<VkImageView> imageViews = NazaraStackArrayNoInit(VkImageView, attachments.size());
for (std::size_t i = 0; i < attachments.size(); ++i) for (std::size_t i = 0; i < attachments.size(); ++i)
{ {
assert(attachments[i]); assert(attachments[i]);
const VulkanTexture& vkTexture = static_cast<const VulkanTexture&>(*attachments[i]); const VulkanTexture& vkTexture = SafeCast<const VulkanTexture&>(*attachments[i]);
imageViews[i] = vkTexture.GetImageView(); imageViews[i] = vkTexture.GetImageView();
} }
VkFramebufferCreateInfo createInfo = { VkFramebufferCreateInfo createInfo = {
VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
nullptr, .pNext = nullptr,
0, .flags = 0,
vkRenderPass.GetRenderPass(), .renderPass = vkRenderPass.GetRenderPass(),
UInt32(imageViews.size()), .attachmentCount = UInt32(imageViews.size()),
imageViews.data(), .pAttachments = imageViews.data(),
UInt32(width), .width = UInt32(width),
UInt32(height), .height = UInt32(height),
1 .layers = 1
}; };
if (!m_framebuffer.Create(device, createInfo)) if (!m_framebuffer.Create(device, createInfo))

View File

@ -263,7 +263,7 @@ end
add_repositories("nazara-engine-repo https://github.com/NazaraEngine/xmake-repo") add_repositories("nazara-engine-repo https://github.com/NazaraEngine/xmake-repo")
add_requires("entt 3.12.2", "fmt", "frozen", "nazarautils >=2024.01.02") add_requires("entt 3.12.2", "fmt", "frozen", "nazarautils >=2024.01.13")
-- Module dependencies -- Module dependencies
if has_config("audio") then if has_config("audio") then