Skip to content

Commit d8ddfb7

Browse files
Improved inline constant validation (#672)
1 parent 2dacc9d commit d8ddfb7

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

Graphics/GraphicsEngine/include/ShaderResourceVariableBase.hpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,6 @@ bool VerifyResourceBinding(const char* ExpectedResourceTypeName,
179179
return false;
180180
}
181181

182-
if (ResDesc.ResourceType == SHADER_RESOURCE_TYPE_CONSTANT_BUFFER && (ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
183-
{
184-
if (pResourceImpl != nullptr)
185-
{
186-
std::stringstream ss;
187-
ss << "Failed to bind " << ExpectedResourceTypeName << " '" << pResourceImpl->GetDesc().Name << "' to variable '"
188-
<< GetShaderResourcePrintName(ResDesc, BindInfo.ArrayIndex) << '\'';
189-
if (SignatureName != nullptr)
190-
{
191-
ss << " defined by signature '" << SignatureName << '\'';
192-
}
193-
ss << ". Inline constants must be set using IShaderResourceVariable::SetInlineConstants() method.";
194-
RESOURCE_VALIDATION_FAILURE(ss.str());
195-
return false;
196-
}
197-
}
198-
199182
if (ResDesc.VarType != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC &&
200183
(BindInfo.Flags & SET_SHADER_RESOURCE_FLAG_ALLOW_OVERWRITE) == 0 &&
201184
pCachedObject != nullptr && pCachedObject != pResourceImpl)
@@ -248,6 +231,20 @@ bool VerifyConstantBufferBinding(const PipelineResourceDesc& ResDesc,
248231
Uint64 CachedRangeSize,
249232
const char* SignatureName)
250233
{
234+
if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
235+
{
236+
std::stringstream ss;
237+
ss << "Error binding buffer to variable '" << GetShaderResourcePrintName(ResDesc, BindInfo.ArrayIndex) << '\'';
238+
if (SignatureName != nullptr)
239+
{
240+
ss << " defined by signature '" << SignatureName << '\'';
241+
}
242+
ss << ". The variable is marked as inline constants and cannot be bound to a buffer. "
243+
"Use IShaderResourceVariable::SetInlineConstants() method to set the inline constant values.";
244+
RESOURCE_VALIDATION_FAILURE(ss.str());
245+
return false;
246+
}
247+
251248
bool BindingOK = VerifyResourceBinding("buffer", ResDesc, BindInfo, pBufferImpl, pCachedBuffer, SignatureName);
252249

253250
if (pBufferImpl != nullptr)
@@ -557,6 +554,12 @@ bool VerifyDynamicBufferOffset(const PipelineResourceDesc& ResDesc,
557554
{
558555
bool BindingOK = true;
559556

557+
if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
558+
{
559+
RESOURCE_VALIDATION_FAILURE("Error setting dynamic buffer offset for variable '", ResDesc.Name, "': inline constants do not support dynamic offsets.");
560+
BindingOK = false;
561+
}
562+
560563
if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS) != 0)
561564
{
562565
RESOURCE_VALIDATION_FAILURE("Error setting dynamic buffer offset for variable '", ResDesc.Name, "': the variable was created with PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS flag.");

0 commit comments

Comments
 (0)