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

@@ -217,7 +217,7 @@ namespace Nz
inline void OpenGLCommandBuffer::Execute(const GL::Context* context, const InsertDebugLabelCommand& command)
{
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)
@@ -277,7 +277,7 @@ namespace Nz
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);

View File

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

View File

@@ -22,14 +22,14 @@ namespace Nz
if (!device.GetEnabledFeatures().computeShaders)
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))
throw std::runtime_error("failed to create program");
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;
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)
{
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();
@@ -187,7 +187,7 @@ namespace Nz
for (std::size_t i = 0; i < m_colorAttachmentCount; ++i)
fboDrawBuffers[i] = GLenum(GL_COLOR_ATTACHMENT0 + i);
framebuffer.DrawBuffers(SafeCast<GLsizei>(m_colorAttachmentCount), fboDrawBuffers.data());
framebuffer.DrawBuffers(SafeCaster(m_colorAttachmentCount), fboDrawBuffers.data());
}
else
{

View File

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

View File

@@ -22,7 +22,7 @@ namespace Nz
{
ValidatePipelineInfo(device, m_pipelineInfo);
OpenGLRenderPipelineLayout& pipelineLayout = static_cast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout);
OpenGLRenderPipelineLayout& pipelineLayout = SafeCast<OpenGLRenderPipelineLayout&>(*m_pipelineInfo.pipelineLayout);
if (!m_program.Create(device))
throw std::runtime_error("failed to create program");
@@ -38,7 +38,7 @@ namespace Nz
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);
}

View File

@@ -138,7 +138,7 @@ namespace Nz
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 bindingIndex = vulkanBinding.GetBindingIndex();

View File

@@ -102,7 +102,7 @@ namespace Nz
storageDescriptor.offset = arg.offset;
storageDescriptor.size = arg.range;
if (OpenGLBuffer* glBuffer = static_cast<OpenGLBuffer*>(arg.buffer))
if (OpenGLBuffer* glBuffer = SafeCast<OpenGLBuffer*>(arg.buffer))
{
if (glBuffer->GetType() != BufferType::Storage)
throw std::runtime_error("expected storage buffer");
@@ -115,7 +115,7 @@ namespace Nz
else if constexpr (std::is_same_v<T, TextureBinding>)
{
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());
if (!format)
@@ -151,7 +151,7 @@ namespace Nz
uboDescriptor.offset = arg.offset;
uboDescriptor.size = arg.range;
if (OpenGLBuffer* glBuffer = static_cast<OpenGLBuffer*>(arg.buffer))
if (OpenGLBuffer* glBuffer = SafeCast<OpenGLBuffer*>(arg.buffer))
{
if (glBuffer->GetType() != BufferType::Uniform)
throw std::runtime_error("expected uniform buffer");
@@ -177,13 +177,13 @@ namespace Nz
{
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
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();
else
textureDescriptor.sampler = 0;

View File

@@ -118,7 +118,7 @@ namespace Nz
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();
return context.CopyTexture(glTexture, *this, srcBox, dstPos);

View File

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

View File

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

View File

@@ -254,7 +254,7 @@ namespace Nz::GL
glClearDepthf = [](GLfloat depth)
{
const WGLContext* context = static_cast<const WGLContext*>(GetCurrentContext());
const WGLContext* context = SafeCast<const WGLContext*>(GetCurrentContext());
assert(context);
context->fallbacks.glClearDepth(depth);
};
@@ -328,7 +328,7 @@ namespace Nz::GL
int pixelFormat = 0;
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)
{
// 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
{
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");
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
{
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");
return {};