Skip to content

Commit 30525f5

Browse files
Merge from main
2 parents c7aea41 + 377c4ca commit 30525f5

24 files changed

Lines changed: 593 additions & 71 deletions

.github/workflows/clang-format-checker.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
permissions:
1313
pull-requests: write
1414
steps:
15-
- name: Fetch LLVM sources
15+
- name: Fetch DirectXShaderCompiler sources
1616
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1717
with:
1818
ref: ${{ github.event.pull_request.head.sha }}
@@ -31,6 +31,20 @@ jobs:
3131
separator: ","
3232
skip_initial_fetch: true
3333

34+
# We need to pull the script from the main branch, so that we ensure
35+
# we get the latest version of this script.
36+
- name: Fetch code formatting utils
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
with:
39+
repository: microsoft/DirectXShaderCompiler
40+
ref: ${{ github.base_ref }}
41+
sparse-checkout: |
42+
utils/git/requirements_formatting.txt
43+
utils/git/code-format-helper.py
44+
utils/git/code-format-save-diff.py
45+
sparse-checkout-cone-mode: false
46+
path: code-format-tools
47+
3448
- name: "Listed files"
3549
env:
3650
LISTED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -48,10 +62,10 @@ jobs:
4862
with:
4963
python-version: '3.11'
5064
cache: 'pip'
51-
cache-dependency-path: 'utils/git/requirements_formatting.txt'
65+
cache-dependency-path: 'code-format-tools/utils/git/requirements_formatting.txt'
5266

5367
- name: Install python dependencies
54-
run: pip install -r utils/git/requirements_formatting.txt
68+
run: pip install -r code-format-tools/utils/git/requirements_formatting.txt
5569

5670
- name: Run code formatter
5771
id: formatter
@@ -61,7 +75,7 @@ jobs:
6175
END_REV: ${{ github.event.pull_request.head.sha }}
6276
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
6377
run: |
64-
python utils/git/code-format-helper.py \
78+
python code-format-tools/utils/git/code-format-helper.py \
6579
--token ${{ secrets.GITHUB_TOKEN }} \
6680
--issue-number $GITHUB_PR_NUMBER \
6781
--start-rev $START_REV \
@@ -92,28 +106,37 @@ jobs:
92106
} catch (err) {
93107
core.setFailed(`Request failed with error ${err}`)
94108
}
95-
- name: Fetch LLVM sources
96-
uses: actions/checkout@v4
109+
110+
# We need to pull the script from the main branch, so that we ensure
111+
# we get the latest version of this script.
112+
- name: Fetch code formatting utils
113+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
97114
with:
98-
fetch-depth: 2
99-
path: build/main_src
115+
repository: microsoft/DirectXShaderCompiler
116+
ref: ${{ github.base_ref }}
117+
sparse-checkout: |
118+
utils/git/requirements_formatting.txt
119+
utils/git/code-format-helper.py
120+
utils/git/code-format-save-diff.py
121+
sparse-checkout-cone-mode: false
122+
path: code-format-tools
100123

101124
- name: Setup Python env
102125
uses: actions/setup-python@v4
103126
with:
104127
python-version: '3.11'
105128
cache: 'pip'
106-
cache-dependency-path: 'build/main_src/utils/git/requirements_formatting.txt'
129+
cache-dependency-path: 'code-format-tools/utils/git/requirements_formatting.txt'
107130

108131
- name: Install python dependencies
109-
run: pip install -r build/main_src/utils/git/requirements_formatting.txt
132+
run: pip install -r code-format-tools/utils/git/requirements_formatting.txt
110133

111134
- name: Apply code diff
112135
env:
113136
GITHUB_PR_NUMBER: ${{ github.event.issue.number }}
114137
COMMENT_ID: ${{ github.event.comment.id }}
115138
run: |
116-
python build/main_src/utils/git/code-format-save-diff.py \
139+
python code-format-tools/utils/git/code-format-save-diff.py \
117140
--token ${{ secrets.GITHUB_TOKEN }} \
118141
--issue-number $GITHUB_PR_NUMBER \
119142
--tmp-diff-file $TMP_DIFF_FILE \

docs/DXIL.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3177,6 +3177,7 @@ INSTR.OPCONSTRANGE Constant values mu
31773177
INSTR.OPERANDRANGE DXIL intrinsic operand must be within defined range
31783178
INSTR.PARAMMULTIPLE Parameter must be a valid multiple
31793179
INSTR.PTRBITCAST Pointer type bitcast must be have same size.
3180+
INSTR.REORDERCOHERENTREQUIRESSM69 reordercoherent requires SM 6.9 or later.
31803181
INSTR.RESOURCECLASSFORLOAD load can only run on UAV/SRV resource.
31813182
INSTR.RESOURCECLASSFORSAMPLERGATHER sample, lod and gather should be on srv resource.
31823183
INSTR.RESOURCECLASSFORUAVSTORE store should be on uav resource.
@@ -3218,14 +3219,14 @@ META.BARYCENTRICSTWOPERSPECTIVES There can only be
32183219
META.BRANCHFLATTEN Can't use branch and flatten attributes together.
32193220
META.CLIPCULLMAXCOMPONENTS Combined elements of SV_ClipDistance and SV_CullDistance must fit in 8 components
32203221
META.CLIPCULLMAXROWS Combined elements of SV_ClipDistance and SV_CullDistance must fit in two rows.
3222+
META.COHERENCENOTONAPPENDCONSUME globally/reorder coherent incompatible with append/consume/counter buffers
32213223
META.COMPUTEWITHNODE Compute entry must not have node metadata
32223224
META.CONTROLFLOWHINTNOTONCONTROLFLOW Control flow hint only works on control flow inst.
32233225
META.DENSERESIDS Resource identifiers must be zero-based and dense.
32243226
META.DUPLICATESYSVALUE System value may only appear once in signature
32253227
META.ENTRYFUNCTION entrypoint not found.
32263228
META.FLAGSUSAGE Flags must match usage.
32273229
META.FORCECASEONSWITCH Attribute forcecase only works for switch.
3228-
META.GLCNOTONAPPENDCONSUME globallycoherent cannot be used with append/consume buffers: '%0'.
32293230
META.INTEGERINTERPMODE Interpolation mode on integer must be Constant
32303231
META.INTERPMODEINONEROW Interpolation mode must be identical for all elements packed into the same row.
32313232
META.INTERPMODEVALID Interpolation mode must be valid

include/dxc/Support/HLSLOptions.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ def print_before_all : Flag<["-", "/"], "print-before-all">, Group<hlslcomp_Grou
317317
HelpText<"Print LLVM IR before each pass.">;
318318
def print_before : Separate<["-", "/"], "print-before">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
319319
HelpText<"Print LLVM IR before a specific pass. May be specificied multiple times.">;
320-
def select_validator : Separate<["-", "/"], "select-validator">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
321-
HelpText<"Select validator: auto: (default) use DXIL.dll if found, otherwise use internal; internal: internal non-signing validator; external: use DXIL.dll if found, otherwise fail compilation.">;
322320
def print_after_all : Flag<["-", "/"], "print-after-all">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
323321
HelpText<"Print LLVM IR after each pass.">;
324322
def print_after : Separate<["-", "/"], "print-after">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,

lib/DXIL/DxilOperations.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -765,32 +765,32 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
765765
"unary",
766766
Attribute::ReadNone,
767767
1,
768-
{{0x403}},
769-
{{0x3}}}, // Overloads: hf<hf
768+
{{0x3}},
769+
{{0x0}}}, // Overloads: hf
770770
{OC::DerivCoarseY,
771771
"DerivCoarseY",
772772
OCC::Unary,
773773
"unary",
774774
Attribute::ReadNone,
775775
1,
776-
{{0x403}},
777-
{{0x3}}}, // Overloads: hf<hf
776+
{{0x3}},
777+
{{0x0}}}, // Overloads: hf
778778
{OC::DerivFineX,
779779
"DerivFineX",
780780
OCC::Unary,
781781
"unary",
782782
Attribute::ReadNone,
783783
1,
784-
{{0x403}},
785-
{{0x3}}}, // Overloads: hf<hf
784+
{{0x3}},
785+
{{0x0}}}, // Overloads: hf
786786
{OC::DerivFineY,
787787
"DerivFineY",
788788
OCC::Unary,
789789
"unary",
790790
Attribute::ReadNone,
791791
1,
792-
{{0x403}},
793-
{{0x3}}}, // Overloads: hf<hf
792+
{{0x3}},
793+
{{0x0}}}, // Overloads: hf
794794

