From 858162e0c10416c9d23eeac928c125471bd63e0f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 17 Mar 2020 19:03:58 -0400 Subject: [PATCH 1/2] CLineRenderer: Remove unnecessary casts to bool These constructs function identically without the need for casting. --- Runtime/Graphics/CLineRenderer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Runtime/Graphics/CLineRenderer.cpp b/Runtime/Graphics/CLineRenderer.cpp index 517f72a2a..d8b4b3472 100644 --- a/Runtime/Graphics/CLineRenderer.cpp +++ b/Runtime/Graphics/CLineRenderer.cpp @@ -40,10 +40,11 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitive break; } - if (bool(texture)) + if (texture) { m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts); - else + } else { m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts); + } m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory); @@ -70,10 +71,11 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjTo break; } - if (bool(texture)) + if (texture) { m_vertBufTex = s_vertPoolTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts); - else + } else { m_vertBufNoTex = s_vertPoolNoTex.allocateBlock(CGraphics::g_BooFactory, maxTriVerts); + } m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory); From e5e4a6482c9007a79b9274076196747c00819719 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 17 Mar 2020 19:07:24 -0400 Subject: [PATCH 2/2] CLineRenderer: Make use of std::array where applicable Same behavior, but without the potential for unintentional array to pointer decay. --- Runtime/Graphics/CLineRenderer.hpp | 4 +++- Runtime/Graphics/Shaders/CLineRendererShaders.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Runtime/Graphics/CLineRenderer.hpp b/Runtime/Graphics/CLineRenderer.hpp index 07aa05879..c17ad69bf 100644 --- a/Runtime/Graphics/CLineRenderer.hpp +++ b/Runtime/Graphics/CLineRenderer.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/RetroTypes.hpp" #include "Runtime/rstl.hpp" #include "Runtime/Graphics/CGraphics.hpp" @@ -68,7 +70,7 @@ public: hecl::VertexBufferPool::Token m_vertBufTex; hecl::VertexBufferPool::Token m_vertBufNoTex; hecl::UniformBufferPool::Token m_uniformBuf; - boo::ObjToken m_shaderBind[2]; + std::array, 2> m_shaderBind; CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken& texture, bool additive, bool zTest = false, bool zGEqual = false); diff --git a/Runtime/Graphics/Shaders/CLineRendererShaders.cpp b/Runtime/Graphics/Shaders/CLineRendererShaders.cpp index 414783b43..00428f1d8 100644 --- a/Runtime/Graphics/Shaders/CLineRendererShaders.cpp +++ b/Runtime/Graphics/Shaders/CLineRendererShaders.cpp @@ -111,7 +111,7 @@ void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Con const std::array ubufOffs{size_t(ubufInfo.second)}; const std::array ubufSizes{sizeof(CLineRenderer::SDrawUniform)}; - for (size_t i = 0; i < std::size(renderer.m_shaderBind); ++i) { + for (size_t i = 0; i < renderer.m_shaderBind.size(); ++i) { renderer.m_shaderBind[i] = ctx.newShaderDataBinding( (*pipeline)[i], vbufInfo.first.get(), nullptr, nullptr, uniforms.size(), uniforms.data(), stages.data(), ubufOffs.data(), ubufSizes.data(), texCount, textures.data(), nullptr, nullptr, vbufInfo.second);