From 23044c8e43a7b900d556b09079c1b1c2660b05a0 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 19 Apr 2022 16:28:47 -0400 Subject: [PATCH 01/11] Enable VK_KHR_portability_enumeration for macOS on Vulkan SDK 1.3.211.0 or later --- neo/renderer/Vulkan/RenderBackend_VK.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index f147ba01..0e47dad8 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -309,8 +309,15 @@ static void CreateVulkanInstance() { vkcontext.instanceExtensions.AddUnique( VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME ); vkcontext.deviceProperties2Available = true; - break; } +#if defined(__APPLE__) && defined( VK_KHR_portability_enumeration ) + // SRS - Enable physical device enumeration when using the Vulkan loader on macOS (MoltenVK portability driver) + if( idStr::Icmp( instanceExtensionProps[ i ].extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME ) == 0 ) + { + vkcontext.instanceExtensions.AddUnique( VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME ); + createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR; + } +#endif } vkcontext.debugUtilsSupportAvailable = false; From 511e18d9fd23c4e09184376495b12a388d5319cd Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Wed, 30 Mar 2022 17:01:56 -0400 Subject: [PATCH 02/11] Check Vulkan header version for macro compatibility, improve VkPhysicalDeviceProperties2 variable names (cherry picked from commit 6399dc2a48829ea25be649213cc059d5bfd1b379) --- neo/renderer/Vulkan/RenderBackend_VK.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index 0e47dad8..1c26b34c 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -750,7 +750,12 @@ static void SelectPhysicalDevice() static idStr version_string; version_string.Clear(); +#if VK_HEADER_VERSION >= 176 version_string.Append( va( "Vulkan API %i.%i.%i", VK_API_VERSION_MAJOR( gpu.props.apiVersion ), VK_API_VERSION_MINOR( gpu.props.apiVersion ), VK_API_VERSION_PATCH( gpu.props.apiVersion ) ) ); +#else + // SRS - Allow deprecated version macros on older Vulkan SDKs < 1.2.176 + version_string.Append( va( "Vulkan API %i.%i.%i", VK_VERSION_MAJOR( gpu.props.apiVersion ), VK_VERSION_MINOR( gpu.props.apiVersion ), VK_VERSION_PATCH( gpu.props.apiVersion ) ) ); +#endif static idStr extensions_string; extensions_string.Clear(); @@ -768,13 +773,13 @@ static void SelectPhysicalDevice() if( vkcontext.deviceProperties2Available && driverPropertiesAvailable ) { - VkPhysicalDeviceProperties2 pProperties = {}; - VkPhysicalDeviceDriverProperties pDriverProperties = {}; - pProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; - pProperties.pNext = &pDriverProperties; - pDriverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; - vkGetPhysicalDeviceProperties2( vkcontext.physicalDevice, &pProperties ); - version_string.Append( va( " (%s %s)", pDriverProperties.driverName, pDriverProperties.driverInfo ) ); + VkPhysicalDeviceProperties2 deviceProperties = {}; + VkPhysicalDeviceDriverProperties driverProperties = {}; + deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; + deviceProperties.pNext = &driverProperties; + driverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; + vkGetPhysicalDeviceProperties2( vkcontext.physicalDevice, &deviceProperties ); + version_string.Append( va( " (%s %s)", driverProperties.driverName, driverProperties.driverInfo ) ); } glConfig.version_string = version_string.c_str(); From 93b8564b6e72874dbc56c83291ce685505200f67 Mon Sep 17 00:00:00 2001 From: Admer <49600504+Admer456@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:54:27 +0200 Subject: [PATCH 03/11] Add move semantics to idList and idStr * idListArrayResize uses std::move * idStr implements move constructor * and move operator * mpMap_t also implements a move operator --- neo/framework/Common.h | 1 + neo/idlib/Str.h | 30 +++++++++++++++++++++++++++ neo/idlib/containers/List.h | 41 ++++++++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/neo/framework/Common.h b/neo/framework/Common.h index 5094ecd1..a4a9b369 100644 --- a/neo/framework/Common.h +++ b/neo/framework/Common.h @@ -167,6 +167,7 @@ struct MemInfo_t struct mpMap_t { + mpMap_t& operator=( mpMap_t&& src ) = default; void operator=( const mpMap_t& src ) { diff --git a/neo/idlib/Str.h b/neo/idlib/Str.h index 135ce59b..89765dd6 100644 --- a/neo/idlib/Str.h +++ b/neo/idlib/Str.h @@ -130,6 +130,7 @@ class idStr public: idStr(); + idStr( idStr&& text ) noexcept; // Admer: added move constructor idStr( const idStr& text ); idStr( const idStr& text, int start, int end ); idStr( const char* text ); @@ -149,6 +150,7 @@ public: char operator[]( int index ) const; char& operator[]( int index ); + void operator=( idStr&& text ) noexcept; // Admer: added move operator void operator=( const idStr& text ); void operator=( const char* text ); @@ -477,6 +479,12 @@ ID_INLINE idStr::idStr() Construct(); } +ID_INLINE idStr::idStr( idStr&& text ) noexcept +{ + Construct(); + *this = std::move( text ); +} + ID_INLINE idStr::idStr( const idStr& text ) { Construct(); @@ -677,6 +685,28 @@ ID_INLINE char& idStr::operator[]( int index ) return data[ index ]; } +ID_INLINE void idStr::operator=( idStr&& text ) noexcept +{ + Clear(); + + len = text.len; + allocedAndFlag = text.allocedAndFlag; + memcpy( baseBuffer, text.baseBuffer, sizeof( baseBuffer ) ); + + if ( text.data == text.baseBuffer ) + { + data = baseBuffer; + } + else + { + data = text.data; + } + + text.len = 0; + text.allocedAndFlag = 0; + text.data = nullptr; +} + ID_INLINE void idStr::operator=( const idStr& text ) { int l; diff --git a/neo/idlib/containers/List.h b/neo/idlib/containers/List.h index cf7951bb..58511b4b 100644 --- a/neo/idlib/containers/List.h +++ b/neo/idlib/containers/List.h @@ -98,7 +98,8 @@ ID_INLINE void* idListArrayResize( void* voldptr, int oldNum, int newNum, bool z int overlap = Min( oldNum, newNum ); for( int i = 0; i < overlap; i++ ) { - newptr[i] = oldptr[i]; + //newptr[i] = oldptr[i]; + newptr[i] = std::move( oldptr[i] ); } } idListArrayDelete<_type_>( voldptr, oldNum ); @@ -125,6 +126,7 @@ public: typedef _type_ new_t(); idList( int newgranularity = 16 ); + idList( idList&& other ); idList( const idList& other ); idList( std::initializer_list<_type_> initializerList ); ~idList(); @@ -139,6 +141,7 @@ public: size_t Size() const; // returns total size of allocated memory including size of list _type_ size_t MemoryUsed() const; // returns size of the used elements in the list + idList<_type_, _tag_>& operator=( idList<_type_, _tag_>&& other ); idList<_type_, _tag_>& operator=( const idList<_type_, _tag_>& other ); const _type_& operator[]( int index ) const; _type_& operator[]( int index ); @@ -303,6 +306,18 @@ ID_INLINE idList<_type_, _tag_>::idList( int newgranularity ) Clear(); } +/* +================ +idList<_type_,_tag_>::idList( idList< _type_, _tag_ >&& other ) +================ +*/ +template< typename _type_, memTag_t _tag_ > +ID_INLINE idList<_type_, _tag_>::idList( idList&& other ) +{ + list = NULL; + *this = std::move( other ); +} + /* ================ idList<_type_,_tag_>::idList( const idList< _type_, _tag_ > &other ) @@ -700,6 +715,30 @@ ID_INLINE void idList<_type_, _tag_>::AssureSizeAlloc( int newSize, new_t* alloc ================ idList<_type_,_tag_>::operator= +Moves the contents and size attributes of another list, effectively emptying the other list. +================ +*/ +template< typename _type_, memTag_t _tag_ > +ID_INLINE idList<_type_, _tag_>& idList<_type_, _tag_>::operator=( idList<_type_, _tag_>&& other ) +{ + Clear(); + + num = other.num; + size = other.size; + granularity = other.granularity; + memTag = other.memTag; + list = other.list; + + other.list = nullptr; + other.Clear(); + + return *this; +} + +/* +================ +idList<_type_,_tag_>::operator= + Copies the contents and size attributes of another list. ================ */ From 67022836c4add9a68858db0ce85ad781e085981d Mon Sep 17 00:00:00 2001 From: HarrievG Date: Wed, 5 Oct 2022 21:44:35 +0200 Subject: [PATCH 04/11] ~ Fixed pose root root matrix correction. - Removed single bone orientation hack - removed unused code. --- neo/renderer/Model_gltf.cpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/neo/renderer/Model_gltf.cpp b/neo/renderer/Model_gltf.cpp index 624393f9..d500719c 100644 --- a/neo/renderer/Model_gltf.cpp +++ b/neo/renderer/Model_gltf.cpp @@ -523,6 +523,7 @@ idList GetPose( idList& bones, idJointMat* poseMat ) if( node->parent == nullptr ) { node->matrix *= blenderToDoomTransform; + trans = node->matrix; } idJointQuat& pose = ret[i]; @@ -720,24 +721,6 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T baseFrame.SetGranularity( 1 ); baseFrame.SetNum( bones.Num() ); - gltfSkin* skin = data->GetSkin( gltfAnim );; - gltfAccessor* acc = nullptr; - if( skin != nullptr ) - { - acc = data->AccessorList()[skin->inverseBindMatrices]; - } - else - { - skin = new gltfSkin; - skin->joints.AssureSize( 1, data->GetNodeIndex( root ) ); - idMat4 trans = mat4_identity; - data->ResolveNodeMatrix( root, &trans ); - trans *= blenderToDoomTransform.Inverse(); - acc = new gltfAccessor(); - acc->matView = new idList( 1 ); - acc->matView->AssureSize( 1, trans.Inverse().Transpose() ); - } - idJointMat* poseMat = ( idJointMat* ) _alloca16( bones.Num() * sizeof( poseMat[0] ) ); baseFrame = GetPose( animBones[0], poseMat ); @@ -818,15 +801,7 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T { if( node->parent == nullptr ) { - //q = blenderToDoomAngels.ToQuat() * animBones[i][b].rotation; - q = blenderToDoomTransform.ToMat3().ToQuat() * animBones[i][b].rotation; - - if( animBones[i].Num() == 1 ) - { - // this is only hit for single bone or boneless (root is generated!) animations - q = blenderToDoomTransform.ToMat3().ToQuat() * -animBones[i][b].rotation; - } } else { From fc42078ccfda99ace155a61fe8705f870ec8e603 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 13 Oct 2022 09:37:14 +0200 Subject: [PATCH 05/11] Fixed Linux compile issues. Closes #702 #703 --- neo/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 7830a003..6619931f 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -1779,7 +1779,7 @@ else() if(USE_PRECOMPILED_HEADERS) set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES}) - list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES} ${BINKDEC_SOURCES} ${IMGUI_SOURCES} ${MIKKTSPACE_SOURCES}) + list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES} ${BINKDEC_SOURCES} ${IMGUI_SOURCES} ${MIKKTSPACE_SOURCES} ${OGGVORBIS_SOURCES}) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs/zlib/minizip/ioapi.c) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp) From 9858ab99f78f4f646ab8924c5ed445065c39e341 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Mon, 17 Oct 2022 21:01:58 -0400 Subject: [PATCH 06/11] Fix snprintf() buffer length issues for Doom Classic on linux with gcc 12 compiler (cherry picked from commit c9212b9554edeccdf2ba1edc430727fd8f1f1f42) --- doomclassic/doom/f_finale.cpp | 2 +- doomclassic/doom/hu_stuff.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 doomclassic/doom/f_finale.cpp mode change 100644 => 100755 doomclassic/doom/hu_stuff.cpp diff --git a/doomclassic/doom/f_finale.cpp b/doomclassic/doom/f_finale.cpp old mode 100644 new mode 100755 index 08b977fb..73aa46a8 --- a/doomclassic/doom/f_finale.cpp +++ b/doomclassic/doom/f_finale.cpp @@ -830,7 +830,7 @@ void F_BunnyScroll( void ) int x; patch_t* p1; patch_t* p2; - const size_t name_len = 10; + const size_t name_len = 14; char name[name_len]; int stage; diff --git a/doomclassic/doom/hu_stuff.cpp b/doomclassic/doom/hu_stuff.cpp old mode 100644 new mode 100755 index 0ffede1e..d5995c83 --- a/doomclassic/doom/hu_stuff.cpp +++ b/doomclassic/doom/hu_stuff.cpp @@ -319,7 +319,7 @@ void HU_Init( void ) int i; int j; - const size_t buffer_len = 9; + const size_t buffer_len = 17; char buffer[buffer_len]; shiftxform = english_shiftxform; From 4691a4cf017a4f792d66200984957139046f3e9a Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 18 Oct 2022 09:51:07 -0400 Subject: [PATCH 07/11] Include STL in List.h to define std::copy() for clang 14+ (cherry picked from commit 2c36496af53d89a74cf3e9d7889a019c829afb48) --- neo/idlib/containers/List.h | 1 + 1 file changed, 1 insertion(+) diff --git a/neo/idlib/containers/List.h b/neo/idlib/containers/List.h index cf7951bb..e4411270 100644 --- a/neo/idlib/containers/List.h +++ b/neo/idlib/containers/List.h @@ -32,6 +32,7 @@ If you have questions concerning this license or the applicable additional terms #include #include +#include // SRS - Needed for clang 14 so std::copy() is defined /* =============================================================================== From 73b70ce4ba33dcbf4adb93dfbd30fa258dd0fead Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 19 Oct 2022 18:26:14 +0200 Subject: [PATCH 08/11] Astyle --- neo/idlib/Str.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/idlib/Str.h b/neo/idlib/Str.h index 89765dd6..b39b5c8d 100644 --- a/neo/idlib/Str.h +++ b/neo/idlib/Str.h @@ -692,8 +692,8 @@ ID_INLINE void idStr::operator=( idStr&& text ) noexcept len = text.len; allocedAndFlag = text.allocedAndFlag; memcpy( baseBuffer, text.baseBuffer, sizeof( baseBuffer ) ); - - if ( text.data == text.baseBuffer ) + + if( text.data == text.baseBuffer ) { data = baseBuffer; } From 3702fb1dec88a5710274b3824de2b2d3668e1da2 Mon Sep 17 00:00:00 2001 From: HarrievG Date: Thu, 20 Oct 2022 12:17:09 +0200 Subject: [PATCH 09/11] - removal of backface genration in Aasbuild for polygonmeshes. --- neo/tools/compilers/aas/AASBuild.cpp | 38 +--------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/neo/tools/compilers/aas/AASBuild.cpp b/neo/tools/compilers/aas/AASBuild.cpp index 0d4b8fdd..dc620aed 100644 --- a/neo/tools/compilers/aas/AASBuild.cpp +++ b/neo/tools/compilers/aas/AASBuild.cpp @@ -452,14 +452,7 @@ idBrushList idAASBuild::AddBrushesForMapPolygonMesh( const MapPolygonMesh* mapMe const idList& verts = mapMesh->GetDrawVerts(); const idList& indices = face.GetIndexes(); - idVec3 triNormal; - int v1 = 0; - int v2 = 1; - int v3 = 2; - - //create brush with 2 triangles - // 1 frontface from the mappoly verts - // 1 backface, offset in direction off frontface normal at unit distance + //create brush from triangle //Front face d1 = verts[indices[1]].xyz - verts[indices[0]].xyz; @@ -490,35 +483,6 @@ idBrushList idAASBuild::AddBrushesForMapPolygonMesh( const MapPolygonMesh* mapMe delete brush; } } - - //Back face - triNormal = plane.Normal(); - plane.SetNormal( d2.Cross( d1 ) ); - if( plane.Normalize() != 0.0f ) - { - plane.FitThroughPoint( verts[indices[0]].xyz ); - - w.Clear(); - w += verts[indices[2]].xyz + triNormal; - w += verts[indices[1]].xyz + triNormal; - w += verts[indices[0]].xyz + triNormal; - - brush = new idBrush(); - brush->SetContents( contents ); - if( brush->FromWinding( w, plane ) ) - { - brush->SetEntityNum( entityNum ); - brush->SetPrimitiveNum( primitiveNum ); - brush->SetFlag( BFL_PATCH ); - brush->Transform( origin, axis ); - brushList.AddToTail( brush ); - validBrushes++; - } - else - { - delete brush; - } - } } if( !validBrushes ) From b1e198ce577152d04be0d5a6981804dffb46743c Mon Sep 17 00:00:00 2001 From: HarrievG Date: Thu, 20 Oct 2022 13:20:55 +0200 Subject: [PATCH 10/11] - fixed dmap crash while trying to merge leaf nodes --- neo/tools/compilers/aas/BrushBSP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neo/tools/compilers/aas/BrushBSP.cpp b/neo/tools/compilers/aas/BrushBSP.cpp index 689b860f..7fb5e947 100644 --- a/neo/tools/compilers/aas/BrushBSP.cpp +++ b/neo/tools/compilers/aas/BrushBSP.cpp @@ -2258,7 +2258,8 @@ bool idBrushBSP::TryMergeLeafNodes( idBrushBSPPortal* portal, int side ) // replace every reference to node2 by a reference to node1 UpdateTreeAfterMerge_r( root, bounds, node2, node1 ); - delete node2; + if (node2->GetFlags() & NODE_DONE) + delete node2; return true; } From 9866e121ba9f8fa2f1ad43f372d5195ce74b747d Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 20 Oct 2022 16:40:11 +0200 Subject: [PATCH 11/11] Cleanup & Astyle --- neo/tools/compilers/aas/BrushBSP.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neo/tools/compilers/aas/BrushBSP.cpp b/neo/tools/compilers/aas/BrushBSP.cpp index 7fb5e947..811a9f8a 100644 --- a/neo/tools/compilers/aas/BrushBSP.cpp +++ b/neo/tools/compilers/aas/BrushBSP.cpp @@ -2258,8 +2258,12 @@ bool idBrushBSP::TryMergeLeafNodes( idBrushBSPPortal* portal, int side ) // replace every reference to node2 by a reference to node1 UpdateTreeAfterMerge_r( root, bounds, node2, node1 ); - if (node2->GetFlags() & NODE_DONE) + // HarrievG: fixed crash with polygon maps + if( node2->GetFlags() & NODE_DONE ) + { delete node2; + } + // HarrievG end return true; }