Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8b836c0
Added SHADER_RESOURCE_TYPE_INLINE_CONSTANTS enum value (#672)
TheMostDiligent Oct 19, 2025
28e2ebe
D3D12/RootParamsManager: add support for root constants (#672)
TheMostDiligent Oct 19, 2025
8f6ba3c
ResourceSignatureD3D12: implement CommitRootConstants method (#672)
TheMostDiligent Oct 19, 2025
db536bc
Add DRAW_FLAG_INLINE_CONSTANTS_INTACT flag (#672)
TheMostDiligent Oct 19, 2025
ba64ae9
IShaderResourceVariable: add SetInlineConstants method plumbing (#672)
TheMostDiligent Oct 19, 2025
5492581
ResourceSignatureD3D12: set all root constants at once (#672)
TheMostDiligent Oct 19, 2025
df28e00
ResourceCacheD3D12: implement SetInlineConstants (#672)
TheMostDiligent Oct 20, 2025
0059823
Replace SHADER_RESOURCE_TYPE_INLINE_CONSTANTS type with PIPELINE_RESO…
TheMostDiligent Oct 20, 2025
f62ff51
ResourceSignatureD3D12: initialize root constants (#672)
TheMostDiligent Oct 20, 2025
44628cf
ShaderResourceCacheD3D12: allocate space for inline constant values (…
TheMostDiligent Oct 22, 2025
4979c95
ResourceSignatureD3D12: copy inline constants from static resources (…
TheMostDiligent Oct 22, 2025
86f15cf
ShaderResourceCacheD3D12: do not transition/validate null resources
TheMostDiligent Oct 22, 2025
75af7b2
ShaderVarManagerD3D12: properly handle offset from table start for in…
TheMostDiligent Oct 22, 2025
29693cf
ResourceSignatureD3D12: use correct array size for inline constants w…
TheMostDiligent Oct 23, 2025
3d4ae9e
D3D12: commit root constants; add inline constants test (#672)
TheMostDiligent Oct 23, 2025
b5d4e1b
Improve inline constants test
TheMostDiligent Oct 23, 2025
8187227
Improved inline constant validation (#672)
TheMostDiligent Oct 23, 2025
9cdc234
Improve inline constants resource description validation (#672)
TheMostDiligent Oct 23, 2025
ce6fb94
Add inline constants test with two resource signatures (#672)
TheMostDiligent Oct 23, 2025
175fbf6
D3DShaderResourceLoader: don't use auto where unnecessary
TheMostDiligent Oct 24, 2025
1b9419c
D3DShaderResourceAttribs: store constant buffer size
TheMostDiligent Oct 24, 2025
bd8cc46
Add SHADER_VARIABLE_FLAG_INLINE_CONSTANTS flag with implementation in…
TheMostDiligent Oct 24, 2025
c4134c3
Add validation for SHADER_VARIABLE_FLAG_INLINE_CONSTANTS flag
TheMostDiligent Oct 24, 2025
b3c1365
Add test for inline constants in render state cache
TheMostDiligent Oct 25, 2025
8a90ceb
PipelineStateD3D11: handle inline constants flag (#672)
TheMostDiligent Oct 25, 2025
d67997b
Inline Constants test: use constants in PS (#672)
TheMostDiligent Oct 26, 2025
3961e5a
ShaderResourceCacheD3D11: enable inline constants (#672)
TheMostDiligent Oct 26, 2025
5aa7013
ResourceSignatureD3D11: implement inline constant buffers update (#672)
TheMostDiligent Oct 27, 2025
061a231
DeviceContextD3D11: update inline constant buffers (#672)
TheMostDiligent Oct 27, 2025
2a8dc91
D3D11: fix inline constant buffers remapping; enable inline constant …
TheMostDiligent Oct 27, 2025
fbdf688
D3D11/D3D12: improved handling of DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_…
TheMostDiligent Oct 27, 2025
95d4239
D3D11/D3D12: clean up code and update documentation for inline constants
TheMostDiligent Oct 30, 2025
d43bb1b
Add tests for inline constants flag validation
TheMostDiligent Oct 31, 2025
03c05e1
SPIRVShaderResources: Add support for push constants (#733)
hzqst Dec 13, 2025
d39eda1
Add DXC tests to SPIRVShaderResourcesTest (#736)
hzqst Dec 16, 2025
e256723
SPIRVShaderResourcesTest: simplify code
TheMostDiligent Dec 16, 2025
aabb421
Add ConvertUBOToPushConstants and corresponding tests (#737)
hzqst Dec 24, 2025
1980a5d
ConvertUBOToPushConstantPass: return SuccessWithoutChange if UBO is n…
TheMostDiligent Dec 24, 2025
973c29e
ConvertUBOToPushConstantPass: minor refactor
TheMostDiligent Dec 24, 2025
3d75fa7
ConvertUBOToPushConstantPass: better handle edge cases
TheMostDiligent Dec 24, 2025
04feca3
ConvertUBOToPushConstantPass: add descriptive failure messages
TheMostDiligent Dec 24, 2025
dd2dfb7
ConvertUBOToPushConstantPass: fail if the UBO is not found
TheMostDiligent Dec 25, 2025
79deb9f
Fix ConvertUBOToPushConstant: The pointer type instruction needs to b…
hzqst Dec 27, 2025
bf3a482
ConvertUBOToPushConstantPass: invalidated analyses after correspondin…
TheMostDiligent Dec 27, 2025
c3b47c2
ConvertUBOToPushConstantPass: do not fail on unknown pointer-producin…
TheMostDiligent Dec 27, 2025
3291252
ConvertUBOToPushConstantPass: do not cache type mgr
TheMostDiligent Dec 27, 2025
adfac1b
ConvertUBOToPushConstantPass: inline functions before conversion
TheMostDiligent Dec 27, 2025
ad83193
SPIRVTools.hpp: remove dependency on libspirv.h
TheMostDiligent Dec 27, 2025
c0d3ccb
Add ConvertUBOToPushConstantsTestVk (#746)
hzqst Dec 28, 2025
578f8f4
Add DILIGENT_MAX_INLINE_CONSTANTS_SIZE constant (#748)
hzqst Jan 1, 2026
697eff0
Replace MAX_INLINE_CONSTANTS_SIZE with MAX_INLINE_CONSTANTS
TheMostDiligent Jan 1, 2026
8bffc4d
SPIRVShaderResources: use CreateInfo struct to group constructor para…
TheMostDiligent Jan 2, 2026
b0ce020
SPIRVShaderResources: add Create method
TheMostDiligent Jan 2, 2026
ceca0c5
PipelineResourceSignatureVkImpl: use ResDesc.GetArraySize() to correc…
TheMostDiligent Jan 2, 2026
b4950ec
Fix issue from https://github.com/DiligentGraphics/DiligentCore/pull/747
hzqst Jan 2, 2026
8590808
fix formatting
hzqst Jan 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Graphics/Archiver/src/Archiver_Vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ void SerializedPipelineStateImpl::PatchShadersVk(const CreateInfoType& CreateInf
{
ShaderStageInfoVk& Src{ShaderStages[i]};
PipelineStateVkImpl::ShaderStageInfo& Dst{ShaderStagesVk[i]};
Dst.Type = Src.Type;
Dst.Shaders = std::move(Src.Shaders);
Dst.SPIRVs = std::move(Src.SPIRVs);
Dst.Type = Src.Type;
Dst.Shaders = std::move(Src.Shaders);
Dst.SPIRVs = std::move(Src.SPIRVs);
Dst.ShaderResources = std::move(Src.ShaderResources);
}

IPipelineResourceSignature** ppSignatures = CreateInfo.ppResourceSignatures;
Expand Down
13 changes: 10 additions & 3 deletions Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,13 +1637,17 @@ String GetPipelineResourceFlagsString(PIPELINE_RESOURCE_FLAGS Flags, bool GetFul

PIPELINE_RESOURCE_FLAGS Flag = ExtractLSB(Flags);

static_assert(PIPELINE_RESOURCE_FLAG_LAST == (1u << 4), "Please update the switch below to handle the new pipeline resource flag.");
static_assert(PIPELINE_RESOURCE_FLAG_LAST == (1u << 5), "Please update the switch below to handle the new pipeline resource flag.");
switch (Flag)
{
case PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS:
Str.append(GetFullName ? "PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS" : "NO_DYNAMIC_BUFFERS");
break;

case PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS:
Str.append(GetFullName ? "PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS" : "INLINE_CONSTANTS");
break;

case PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER:
Str.append(GetFullName ? "PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER" : "COMBINED_SAMPLER");
break;
Expand Down Expand Up @@ -1808,7 +1812,7 @@ PIPELINE_RESOURCE_FLAGS GetValidPipelineResourceFlags(SHADER_RESOURCE_TYPE Resou
switch (ResourceType)
{
case SHADER_RESOURCE_TYPE_CONSTANT_BUFFER:
return PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS | PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY;
return PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS | PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY | PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS;

case SHADER_RESOURCE_TYPE_TEXTURE_SRV:
return PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER | PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY;
Expand Down Expand Up @@ -1839,7 +1843,7 @@ PIPELINE_RESOURCE_FLAGS GetValidPipelineResourceFlags(SHADER_RESOURCE_TYPE Resou

PIPELINE_RESOURCE_FLAGS ShaderVariableFlagsToPipelineResourceFlags(SHADER_VARIABLE_FLAGS Flags)
{
static_assert(SHADER_VARIABLE_FLAG_LAST == (1 << 3), "Please update the switch below to handle the new shader variable flags");
static_assert(SHADER_VARIABLE_FLAG_LAST == (1 << 4), "Please update the switch below to handle the new shader variable flags");
switch (Flags)
{
case SHADER_VARIABLE_FLAG_NONE:
Expand All @@ -1848,6 +1852,9 @@ PIPELINE_RESOURCE_FLAGS ShaderVariableFlagsToPipelineResourceFlags(SHADER_VARIAB
case SHADER_VARIABLE_FLAG_NO_DYNAMIC_BUFFERS:
return PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS;

case SHADER_VARIABLE_FLAG_INLINE_CONSTANTS:
return PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS;

case SHADER_VARIABLE_FLAG_GENERAL_INPUT_ATTACHMENT_VK:
return PIPELINE_RESOURCE_FLAG_GENERAL_INPUT_ATTACHMENT;

Expand Down
18 changes: 17 additions & 1 deletion Graphics/GraphicsEngine/include/DeviceContextBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ class DeviceContextBase : public ObjectBase<typename EngineImplTraits::DeviceCon
// buffers with dynamic offsets in all backends).
SRBMaskType DynamicSRBMask = 0;

// Indicates which SRBs contain inline constants
SRBMaskType InlineConstantsSRBMask = 0;

void Set(Uint32 Index, ShaderResourceBindingImplType* pSRB)
{
VERIFY_EXPR(Index < MAX_RESOURCE_SIGNATURES);
Expand All @@ -398,6 +401,11 @@ class DeviceContextBase : public ObjectBase<typename EngineImplTraits::DeviceCon
else
DynamicSRBMask &= ~SRBBit;

if (pResourceCache != nullptr && pResourceCache->HasInlineConstants())
InlineConstantsSRBMask |= SRBBit;
else
InlineConstantsSRBMask &= ~SRBBit;

#ifdef DILIGENT_DEVELOPMENT
SRBs[Index] = pSRB;
if (pSRB != nullptr)
Expand All @@ -412,18 +420,26 @@ class DeviceContextBase : public ObjectBase<typename EngineImplTraits::DeviceCon
}

// Returns the mask of SRBs whose resources need to be committed
SRBMaskType GetCommitMask(bool DynamicResourcesIntact = false) const
SRBMaskType GetCommitMask(bool DynamicResourcesIntact = false,
bool InlineConstantsIntact = false) const
{
#ifdef DILIGENT_DEVELOPMENT
DvpVerifyCacheRevisions();
#endif

// Stale SRBs always have to be committed
SRBMaskType CommitMask = StaleSRBMask;

// If dynamic resources are not intact, SRBs with dynamic resources
// have to be handled
if (!DynamicResourcesIntact)
CommitMask |= DynamicSRBMask;

// If inline constants are not intact, SRBs with inline constants
// have to be handled
if (!InlineConstantsIntact)
CommitMask |= InlineConstantsSRBMask;

// Only process SRBs that are used by current PSO
CommitMask &= ActiveSRBMask;
return CommitMask;
Expand Down
69 changes: 69 additions & 0 deletions Graphics/GraphicsEngine/include/ShaderResourceVariableBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@ bool VerifyConstantBufferBinding(const PipelineResourceDesc& ResDesc,
Uint64 CachedRangeSize,
const char* SignatureName)
{
if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
{
std::stringstream ss;
ss << "Error binding buffer to variable '" << GetShaderResourcePrintName(ResDesc, BindInfo.ArrayIndex) << '\'';
if (SignatureName != nullptr)
{
ss << " defined by signature '" << SignatureName << '\'';
}
ss << ". The variable is marked as inline constants and cannot be bound to a buffer. "
"Use IShaderResourceVariable::SetInlineConstants() method to set the inline constant values.";
RESOURCE_VALIDATION_FAILURE(ss.str());
return false;
}

bool BindingOK = VerifyResourceBinding("buffer", ResDesc, BindInfo, pBufferImpl, pCachedBuffer, SignatureName);

if (pBufferImpl != nullptr)
Expand Down Expand Up @@ -540,6 +554,12 @@ bool VerifyDynamicBufferOffset(const PipelineResourceDesc& ResDesc,
{
bool BindingOK = true;

if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
{
RESOURCE_VALIDATION_FAILURE("Error setting dynamic buffer offset for variable '", ResDesc.Name, "': inline constants do not support dynamic offsets.");
BindingOK = false;
}

if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS) != 0)
{
RESOURCE_VALIDATION_FAILURE("Error setting dynamic buffer offset for variable '", ResDesc.Name, "': the variable was created with PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS flag.");
Expand Down Expand Up @@ -602,6 +622,34 @@ bool VerifyDynamicBufferOffset(const PipelineResourceDesc& ResDesc,
}


inline bool VerifyInlineConstants(const PipelineResourceDesc& ResDesc,
const void* pConstants,
Uint32 FirstConstant,
Uint32 NumConstants)
{
bool ParamsOK = true;
if (ResDesc.ResourceType != SHADER_RESOURCE_TYPE_CONSTANT_BUFFER)
{
RESOURCE_VALIDATION_FAILURE("SetInlineConstants() is only allowed for constant buffer resources.");
ParamsOK = false;
}

if (pConstants == nullptr)
{
RESOURCE_VALIDATION_FAILURE("Pointer to inline constants is null.");
ParamsOK = false;
}

if (FirstConstant + NumConstants > ResDesc.ArraySize)
{
RESOURCE_VALIDATION_FAILURE("Inline constant range (", FirstConstant, " .. ", FirstConstant + NumConstants - 1,
") is out of bounds for variable '", ResDesc.Name, "' of size ", ResDesc.ArraySize, " constants.");
ParamsOK = false;
}

return ParamsOK;
}

#undef RESOURCE_VALIDATION_FAILURE

template <typename ShaderVectorType>
Expand Down Expand Up @@ -713,6 +761,27 @@ struct ShaderVariableBase : public ResourceVariableBaseInterface
}


virtual void DILIGENT_CALL_TYPE SetInlineConstants(const void* pConstants,
Uint32 FirstConstant,
Uint32 NumConstants) override final
{
#ifdef DILIGENT_DEVELOPMENT
{
const PipelineResourceDesc& Desc = GetDesc();
DEV_CHECK_ERR(Desc.ResourceType == SHADER_RESOURCE_TYPE_CONSTANT_BUFFER,
"SetInlineConstants() is only allowed for constant buffer resources.");
DEV_CHECK_ERR(Desc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS,
"SetInlineConstants() is only allowed for inline constant buffers.");
DEV_CHECK_ERR(pConstants != nullptr, "Pointer to inline constants is null.");
DEV_CHECK_ERR(FirstConstant + NumConstants <= Desc.ArraySize,
"Inline constant range (", FirstConstant, " .. ", FirstConstant + NumConstants - 1,
") is out of bounds for variable '", Desc.Name, "' of size ", Desc.ArraySize, " constants.");
}
#endif

static_cast<ThisImplType*>(this)->SetConstants(pConstants, FirstConstant, NumConstants);
}

virtual SHADER_RESOURCE_VARIABLE_TYPE DILIGENT_CALL_TYPE GetType() const override final
{
return GetDesc().VarType;
Expand Down
6 changes: 5 additions & 1 deletion Graphics/GraphicsEngine/interface/Constants.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 Diligent Graphics LLC
* Copyright 2019-2026 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -62,6 +62,9 @@ DILIGENT_BEGIN_NAMESPACE(Diligent)
/// Bit shift for the the shading X-axis rate.
#define DILIGENT_SHADING_RATE_X_SHIFT 2

/// The maximum number of 4-byte inline constants in a pipeline state.
#define DILIGENT_MAX_INLINE_CONSTANTS 64

static DILIGENT_CONSTEXPR Uint32 MAX_BUFFER_SLOTS = DILIGENT_MAX_BUFFER_SLOTS;
static DILIGENT_CONSTEXPR Uint32 MAX_RENDER_TARGETS = DILIGENT_MAX_RENDER_TARGETS;
static DILIGENT_CONSTEXPR Uint32 MAX_VIEWPORTS = DILIGENT_MAX_VIEWPORTS;
Expand All @@ -71,5 +74,6 @@ static DILIGENT_CONSTEXPR Uint32 DEFAULT_ADAPTER_ID = DILIGENT_DEFAULT_ADAP
static DILIGENT_CONSTEXPR Uint8 DEFAULT_QUEUE_ID = DILIGENT_DEFAULT_QUEUE_ID;
static DILIGENT_CONSTEXPR Uint32 MAX_SHADING_RATES = DILIGENT_MAX_SHADING_RATES;
static DILIGENT_CONSTEXPR Uint32 SHADING_RATE_X_SHIFT = DILIGENT_SHADING_RATE_X_SHIFT;
static DILIGENT_CONSTEXPR Uint32 MAX_INLINE_CONSTANTS = DILIGENT_MAX_INLINE_CONSTANTS;

DILIGENT_END_NAMESPACE // namespace Diligent
22 changes: 21 additions & 1 deletion Graphics/GraphicsEngine/interface/DeviceContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,27 @@ DILIGENT_TYPED_ENUM(DRAW_FLAGS, Uint8)
/// (see RootSignature::CommitRootViews). When `DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT` is set, root views are only bound
/// by the first draw command that uses the PSO + SRB pair. The flag avoids setting the same GPU virtual addresses when
/// they stay unchanged.
DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT = 1u << 2u
///
/// \see DRAW_FLAG_INLINE_CONSTANTS_INTACT, DRAW_FLAG_DYNAMIC_BUFFERS_AND_INLINE_CONSTANTS_INTACT
DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT = 1u << 2u,

/// Indicates that none of the inline constants used by the draw command
/// have been modified by the CPU since the last command.
///
/// This flag should be used to improve performance when an application issues a
/// series of draw commands that use the same pipeline state and shader resources and
/// no inline constants are updated between the commands.
///
/// \see DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, DRAW_FLAG_DYNAMIC_BUFFERS_AND_INLINE_CONSTANTS_INTACT
DRAW_FLAG_INLINE_CONSTANTS_INTACT = 1u << 3u,

/// Indicates that neither the dynamic resource buffers nor the inline constants used by
/// the draw command have been modified by the CPU since the previous command.
///
/// \see DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, DRAW_FLAG_INLINE_CONSTANTS_INTACT
DRAW_FLAG_DYNAMIC_BUFFERS_AND_INLINE_CONSTANTS_INTACT =
DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT |
DRAW_FLAG_INLINE_CONSTANTS_INTACT
};
DEFINE_FLAG_ENUM_OPERATORS(DRAW_FLAGS)

Expand Down
39 changes: 34 additions & 5 deletions Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,28 @@ DILIGENT_TYPED_ENUM(PIPELINE_RESOURCE_FLAGS, Uint8)
/// PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS flag.
PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS = 1u << 0,

/// Indicates that the resource consists of inline constants (also
/// known as push constants in Vulkan or root constants in Direct3D12).
///
/// Applies to SHADER_RESOURCE_TYPE_CONSTANT_BUFFER only.
///
/// Use this flag if you have a buffer of frequently changing constants
/// - that are small in size (typically up to 128 bytes) and
/// - change often (e.g. per-draw or per-dispatch).
///
/// Inline constants are set directly using IShaderResourceVariable::SetInlineConstants.
///
/// This flag cannot be combined with any other flags.
///
/// In Vulkan and Direct3D12, inline constants are not bound via descriptor sets or root
/// signatures, but are set directly in command buffers or command lists and are very cheap.
/// In legacy APIs (Direct3D11 and OpenGL), inline constants are emulated using regular
/// constant buffers and thus have higher overhead.
PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS = 1u << 1,

/// Indicates that a texture SRV will be combined with a sampler.
/// Applies to SHADER_RESOURCE_TYPE_TEXTURE_SRV resources.
PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER = 1u << 1,
PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER = 1u << 2,

/// Indicates that this variable will be used to bind formatted buffers.
/// Applies to SHADER_RESOURCE_TYPE_BUFFER_UAV and SHADER_RESOURCE_TYPE_BUFFER_SRV
Expand All @@ -117,19 +136,19 @@ DILIGENT_TYPED_ENUM(PIPELINE_RESOURCE_FLAGS, Uint8)
/// as opposed to structured buffers. If an application will be using
/// formatted buffers with buffer UAVs and SRVs, it must specify the
/// PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER flag.
PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER = 1u << 2,
PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER = 1u << 3,

/// Indicates that resource is a run-time sized shader array (e.g. an array without a specific size).
PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY = 1u << 3,
PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY = 1u << 4,

/// Indicates that the resource is an input attachment in general layout, which allows simultaneously
/// reading from the resource through the input attachment and writing to it via color or depth-stencil
/// attachment.
///
/// \note This flag is only valid in Vulkan.
PIPELINE_RESOURCE_FLAG_GENERAL_INPUT_ATTACHMENT = 1u << 4,
PIPELINE_RESOURCE_FLAG_GENERAL_INPUT_ATTACHMENT = 1u << 5,

PIPELINE_RESOURCE_FLAG_LAST = PIPELINE_RESOURCE_FLAG_GENERAL_INPUT_ATTACHMENT
PIPELINE_RESOURCE_FLAG_LAST = PIPELINE_RESOURCE_FLAG_GENERAL_INPUT_ATTACHMENT
};
DEFINE_FLAG_ENUM_OPERATORS(PIPELINE_RESOURCE_FLAGS);

Expand Down Expand Up @@ -269,6 +288,9 @@ struct PipelineResourceDesc
SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);

/// Resource array size (must be 1 for non-array resources).
///
/// For inline constants (see PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS),
/// this member specifies the number of 4-byte values.
Uint32 ArraySize DEFAULT_INITIALIZER(1);

/// Resource type, see Diligent::SHADER_RESOURCE_TYPE.
Expand Down Expand Up @@ -334,6 +356,13 @@ struct PipelineResourceDesc
{
return !(*this == Rhs);
}

Uint32 GetArraySize() const noexcept
{
return (Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0 ?
1 : // For inline constants, ArraySize is the number of 4-byte constants.
ArraySize;
}
#endif
};
typedef struct PipelineResourceDesc PipelineResourceDesc;
Expand Down
16 changes: 13 additions & 3 deletions Graphics/GraphicsEngine/interface/PipelineState.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,32 @@ DILIGENT_TYPED_ENUM(SHADER_VARIABLE_FLAGS, Uint8)
/// flag in the internal pipeline resource signature.
SHADER_VARIABLE_FLAG_NO_DYNAMIC_BUFFERS = 1u << 0,

/// Indicates that the resource consists of inline constants
/// (also known as push constants in Vulkan or root constants in Direct3D12).
/// Applies to Diligent::SHADER_RESOURCE_TYPE_CONSTANT_BUFFER only.
///
/// \remarks This flag directly translates to the Diligent::PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS
/// flag in the internal pipeline resource signature.
///
/// See Diligent::PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS for more details.
SHADER_VARIABLE_FLAG_INLINE_CONSTANTS = 1u << 1,

/// Indicates that the resource is an input attachment in general layout, which allows simultaneously
/// reading from the resource through the input attachment and writing to it via color or depth-stencil
/// attachment.
///
/// \note This flag is only valid in Vulkan.
SHADER_VARIABLE_FLAG_GENERAL_INPUT_ATTACHMENT_VK = 1u << 1,
SHADER_VARIABLE_FLAG_GENERAL_INPUT_ATTACHMENT_VK = 1u << 2,

/// Indicates that the resource is an unfilterable-float texture.
///
/// \note This flag is only valid in WebGPU and ignored in other backends.
SHADER_VARIABLE_FLAG_UNFILTERABLE_FLOAT_TEXTURE_WEBGPU = 1u << 2,
SHADER_VARIABLE_FLAG_UNFILTERABLE_FLOAT_TEXTURE_WEBGPU = 1u << 3,

/// Indicates that the resource is a non-filtering sampler.
///
/// \note This flag is only valid in WebGPU and ignored in other backends.
SHADER_VARIABLE_FLAG_NON_FILTERING_SAMPLER_WEBGPU = 1u << 3,
SHADER_VARIABLE_FLAG_NON_FILTERING_SAMPLER_WEBGPU = 1u << 4,

/// Special value that indicates the last flag in the enumeration.
SHADER_VARIABLE_FLAG_LAST = SHADER_VARIABLE_FLAG_NON_FILTERING_SAMPLER_WEBGPU
Expand Down
Loading
Loading