Skip to content

Commit 2cf6fa2

Browse files
committed
Merge branch 'main' of github.com:microsoft/DirectXShaderCompiler into devshFixes
2 parents 71cfa91 + d6e7e37 commit 2cf6fa2

File tree

705 files changed

+85916
-69198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

705 files changed

+85916
-69198
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Check code formatting"
2+
on: pull_request_target
3+
permissions:
4+
pull-requests: write
5+
6+
jobs:
7+
code_formatter:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Fetch LLVM sources
11+
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 2
14+
15+
- name: Get changed files
16+
id: changed-files
17+
uses: tj-actions/changed-files@v39
18+
with:
19+
separator: ","
20+
fetch_depth: 100 # Fetches only the last 10 commits
21+
22+
- name: "Listed files"
23+
run: |
24+
echo "Formatting files:"
25+
echo "${{ steps.changed-files.outputs.all_changed_files }}"
26+
27+
- name: Install clang-format
28+
uses: aminya/setup-cpp@v1
29+
with:
30+
clangformat: 17.0.1
31+
32+
- name: Setup Python env
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: '3.11'
36+
cache: 'pip'
37+
cache-dependency-path: 'utils/git/requirements_formatting.txt'
38+
39+
- name: Install python dependencies
40+
run: pip install -r utils/git/requirements_formatting.txt
41+
42+
- name: Run code formatter
43+
env:
44+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
45+
START_REV: ${{ github.event.pull_request.base.sha }}
46+
END_REV: ${{ github.event.pull_request.head.sha }}
47+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
48+
run: |
49+
python utils/git/code-format-helper.py \
50+
--token ${{ secrets.GITHUB_TOKEN }} \
51+
--issue-number $GITHUB_PR_NUMBER \
52+
--start-rev $START_REV \
53+
--end-rev $END_REV \
54+
--changed-files "$CHANGED_FILES"

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ add_link_options(/guard:cf)
120120
endif(WIN32)
121121

122122
# Enable CET Shadow Stack
123-
if(WIN32 AND NOT (CMAKE_GENERATOR_PLATFORM MATCHES "ARM.*"))
124-
add_link_options(/CETCOMPAT)
125-
endif(WIN32 AND NOT (CMAKE_GENERATOR_PLATFORM MATCHES "ARM.*"))
123+
if(WIN32 AND NOT (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*"))
124+
add_link_options(/CETCOMPAT)
125+
endif()
126126

127127
# HLSL Change Ends
128128

autoconf/config.guess

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ EOF
909909
crisv32:Linux:*:*)
910910
echo crisv32-axis-linux-gnu
911911
exit ;;
912+
e2k:Linux:*:*)
913+
echo ${UNAME_MACHINE}-unknown-linux-gnu
914+
exit ;;
912915
frv:Linux:*:*)
913916
echo frv-unknown-linux-gnu
914917
exit ;;

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ stages:
5353
configuration: Release
5454
CC: clang
5555
CXX: clang++
56-
CMAKE_OPTS: -DLLVM_ENABLE_WERROR=On
56+
CMAKE_OPTS: -DLLVM_ENABLE_WERROR=On -DLLVM_ENABLE_SANITIZER=Address -DLLVM_ENABLE_LIBCXX=On
5757
OS: Linux
5858
Linux_Clang_Debug:
5959
image: ${{ variables.linux }}

cmake/config-ix.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ elseif (LLVM_NATIVE_ARCH MATCHES "wasm64")
367367
set(LLVM_NATIVE_ARCH WebAssembly)
368368
elseif (LLVM_NATIVE_ARCH MATCHES "riscv64")
369369
set(LLVM_NATIVE_ARCH RISCV)
370+
elseif (LLVM_NATIVE_ARCH MATCHES "e2k")
371+
set(LLVM_NATIVE_ARCH E2K)
370372
else ()
371373
message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}")
372374
endif ()

cmake/modules/HCT.cmake

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ option(HLSL_COPY_GENERATED_SOURCES "Copy generated sources if different" Off)
22

33
add_custom_target(HCTGen)
44

5+
find_program(CLANG_FORMAT_EXE NAMES clang-format)
6+
7+
if (NOT CLANG_FORMAT_EXE)
8+
message(WARNING "Clang-format is not available. Generating included sources is not supported.")
9+
if (HLSL_COPY_GENERATED_SOURCES)
10+
message(FATAL_ERROR "Generating sources requires clang-format")
11+
endif ()
12+
endif ()
13+
514
if (WIN32 AND NOT DEFINED HLSL_AUTOCRLF)
615
find_program(git_executable NAMES git git.exe git.cmd)
716
execute_process(COMMAND ${git_executable} config --get core.autocrlf
@@ -35,7 +44,7 @@ function(add_hlsl_hctgen mode)
3544
message(FATAL_ERROR "add_hlsl_hctgen requires OUTPUT argument")
3645
endif()
3746

38-
set(temp_output ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OUTPUT}.tmp)
47+
set(temp_output ${CMAKE_CURRENT_BINARY_DIR}/tmp/${ARG_OUTPUT})
3948
set(full_output ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTPUT})
4049
if (ARG_BUILD_DIR)
4150
set(full_output ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OUTPUT})
@@ -49,6 +58,12 @@ function(add_hlsl_hctgen mode)
4958
${hctdb}
5059
${hctdb_helper})
5160

