From d937c50726a196fd13553467e15f67a705098fcd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 14:59:49 +0100 Subject: [PATCH] - use a TArray in PPUniforms. This makes the vast majority of code in that class just go away --- src/gl/renderer/gl_renderbuffers.cpp | 4 +- .../postprocessing/hw_postprocess.h | 42 ++++--------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index d5c78f116..67d083a31 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -966,11 +966,11 @@ void FGLRenderBuffers::RenderEffect(const FString &name) auto &shader = GLShaders[step.ShaderName]; // Set uniforms - if (step.Uniforms.Size > 0) + if (step.Uniforms.Data.Size() > 0) { if (!shader->Uniforms) shader->Uniforms.reset(screen->CreateDataBuffer(POSTPROCESS_BINDINGPOINT, false)); - shader->Uniforms->SetData(step.Uniforms.Size, step.Uniforms.Data); + shader->Uniforms->SetData(step.Uniforms.Data.Size(), step.Uniforms.Data.Data()); shader->Uniforms->BindBase(); } diff --git a/src/hwrenderer/postprocessing/hw_postprocess.h b/src/hwrenderer/postprocessing/hw_postprocess.h index c94a89b81..0b11ec124 100644 --- a/src/hwrenderer/postprocessing/hw_postprocess.h +++ b/src/hwrenderer/postprocessing/hw_postprocess.h @@ -38,12 +38,7 @@ public: PPUniforms(const PPUniforms &src) { - if (src.Size > 0) - { - Data = new uint8_t[src.Size]; - Size = src.Size; - memcpy(Data, src.Data, Size); - } + Data = src.Data; } ~PPUniforms() @@ -53,49 +48,26 @@ public: PPUniforms &operator=(const PPUniforms &src) { - if (this != &src) - { - if (src.Size > 0) - { - Data = new uint8_t[src.Size]; - Size = src.Size; - memcpy(Data, src.Data, Size); - } - else - { - delete[] Data; - Data = nullptr; - Size = 0; - } - } - + Data = src.Data; return *this; } void Clear() { - delete[] Data; - Data = nullptr; - Size = 0; + Data.Clear(); } template void Set(const T &v) { - if (Size != (int)sizeof(T)) + if (Data.Size() != (int)sizeof(T)) { - delete[] Data; - Data = nullptr; - Size = 0; - - Data = new uint8_t[sizeof(T)]; - Size = sizeof(T); - memcpy(Data, &v, Size); + Data.Resize(sizeof(T)); + memcpy(Data.Data(), &v, Data.Size()); } } - uint8_t *Data = nullptr; - int Size = 0; + TArray Data; }; class PPStep