From b7ecffedcd46b7d9320c03769d37e9db86b6249e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Wed, 13 Aug 2025 17:51:08 +0200 Subject: [PATCH 1/6] Fix pixel shift caused by negative pixel positioning in software --- src/r_draw_column.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index dcc1a5b90..4b3a4f95d 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -217,7 +217,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) { if (frac < 0) // adjust in case we underread - frac += FRACUNIT; + frac += fracstep; // texture has no height, so just go while (--count >= 0) From 9338b5b10f8e262f30530c493fe0af3f260e31c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 14 Aug 2025 16:19:05 +0200 Subject: [PATCH 2/6] dont need to realloc this didnt see when i added realloc everywhere this doesent need to keep old data --- src/hardware/hw_batching.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 3b5c5426e..28b568c54 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -99,7 +99,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt polygonArrayAllocSize *= 2; polygonArray = realloc(polygonArray, polygonArrayAllocSize * sizeof(PolygonArrayEntry)); // also need to redo the index array, dont need to copy it though - polygonArraySorted = realloc(polygonArraySorted, polygonArrayAllocSize * sizeof(PolygonArrayEntry*)); + free(polygonArraySorted); + polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *)); } while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize) From 9dee0f0ea8cb33f07a44214bbf6301c59a2705ef Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 Aug 2025 07:58:26 +0200 Subject: [PATCH 3/6] fix restrict being in wrong place in declaration R_DrawColumnPixel --- src/r_draw_column.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index 4b3a4f95d..bae220e6d 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -57,7 +57,7 @@ static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * rest } template -static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const restrict UINT8 *source, const restrict UINT8 *colormap) +static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap) { UINT8 col = source[bit]; From 7d06f59da57983b1e72754ca94a83a50163e0f92 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 Aug 2025 07:57:31 +0200 Subject: [PATCH 4/6] append those to LDFLAGS instead of libs so they may be passed to other things --- src/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Makefile b/src/Makefile index 9b8a92f55..8b7d17cec 100644 --- a/src/Makefile +++ b/src/Makefile @@ -236,7 +236,7 @@ endif # build with profiling information ifdef PROFILEMODE opts+=-pg -libs+=-pg +LDFLAGS+=-pg endif ifdef DEBUGMODE @@ -248,10 +248,10 @@ ifdef USELTO # compile with LTO ifdef MINGW opts+=-flto=auto -g -libs+=-flto=auto -g +LDFLAGS+=-flto=auto -g else opts+=-flto=auto -libs+=-flto=auto +LDFLAGS+=-flto=auto endif endif endif @@ -265,8 +265,8 @@ else opts+=-fsanitize=address libs+=-fsanitize=address endif -opts+=-fsanitize=address -libs+=-fsanitize=address +endif + endif # debug_opts also get passed to windres @@ -281,6 +281,7 @@ cxxopts:=$(opts) $(CXXFLAGS) opts+=$(CWFLAGS) # warning flags that shouldnt be passed to c++ compiler libs+=$(LDFLAGS) -lstdc++ -lpthread + asflags:=$(ASFLAGS) -x assembler-with-cpp cc=$(CC) From 6c891f11462fc86ed41cdc87f841cd1da7e800cc Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 Aug 2025 07:53:13 +0200 Subject: [PATCH 5/6] supress align and unkown pragma warnings in clang --- src/Makefile.d/versions.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 8485b0b16..d34070bb9 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -144,6 +144,10 @@ ifdef GCC81 WFLAGS+=-Wno-error=multistatement-macros endif +ifeq ($(CC),clang) + WFLAGS+= -Wno-unknown-pragmas -Wno-cast-align +endif + ifdef NONX86 ifdef X86_64 # yeah that SEEMS contradictory opts+=-march=nocona From b5dfe74cfe0a2359c77a79f57fa6f6ed2ecffd9d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 Aug 2025 07:59:00 +0200 Subject: [PATCH 6/6] add USECLANG compile flag to force building with clang --- src/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Makefile b/src/Makefile index 8b7d17cec..752579fdb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -131,9 +131,19 @@ endif include Makefile.d/util.mk ifdef PREFIX +ifdef USECLANG +CC:=$(PREFIX)-clang +CXX:=$(PREFIX)-clang++ +else CC:=$(PREFIX)-gcc CXX:=$(PREFIX)-g++ endif +endif + +ifdef USECLANG +CC=clang +CXX=clang++ +endif OBJDUMP_OPTS?=--wide --source --line-numbers @@ -267,6 +277,8 @@ libs+=-fsanitize=address endif endif +ifeq ($(CC),clang) + LDFLAGS+= -fuse-ld=lld endif # debug_opts also get passed to windres