Skip to content

Commit

Permalink
Fail compilation when node cannot be found (#2453)
Browse files Browse the repository at this point in the history
* Fail compilation when node cannot be found

As of da8ce39 compilation succeeds when the resource node cannot be found. This change restores the pre-existing behavior (set by ad73950).

* Switch to calling report_fatal_error instead of crashing via assert

* Add an amdllpc test to ensure this issue does not bubble back up in the future

* Update error message in MissingResourceNodeTest.pipe
  • Loading branch information
mdinkov committed Jun 19, 2023
1 parent 00bfa2c commit 73872ee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lgc/builder/DescBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ Value *BuilderImpl::CreateLoadBufferDesc(uint64_t descSet, unsigned binding, Val
// If we can't find the node, assume mutable descriptor and search for any node.
std::tie(topNode, node) =
m_pipelineState->findResourceNode(ResourceNodeType::DescriptorMutable, descSet, binding);
if (!node) {
// We did not find the resource node. Return an poison value.
return PoisonValue::get(getBufferDescTy());
}
}
assert(node && "missing resource node");

if (!node)
report_fatal_error("Resource node not found");

if (node == topNode && isa<Constant>(descIndex) && node->concreteType != ResourceNodeType::InlineBuffer) {
// Handle a descriptor in the root table (a "dynamic descriptor") specially, as long as it is not variably
Expand Down
38 changes: 38 additions & 0 deletions llpc/test/shaderdb/general/MissingResourceNodeTest.pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
; Check that a pipeline compilation fails when resource nodes are missing

; BEGIN_SHADERTEST
; RUN: not --crash amdllpc -v %gfxip %s | FileCheck -check-prefix=SHADERTEST %s
; SHADERTEST-LABEL: {{^// LLPC}} SPIRV-to-LLVM translation results
; SHADERTEST: LLVM FATAL ERROR: Resource node not found
; END_SHADERTEST

[CsGlsl]
#version 450
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 1, std140) uniform UBO
{
int a;
int b;
int c;
int objectCount;
} ubo;

layout(set = 0, binding = 0, std430) buffer Pos
{
vec4 object[];
} pos;

void main()
{
uint index = gl_GlobalInvocationID.x;
if (index >= uint(ubo.objectCount))
{
return;
}
vec4 position = pos.object[index];
pos.object[index].w = dot(position.xyz, position.xyz);
}

[CsInfo]
entryPoint = main

0 comments on commit 73872ee

Please sign in to comment.