From bf889b96313414fe8ec16e09f363241b94ba3639 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Wed, 19 Jan 2022 23:27:36 -0500 Subject: [PATCH] Vulkan: Simplify Instance error checking, fix validation errors when using BINK decoder, check GPU's maxSamplerAnisotropy (cherry picked from commit f0f7536e888e4a4b70a71510d5b61313aa4ebb6a) --- neo/renderer/Cinematic.cpp | 3 ++- neo/renderer/Vulkan/Image_VK.cpp | 2 +- neo/renderer/Vulkan/RenderBackend_VK.cpp | 22 ++++++++++------------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index 9e5a087e..d5187453 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -406,9 +406,9 @@ idCinematicLocal::idCinematicLocal() qStatus[0] = ( byte** )Mem_Alloc( 32768 * sizeof( byte* ), TAG_CINEMATIC ); qStatus[1] = ( byte** )Mem_Alloc( 32768 * sizeof( byte* ), TAG_CINEMATIC ); + isRoQ = false; // SRS - Initialize isRoQ for all cases, not just FFMPEG #if defined(USE_FFMPEG) // Carl: ffmpeg stuff, for bink and normal video files: - isRoQ = false; // fmt_ctx = avformat_alloc_context(); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) frame = av_frame_alloc(); @@ -731,6 +731,7 @@ bool idCinematicLocal::InitFromBinkDecFile( const char* qpath, bool amilooping ) startTime = Sys_Milliseconds(); memset( yuvBuffer, 0, sizeof( yuvBuffer ) ); framePos = -1; + ImageForTime( 0 ); // SRS - Was missing initial call to ImageForTime() - fixes validation errors when using Vulkan renderer return true; } diff --git a/neo/renderer/Vulkan/Image_VK.cpp b/neo/renderer/Vulkan/Image_VK.cpp index b004e7b0..54b09129 100644 --- a/neo/renderer/Vulkan/Image_VK.cpp +++ b/neo/renderer/Vulkan/Image_VK.cpp @@ -267,7 +267,7 @@ void idImage::CreateSampler() if( r_maxAnisotropicFiltering.GetInteger() > 0 ) { createInfo.anisotropyEnable = VK_TRUE; - createInfo.maxAnisotropy = r_maxAnisotropicFiltering.GetInteger(); + createInfo.maxAnisotropy = Min( r_maxAnisotropicFiltering.GetFloat(), vkcontext.gpu->props.limits.maxSamplerAnisotropy ); } break; diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index 1d3c4c10..b3423213 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -305,20 +305,18 @@ static void CreateVulkanInstance() ID_VK_CHECK( vkEnumerateInstanceExtensionProperties( NULL, &numInstanceExtensions, NULL ) ); ID_VK_VALIDATE( numInstanceExtensions > 0, "vkEnumerateInstanceExtensionProperties returned zero extensions." ); - if( numInstanceExtensions > 0 ) - { - idList< VkExtensionProperties > instanceExtensionProps; - instanceExtensionProps.SetNum( numInstanceExtensions ); - ID_VK_CHECK( vkEnumerateInstanceExtensionProperties( NULL, &numInstanceExtensions, instanceExtensionProps.Ptr() ) ); + idList< VkExtensionProperties > instanceExtensionProps; + instanceExtensionProps.SetNum( numInstanceExtensions ); + ID_VK_CHECK( vkEnumerateInstanceExtensionProperties( NULL, &numInstanceExtensions, instanceExtensionProps.Ptr() ) ); + ID_VK_VALIDATE( numInstanceExtensions > 0, "vkEnumerateInstanceExtensionProperties returned zero extensions." ); - for( int i = 0; i < numInstanceExtensions; i++ ) + for( int i = 0; i < numInstanceExtensions; i++ ) + { + if( idStr::Icmp( instanceExtensionProps[ i ].extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME ) == 0 ) { - if( idStr::Icmp( instanceExtensionProps[ i ].extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME ) == 0 ) - { - vkcontext.instanceExtensions.AddUnique( VK_EXT_DEBUG_UTILS_EXTENSION_NAME ); - vkcontext.debugUtilsSupportAvailable = true; - break; - } + vkcontext.instanceExtensions.AddUnique( VK_EXT_DEBUG_UTILS_EXTENSION_NAME ); + vkcontext.debugUtilsSupportAvailable = true; + break; } }