Skip to content

Commit bd9a8b1

Browse files
committed
Wire legalization loop unroll requirement
1 parent 54afd2c commit bd9a8b1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ SpirvEmitter::SpirvEmitter(CompilerInstance &ci)
593593
constEvaluator(astContext, spvBuilder), entryFunction(nullptr),
594594
curFunction(nullptr), curThis(nullptr), seenPushConstantAt(),
595595
isSpecConstantMode(false), needsLegalization(false),
596+
needsLegalizationLoopUnroll(false),
596597
beforeHlslLegalization(false), mainSourceFile(nullptr) {
597598

598599
// Get ShaderModel from command line hlsl profile option.
@@ -5823,8 +5824,10 @@ SpirvInstruction *SpirvEmitter::createImageSample(
58235824
SpirvInstruction *minLod, SpirvInstruction *residencyCodeId,
58245825
SourceLocation loc, SourceRange range) {
58255826

5826-
if (varOffset)
5827+
if (varOffset) {
58275828
needsLegalization = true;
5829+
needsLegalizationLoopUnroll = true;
5830+
}
58285831

58295832
// SampleDref* instructions in SPIR-V always return a scalar.
58305833
// They also have the correct type in HLSL.
@@ -16665,7 +16668,8 @@ bool SpirvEmitter::spirvToolsLegalize(std::vector<uint32_t> *mod,
1666516668
optimizer.RegisterPass(
1666616669
spvtools::CreateInterfaceVariableScalarReplacementPass());
1666716670
}
16668-
optimizer.RegisterLegalizationPasses(spirvOptions.preserveInterface);
16671+
optimizer.RegisterLegalizationPasses(spirvOptions.preserveInterface,
16672+
needsLegalizationLoopUnroll);
1666916673
// Add flattening of resources if needed.
1667016674
if (spirvOptions.flattenResourceArrays) {
1667116675
optimizer.RegisterPass(

tools/clang/lib/SPIRV/SpirvEmitter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ class SpirvEmitter : public ASTConsumer {
15781578
///
15791579
/// Note: legalization specific code
15801580
bool needsLegalization;
1581+
bool needsLegalizationLoopUnroll;
15811582

15821583
/// Whether the translated SPIR-V binary passes --before-hlsl-legalization
15831584
/// option to spirv-val because of illegal function parameter scope.

0 commit comments

Comments
 (0)