From e2e34f52450b98696cbdd0c13f6eca379ece9eaf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 30 Oct 2018 22:43:58 +0100 Subject: [PATCH] - cleanup of the buffer binding interface. Some stuff is not really needed and the vertex buffers no longer need to insert themselves into the render state. --- src/hwrenderer/dynlights/hw_lightbuffer.h | 7 ------- src/hwrenderer/scene/hw_drawinfo.cpp | 1 - src/hwrenderer/scene/hw_skydome.cpp | 11 ----------- src/hwrenderer/scene/hw_skydome.h | 5 ++++- src/hwrenderer/scene/hw_skyportal.cpp | 2 +- src/hwrenderer/utility/hw_draw2d.cpp | 8 +++----- 6 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/hwrenderer/dynlights/hw_lightbuffer.h b/src/hwrenderer/dynlights/hw_lightbuffer.h index 6355508ba3..f47595eb14 100644 --- a/src/hwrenderer/dynlights/hw_lightbuffer.h +++ b/src/hwrenderer/dynlights/hw_lightbuffer.h @@ -54,13 +54,6 @@ public: } return index; } - - // The parameter is a reminder for Vulkan. - void BindBase(FRenderState &state) - { - mBuffer->BindBase(); - } - }; int gl_SetDynModelLight(AActor *self, int dynlightindex); diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index 7222247b2c..312b52bad0 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -496,7 +496,6 @@ void HWDrawInfo::RenderScene(FRenderState &state) state.SetDepthMask(true); - screen->mLights->BindBase(state); // not needed for OpenGL but necessary for Vulkan command buffers to do it here! state.EnableFog(true); state.SetRenderStyle(STYLE_Source); diff --git a/src/hwrenderer/scene/hw_skydome.cpp b/src/hwrenderer/scene/hw_skydome.cpp index 3c6e5f635a..7184b7bad6 100644 --- a/src/hwrenderer/scene/hw_skydome.cpp +++ b/src/hwrenderer/scene/hw_skydome.cpp @@ -102,17 +102,6 @@ FSkyVertexBuffer::FSkyVertexBuffer() // //----------------------------------------------------------------------------- -void FSkyVertexBuffer::Bind(FRenderState &state) -{ - state.SetVertexBuffer(mVertexBuffer, 0, 0); -} - -//----------------------------------------------------------------------------- -// -// -// -//----------------------------------------------------------------------------- - void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip) { static const FAngle maxSideAngle = 60.f; diff --git a/src/hwrenderer/scene/hw_skydome.h b/src/hwrenderer/scene/hw_skydome.h index 12a134e683..b441bc8ca7 100644 --- a/src/hwrenderer/scene/hw_skydome.h +++ b/src/hwrenderer/scene/hw_skydome.h @@ -68,7 +68,10 @@ public: FSkyVertexBuffer(); void SetupMatrices(FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelmatrix, VSMatrix &textureMatrix); - void Bind(FRenderState &state); + std::pair GetBufferObjects() const + { + return std::make_pair(mVertexBuffer, nullptr); + } int FaceStart(int i) { diff --git a/src/hwrenderer/scene/hw_skyportal.cpp b/src/hwrenderer/scene/hw_skyportal.cpp index 2b0e076296..9da564e635 100644 --- a/src/hwrenderer/scene/hw_skyportal.cpp +++ b/src/hwrenderer/scene/hw_skyportal.cpp @@ -180,7 +180,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state) di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); - vertexBuffer->Bind(state); + state.SetVertexBuffer(vertexBuffer); if (origin->texture[0] && origin->texture[0]->tex->bSkybox) { RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); diff --git a/src/hwrenderer/utility/hw_draw2d.cpp b/src/hwrenderer/utility/hw_draw2d.cpp index 97eeb55a1a..f15ddc2c45 100644 --- a/src/hwrenderer/utility/hw_draw2d.cpp +++ b/src/hwrenderer/utility/hw_draw2d.cpp @@ -76,10 +76,9 @@ public: mIndexBuffer->SetData(indexcount * sizeof(unsigned int), indices, false); } - void Bind(FRenderState &state) + std::pair GetBufferObjects() const { - state.SetVertexBuffer(mVertexBuffer, 0, 0); - state.SetIndexBuffer(mIndexBuffer); + return std::make_pair(mVertexBuffer, mIndexBuffer); } }; @@ -120,7 +119,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) } F2DVertexBuffer vb; vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size()); - vb.Bind(state); + state.SetVertexBuffer(&vb); state.EnableFog(false); for(auto &cmd : commands) @@ -131,7 +130,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed)); state.EnableFog(2); // Special 2D mode 'fog'. - // Rather than adding remapping code, let's enforce that the constants here are equal. state.SetTextureMode(cmd.mDrawMode); int sciX, sciY, sciW, sciH;