- Backend update from GZDoom.

This commit is contained in:
Christoph Oelckers 2021-07-11 09:50:36 +02:00
parent 577c6cb374
commit 8a8379f5fc
13 changed files with 110 additions and 50 deletions

View file

@ -528,8 +528,13 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
offset = osave; offset = osave;
} }
DShape2D::~DShape2D() { void DShape2D::OnDestroy() {
delete lastParms; if (lastParms) delete lastParms;
lastParms = nullptr;
mIndices.Reset();
mVertices.Reset();
mCoords.Reset();
buffers.Reset();
} }
//========================================================================== //==========================================================================

View file

@ -269,7 +269,7 @@ public:
bool uploadedOnce = false; bool uploadedOnce = false;
DrawParms* lastParms; DrawParms* lastParms;
~DShape2D(); void OnDestroy() override;
}; };

View file

@ -495,6 +495,7 @@ xx(Blockeverything)
xx(Zoneboundary) xx(Zoneboundary)
xx(Jumpover) xx(Jumpover)
xx(Blockfloaters) xx(Blockfloaters)
xx(Blocklandmonsters)
xx(Clipmidtex) xx(Clipmidtex)
xx(Wrapmidtex) xx(Wrapmidtex)
xx(Midtex3d) xx(Midtex3d)
@ -1109,3 +1110,5 @@ xy(menu_advance, "menu/advance")
xx(zoomsize) xx(zoomsize)
xx(ScreenJobRunner) xx(ScreenJobRunner)
xx(RazeStatusBar) xx(RazeStatusBar)
xx(RipSound)
xx(Archvile)

View file

@ -238,7 +238,7 @@ FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **
vv = value - base; vv = value - base;
if (vv < 0 || vv >= count) if (vv < 0 || vv >= count)
{ {
Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count); Printf("Trying to serialize out-of-bounds array value with key '%s', index = %" PRId64 ", size = %" PRId64 "\n", key, vv, count);
vv = -1; vv = -1;
} }
} }
@ -247,7 +247,7 @@ FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T **
value = nullptr; value = nullptr;
else if (vv < 0 || vv >= count) else if (vv < 0 || vv >= count)
{ {
Printf("Trying to serialize out-of-bounds array value with key '%s', index = %lli, size = %lli\n", key, vv, count); Printf("Trying to serialize out-of-bounds array value with key '%s', index = %" PRId64 ", size = %" PRId64 "\n", key, vv, count);
value = nullptr; value = nullptr;
} }
else else

View file

@ -958,28 +958,3 @@ char* CleanseString(char* str)
return str; return str;
} }
#include "c_dispatch.h"
FGameTexture* GetBaseForChar(FGameTexture* t);
CCMD(dumpfonts)
{
for (auto c : { "tilesmallfont", "tilebigfont", "smallfont2", "digifont", "indexfont" })
{
auto f = V_GetFont(c);
if (f)
{
Printf("%s\n{\n", c);
for (int i = 33; i < 127; i++)
{
auto ch = f->GetChar(i, CR_UNDEFINED, nullptr);
if (ch)
{
ch = GetBaseForChar(ch);
if (i == 34) Printf("\t\"\\\""); else Printf("\t%c", i);
Printf(" %s\n", ch->GetName().GetChars());
}
}
Printf("}\n\n");
}
}
}

View file

@ -240,13 +240,12 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
*/ */
template<typename T, size_t L> void FOBJModel::ParseVector(TArray<T> &array) template<typename T, size_t L> void FOBJModel::ParseVector(TArray<T> &array)
{ {
float coord[L]; T vec;
for (size_t axis = 0; axis < L; axis++) for (unsigned axis = 0; axis < L; axis++)
{ {
sc.MustGetFloat(); sc.MustGetFloat();
coord[axis] = (float)sc.Float; vec[axis] = (float)sc.Float;
} }
T vec(coord);
array.Push(vec); array.Push(vec);
} }

View file

