diff --git a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp index 0ab124025..90001b7b9 100644 --- a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp @@ -48,7 +48,6 @@ HWViewpointBuffer::HWViewpointBuffer(int pipelineNbr): Clear(); mLastMappedIndex = UINT_MAX; - mClipPlaneInfo.Push(0); } HWViewpointBuffer::~HWViewpointBuffer() @@ -67,7 +66,6 @@ void HWViewpointBuffer::CheckSize() { mBufferPipeline[n]->Resize(mByteSize); } - m2DHeight = m2DWidth = -1; } } @@ -84,33 +82,26 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index) void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll) { - if (width != m2DWidth || height != m2DHeight) - { - HWViewpointUniforms matrices; + HWViewpointUniforms matrices; - matrices.mViewMatrix.loadIdentity(); - matrices.mNormalViewMatrix.loadIdentity(); - matrices.mViewHeight = 0; - matrices.mGlobVis = 1.f; - matrices.mPalLightLevels = pll; - matrices.mClipLine.X = -10000000.0f; - matrices.mShadowmapFilter = gl_shadowmap_filter; + matrices.mViewMatrix.loadIdentity(); + matrices.mNormalViewMatrix.loadIdentity(); + matrices.mViewHeight = 0; + matrices.mGlobVis = 1.f; + matrices.mPalLightLevels = pll; + matrices.mClipLine.X = -10000000.0f; + matrices.mShadowmapFilter = gl_shadowmap_filter; - matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f); - matrices.CalcDependencies(); + matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f); + matrices.CalcDependencies(); - for (int n = 0; n < mPipelineNbr; n++) - { - mBufferPipeline[n]->Map(); - memcpy(mBufferPipeline[n]->Memory(), &matrices, sizeof(matrices)); - mBufferPipeline[n]->Unmap(); - } + mBuffer->Map(); + memcpy(((char*)mBuffer->Memory()) + mUploadIndex * mBlockAlign, &matrices, sizeof(matrices)); + mBuffer->Unmap(); - m2DWidth = width; - m2DHeight = height; - mLastMappedIndex = -1; - } - Bind(di, 0); + mClipPlaneInfo.Push(0); + + Bind(di, mUploadIndex++); } int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp) @@ -126,9 +117,8 @@ int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp) void HWViewpointBuffer::Clear() { - // Index 0 is reserved for the 2D projection. - mUploadIndex = 1; - mClipPlaneInfo.Resize(1); + mUploadIndex = 0; + mClipPlaneInfo.Clear(); mPipelinePos++; mPipelinePos %= mPipelineNbr; diff --git a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h index 90c64ca7f..f52af7ebc 100644 --- a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h +++ b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h @@ -19,8 +19,6 @@ class HWViewpointBuffer unsigned int mByteSize; TArray mClipPlaneInfo; - int m2DWidth = -1, m2DHeight = -1; - unsigned int mBlockSize; void CheckSize();