Skip to content

Commit

Permalink
v1.134:
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
dzhdanNV committed May 21, 2024
1 parent 097ece9 commit 5123bb7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions Include/NRI.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Non-goals:
#include <stddef.h>

#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
Expand Down
4 changes: 2 additions & 2 deletions Include/NRICompatibility.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Resources/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions Source/VK/ConversionVK.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 13 additions & 8 deletions Source/Validation/DeviceVal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@

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) {
n += x & 1;
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);
Expand Down Expand Up @@ -447,20 +451,20 @@ 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;

RETURN_ON_FAILURE(
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;
Expand Down Expand Up @@ -1153,15 +1157,16 @@ 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];

RETURN_ON_FAILURE(
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;
Expand Down

0 comments on commit 5123bb7

Please sign in to comment.