From f73f42c4a646f256fadd14db3b19266025388885 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 2 May 2017 10:19:16 +0300 Subject: [PATCH 1/5] Removed unsuccessful attempt to fix sndfile unaligned access This reverts commit 8a36bf5c09e6ca2ea6bab336869cf2e9a4ccb1e4. --- src/sound/sndfile_decoder.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sound/sndfile_decoder.cpp b/src/sound/sndfile_decoder.cpp index fd89aa2bcf..a46f0146b3 100644 --- a/src/sound/sndfile_decoder.cpp +++ b/src/sound/sndfile_decoder.cpp @@ -163,10 +163,7 @@ size_t SndFileDecoder::read(char *buffer, size_t bytes) while(total < frames) { size_t todo = MIN(frames-total, 64/SndInfo.channels); - - // libsndfile uses SSE optimization on Intel platform - // This requires proper read buffer alignment - alignas(16) float tmp[64]; + float tmp[64]; size_t got = (size_t)sf_readf_float(SndFile, tmp, todo); if(got < todo) frames = total + got; From 43fc5633af68bcaab0cf54ad149a1c365a5fa436 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 2 May 2017 17:22:50 +0300 Subject: [PATCH 2/5] Fixed player falling through narrow notch upon unmorphing https://forum.zdoom.org/viewtopic.php?t=56230 --- src/g_shared/a_morph.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 41c2e174d5..d8b4b373b0 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -267,6 +267,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, mo->Vel.X = mo->Vel.Y = 0; player->Vel.Zero(); mo->Vel.Z = pmo->Vel.Z; + mo->floorz = pmo->floorz; if (!(pmo->special2 & MF_JUSTHIT)) { mo->renderflags &= ~RF_INVISIBLE; From 17108e575ab7e33be3e77e488f081888e1e0db1f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 2 May 2017 22:24:32 +0200 Subject: [PATCH 3/5] - Add support for drawing decals on 3d floors in softpoly --- src/polyrenderer/scene/poly_decal.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/polyrenderer/scene/poly_decal.cpp b/src/polyrenderer/scene/poly_decal.cpp index bbda32b042..1c75384159 100644 --- a/src/polyrenderer/scene/poly_decal.cpp +++ b/src/polyrenderer/scene/poly_decal.cpp @@ -67,8 +67,13 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane & // Determine actor z double zpos = decal->Z; - sector_t *front = line->frontsector; sector_t *back = (line->backsector != nullptr) ? line->backsector : line->frontsector; + + // for 3d-floor segments use the model sector as reference + sector_t *front; + if ((decal->RenderFlags&RF_CLIPMASK) == RF_CLIPMID) front = decal->Sector; + else front = line->frontsector; + switch (decal->RenderFlags & RF_RELMASK) { default: From c8070c65d4d185111ac940e6448093adcaebc117 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 2 May 2017 22:26:13 +0200 Subject: [PATCH 4/5] - Add support for drawing decals on 3d floors in the software renderer --- src/swrenderer/line/r_line.cpp | 2 +- src/swrenderer/line/r_renderdrawsegment.cpp | 3 +- src/swrenderer/things/r_decal.cpp | 111 ++++++++++---------- src/swrenderer/things/r_decal.h | 4 +- 4 files changed, 62 insertions(+), 58 deletions(-) diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp index 95b0b1d8c0..5c3d2c124e 100644 --- a/src/swrenderer/line/r_line.cpp +++ b/src/swrenderer/line/r_line.cpp @@ -554,7 +554,7 @@ namespace swrenderer // [ZZ] Only if not an active mirror if (!markportal) { - RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, mLineSegment, WallC, foggy, basecolormap, walltop.ScreenY, wallbottom.ScreenY); + RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, mLineSegment, WallC, foggy, basecolormap, walltop.ScreenY, wallbottom.ScreenY, false); } if (markportal) diff --git a/src/swrenderer/line/r_renderdrawsegment.cpp b/src/swrenderer/line/r_renderdrawsegment.cpp index 5831fa0586..6718bc3702 100644 --- a/src/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/swrenderer/line/r_renderdrawsegment.cpp @@ -515,6 +515,8 @@ namespace swrenderer RenderWallPart renderWallpart(Thread); renderWallpart.Render(drawerargs, frontsector, curline, WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, top, bot, true, wallshade, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap); + + RenderDecal::RenderDecals(Thread, curline->sidedef, ds, wallshade, rw_light, rw_lightstep, curline, WallC, ds->foggy, basecolormap, wallupper.ScreenY, walllower.ScreenY, true); } // kg3D - walls of fake floors @@ -926,7 +928,6 @@ namespace swrenderer break; } } - return; } // Clip a midtexture to the floor and ceiling of the sector in front of it. diff --git a/src/swrenderer/things/r_decal.cpp b/src/swrenderer/things/r_decal.cpp index 676b561a6d..b1711d9e3b 100644 --- a/src/swrenderer/things/r_decal.cpp +++ b/src/swrenderer/things/r_decal.cpp @@ -57,19 +57,15 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); namespace swrenderer { - void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom) + void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass) { for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext) { - Render(thread, sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, walltop, wallbottom, 0); + Render(thread, sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, walltop, wallbottom, drawsegPass); } } - // pass = 0: when seg is first drawn - // = 1: drawing masked textures (including sprites) - // Currently, only pass = 0 is done or used - - void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &savecoord, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, int pass) + void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &savecoord, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass) { DVector2 decal_left, decal_right, decal_pos; int x1, x2; @@ -77,7 +73,7 @@ namespace swrenderer uint8_t flipx; double zpos; int needrepeat = 0; - sector_t *front, *back; + sector_t *back; bool calclighting; bool rereadcolormap; FDynamicColormap *usecolormap; @@ -90,8 +86,13 @@ namespace swrenderer // Determine actor z zpos = decal->Z; - front = curline->frontsector; back = (curline->backsector != NULL) ? curline->backsector : curline->frontsector; + + // for 3d-floor segments use the model sector as reference + sector_t *front; + if ((decal->RenderFlags&RF_CLIPMASK) == RF_CLIPMID) front = decal->Sector; + else front = curline->frontsector; + switch (decal->RenderFlags & RF_RELMASK) { default: @@ -171,62 +172,64 @@ namespace swrenderer FWallTmapVals WallT; WallT.InitFromWallCoords(thread, &WallC); - // Get the top and bottom clipping arrays - switch (decal->RenderFlags & RF_CLIPMASK) + if (drawsegPass) { - default: - // keep GCC quiet. - return; + uint32_t clipMode = decal->RenderFlags & RF_CLIPMASK; + if (clipMode != RF_CLIPMID && clipMode != RF_CLIPFULL) + return; - case RF_CLIPFULL: - if (curline->backsector == NULL) - { - if (pass != 0) - { - return; - } - mceilingclip = walltop; - mfloorclip = wallbottom; - } - else if (pass == 0) - { - mceilingclip = walltop; - mfloorclip = thread->OpaquePass->ceilingclip; - needrepeat = 1; - } - else + // Clip decal to stay within the draw segment wall + mceilingclip = walltop; + mfloorclip = wallbottom; + + // Rumor has it that if RT_CLIPMASK is specified then the decal should be clipped according + // to the full drawsegment visibility, as implemented in the remarked section below. + // + // This is problematic because not all 3d floors may have been drawn yet at this point. The + // code below might work ok for cases where there is only one 3d floor. + + /*if (clipMode == RF_CLIPFULL) { mceilingclip = clipper->sprtopclip - clipper->x1; mfloorclip = clipper->sprbottomclip - clipper->x1; - } - break; - - case RF_CLIPUPPER: - if (pass != 0) + }*/ + } + else + { + // Get the top and bottom clipping arrays + switch (decal->RenderFlags & RF_CLIPMASK) { + default: + // keep GCC quiet. return; - } - mceilingclip = walltop; - mfloorclip = thread->OpaquePass->ceilingclip; - break; - case RF_CLIPMID: - if (curline->backsector != NULL && pass != 2) - { - return; - } - mceilingclip = clipper->sprtopclip - clipper->x1; - mfloorclip = clipper->sprbottomclip - clipper->x1; - break; + case RF_CLIPFULL: + if (curline->backsector == NULL) + { + mceilingclip = walltop; + mfloorclip = wallbottom; + } + else + { + mceilingclip = walltop; + mfloorclip = thread->OpaquePass->ceilingclip; + needrepeat = 1; + } + break; - case RF_CLIPLOWER: - if (pass != 0) - { + case RF_CLIPUPPER: + mceilingclip = walltop; + mfloorclip = thread->OpaquePass->ceilingclip; + break; + + case RF_CLIPMID: return; + + case RF_CLIPLOWER: + mceilingclip = thread->OpaquePass->floorclip; + mfloorclip = wallbottom; + break; } - mceilingclip = thread->OpaquePass->floorclip; - mfloorclip = wallbottom; - break; } yscale = decal->ScaleY; diff --git a/src/swrenderer/things/r_decal.h b/src/swrenderer/things/r_decal.h index 98e1f4ed5d..712e829003 100644 --- a/src/swrenderer/things/r_decal.h +++ b/src/swrenderer/things/r_decal.h @@ -12,10 +12,10 @@ namespace swrenderer class RenderDecal { public: - static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom); + static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass); private: - static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, int pass); + static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass); static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); }; } From e68da4cd6b855259ed7b9daa43a5b3c92e0f017b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 2 May 2017 22:56:31 +0200 Subject: [PATCH 5/5] - Fix crash in glswfb if vid_hw2d is toggled off --- src/gl/system/gl_swframebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 7b9e54cfbd..ca153980dc 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -2511,7 +2511,7 @@ void OpenGLSWFrameBuffer::DoClear(int left, int top, int right, int bottom, int { if (In2D < 2) { - Super::Clear(left, top, right, bottom, palcolor, color); + Super::DoClear(left, top, right, bottom, palcolor, color); return; } if (!InScene)