- use a TArray in PPUniforms.

This makes the vast majority of code in that class just go away
This commit is contained in:
Christoph Oelckers 2018-12-15 14:59:49 +01:00
parent 056b2c3a80
commit d937c50726
2 changed files with 9 additions and 37 deletions

View file

@ -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();
}

View file

@ -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<typename T>
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<uint8_t> Data;
};
class PPStep