Skip to content

Commit 1c66c4d

Browse files
author
Greg Roth
authored
Disable non-legacy cbuffer flags (microsoft#6559)
These flags had some effect on load code generation, but never worked right and were not tested in the DXC compiler let alone with drivers. This removes any notion of the flags beyond option processing and produces a warning message that the flag is not supported and will be ignored. The flags are both not listed in help anymore either. A simple OptionsTest and lit test verify that the warning message is produced for either flag and existing tests that used the flag are updated or removed. Incidentally fixed the capitalization of an existing options warning message. Fixes microsoft#6306
1 parent aa6db9b commit 1c66c4d

File tree

15 files changed

+57
-110
lines changed

15 files changed

+57
-110
lines changed

include/dxc/HLSL/HLModule.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ class OP;
5151
struct HLOptions {
5252
HLOptions()
5353
: bDefaultRowMajor(false), bIEEEStrict(false), bAllResourcesBound(false),
54-
bDisableOptimizations(false), bLegacyCBufferLoad(false),
55-
PackingStrategy(0), bUseMinPrecision(false), bDX9CompatMode(false),
56-
bFXCCompatMode(false), bLegacyResourceReservation(false),
57-
bForceZeroStoreLifetimes(false), unused(0) {}
54+
bDisableOptimizations(false), PackingStrategy(0),
55+
bUseMinPrecision(false), bDX9CompatMode(false), bFXCCompatMode(false),
56+
bLegacyResourceReservation(false), bForceZeroStoreLifetimes(false),
57+
unused(0) {}
5858
uint32_t GetHLOptionsRaw() const;
5959
void SetHLOptionsRaw(uint32_t data);
6060
unsigned bDefaultRowMajor : 1;
6161
unsigned bIEEEStrict : 1;
6262
unsigned bAllResourcesBound : 1;
6363
unsigned bDisableOptimizations : 1;
64-
unsigned bLegacyCBufferLoad : 1;
6564
unsigned PackingStrategy : 2;
6665
static_assert((unsigned)DXIL::PackingStrategy::Invalid < 4,
6766
"otherwise 2 bits is not enough to store PackingStrategy");

include/dxc/Support/HLSLOptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ class DxcOpts {
198198
bool UseHexLiterals = false; // OPT_Lx
199199
bool UseInstructionByteOffsets = false; // OPT_No
200200
bool UseInstructionNumbers = false; // OPT_Ni
201-
bool NotUseLegacyCBufLoad = false; // OPT_no_legacy_cbuf_layout
202201
bool PackPrefixStable = false; // OPT_pack_prefix_stable
203202
bool PackOptimized = false; // OPT_pack_optimized
204203
bool DisplayIncludeProcess = false; // OPT__vi

include/dxc/Support/HLSLOptions.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def flegacy_macro_expansion : Flag<["-", "/"], "flegacy-macro-expansion">, Group
278278
HelpText<"Expand the operands before performing token-pasting operation (fxc behavior)">;
279279
def flegacy_resource_reservation : Flag<["-", "/"], "flegacy-resource-reservation">, Group<hlslcomp_Group>, Flags<[CoreOption, DriverOption]>,
280280
HelpText<"Reserve unused explicit register assignments for compatibility with shader model 5.0 and below">;
281-
def no_legacy_cbuf_layout : Flag<["-", "/"], "no-legacy-cbuf-layout">, Group<hlslcomp_Group>, Flags<[CoreOption]>,
281+
def no_legacy_cbuf_layout : Flag<["-", "/"], "no-legacy-cbuf-layout">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
282282
HelpText<"Do not use legacy cbuffer load">;
283283
def not_use_legacy_cbuf_load_ : Flag<["-", "/"], "not_use_legacy_cbuf_load">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
284284
HelpText<"Do not use legacy cbuffer load">;

lib/DxcSupport/HLSLOptions.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
570570
// Args.getLastArgValue(OPT_INPUT) get expect Input.
571571
InputArg->getValues()[0] = PrevInputArg->getValues()[0];
572572
}
573-
errors << "Warning: -P " << opts.Preprocess
573+
errors << "warning: -P " << opts.Preprocess
574574
<< " is deprecated, please use -P -Fi " << opts.Preprocess
575575
<< " instead.\n";
576576
break;
@@ -762,10 +762,14 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
762762
opts.DefaultColMajor = Args.hasFlag(OPT_Zpc, OPT_INVALID, false);
763763
opts.DumpBin = Args.hasFlag(OPT_dumpbin, OPT_INVALID, false);
764764
opts.Link = Args.hasFlag(OPT_link, OPT_INVALID, false);
765-
opts.NotUseLegacyCBufLoad =
765+
bool NotUseLegacyCBufLoad =
766766
Args.hasFlag(OPT_no_legacy_cbuf_layout, OPT_INVALID, false);
767-
opts.NotUseLegacyCBufLoad = Args.hasFlag(
768-
OPT_not_use_legacy_cbuf_load_, OPT_INVALID, opts.NotUseLegacyCBufLoad);
767+
NotUseLegacyCBufLoad = Args.hasFlag(OPT_not_use_legacy_cbuf_load_,
768+
OPT_INVALID, NotUseLegacyCBufLoad);
769+
if (NotUseLegacyCBufLoad)
770+
errors << "warning: -no-legacy-cbuf-layout"
771+
<< " is no longer supported and will be ignored."
772+
<< " Future releases will not recognize it.\n";
769773
opts.PackPrefixStable =
770774
Args.hasFlag(OPT_pack_prefix_stable, OPT_INVALID, false);
771775
opts.PackPrefixStable =

lib/HLSL/HLOperationLower.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ struct HLOperationLowerHelper {
5151
Type *i8Ty;
5252
DxilTypeSystem &dxilTypeSys;
5353
DxilFunctionProps *functionProps;
54-
bool bLegacyCBufferLoad;
5554
DataLayout dataLayout;
5655
SmallDenseMap<Type *, Type *, 4> loweredTypes;
5756
typedef std::pair<DxilWaveMatrixProperties, Constant *> WaveMatrix_Props;
@@ -77,7 +76,6 @@ HLOperationLowerHelper::HLOperationLowerHelper(HLModule &HLM)
7776
functionProps = nullptr;
7877
if (HLM.HasDxilFunctionProps(EntryFunc))
7978
functionProps = &HLM.GetDxilFunctionProps(EntryFunc);
80-
bLegacyCBufferLoad = HLM.GetHLOptions().bLegacyCBufferLoad;
8179
}
8280

8381
const HLOperationLowerHelper::WaveMatrix_Props &
@@ -7459,20 +7457,6 @@ void TranslateCBGep(GetElementPtrInst *GEP, Value *handle, Value *baseOffset,
74597457
}
74607458
}
74617459

7462-
void TranslateCBOperations(Value *handle, Value *ptr, Value *offset, OP *hlslOP,
7463-
DxilTypeSystem &dxilTypeSys, const DataLayout &DL,
7464-
HLObjectOperationLowerHelper *pObjHelper) {
7465-
auto User = ptr->user_begin();
7466-
auto UserE = ptr->user_end();
7467-
for (; User != UserE;) {
7468-
// Must be Instruction.
7469-
Instruction *I = cast<Instruction>(*(User++));
7470-
TranslateCBAddressUser(I, handle, offset, hlslOP,
7471-
/*prevFieldAnnotation*/ nullptr, dxilTypeSys, DL,
7472-
pObjHelper);
7473-
}
7474-
}
7475-
74767460
Value *GenerateCBLoadLegacy(Value *handle, Value *legacyIdx,
74777461
unsigned channelOffset, Type *EltTy, OP *hlslOP,
74787462
IRBuilder<> &Builder) {
@@ -9057,14 +9041,8 @@ void TranslateHLSubscript(CallInst *CI, HLSubscriptOpcode opcode,
90579041
dxilutil::MergeGepUse(CI);
90589042
// Resource ptr.
90599043
Value *handle = CI->getArgOperand(HLOperandIndex::kSubscriptObjectOpIdx);
9060-
if (helper.bLegacyCBufferLoad)
9061-
TranslateCBOperationsLegacy(handle, CI, hlslOP, helper.dxilTypeSys,
9062-
helper.dataLayout, pObjHelper);
9063-
else {
9064-
TranslateCBOperations(handle, CI, /*offset*/ hlslOP->GetU32Const(0),
9065-
hlslOP, helper.dxilTypeSys,
9066-
CI->getModule()->getDataLayout(), pObjHelper);
9067-
}
9044+
TranslateCBOperationsLegacy(handle, CI, hlslOP, helper.dxilTypeSys,
9045+
helper.dataLayout, pObjHelper);
90689046
Translated = true;
90699047
return;
90709048
} else if (opcode == HLSubscriptOpcode::DoubleSubscript) {

tools/clang/include/clang/Frontend/CodeGenOptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
185185
bool HLSLAllowPreserveValues = false;
186186
/// Whether we fail compilation if loop fails to unroll
187187
bool HLSLOnlyWarnOnUnrollFail = false;
188-
/// Whether use legacy cbuffer load.
189-
bool HLSLNotUseLegacyCBufLoad = false;
190188
/// Whether use legacy resource reservation.
191189
bool HLSLLegacyResourceReservation = false;
192190
/// Set [branch] on every if.

tools/clang/lib/CodeGen/CGHLSLMS.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ CGMSHLSLRuntime::CGMSHLSLRuntime(CodeGenModule &CGM)
394394
HLOptions opts;
395395
opts.bIEEEStrict = CGM.getCodeGenOpts().UnsafeFPMath;
396396
opts.bDisableOptimizations = CGM.getCodeGenOpts().DisableLLVMOpts;
397-
opts.bLegacyCBufferLoad = !CGM.getCodeGenOpts().HLSLNotUseLegacyCBufLoad;
398397
opts.bAllResourcesBound = CGM.getCodeGenOpts().HLSLAllResourcesBound;
399398
opts.bResMayAlias = CGM.getCodeGenOpts().HLSLResMayAlias;
400399
opts.PackingStrategy = CGM.getCodeGenOpts().HLSLSignaturePackingStrategy;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %dxc -T vs_6_0 %s -no-legacy-cbuf-layout 2>&1 | FileCheck %s
2+
// RUN: %dxc -T vs_6_0 %s -not_use_legacy_cbuf_load 2>&1 | FileCheck %s
3+
4+
// CHECK: warning: -no-legacy-cbuf-layout is no longer supported and will be ignored. Future releases will not recognize it.
5+
6+
void main() {}

tools/clang/test/HLSLFileCheck/hlsl/objects/Cbuffer/cbufferAlloc.hlsl

Lines changed: 0 additions & 63 deletions
This file was deleted.

tools/clang/test/HLSLFileCheck/hlsl/objects/Cbuffer/resource-in-cb.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -E main -T ps_6_0 -not_use_legacy_cbuf_load %s | FileCheck %s
1+
// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
22

33
// CHECK: Tex1
44

0 commit comments

Comments
 (0)