Skip to content

Commit 1e5414b

Browse files
committed
Merge branch 'main' of github.com:Devsh-Graphics-Programming/DirectXShaderCompiler into devshFixes
2 parents 155f57a + 8be0439 commit 1e5414b

File tree

7 files changed

+6938
-1
lines changed

7 files changed

+6938
-1
lines changed

.github/workflows/main.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Devsh - Build & Deploy DXCompiler
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
COMMIT_SHA:
7+
description: 'Commit SHA to build'
8+
required: true
9+
10+
jobs:
11+
windows:
12+
name: Windows Build
13+
runs-on: windows-2022
14+
env:
15+
HLSL_SRC_DIR: ${{ github.workspace }}
16+
HLSL_BLD_DIR: "${{ github.workspace }}\\build"
17+
platform: x64
18+
os: windows-latest
19+
COMMIT_SHA: ${{ github.event.inputs.COMMIT_SHA }}
20+
strategy:
21+
matrix:
22+
configuration: [Release, Debug]
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
with:
27+
ref: ${{ github.event.inputs.COMMIT_SHA }}
28+
clean: true
29+
submodules: true
30+
31+
- name: Build
32+
run: |
33+
call utils\hct\hctstart.cmd %HLSL_SRC_DIR% %HLSL_BLD_DIR%
34+
call utils\hct\hctbuild.cmd -${{ env.platform }} -${{ matrix.configuration }} -show-cmake-log -spirvtest
35+
shell: cmd
36+
37+
- name: CMake Install DXCompiler
38+
run: |
39+
cmake --install build/include/dxc --prefix build/install --config ${{ matrix.configuration }}
40+
cmake --install build/tools/clang/tools/dxcompiler --prefix build/install --config ${{ matrix.configuration }}
41+
cmake -E copy build/${{ matrix.configuration }}/bin/dxcompiler.pdb build/install/lib/
42+
cmake -E copy build/${{ matrix.configuration }}/bin/dxc.exe build/install/bin/
43+
cmake -E copy include/dxc/WinAdapter.h build/install/include/dxc/
44+
shell: cmd
45+
46+
- name: Archive Installed Directory
47+
run: cmake -E tar czf ${{ github.event.inputs.COMMIT_SHA }}.tar.gz build/install
48+
shell: cmd
49+
50+
- name: Upload Installed Artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: ${{ env.os }}-${{ matrix.configuration }}-${{ github.event.inputs.COMMIT_SHA }}
54+
path: ${{ github.event.inputs.COMMIT_SHA }}.tar.gz
55+
56+
nix:
57+
name: Unix and macOS Build
58+
strategy:
59+
matrix:
60+
include:
61+
- os: ubuntu-latest
62+
name: Linux_Clang_Release
63+
configuration: Release
64+
CC: clang-18
65+
CXX: clang++-18
66+
CMAKE_OPTS: "-DLLVM_ENABLE_WERROR=On -DLLVM_USE_LINKER=lld"
67+
- os: ubuntu-latest
68+
name: Linux_Clang_Debug
69+
configuration: Debug
70+
CC: clang
71+
CXX: clang++
72+
CMAKE_OPTS: "-DLLVM_ENABLE_WERROR=On -DLLVM_USE_LINKER=lld"
73+
- os: macos-latest
74+
name: MacOS_Clang_Release
75+
configuration: Release
76+
CC: clang
77+
CXX: clang++
78+
CMAKE_OPTS: "-DLLVM_ENABLE_WERROR=On"
79+
- os: macos-latest
80+
name: MacOS_Clang_Debug
81+
configuration: Debug
82+
CC: clang
83+
CXX: clang++
84+
CMAKE_OPTS: "-DLLVM_ENABLE_WERROR=On"
85+
runs-on: ${{ matrix.os }}
86+
env:
87+
COMMIT_SHA: ${{ github.event.inputs.COMMIT_SHA }}
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v3
91+
with:
92+
ref: ${{ github.event.inputs.COMMIT_SHA }}
93+
clean: true
94+
submodules: true
95+
96+
- name: Set up Python
97+
uses: actions/setup-python@v4
98+
with:
99+
python-version: '3.x'
100+
101+
- name: Install dependencies on Linux
102+
if: ${{ matrix.os == 'ubuntu-latest' }}
103+
run: |
104+
sudo apt-get update
105+
sudo apt-get install -y ninja-build
106+
wget https://apt.llvm.org/llvm.sh
107+
chmod u+x llvm.sh
108+
sudo ./llvm.sh 18
109+
sudo apt-get install -y libc++-18-dev
110+
- name: Install dependencies on macOS
111+
if: ${{ matrix.os == 'macos-latest' }}
112+
run: |
113+
brew update
114+
brew install ninja
115+
ulimit -Sn 1024
116+
- name: Configure with CMake
117+
run: |
118+
cmake -B build -G Ninja $GITHUB_WORKSPACE \
119+
-DLLVM_LIT_ARGS="-v --xunit-xml-output=testresults.xunit.xml" \
120+
-C $GITHUB_WORKSPACE/cmake/caches/PredefinedParams.cmake \
121+
-DSPIRV_BUILD_TESTS=OFF \
122+
-DCMAKE_BUILD_TYPE=${{ matrix.configuration }} \
123+
-DCMAKE_C_COMPILER=${{ matrix.CC }} \
124+
-DCMAKE_CXX_COMPILER=${{ matrix.CXX }} \
125+
${{ matrix.CMAKE_OPTS || '' }}
126+
- name: Build
127+
run: ninja -C build test-depends
128+
129+
- name: CMake Install DXCompiler
130+
run: |
131+
cmake --install build/include/dxc --prefix build/install --config ${{ matrix.configuration }}
132+
cmake --install build/tools/clang/tools/dxcompiler --prefix build/install --config ${{ matrix.configuration }}
133+
cmake -E copy include/dxc/WinAdapter.h build/install/include/dxc/
134+
- name: Archive Installed Directory
135+
run: cmake -E tar czf ${{ github.event.inputs.COMMIT_SHA }}.tar.gz build/install
136+
137+
- name: Upload Installed Artifact
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: ${{ matrix.os }}-${{ matrix.configuration }}-${{ github.event.inputs.COMMIT_SHA }}
141+
path: ${{ github.event.inputs.COMMIT_SHA }}.tar.gz
142+
143+
windows-tests:
144+
name: Windows Devsh DXC smoke tests
145+
needs: windows
146+
runs-on: windows-2022
147+
strategy:
148+
fail-fast: false
149+
matrix:
150+
configuration: [Debug, Release]
151+
env:
152+
os: windows-latest
153+
COMMIT_SHA: ${{ github.event.inputs.COMMIT_SHA }}
154+
155+
steps:
156+
- name: Checkout repository
157+
uses: actions/checkout@v3
158+
with:
159+
ref: ${{ github.event.inputs.COMMIT_SHA }}
160+
fetch-depth: 1
161+
sparse-checkout: |
162+
unittests
163+
164+
- name: Download DXCompiler artifact
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: ${{ env.os }}-${{ matrix.configuration }}-${{ github.event.inputs.COMMIT_SHA }}
168+
path: artifacts
169+
170+
- name: Unpack DXCompiler into unittests\Devsh\install
171+
run: |
172+
cmake -E tar xzf artifacts\${{ github.event.inputs.COMMIT_SHA }}.tar.gz
173+
cmake -E make_directory unittests\Devsh\install
174+
cmake -E copy_directory build\install unittests\Devsh\install
175+
shell: cmd
176+
177+
- name: Configure Devsh unit tests
178+
run: |
179+
cmake -S unittests\Devsh -B unittests\Devsh\build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }}
180+
shell: cmd
181+
182+
- name: Run Devsh DXC smoke tests
183+
run: |
184+
ctest -C ${{ matrix.configuration }} -VV -R dxc_smoke --output-on-failure
185+
working-directory: unittests\Devsh\build
186+
shell: cmd

tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4930,7 +4930,7 @@ bool DeclResultIdMapper::tryToCreateConstantVar(const ValueDecl *decl) {
49304930
spvBuilder.getConstantFloat(astContext.DoubleTy, val->getFloat());
49314931
break;
49324932
default:
4933-
assert(false && "Unsupported builtin type evaluation at compile-time");
4933+
// assert(false && "Unsupported builtin type evaluation at compile-time");
49344934
return false;
49354935
}
49364936
constVal->setRValue(true);

tools/clang/unittests/HLSLExec/LongVectorOps.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,6 @@ OP(Wave, WaveMultiPrefixProduct, 1, "TestWaveMultiPrefixProduct", "", " -DFUNC_W
219219
OP(Wave, WaveMultiPrefixBitAnd, 1, "TestWaveMultiPrefixBitAnd", "", " -DFUNC_WAVE_MULTI_PREFIX_BIT_AND=1 -DIS_WAVE_PREFIX_OP=1", "LongVectorOp", WaveMultiPrefixBitwise, Default2, Default3)
220220
OP(Wave, WaveMultiPrefixBitOr, 1, "TestWaveMultiPrefixBitOr", "", " -DFUNC_WAVE_MULTI_PREFIX_BIT_OR=1 -DIS_WAVE_PREFIX_OP=1", "LongVectorOp", WaveMultiPrefixBitwise, Default2, Default3)
221221
OP(Wave, WaveMultiPrefixBitXor, 1, "TestWaveMultiPrefixBitXor", "", " -DFUNC_WAVE_MULTI_PREFIX_BIT_XOR=1 -DIS_WAVE_PREFIX_OP=1", "LongVectorOp", WaveMultiPrefixBitwise, Default2, Default3)
222+
OP_DEFAULT_DEFINES(Wave, WaveMatch, 1, "TestWaveMatch", "", " -DFUNC_WAVE_MATCH=1 -DIS_WAVE_PREFIX_OP=1")
222223

223224
#undef OP

tools/clang/unittests/HLSLExec/LongVectors.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,49 @@ template <typename T> T waveMultiPrefixProduct(T A, UINT) {
15421542
return A * A;
15431543
}
15441544

1545+
template <typename T> struct Op<OpType::WaveMatch, T, 1> : StrictValidation {};
1546+
1547+
template <typename T> struct ExpectedBuilder<OpType::WaveMatch, T> {
1548+
static std::vector<UINT> buildExpected(Op<OpType::WaveMatch, T, 1> &,
1549+
const InputSets<T> &,
1550+
const UINT WaveSize) {
1551+
// For this test, the shader arranges it so that lane 0 is different from
1552+
// all the other lanes. Besides that all other lines write their result of
1553+
// WaveMatch as well.
1554+
1555+
std::vector<UINT> Expected;
1556+
Expected.assign(WaveSize * 4, 0);
1557+
1558+
const UINT LowWaves = std::min(64U, WaveSize);
1559+
const UINT HighWaves = WaveSize - LowWaves;
1560+
1561+
const uint64_t LowWaveMask =
1562+
(LowWaves < 64) ? (1ULL << LowWaves) - 1 : ~0ULL;
1563+
1564+
const uint64_t HighWaveMask =
1565+
(HighWaves < 64) ? (1ULL << HighWaves) - 1 : ~0ULL;
1566+
1567+
const uint64_t LowExpected = ~1ULL & LowWaveMask;
1568+
const uint64_t HighExpected = ~0ULL & HighWaveMask;
1569+
1570+
Expected[0] = 1;
1571+
Expected[1] = 0;
1572+
Expected[2] = 0;
1573+
Expected[3] = 0;
1574+
1575+
// all lanes other than the first one have the same result
1576+
for (UINT I = 1; I < WaveSize; ++I) {
1577+
const UINT Index = I * 4;
1578+
Expected[Index] = static_cast<UINT>(LowExpected);
1579+
Expected[Index + 1] = static_cast<UINT>(LowExpected >> 32);
1580+
Expected[Index + 2] = static_cast<UINT>(HighExpected);
1581+
Expected[Index + 3] = static_cast<UINT>(HighExpected >> 32);
1582+
}
1583+
1584+
return Expected;
1585+
}
1586+
};
1587+
15451588
#undef WAVE_OP
15461589

15471590
//
@@ -2461,6 +2504,7 @@ class DxilConf_SM69_Vectorized {
24612504
HLK_WAVEOP_TEST(WaveActiveAllEqual, HLSLBool_t);
24622505
HLK_WAVEOP_TEST(WaveReadLaneAt, HLSLBool_t);
24632506
HLK_WAVEOP_TEST(WaveReadLaneFirst, HLSLBool_t);
2507+
HLK_WAVEOP_TEST(WaveMatch, HLSLBool_t);
24642508

24652509
HLK_WAVEOP_TEST(WaveActiveSum, int16_t);
24662510
HLK_WAVEOP_TEST(WaveActiveMin, int16_t);
@@ -2476,6 +2520,7 @@ class DxilConf_SM69_Vectorized {
24762520
HLK_WAVEOP_TEST(WaveMultiPrefixBitAnd, int16_t);
24772521
HLK_WAVEOP_TEST(WaveMultiPrefixBitOr, int16_t);
24782522
HLK_WAVEOP_TEST(WaveMultiPrefixBitXor, int16_t);
2523+
HLK_WAVEOP_TEST(WaveMatch, int16_t);
24792524
HLK_WAVEOP_TEST(WaveActiveSum, int32_t);
24802525
HLK_WAVEOP_TEST(WaveActiveMin, int32_t);
24812526
HLK_WAVEOP_TEST(WaveActiveMax, int32_t);
@@ -2490,6 +2535,7 @@ class DxilConf_SM69_Vectorized {
24902535
HLK_WAVEOP_TEST(WaveMultiPrefixBitAnd, int32_t);
24912536
HLK_WAVEOP_TEST(WaveMultiPrefixBitOr, int32_t);
24922537
HLK_WAVEOP_TEST(WaveMultiPrefixBitXor, int32_t);
2538+
HLK_WAVEOP_TEST(WaveMatch, int32_t);
24932539
HLK_WAVEOP_TEST(WaveActiveSum, int64_t);
24942540
HLK_WAVEOP_TEST(WaveActiveMin, int64_t);
24952541
HLK_WAVEOP_TEST(WaveActiveMax, int64_t);
@@ -2504,6 +2550,7 @@ class DxilConf_SM69_Vectorized {
25042550
HLK_WAVEOP_TEST(WaveMultiPrefixBitAnd, int64_t);
25052551
HLK_WAVEOP_TEST(WaveMultiPrefixBitOr, int64_t);
25062552
HLK_WAVEOP_TEST(WaveMultiPrefixBitXor, int64_t);
2553+
HLK_WAVEOP_TEST(WaveMatch, int64_t);
25072554

25082555
// Note: WaveActiveBit* ops don't support uint16_t in HLSL
25092556
// But the WaveMultiPrefixBit ops support all int and uint types
@@ -2521,6 +2568,7 @@ class DxilConf_SM69_Vectorized {
25212568
HLK_WAVEOP_TEST(WaveMultiPrefixBitAnd, uint16_t);
25222569
HLK_WAVEOP_TEST(WaveMultiPrefixBitOr, uint16_t);
25232570
HLK_WAVEOP_TEST(WaveMultiPrefixBitXor, uint16_t);
2571+
HLK_WAVEOP_TEST(WaveMatch, uint16_t);
25242572
HLK_WAVEOP_TEST(WaveActiveSum, uint32_t);
25252573
HLK_WAVEOP_TEST(WaveActiveMin, uint32_t);
25262574
HLK_WAVEOP_TEST(WaveActiveMax, uint32_t);
@@ -2538,6 +2586,7 @@ class DxilConf_SM69_Vectorized {
25382586
HLK_WAVEOP_TEST(WaveMultiPrefixBitAnd, uint32_t);
25392587
HLK_WAVEOP_TEST(WaveMultiPrefixBitOr, uint32_t);
25402588
HLK_WAVEOP_TEST(WaveMultiPrefixBitXor, uint32_t);
2589+
HLK_WAVEOP_TEST(WaveMatch, uint32_t);
25412590
HLK_WAVEOP_TEST(WaveActiveSum, uint64_t);
25422591
HLK_WAVEOP_TEST(WaveActiveMin, uint64_t);
25432592
HLK_WAVEOP_TEST(WaveActiveMax, uint64_t);
@@ -2555,6 +2604,7 @@ class DxilConf_SM69_Vectorized {
25552604
HLK_WAVEOP_TEST(WaveMultiPrefixBitAnd, uint64_t);
25562605
HLK_WAVEOP_TEST(WaveMultiPrefixBitOr, uint64_t);
25572606
HLK_WAVEOP_TEST(WaveMultiPrefixBitXor, uint64_t);
2607+
HLK_WAVEOP_TEST(WaveMatch, uint64_t);
25582608

25592609
HLK_WAVEOP_TEST(WaveActiveSum, HLSLHalf_t);
25602610
HLK_WAVEOP_TEST(WaveActiveMin, HLSLHalf_t);
@@ -2567,6 +2617,7 @@ class DxilConf_SM69_Vectorized {
25672617
HLK_WAVEOP_TEST(WavePrefixProduct, HLSLHalf_t);
25682618
HLK_WAVEOP_TEST(WaveMultiPrefixSum, HLSLHalf_t);
25692619
HLK_WAVEOP_TEST(WaveMultiPrefixProduct, HLSLHalf_t);
2620+
HLK_WAVEOP_TEST(WaveMatch, HLSLHalf_t);
25702621
HLK_WAVEOP_TEST(WaveActiveSum, float);
25712622
HLK_WAVEOP_TEST(WaveActiveMin, float);
25722623
HLK_WAVEOP_TEST(WaveActiveMax, float);
@@ -2578,6 +2629,7 @@ class DxilConf_SM69_Vectorized {
25782629
HLK_WAVEOP_TEST(WavePrefixProduct, float);
25792630
HLK_WAVEOP_TEST(WaveMultiPrefixSum, float);
25802631
HLK_WAVEOP_TEST(WaveMultiPrefixProduct, float);
2632+
HLK_WAVEOP_TEST(WaveMatch, float);
25812633
HLK_WAVEOP_TEST(WaveActiveSum, double);
25822634
HLK_WAVEOP_TEST(WaveActiveMin, double);
25832635
HLK_WAVEOP_TEST(WaveActiveMax, double);
@@ -2589,6 +2641,7 @@ class DxilConf_SM69_Vectorized {
25892641
HLK_WAVEOP_TEST(WavePrefixProduct, double);
25902642
HLK_WAVEOP_TEST(WaveMultiPrefixSum, double);
25912643
HLK_WAVEOP_TEST(WaveMultiPrefixProduct, double);
2644+
HLK_WAVEOP_TEST(WaveMatch, double);
25922645

25932646
private:
25942647
bool Initialized = false;

tools/clang/unittests/HLSLExec/ShaderOpArith.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4405,6 +4405,25 @@ void MSMain(uint GID : SV_GroupIndex,
44054405
}
44064406
#endif
44074407
4408+
#ifdef FUNC_WAVE_MATCH
4409+
void TestWaveMatch(vector<TYPE, NUM> Vector)
4410+
{
4411+
if(WaveGetLaneIndex() == 0)
4412+
{
4413+
if(Vector[0] == (TYPE)0)
4414+
Vector[0] = (TYPE) 1;
4415+
else if(Vector[0] == (TYPE)1)
4416+
Vector[0] = (TYPE) 0;
4417+
else
4418+
Vector[0] = (TYPE) 1;
4419+
}
4420+
uint4 result = WaveMatch(Vector);
4421+
uint index = WaveGetLaneIndex();
4422+
4423+
g_OutputVector.Store<uint4>(index * sizeof(uint4), result);
4424+
}
4425+
#endif
4426+
44084427
#ifdef FUNC_TEST_SELECT
44094428
vector<OUT_TYPE, NUM> TestSelect(vector<TYPE, NUM> Vector1,
44104429
vector<TYPE, NUM> Vector2,

0 commit comments

Comments
 (0)