61+
get_filename_component(output_extension ${full_output} LAST_EXT)
62+
63+
if (CLANG_FORMAT_EXE AND output_extension MATCHES "\.h|\.cpp|\.inl")
64+
set(format_cmd COMMAND ${CLANG_FORMAT_EXE} -i ${temp_output})
65+
endif ()
66+
5267
set(copy_sources Off)
5368
if(ARG_BUILD_DIR OR HLSL_COPY_GENERATED_SOURCES)
5469
set(copy_sources On)
@@ -77,7 +92,9 @@ function(add_hlsl_hctgen mode)
7792
# file, and define the verification command
7893
if(NOT copy_sources)
7994
set(output ${temp_output})
80-
set(verification COMMAND ${CMAKE_COMMAND} -E compare_files ${temp_output} ${full_output})
95+
if (CLANG_FORMAT_EXE) # Only verify sources if clang-format is available.
96+
set(verification COMMAND ${CMAKE_COMMAND} -E compare_files ${temp_output} ${full_output})
97+
endif()
8198
endif()
8299
if(WIN32 AND NOT HLSL_AUTOCRLF)
83100
set(force_lf "--force-lf")
@@ -87,6 +104,7 @@ function(add_hlsl_hctgen mode)
87104
COMMAND ${PYTHON_EXECUTABLE}
88105
${hctgen} ${force_lf}
89106
${mode} --output ${temp_output} ${input_flag}
107+
${format_cmd}
90108
COMMENT "Building ${ARG_OUTPUT}..."
91109
DEPENDS ${hct_dependencies}
92110
)

cmake/modules/HandleLLVMOptions.cmake

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,23 @@ if( MSVC )
363363
if (LLVM_ENABLE_PEDANTIC)
364364
# No MSVC equivalent available
365365
endif (LLVM_ENABLE_PEDANTIC)
366+
367+
if (CLANG_CL)
368+
append("-Wall -W -Wno-unused-parameter -Wwrite-strings -Wimplicit-fallthrough" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
369+
append("-Wcast-qual" CMAKE_CXX_FLAGS)
370+
371+
# Disable unknown pragma warnings because the output is just too long with them.
372+
append("-Wno-unknown-pragmas" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
373+
374+
add_flag_if_supported("-Wno-unused-but-set-variable" UNUSED_BUT_SET_VARIABLE)
375+
append("-Wno-switch" CMAKE_CXX_FLAGS)
376+
377+
append("-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
378+
379+
# enable warnings explicitly.
380+
append("-Wnonportable-include-path -Wunused-function" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
381+
append("-Wtrigraphs -Wconstant-logical-operand -Wunused-variable" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
382+
endif (CLANG_CL)
366383
endif (LLVM_ENABLE_WARNINGS)
367384
if (LLVM_ENABLE_WERROR)
368385
append("/WX" msvc_warning_flags)
@@ -502,7 +519,7 @@ if(LLVM_USE_SANITIZER)
502519
endif()
503520
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
504521
append_common_sanitizer_flags()
505-
append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
522+
append("-fsanitize=undefined -fno-sanitize=vptr,function,alignment -fno-sanitize-recover=all"
506523
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
507524
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
508525
append_common_sanitizer_flags()

docs/BuildingAndTestingDXC.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ for the configuration process.
3232

3333
All of the most basic CMake configurations for DXC follow a similar format to:
3434

35-
.. code:: sh
35+
.. code-block:: sh
36+
3637
cmake <Repository Root> \
3738
-C <Repository Root>/cmake/caches/PredefinedParams.cmake \
3839
-DCMAKE_BUILD_TYPE=<Build Type> \
@@ -52,7 +53,8 @@ Generating a Visual Studio Solution
5253

5354
Open a Visual Stuido command prompt and run:
5455

55-
.. code:: sh
56+
.. code-block:: sh
57+
5658
cmake <Repository Root> \
5759
-B <Path to Output> \
5860
-C <Repository Root>/cmake/caches/PredefinedParams.cmake \
@@ -79,7 +81,8 @@ Generating Ninja or Makefiles
7981

8082
In your preferred terminal run:
8183

82-
.. code:: sh
84+
.. code-block:: sh
85+
8386
cmake <Repository Root> \
8487
-B <Path to Output> \
8588
-C <Repository Root>/cmake/caches/PredefinedParams.cmake \

docs/SPIR-V.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ are translated into SPIR-V ``OpTypeImage``, with parameters:
856856
``Texture1DArray`` Sampled Image RO ``UniformConstant`` ``1D`` 2 1 0 1 ``Unknown``
857857
``Texture2DArray`` Sampled Image RO ``UniformConstant`` ``2D`` 2 1 0 1 ``Unknown``
858858
``Texture2DMS`` Sampled Image RO ``UniformConstant`` ``2D`` 2 0 1 1 ``Unknown``
859-
``Texture2DMSArray`` Sampled Image RO ``UniformConstant`` ``2D`` 2 1 1 1 ``Unknown`` ``ImageMSArray``
859+
``Texture2DMSArray`` Sampled Image RO ``UniformConstant`` ``2D`` 2 1 1 1 ``Unknown``
860860
``TextureCubeArray`` Sampled Image RO ``UniformConstant`` ``3D`` 2 1 0 1 ``Unknown``
861861
``Buffer<T>`` Uniform Texel Buffer RO ``UniformConstant`` ``Buffer`` 2 0 0 1 Depends on ``T`` ``SampledBuffer``
862862
``RWBuffer<T>`` Storage Texel Buffer RW ``UniformConstant`` ``Buffer`` 2 0 0 2 Depends on ``T`` ``SampledBuffer``

0 commit comments

Comments
 (0)