Remove allowSSBO, useSSBO, glslversion, hwcaps and BuffersArePersistent as none of them apply to Vulkan

This commit is contained in:
Magnus Norddahl 2023-10-19 21:31:12 +02:00
commit 52ec71b05b
12 changed files with 24 additions and 167 deletions

View file

@ -7,7 +7,6 @@ class FRenderState;
#ifdef __ANDROID__
#define HW_MAX_PIPELINE_BUFFERS 4
#define HW_BLOCK_SSBO 1
#else
// On desktop this is only useful fpr letting the GPU run in parallel with the playsim and for that 2 buffers are enough.
#define HW_MAX_PIPELINE_BUFFERS 2

View file

@ -389,7 +389,7 @@ void PPFXAA::Render(PPRenderState *renderstate)
int PPFXAA::GetMaxVersion()
{
return screen->glslversion >= 4.f ? 400 : 330;
return 460;
}
void PPFXAA::CreateShaders()

View file

@ -56,22 +56,6 @@ class FMaterial;
class FGameTexture;
class FRenderState;
enum EHWCaps
{
// [BB] Added texture compression flags.
RFL_TEXTURE_COMPRESSION = 1,
RFL_TEXTURE_COMPRESSION_S3TC = 2,
RFL_SHADER_STORAGE_BUFFER = 4,
RFL_BUFFER_STORAGE = 8,
RFL_NO_CLIP_PLANES = 32,
RFL_INVALIDATE_BUFFER = 64,
RFL_DEBUG = 128,
};
extern int DisplayWidth, DisplayHeight;
void V_UpdateModeSize (int width, int height);
@ -128,8 +112,6 @@ private:
public:
// Hardware render state that needs to be exposed to the API independent part of the renderer. For ease of access this is stored in the base class.
int hwcaps = 0; // Capability flags
float glslversion = 0; // This is here so that the differences between old OpenGL and new OpenGL/Vulkan can be handled by platform independent code.
int instack[2] = { 0,0 }; // this is globally maintained state for portal recursion avoidance.
int stencilValue = 0; // Global stencil test value
unsigned int uniformblockalignment = 256; // Hardware dependent uniform buffer alignment.
@ -157,20 +139,6 @@ public:
virtual bool CompileNextShader() { return true; }
virtual void SetLevelMesh(LevelMesh *mesh) { }
virtual void UpdateLightmaps(const TArray<LevelMeshSurface*>& surfaces) {}
bool allowSSBO() const
{
#ifndef HW_BLOCK_SSBO
return true;
#else
return mPipelineType == 0;
#endif
}
// SSBOs have quite worse performance for read only data, so keep this around only as long as Vulkan has not been adapted yet.
bool useSSBO()
{
return IsVulkan();
}
virtual DCanvas* GetCanvas() { return nullptr; }
@ -224,7 +192,6 @@ public:
// Interface to hardware rendering resources
virtual IBuffer* CreateVertexBuffer(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute* attrs) { return nullptr; }
virtual IBuffer* CreateIndexBuffer() { return nullptr; }
bool BuffersArePersistent() { return !!(hwcaps & RFL_BUFFER_STORAGE); }
// This is overridable in case Vulkan does it differently.
virtual bool RenderTextureIsFlipped() const

View file

