Prefer [[maybe_unused]] over UNUSED2

`[[maybe_unused]]` is in the C++ standard.
This commit is contained in:
phosit
2025-05-21 12:29:47 +02:00
committed by Phosit
parent 5be02743fa
commit eb3f0166f8
27 changed files with 83 additions and 196 deletions
+1 -3
View File
@@ -59,7 +59,7 @@ GLenum GetTargetFromBufferType(const IBuffer::Type type)
// static
std::unique_ptr<CBuffer> CBuffer::Create(
CDevice* device, const char* name,
CDevice* device, [[maybe_unused]] const char* name,
const Type type, const uint32_t size, const uint32_t usage)
{
ENSURE(type == Type::VERTEX || type == Type::INDEX || type == Type::UNIFORM);
@@ -77,8 +77,6 @@ std::unique_ptr<CBuffer> CBuffer::Create(
{
glObjectLabel(GL_BUFFER, buffer->m_Handle, -1, name);
}
#else
UNUSED2(name);
#endif
glBindBufferARB(target, 0);
return buffer;
@@ -864,18 +864,13 @@ void CDeviceCommandContext::SetGraphicsPipelineStateImpl(
void CDeviceCommandContext::BlitFramebuffer(
IFramebuffer* srcFramebuffer, IFramebuffer* dstFramebuffer,
const Rect& sourceRegion, const Rect& destinationRegion,
const Sampler::Filter filter)
[[maybe_unused]] const Rect& sourceRegion, [[maybe_unused]] const Rect& destinationRegion,
[[maybe_unused]] const Sampler::Filter filter)
{
ENSURE(!m_InsideFramebufferPass);
CFramebuffer* destinationFramebuffer = dstFramebuffer->As<CFramebuffer>();
CFramebuffer* sourceFramebuffer = srcFramebuffer->As<CFramebuffer>();
[[maybe_unused]] CFramebuffer* destinationFramebuffer = dstFramebuffer->As<CFramebuffer>();
[[maybe_unused]] CFramebuffer* sourceFramebuffer = srcFramebuffer->As<CFramebuffer>();
#if CONFIG2_GLES
UNUSED2(destinationFramebuffer);
UNUSED2(sourceFramebuffer);
UNUSED2(destinationRegion);
UNUSED2(sourceRegion);
UNUSED2(filter);
debug_warn("CDeviceCommandContext::BlitFramebuffer is not implemented for GLES");
#else
// Source framebuffer should not be backbuffer.
@@ -1188,7 +1183,7 @@ void CDeviceCommandContext::DrawIndexed(
}
void CDeviceCommandContext::DrawInstanced(
const uint32_t firstVertex, const uint32_t vertexCount,
[[maybe_unused]] const uint32_t firstVertex, const uint32_t vertexCount,
const uint32_t firstInstance, const uint32_t instanceCount)
{
ENSURE(m_Device->GetCapabilities().instancing);
@@ -1200,7 +1195,6 @@ void CDeviceCommandContext::DrawInstanced(
m_ShaderProgram->AssertPointersBound();
#if CONFIG2_GLES
ENSURE(!m_Device->GetCapabilities().instancing);
UNUSED2(firstVertex);
#else
glDrawArraysInstancedARB(GL_TRIANGLES, firstVertex, vertexCount, instanceCount);
#endif
@@ -1209,7 +1203,7 @@ void CDeviceCommandContext::DrawInstanced(
void CDeviceCommandContext::DrawIndexedInstanced(
const uint32_t firstIndex, const uint32_t indexCount,
const uint32_t firstInstance, const uint32_t instanceCount,
const uint32_t firstInstance, [[maybe_unused]] const uint32_t instanceCount,
const int32_t vertexOffset)
{
ENSURE(m_Device->GetCapabilities().instancing);
@@ -1229,7 +1223,6 @@ void CDeviceCommandContext::DrawIndexedInstanced(
// in Mesa 7.10 swrast with index VBOs).
#if CONFIG2_GLES
ENSURE(!m_Device->GetCapabilities().instancing);
UNUSED2(instanceCount);
#else
glDrawElementsInstancedARB(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT,
static_cast<const void*>((static_cast<const uint8_t*>(m_IndexBufferData) + sizeof(uint16_t) * firstIndex)),
@@ -1240,7 +1233,7 @@ void CDeviceCommandContext::DrawIndexedInstanced(
void CDeviceCommandContext::DrawIndexedInRange(
const uint32_t firstIndex, const uint32_t indexCount,
const uint32_t start, const uint32_t end)
[[maybe_unused]] const uint32_t start, [[maybe_unused]] const uint32_t end)
{
ENSURE(m_ShaderProgram);
ENSURE(m_InsidePass);
@@ -1253,8 +1246,6 @@ void CDeviceCommandContext::DrawIndexedInRange(
// Draw with DrawRangeElements where available, since it might be more
// efficient for slow hardware.
#if CONFIG2_GLES
UNUSED2(start);
UNUSED2(end);
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, indices);
#else
glDrawRangeElementsEXT(GL_TRIANGLES, start, end, indexCount, GL_UNSIGNED_SHORT, indices);
@@ -1276,9 +1267,9 @@ void CDeviceCommandContext::EndComputePass()
}
void CDeviceCommandContext::Dispatch(
const uint32_t groupCountX,
const uint32_t groupCountY,
const uint32_t groupCountZ)
[[maybe_unused]] const uint32_t groupCountX,
[[maybe_unused]] const uint32_t groupCountY,
[[maybe_unused]] const uint32_t groupCountZ)
{
#if !CONFIG2_GLES
ENSURE(m_InsideComputePass);
@@ -1290,16 +1281,12 @@ void CDeviceCommandContext::Dispatch(
glMemoryBarrier(
GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL_TEXTURE_FETCH_BARRIER_BIT | GL_TEXTURE_UPDATE_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT );
}
#else
UNUSED2(groupCountX);
UNUSED2(groupCountY);
UNUSED2(groupCountZ);
#endif
}
void CDeviceCommandContext::InsertMemoryBarrier(
const uint32_t /*srcStageMask*/, const uint32_t dstStageMask,
const uint32_t srcAccessMask, const uint32_t dstAccessMask)
const uint32_t /*srcStageMask*/, [[maybe_unused]] const uint32_t dstStageMask,
[[maybe_unused]] const uint32_t srcAccessMask, [[maybe_unused]] const uint32_t dstAccessMask)
{
#if !CONFIG2_GLES
ENSURE(!m_InsideFramebufferPass);
@@ -1323,10 +1310,6 @@ void CDeviceCommandContext::InsertMemoryBarrier(
}
if (barriers)
glMemoryBarrier(barriers);
#else
UNUSED2(dstStageMask);
UNUSED2(srcAccessMask);
UNUSED2(dstAccessMask);
#endif
}
@@ -1372,7 +1355,8 @@ void CDeviceCommandContext::SetTexture(const int32_t bindingSlot, ITexture* text
BindTexture(unit, textureUnit.target, texture->As<CTexture>()->GetHandle());
}
void CDeviceCommandContext::SetStorageTexture(const int32_t bindingSlot, ITexture* texture)
void CDeviceCommandContext::SetStorageTexture([[maybe_unused]] const int32_t bindingSlot,
[[maybe_unused]] ITexture* texture)
{
#if !CONFIG2_GLES
ENSURE(m_ShaderProgram);
@@ -1386,13 +1370,11 @@ void CDeviceCommandContext::SetStorageTexture(const int32_t bindingSlot, ITextur
ENSURE(textureUnit.type == GL_IMAGE_2D);
ENSURE(texture->GetFormat() == Format::R8G8B8A8_UNORM);
glBindImageTexture(textureUnit.unit, texture->As<CTexture>()->GetHandle(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
#else
UNUSED2(bindingSlot);
UNUSED2(texture);
#endif
}
void CDeviceCommandContext::SetStorageBuffer(const int32_t bindingSlot, IBuffer* buffer)
void CDeviceCommandContext::SetStorageBuffer([[maybe_unused]] const int32_t bindingSlot,
[[maybe_unused]] IBuffer* buffer)
{
#if !CONFIG2_GLES
if (bindingSlot < 0)
@@ -1401,9 +1383,6 @@ void CDeviceCommandContext::SetStorageBuffer(const int32_t bindingSlot, IBuffer*
ENSURE(buffer);
ENSURE(buffer->GetUsage() & Renderer::Backend::IBuffer::Usage::STORAGE);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, m_ShaderProgram->GetStorageBuffer(bindingSlot), buffer->As<CBuffer>()->GetHandle());
#else
UNUSED2(bindingSlot);
UNUSED2(buffer);
#endif
}
+1 -3
View File
@@ -38,7 +38,7 @@ namespace GL
// static
std::unique_ptr<CFramebuffer> CFramebuffer::Create(
CDevice* device, const char* name, SColorAttachment* colorAttachment,
CDevice* device, [[maybe_unused]] const char* name, SColorAttachment* colorAttachment,
SDepthStencilAttachment* depthStencilAttachment)
{
ENSURE(colorAttachment || depthStencilAttachment);
@@ -143,8 +143,6 @@ std::unique_ptr<CFramebuffer> CFramebuffer::Create(
{
glObjectLabel(GL_FRAMEBUFFER, framebuffer->m_Handle, -1, name);
}
#else
UNUSED2(name);
#endif
const GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+1 -2
View File
@@ -1254,7 +1254,7 @@ public:
void VertexAttribPointer(
const VertexAttributeStream stream, const Format format,
const uint32_t offset, const uint32_t stride,
const VertexAttributeRate rate, const void* data) override
[[maybe_unused]] const VertexAttributeRate rate, const void* data) override
{
const int attributeLocation = GetAttributeLocationFromStream(m_Device, stream);
std::vector<int>::const_iterator it =
@@ -1268,7 +1268,6 @@ public:
attributeLocation, size, type, normalized, stride, static_cast<const u8*>(data) + offset);
#if CONFIG2_GLES
ENSURE(!m_Device->GetCapabilities().instancing);
UNUSED2(rate);
#else
if (rate == VertexAttributeRate::PER_INSTANCE)
ENSURE(m_Device->GetCapabilities().instancing);