Skip to content

Commit a9a8b73

Browse files
committed
Merge branch 'main' into main_to_staging
2 parents 8ab7045 + 422604b commit a9a8b73

26 files changed

Lines changed: 637 additions & 59 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 \

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,32 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
22872287
break;
22882288
}
22892289

2290+
// Shader Execution Reordering - from ray query
2291+
case DXIL::OpCode::HitObject_FromRayQuery:
2292+
case DXIL::OpCode::HitObject_FromRayQueryWithAttrs: {
2293+
for (unsigned i = 1; i < CI->getNumOperands(); ++i) {
2294+
Value *Arg = CI->getArgOperand(i);
2295+
if (isa<UndefValue>(Arg))
2296+
ValCtx.EmitInstrError(CI, ValidationRule::InstrNoReadingUninitialized);
2297+
}
2298+
break;
2299+
}
2300+
2301+
case DXIL::OpCode::HitObject_Invoke: {
2302+
if (isa<UndefValue>(CI->getArgOperand(1)))
2303+
ValCtx.EmitInstrError(CI, ValidationRule::InstrUndefHitObject);
2304+
if (isa<UndefValue>(CI->getArgOperand(2)))
2305+
ValCtx.EmitInstrError(CI, ValidationRule::InstrNoReadingUninitialized);
2306+
} break;
2307+
case DXIL::OpCode::HitObject_TraceRay: {
2308+
Value *Hdl = CI->getArgOperand(
2309+
DxilInst_HitObject_TraceRay::arg_accelerationStructure);
2310+
ValidateASHandle(CI, Hdl, ValCtx);
2311+
for (unsigned ArgIdx = 2; ArgIdx < CI->getNumArgOperands(); ++ArgIdx)
2312+
if (isa<UndefValue>(CI->getArgOperand(ArgIdx)))
2313+
ValCtx.EmitInstrError(CI, ValidationRule::InstrNoReadingUninitialized);
2314+
DxilInst_HitObject_TraceRay HOTraceRay(CI);
2315+
} break;
22902316
case DXIL::OpCode::AtomicBinOp:
22912317
case DXIL::OpCode::AtomicCompareExchange: {
22922318
Type *pOverloadType = OP::GetOverloadType(Opcode, CI->getCalledFunction());

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/SPIRV/EmitVisitor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,13 @@ bool EmitVisitor::visit(SpirvIntrinsicInstruction *inst) {
20002000
}
20012001
}
20022002

2003-
finalizeInstruction(&mainBinary);
2003+
auto opcode = static_cast<spv::Op>(inst->getInstruction());
2004+
if ((opcode == spv::Op::OpSpecConstant || opcode == spv::Op::OpConstant) &&
2005+
!inst->getInstructionSet()) {
2006+
finalizeInstruction(&typeConstantBinary);
2007+
} else {
2008+
finalizeInstruction(&mainBinary);
2009+
}
20042010
return true;
20052011
}
20062012

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DFUNC=abs -DOP=6 -DNUM=7 %s | FileCheck %s
2+
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DFUNC=abs -DOP=6 -DNUM=1022 %s | FileCheck %s
13
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DFUNC=saturate -DOP=7 -DNUM=7 %s | FileCheck %s
24
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DFUNC=saturate -DOP=7 -DNUM=1022 %s | FileCheck %s
35
// RUN: %dxc -T cs_6_9 -enable-16bit-types -DFUNC=cos -DOP=12 -DNUM=7 %s | FileCheck %s

0 commit comments

Comments
 (0)