mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- moved more code from FDrawInfo to HWDrawInfo.
The entire setup/takedown code did not reference any API specific data. The only thing needed is a global virtual creation function.
This commit is contained in:
parent
1ca811d4a8
commit
2ee2766812
8 changed files with 103 additions and 83 deletions
|
@ -45,85 +45,6 @@
|
|||
#include "hwrenderer/dynlights/hw_lightbuffer.h"
|
||||
#include "hwrenderer/models/hw_models.h"
|
||||
|
||||
class FDrawInfoList
|
||||
{
|
||||
public:
|
||||
TDeletingArray<FDrawInfo *> mList;
|
||||
|
||||
|
||||
FDrawInfo * GetNew();
|
||||
void Release(FDrawInfo *);
|
||||
};
|
||||
|
||||
|
||||
static FDrawInfo * gl_drawinfo;
|
||||
FDrawInfoList di_list;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Try to reuse the lists as often as possible as they contain resources that
|
||||
// are expensive to create and delete.
|
||||
//
|
||||
// Note: If multithreading gets used, this class needs synchronization.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FDrawInfo *FDrawInfoList::GetNew()
|
||||
{
|
||||
if (mList.Size() > 0)
|
||||
{
|
||||
FDrawInfo *di;
|
||||
mList.Pop(di);
|
||||
return di;
|
||||
}
|
||||
return new FDrawInfo;
|
||||
}
|
||||
|
||||
void FDrawInfoList::Release(FDrawInfo * di)
|
||||
{
|
||||
di->ClearBuffers();
|
||||
mList.Push(di);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Sets up a new drawinfo struct
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
// OpenGL has no use for multiple clippers so use the same one for all DrawInfos.
|
||||
static Clipper staticClipper;
|
||||
|
||||
FDrawInfo *FDrawInfo::StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
|
||||
{
|
||||
FDrawInfo *di=di_list.GetNew();
|
||||
staticClipper.Clear();
|
||||
di->mClipper = &staticClipper;
|
||||
|
||||
di->StartScene(parentvp, uniforms);
|
||||
|
||||
di->outer = gl_drawinfo;
|
||||
gl_drawinfo = di;
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
FDrawInfo *FDrawInfo::EndDrawInfo()
|
||||
{
|
||||
assert(this == gl_drawinfo);
|
||||
for(int i=0;i<GLDL_TYPES;i++) drawlists[i].Reset();
|
||||
gl_drawinfo=static_cast<FDrawInfo*>(outer);
|
||||
di_list.Release(this);
|
||||
if (gl_drawinfo == nullptr)
|
||||
ResetRenderDataAllocator();
|
||||
return gl_drawinfo;
|
||||
}
|
||||
|
||||
bool FDrawInfo::SetDepthClamp(bool on)
|
||||
{
|
||||
return gl_RenderState.SetDepthClamp(on);
|
||||
|
|
|
@ -35,8 +35,5 @@ struct FDrawInfo : public HWDrawInfo
|
|||
void DrawEndScene2D(sector_t * viewsector);
|
||||
bool SetDepthClamp(bool on) override;
|
||||
void ClearScreen() override;
|
||||
|
||||
static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
||||
FDrawInfo *EndDrawInfo();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -416,7 +416,7 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
|||
|
||||
Set3DViewport();
|
||||
|
||||
FDrawInfo *di = FDrawInfo::StartDrawInfo(mainvp, nullptr);
|
||||
FDrawInfo *di = static_cast<FDrawInfo*>(HWDrawInfo::StartDrawInfo(mainvp, nullptr));
|
||||
auto &vp = di->Viewpoint;
|
||||
di->SetViewArea();
|
||||
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "hwrenderer/dynlights/hw_lightbuffer.h"
|
||||
#include "gl/shaders/gl_shaderprogram.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl_debug.h"
|
||||
#include "r_videoscale.h"
|
||||
#include "gl_buffers.h"
|
||||
|
@ -376,6 +377,10 @@ IDataBuffer *OpenGLFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo)
|
|||
return new GLDataBuffer(bindingpoint, ssbo);
|
||||
}
|
||||
|
||||
HWDrawInfo *OpenGLFrameBuffer::CreateDrawInfo()
|
||||
{
|
||||
return new FDrawInfo;
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::TextureFilterChanged()
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
IVertexBuffer *CreateVertexBuffer() override;
|
||||
IIndexBuffer *CreateIndexBuffer() override;
|
||||
IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo) override;
|
||||
HWDrawInfo *CreateDrawInfo() override;
|
||||
|
||||
// Retrieves a buffer containing image data for a screenshot.
|
||||
// Hint: Pitch can be negative for upside-down images, in which case buffer
|
||||
|
|
|
@ -61,8 +61,73 @@ inline void DeleteLinkedList(T *node)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class FDrawInfoList
|
||||
{
|
||||
public:
|
||||
TDeletingArray<HWDrawInfo *> mList;
|
||||
|
||||
HWDrawInfo * GetNew();
|
||||
void Release(HWDrawInfo *);
|
||||
};
|
||||
|
||||
|
||||
FDrawInfoList di_list;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Try to reuse the lists as often as possible as they contain resources that
|
||||
// are expensive to create and delete.
|
||||
//
|
||||
// Note: If multithreading gets used, this class needs synchronization.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
HWDrawInfo *FDrawInfoList::GetNew()
|
||||
{
|
||||
if (mList.Size() > 0)
|
||||
{
|
||||
HWDrawInfo *di;
|
||||
mList.Pop(di);
|
||||
return di;
|
||||
}
|
||||
return screen->CreateDrawInfo();
|
||||
}
|
||||
|
||||
void FDrawInfoList::Release(HWDrawInfo * di)
|
||||
{
|
||||
di->ClearBuffers();
|
||||
mList.Push(di);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Sets up a new drawinfo struct
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
HWDrawInfo *HWDrawInfo::StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
|
||||
{
|
||||
HWDrawInfo *di = di_list.GetNew();
|
||||
di->StartScene(parentvp, uniforms);
|
||||
return di;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static Clipper staticClipper; // Since all scenes are processed sequentially we only need one clipper.
|
||||
static HWDrawInfo * gl_drawinfo; // This is a linked list of all active DrawInfos and needed to free the memory arena after the last one goes out of scope.
|
||||
|
||||
void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
|
||||
{
|
||||
staticClipper.Clear();
|
||||
mClipper = &staticClipper;
|
||||
|
||||
Viewpoint = parentvp;
|
||||
if (uniforms)
|
||||
{
|
||||
|
@ -84,8 +149,35 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
|
|||
if (outer != nullptr) FullbrightFlags = outer->FullbrightFlags;
|
||||
else FullbrightFlags = 0;
|
||||
|
||||
outer = gl_drawinfo;
|
||||
gl_drawinfo = this;
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
HWDrawInfo *HWDrawInfo::EndDrawInfo()
|
||||
{
|
||||
assert(this == gl_drawinfo);
|
||||
for (int i = 0; i < GLDL_TYPES; i++) drawlists[i].Reset();
|
||||
gl_drawinfo = outer;
|
||||
di_list.Release(this);
|
||||
if (gl_drawinfo == nullptr)
|
||||
ResetRenderDataAllocator();
|
||||
return gl_drawinfo;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void HWDrawInfo::ClearBuffers()
|
||||
{
|
||||
for (auto node : otherfloorplanes) DeleteLinkedList(node);
|
||||
|
|
|
@ -298,8 +298,10 @@ public:
|
|||
HWPortal * FindPortal(const void * src);
|
||||
void RenderBSPNode(void *node);
|
||||
|
||||
static HWDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
||||
void StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
||||
void ClearBuffers();
|
||||
HWDrawInfo *EndDrawInfo();
|
||||
void SetViewArea();
|
||||
int SetFullbrightFlags(player_t *player);
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ class IDataBuffer;
|
|||
class FFlatVertexBuffer;
|
||||
class GLViewpointBuffer;
|
||||
class FLightBuffer;
|
||||
struct HWDrawInfo;
|
||||
|
||||
enum EHWCaps
|
||||
{
|
||||
|
@ -464,6 +465,7 @@ public:
|
|||
virtual IVertexBuffer *CreateVertexBuffer() { return nullptr; }
|
||||
virtual IIndexBuffer *CreateIndexBuffer() { return nullptr; }
|
||||
virtual IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo) { return nullptr; }
|
||||
virtual HWDrawInfo *CreateDrawInfo() { return nullptr; }
|
||||
bool BuffersArePersistent() { return !!(hwcaps & RFL_BUFFER_STORAGE); }
|
||||
|
||||
// Begin/End 2D drawing operations.
|
||||
|
|
Loading…
Reference in a new issue