Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
61f2358
Added SHADER_RESOURCE_TYPE_INLINE_CONSTANTS enum value (#672)
TheMostDiligent Oct 19, 2025
aea9cac
D3D12/RootParamsManager: add support for root constants (#672)
TheMostDiligent Oct 19, 2025
d729b38
ResourceSignatureD3D12: implement CommitRootConstants method (#672)
TheMostDiligent Oct 19, 2025
4a20552
Add DRAW_FLAG_INLINE_CONSTANTS_INTACT flag (#672)
TheMostDiligent Oct 19, 2025
0c61209
IShaderResourceVariable: add SetInlineConstants method plumbing (#672)
TheMostDiligent Oct 19, 2025
1c02a41
ResourceSignatureD3D12: set all root constants at once (#672)
TheMostDiligent Oct 19, 2025
2a86179
ResourceCacheD3D12: implement SetInlineConstants (#672)
TheMostDiligent Oct 20, 2025
5e188f0
Replace SHADER_RESOURCE_TYPE_INLINE_CONSTANTS type with PIPELINE_RESO…
TheMostDiligent Oct 20, 2025
2d41af2
ResourceSignatureD3D12: initialize root constants (#672)
TheMostDiligent Oct 20, 2025
69d2f73
ShaderResourceCacheD3D12: allocate space for inline constant values (…
TheMostDiligent Oct 22, 2025
1c4be13
ResourceSignatureD3D12: copy inline constants from static resources (…
TheMostDiligent Oct 22, 2025
7f03389
ShaderResourceCacheD3D12: do not transition/validate null resources
TheMostDiligent Oct 22, 2025
24e9fdd
ShaderVarManagerD3D12: properly handle offset from table start for in…
TheMostDiligent Oct 22, 2025
98c8cda
ResourceSignatureD3D12: use correct array size for inline constants w…
TheMostDiligent Oct 23, 2025
36006c1
D3D12: commit root constants; add inline constants test (#672)
TheMostDiligent Oct 23, 2025
2dacc9d
Improve inline constants test
TheMostDiligent Oct 23, 2025
d8ddfb7
Improved inline constant validation (#672)
TheMostDiligent Oct 23, 2025
72bb177
Improve inline constants resource description validation (#672)
TheMostDiligent Oct 23, 2025
93391d1
Add inline constants test with two resource signatures (#672)
TheMostDiligent Oct 23, 2025
3afba64
D3DShaderResourceLoader: don't use auto where unnecessary
TheMostDiligent Oct 24, 2025
4bdeda4
D3DShaderResourceAttribs: store constant buffer size
TheMostDiligent Oct 24, 2025
5443eb7
Add SHADER_VARIABLE_FLAG_INLINE_CONSTANTS flag with implementation in…
TheMostDiligent Oct 24, 2025
f99e3dd
Add validation for SHADER_VARIABLE_FLAG_INLINE_CONSTANTS flag
TheMostDiligent Oct 24, 2025
2f706ee
Add test for inline constants in render state cache
TheMostDiligent Oct 25, 2025
aeeac03
PipelineStateD3D11: handle inline constants flag (#672)
TheMostDiligent Oct 25, 2025
73be86c
Inline Constants test: use constants in PS (#672)
TheMostDiligent Oct 26, 2025
43fecc0
ShaderResourceCacheD3D11: enable inline constants (#672)
TheMostDiligent Oct 26, 2025
cb316d7
ResourceSignatureD3D11: implement inline constant buffers update (#672)
TheMostDiligent Oct 27, 2025
1c3e30d
DeviceContextD3D11: update inline constant buffers (#672)
TheMostDiligent Oct 27, 2025
0ffcb53
D3D11: fix inline constant buffers remapping; enable inline constant …
TheMostDiligent Oct 27, 2025
93af1da
D3D11/D3D12: improved handling of DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_…
TheMostDiligent Oct 27, 2025
686f151
D3D11/D3D12: clean up code and update documentation for inline constants
TheMostDiligent Oct 30, 2025
68a2c34
Add tests for inline constants flag validation
TheMostDiligent Oct 31, 2025
0324728
Add vulkan inline constants support, emulated with uniform buffers. (…
hzqst Dec 6, 2025
a627e36
fix formatting.
hzqst Dec 6, 2025
f20c19e
fix formatting.
hzqst Dec 6, 2025
98bf219
fix typo
hzqst Dec 6, 2025
437a562
remove unused var
hzqst Dec 6, 2025
feed4cd
Add stuffs for vk push constants
hzqst Dec 7, 2025
f63da22
Add PIPELINE_RESOURCE_FLAG_VULKAN_PUSH_CONSTANT to PRS so we don't to…
hzqst Dec 7, 2025
b8cddc6
fix formatting
hzqst Dec 7, 2025
1e3f54f
Fix emulated inline constant.
hzqst Dec 7, 2025
5381581
Add missing tests
hzqst Dec 7, 2025
4354493
constexpr has ODR issue on ARM64, better go with macro.
hzqst Dec 7, 2025
0899af0
fix formatting
hzqst Dec 7, 2025
de1d047
better flags check in ValidatePipelineResourceSignatureDesc
hzqst Dec 7, 2025
c42471c
update SetInlineConstants.md vulkan impl.
hzqst Dec 7, 2025
75ad2c3
update doc
hzqst Dec 7, 2025
d5cbc6d
Fix testing
hzqst Dec 7, 2025
1844c67
enable testing for vulkan
hzqst Dec 7, 2025
869683a
Don't update revision, aligning to D3D11 inline constant behavior.
hzqst Dec 7, 2025
1307ba8
Fix m_HasInlineConstant not set when PRS restored from Render State C…
hzqst Dec 7, 2025
c4856ba
use vk staging buffer instead of dynamic buffer to avoid dynamic buff…
hzqst Dec 7, 2025
9f796b6
Restore dynamic buffer, and skip buffer id verification
hzqst Dec 7, 2025
e030acc
Fix issue when multiple inline constants using same pInlineConstantData.
hzqst Dec 8, 2025
0309087
fix formatting
hzqst Dec 8, 2025
cbe779b
Fix PipelineResourceSignatureVkImpl::UpdateInlineConstantBuffers not …
hzqst Dec 8, 2025
f523086
fix formatting
hzqst Dec 8, 2025
e2bbc2a
Fix https://github.com/DiligentGraphics/DiligentCore/issues/730
hzqst Dec 8, 2025
1a25e22
Move pBuffer and pPushConstantData from PipelineResourceSignatureVkIm…
hzqst Dec 8, 2025
1f18ab5
Fix formatting
hzqst Dec 8, 2025
6a02357
Don't apply PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS to SHADER_RESOU…
hzqst Dec 8, 2025
ad65b58
For some reason, pUncachedVS and pVS1 got same hash computation resul…
hzqst Dec 8, 2025
00a01d9
Fix GetBindInfo() from DeviceContextVkImpl.cpp returning unexpected P…
hzqst Dec 8, 2025
617b449
Fix formatting.
hzqst Dec 8, 2025
17b7af5
Fix ImmutableSamplers2 test when no resources provided in PRS Desc.
hzqst Dec 8, 2025
fb87222
Fix formatting
hzqst Dec 8, 2025
af59a53
Skip CommitShaderResources for PRS that has no resources bound on it.
hzqst Dec 8, 2025
2574f04
Use ResIndex to locate actual InlineCB and PushConstantData.
hzqst Dec 8, 2025
693ca4e
Fix formatting.
hzqst Dec 8, 2025
8d57cdf
Rename GetInlineConstantBuffers to GetInlineConstantBufferAttribs to …
hzqst Dec 9, 2025
b882f3e
Add PatchShaderConvertUniformBufferToPushConstant
hzqst Dec 9, 2025
333c3d1
Move buffervk to InlineConstantBufferAttribsVk, aligning to D3D11 impl.
hzqst Dec 9, 2025
11b5918
Fix bad SRBCacheOffset.
hzqst Dec 9, 2025
fb2ecee
Remove PIPELINE_RESOURCE_FLAG_VULKAN_PUSH_CONSTANT, implement deferre…
hzqst Dec 9, 2025
0708918
bump SPIRV-Tools
hzqst Dec 9, 2025
7f42a31
fix formatting
hzqst Dec 9, 2025
ac772fa
restore test
hzqst Dec 9, 2025
e2accc3
restore tests
hzqst Dec 9, 2025
a2bb192
remove test code.
hzqst Dec 9, 2025
2db3e63
bump submodule
hzqst Dec 9, 2025
c67819d
Now using pShaderResources from ShaderStageInfo instead of from Shade…
hzqst Dec 10, 2025
475de54
fix formatting.
hzqst Dec 10, 2025
01daa97
fix formatting.
hzqst Dec 10, 2025
9e813e4
fix formatting
hzqst Dec 10, 2025
e149356
restore check in PRSBase
hzqst Dec 10, 2025
3fa0977
Allow empty ShaderResource.
hzqst Dec 10, 2025
63411b2
restore SPIRV-Tools
hzqst Dec 10, 2025
d1e2ce3
Port ConvertUBOToPushConstantPass to SPIRVTools.cpp
hzqst Dec 10, 2025
9ebbadb
fix formatting
hzqst Dec 10, 2025
9271f70
Fix SPIRV-Tools headers warning
hzqst Dec 10, 2025
59a3c8f
restore SPIRV-Tools
hzqst Dec 10, 2025
733ac6b
Fix formatting
hzqst Dec 10, 2025
65f99b6
restore #include "SPIRVTools.hpp"
hzqst Dec 10, 2025
56eb92d
We don't need TargetEnv in PatchSPIRVConvertUniformBufferToPushConstant
hzqst Dec 10, 2025
d0b19f1
fiX not commit
hzqst Dec 10, 2025
7cfe7e4
Fix error C3861: 'PatchSPIRVConvertUniformBufferToPushConstant': iden…
hzqst Dec 10, 2025
de856be
fix formatting.
hzqst Dec 10, 2025
57b9bbf
We always need SPIRV-Tools to patch uniform buffer block, no matter N…
hzqst Dec 10, 2025
1164bde
Enable SPIRV-Tools by default.
hzqst Dec 10, 2025
3520519
restore CMakeLists.txt
hzqst Dec 10, 2025
c84f619
Don't filter out SRBs that only have push constants (no descriptor se…
hzqst Dec 10, 2025
7a6a6c1
throw err when SPIRV-Tools is not available. remove unused code.
hzqst Dec 10, 2025
616e607
fix formatting
hzqst Dec 10, 2025
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
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