Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail compilation when node cannot be found #2453

Merged
merged 6 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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(unsigned 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