Skip to content

Commit a9e9d4b

Browse files
committed
Addresses additional review comments.
Also restores file inadvertently committed source file changed for debugging.
1 parent 27547de commit a9e9d4b

4 files changed

Lines changed: 43 additions & 12 deletions

File tree

tools/clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9457,7 +9457,7 @@ bool Expr::isVulkanSpecConstantExpr(const ASTContext &Ctx,
94579457
if (!V || !V->hasAttr<VKConstantIdAttr>())
94589458
return false;
94599459
if (const Expr *I = V->getAnyInitializer())
9460-
return I->isCXX11ConstantExpr(Ctx, Result);
9460+
return I->IgnoreParenCasts()->isCXX11ConstantExpr(Ctx, Result);
94619461
return true;
94629462
}
94639463

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13750,11 +13750,7 @@ bool SpirvEmitter::processNumThreadsAttr(const FunctionDecl *decl) {
1375013750
return (unsigned)apsInt.getZExtValue();
1375113751
if (E->isVulkanSpecConstantExpr(astContext, &apValue) &&
1375213752
apValue.isInt()) {
13753-
Expr::EvalResult evalResult;
13754-
if (E->EvaluateAsRValue(evalResult, astContext) &&
13755-
!evalResult.HasSideEffects) {
13756-
return (unsigned)evalResult.Val.getInt().getZExtValue();
13757-
}
13753+
return apValue.getInt().getZExtValue();
1375813754
}
1375913755
}
1376013756
return 1U;
@@ -15839,15 +15835,16 @@ bool SpirvEmitter::spirvToolsValidate(std::vector<uint32_t> *mod,
1583915835
void SpirvEmitter::addDerivativeGroupExecutionMode() {
1584015836
assert(spvContext.isCS());
1584115837

15842-
SpirvExecutionMode *numThreadsEm =
15843-
dyn_cast<SpirvExecutionMode>(spvBuilder.getModule()->findExecutionMode(
15844-
entryFunction, spv::ExecutionMode::LocalSize));
15838+
SpirvExecutionMode *numThreadsEm = dyn_cast_or_null<SpirvExecutionMode>(
15839+
spvBuilder.getModule()->findExecutionMode(entryFunction,
15840+
spv::ExecutionMode::LocalSize));
15841+
// If there is no LocalSize, there must be LocalSizeId.
1584515842
if (!numThreadsEm)
1584615843
return addDerivativeGroupExecutionModeId();
1584715844
auto numThreads = numThreadsEm->getParams();
1584815845

1584915846
// The layout of the quad is determined by the numer of threads in each
15850-
// dimention. From the HLSL spec
15847+
// dimension. From the HLSL spec
1585115848
// (https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Derivatives.html):
1585215849
//
1585315850
// Where numthreads has an X value divisible by 4 and Y and Z are both 1, the
@@ -15885,7 +15882,7 @@ void SpirvEmitter::addDerivativeGroupExecutionModeId() {
1588515882
};
1588615883

1588715884
// The layout of the quad is determined by the numer of threads in each
15888-
// dimention. From the HLSL spec
15885+
// dimension. From the HLSL spec
1588915886
// (https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Derivatives.html):
1589015887
//
1589115888
// Where numthreads has an X value divisible by 4 and Y and Z are both 1, the
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck -check-prefix=CHECK-LINEAR %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl -DQUADS %s -spirv 2>&1 | FileCheck -check-prefix=CHECK-QUADS %s
3+
4+
// Note: validation disabled until NodePayloadAMDX pointers are allowed
5+
// as function arguments
6+
7+
// CHECK-LINEAR: OpCapability ComputeDerivativeGroupLinearKHR
8+
// CHECK-LINEAR: OpExecutionMode %{{[^ ]*}} DerivativeGroupLinearKHR
9+
// CHECK-QUADS: OpCapability ComputeDerivativeGroupQuadsKHR
10+
// CHECK-QUADS: OpExecutionMode %{{[^ ]*}} DerivativeGroupQuadsKHR
11+
12+
SamplerState ss : register(s2);
13+
SamplerComparisonState scs;
14+
15+
RWStructuredBuffer<uint> o;
16+
Texture1D <float> t1;
17+
18+
#ifdef QUADS
19+
[[vk::constant_id(0)]]
20+
const uint NumThreadsX = 2;
21+
[[vk::constant_id(1)]]
22+
const uint NumThreadsY = 2;
23+
#else
24+
[[vk::constant_id(0)]]
25+
const uint NumThreadsX = 24;
26+
[[vk::constant_id(1)]]
27+
const uint NumThreadsY = 1;
28+
#endif
29+
30+
[numthreads(NumThreadsX,NumThreadsY,1)]
31+
void main(uint3 id : SV_GroupThreadID)
32+
{
33+
o[0] = t1.Sample(ss, 1);
34+
}
35+

tools/clang/unittests/HLSL/RewriterTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <vector>
2727
#include <string>
2828
#include <cassert>
29-
#include <iostream>
3029
#include <sstream>
3130
#include <algorithm>
3231
#ifdef _WIN32

0 commit comments

Comments
 (0)