@ -35,6 +35,7 @@
#include "s_soundinternal.h" #include "s_soundinternal.h"
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/stat.h>
#include "c_console.h" #include "c_console.h"
#include "c_cvars.h" #include "c_cvars.h"
@ -89,20 +90,83 @@ struct NSOperatingSystemVersion
#endif // before 10.10 #endif // before 10.10
static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED < 110000
// The version returned by macOS depends on the SDK which the software has been built against.
// When built against the 10.15 SDK or earlier, Big Sur returns 10.16 for compatibility with previous numbering.
// When built against the 11.0 SDK, it returns 11.0 for forward compatibility.
// https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/
// It's impossible to load real SystemVersion.plist when linking with old SDK, i.e. when building for Intel CPU
// Any attempt to read this file is redirected to SystemVersionCompat.plist silently
// Workaround with the external process is needed in order to report correct macOS version
const char *const plistPath = "/System/Library/CoreServices/SystemVersion.plist";
struct stat dummy;
if (stat(plistPath, &dummy) != 0)
return false;
char commandLine[1024] = {};
snprintf(commandLine, sizeof commandLine, "defaults read %s ProductVersion", plistPath);
FILE *const versionFile = popen(commandLine, "r");
if (versionFile == nullptr)
return false;
NSOperatingSystemVersion plistVersion = {};
char versionString[256] = {};
if (fgets(versionString, sizeof versionString, versionFile))
{
plistVersion.majorVersion = atoi(versionString);
if (const char *minorVersionString = strstr(versionString, "."))
{
minorVersionString++;
plistVersion.minorVersion = atoi(minorVersionString);
if (const char *patchVersionString = strstr(minorVersionString, "."))
{
patchVersionString++;
plistVersion.patchVersion = atoi(minorVersionString);
}
}
}
fclose(versionFile);
if (plistVersion.majorVersion != 0)
{
version = plistVersion;
return true;
}
#endif // MAC_OS_X_VERSION_MAX_ALLOWED < 110000
return false;
}
void I_DetectOS() void I_DetectOS()
{ {
NSOperatingSystemVersion version = {}; NSOperatingSystemVersion version = {};
NSProcessInfo* const processInfo = [NSProcessInfo processInfo];
if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) if (!ReadSystemVersionFromPlist(version))
{ {
version = [processInfo operatingSystemVersion]; NSProcessInfo *const processInfo = [NSProcessInfo processInfo];
if ([processInfo respondsToSelector:@selector(operatingSystemVersion)])
{
version = [processInfo operatingSystemVersion];
}
} }
const char* name = "Unknown version"; const char* name = "Unknown version";
if (10 == version.majorVersion) switch (version.majorVersion)
{ {
case 10:
switch (version.minorVersion) switch (version.minorVersion)
{ {
case 9: name = "OS X Mavericks"; break; case 9: name = "OS X Mavericks"; break;
@ -114,13 +178,13 @@ void I_DetectOS()
case 15: name = "macOS Catalina"; break; case 15: name = "macOS Catalina"; break;
case 16: name = "macOS Big Sur"; break; case 16: name = "macOS Big Sur"; break;
} }
} break;
else if (11 == version.majorVersion) case 11:
{ name = "macOS Big Sur";
switch (version.minorVersion) break;
{ case 12:
case 0: name = "macOS Big Sur"; break; name = "macOS Monterey";
} break;
} }
char release[16] = "unknown"; char release[16] = "unknown";

View file

@ -199,7 +199,7 @@ void I_DetectOS(void)
} }
else if (info.dwMajorVersion == 10) else if (info.dwMajorVersion == 10)
{ {
osname = (info.wProductType == VER_NT_WORKSTATION) ? "10 (or higher)" : "Server 2016 (or higher)"; osname = (info.wProductType == VER_NT_WORKSTATION) ? (info.dwBuildNumber >= 22000 ? "11 (or higher)" : "10") : "Server 2016 (or higher)";
sys_ostype = 3; // modern OS sys_ostype = 3; // modern OS
} }
break; break;

View file

@ -27,6 +27,7 @@
#undef min #undef min
#endif #endif
#include <inttypes.h>
#include <vector> #include <vector>
#include <array> #include <array>
#include <set> #include <set>
@ -361,7 +362,7 @@ VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT mess
if (callbackData->pObjects[i].pObjectName) if (callbackData->pObjects[i].pObjectName)
{ {
FString hexname; FString hexname;
hexname.Format("0x%llx", callbackData->pObjects[i].objectHandle); hexname.Format("0x%" PRIx64, callbackData->pObjects[i].objectHandle);
msg.Substitute(hexname.GetChars(), callbackData->pObjects[i].pObjectName); msg.Substitute(hexname.GetChars(), callbackData->pObjects[i].pObjectName);
} }
} }

View file

@ -22,6 +22,8 @@
#include "volk/volk.h" #include "volk/volk.h"
#include <inttypes.h>
#include "v_video.h" #include "v_video.h"
#include "m_png.h" #include "m_png.h"
#include "templates.h" #include "templates.h"
@ -698,7 +700,7 @@ void VulkanFrameBuffer::PrintStartupLog()
const auto &limits = props.limits; const auto &limits = props.limits;
Printf("Max. texture size: %d\n", limits.maxImageDimension2D); Printf("Max. texture size: %d\n", limits.maxImageDimension2D);
Printf("Max. uniform buffer range: %d\n", limits.maxUniformBufferRange); Printf("Max. uniform buffer range: %d\n", limits.maxUniformBufferRange);
Printf("Min. uniform buffer offset alignment: %llu\n", limits.minUniformBufferOffsetAlignment); Printf("Min. uniform buffer offset alignment: %" PRIu64 "\n", limits.minUniformBufferOffsetAlignment);
} }
void VulkanFrameBuffer::CreateFanToTrisIndexBuffer() void VulkanFrameBuffer::CreateFanToTrisIndexBuffer()

View file

@ -1449,7 +1449,7 @@ FxFontCast::FxFontCast(FxExpression *x)
: FxExpression(EFX_FontCast, x->ScriptPosition) : FxExpression(EFX_FontCast, x->ScriptPosition)
{ {
basex = x; basex = x;
ValueType = TypeSound; ValueType = TypeFont;
} }
//========================================================================== //==========================================================================

View file

@ -978,10 +978,16 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand)
// This is only accessible to the special menu item to run CCMDs. // This is only accessible to the special menu item to run CCMDs.
DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand) DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
{ {
if (CurrentMenu == nullptr) return 0;
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_STRING(cmd); PARAM_STRING(cmd);
PARAM_BOOL(unsafe); PARAM_BOOL(unsafe);
// Only menus are allowed to execute CCMDs.
if (DMenu::InMenu == 0)
{
I_FatalError("Attempt to execute CCMD '%s' outside of menu code", cmd.GetChars());
}
UnsafeExecutionScope scope(unsafe); UnsafeExecutionScope scope(unsafe);
C_DoCommand(cmd); C_DoCommand(cmd);
return 0; return 0;

View file

@ -82,6 +82,11 @@ struct TVector2
{ {
} }
TVector2(vec_t *o)
: X(o[0]), Y(o[1])
{
}
void Zero() void Zero()
{ {
Y = X = 0; Y = X = 0;