From 5123bb758aa35fb64d7c5582f808640e792ac51d Mon Sep 17 00:00:00 2001 From: dzhdan Date: Tue, 21 May 2024 11:25:51 +0800 Subject: [PATCH] v1.134: HIGHLIGHTS: - bug fixes and improvements DETAILS: - NRI included MR #67: backend fixes - NRI: added clarifications to the headers - VK: VK headers updated to v1.3.283 - VK: fixed regression introduced in MR #67 - D3D12: updated Agility SDK to v1.614 - HLSL: fixed double-use of a dummy built-in name - VALIDATION: added check to verify shader stage uniqueness in "CreatePipeline" --- CMakeLists.txt | 2 +- Include/NRI.h | 4 ++-- Include/NRICompatibility.hlsli | 4 ++-- Resources/Version.h | 2 +- Source/VK/ConversionVK.h | 5 +++++ Source/Validation/DeviceVal.cpp | 21 +++++++++++++-------- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26bcbfc3..556c8eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ option (NRI_ENABLE_WAYLAND_SUPPORT "Enable 'wayland' support" ON) # Options: D3D12 specific option (NRI_ENABLE_AGILITY_SDK_SUPPORT "Enable Agility SDK suupport to unlock access to recent D3D12 features" OFF) set (NRI_AGILITY_SDK_PATH "C:/AgilitySDK" CACHE STRING "Path to a directory containing Agility SDK (contents of '.nupkg/build/native/')") -set (NRI_AGILITY_SDK_VERSION "613" CACHE STRING "Agility SDK version") +set (NRI_AGILITY_SDK_VERSION "614" CACHE STRING "Agility SDK version") set (NRI_AGILITY_SDK_DIR "AgilitySDK" CACHE STRING "Directory where Agility SDK binaries will be copied to relative to 'CMAKE_RUNTIME_OUTPUT_DIRECTORY'") # Is submodule? diff --git a/Include/NRI.h b/Include/NRI.h index c66ddbfd..e14916a6 100644 --- a/Include/NRI.h +++ b/Include/NRI.h @@ -25,8 +25,8 @@ Non-goals: #include #define NRI_VERSION_MAJOR 1 -#define NRI_VERSION_MINOR 133 -#define NRI_VERSION_DATE "10 May 2024" +#define NRI_VERSION_MINOR 134 +#define NRI_VERSION_DATE "21 May 2024" #ifdef _WIN32 #define NRI_CALL __fastcall diff --git a/Include/NRICompatibility.hlsli b/Include/NRICompatibility.hlsli index 2545f12d..00291844 100644 --- a/Include/NRICompatibility.hlsli +++ b/Include/NRICompatibility.hlsli @@ -129,8 +129,8 @@ Draw parameters: #define NRI_DECLARE_DRAW_PARAMETERS \ int NRI_VERTEX_ID_OFFSET : SV_VertexID, \ uint NRI_INSTANCE_ID_OFFSET : SV_InstanceID, \ - [[vk::builtin("BaseVertex")]] int NRI_BASE_VERTEX : _SV_Nothing, \ - [[vk::builtin("BaseInstance")]] uint NRI_BASE_INSTANCE : _SV_Nothing + [[vk::builtin("BaseVertex")]] int NRI_BASE_VERTEX : _SV_Nothing1, \ + [[vk::builtin("BaseInstance")]] uint NRI_BASE_INSTANCE : _SV_Nothing2 #define NRI_VERTEX_ID (NRI_VERTEX_ID_OFFSET - NRI_BASE_VERTEX) #define NRI_INSTANCE_ID (NRI_INSTANCE_ID_OFFSET - NRI_BASE_INSTANCE) diff --git a/Resources/Version.h b/Resources/Version.h index c7086d53..86f33a82 100644 --- a/Resources/Version.h +++ b/Resources/Version.h @@ -4,7 +4,7 @@ #define STR(x) STR_HELPER(x) #define VERSION_MAJOR 1 -#define VERSION_MINOR 133 +#define VERSION_MINOR 134 #define VERSION_BUILD 0 #define VERSION_REVISION 0 diff --git a/Source/VK/ConversionVK.h b/Source/VK/ConversionVK.h index 6e87b162..c0f5e35e 100644 --- a/Source/VK/ConversionVK.h +++ b/Source/VK/ConversionVK.h @@ -102,6 +102,11 @@ constexpr VkPipelineStageFlags2 GetPipelineStageFlags(StageBits stageBits) { } constexpr VkShaderStageFlags GetShaderStageFlags(StageBits stage) { + // Check non-mask values first + if (stage == StageBits::ALL) + return VK_SHADER_STAGE_ALL; + + // Gather bits VkShaderStageFlags stageFlags = 0; if (stage & StageBits::VERTEX_SHADER) diff --git a/Source/Validation/DeviceVal.cpp b/Source/Validation/DeviceVal.cpp index fe2faf92..3a6bd872 100644 --- a/Source/Validation/DeviceVal.cpp +++ b/Source/Validation/DeviceVal.cpp @@ -21,7 +21,7 @@ using namespace nri; -static inline bool IsShaderStageValid(StageBits shaderStages, StageBits allowedStages) { +static inline bool IsShaderStageValid(StageBits shaderStages, uint32_t& uniqueShaderStages, StageBits allowedStages) { uint32_t x = (uint32_t)(shaderStages & allowedStages); uint32_t n = 0; while (x) { @@ -29,7 +29,11 @@ static inline bool IsShaderStageValid(StageBits shaderStages, StageBits allowedS x >>= 1; } - return n == 1 || shaderStages == StageBits::ALL; + x = (uint32_t)shaderStages; + bool isUnique = (uniqueShaderStages & x) == 0; + uniqueShaderStages |= x; + + return n == 1 && isUnique; } void ConvertGeometryObjectsVal(GeometryObject* destObjects, const GeometryObject* sourceObjects, uint32_t objectNum); @@ -447,9 +451,9 @@ Result DeviceVal::CreatePipeline(const GraphicsPipelineDesc& graphicsPipelineDes const PipelineLayoutVal& pipelineLayout = *(PipelineLayoutVal*)graphicsPipelineDesc.pipelineLayout; const StageBits shaderStages = pipelineLayout.GetPipelineLayoutDesc().shaderStages; bool hasEntryPoint = false; + uint32_t uniqueShaderStages = 0; for (uint32_t i = 0; i < graphicsPipelineDesc.shaderNum; i++) { const ShaderDesc* shaderDesc = graphicsPipelineDesc.shaders + i; - if (shaderDesc->stage == StageBits::VERTEX_SHADER || shaderDesc->stage == StageBits::MESH_CONTROL_SHADER) hasEntryPoint = true; @@ -457,10 +461,10 @@ Result DeviceVal::CreatePipeline(const GraphicsPipelineDesc& graphicsPipelineDes this, shaderDesc->stage & shaderStages, Result::INVALID_ARGUMENT, "CreatePipeline: 'graphicsPipelineDesc.shaders[%u].stage' is not enabled in the pipeline layout", i); RETURN_ON_FAILURE(this, shaderDesc->bytecode != nullptr, Result::INVALID_ARGUMENT, "CreatePipeline: 'graphicsPipelineDesc.shaders[%u].bytecode' is invalid", i); RETURN_ON_FAILURE(this, shaderDesc->size != 0, Result::INVALID_ARGUMENT, "CreatePipeline: 'graphicsPipelineDesc.shaders[%u].size' is 0", i); - RETURN_ON_FAILURE(this, IsShaderStageValid(shaderDesc->stage, StageBits::GRAPHICS_SHADERS), Result::INVALID_ARGUMENT, - "CreatePipeline: 'graphicsPipelineDesc.shaders[%u].stage' must include only 1 graphics shader stage", i); + RETURN_ON_FAILURE(this, IsShaderStageValid(shaderDesc->stage, uniqueShaderStages, StageBits::GRAPHICS_SHADERS), Result::INVALID_ARGUMENT, + "CreatePipeline: 'graphicsPipelineDesc.shaders[%u].stage' must include only 1 graphics shader stage, unique for the entire pipeline", i); } - RETURN_ON_FAILURE(this, hasEntryPoint, Result::INVALID_ARGUMENT, "CreatePipeline: Vertex or Mesh control shader is not provided"); + RETURN_ON_FAILURE(this, hasEntryPoint, Result::INVALID_ARGUMENT, "CreatePipeline: a VERTEX or MESH_CONTROL shader is not provided"); for (uint32_t i = 0; i < graphicsPipelineDesc.outputMerger.colorNum; i++) { const ColorAttachmentDesc* color = graphicsPipelineDesc.outputMerger.color + i; @@ -1153,6 +1157,7 @@ Result DeviceVal::CreateRayTracingPipeline(const RayTracingPipelineDesc& pipelin RETURN_ON_FAILURE(this, pipelineDesc.shaderGroupDescNum != 0, Result::INVALID_ARGUMENT, "CreateRayTracingPipeline: 'pipelineDesc.shaderGroupDescNum' is 0"); RETURN_ON_FAILURE(this, pipelineDesc.recursionDepthMax != 0, Result::INVALID_ARGUMENT, "CreateRayTracingPipeline: 'pipelineDesc.recursionDepthMax' is 0"); + uint32_t uniqueShaderStages = 0; for (uint32_t i = 0; i < pipelineDesc.shaderLibrary->shaderNum; i++) { const ShaderDesc& shaderDesc = pipelineDesc.shaderLibrary->shaders[i]; @@ -1160,8 +1165,8 @@ Result DeviceVal::CreateRayTracingPipeline(const RayTracingPipelineDesc& pipelin this, shaderDesc.bytecode != nullptr, Result::INVALID_ARGUMENT, "CreateRayTracingPipeline: 'pipelineDesc.shaderLibrary->shaders[%u].bytecode' is invalid", i); RETURN_ON_FAILURE(this, shaderDesc.size != 0, Result::INVALID_ARGUMENT, "CreateRayTracingPipeline: 'pipelineDesc.shaderLibrary->shaders[%u].size' is 0", i); - RETURN_ON_FAILURE(this, IsShaderStageValid(shaderDesc.stage, StageBits::RAY_TRACING_SHADERS), Result::INVALID_ARGUMENT, - "CreateRayTracingPipeline: 'pipelineDesc.shaderLibrary->shaders[%u].stage' must include only 1 ray tracing shader stage", i); + RETURN_ON_FAILURE(this, IsShaderStageValid(shaderDesc.stage, uniqueShaderStages, StageBits::RAY_TRACING_SHADERS), Result::INVALID_ARGUMENT, + "CreateRayTracingPipeline: 'pipelineDesc.shaderLibrary->shaders[%u].stage' must include only 1 ray tracing shader stage, unique for the entire pipeline", i); } auto pipelineDescImpl = pipelineDesc;