mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-19 16:21:11 +00:00
Merge pull request #730 from SRSaunders/635-nvrhi5-build-fixes
[Vulkan] Build fixes for linux/macOS and update Vulkan descriptor selectors for BinkDec shaders
This commit is contained in:
commit
3e13aa15f9
19 changed files with 138 additions and 114 deletions
|
@ -29,6 +29,12 @@ option(USE_PRECOMPILED_HEADERS
|
|||
option(OPENAL
|
||||
"Use OpenAL soft instead of XAudio2" OFF)
|
||||
|
||||
option(FFMPEG
|
||||
"Use FMPEG to render Bink videos" ON)
|
||||
|
||||
option(BINKDEC
|
||||
"Use included libbinkdec to render Bink videos" OFF)
|
||||
|
||||
option(SPIRV_SHADERC
|
||||
"Compile SPIR-V shader byte code using shaderc instead of using Glslang directly" OFF)
|
||||
|
||||
|
@ -72,18 +78,10 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)" OR CMAKE_OSX_AR
|
|||
endif()
|
||||
|
||||
# SRS - Turn off MMX/SSE intrinsics when cross-compiling from Apple x86_64 to arm64
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)|(e2k)|(E2K)" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(x64)")
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)|(e2k)|(E2K)" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
|
||||
option(USE_INTRINSICS_SSE "Compile using SSE intrinsics (e.g mmx, sse, msse2)" ON)
|
||||
|
||||
option(FFMPEG "Use FMPEG to render Bink videos" ON)
|
||||
|
||||
option(BINKDEC "Use included libbinkdec to render Bink videos" OFF)
|
||||
else()
|
||||
option(USE_INTRINSICS_SSE "Compile using SSE intrinsics (e.g mmx, sse, msse2)" OFF)
|
||||
|
||||
option(FFMPEG "Use FMPEG to render Bink videos" OFF)
|
||||
|
||||
option(BINKDEC "Use included libbinkdec to render Bink videos" ON)
|
||||
endif()
|
||||
|
||||
if(FFMPEG AND BINKDEC)
|
||||
|
@ -94,14 +92,10 @@ if(UNIX)
|
|||
set(OPENAL ON)
|
||||
set(USE_DX12 OFF)
|
||||
set(USE_VULKAN ON)
|
||||
set(USE_NVRHI ON)
|
||||
#set(FFMPEG OFF)
|
||||
#set(BINKDEC ON)
|
||||
|
||||
# SRS - Disable precompiled headers when cross-compiling on OSX, e.g. when creating universal binaries
|
||||
if((CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" ) OR
|
||||
# (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64" AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
||||
(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64") OR (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x64"))
|
||||
if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" ) OR
|
||||
(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64"))
|
||||
set(USE_PRECOMPILED_HEADERS OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -384,6 +378,8 @@ if(USE_VULKAN)
|
|||
if(APPLE)
|
||||
# SRS - Enable Beta extensions for VULKAN_SDK portability subset features on OSX
|
||||
add_definitions(-DVK_ENABLE_BETA_EXTENSIONS)
|
||||
# SRS - Explicitly define dxc path so find_package(DXCspirv) uses the specified Vulkan SDK location on OSX
|
||||
set(DXC_SPIRV_EXECUTABLE $ENV{VULKAN_SDK}/bin/dxc CACHE FILEPATH "Path to SPIR-V shader compiler." FORCE)
|
||||
# SRS - Optionally link directly to MoltenVK headers/library for runtime config functions on OSX
|
||||
if(USE_MoltenVK)
|
||||
add_definitions(-DUSE_MoltenVK)
|
||||
|
@ -1087,7 +1083,7 @@ file(GLOB SDL_INCLUDES sys/sdl/*.h)
|
|||
file(GLOB SDL_SOURCES sys/sdl/*.cpp)
|
||||
|
||||
if(UNIX)
|
||||
#if(USE_VULKAN OR USE_VULKAN)
|
||||
#if(USE_VULKAN)
|
||||
get_filename_component(sdl_glimp_cpp_full_path ${CMAKE_CURRENT_SOURCE_DIR}/sys/sdl/sdl_glimp.cpp ABSOLUTE)
|
||||
list(REMOVE_ITEM SDL_SOURCES "${sdl_glimp_cpp_full_path}")
|
||||
#else()
|
||||
|
@ -1679,7 +1675,6 @@ else()
|
|||
add_definitions(-DUSE_FFMPEG)
|
||||
|
||||
include_directories(${FFMPEG_INCLUDE_DIR})
|
||||
link_directories(${FFMPEG_LIBRARIES_DIRS})
|
||||
endif()
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
cd ..
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
# change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET=<version> to match supported runtime targets
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
|
@ -1,6 +0,0 @@
|
|||
cd ..
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
# change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET=<version> to match supported runtime targets
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
|
@ -3,4 +3,4 @@ rm -rf build-vulkan
|
|||
mkdir build-vulkan
|
||||
cd build-vulkan
|
||||
# change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET=<version> to match supported runtime targets
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DNO_MULTI_CONFIG" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
||||
|
|
|
@ -3,4 +3,4 @@ rm -rf build-vulkan
|
|||
mkdir build-vulkan
|
||||
cd build-vulkan
|
||||
# change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET=<version> to match supported runtime targets
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DNO_MULTI_CONFIG -DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
cd ..
|
||||
rm -rf xcode-opengl-debug
|
||||
mkdir xcode-opengl-debug
|
||||
cd xcode-opengl-debug
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
|
@ -1,5 +0,0 @@
|
|||
cd ..
|
||||
rm -rf xcode-opengl-release
|
||||
mkdir xcode-opengl-release
|
||||
cd xcode-opengl-release
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
|
@ -1,6 +0,0 @@
|
|||
cd ..
|
||||
rm -rf xcode-opengl-universal
|
||||
mkdir xcode-opengl-universal
|
||||
cd xcode-opengl-universal
|
||||
# note: universal openal-soft library and include paths assume MacPorts install locations
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DOPENAL_LIBRARY=/opt/local/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/opt/local/include ../neo -Wno-dev
|
|
@ -4,7 +4,7 @@ mkdir xcode-vulkan-debug
|
|||
cd xcode-vulkan-debug
|
||||
# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds
|
||||
# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur
|
||||
# note 2: env variable MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1 enables MoltenVK's image view swizzle which may be required on older macOS versions or hardware (see vulkaninfo)
|
||||
# note 3: env variable MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0 disables MoltenVK's use of Metal argument buffers, which then removes the limit on sampler allocation
|
||||
# note 4: env variable VK_LAYER_MESSAGE_ID_FILTER=0xb408bc0b suppresses validation layer error messages caused by exceeding the maxSamplerAllocationCount limit
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENVIRONMENT="MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1;MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0;VK_LAYER_MESSAGE_ID_FILTER=0xb408bc0b" -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
||||
# note 2: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later
|
||||
#note 3: env variable MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1 enables MoltenVK's image view swizzle which may be required on older macOS versions or hardware (see vulkaninfo)
|
||||
# note 4: env variable MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=2 enables MoltenVK's use of Metal argument buffers only if VK_EXT_descriptor_indexing is enabled
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DUSE_VULKAN=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENVIRONMENT="MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1;MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=2" -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev
|
||||
|
|
|
@ -2,6 +2,7 @@ cd ..
|
|||
rm -rf xcode-vulkan-release
|
||||
mkdir xcode-vulkan-release
|
||||
cd xcode-vulkan-release
|
||||
# remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds
|
||||
# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
|
||||
# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds
|
||||
# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur
|
||||
# note 2: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev
|
||||
|
|
|
@ -2,7 +2,8 @@ cd ..
|
|||
rm -rf xcode-vulkan-universal
|
||||
mkdir xcode-vulkan-universal
|
||||
cd xcode-vulkan-universal
|
||||
# remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds
|
||||
# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur
|
||||
# note: universal openal-soft library and include paths assume MacPorts install locations
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DSDL2=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/opt/local/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/opt/local/include ../neo -Wno-dev
|
||||
# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds
|
||||
# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur
|
||||
# note 2: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later
|
||||
# note 3: universal openal-soft library and include paths assume MacPorts install locations
|
||||
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DFFMPEG=OFF -DBINKDEC=ON -DUSE_VULKAN=ON -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/opt/local/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/opt/local/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev
|
||||
|
|
|
@ -100,7 +100,7 @@ function(compile_shaders)
|
|||
--compiler ${FXC_EXECUTABLE})
|
||||
endif()
|
||||
|
||||
if (params_SPIRV_DXC AND USE_NVRHI_VULKAN)
|
||||
if (params_SPIRV_DXC AND USE_VULKAN)
|
||||
if (NOT DXC_SPIRV_EXECUTABLE)
|
||||
message(FATAL_ERROR "compile_shaders: DXC for SPIR-V not found --- please set DXC_SPIRV_EXECUTABLE to the full path to the DXC binary")
|
||||
endif()
|
||||
|
|
|
@ -218,7 +218,7 @@ class idRenderModelMD5 : public idRenderModelStatic
|
|||
{
|
||||
friend class idRenderModelGLTF;
|
||||
public:
|
||||
void InitFromFile( const char* fileName, const idImportOptions* options );
|
||||
void InitFromFile( const char* fileName, const idImportOptions* options ) override;
|
||||
bool LoadBinaryModel( idFile* file, const ID_TIME_T sourceTimeStamp ) override;
|
||||
void WriteBinaryModel( idFile* file, ID_TIME_T* _timeStamp = NULL ) const override;
|
||||
dynamicModel_t IsDynamicModel() const override;
|
||||
|
|
|
@ -1422,7 +1422,7 @@ struct glimpParms_t
|
|||
// Helper functions for using SDL2 and Vulkan on Linux.
|
||||
std::vector<const char*> get_required_extensions();
|
||||
#if defined( USE_NVRHI )
|
||||
bool CreateSDLWindowSurface( VkInstance instance, VkSurfaceKHR* surface );
|
||||
vk::Result CreateSDLWindowSurface( vk::Instance instance, vk::SurfaceKHR* surface );
|
||||
#else
|
||||
extern vulkanContext_t vkcontext;
|
||||
#endif
|
||||
|
|
|
@ -30,11 +30,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Y : register( t0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
Texture2D t_Cr : register( t1 VK_DESCRIPTOR_SET( 1 ) );
|
||||
Texture2D t_Cb : register( t2 VK_DESCRIPTOR_SET( 1 ) );
|
||||
Texture2D t_Y : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Cr : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Cb : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 2 ) );
|
||||
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
|
||||
struct PS_IN {
|
||||
|
@ -67,4 +67,4 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
color *= rpColor;
|
||||
|
||||
result.color = sRGBAToLinearRGBA( color );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,11 +30,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Y : register( t0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
Texture2D t_Cr : register( t1 VK_DESCRIPTOR_SET( 1 ) );
|
||||
Texture2D t_Cb : register( t2 VK_DESCRIPTOR_SET( 1 ) );
|
||||
Texture2D t_Y : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Cr : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Cb : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 2 ) );
|
||||
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : SV_Position;
|
||||
|
@ -69,4 +69,4 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float4 color = ( binkImage * fragment.color ) + fragment.texcoord1;
|
||||
result.color.xyz = color.xyz * color.w;
|
||||
result.color.w = color.w;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
#include <sys/DeviceManager.h>
|
||||
|
||||
#include <nvrhi/vulkan.h>
|
||||
// SRS - optionally needed for VK_MVK_MOLTENVK_EXTENSION_NAME and MoltenVK runtime config visibility
|
||||
#if defined(__APPLE__) && defined( USE_MoltenVK )
|
||||
#include <MoltenVK/vk_mvk_moltenvk.h>
|
||||
#endif
|
||||
#include <nvrhi/validation.h>
|
||||
|
||||
// Define the Vulkan dynamic dispatcher - this needs to occur in exactly one cpp file in the program.
|
||||
|
@ -475,7 +479,7 @@ void DeviceManager_VK::installDebugCallback()
|
|||
.setPfnCallback( vulkanDebugCallback )
|
||||
.setPUserData( this );
|
||||
|
||||
vk::Result res = m_VulkanInstance.createDebugReportCallbackEXT( &info, nullptr, &m_DebugReportCallback );
|
||||
const vk::Result res = m_VulkanInstance.createDebugReportCallbackEXT( &info, nullptr, &m_DebugReportCallback );
|
||||
assert( res == vk::Result::eSuccess );
|
||||
}
|
||||
|
||||
|
@ -673,7 +677,7 @@ bool DeviceManager_VK::findQueueFamilies( vk::PhysicalDevice physicalDevice, vk:
|
|||
vk::Bool32 presentSupported;
|
||||
// SRS - Use portable implmentation for detecting presentation support vs. Windows-specific Vulkan call
|
||||
if( queueFamily.queueCount > 0 &&
|
||||
vkGetPhysicalDeviceSurfaceSupportKHR( physicalDevice, i, surface, &presentSupported ) == VK_SUCCESS )
|
||||
physicalDevice.getSurfaceSupportKHR( i, surface, &presentSupported ) == vk::Result::eSuccess )
|
||||
{
|
||||
if( presentSupported )
|
||||
{
|
||||
|
@ -907,26 +911,22 @@ bool DeviceManager_VK::createDevice()
|
|||
*/
|
||||
bool DeviceManager_VK::createWindowSurface()
|
||||
{
|
||||
VkResult err = VK_SUCCESS;
|
||||
|
||||
// Create the platform-specific surface
|
||||
#if defined( VULKAN_USE_PLATFORM_SDL )
|
||||
// SRS - Support generic SDL platform for linux and macOS
|
||||
if( !CreateSDLWindowSurface( m_VulkanInstance, ( VkSurfaceKHR* )&m_WindowSurface ) )
|
||||
{
|
||||
err = VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
|
||||
}
|
||||
const vk::Result res = CreateSDLWindowSurface( m_VulkanInstance, &m_WindowSurface );
|
||||
|
||||
#elif defined( VK_USE_PLATFORM_WIN32_KHR )
|
||||
VkWin32SurfaceCreateInfoKHR surfaceCreateInfo = {};
|
||||
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
surfaceCreateInfo.hinstance = ( HINSTANCE )windowInstance;
|
||||
surfaceCreateInfo.hwnd = ( HWND )windowHandle;
|
||||
err = vkCreateWin32SurfaceKHR( m_VulkanInstance, &surfaceCreateInfo, nullptr, ( VkSurfaceKHR* )&m_WindowSurface );
|
||||
auto surfaceCreateInfo = vk::Win32SurfaceCreateInfoKHR()
|
||||
.setHinstance( ( HINSTANCE )windowInstance )
|
||||
.setHwnd( ( HWND )windowHandle );
|
||||
|
||||
const vk::Result res = m_VulkanInstance.createWin32SurfaceKHR( &surfaceCreateInfo, nullptr, &m_WindowSurface );
|
||||
#endif
|
||||
|
||||
if( err != VK_SUCCESS )
|
||||
if( res != vk::Result::eSuccess )
|
||||
{
|
||||
common->FatalError( "Failed to create a Vulkan window surface, error code = %s", nvrhi::vulkan::resultToString( err ) );
|
||||
common->FatalError( "Failed to create a Vulkan window surface, error code = %s", nvrhi::vulkan::resultToString( res ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1034,12 +1034,17 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain()
|
|||
enabledExtensions.instance.insert( VK_EXT_DEBUG_REPORT_EXTENSION_NAME );
|
||||
#if defined(__APPLE__) && defined( USE_MoltenVK )
|
||||
enabledExtensions.layers.insert( "MoltenVK" );
|
||||
#else
|
||||
enabledExtensions.layers.insert( "VK_LAYER_KHRONOS_validation" );
|
||||
#endif
|
||||
}
|
||||
|
||||
const vk::DynamicLoader dl;
|
||||
// SRS - when USE_MoltenVK defined, load libMoltenVK vs. the default libvulkan
|
||||
static const vk::DynamicLoader dl( "libMoltenVK.dylib" );
|
||||
#else
|
||||
enabledExtensions.layers.insert( "VK_LAYER_KHRONOS_validation" );
|
||||
}
|
||||
|
||||
// SRS - make static so ~DynamicLoader() does not prematurely unload vulkan dynamic lib
|
||||
static const vk::DynamicLoader dl;
|
||||
#endif
|
||||
const PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = // NOLINT(misc-misplaced-const)
|
||||
dl.getProcAddress<PFN_vkGetInstanceProcAddr>( "vkGetInstanceProcAddr" );
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init( vkGetInstanceProcAddr );
|
||||
|
@ -1075,6 +1080,36 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain()
|
|||
CHECK( createWindowSurface() );
|
||||
CHECK( pickPhysicalDevice() );
|
||||
CHECK( findQueueFamilies( m_VulkanPhysicalDevice, m_WindowSurface ) );
|
||||
|
||||
// SRS - when USE_MoltenVK defined, set MoltenVK runtime configuration parameters on macOS
|
||||
#if defined(__APPLE__) && defined( USE_MoltenVK )
|
||||
vk::PhysicalDeviceFeatures2 deviceFeatures2;
|
||||
vk::PhysicalDevicePortabilitySubsetFeaturesKHR portabilityFeatures;
|
||||
deviceFeatures2.setPNext( &portabilityFeatures );
|
||||
m_VulkanPhysicalDevice.getFeatures2( &deviceFeatures2 );
|
||||
|
||||
MVKConfiguration pConfig;
|
||||
size_t pConfigSize = sizeof( pConfig );
|
||||
|
||||
vkGetMoltenVKConfigurationMVK( m_VulkanInstance, &pConfig, &pConfigSize );
|
||||
|
||||
// SRS - If we don't have native image view swizzle, enable MoltenVK's image view swizzle feature
|
||||
if( portabilityFeatures.imageViewFormatSwizzle == VK_FALSE )
|
||||
{
|
||||
idLib::Printf( "Enabling MoltenVK's image view swizzle...\n" );
|
||||
pConfig.fullImageViewSwizzle = VK_TRUE;
|
||||
vkSetMoltenVKConfigurationMVK( m_VulkanInstance, &pConfig, &pConfigSize );
|
||||
}
|
||||
|
||||
// SRS - Turn MoltenVK's Metal argument buffer feature on for descriptor indexing only
|
||||
if( pConfig.useMetalArgumentBuffers == MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER )
|
||||
{
|
||||
idLib::Printf( "Enabling MoltenVK's Metal argument buffers for descriptor indexing...\n" );
|
||||
pConfig.useMetalArgumentBuffers = MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_DESCRIPTOR_INDEXING;
|
||||
vkSetMoltenVKConfigurationMVK( m_VulkanInstance, &pConfig, &pConfigSize );
|
||||
}
|
||||
#endif
|
||||
|
||||
CHECK( createDevice() );
|
||||
|
||||
auto vecInstanceExt = stringSetToVector( enabledExtensions.instance );
|
||||
|
|
|
@ -101,6 +101,7 @@ const char* Sys_DefaultSavePath()
|
|||
if( base_path )
|
||||
{
|
||||
savepath = SDL_strdup( base_path );
|
||||
savepath.StripTrailing( '/' );
|
||||
SDL_free( base_path );
|
||||
}
|
||||
#else
|
||||
|
@ -410,8 +411,9 @@ Sys_DefaultBasePath
|
|||
|
||||
Get the default base path
|
||||
- binary image path
|
||||
- MacOS app bundle resources directory path // SRS - Added MacOS app bundle resources path
|
||||
- current directory
|
||||
- macOS app bundle resources directory path // SRS - added macOS app bundle resources path
|
||||
- build directory path // SRS - added build directory path
|
||||
- hardcoded
|
||||
Try to be intelligent: if there is no BASE_GAMEDIR, try the next path
|
||||
================
|
||||
|
@ -419,11 +421,12 @@ Try to be intelligent: if there is no BASE_GAMEDIR, try the next path
|
|||
const char* Sys_DefaultBasePath()
|
||||
{
|
||||
struct stat st;
|
||||
idStr testbase;
|
||||
idStr testbase, exepath = {};
|
||||
basepath = Sys_EXEPath();
|
||||
if( basepath.Length() )
|
||||
{
|
||||
basepath.StripFilename();
|
||||
exepath = basepath;
|
||||
testbase = basepath;
|
||||
testbase += "/";
|
||||
testbase += BASE_GAMEDIR;
|
||||
|
@ -435,20 +438,6 @@ const char* Sys_DefaultBasePath()
|
|||
{
|
||||
common->Printf( "no '%s' directory in exe path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
|
||||
}
|
||||
#if defined(__APPLE__) // SRS - - Added check for MacOS app bundle resources path
|
||||
basepath += "/../Resources";
|
||||
testbase = basepath;
|
||||
testbase += "/";
|
||||
testbase += BASE_GAMEDIR;
|
||||
if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) )
|
||||
{
|
||||
return basepath.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "no '%s' directory in MacOS app bundle resources path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if( basepath != Posix_Cwd() )
|
||||
{
|
||||
|
@ -465,6 +454,41 @@ const char* Sys_DefaultBasePath()
|
|||
common->Printf( "no '%s' directory in cwd path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
|
||||
}
|
||||
}
|
||||
if( exepath.Length() )
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
// SRS - Check for macOS app bundle resources path
|
||||
basepath = exepath + "/../Resources";
|
||||
testbase = basepath;
|
||||
testbase += "/";
|
||||
testbase += BASE_GAMEDIR;
|
||||
if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) )
|
||||
{
|
||||
return basepath.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "no '%s' directory in macOS app bundle resources path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
|
||||
}
|
||||
#endif
|
||||
// SRS - Check for macOS/linux build path (directory structure with build dir and possible config suffix)
|
||||
#if defined(__APPLE__) && !defined( NO_MULTI_CONFIG )
|
||||
basepath = exepath + "/../.."; // for macOS Xcode builds with Debug/Release/etc config suffix
|
||||
#else
|
||||
basepath = exepath + "/.."; // for linux and macOS single-config makefile builds
|
||||
#endif
|
||||
testbase = basepath;
|
||||
testbase += "/";
|
||||
testbase += BASE_GAMEDIR;
|
||||
if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) )
|
||||
{
|
||||
return basepath.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "no '%s' directory in build path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
|
||||
}
|
||||
}
|
||||
common->Printf( "WARNING: using hardcoded default base path %s\n", DEFAULT_BASEPATH );
|
||||
return DEFAULT_BASEPATH;
|
||||
}
|
||||
|
|
|
@ -41,10 +41,6 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include <SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
// SRS - optinally needed for VK_MVK_MOLTENVK_EXTENSION_NAME visibility
|
||||
#if defined(__APPLE__) && defined(USE_MoltenVK)
|
||||
#include <MoltenVK/vk_mvk_moltenvk.h>
|
||||
#endif
|
||||
#include <vector>
|
||||
|
||||
#include "renderer/RenderCommon.h"
|
||||
|
@ -94,15 +90,15 @@ std::vector<const char*> get_required_extensions()
|
|||
|
||||
#if defined( USE_NVRHI )
|
||||
// SRS - Helper function for creating SDL Vulkan surface within DeviceManager_VK() when NVRHI enabled
|
||||
bool CreateSDLWindowSurface( VkInstance instance, VkSurfaceKHR* surface )
|
||||
vk::Result CreateSDLWindowSurface( vk::Instance instance, vk::SurfaceKHR* surface )
|
||||
{
|
||||
if( !SDL_Vulkan_CreateSurface( window, instance, surface ) )
|
||||
if( !SDL_Vulkan_CreateSurface( window, ( VkInstance )instance, ( VkSurfaceKHR* )surface ) )
|
||||
{
|
||||
common->Warning( "Error while creating SDL Vulkan surface: %s", SDL_GetError() );
|
||||
return false;
|
||||
return vk::Result::eErrorSurfaceLostKHR;
|
||||
}
|
||||
|
||||
return true;
|
||||
return vk::Result::eSuccess;
|
||||
}
|
||||
|
||||
bool DeviceManager::CreateWindowDeviceAndSwapChain( const glimpParms_t& parms, const char* windowTitle )
|
||||
|
|
Loading…
Reference in a new issue