mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
Manage viewpoint buffer internally in the backend
This commit is contained in:
parent
309330d222
commit
62a227621a
20 changed files with 78 additions and 240 deletions
|
@ -1098,7 +1098,6 @@ set (PCH_SOURCES
|
|||
common/rendering/hwrenderer/data/hw_clock.cpp
|
||||
common/rendering/hwrenderer/data/hw_skydome.cpp
|
||||
common/rendering/hwrenderer/data/flatvertices.cpp
|
||||
common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp
|
||||
common/rendering/hwrenderer/data/hw_modelvertexbuffer.cpp
|
||||
common/rendering/hwrenderer/data/hw_cvars.cpp
|
||||
common/rendering/hwrenderer/data/hw_vrmodes.cpp
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
virtual void SetSubData(size_t offset, size_t size, const void *data) = 0;
|
||||
virtual void *Lock(unsigned int size) = 0;
|
||||
virtual void Unlock() = 0;
|
||||
virtual void Resize(size_t newsize) = 0;
|
||||
//virtual void Resize(size_t newsize) = 0;
|
||||
|
||||
virtual void Upload(size_t start, size_t size) {} // For unmappable buffers
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@ public:
|
|||
// Vertices
|
||||
std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count) override;
|
||||
|
||||
// Buffers
|
||||
int SetViewpoint(const HWViewpointUniforms& vp) override { return 0; }
|
||||
void SetViewpoint(int index) override { }
|
||||
|
||||
// Draw commands
|
||||
void Draw(int dt, int index, int count, bool apply = true) override;
|
||||
void DrawIndexed(int dt, int index, int count, bool apply = true) override;
|
||||
|
@ -77,10 +81,8 @@ public:
|
|||
void ClearScreen() override { }
|
||||
void SetScissor(int x, int y, int w, int h) override { }
|
||||
void SetViewport(int x, int y, int w, int h) override { }
|
||||
void EnableMultisampling(bool on) override { }
|
||||
void EnableLineSmooth(bool on) override { }
|
||||
void EnableDrawBuffers(int count, bool apply) override { }
|
||||
void EnableClipDistance(int num, bool state) override { }
|
||||
void SetDepthRange(float min, float max) override { }
|
||||
bool SetDepthClamp(bool on) override { return false; }
|
||||
void SetDepthMask(bool on) override { }
|
||||
|
@ -89,7 +91,6 @@ public:
|
|||
void SetCulling(int mode) override { }
|
||||
void EnableStencil(bool on) override { }
|
||||
void EnableDepthTest(bool on) override { }
|
||||
void SetViewpointOffset(uint32_t offset) override { }
|
||||
|
||||
std::unique_ptr<Mesh> Create();
|
||||
|
||||
|
|
|
@ -6,9 +6,12 @@
|
|||
#include "texmanip.h"
|
||||
#include "version.h"
|
||||
#include "i_interface.h"
|
||||
#include "hw_viewpointuniforms.h"
|
||||
#include "hw_cvars.h"
|
||||
|
||||
struct FColormap;
|
||||
class IBuffer;
|
||||
struct HWViewpointUniforms;
|
||||
|
||||
enum EClearTarget
|
||||
{
|
||||
|
@ -731,11 +734,31 @@ public:
|
|||
mColorMapFlash = flash;
|
||||
}
|
||||
|
||||
int Set2DViewpoint(int width, int height, int palLightLevels = 0)
|
||||
{
|
||||
HWViewpointUniforms matrices;
|
||||
matrices.mViewMatrix.loadIdentity();
|
||||
matrices.mNormalViewMatrix.loadIdentity();
|
||||
matrices.mViewHeight = 0;
|
||||
matrices.mGlobVis = 1.f;
|
||||
matrices.mPalLightLevels = palLightLevels;
|
||||
matrices.mClipLine.X = -10000000.0f;
|
||||
matrices.mShadowmapFilter = gl_shadowmap_filter;
|
||||
matrices.mLightBlendMode = 0;
|
||||
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
|
||||
matrices.CalcDependencies();
|
||||
return SetViewpoint(matrices);
|
||||
}
|
||||
|
||||
// API-dependent render interface
|
||||
|
||||
// Vertices
|
||||
virtual std::pair<FFlatVertex*, unsigned int> AllocVertices(unsigned int count);
|
||||
|
||||
// Buffers
|
||||
virtual int SetViewpoint(const HWViewpointUniforms& vp) = 0;
|
||||
virtual void SetViewpoint(int index) = 0;
|
||||
|
||||
// Draw commands
|
||||
virtual void ClearScreen() = 0;
|
||||
virtual void Draw(int dt, int index, int count, bool apply = true) = 0;
|
||||
|
@ -749,16 +772,13 @@ public:
|
|||
virtual void SetColorMask(bool r, bool g, bool b, bool a) = 0; // Used by portals.
|
||||
virtual void SetStencil(int offs, int op, int flags=-1) = 0; // Used by portal setup and render hacks.
|
||||
virtual void SetCulling(int mode) = 0; // Used by model drawer only.
|
||||
virtual void EnableClipDistance(int num, bool state) = 0; // Use by sprite sorter for vertical splits.
|
||||
virtual void Clear(int targets) = 0; // not used during normal rendering
|
||||
virtual void EnableStencil(bool on) = 0; // always on for 3D, always off for 2D
|
||||
virtual void SetScissor(int x, int y, int w, int h) = 0; // constant for 3D, changes for 2D
|
||||
virtual void SetViewport(int x, int y, int w, int h) = 0; // constant for all 3D and all 2D
|
||||
virtual void EnableDepthTest(bool on) = 0; // used by 2D, portals and render hacks.
|
||||
virtual void EnableMultisampling(bool on) = 0; // only active for 2D
|
||||
virtual void EnableLineSmooth(bool on) = 0; // constant setting for each 2D drawer operation
|
||||
virtual void EnableDrawBuffers(int count, bool apply = false) = 0; // Used by SSAO and EnableDrawBufferAttachments
|
||||
virtual void SetViewpointOffset(uint32_t offset) = 0; // HWViewpoint uniform binding offset
|
||||
|
||||
void SetColorMask(bool on)
|
||||
{
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2018 Christoph Oelckers
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
/*
|
||||
** gl_viewpointbuffer.cpp
|
||||
** Buffer data maintenance for per viewpoint uniform data
|
||||
**
|
||||
**/
|
||||
|
||||
#include "hw_viewpointuniforms.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_viewpointbuffer.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "v_video.h"
|
||||
|
||||
static const int INITIAL_BUFFER_SIZE = 100; // 100 viewpoints per frame should nearly always be enough
|
||||
|
||||
HWViewpointBuffer::HWViewpointBuffer(DFrameBuffer* fb, int pipelineNbr) : fb(fb), mPipelineNbr(pipelineNbr)
|
||||
{
|
||||
mBufferSize = INITIAL_BUFFER_SIZE;
|
||||
mBlockAlign = ((sizeof(HWViewpointUniforms) / fb->uniformblockalignment) + 1) * fb->uniformblockalignment;
|
||||
mByteSize = mBufferSize * mBlockAlign;
|
||||
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n] = fb->CreateViewpointBuffer();
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, BufferUsageType::Persistent);
|
||||
}
|
||||
|
||||
Clear();
|
||||
mLastMappedIndex = UINT_MAX;
|
||||
}
|
||||
|
||||
HWViewpointBuffer::~HWViewpointBuffer()
|
||||
{
|
||||
delete mBuffer;
|
||||
}
|
||||
|
||||
|
||||
void HWViewpointBuffer::CheckSize()
|
||||
{
|
||||
if (mUploadIndex >= mBufferSize)
|
||||
{
|
||||
mBufferSize *= 2;
|
||||
mByteSize *= 2;
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n]->Resize(mByteSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index)
|
||||
{
|
||||
if (index != mLastMappedIndex)
|
||||
{
|
||||
mLastMappedIndex = index;
|
||||
di.SetViewpointOffset(index * mBlockAlign);
|
||||
di.EnableClipDistance(0, mClipPlaneInfo[index]);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
|
||||
{
|
||||
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.mLightBlendMode = 0;
|
||||
|
||||
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
|
||||
matrices.CalcDependencies();
|
||||
|
||||
CheckSize();
|
||||
mBuffer->Map();
|
||||
memcpy(((char*)mBuffer->Memory()) + mUploadIndex * mBlockAlign, &matrices, sizeof(matrices));
|
||||
mBuffer->Unmap();
|
||||
|
||||
mClipPlaneInfo.Push(0);
|
||||
|
||||
Bind(di, mUploadIndex++);
|
||||
}
|
||||
|
||||
int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp)
|
||||
{
|
||||
CheckSize();
|
||||
mBuffer->Map();
|
||||
memcpy(((char*)mBuffer->Memory()) + mUploadIndex * mBlockAlign, vp, sizeof(*vp));
|
||||
mBuffer->Unmap();
|
||||
|
||||
mClipPlaneInfo.Push(vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f);
|
||||
return Bind(di, mUploadIndex++);
|
||||
}
|
||||
|
||||
void HWViewpointBuffer::Clear()
|
||||
{
|
||||
bool needNewPipeline = mUploadIndex > 0; // Clear might be called multiple times before any actual rendering
|
||||
|
||||
mUploadIndex = 0;
|
||||
mClipPlaneInfo.Clear();
|
||||
|
||||
if (needNewPipeline)
|
||||
{
|
||||
mLastMappedIndex = UINT_MAX;
|
||||
|
||||
mPipelinePos++;
|
||||
mPipelinePos %= mPipelineNbr;
|
||||
}
|
||||
|
||||
mBuffer = mBufferPipeline[mPipelinePos];
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#pragma once
|
||||
#include "tarray.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
|
||||
struct HWViewpointUniforms;
|
||||
class DFrameBuffer;
|
||||
class FRenderState;
|
||||
|
||||
class HWViewpointBuffer
|
||||
{
|
||||
DFrameBuffer* fb = nullptr;
|
||||
IBuffer* mBuffer;
|
||||
IBuffer* mBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
|
||||
int mPipelineNbr;
|
||||
int mPipelinePos = 0;
|
||||
|
||||
unsigned int mBufferSize;
|
||||
unsigned int mBlockAlign;
|
||||
unsigned int mUploadIndex;
|
||||
unsigned int mLastMappedIndex;
|
||||
unsigned int mByteSize;
|
||||
TArray<bool> mClipPlaneInfo;
|
||||
|
||||
unsigned int mBlockSize;
|
||||
|
||||
void CheckSize();
|
||||
|
||||
public:
|
||||
|
||||
HWViewpointBuffer(DFrameBuffer* fb, int pipelineNbr = 1);
|
||||
~HWViewpointBuffer();
|
||||
void Clear();
|
||||
int Bind(FRenderState &di, unsigned int index);
|
||||
void Set2D(FRenderState &di, int width, int height, int pll = 0);
|
||||
int SetViewpoint(FRenderState &di, HWViewpointUniforms *vp);
|
||||
unsigned int GetBlockSize() const { return mBlockSize; }
|
||||
};
|
||||
|
|
@ -36,7 +36,6 @@
|
|||
#include "cmdlib.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
#include "flatvertices.h"
|
||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "hw_clock.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "hw_renderstate.h"
|
||||
|
@ -62,13 +61,12 @@ void Draw2D(F2DDrawer* drawer, FRenderState& state, int x, int y, int width, int
|
|||
twoD.Clock();
|
||||
|
||||
state.SetViewport(x, y, width, height);
|
||||
screen->mViewpoints->Set2D(state, drawer->GetWidth(), drawer->GetHeight());
|
||||
state.Set2DViewpoint(drawer->GetWidth(), drawer->GetHeight());
|
||||
|
||||
state.EnableStencil(false);
|
||||
state.SetStencil(0, SOP_Keep, SF_AllOn);
|
||||
state.Clear(CT_Stencil);
|
||||
state.EnableDepthTest(false);
|
||||
state.EnableMultisampling(false);
|
||||
state.EnableLineSmooth(gl_aalines);
|
||||
|
||||
auto &vertices = drawer->mVertices;
|
||||
|
|
|
@ -52,7 +52,6 @@ struct FPortalSceneState;
|
|||
class FSkyVertexBuffer;
|
||||
class IBuffer;
|
||||
class FFlatVertexBuffer;
|
||||
class HWViewpointBuffer;
|
||||
class FLightBuffer;
|
||||
struct HWDrawInfo;
|
||||
class FMaterial;
|
||||
|
@ -141,7 +140,6 @@ public:
|
|||
const char *vendorstring; // We have to account for some issues with particular vendors.
|
||||
FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer
|
||||
FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data
|
||||
HWViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data.
|
||||
FLightBuffer *mLights = nullptr; // Dynamic lights
|
||||
BoneBuffer* mBones = nullptr; // Model bones
|
||||
ShadowMap* mShadowMap = nullptr;
|
||||
|
@ -242,7 +240,6 @@ public:
|
|||
// To do: these buffers shouldn't be created by the hwrenderer layer - it will be simpler if the backend manages them completely
|
||||
virtual IBuffer* CreateLightBuffer() { return nullptr; }
|
||||
virtual IBuffer* CreateBoneBuffer() { return nullptr; }
|
||||
virtual IBuffer* CreateViewpointBuffer() { return nullptr; }
|
||||
virtual IBuffer* CreateShadowmapNodesBuffer() { return nullptr; }
|
||||
virtual IBuffer* CreateShadowmapLinesBuffer() { return nullptr; }
|
||||
virtual IBuffer* CreateShadowmapLightsBuffer() { return nullptr; }
|
||||
|
|
|
@ -39,11 +39,19 @@ void VkBufferManager::Init()
|
|||
MatrixBuffer.reset(new VkStreamBuffer(this, sizeof(MatricesUBO), 50000));
|
||||
StreamBuffer.reset(new VkStreamBuffer(this, sizeof(StreamUBO), 300));
|
||||
|
||||
Viewpoint.BlockAlign = (sizeof(HWViewpointUniforms) + fb->uniformblockalignment - 1) / fb->uniformblockalignment * fb->uniformblockalignment;
|
||||
Viewpoint.UBO.reset(new VkHardwareDataBuffer(fb, false, true));
|
||||
Viewpoint.UBO->SetData(Viewpoint.Count * Viewpoint.BlockAlign, nullptr, BufferUsageType::Persistent);
|
||||
Viewpoint.UBO->Map();
|
||||
|
||||
CreateFanToTrisIndexBuffer();
|
||||
}
|
||||
|
||||
void VkBufferManager::Deinit()
|
||||
{
|
||||
Viewpoint.UBO->Unmap();
|
||||
Viewpoint.UBO.reset();
|
||||
|
||||
while (!Buffers.empty())
|
||||
RemoveBuffer(Buffers.back());
|
||||
}
|
||||
|
@ -59,7 +67,7 @@ void VkBufferManager::RemoveBuffer(VkHardwareBuffer* buffer)
|
|||
buffer->fb = nullptr;
|
||||
Buffers.erase(buffer->it);
|
||||
|
||||
for (VkHardwareDataBuffer** knownbuf : { &ViewpointUBO, &LightBufferSSO, &LightNodes, &LightLines, &LightList, &BoneBufferSSO })
|
||||
for (VkHardwareDataBuffer** knownbuf : { &LightBufferSSO, &LightNodes, &LightLines, &LightList, &BoneBufferSSO})
|
||||
{
|
||||
if (buffer == *knownbuf) *knownbuf = nullptr;
|
||||
}
|
||||
|
@ -87,12 +95,6 @@ IBuffer* VkBufferManager::CreateBoneBuffer()
|
|||
return BoneBufferSSO;
|
||||
}
|
||||
|
||||
IBuffer* VkBufferManager::CreateViewpointBuffer()
|
||||
{
|
||||
ViewpointUBO = new VkHardwareDataBuffer(fb, false, true);
|
||||
return ViewpointUBO;
|
||||
}
|
||||
|
||||
IBuffer* VkBufferManager::CreateShadowmapNodesBuffer()
|
||||
{
|
||||
LightNodes = new VkHardwareDataBuffer(fb, true, false);
|
||||
|
|
|
@ -10,6 +10,7 @@ class VkHardwareDataBuffer;
|
|||
class VkStreamBuffer;
|
||||
class IBuffer;
|
||||
struct FVertexBufferAttribute;
|
||||
struct HWViewpointUniforms;
|
||||
|
||||
class VkBufferManager
|
||||
{
|
||||
|
@ -25,7 +26,6 @@ public:
|
|||
|
||||
IBuffer* CreateLightBuffer();
|
||||
IBuffer* CreateBoneBuffer();
|
||||
IBuffer* CreateViewpointBuffer();
|
||||
IBuffer* CreateShadowmapNodesBuffer();
|
||||
IBuffer* CreateShadowmapLinesBuffer();
|
||||
IBuffer* CreateShadowmapLightsBuffer();
|
||||
|
@ -33,7 +33,14 @@ public:
|
|||
void AddBuffer(VkHardwareBuffer* buffer);
|
||||
void RemoveBuffer(VkHardwareBuffer* buffer);
|
||||
|
||||
VkHardwareDataBuffer* ViewpointUBO = nullptr;
|
||||
struct
|
||||
{
|
||||
int UploadIndex = 0;
|
||||
int BlockAlign = 0;
|
||||
int Count = 1000;
|
||||
std::unique_ptr<VkHardwareDataBuffer> UBO;
|
||||
} Viewpoint;
|
||||
|
||||
VkHardwareDataBuffer* LightBufferSSO = nullptr;
|
||||
VkHardwareDataBuffer* LightNodes = nullptr;
|
||||
VkHardwareDataBuffer* LightLines = nullptr;
|
||||
|
|
|
@ -158,6 +158,7 @@ void VkHardwareBuffer::SetSubData(size_t offset, size_t size, const void *data)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void VkHardwareBuffer::Resize(size_t newsize)
|
||||
{
|
||||
newsize = max(newsize, (size_t)16); // For supporting zero byte buffers
|
||||
|
@ -188,6 +189,7 @@ void VkHardwareBuffer::Resize(size_t newsize)
|
|||
// Fetch pointer to new buffer
|
||||
map = mBuffer->Map(0, newsize);
|
||||
}
|
||||
*/
|
||||
|
||||
void VkHardwareBuffer::Map()
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
void SetData(size_t size, const void *data, BufferUsageType usage) override;
|
||||
void SetSubData(size_t offset, size_t size, const void *data) override;
|
||||
void Resize(size_t newsize) override;
|
||||
//void Resize(size_t newsize) override;
|
||||
|
||||
void Map() override;
|
||||
void Unmap() override;
|
||||
|
|
|
@ -81,7 +81,7 @@ void VkDescriptorSetManager::UpdateHWBufferSet()
|
|||
}
|
||||
|
||||
WriteDescriptors()
|
||||
.AddBuffer(HWBufferSet.get(), 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->GetBufferManager()->ViewpointUBO->mBuffer.get(), 0, sizeof(HWViewpointUniforms))
|
||||
.AddBuffer(HWBufferSet.get(), 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->GetBufferManager()->Viewpoint.UBO->mBuffer.get(), 0, sizeof(HWViewpointUniforms))
|
||||
.AddBuffer(HWBufferSet.get(), 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->GetBufferManager()->MatrixBuffer->UniformBuffer->mBuffer.get(), 0, sizeof(MatricesUBO))
|
||||
.AddBuffer(HWBufferSet.get(), 2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->GetBufferManager()->StreamBuffer->UniformBuffer->mBuffer.get(), 0, sizeof(StreamUBO))
|
||||
.AddBuffer(HWBufferSet.get(), 3, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetBufferManager()->LightBufferSSO->mBuffer.get())
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "hw_vrmodes.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "hw_skydome.h"
|
||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "flatvertices.h"
|
||||
#include "hw_lightbuffer.h"
|
||||
#include "hw_bonebuffer.h"
|
||||
|
@ -134,7 +133,6 @@ VulkanRenderDevice::~VulkanRenderDevice()
|
|||
|
||||
delete mVertexData;
|
||||
delete mSkyData;
|
||||
delete mViewpoints;
|
||||
delete mLights;
|
||||
delete mBones;
|
||||
delete mShadowMap;
|
||||
|
@ -193,7 +191,6 @@ void VulkanRenderDevice::InitializeState()
|
|||
|
||||
mVertexData = new FFlatVertexBuffer(this, GetWidth(), GetHeight());
|
||||
mSkyData = new FSkyVertexBuffer(this);
|
||||
mViewpoints = new HWViewpointBuffer(this);
|
||||
mLights = new FLightBuffer(this);
|
||||
mBones = new BoneBuffer(this);
|
||||
mShadowMap = new ShadowMap(this);
|
||||
|
@ -332,11 +329,6 @@ IBuffer* VulkanRenderDevice::CreateBoneBuffer()
|
|||
return GetBufferManager()->CreateBoneBuffer();
|
||||
}
|
||||
|
||||
IBuffer* VulkanRenderDevice::CreateViewpointBuffer()
|
||||
{
|
||||
return GetBufferManager()->CreateViewpointBuffer();
|
||||
}
|
||||
|
||||
IBuffer* VulkanRenderDevice::CreateShadowmapNodesBuffer()
|
||||
{
|
||||
return GetBufferManager()->CreateShadowmapNodesBuffer();
|
||||
|
@ -486,7 +478,7 @@ TArray<uint8_t> VulkanRenderDevice::GetScreenshotBuffer(int &pitch, ESSType &col
|
|||
void VulkanRenderDevice::BeginFrame()
|
||||
{
|
||||
SetViewportRects(nullptr);
|
||||
mViewpoints->Clear();
|
||||
mBufferManager->Viewpoint.UploadIndex = 0;
|
||||
mCommands->BeginFrame();
|
||||
mTextureManager->BeginFrame();
|
||||
mScreenBuffers->BeginFrame(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
||||
|
|
|
@ -78,7 +78,6 @@ public:
|
|||
|
||||
IBuffer* CreateLightBuffer() override;
|
||||
IBuffer* CreateBoneBuffer() override;
|
||||
IBuffer* CreateViewpointBuffer() override;
|
||||
IBuffer* CreateShadowmapNodesBuffer() override;
|
||||
IBuffer* CreateShadowmapLinesBuffer() override;
|
||||
IBuffer* CreateShadowmapLightsBuffer() override;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "hw_cvars.h"
|
||||
#include "hw_clock.h"
|
||||
#include "flatvertices.h"
|
||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
|
||||
CVAR(Int, vk_submit_size, 1000, 0);
|
||||
EXTERN_CVAR(Bool, r_skipmats)
|
||||
|
@ -48,7 +47,7 @@ VkRenderState::VkRenderState(VulkanRenderDevice* fb) : fb(fb), mStreamBufferWrit
|
|||
|
||||
void VkRenderState::ClearScreen()
|
||||
{
|
||||
screen->mViewpoints->Set2D(*this, SCREENWIDTH, SCREENHEIGHT);
|
||||
Set2DViewpoint(SCREENWIDTH, SCREENHEIGHT);
|
||||
SetColor(0, 0, 0);
|
||||
Apply(DT_TriangleStrip);
|
||||
mCommandBuffer->draw(4, 1, FFlatVertexBuffer::FULLSCREEN_INDEX, 0);
|
||||
|
@ -127,10 +126,6 @@ void VkRenderState::SetCulling(int mode)
|
|||
mNeedApply = true;
|
||||
}
|
||||
|
||||
void VkRenderState::EnableClipDistance(int num, bool state)
|
||||
{
|
||||
}
|
||||
|
||||
void VkRenderState::Clear(int targets)
|
||||
{
|
||||
mClearTargets = targets;
|
||||
|
@ -169,10 +164,6 @@ void VkRenderState::EnableDepthTest(bool on)
|
|||
mNeedApply = true;
|
||||
}
|
||||
|
||||
void VkRenderState::EnableMultisampling(bool on)
|
||||
{
|
||||
}
|
||||
|
||||
void VkRenderState::EnableLineSmooth(bool on)
|
||||
{
|
||||
}
|
||||
|
@ -492,9 +483,23 @@ void VkRenderState::WaitForStreamBuffers()
|
|||
mMatrixBufferWriter.Reset();
|
||||
}
|
||||
|
||||
void VkRenderState::SetViewpointOffset(uint32_t offset)
|
||||
int VkRenderState::SetViewpoint(const HWViewpointUniforms& vp)
|
||||
{
|
||||
mViewpointOffset = offset;
|
||||
auto buffers = fb->GetBufferManager();
|
||||
if (buffers->Viewpoint.Count == buffers->Viewpoint.UploadIndex)
|
||||
{
|
||||
return buffers->Viewpoint.Count - 1;
|
||||
}
|
||||
memcpy(((char*)buffers->Viewpoint.UBO->Memory()) + buffers->Viewpoint.UploadIndex * buffers->Viewpoint.BlockAlign, &vp, sizeof(HWViewpointUniforms));
|
||||
int index = buffers->Viewpoint.UploadIndex++;
|
||||
mViewpointOffset = index * buffers->Viewpoint.BlockAlign;
|
||||
mNeedApply = true;
|
||||
return index;
|
||||
}
|
||||
|
||||
void VkRenderState::SetViewpoint(int index)
|
||||
{
|
||||
mViewpointOffset = index * fb->GetBufferManager()->Viewpoint.BlockAlign;
|
||||
mNeedApply = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,22 +34,22 @@ public:
|
|||
void SetColorMask(bool r, bool g, bool b, bool a) override;
|
||||
void SetStencil(int offs, int op, int flags = -1) override;
|
||||
void SetCulling(int mode) override;
|
||||
void EnableClipDistance(int num, bool state) override;
|
||||
void Clear(int targets) override;
|
||||
void EnableStencil(bool on) override;
|
||||
void SetScissor(int x, int y, int w, int h) override;
|
||||
void SetViewport(int x, int y, int w, int h) override;
|
||||
void EnableDepthTest(bool on) override;
|
||||
void EnableMultisampling(bool on) override;
|
||||
void EnableLineSmooth(bool on) override;
|
||||
void EnableDrawBuffers(int count, bool apply) override;
|
||||
void SetViewpointOffset(uint32_t offset) override;
|
||||
|
||||
void BeginFrame();
|
||||
void SetRenderTarget(VkTextureImage *image, VulkanImageView *depthStencilView, int width, int height, VkFormat Format, VkSampleCountFlagBits samples);
|
||||
void EndRenderPass();
|
||||
void EndFrame();
|
||||
|
||||
int SetViewpoint(const HWViewpointUniforms& vp) override;
|
||||
void SetViewpoint(int index) override;
|
||||
|
||||
protected:
|
||||
void Apply(int dt);
|
||||
void ApplyRenderPass(int dt);
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "hw_lightbuffer.h"
|
||||
#include "hw_bonebuffer.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "hwrenderer/scene/hw_fakeflat.h"
|
||||
#include "hwrenderer/scene/hw_clipper.h"
|
||||
#include "hwrenderer/scene/hw_portal.h"
|
||||
|
@ -282,7 +281,6 @@ void WriteSavePic(player_t* player, FileWriter* file, int width, int height)
|
|||
RenderState.SetVertexBuffer(screen->mVertexData);
|
||||
screen->mLights->Clear();
|
||||
screen->mBones->Clear();
|
||||
screen->mViewpoints->Clear();
|
||||
|
||||
// This shouldn't overwrite the global viewpoint even for a short time.
|
||||
FRenderViewpoint savevp;
|
||||
|
@ -348,7 +346,6 @@ sector_t* RenderView(player_t* player)
|
|||
|
||||
screen->mLights->Clear();
|
||||
screen->mBones->Clear();
|
||||
screen->mViewpoints->Clear();
|
||||
|
||||
// NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below.
|
||||
bool saved_niv = NoInterpolateView;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "models.h"
|
||||
#include "hw_clock.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "hw_viewpointbuffer.h"
|
||||
#include "flatvertices.h"
|
||||
#include "hw_lightbuffer.h"
|
||||
#include "hw_bonebuffer.h"
|
||||
|
@ -400,7 +399,7 @@ void HWDrawInfo::SetupView(FRenderState &state, float vx, float vy, float vz, bo
|
|||
SetViewMatrix(vp.HWAngles, vx, vy, vz, mirror, planemirror);
|
||||
SetCameraPos(vp.Pos);
|
||||
VPUniforms.CalcDependencies();
|
||||
vpIndex = screen->mViewpoints->SetViewpoint(state, &VPUniforms);
|
||||
vpIndex = state.SetViewpoint(VPUniforms);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -598,7 +597,7 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil)
|
|||
gp->DrawContents(new_di, state);
|
||||
new_di->EndDrawInfo();
|
||||
state.SetVertexBuffer(screen->mVertexData);
|
||||
screen->mViewpoints->Bind(state, vpIndex);
|
||||
state.SetViewpoint(vpIndex);
|
||||
gp->RemoveStencil(this, state, usestencil);
|
||||
|
||||
}
|
||||
|
@ -688,7 +687,7 @@ void HWDrawInfo::DrawCoronas(FRenderState& state)
|
|||
HWViewpointUniforms vp = VPUniforms;
|
||||
vp.mViewMatrix.loadIdentity();
|
||||
vp.mProjectionMatrix = VRMode::GetVRMode(true)->GetHUDSpriteProjection();
|
||||
screen->mViewpoints->SetViewpoint(state, &vp);
|
||||
state.SetViewpoint(vp);
|
||||
|
||||
float timeElapsed = (screen->FrameTime - LastFrameTime) / 1000.0f;
|
||||
LastFrameTime = screen->FrameTime;
|
||||
|
@ -721,7 +720,7 @@ void HWDrawInfo::DrawCoronas(FRenderState& state)
|
|||
}
|
||||
|
||||
state.SetTextureMode(TM_NORMAL);
|
||||
screen->mViewpoints->Bind(state, vpIndex);
|
||||
state.SetViewpoint(vpIndex);
|
||||
state.EnableDepthTest(true);
|
||||
state.SetDepthMask(true);
|
||||
}
|
||||
|
@ -770,9 +769,8 @@ void HWDrawInfo::DrawEndScene2D(sector_t * viewsector, FRenderState &state)
|
|||
HWViewpointUniforms vp = VPUniforms;
|
||||
vp.mViewMatrix.loadIdentity();
|
||||
vp.mProjectionMatrix = vrmode->GetHUDSpriteProjection();
|
||||
screen->mViewpoints->SetViewpoint(state, &vp);
|
||||
state.SetViewpoint(vp);
|
||||
state.EnableDepthTest(false);
|
||||
state.EnableMultisampling(false);
|
||||
|
||||
DrawPlayerSprites(false, state);
|
||||
|
||||
|
@ -802,7 +800,6 @@ void HWDrawInfo::Set3DViewport(FRenderState &state)
|
|||
const auto &bounds = screen->mSceneViewport;
|
||||
state.SetViewport(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||
state.SetScissor(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||
state.EnableMultisampling(true);
|
||||
state.EnableDepthTest(true);
|
||||
state.EnableStencil(true);
|
||||
state.SetStencil(0, SOP_Keep, SF_AllOn);
|
||||
|
@ -858,7 +855,7 @@ void HWDrawInfo::DrawScene(int drawmode, FRenderState& state)
|
|||
if (applySSAO && state.GetPassType() == GBUFFER_PASS)
|
||||
{
|
||||
screen->AmbientOccludeScene(VPUniforms.mProjectionMatrix.get()[5]);
|
||||
screen->mViewpoints->Bind(state, vpIndex);
|
||||
state.SetViewpoint(vpIndex);
|
||||
}
|
||||
|
||||
// Handle all portals after rendering the opaque objects but before
|
||||
|
|
|
@ -944,11 +944,7 @@ void HWDrawList::DrawSorted(HWDrawInfo *di, FRenderState &state)
|
|||
screen->mVertexData->Unmap();
|
||||
}
|
||||
state.ClearClipSplit();
|
||||
state.EnableClipDistance(1, true);
|
||||
state.EnableClipDistance(2, true);
|
||||
DrawSorted(di, state, sorted);
|
||||
state.EnableClipDistance(1, false);
|
||||
state.EnableClipDistance(2, false);
|
||||
state.ClearClipSplit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue