diff --git a/src/common/rendering/gl/gl_shader.cpp b/src/common/rendering/gl/gl_shader.cpp index 2e4951f1ab..d1b6aee546 100644 --- a/src/common/rendering/gl/gl_shader.cpp +++ b/src/common/rendering/gl/gl_shader.cpp @@ -391,25 +391,17 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * assert(screen->mLights != NULL); assert(screen->mBones != NULL); - bool lightbuffertype = screen->mLights->GetBufferType(); - unsigned int lightbuffersize = screen->mLights->GetBlockSize(); - if (!lightbuffertype) - { - vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize()); - } - else - { - // This differentiation is for Intel which do not seem to expose the full extension, even if marked as required. - if (gl.glslversion < 4.3f) - vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n#define SHADER_STORAGE_BONES\n"; - else - vp_comb = "#version 430 core\n#define SHADER_STORAGE_LIGHTS\n#define SHADER_STORAGE_BONES\n"; - } if ((gl.flags & RFL_SHADER_STORAGE_BUFFER) && screen->allowSSBO()) - { - vp_comb << "#define SUPPORTS_SHADOWMAPS\n"; - } + vp_comb << "#version 430 core\n#define SUPPORTS_SHADOWMAPS\n"; + else + vp_comb << "#version 330 core\n"; + + bool lightbuffertype = screen->mLights->GetBufferType(); + if (!lightbuffertype) + vp_comb.AppendFormat("#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", screen->mLights->GetBlockSize(), screen->mBones->GetBlockSize()); + else + vp_comb << "#define SHADER_STORAGE_LIGHTS\n#define SHADER_STORAGE_BONES\n"; FString fp_comb = vp_comb; vp_comb << defines << i_data.GetChars(); diff --git a/src/common/rendering/gl_load/gl_interface.cpp b/src/common/rendering/gl_load/gl_interface.cpp index ea011819bc..3bcbcc4513 100644 --- a/src/common/rendering/gl_load/gl_interface.cpp +++ b/src/common/rendering/gl_load/gl_interface.cpp @@ -108,6 +108,8 @@ static void InitContext() void gl_LoadExtensions() { + int v = 0; + InitContext(); CollectExtensions(); @@ -162,32 +164,18 @@ void gl_LoadExtensions() #endif gl.glslversion = 3.31f; // Force GLSL down to 3.3. } - else if (gl_version < 4.5f) - { - // don't use GL 4.x features when running a GL 3.x context. - if (CheckExtension("GL_ARB_buffer_storage")) - { - // work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely. - // Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension. - if (CheckExtension("GL_ARB_shader_storage_buffer_object")) - { - gl.flags |= RFL_SHADER_STORAGE_BUFFER; - } - gl.flags |= RFL_BUFFER_STORAGE; - } - } - else + else if (gl_version >= 4.5f) { // Assume that everything works without problems on GL 4.5 drivers where these things are core features. gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE; + + // Mesa implements shader storage only for fragment shaders. + // Just disable the feature there. The light buffer may just use a uniform buffer without any adverse effects. + glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); + if (v == 0) + gl.flags &= ~RFL_SHADER_STORAGE_BUFFER; } - // Mesa implements shader storage only for fragment shaders. - // Just disable the feature there. The light buffer may just use a uniform buffer without any adverse effects. - int v = 0; - glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); - if (v == 0) - gl.flags &= ~RFL_SHADER_STORAGE_BUFFER; if (gl_version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; diff --git a/src/common/rendering/hwrenderer/data/hw_bonebuffer.cpp b/src/common/rendering/hwrenderer/data/hw_bonebuffer.cpp index 6335c3fc47..e6de054114 100644 --- a/src/common/rendering/hwrenderer/data/hw_bonebuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_bonebuffer.cpp @@ -33,10 +33,7 @@ BoneBuffer::BoneBuffer(int pipelineNbr) : mPipelineNbr(pipelineNbr) mBufferSize = maxNumberOfBones; mByteSize = mBufferSize * BONE_SIZE; - // Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs. - // We only want to disable using SSBOs for bones but not disable the feature entirely. - // Note that using an uniform buffer here will limit the number of bones per model so it isn't done for NVidia and AMD. - if (screen->IsVulkan() || screen->IsPoly() || ((screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && screen->allowSSBO() && !strstr(screen->vendorstring, "Intel"))) + if (screen->useSSBO()) { mBufferType = true; mBlockAlign = 0; diff --git a/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp b/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp index 622626056d..c4dceefe5c 100644 --- a/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp @@ -41,10 +41,7 @@ FLightBuffer::FLightBuffer(int pipelineNbr): mBufferSize = maxNumberOfLights * ELEMENTS_PER_LIGHT; mByteSize = mBufferSize * ELEMENT_SIZE; - // Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs. - // We only want to disable using SSBOs for lights but not disable the feature entirely. - // Note that using an uniform buffer here will limit the number of lights per surface so it isn't done for NVidia and AMD. - if (screen->IsVulkan() || screen->IsPoly() || ((screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && screen->allowSSBO() && !strstr(screen->vendorstring, "Intel"))) + if (screen->useSSBO()) { mBufferType = true; mBlockAlign = 0; diff --git a/src/common/rendering/v_video.h b/src/common/rendering/v_video.h index afba5784ae..0500941816 100644 --- a/src/common/rendering/v_video.h +++ b/src/common/rendering/v_video.h @@ -170,7 +170,7 @@ public: mShadowMap.SetAABBTree(tree); } virtual void SetLevelMesh(hwrenderer::LevelMesh *mesh) { } - bool allowSSBO() + bool allowSSBO() const { #ifndef HW_BLOCK_SSBO return true; @@ -179,6 +179,14 @@ public: #endif } + // Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs. + // We only want to disable using SSBOs for lights but not disable the feature entirely. + // Note that using an uniform buffer here will limit the number of lights per surface so it isn't done for NVidia and AMD. + bool useSSBO() + { + return IsVulkan();// || ((hwcaps & RFL_SHADER_STORAGE_BUFFER) && allowSSBO() && !strstr(vendorstring, "Intel")); + } + virtual DCanvas* GetCanvas() { return nullptr; } void SetSize(int width, int height); diff --git a/src/doomdef.h b/src/doomdef.h index 641e4597a3..8dd96ea704 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -249,6 +249,7 @@ enum BCOMPATF_FLOATBOB = 1 << 8, // Use Hexen's original method of preventing floatbobbing items from falling down BCOMPATF_NOSLOPEID = 1 << 9, // disable line IDs on slopes. BCOMPATF_CLIPMIDTEX = 1 << 10, // Always Clip midtex's in the software renderer (required to run certain GZDoom maps, has no effect in the hardware renderer) + BCOMPATF_NOSECTIONMERGE = 1 << 11, // (for IWAD maps) keep separate sections for sectors with intra-sector linedefs. }; // phares 3/20/98: diff --git a/src/maploader/compatibility.cpp b/src/maploader/compatibility.cpp index 9b74a879aa..a9d9ca0e5a 100644 --- a/src/maploader/compatibility.cpp +++ b/src/maploader/compatibility.cpp @@ -126,6 +126,8 @@ static FCompatOption Options[] = { "floatbob", BCOMPATF_FLOATBOB, SLOT_BCOMPAT }, { "noslopeid", BCOMPATF_NOSLOPEID, SLOT_BCOMPAT }, { "clipmidtex", BCOMPATF_CLIPMIDTEX, SLOT_BCOMPAT }, + { "nosectionmerge", BCOMPATF_NOSECTIONMERGE, SLOT_BCOMPAT }, + // list copied from g_mapinfo.cpp { "shorttex", COMPATF_SHORTTEX, SLOT_COMPAT }, @@ -288,12 +290,13 @@ FName MapLoader::CheckCompatibility(MapData *map) Level->ii_compatflags2 = 0; Level->ib_compatflags = 0; - // When playing Doom IWAD levels force COMPAT_SHORTTEX and COMPATF_LIGHT. - // I'm not sure if the IWAD maps actually need COMPATF_LIGHT but it certainly does not hurt. + // When playing Doom IWAD levels force BCOMPATF_NOSECTIONMERGE, COMPAT_SHORTTEX and COMPATF_LIGHT. + // I'm not sure if the IWAD maps actually need COMPATF_LIGHT but it certainly does not hurt. BCOMPATF_NOSECTIONMERGE is mainly for MAP18's sector 0 // TNT's MAP31 also needs COMPATF_STAIRINDEX but that only gets activated for TNT.WAD. if (fileSystem.GetFileContainer(map->lumpnum) == fileSystem.GetIwadNum() && (gameinfo.flags & GI_COMPATSHORTTEX) && Level->maptype == MAPTYPE_DOOM) { Level->ii_compatflags = COMPATF_SHORTTEX|COMPATF_LIGHT; + Level->ib_compatflags = BCOMPATF_NOSECTIONMERGE; if (gameinfo.flags & GI_COMPATSTAIRS) Level->ii_compatflags |= COMPATF_STAIRINDEX; } diff --git a/src/r_data/r_sections.cpp b/src/r_data/r_sections.cpp index 7ffe3cf0f4..c414924828 100644 --- a/src/r_data/r_sections.cpp +++ b/src/r_data/r_sections.cpp @@ -243,7 +243,8 @@ public: { if (sub->firstline[i].PartnerSeg && sub->firstline[i].Subsector->render_sector == sub->firstline[i].PartnerSeg->Subsector->render_sector) { - seglist.Push(sub->firstline[i].PartnerSeg); + if (sub->firstline[i].sidedef == nullptr || !(Level->ib_compatflags & BCOMPATF_NOSECTIONMERGE)) + seglist.Push(sub->firstline[i].PartnerSeg); } } };