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

Add error for invalid arguments to GetDimension #6698

Merged
merged 1 commit into from
Jun 18, 2024
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
9 changes: 9 additions & 0 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,15 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) {
numSamples = expr->getArg(numArgs - 1);
}

// Make sure that all output args are an l-value.
for (uint32_t argIdx = (mipLevel ? 1 : 0); argIdx < numArgs; ++argIdx) {
if (!expr->getArg(argIdx)->isLValue()) {
emitError("Output argument must be an l-value",
expr->getArg(argIdx)->getExprLoc());
return nullptr;
}
}

uint32_t querySize = numArgs;
// If numLevels arg is present, mipLevel must also be present. These are not
// queried via ImageQuerySizeLod.
Expand Down
9 changes: 9 additions & 0 deletions tools/clang/test/CodeGenSPIRV/texture.get-dimensions.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
// RUN: not %dxc -T ps_6_0 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=ERROR

// CHECK: OpCapability ImageQuery

Expand Down Expand Up @@ -360,4 +361,12 @@ void main() {
// CHECK-NEXT: [[query_levels_int:%[0-9]+]] = OpBitcast %int [[query_levels_uint]]
// CHECK-NEXT: OpStore %signedNumLevels [[query_levels_int]]
t3.GetDimensions(signedMipLevel, signedWidth, signedHeight, signedNumLevels);

#ifdef ERROR
// ERROR: 367:30: error: Output argument must be an l-value
t9.GetDimensions(mipLevel, 0, height, elements, numLevels);

// ERROR: 370:35: error: Output argument must be an l-value
t9.GetDimensions(width, height, 20);
#endif
}
Loading