@ -88,10 +88,6 @@ FString VkPPShader::CreateUniformBlockDecl(const char* name, const std::vector<U
{
layout = "push_constant";
}
else if (screen->glslversion < 4.20)
{
layout = "std140";
}
else
{
layout.Format("std140, binding = %d", bindingpoint);

View file

@ -189,8 +189,6 @@ void VulkanRenderDevice::InitializeState()
default: vendorstring = "Unknown"; break;
}
hwcaps = RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE;
glslversion = 4.50f;
uniformblockalignment = (unsigned int)mDevice->PhysicalDevice.Properties.Properties.limits.minUniformBufferOffsetAlignment;
maxuniformblock = mDevice->PhysicalDevice.Properties.Properties.limits.maxUniformBufferRange;

View file

@ -108,7 +108,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
R_SetupFrame(mainvp, r_viewwindow, camera);
if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadows > 0 && screen->allowSSBO() && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER))
if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadows > 0)
{
screen->mShadowMap->SetAABBTree(camera->Level->aabbTree);
screen->mShadowMap->SetCollectLights([=] {

View file

@ -234,7 +234,7 @@ void HWDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort)
//
//
//==========================================================================
void HWDrawList::SortWallIntoPlane(HWDrawInfo* di, FRenderState& state, SortNode * head, SortNode * sort)
void HWDrawList::SortWallIntoPlane(HWDrawInfo* di, SortNode * head, SortNode * sort)
{
HWFlat * fh = flats[drawitems[head->itemindex].index];
HWWall * ws = walls[drawitems[sort->itemindex].index];
@ -248,32 +248,6 @@ void HWDrawList::SortWallIntoPlane(HWDrawInfo* di, FRenderState& state, SortNode
HWWall *w = NewWall();
*w = *ws;
// Splitting is done in the shader with clip planes, if available
if (screen->hwcaps & RFL_NO_CLIP_PLANES)
{
ws->vertcount = 0; // invalidate current vertices.
float newtexv = ws->tcs[HWWall::UPLFT].v + ((ws->tcs[HWWall::LOLFT].v - ws->tcs[HWWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]);
float newlmv = ws->lightuv[HWWall::UPLFT].v + ((ws->lightuv[HWWall::LOLFT].v - ws->lightuv[HWWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]);
// I make the very big assumption here that translucent walls in sloped sectors
// and 3D-floors never coexist in the same level - If that were the case this
// code would become extremely more complicated.
if (!ceiling)
{
ws->ztop[1] = w->zbottom[1] = ws->ztop[0] = w->zbottom[0] = fh->z;
ws->tcs[HWWall::UPRGT].v = w->tcs[HWWall::LORGT].v = ws->tcs[HWWall::UPLFT].v = w->tcs[HWWall::LOLFT].v = newtexv;
ws->lightuv[HWWall::UPRGT].v = w->lightuv[HWWall::LORGT].v = ws->lightuv[HWWall::UPLFT].v = w->lightuv[HWWall::LOLFT].v = newlmv;
}
else
{
w->ztop[1] = ws->zbottom[1] = w->ztop[0] = ws->zbottom[0] = fh->z;
w->tcs[HWWall::UPLFT].v = ws->tcs[HWWall::LOLFT].v = w->tcs[HWWall::UPRGT].v = ws->tcs[HWWall::LORGT].v = newtexv;
w->lightuv[HWWall::UPLFT].v = ws->lightuv[HWWall::LOLFT].v = w->lightuv[HWWall::UPRGT].v = ws->lightuv[HWWall::LORGT].v = newlmv;
}
w->MakeVertices(di, state, false);
ws->MakeVertices(di, state, false);
}
SortNode * sort2 = drawctx->SortNodes.GetNew();
memset(sort2, 0, sizeof(SortNode));
sort2->itemindex = drawitems.Size() - 1;
@ -313,24 +287,6 @@ void HWDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort)
HWSprite *s = NewSprite();
*s = *ss;
// Splitting is done in the shader with clip planes, if available.
// The fallback here only really works for non-y-billboarded sprites.
if (screen->hwcaps & RFL_NO_CLIP_PLANES)
{
float newtexv = ss->vt + ((ss->vb - ss->vt) / (ss->z2 - ss->z1))*(fh->z - ss->z1);
if (!ceiling)
{
ss->z1 = s->z2 = fh->z;
ss->vt = s->vb = newtexv;
}
else
{
s->z1 = ss->z2 = fh->z;
s->vt = ss->vb = newtexv;
}
}
SortNode * sort2 = drawctx->SortNodes.GetNew();
memset(sort2, 0, sizeof(SortNode));
sort2->itemindex = drawitems.Size() - 1;
@ -456,7 +412,7 @@ inline double CalcIntersectionVertex(HWSprite *s, HWWall * w2)
return ((ay - cy)*(dx - cx) - (ax - cx)*(dy - cy)) / ((bx - ax)*(dy - cy) - (by - ay)*(dx - cx));
}
void HWDrawList::SortSpriteIntoWall(HWDrawInfo *di, FRenderState& state, SortNode * head,SortNode * sort)
void HWDrawList::SortSpriteIntoWall(HWDrawInfo *di, SortNode * head,SortNode * sort)
{
HWWall *wh= walls[drawitems[head->itemindex].index];
HWSprite * ss= sprites[drawitems[sort->itemindex].index];
@ -533,16 +489,8 @@ void HWDrawList::SortSpriteIntoWall(HWDrawInfo *di, FRenderState& state, SortNod
head->AddToLeft(sort);
head->AddToRight(sort2);
}
if (screen->BuffersArePersistent())
{
s->vertexindex = ss->vertexindex = -1;
}
else
{
s->CreateVertices(di, state);
ss->CreateVertices(di, state);
}
s->vertexindex = ss->vertexindex = -1;
}
}
@ -620,7 +568,7 @@ SortNode * HWDrawList::DoSort(HWDrawInfo *di, FRenderState& state, SortNode * he
break;
case DrawType_WALL:
SortWallIntoPlane(di,state,head,node);
SortWallIntoPlane(di,head,node);
break;
case DrawType_SPRITE:
@ -649,7 +597,7 @@ SortNode * HWDrawList::DoSort(HWDrawInfo *di, FRenderState& state, SortNode * he
break;
case DrawType_SPRITE:
SortSpriteIntoWall(di, state, head, node);
SortSpriteIntoWall(di, head, node);
break;
case DrawType_FLAT: break;

View file

@ -98,10 +98,10 @@ struct HWDrawList
SortNode * FindSortPlane(SortNode * head);
SortNode * FindSortWall(SortNode * head);
void SortPlaneIntoPlane(SortNode * head,SortNode * sort);
void SortWallIntoPlane(HWDrawInfo* di, FRenderState& state, SortNode * head,SortNode * sort);
void SortWallIntoPlane(HWDrawInfo* di, SortNode * head,SortNode * sort);
void SortSpriteIntoPlane(SortNode * head,SortNode * sort);
void SortWallIntoWall(HWDrawInfo *di, FRenderState& state, SortNode * head,SortNode * sort);
void SortSpriteIntoWall(HWDrawInfo *di, FRenderState& state, SortNode * head,SortNode * sort);
void SortSpriteIntoWall(HWDrawInfo *di, SortNode * head,SortNode * sort);
int CompareSprites(SortNode * a,SortNode * b);
SortNode * SortSpriteList(SortNode * head);
SortNode * DoSort(HWDrawInfo *di, FRenderState& state, SortNode * head);

View file

@ -336,7 +336,7 @@ public:
void CreateSkyboxVertices(FFlatVertex *buffer);
void SetupLights(HWDrawInfo *di, FRenderState& state, FLightNode *head, FDynLightData &lightdata, int portalgroup);
void PutFlat(HWDrawInfo *di, FRenderState& state, bool fog = false);
void PutFlat(HWDrawInfo *di, bool fog = false);
void Process(HWDrawInfo *di, FRenderState& state, sector_t * model, int whichplane, bool notexture);
void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside);
void ProcessSector(HWDrawInfo *di, FRenderState& state, sector_t * frontsector, int which = 7 /*SSRF_RENDERALL*/); // cannot use constant due to circular dependencies.

View file

@ -201,7 +201,7 @@ void HWFlat::SetupLights(HWDrawInfo *di, FRenderState& state, FLightNode * node,
void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
{
if (di->Level->HasDynamicLights && screen->BuffersArePersistent() && !di->isFullbrightScene())
if (di->Level->HasDynamicLights && !di->isFullbrightScene())
{
SetupLights(di, state, section->lighthead, lightdata, sector->PortalGroup);
}
@ -390,19 +390,12 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
//
//==========================================================================
inline void HWFlat::PutFlat(HWDrawInfo *di, FRenderState& state, bool fog)
inline void HWFlat::PutFlat(HWDrawInfo *di, bool fog)
{
if (di->isFullbrightScene())
{
Colormap.Clear();
}
else if (!screen->BuffersArePersistent())
{
if (di->Level->HasDynamicLights && texture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK|SSRF_FLOODHACK)) )
{
SetupLights(di, state, section->lighthead, lightdata, sector->PortalGroup);
}
}
di->AddFlat(this, fog);
}
@ -447,7 +440,7 @@ void HWFlat::Process(HWDrawInfo *di, FRenderState& state, sector_t * model, int
}
// For hacks this won't go into a render list.
PutFlat(di, state, fog);
PutFlat(di, fog);
rendered_flats++;
}

View file

@ -274,11 +274,8 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
{
state.SetNormal(0, 0, 0);
CreateVertices(di, state);
if (screen->BuffersArePersistent())
{
CreateVertices(di, state);
}
if (polyoffset)
{
state.SetDepthBias(-1, -128);
@ -557,10 +554,6 @@ inline void HWSprite::PutSprite(HWDrawInfo *di, FRenderState& state, bool transl
dynlightindex = -1;
vertexindex = -1;
if (!screen->BuffersArePersistent())
{
CreateVertices(di, state);
}
di->AddSprite(this, translucent);
}
@ -1266,18 +1259,7 @@ void HWSprite::Process(HWDrawInfo *di, FRenderState& state, AActor* thing, secto
if (thing->Sector->e->XFloor.lightlist.Size() != 0 && !di->isFullbrightScene() && !fullbright &&
RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub)
{
if (screen->hwcaps & RFL_NO_CLIP_PLANES) // on old hardware we are rather limited...
{
lightlist = nullptr;
if (!drawWithXYBillboard && !modelframe)
{
SplitSprite(di, state, thing->Sector, hw_styleflags != STYLEHW_Solid);
}
}
else
{
lightlist = &thing->Sector->e->XFloor.lightlist;
}
lightlist = &thing->Sector->e->XFloor.lightlist;
}
else
{

View file

@ -339,14 +339,11 @@ void HWWall::RenderTranslucentWall(HWDrawInfo*di, FRenderState &state)
//==========================================================================
void HWWall::DrawWall(HWDrawInfo*di, FRenderState &state, bool translucent)
{
if (screen->BuffersArePersistent())
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && texture != nullptr)
{
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && texture != nullptr)
{
SetupLights(di, state, lightdata);
}
MakeVertices(di, state, !!(flags & HWWall::HWF_TRANSLUCENT));
SetupLights(di, state, lightdata);
}
MakeVertices(di, state, !!(flags & HWWall::HWF_TRANSLUCENT));
state.SetNormal(glseg.Normal());
if (!translucent)
@ -527,17 +524,6 @@ void HWWall::PutWall(HWWallDispatcher *di, FRenderState& state, bool translucent
flags &= ~HWF_GLOW;
}
if (!screen->BuffersArePersistent())
{
if (ddi->Level->HasDynamicLights && !ddi->isFullbrightScene() && texture != nullptr)
{
SetupLights(ddi, state, lightdata);
}
MakeVertices(ddi, state, translucent);
}
bool solid;
if (passflag[type] == 1) solid = true;
else if (type == RENDERWALL_FFBLOCK) solid = texture && !texture->isMasked();
@ -547,12 +533,9 @@ void HWWall::PutWall(HWWallDispatcher *di, FRenderState& state, bool translucent
if (hasDecals)
{
// If we want to use the light infos for the decal we cannot delay the creation until the render pass.
if (screen->BuffersArePersistent())
if (ddi->Level->HasDynamicLights && !ddi->isFullbrightScene() && texture != nullptr)
{
if (ddi->Level->HasDynamicLights && !ddi->isFullbrightScene() && texture != nullptr)
{
SetupLights(ddi, state, lightdata);
}
SetupLights(ddi, state, lightdata);
}
ProcessDecals(ddi, state);
}
@ -867,19 +850,10 @@ void HWWall::SplitWall(HWWallDispatcher *di, FRenderState& state, sector_t * fro
(maplightbottomleft<zbottom[0] && maplightbottomright>zbottom[1]) ||
(maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1]))
{
if (!(screen->hwcaps & RFL_NO_CLIP_PLANES))
{
// Use hardware clipping if this cannot be done cleanly.
this->lightlist = &lightlist;
PutWall(di, state, translucent);
goto out;
}
// crappy fallback if no clip planes available
else if (SplitWallComplex(di, state, frontsector, translucent, maplightbottomleft, maplightbottomright))
{
goto out;
}
// Use hardware clipping if this cannot be done cleanly.
this->lightlist = &lightlist;
PutWall(di, state, translucent);
goto out;
}
// 3D floor is completely within this light