795795
// Pixel shader
796796
{OC::EvalSnapped,

lib/DxcSupport/HLSLOptions.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,20 +1033,6 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
10331033
opts.ValVerMinor = (unsigned long)minor64;
10341034
}
10351035

1036-
llvm::StringRef valSelectStr = Args.getLastArgValue(OPT_select_validator);
1037-
if (!valSelectStr.empty()) {
1038-
opts.SelectValidator = llvm::StringSwitch<ValidatorSelection>(valSelectStr)
1039-
.Case("auto", ValidatorSelection::Auto)
1040-
.Case("internal", ValidatorSelection::Internal)
1041-
.Case("external", ValidatorSelection::External)
1042-
.Default(ValidatorSelection::Invalid);
1043-
if (opts.SelectValidator == ValidatorSelection::Invalid) {
1044-
errors << "Unsupported value '" << valSelectStr
1045-
<< "for -select-validator option.";
1046-
return 1;
1047-
}
1048-
}
1049-
10501036
if (opts.IsLibraryProfile() && Minor == 0xF) {
10511037
if (opts.ValVerMajor != UINT_MAX && opts.ValVerMajor != 0) {
10521038
errors << "Offline library profile cannot be used with non-zero "

lib/DxilValidation/DxilValidation.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ ValidateSignatureAccess(Instruction *I, DxilSignature &Sig, Value *SigId,
165165

166166
static DxilResourceProperties GetResourceFromHandle(Value *Handle,
167167
ValidationContext &ValCtx) {
168-
if (!isa<CallInst>(Handle)) {
168+
CallInst *HandleCall = dyn_cast<CallInst>(Handle);
169+
if (!HandleCall) {
169170
if (Instruction *I = dyn_cast<Instruction>(Handle))
170171
ValCtx.EmitInstrError(I, ValidationRule::InstrHandleNotFromCreateHandle);
171172
else
@@ -175,10 +176,13 @@ static DxilResourceProperties GetResourceFromHandle(Value *Handle,
175176
}
176177

177178
DxilResourceProperties RP = ValCtx.GetResourceFromVal(Handle);
178-
if (RP.getResourceClass() == DXIL::ResourceClass::Invalid) {
179+
if (RP.getResourceClass() == DXIL::ResourceClass::Invalid)
179180
ValCtx.EmitInstrError(cast<CallInst>(Handle),
180181
ValidationRule::InstrHandleNotFromCreateHandle);
181-
}
182+
if (RP.Basic.IsReorderCoherent &&
183+
!ValCtx.DxilMod.GetShaderModel()->IsSM69Plus())
184+
ValCtx.EmitInstrError(HandleCall,
185+
ValidationRule::InstrReorderCoherentRequiresSM69);
182186

183187
return RP;
184188
}
@@ -4208,6 +4212,9 @@ static void ValidateResourceOverlap(
42084212

42094213
static void ValidateResource(hlsl::DxilResource &Res,
42104214
ValidationContext &ValCtx) {
4215+
if (Res.IsReorderCoherent() && !ValCtx.DxilMod.GetShaderModel()->IsSM69Plus())
4216+
ValCtx.EmitResourceError(&Res,
4217+
ValidationRule::InstrReorderCoherentRequiresSM69);
42114218
switch (Res.GetKind()) {
42124219
case DXIL::ResourceKind::RawBuffer:
42134220
case DXIL::ResourceKind::TypedBuffer:
@@ -4439,10 +4446,13 @@ static void ValidateResources(ValidationContext &ValCtx) {
44394446
ValCtx.EmitResourceError(Uav.get(),
44404447
ValidationRule::SmCounterOnlyOnStructBuf);
44414448
}
4442-
if (Uav->HasCounter() && Uav->IsGloballyCoherent())
4443-
ValCtx.EmitResourceFormatError(Uav.get(),
4444-
ValidationRule::MetaGlcNotOnAppendConsume,
4445-
{ValCtx.GetResourceName(Uav.get())});
4449+
const bool UavIsCoherent =
4450+
Uav->IsGloballyCoherent() || Uav->IsReorderCoherent();
4451+
if (Uav->HasCounter() && UavIsCoherent) {
4452+
StringRef Prefix = Uav->IsGloballyCoherent() ? "globally" : "reorder";
4453+
ValCtx.EmitResourceFormatError(
4454+
Uav.get(), ValidationRule::MetaCoherenceNotOnAppendConsume, {Prefix});
4455+
}
44464456

44474457
ValidateResource(*Uav, ValCtx);
44484458
ValidateResourceOverlap(*Uav, UavAllocator, ValCtx);

lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,6 @@ void SROA_Helper::RewriteCall(CallInst *CI) {
28192819
DeadInsts.push_back(CI);
28202820
break;
28212821
}
2822-
LLVM_FALLTHROUGH;
28232822
default:
28242823
// RayQuery this pointer replacement.
28252824
if (OldVal->getType()->isPointerTy() &&

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6737,8 +6737,8 @@ bool HLSLExternalSource::MatchArguments(
67376737
(iArg != retArgIdx && retTypeIdx == pIntrinsicArg->uComponentTypeId);
67386738
// For literal arg which don't affect return type, find concrete type.
67396739
// For literal arg affect return type,
6740-
// TryEvalIntrinsic in CGHLSLMS.cpp will take care of cases
6741-
// where all argumentss are literal.
6740+
// TryEvalIntrinsic in CGHLSLMSFinishCodeGen.cpp will take care of
6741+
// cases where all arguments are literal.
67426742
// CombineBasicTypes will cover the rest cases.
67436743
if (!affectRetType) {
67446744
TypeInfoEltKind =

tools/clang/test/CodeGenDXIL/hlsl/types/longvec-intrinsics.hlsl

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DNUM=7 %s | FileCheck %s
33
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DNUM=125 %s | FileCheck %s
44
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DNUM=256 %s | FileCheck %s
5-
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DNUM=1024 %s | FileCheck %s
65

76
// Test vector-enabled non-trivial intrinsics that take parameters of various types.
87

@@ -203,6 +202,36 @@ void main() {
203202
// CHECK: fmul fast <[[NUM]] x float> [[tmp]], <float 0x3FE62E4300000000
204203
fRes += log(fVec1);
205204

205+
// CHECK-NOT: extractelement
206+
// CHECK-NOT: insertelement
207+
// CHECK: [[tmp:%.*]] = call <[[NUM]] x half> @dx.op.unary.[[HTY]](i32 23, <[[NUM]] x half> [[hvec2]]) ; Log(value)
208+
// CHECK: [[tmp2:%.*]] = fmul fast <[[NUM]] x half> [[tmp]], [[hvec1]]
209+
// CHECK: call <[[NUM]] x half> @dx.op.unary.[[HTY]](i32 21, <[[NUM]] x half> [[tmp2]]) ; Exp(value)
210+
hRes += pow(hVec2, hVec1);
211+
212+
// CHECK-NOT: extractelement
213+
// CHECK-NOT: insertelement
214+
// CHECK: [[tmp:%.*]] = call <[[NUM]] x float> @dx.op.unary.[[FTY]](i32 23, <[[NUM]] x float> [[fvec2]]) ; Log(value)
215+
// CHECK: [[tmp2:%.*]] = fmul fast <[[NUM]] x float> [[tmp]], [[fvec1]]
216+
// CHECK: call <[[NUM]] x float> @dx.op.unary.[[FTY]](i32 21, <[[NUM]] x float> [[tmp2]]) ; Exp(value)
217+
fRes += pow(fVec2, fVec1);
218+
219+
vector<half, NUM> hVal;
220+
// CHECK-NOT: extractelement
221+
// CHECK-NOT: insertelement
222+
// CHECK: [[tmp:%.*]] = call <[[NUM]] x half> @dx.op.unary.[[HTY]](i32 29, <[[NUM]] x half> [[hvec1]]) ; Round_z(value)
223+
// CHECK: fsub fast <[[NUM]] x half> [[hvec1]], [[tmp]]
224+
hRes *= modf(hVec1, hVal);
225+
hRes += hVal;
226+
227+
vector<float, NUM> fVal;
228+
// CHECK-NOT: extractelement
229+
// CHECK-NOT: insertelement
230+
// CHECK: [[tmp:%.*]] = call <[[NUM]] x float> @dx.op.unary.[[FTY]](i32 29, <[[NUM]] x float> [[fvec1]]) ; Round_z(value)
231+
// CHECK: fsub fast <[[NUM]] x float> [[fvec1]], [[tmp]]
232+
fRes *= modf(fVec1, fVal);
233+
fRes += fVal;
234+
206235
// CHECK-NOT: extractelement
207236
// CHECK-NOT: insertelement
208237
// CHECK: [[sub:%.*]] = fsub fast <[[NUM]] x half> [[hvec2]], [[hvec1]]
@@ -227,6 +256,25 @@ void main() {
227256
// CHECK: fmul fast <[[NUM]] x float> [[mul]], [[sub]]
228257
fRes += smoothstep(fVec1, fVec2, fVec3);
229258

259+
// Note that Fabs is tested in longvec-trivial-unary-float-intrinsics.
260+
// CHECK-NOT: extractelement
261+
// CHECK-NOT: insertelement
262+
// CHECK: [[tmp:%.*]] = sub <[[NUM]] x i16> zeroinitializer, [[svec1]]
263+
// CHECK: call <[[NUM]] x i16> @dx.op.binary.[[STY]](i32 37, <[[NUM]] x i16> [[svec1]], <[[NUM]] x i16> [[tmp]]) ; IMax(a,b)
264+
sRes += abs(sVec1);
265+
266+
// CHECK-NOT: extractelement
267+
// CHECK-NOT: insertelement
268+
// CHECK: [[tmp:%.*]] = sub <[[NUM]] x i32> zeroinitializer, [[ivec1]]
269+
// CHECK: call <[[NUM]] x i32> @dx.op.binary.[[ITY]](i32 37, <[[NUM]] x i32> [[ivec1]], <[[NUM]] x i32> [[tmp]]) ; IMax(a,b)
270+
iRes += abs(iVec1);
271+
272+
// CHECK-NOT: extractelement
273+
// CHECK-NOT: insertelement
274+
// CHECK: [[tmp:%.*]] = sub <[[NUM]] x i64> zeroinitializer, [[lvec1]]
275+
// CHECK: call <[[NUM]] x i64> @dx.op.binary.[[LTY]](i32 37, <[[NUM]] x i64> [[lvec1]], <[[NUM]] x i64> [[tmp]]) ; IMax(a,b)
276+
lRes += abs(lVec1);
277+
230278
// Intrinsics that expand into llvm ops.
231279

232280
// CHECK-NOT: extractelement

tools/clang/test/CodeGenDXIL/hlsl/types/longvec-trivial-scalarized-intrinsics.hlsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
// RUN: %dxc -DFUNC=countbits -DARITY=1 -DTYPE=uint -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
1010
// RUN: %dxc -DFUNC=firstbithigh -DARITY=1 -DTYPE=uint -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
1111
// RUN: %dxc -DFUNC=firstbitlow -DARITY=1 -DTYPE=uint -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
12+
// RUN: %dxc -DFUNC=ddx -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
13+
// RUN: %dxc -DFUNC=ddx_coarse -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
14+
// RUN: %dxc -DFUNC=ddx_fine -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
15+
// RUN: %dxc -DFUNC=ddy -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
16+
// RUN: %dxc -DFUNC=ddy_coarse -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
17+
// RUN: %dxc -DFUNC=ddy_fine -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
18+
// RUN: %dxc -DFUNC=fwidth -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,UNARY
1219
// RUN: %dxc -DFUNC=QuadReadLaneAt -DARITY=4 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,QUAD
1320
// RUN: %dxc -DFUNC=QuadReadAcrossX -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,QUAD
1421
// RUN: %dxc -DFUNC=QuadReadAcrossY -DARITY=1 -T ps_6_9 %s | FileCheck %s --check-prefixes=CHECK,QUAD

0 commit comments

Comments
 (0)