From ef55386d9f81036e6d3c4fd807e7642060ff2d61 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 Feb 2018 17:56:04 +0100 Subject: [PATCH 1/7] - let the texture manager handle the special OpenGL textures so that they get deleted and recreated when needed. --- src/gl/compatibility/gl_20.cpp | 4 ++-- src/gl/renderer/gl_renderer.cpp | 13 ++++--------- src/gl/renderer/gl_renderer.h | 8 ++++---- src/gl/scene/gl_sprite.cpp | 11 ++++++----- src/gl/scene/gl_walls_draw.cpp | 4 ++-- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index d714d3e46..3321f9561 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -459,8 +459,8 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, FVector3 & nearP bool gl_SetupLightTexture() { - if (GLRenderer->gllight == nullptr) return false; - FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); + if (!GLRenderer->glLight.isValid()) return false; + FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->glLight, false, false); gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false); return true; } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 74bd81c17..a401fc9b8 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -104,7 +104,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mSkyVBO = nullptr; gl_spriteindex = 0; mShaderManager = nullptr; - gllight = glpart2 = glpart = mirrortexture = nullptr; mLights = nullptr; m2DDrawer = nullptr; mTonemapPalette = nullptr; @@ -172,10 +171,10 @@ void FGLRenderer::Initialize(int width, int height) } else mVAOID = 0; - if (gl.legacyMode) gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); - glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); - glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); - mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); + if (gl.legacyMode) glLight = TexMan.CheckForTexture("glstuff/gllight.png", FTexture::TEX_MiscPatch); + glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", FTexture::TEX_MiscPatch); + glPart = TexMan.CheckForTexture("glstuff/glpart.png", FTexture::TEX_MiscPatch); + mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", FTexture::TEX_MiscPatch); mVBO = new FFlatVertexBuffer(width, height); mSkyVBO = new FSkyVertexBuffer; @@ -206,10 +205,6 @@ FGLRenderer::~FGLRenderer() if (mVBO != NULL) delete mVBO; if (mSkyVBO != NULL) delete mSkyVBO; if (mLights != NULL) delete mLights; - if (glpart2) delete glpart2; - if (glpart) delete glpart; - if (gllight) delete gllight; - if (mirrortexture) delete mirrortexture; if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); if (mVAOID != 0) { diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index eb71cd4be..857ed72ea 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -133,10 +133,10 @@ public: FShadowMap mShadowMap; - FTexture *gllight; - FTexture *glpart2; - FTexture *glpart; - FTexture *mirrortexture; + FTextureID glLight; + FTextureID glPart2; + FTextureID glPart; + FTextureID mirrorTexture; float mSky1Pos, mSky2Pos; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c07aceed4..cfaa34f6f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -1185,19 +1185,20 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s // [BB] Load the texture for round or smooth particles if (gl_particles_style) { - FTexture *lump = NULL; + FTextureID lump; if (gl_particles_style == 1) { - lump = GLRenderer->glpart2; + lump = GLRenderer->glPart2; } else if (gl_particles_style == 2) { - lump = GLRenderer->glpart; + lump = GLRenderer->glPart; } + else lump.SetNull(); - if (lump != NULL) + if (lump.isValid()) { - gltexture = FMaterial::ValidateTexture(lump, true); + gltexture = FMaterial::ValidateTexture(lump, true, false); translation = 0; ul = gltexture->GetUL(); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index d69ceeb4d..beeb103a0 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -260,7 +260,7 @@ void GLWall::RenderFogBoundary() //========================================================================== void GLWall::RenderMirrorSurface() { - if (GLRenderer->mirrortexture == NULL) return; + if (!GLRenderer->mirrorTexture.isValid()) return; // For the sphere map effect we need a normal of the mirror surface, FVector3 v = glseg.Normal(); @@ -288,7 +288,7 @@ void GLWall::RenderMirrorSurface() gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); - FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false); + FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrorTexture, false, false); gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false); flags &= ~GLWF_GLOW; From 6a02eaa595531bbfabf7cc48965e2d4ff2381caf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 Feb 2018 18:40:23 +0100 Subject: [PATCH 2/7] - second part of texture fix. --- src/gl/renderer/gl_renderer.cpp | 17 ++++++++++++----- src/gl/renderer/gl_renderer.h | 1 + src/gl/system/gl_framebuffer.cpp | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index a401fc9b8..212fc704c 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -162,6 +162,8 @@ void FGLRenderer::Initialize(int width, int height) mCustomPostProcessShaders = new FCustomPostProcessShaders(); m2DDrawer = new F2DDrawer; + GetSpecialTextures(); + // needed for the core profile, because someone decided it was a good idea to remove the default VAO. if (!gl.legacyMode) { @@ -171,11 +173,6 @@ void FGLRenderer::Initialize(int width, int height) } else mVAOID = 0; - if (gl.legacyMode) glLight = TexMan.CheckForTexture("glstuff/gllight.png", FTexture::TEX_MiscPatch); - glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", FTexture::TEX_MiscPatch); - glPart = TexMan.CheckForTexture("glstuff/glpart.png", FTexture::TEX_MiscPatch); - mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", FTexture::TEX_MiscPatch); - mVBO = new FFlatVertexBuffer(width, height); mSkyVBO = new FSkyVertexBuffer; if (!gl.legacyMode) mLights = new FLightBuffer(); @@ -236,6 +233,16 @@ FGLRenderer::~FGLRenderer() delete mFXAALumaShader; } + +void FGLRenderer::GetSpecialTextures() +{ + if (gl.legacyMode) glLight = TexMan.CheckForTexture("glstuff/gllight.png", FTexture::TEX_MiscPatch); + glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", FTexture::TEX_MiscPatch); + glPart = TexMan.CheckForTexture("glstuff/glpart.png", FTexture::TEX_MiscPatch); + mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", FTexture::TEX_MiscPatch); + +} + //========================================================================== // // Calculates the viewport values needed for 2D and 3D operations diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 857ed72ea..1f68fe57e 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -190,6 +190,7 @@ public: void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void DrawPresentTexture(const GL_IRECT &box, bool applyGamma); void Flush(); + void GetSpecialTextures(); bool StartOffscreen(); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d6eb142d8..8549abb7e 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -551,6 +551,7 @@ void OpenGLFrameBuffer::GameRestart() UpdatePalette (); ScreenshotBuffer = NULL; gl_GenerateGlobalBrightmapFromColormap(); + GLRenderer->GetSpecialTextures(); } From 1e41c042d4d1482579b0a34c6791cde646e97c39 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 19 Feb 2018 11:46:36 +0200 Subject: [PATCH 3/7] Fixed codegen crash with non-numeric random seed The following code crashed ZScript code generator if my_seed is not convertible to numeric type SetRandomSeed[my_random_id](my_seed); --- src/scripting/backend/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index a9c7e4fcc..96393ad4c 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -5945,7 +5945,7 @@ FxRandomSeed::~FxRandomSeed() FxExpression *FxRandomSeed::Resolve(FCompileContext &ctx) { CHECKRESOLVED(); - RESOLVE(seed, ctx); + SAFE_RESOLVE(seed, ctx); return this; }; From 05538f2de8ba2447fff9a1c01e8ab1e4eb9fff68 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 19 Feb 2018 12:28:24 +0200 Subject: [PATCH 4/7] Fixed compilation warnings reported by MSVC src\sound\musicformats\music_libsndfile.cpp(119): warning C4267: 'argument': conversion from 'size_t' to 'long', possible loss of data src\sound\musicformats\music_libsndfile.cpp(139): warning C4267: 'argument': conversion from 'size_t' to 'long', possible loss of data src\sound\musicformats\music_libsndfile.cpp(145): warning C4267: 'argument': conversion from 'size_t' to 'long', possible loss of data src\sound\musicformats\music_libsndfile.cpp(167): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) src\sound\musicformats\music_libsndfile.cpp(178): warning C4267: 'argument': conversion from 'size_t' to 'long', possible loss of data src\sound\musicformats\music_libsndfile.cpp(240): warning C4267: 'argument': conversion from 'size_t' to 'long', possible loss of data --- src/sound/musicformats/music_libsndfile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sound/musicformats/music_libsndfile.cpp b/src/sound/musicformats/music_libsndfile.cpp index 15b158d60..af53ac37f 100644 --- a/src/sound/musicformats/music_libsndfile.cpp +++ b/src/sound/musicformats/music_libsndfile.cpp @@ -113,7 +113,7 @@ static void ParseVorbisComments(FileReader *fr, uint32_t *start, bool *startass, // followed by the vendor string if(fr->Read(vc_data, 4) != 4) return; - size_t vndr_len = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24); + uint32_t vndr_len = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24); // Skip vendor string if(fr->Seek(vndr_len, SEEK_CUR) == -1) @@ -131,7 +131,7 @@ static void ParseVorbisComments(FileReader *fr, uint32_t *start, bool *startass, // the comment text (not null terminated!) if(fr->Read(vc_data, 4) != 4) return; - size_t length = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24); + uint32_t length = vc_data[0] | (vc_data[1]<<8) | (vc_data[2]<<16) | (vc_data[3]<<24); if(length >= 128) { @@ -164,9 +164,9 @@ static void FindFlacComments(FileReader *fr, uint32_t *loop_start, bool *startas // The first byte of the block header contains the type and a flag // indicating the last metadata block char blocktype = header[0]&0x7f; - lastblock = header[0]&0x80; + lastblock = !!(header[0]&0x80); // Following the type is a 24BE integer for the size of the block - size_t blocksize = (header[1]<<16) | (header[2]<<8) | header[3]; + uint32_t blocksize = (header[1]<<16) | (header[2]<<8) | header[3]; // FLAC__METADATA_TYPE_VORBIS_COMMENT is 4 if(blocktype == 4) @@ -205,7 +205,7 @@ static void FindOggComments(FileReader *fr, uint32_t *loop_start, bool *startass // Find the segment with the Vorbis Comment packet (type 3) for(int i = 0; i < ogg_segments; ++i) { - size_t segsize = segsizes[i]; + uint8_t segsize = segsizes[i]; if(segsize > 16) { From a3236aa7ef36390f7d3f25cd4c1843c8b5ab1c4a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 19 Feb 2018 16:57:52 +0200 Subject: [PATCH 5/7] Set target for blood actor with PUFFGETSOWNER flag spawned by crusher https://forum.zdoom.org/viewtopic.php?t=59447 --- src/p_map.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_map.cpp b/src/p_map.cpp index 8e445862a..7d5a79de8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6380,6 +6380,11 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) mo->Translation = thing->BloodTranslation; } + if (mo->flags5 & MF5_PUFFGETSOWNER) + { + mo->target = thing; + } + if (!(cl_bloodtype <= 1)) mo->renderflags |= RF_INVISIBLE; } From 1bcbdf9fd1d6be4c67780392f72087a14082ee8b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 20 Feb 2018 10:51:12 +0200 Subject: [PATCH 6/7] Added CHAN_LOOP to ZScript ESoundFlags enum https://forum.zdoom.org/viewtopic.php?t=59417 --- wadsrc/static/zscript/constants.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 47cf4accd..ef20e2310 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -416,6 +416,7 @@ enum ESoundFlags CHAN_MAYBE_LOCAL = 16, CHAN_UI = 32, CHAN_NOPAUSE = 64, + CHAN_LOOP = 256, CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL), CHAN_NOSTOP = 4096 From 117b796c6b4333df247b95aa017417d642b6f875 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 20 Feb 2018 04:44:36 -0500 Subject: [PATCH 7/7] - fixed: Phobia: The Age (or any mod with DEHACKED overriding player bits) overwrote the player's Friendly flag --- src/d_dehacked.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index cd6525304..92d574d69 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1196,6 +1196,10 @@ static int PatchThing (int thingy) // triggering line effects and can teleport when the missile flag is removed. info->flags2 &= ~MF2_NOTELEPORT; } + if (thingy == 1) // [SP] special handling for players - always be friendly! + { + value[0] |= MF_FRIENDLY; + } info->flags = ActorFlags::FromInt (value[0]); } if (vchanged[1])