48 Commits

Author SHA1 Message Date
bruvzg
e37433ee07 Merge pull request #29 from bruvzg/fix_arm64
Fix ARM64 build.
2025-12-16 10:55:41 +02:00
Pāvels Nadtočajevs
f66b541698 Fix ARM64 build. 2025-12-15 15:10:38 +02:00
Rémi Verschelde
8bf797f994 Merge pull request #28 from blueskythlikesclouds/input-attachment-to-srv
Convert input attachments to textures when lowering them.
2025-12-12 14:40:56 +01:00
Skyth
809e271095 Convert input attachments to textures when lowering them. 2025-12-12 15:12:10 +03:00
Rémi Verschelde
10efaa3a24 Merge pull request #26 from blueskythlikesclouds/alloc-redirection
Redirect memory allocation functions to Godot NIR bridge.
2025-12-12 13:09:32 +01:00
Skyth
2ec0afddea Redirect memory allocation functions to Godot NIR bridge. 2025-12-12 15:02:15 +03:00
Rémi Verschelde
6e74f88c54 Merge pull request #27 from blueskythlikesclouds/mesa-ver-upgrade
Upgrade Mesa version to 25.3.1.
2025-12-12 12:29:32 +01:00
Skyth
1bdec2ab6a Upgrade Mesa version to 25.3.1. 2025-12-09 17:28:17 +03:00
bruvzg
7719abc192 Merge pull request #23 from blueskythlikesclouds/ndebug-and-no-dxil-opt
Add NDEBUG & disable some DXIL optimizations.
2025-11-03 10:44:51 +02:00
bruvzg
e20edfeddb Merge pull request #22 from blueskythlikesclouds/remove-bit-masking
Remove 0xbfffffff bitmask from specialization constants.
2025-11-03 10:41:31 +02:00
bruvzg
2c12ce242a Merge pull request #25 from bruvzg/ci_scons_44
Bump SCons version to fix MSVC detection.
2025-11-01 19:47:05 +02:00
Pāvels Nadtočajevs
6e377555a0 Bump SCons version to fix MSVC detection. 2025-11-01 19:40:12 +02:00
Skyth
c2ae0c3cb6 Remove 0xbfffffff bitmask from specialization constants. 2025-10-31 23:29:43 +03:00
Skyth
eb3eef2b98 Add NDEBUG & disable DXIL optimizations. 2025-10-31 23:05:17 +03:00
bruvzg
c95c0dc8b0 Merge pull request #24 from bruvzg/ci_upd
Update CI images to windows-2022
2025-10-31 21:48:25 +02:00
Pāvels Nadtočajevs
f4466616e6 Update CI images to windows-2022 2025-10-31 21:43:02 +02:00
Rémi Verschelde
226205dac0 Merge pull request #20 from bruvzg/remove_arm32
[CI] Remove 32-bit ARM build.
2024-07-26 13:54:33 +02:00
bruvzg
28a96cc196 [CI] Remove 32-bit ARM build. 2024-07-26 14:36:28 +03:00
Rémi Verschelde
ff659277fb Merge pull request #19 from bruvzg/ci_upload_fix
[CI] Fix upload action.
2024-07-18 14:13:04 +02:00
bruvzg
c2b257ae7c [CI] Fix upload action. 2024-07-18 14:36:26 +03:00
Rémi Verschelde
a46efbb83c Merge pull request #16 from bruvzg/ci_set
Setup CI for MSVC, MinGW/GCC and MinGW/LLVM
2024-07-18 10:48:44 +02:00
Rémi Verschelde
4fa39a02b0 Merge pull request #18 from kus04e4ek/master
Add missing imports, remove wildcard and unused imports
2024-07-17 14:20:53 +02:00
Kusok
232dda2a37 Add missing imports, remove wildcard and unused imports 2024-07-16 16:53:40 +08:00
bruvzg
e72737a1a8 Setup CI for MSVC, MinGW/GCC and MinGW/LLVM 2024-07-12 11:44:15 +03:00
Rémi Verschelde
27a49f8601 Merge pull request #15 from RandomShaper/bye_bye_dxil_dll
Remove patch to the no longer needed validation feature
2024-07-11 23:17:32 +02:00
Pedro J. Estébanez
1e66fa02bf Remove patch to the no longer needed validation feature 2024-07-11 10:45:09 +02:00
Rémi Verschelde
e101346d1e Merge pull request #14 from RandomShaper/handle_sc_composite
Handle OpSpecConstantComposite
2024-07-02 15:31:02 +02:00
Pedro J. Estébanez
b6ed19e648 Handle OpSpecConstantComposite 2024-07-02 15:13:54 +02:00
Rémi Verschelde
360d88bb7e Merge pull request #11 from RandomShaper/asan
Add `use_asan` build option
2024-07-02 14:30:35 +02:00
Rémi Verschelde
d3d7cc7a5a Merge pull request #13 from bruvzg/llvm-mingw-win
Fix LLVM/MinGW build on Windows.
2024-06-20 14:04:05 +02:00
bruvzg
97b2e3580c Fix LLVM/MinGW build on Windows. 2024-06-20 14:20:50 +03:00
Rémi Verschelde
7546e0b405 Merge pull request #12 from bruvzg/fix_clang_mingw
Fix LLVM/MinGW build.
2024-06-19 20:46:48 +02:00
bruvzg
c4211d1652 Fix LLVM/MinGW build. 2024-06-19 20:50:10 +03:00
Pedro J. Estébanez
d61034bda2 Add use_asan build option 2024-06-14 14:03:34 +02:00
Rémi Verschelde
0af9607ba4 Merge pull request #10 from bruvzg/add_license
Add missing license file.
2024-04-15 22:32:30 +02:00
bruvzg
ea21cea768 Add missing license file. 2024-04-15 23:25:08 +03:00
Rémi Verschelde
b3565f5cb4 Merge pull request #8 from bruvzg/fix_dxil_load
Fix infinite loop when loading DXIL.dll if library is not found.
2024-02-13 11:29:40 +01:00
bruvzg
8d78553b4f Fix infinite loop when loading DXIL.dll if library is not found. 2024-02-11 17:15:33 +02:00
Rémi Verschelde
4eaadef72f Merge pull request #6 from bruvzg/update_mesa
Update mesa to 23.1.9
2024-01-31 14:03:24 +01:00
Rémi Verschelde
d6fe1ff902 Merge pull request #5 from bruvzg/mesa_no_ex
[MinGW] Disable exceptions.
2024-01-31 13:16:31 +01:00
bruvzg
0985547d67 Update mesa to 23.1.9 2024-01-31 14:08:58 +02:00
bruvzg
9557f078cd [MinGW] Disable exceptions. 2024-01-30 19:13:32 +02:00
Rémi Verschelde
f2e0daf5eb Merge pull request #4 from shana/more-build-options
Allow setting additional defines and an extra suffix from the cli
2024-01-10 14:07:43 +01:00
Andreia Gaita
938501d717 Allow setting additional defines and an extra suffix from the command line
We need to do some builds with additional defines for Xbox because the
dxil validator code uses a different DLL name depending on the active
defines. It's not really worth adding a whole new platform for this,
everything else is just the normal Windows build, so this PR just adds
the ability to pass in additional defines from the CLI, and an option
to set an additional suffix to the binary, so we can tell builds apart.
2024-01-10 13:53:55 +01:00
bruvzg
5435ae8bae Merge pull request #3 from superxkooda/clangarm64
Modifications to get compiled in msys2 on arm64
2024-01-08 09:04:02 +02:00
Michael Anghelone
149bcf6cff Modifications to get compiled in msys2 on arm64
These modifications make it possible to compile within a msys2
clangarm64 environment.

Command used to build:
```
    scons use_mingw=True use_llvm=True arch=arm64
```

The patch file prevents this error from occurring:
```
    gcc -o godot-mesa/src/microsoft/compiler/nir_to_dxil.windows.arm64.o -c -std=c11 -O3 -DMINGW_ENABLED -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -D__MSVCRT_VERSION__=1792 -DHAVE_STRUCT_TIMESPEC -DWINDOWS_NO_FUTEX -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DPACKAGE_VERSION=\"23.1.0-devel\" -DPACKAGE_BUGREPORT=\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\" -DPIPE_SUBSYSTEM_WINDOWS_USER -D_USE_MATH_DEFINES -DHAVE_TIMESPEC_GET -DHAVE_STRUCT_TIMESPEC -D_UCRT -Igodot-mesa -Igodot-mesa/bin -Igodot-mesa/include -Igodot-mesa/include/GL -Igodot-mesa/include/GLES -Igodot-mesa/include/GLES2 -Igodot-mesa/include/GLES3 -Igodot-mesa/include/KHR -Igodot-mesa/src -Igodot-mesa/src/c11/impl -Igodot-mesa/src/compiler -Igodot-mesa/src/compiler/glsl -Igodot-mesa/src/compiler/nir -Igodot-mesa/src/compiler/nir/__pycache__ -Igodot-mesa/src/compiler/spirv -Igodot-mesa/src/gallium -Igodot-mesa/src/gallium/include -Igodot-mesa/src/gallium/include/pipe -Igodot-mesa/src/mesa -Igodot-mesa/src/mesa/main -Igodot-mesa/src/mesa/program -Igodot-mesa/src/microsoft -Igodot-mesa/src/microsoft/compiler -Igodot-mesa/src/microsoft/spirv_to_dxil -Igodot-mesa/src/util -Igodot-mesa/src/util/format -Igodot-mesa/src/util/format/__pycache__ -Igodot-mesa/src/util/sha1 -Igodot-mesa/src/vulkan -Igodot-mesa/src/vulkan/runtime -Igodot-mesa/src/vulkan/util -Igodot-mesa/generated/src -Igodot-mesa/generated/src/compiler -Igodot-mesa/generated/src/compiler/nir -Igodot-mesa/generated/src/compiler/nir -Igodot-mesa/generated/src/compiler/nir -Igodot-mesa/generated/src/compiler/nir -Igodot-mesa/generated/src/compiler/spirv -Igodot-mesa/generated/src/util/format -I. -Ivulkan/include godot-mesa/src/microsoft/compiler/nir_to_dxil.c
    =====
    godot-mesa/src/microsoft/compiler/nir_to_dxil.c:5087:7: error: expected expression
     5087 |       const struct dxil_value* value = get_src(ctx, &intr->src[0], 0, nir_type_uint);
          |       ^
    godot-mesa/src/microsoft/compiler/nir_to_dxil.c:5088:45: error: use of undeclared identifier 'value'
     5088 |       store_dest_value(ctx, &intr->dest, 0, value);
          |                                             ^
    2 errors generated.

    =====
    scons: *** [godot-mesa/src/microsoft/compiler/nir_to_dxil.windows.arm64.o] Error 1
    scons: building terminated because of errors.
```

With these change I am able to build on a Surface Pro X without any
issues.

Afterwords compiling godot itself looks like this:
```
$ scons  mingw_prefix=/clangarm64 LINKFLAGS="-lpng -lembree3.dll -L/clangarm64/lib/" CCFLAGS='-I/clangarm64/include/-v' CC=aarch64-w64-mingw32-gcc CXX=aarch64-w64-mingw32-g++ platform=windows builtin_embree=False builtin_libpng=False d3d12=True mesa_libs=<path to godot-nir-static> dxc_path=<path to dxc> opengl3=False vulkan=False use_volk=False
```

embree, and libpng included in the repo proved to be difficult to
compile with. I opted to use the pre compiled versions available through
my package manager.

This was a fun challenge, and I hope it is found to be useful.

PS this only worked on the current master of Godot (v4.3.dev.custom_build [13a0d6e9b]),
the 4.2 branch would not compile.
2024-01-05 16:40:23 -05:00
Yuri Sizov
aa5c9775c7 Merge pull request #2 from bruvzg/mingw_fixes
[MinGW] Rename conflicting file, add missing timespec function implementation.
2023-12-14 16:18:06 +01:00
bruvzg
d1ca231620 [MinGW] Rename conflicting file, add missing timespec function implementation. 2023-12-14 11:07:37 +02:00
14 changed files with 795 additions and 213 deletions

179
.github/workflows/ci.yaml vendored Normal file
View File

@@ -0,0 +1,179 @@
name: Godot Mesa/NIR static libs
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.name }}
strategy:
matrix:
include:
# MinGW/LLVM libs using UCRT
- name: 🏁 Windows - MinGW/LLVM (UCRT) x86_64
platform: windows
os: windows-2022
artifact-name: godot-nir-static-x86_64-llvm-release
artifact-path: bin/libNIR.windows.x86_64.a
flags: use_mingw=yes arch=x86_64 use_llvm=yes mingw_prefix=$HOME/llvm-mingw
llvm: yes
- name: 🏁 Windows - MinGW/LLVM (UCRT) x86_32
platform: windows
os: windows-2022
artifact-name: godot-nir-static-x86_32-llvm-release
artifact-path: bin/libNIR.windows.x86_32.a
flags: use_mingw=yes arch=x86_32 use_llvm=yes mingw_prefix=$HOME/llvm-mingw
llvm: yes
- name: 🏁 Windows - MinGW/LLVM (UCRT) arm64
platform: windows
os: windows-2022
artifact-name: godot-nir-static-arm64-llvm-release
artifact-path: bin/libNIR.windows.arm64.a
flags: use_mingw=yes arch=arm64 use_llvm=yes mingw_prefix=$HOME/llvm-mingw
llvm: yes
# MSVC libs
- name: 🏁 Windows - MSVC x86_64
platform: windows
os: windows-2022
artifact-name: godot-nir-static-x86_64-msvc-release
artifact-path: bin/libNIR.windows.x86_64.lib
flags: use_mingw=no arch=x86_64
- name: 🏁 Windows - MSVC x86_32
platform: windows
os: windows-2022
artifact-name: godot-nir-static-x86_32-msvc-release
artifact-path: bin/libNIR.windows.x86_32.lib
flags: use_mingw=no arch=x86_32
- name: 🏁 Windows - MSVC arm64
platform: windows
os: windows-2022
artifact-name: godot-nir-static-arm64-msvc-release
artifact-path: bin/libNIR.windows.arm64.lib
flags: use_mingw=no arch=arm64
# MinGW/GCC libs using MSVCRT
- name: 🏁 Windows - MinGW/GCC (MSVCRT) x86_64
platform: windows
os: windows-2022
artifact-name: godot-nir-static-x86_64-gcc-release
artifact-path: bin/libNIR.windows.x86_64.a
flags: use_mingw=yes arch=x86_64
mingw: yes
msys: mingw64
msysenv: x86_64
- name: 🏁 Windows - MinGW/GCC (MSVCRT) x86_32
platform: windows
os: windows-2022
artifact-name: godot-nir-static-x86_32-gcc-release
artifact-path: bin/libNIR.windows.x86_32.a
flags: use_mingw=yes arch=x86_32
mingw: yes
msys: mingw32
msysenv: i686
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install SCons (Native env)
if: ${{ matrix.mingw != 'yes' }}
run: |
python -m pip install scons==4.9.0
- name: Install mako
run: |
python -m pip install mako
- name: Install pyyaml
run: |
python -m pip install pyyaml
- name: Setup MinGW/LLVM
if: ${{ matrix.platform == 'windows' && matrix.llvm == 'yes' }}
run: |
curl -L -O https://github.com/mstorsjo/llvm-mingw/releases/download/20240619/llvm-mingw-20240619-ucrt-x86_64.zip
unzip -q llvm-mingw-*.zip
rm llvm-mingw-*.zip
mv llvm-mingw-* "$HOME/llvm-mingw"
echo "$HOME/llvm-mingw/bin" >> $GITHUB_PATH
- name: Setup MinGW/MSYS2
if: ${{ matrix.mingw == 'yes' }}
uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{matrix.msys}}
install: mingw-w64-${{matrix.msysenv}}-gcc mingw-w64-${{matrix.msysenv}}-scons
- name: Prepare Mesa source
shell: bash
run: |
./update_mesa.sh
- name: Build Mesa (Native env)
if: ${{ matrix.mingw != 'yes' }}
run: |
scons platform=${{ matrix.platform }} ${{ matrix.flags }} optimize=speed
- name: Build Mesa (MSYS2 env)
if: ${{ matrix.mingw == 'yes' }}
shell: msys2 {0}
run: |
scons platform=${{ matrix.platform }} ${{ matrix.flags }} optimize=speed
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: |
${{ matrix.artifact-path }}
godot-mesa/VERSION.info
godot-mesa/**/*.h
godot-mesa/**/*.hpp
if-no-files-found: error
release:
name: 'Release'
needs: [build]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: ZIP Artifacts
run: |
for i in */; do (cd "${i%/}"; zip -r "../${i%/}.zip" .; cd ..); done
- name: Create Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
removeArtifacts: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
artifacts: "*.zip"
artifactErrorsFailBuild: true

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.sconsign.dblite .sconsign.dblite
bin/ bin/
godot-mesa/ godot-mesa/
*.pyc

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "mesa"] [submodule "mesa"]
path = mesa path = mesa
url = https://github.com/Mesa3D/mesa url = https://gitlab.freedesktop.org/mesa/mesa

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2017-present Godot Engine contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -3,9 +3,7 @@
import os import os
import platform import platform
import sys import sys
import subprocess
from pathlib import Path from pathlib import Path
from SCons.Errors import UserError
EnsureSConsVersion(4, 0) EnsureSConsVersion(4, 0)
@@ -113,6 +111,14 @@ opts.Add(
) )
) )
opts.Add("cppdefines", "Custom defines for the pre-processor")
opts.Add("ccflags", "Custom flags for both the C and C++ compilers")
opts.Add("cxxflags", "Custom flags for the C++ compiler")
opts.Add("cflags", "Custom flags for the C compiler")
opts.Add("linkflags", "Custom flags for the linker")
opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files.", "")
opts.Add(BoolVariable("use_asan", "Use address sanitizer (ASAN) in MSVC", False))
# Targets flags tool (optimizations, debug symbols) # Targets flags tool (optimizations, debug symbols)
target_tool = Tool("targets", toolpath=["godot-tools"]) target_tool = Tool("targets", toolpath=["godot-tools"])
target_tool.options(opts) target_tool.options(opts)
@@ -157,6 +163,12 @@ if unknown:
print("Building for architecture " + env["arch"] + " on platform " + env["platform"]) print("Building for architecture " + env["arch"] + " on platform " + env["platform"])
env.Append(CPPDEFINES=env.get("cppdefines", "").split())
env.Append(CCFLAGS=env.get("ccflags", "").split())
env.Append(CXXFLAGS=env.get("cxxflags", "").split())
env.Append(CFLAGS=env.get("cflags", "").split())
env.Append(LINKFLAGS=env.get("linkflags", "").split())
# Require C++17 # Require C++17
if env.get("is_msvc", False): if env.get("is_msvc", False):
env.Append(CXXFLAGS=["/std:c++17"]) env.Append(CXXFLAGS=["/std:c++17"])
@@ -178,6 +190,12 @@ if env["platform"] == "macos":
elif env["platform"] == "windows": elif env["platform"] == "windows":
env.AppendUnique(CPPDEFINES=["WINVER=0x0603", "_WIN32_WINNT=0x0603"]) env.AppendUnique(CPPDEFINES=["WINVER=0x0603", "_WIN32_WINNT=0x0603"])
# Sanitizers.
if env.get("use_asan", False) and env.get("is_msvc", False):
env["extra_suffix"] += ".san"
env.Append(LINKFLAGS=["/INFERASANLIBS"])
env.Append(CCFLAGS=["/fsanitize=address"])
scons_cache_path = os.environ.get("SCONS_CACHE") scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path is not None: if scons_cache_path is not None:
@@ -197,12 +215,12 @@ custom_build_steps = [
], ],
["src/compiler/nir", "nir_builder_opcodes_h.py > %s/nir_builder_opcodes.h", "nir_builder_opcodes.h"], ["src/compiler/nir", "nir_builder_opcodes_h.py > %s/nir_builder_opcodes.h", "nir_builder_opcodes.h"],
["src/compiler/nir", "nir_constant_expressions.py > %s/nir_constant_expressions.c", "nir_constant_expressions.c"], ["src/compiler/nir", "nir_constant_expressions.py > %s/nir_constant_expressions.c", "nir_constant_expressions.c"],
["src/compiler/nir", "nir_intrinsics_h.py --outdir %s", "nir_intrinsics.h"], ["src/compiler/nir", "nir_intrinsics_h.py --out %s/nir_intrinsics.h", "nir_intrinsics.h"],
["src/compiler/nir", "nir_intrinsics_c.py --outdir %s", "nir_intrinsics.c"], ["src/compiler/nir", "nir_intrinsics_c.py --out %s/nir_intrinsics.c", "nir_intrinsics.c"],
["src/compiler/nir", "nir_intrinsics_indices_h.py --outdir %s", "nir_intrinsics_indices.h"], ["src/compiler/nir", "nir_intrinsics_indices_h.py --out %s/nir_intrinsics_indices.h", "nir_intrinsics_indices.h"],
["src/compiler/nir", "nir_opcodes_h.py > %s/nir_opcodes.h", "nir_opcodes.h"], ["src/compiler/nir", "nir_opcodes_h.py > %s/nir_opcodes.h", "nir_opcodes.h"],
["src/compiler/nir", "nir_opcodes_c.py > %s/nir_opcodes.c", "nir_opcodes.c"], ["src/compiler/nir", "nir_opcodes_c.py > %s/nir_opcodes.c", "nir_opcodes.c"],
["src/compiler/nir", "nir_opt_algebraic.py > %s/nir_opt_algebraic.c", "nir_opt_algebraic.c"], ["src/compiler/nir", "nir_opt_algebraic.py --out %s/nir_opt_algebraic.c", "nir_opt_algebraic.c"],
["src/compiler/spirv", "vtn_generator_ids_h.py spir-v.xml %s/vtn_generator_ids.h", "vtn_generator_ids.h"], ["src/compiler/spirv", "vtn_generator_ids_h.py spir-v.xml %s/vtn_generator_ids.h", "vtn_generator_ids.h"],
[ [
"src/microsoft/compiler", "src/microsoft/compiler",
@@ -210,8 +228,11 @@ custom_build_steps = [
"dxil_nir_algebraic.c", "dxil_nir_algebraic.c",
], ],
["src/util", "format_srgb.py > %s/format_srgb.c", "format_srgb.c"], ["src/util", "format_srgb.py > %s/format_srgb.c", "format_srgb.c"],
["src/util/format", "u_format_table.py u_format.csv --header > %s/u_format_pack.h", "u_format_pack.h"], ["src/util/format", "u_format_table.py u_format.yaml --enums > %s/u_format_gen.h", "u_format_gen.h"],
["src/util/format", "u_format_table.py u_format.csv > %s/u_format_table.c", "u_format_table.c"], ["src/util/format", "u_format_table.py u_format.yaml --header > %s/u_format_pack.h", "u_format_pack.h"],
["src/util/format", "u_format_table.py u_format.yaml > %s/u_format_table.c", "u_format_table.c"],
["src/compiler", "builtin_types_h.py %s/builtin_types.h", "builtin_types.h"],
["src/compiler", "builtin_types_c.py %s/builtin_types.c", "builtin_types.c"],
] ]
mesa_sources = [] mesa_sources = []
@@ -274,15 +295,23 @@ extra_defines = [
"WINDOWS_NO_FUTEX", "WINDOWS_NO_FUTEX",
] ]
if env["optimize"] != "debug":
extra_defines += ["NDEBUG"]
# These defines are inspired by the Meson build scripts in the original repo. # These defines are inspired by the Meson build scripts in the original repo.
extra_defines += [ extra_defines += [
"__STDC_CONSTANT_MACROS", "__STDC_CONSTANT_MACROS",
"__STDC_FORMAT_MACROS", "__STDC_FORMAT_MACROS",
"__STDC_LIMIT_MACROS", "__STDC_LIMIT_MACROS",
("PACKAGE_VERSION", '\\"' + Path(mesa_absdir + "/VERSION").read_text().strip() + '\\"'), ("PACKAGE_VERSION", '\\"' + Path(mesa_absdir + "/VERSION.info").read_text().strip() + '\\"'),
("PACKAGE_BUGREPORT", '\\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\\"'), ("PACKAGE_BUGREPORT", '\\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\\"'),
"PIPE_SUBSYSTEM_WINDOWS_USER", "PIPE_SUBSYSTEM_WINDOWS_USER",
"_USE_MATH_DEFINES", "_USE_MATH_DEFINES",
"BLAKE3_NO_SSE2",
"BLAKE3_NO_SSE41",
"BLAKE3_NO_AVX2",
"BLAKE3_NO_AVX512",
("BLAKE3_USE_NEON", 0),
] ]
if env.get("is_msvc", False): if env.get("is_msvc", False):
@@ -297,23 +326,33 @@ if env.get("is_msvc", False):
("_HAS_EXCEPTIONS", 0), ("_HAS_EXCEPTIONS", 0),
"NOMINMAX", "NOMINMAX",
"HAVE_STRUCT_TIMESPEC", "HAVE_STRUCT_TIMESPEC",
"HAVE_TIMESPEC_GET",
("_Static_assert", "static_assert"), ("_Static_assert", "static_assert"),
] ]
env.Append(CFLAGS=["/std:c11"]) env.Append(CFLAGS=["/std:c11"])
else: else:
env.Append( env.Append(
CPPDEFINES=[ CPPDEFINES=[
("__MSVCRT_VERSION__", 0x0700),
"HAVE_STRUCT_TIMESPEC", "HAVE_STRUCT_TIMESPEC",
] ]
) )
env.Append(CFLAGS=["-std=c11"]) env.Append(CFLAGS=["-std=c11"])
env.Append(CXXFLAGS=["-fno-exceptions"])
if env.get("use_llvm", False):
extra_defines += [
("__MSVCRT_VERSION__", 0x0700),
"HAVE_TIMESPEC_GET",
"_UCRT",
]
env.Append(CPPDEFINES=extra_defines) env.Append(CPPDEFINES=extra_defines)
env.Append(CPPPATH=".") env.Append(CPPPATH=".")
env.Append(CPPPATH="#vulkan/include") env.Append(CPPPATH="#vulkan/include")
suffix = ".{}.{}".format(env["platform"], env["arch"]) suffix = ".{}.{}".format(env["platform"], env["arch"])
if env.get("extra_suffix", "") != "":
suffix += "." + env["extra_suffix"]
# Expose it when included from another project # Expose it when included from another project
env["suffix"] = suffix env["suffix"] = suffix

View File

@@ -53,6 +53,10 @@ typedef struct GodotNirCallbacks {
void (*report_bitcode_bit_offset_fn)(uint64_t p_bit_offset, void *p_data); void (*report_bitcode_bit_offset_fn)(uint64_t p_bit_offset, void *p_data);
} GodotNirCallbacks; } GodotNirCallbacks;
extern void *godot_nir_malloc(size_t p_size);
extern void *godot_nir_realloc(void *p_block, size_t p_size);
extern void godot_nir_free(void *p_block);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -1,47 +1,171 @@
diff --git a/godot-mesa/src/compiler/nir/nir_dominance_lca.c b/godot-mesa/src/compiler/nir/nir_dominance_lca.c
index 84a7f1d..40c0811 100644
--- a/godot-mesa/src/compiler/nir/nir_dominance_lca.c
+++ b/godot-mesa/src/compiler/nir/nir_dominance_lca.c
@@ -167,7 +167,7 @@ nir_dominance_lca(nir_block *b1, nir_block *b2)
uint32_t i1 = dom_lca_representative(b1);
uint32_t i2 = dom_lca_representative(b2);
if (i1 > i2)
- SWAP(i1, i2);
+ MESA_SWAP(i1, i2);
uint32_t index = range_minimum_query(&impl->dom_lca_info.table, i1, i2 + 1);
nir_block *result = impl->dom_lca_info.block_from_idx[index];
diff --git a/godot-mesa/src/compiler/nir/nir_intrinsics.py b/godot-mesa/src/compiler/nir/nir_intrinsics.py diff --git a/godot-mesa/src/compiler/nir/nir_intrinsics.py b/godot-mesa/src/compiler/nir/nir_intrinsics.py
index fcb8a9885c..54e199cc43 100644 index 41371db..dd3454f 100644
--- a/godot-mesa/src/compiler/nir/nir_intrinsics.py --- a/godot-mesa/src/compiler/nir/nir_intrinsics.py
+++ b/godot-mesa/src/compiler/nir/nir_intrinsics.py +++ b/godot-mesa/src/compiler/nir/nir_intrinsics.py
@@ -1046,6 +1046,9 @@ load("push_constant", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINAT @@ -1262,6 +1262,9 @@ load("push_constant", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINAT
# src[] = { offset }. # src[] = { offset }.
load("constant", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], load("constant", [1], [BASE, RANGE, ACCESS, ALIGN_MUL, ALIGN_OFFSET],
[CAN_ELIMINATE, CAN_REORDER]) [CAN_ELIMINATE, CAN_REORDER])
+# src[] = { offset }. +# src[] = { offset }.
+load("constant_non_opt", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], +load("constant_non_opt", [1], [BASE, RANGE, ACCESS, ALIGN_MUL, ALIGN_OFFSET],
+ [CAN_ELIMINATE, CAN_REORDER]) + [CAN_ELIMINATE, CAN_REORDER])
# src[] = { address }. # src[] = { address }.
load("global", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE]) load("global", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
# src[] = { address }. # src[] = { base_address, offset, bound }.
diff --git a/godot-mesa/src/compiler/nir/nir_loop_analyze.c b/godot-mesa/src/compiler/nir/nir_loop_analyze.c
index aa7369c..34b8a99 100644
--- a/godot-mesa/src/compiler/nir/nir_loop_analyze.c
+++ b/godot-mesa/src/compiler/nir/nir_loop_analyze.c
@@ -1020,7 +1020,7 @@ try_find_trip_count_vars_in_logical_op(nir_scalar *cond,
if (!nir_scalar_is_alu(logical_op) || !nir_scalar_is_const(zero)) {
/* Maybe we had it the wrong way, flip things around */
- SWAP(zero, logical_op);
+ MESA_SWAP(zero, logical_op);
/* If we still didn't find what we need then return */
if (!nir_scalar_is_const(zero))
diff --git a/godot-mesa/src/compiler/nir/nir_lower_cooperative_matrix.c b/godot-mesa/src/compiler/nir/nir_lower_cooperative_matrix.c
index 830746b..74c8df6 100644
--- a/godot-mesa/src/compiler/nir/nir_lower_cooperative_matrix.c
+++ b/godot-mesa/src/compiler/nir/nir_lower_cooperative_matrix.c
@@ -530,7 +530,7 @@ split_cmat_load_store(nir_builder *b,
col_offset = (i / split->num_col_splits) * desc.rows;
if (layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR)
- SWAP(row_offset, col_offset);
+ MESA_SWAP(row_offset, col_offset);
ptr_deref = nir_build_deref_cast(b, &addr_deref->def, addr_deref->modes, scalar_type, elem_size);
stride = nir_udiv_imm(b, nir_imul_imm(b, stride, deref_bytes_size), elem_size);
diff --git a/godot-mesa/src/compiler/nir/nir_lower_input_attachments.c b/godot-mesa/src/compiler/nir/nir_lower_input_attachments.c
index 323b188..09460ff 100644
--- a/godot-mesa/src/compiler/nir/nir_lower_input_attachments.c
+++ b/godot-mesa/src/compiler/nir/nir_lower_input_attachments.c
@@ -106,12 +106,53 @@ load_coord(nir_builder *b, nir_deref_instr *deref,
}
}
+static const struct glsl_type *
+get_texture_type_for_image(const struct glsl_type *type)
+{
+ if (glsl_type_is_array(type)) {
+ const struct glsl_type *elem_type =
+ get_texture_type_for_image(glsl_get_array_element(type));
+ return glsl_array_type(elem_type, glsl_get_length(type), 0 /*explicit size*/);
+ }
+
+ assert((glsl_type_is_image(type)));
+ return glsl_texture_type(glsl_get_sampler_dim(type),
+ glsl_sampler_type_is_array(type),
+ glsl_get_sampler_result_type(type));
+}
+
+static bool
+replace_image_type_with_texture(nir_deref_instr *deref)
+{
+ const struct glsl_type *type = deref->type;
+
+ /* If we've already chased up the deref chain this far from a different intrinsic, we're done */
+ if (!glsl_type_is_image(glsl_without_array(type)))
+ return false;
+
+ deref->type = get_texture_type_for_image(type);
+ deref->modes = nir_var_uniform;
+ if (deref->deref_type == nir_deref_type_var) {
+ type = deref->var->type;
+ if (glsl_type_is_image(glsl_without_array(type))) {
+ deref->var->type = get_texture_type_for_image(type);
+ deref->var->data.mode = nir_var_uniform;
+ memset(&deref->var->data.sampler, 0, sizeof(deref->var->data.sampler));
+ }
+ } else {
+ nir_deref_instr *parent = nir_deref_instr_parent(deref);
+ if (parent)
+ replace_image_type_with_texture(parent);
+ }
+
+ return true;
+}
+
static bool
try_lower_input_load(nir_builder *b, nir_intrinsic_instr *load,
const nir_input_attachment_options *options)
{
nir_deref_instr *deref = nir_src_as_deref(load->src[0]);
- assert(glsl_type_is_image(deref->type));
enum glsl_sampler_dim image_dim = glsl_get_sampler_dim(deref->type);
if (image_dim != GLSL_SAMPLER_DIM_SUBPASS &&
@@ -172,6 +213,8 @@ try_lower_input_load(nir_builder *b, nir_intrinsic_instr *load,
&tex->def);
}
+ replace_image_type_with_texture(deref);
+
return true;
}
@@ -204,6 +247,8 @@ try_lower_input_texop(nir_builder *b, nir_tex_instr *tex,
nir_src_rewrite(&tex->src[coord_src_idx].src, coord);
+ replace_image_type_with_texture(deref);
+
return true;
}
diff --git a/godot-mesa/src/compiler/nir/nir_opt_reassociate.c b/godot-mesa/src/compiler/nir/nir_opt_reassociate.c
index 09566a5..15c5ad1 100644
--- a/godot-mesa/src/compiler/nir/nir_opt_reassociate.c
+++ b/godot-mesa/src/compiler/nir/nir_opt_reassociate.c
@@ -118,7 +118,7 @@ get_pair_key(nir_op op, nir_scalar a, nir_scalar b)
if ((a.def->index > b.def->index) ||
((a.def->index == b.def->index) && (a.comp > b.comp))) {
- SWAP(a, b);
+ MESA_SWAP(a, b);
}
return (struct pair_key){
@@ -460,8 +460,8 @@ reassociate_chain(struct chain *c, void *pair_freq)
if (best_pair.i != best_pair.j) {
/* Pin the best pair at the front. The rest is sorted by rank. */
- SWAP(c->srcs[0], c->srcs[best_pair.i]);
- SWAP(c->srcs[1], c->srcs[best_pair.j]);
+ MESA_SWAP(c->srcs[0], c->srcs[best_pair.i]);
+ MESA_SWAP(c->srcs[1], c->srcs[best_pair.j]);
pinned = 2;
}
}
diff --git a/godot-mesa/src/compiler/spirv/spirv_to_nir.c b/godot-mesa/src/compiler/spirv/spirv_to_nir.c diff --git a/godot-mesa/src/compiler/spirv/spirv_to_nir.c b/godot-mesa/src/compiler/spirv/spirv_to_nir.c
index 5cb7691506..7620fef9f5 100644 index 7150419..61b0b7c 100644
--- a/godot-mesa/src/compiler/spirv/spirv_to_nir.c --- a/godot-mesa/src/compiler/spirv/spirv_to_nir.c
+++ b/godot-mesa/src/compiler/spirv/spirv_to_nir.c +++ b/godot-mesa/src/compiler/spirv/spirv_to_nir.c
@@ -39,6 +39,8 @@ @@ -45,6 +45,8 @@
#include <stdio.h> #include <stdio.h>
+#include "drivers/d3d12/d3d12_godot_nir_bridge.h" +#include "drivers/d3d12/d3d12_godot_nir_bridge.h"
+ +
#ifndef NDEBUG #ifndef PATH_MAX
uint32_t mesa_spirv_debug = 0; #define PATH_MAX 4096
#endif
@@ -1121,6 +1123,7 @@ struct_member_decoration_cb(struct vtn_builder *b, @@ -2481,7 +2483,7 @@ vtn_null_constant(struct vtn_builder *b, struct vtn_type *type)
case SpvDecorationPerPrimitiveNV:
case SpvDecorationPerTaskNV:
case SpvDecorationPerViewNV:
+ case SpvDecorationInvariant: /* Silence this one to avoid warning spam. */
break;
case SpvDecorationSpecId:
@@ -1129,7 +1132,6 @@ struct_member_decoration_cb(struct vtn_builder *b,
case SpvDecorationArrayStride:
case SpvDecorationGLSLShared:
case SpvDecorationGLSLPacked:
- case SpvDecorationInvariant:
case SpvDecorationAliased:
case SpvDecorationConstant:
case SpvDecorationIndex:
@@ -1938,7 +1940,7 @@ vtn_null_constant(struct vtn_builder *b, struct vtn_type *type)
} }
static void static void
@@ -50,7 +174,7 @@ index 5cb7691506..7620fef9f5 100644
ASSERTED int member, ASSERTED int member,
const struct vtn_decoration *dec, void *data) const struct vtn_decoration *dec, void *data)
{ {
@@ -1946,13 +1948,8 @@ spec_constant_decoration_cb(struct vtn_builder *b, UNUSED struct vtn_value *val, @@ -2489,13 +2491,8 @@ spec_constant_decoration_cb(struct vtn_builder *b, UNUSED struct vtn_value *val,
if (dec->decoration != SpvDecorationSpecId) if (dec->decoration != SpvDecorationSpecId)
return; return;
@@ -66,7 +190,7 @@ index 5cb7691506..7620fef9f5 100644
} }
static void static void
@@ -1976,6 +1973,12 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, @@ -2519,6 +2516,12 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count) const uint32_t *w, unsigned count)
{ {
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_constant); struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_constant);
@@ -79,7 +203,7 @@ index 5cb7691506..7620fef9f5 100644
val->constant = rzalloc(b, nir_constant); val->constant = rzalloc(b, nir_constant);
switch (opcode) { switch (opcode) {
case SpvOpConstantTrue: case SpvOpConstantTrue:
@@ -1993,7 +1996,7 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, @@ -2536,7 +2539,7 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
if (opcode == SpvOpSpecConstantTrue || if (opcode == SpvOpSpecConstantTrue ||
opcode == SpvOpSpecConstantFalse) opcode == SpvOpSpecConstantFalse)
@@ -88,7 +212,7 @@ index 5cb7691506..7620fef9f5 100644
val->constant->values[0].b = u32val.u32 != 0; val->constant->values[0].b = u32val.u32 != 0;
break; break;
@@ -2024,11 +2027,10 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, @@ -2567,14 +2570,12 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
if (opcode == SpvOpSpecConstant) if (opcode == SpvOpSpecConstant)
vtn_foreach_decoration(b, val, spec_constant_decoration_cb, vtn_foreach_decoration(b, val, spec_constant_decoration_cb,
@@ -98,10 +222,14 @@ index 5cb7691506..7620fef9f5 100644
} }
- case SpvOpSpecConstantComposite: - case SpvOpSpecConstantComposite:
case SpvOpConstantComposite: { case SpvOpConstantComposite:
unsigned elem_count = count - 3; - case SpvOpConstantCompositeReplicateEXT:
vtn_fail_if(elem_count != val->type->length, - case SpvOpSpecConstantCompositeReplicateEXT: {
@@ -2076,218 +2078,6 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, + case SpvOpConstantCompositeReplicateEXT: {
const unsigned elem_count =
val->type->base_type == vtn_base_type_cooperative_matrix ?
1 : val->type->length;
@@ -2648,315 +2649,6 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
break; break;
} }
@@ -110,6 +238,54 @@ index 5cb7691506..7620fef9f5 100644
- vtn_foreach_decoration(b, val, spec_constant_decoration_cb, &u32op); - vtn_foreach_decoration(b, val, spec_constant_decoration_cb, &u32op);
- SpvOp opcode = u32op.u32; - SpvOp opcode = u32op.u32;
- switch (opcode) { - switch (opcode) {
- case SpvOpBitcast: {
- struct vtn_value *src = &b->values[w[4]];
-
- vtn_assert(src->value_type == vtn_value_type_constant ||
- src->value_type == vtn_value_type_undef);
-
- unsigned src_len = glsl_get_vector_elements(src->type->type);
- unsigned dst_len = glsl_get_vector_elements(val->type->type);
-
- unsigned src_bit_size = glsl_get_bit_size(src->type->type);
- unsigned dst_bit_size = glsl_get_bit_size(val->type->type);
-
- vtn_assert(src_len * src_bit_size == dst_len * dst_bit_size);
-
- /* This will end up being zero */
- if (src->value_type == vtn_value_type_undef)
- break;
-
- if (src_bit_size == dst_bit_size) {
- /* This is just a copy */
- for (unsigned i = 0; i < src_len; i++)
- val->constant->values[i] = src->constant->values[i];
- } else {
- /* You can't non-trivially bitcast booleans */
- vtn_assert(src_bit_size >= 8 && dst_bit_size >= 8);
- const unsigned src_byte_size = src_bit_size / 8;
- const unsigned dst_byte_size = dst_bit_size / 8;
-
- vtn_assert(src_len <= NIR_MAX_VEC_COMPONENTS &&
- dst_len <= NIR_MAX_VEC_COMPONENTS);
-
- uint8_t bits[NIR_MAX_VEC_COMPONENTS * sizeof(nir_const_value)];
-
- for (unsigned i = 0; i < src_len; i++) {
- uint64_t v = nir_const_value_as_int(src->constant->values[i],
- src_bit_size);
- memcpy(bits + i * src_byte_size, &v, src_byte_size);
- }
-
- for (unsigned i = 0; i < dst_len; i++) {
- uint64_t v = 0;
- memcpy(&v, bits + i * dst_byte_size, dst_byte_size);
- val->constant->values[i] =
- nir_const_value_for_uint(v, dst_bit_size);
- }
- }
- break;
- }
- case SpvOpVectorShuffle: { - case SpvOpVectorShuffle: {
- struct vtn_value *v0 = &b->values[w[4]]; - struct vtn_value *v0 = &b->values[w[4]];
- struct vtn_value *v1 = &b->values[w[5]]; - struct vtn_value *v1 = &b->values[w[5]];
@@ -172,39 +348,45 @@ index 5cb7691506..7620fef9f5 100644
- } else { - } else {
- comp = vtn_value(b, w[5], vtn_value_type_constant); - comp = vtn_value(b, w[5], vtn_value_type_constant);
- deref_start = 6; - deref_start = 6;
- val->constant = nir_constant_clone(comp->constant, - val->constant = nir_constant_clone(comp->constant, b->shader);
- (nir_variable *)b);
- c = &val->constant; - c = &val->constant;
- } - }
- -
- int elem = -1; - int elem = -1;
- const struct vtn_type *type = comp->type; - const struct vtn_type *type = comp->type;
- for (unsigned i = deref_start; i < count; i++) { - for (unsigned i = deref_start; i < count; i++) {
- vtn_fail_if(w[i] > type->length, - if (type->base_type == vtn_base_type_cooperative_matrix) {
- "%uth index of %s is %u but the type has only " - /* Cooperative matrices are always scalar constants. We don't
- "%u elements", i - deref_start, - * care about the index w[i] because it's always replicated.
- spirv_op_to_string(opcode), w[i], type->length); - */
- type = type->component_type;
- } else {
- vtn_fail_if(w[i] > type->length,
- "%uth index of %s is %u but the type has only "
- "%u elements", i - deref_start,
- spirv_op_to_string(opcode), w[i], type->length);
- -
- switch (type->base_type) { - switch (type->base_type) {
- case vtn_base_type_vector: - case vtn_base_type_vector:
- elem = w[i]; - elem = w[i];
- type = type->array_element; - type = type->array_element;
- break; - break;
- -
- case vtn_base_type_matrix: - case vtn_base_type_matrix:
- case vtn_base_type_array: - case vtn_base_type_array:
- c = &(*c)->elements[w[i]]; - c = &(*c)->elements[w[i]];
- type = type->array_element; - type = type->array_element;
- break; - break;
- -
- case vtn_base_type_struct: - case vtn_base_type_struct:
- c = &(*c)->elements[w[i]]; - c = &(*c)->elements[w[i]];
- type = type->members[w[i]]; - type = type->members[w[i]];
- break; - break;
- -
- default: - default:
- vtn_fail("%s must only index into composite types", - vtn_fail("%s must only index into composite types",
- spirv_op_to_string(opcode)); - spirv_op_to_string(opcode));
- }
- } - }
- } - }
- -
@@ -233,10 +415,12 @@ index 5cb7691506..7620fef9f5 100644
- -
- default: { - default: {
- bool swap; - bool swap;
- nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(val->type->type); -
- nir_alu_type src_alu_type = dst_alu_type; - const glsl_type *org_dst_type = val->type->type;
- const glsl_type *org_src_type = org_dst_type;
-
- const bool saturate = vtn_has_decoration(b, val, SpvDecorationSaturatedToLargestFloat8NormalConversionEXT);
- unsigned num_components = glsl_get_vector_elements(val->type->type); - unsigned num_components = glsl_get_vector_elements(val->type->type);
- unsigned bit_size;
- -
- vtn_assert(count <= 7); - vtn_assert(count <= 7);
- -
@@ -244,26 +428,31 @@ index 5cb7691506..7620fef9f5 100644
- case SpvOpSConvert: - case SpvOpSConvert:
- case SpvOpFConvert: - case SpvOpFConvert:
- case SpvOpUConvert: - case SpvOpUConvert:
- /* We have a source in a conversion */ - /* We have a different source type in a conversion. */
- src_alu_type = - org_src_type = vtn_get_value_type(b, w[4])->type;
- nir_get_nir_type_for_glsl_type(vtn_get_value_type(b, w[4])->type);
- /* We use the bitsize of the conversion source to evaluate the opcode later */
- bit_size = glsl_get_bit_size(vtn_get_value_type(b, w[4])->type);
- break; - break;
- default: - default:
- bit_size = glsl_get_bit_size(val->type->type); - break;
- }; - };
- -
- const glsl_type *dst_type = org_dst_type;
- if (glsl_type_is_bfloat_16(dst_type) || glsl_type_is_e4m3fn(dst_type) || glsl_type_is_e5m2(dst_type))
- dst_type = glsl_float_type();
-
- const glsl_type *src_type = org_src_type;
- if (glsl_type_is_bfloat_16(src_type) || glsl_type_is_e4m3fn(src_type) || glsl_type_is_e5m2(src_type))
- src_type = glsl_float_type();
-
- bool exact; - bool exact;
- nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap, &exact, - nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap, &exact,
- nir_alu_type_get_type_size(src_alu_type), - src_type, dst_type);
- nir_alu_type_get_type_size(dst_alu_type));
- -
- /* No SPIR-V opcodes handled through this path should set exact. - /* No SPIR-V opcodes handled through this path should set exact.
- * Since it is ignored, assert on it. - * Since it is ignored, assert on it.
- */ - */
- assert(!exact); - assert(!exact);
- -
- unsigned bit_size = glsl_get_bit_size(dst_type);
- nir_const_value src[3][NIR_MAX_VEC_COMPONENTS]; - nir_const_value src[3][NIR_MAX_VEC_COMPONENTS];
- -
- for (unsigned i = 0; i < count - 4; i++) { - for (unsigned i = 0; i < count - 4; i++) {
@@ -273,16 +462,30 @@ index 5cb7691506..7620fef9f5 100644
- /* If this is an unsized source, pull the bit size from the - /* If this is an unsized source, pull the bit size from the
- * source; otherwise, we'll use the bit size from the destination. - * source; otherwise, we'll use the bit size from the destination.
- */ - */
- if (!nir_alu_type_get_type_size(nir_op_infos[op].input_types[i])) - if (!nir_alu_type_get_type_size(nir_op_infos[op].input_types[i])) {
- bit_size = glsl_get_bit_size(src_val->type->type); - if (org_src_type != src_type) {
- /* Small float conversion. */
- assert(i == 0);
- bit_size = glsl_get_bit_size(src_type);
- } else {
- bit_size = glsl_get_bit_size(src_val->type->type);
- }
- }
- -
- unsigned src_comps = nir_op_infos[op].input_sizes[i] ? - unsigned src_comps = nir_op_infos[op].input_sizes[i] ?
- nir_op_infos[op].input_sizes[i] : - nir_op_infos[op].input_sizes[i] :
- num_components; - num_components;
- -
- unsigned j = swap ? 1 - i : i; - unsigned j = swap ? 1 - i : i;
- for (unsigned c = 0; c < src_comps; c++) - for (unsigned c = 0; c < src_comps; c++) {
- src[j][c] = src_val->constant->values[c]; - src[j][c] = src_val->constant->values[c];
- if (glsl_type_is_bfloat_16(org_src_type))
- src[j][c].f32 = _mesa_bfloat16_bits_to_float(src[j][c].u16);
- else if (glsl_type_is_e4m3fn(org_src_type))
- src[j][c].f32 = _mesa_e4m3fn_to_float(src[j][c].u8);
- else if (glsl_type_is_e5m2(org_src_type))
- src[j][c].f32 = _mesa_e5m2_to_float(src[j][c].u8);
- }
- } - }
- -
- /* fix up fixed size sources */ - /* fix up fixed size sources */
@@ -311,6 +514,28 @@ index 5cb7691506..7620fef9f5 100644
- nir_eval_const_opcode(op, val->constant->values, - nir_eval_const_opcode(op, val->constant->values,
- num_components, bit_size, srcs, - num_components, bit_size, srcs,
- b->shader->info.float_controls_execution_mode); - b->shader->info.float_controls_execution_mode);
-
- for (int i = 0; i < num_components; i++) {
- uint16_t conv;
- if (glsl_type_is_bfloat_16(org_dst_type)) {
- conv = _mesa_float_to_bfloat16_bits_rte(val->constant->values[i].f32);
- } else if (glsl_type_is_e4m3fn(org_dst_type)) {
- if (saturate)
- conv = _mesa_float_to_e4m3fn_sat(val->constant->values[i].f32);
- else
- conv = _mesa_float_to_e4m3fn(val->constant->values[i].f32);
- } else if (glsl_type_is_e5m2(org_dst_type)) {
- if (saturate)
- conv = _mesa_float_to_e5m2_sat(val->constant->values[i].f32);
- else
- conv = _mesa_float_to_e5m2(val->constant->values[i].f32);
- } else {
- continue;
- }
-
- val->constant->values[i] = nir_const_value_for_raw_uint(conv, glsl_get_bit_size(org_dst_type));
- }
-
- break; - break;
- } /* default */ - } /* default */
- } - }
@@ -320,7 +545,7 @@ index 5cb7691506..7620fef9f5 100644
case SpvOpConstantNull: case SpvOpConstantNull:
val->constant = vtn_null_constant(b, val->type); val->constant = vtn_null_constant(b, val->type);
val->is_null_constant = true; val->is_null_constant = true;
@@ -6370,6 +6160,96 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode, @@ -7018,6 +6710,93 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
return true; return true;
} }
@@ -351,46 +576,43 @@ index 5cb7691506..7620fef9f5 100644
+ val->value_type = vtn_value_type_ssa; + val->value_type = vtn_value_type_ssa;
+ val->ssa = vtn_create_ssa_value(b, val->type->type); + val->ssa = vtn_create_ssa_value(b, val->type->type);
+ +
+ nir_ssa_def *sc_imm = nir_imm_int(&b->nb, GODOT_NIR_SC_SENTINEL_MAGIC | val->sc_id); + nir_def *sc_imm = nir_imm_int(&b->nb, GODOT_NIR_SC_SENTINEL_MAGIC | val->sc_id);
+ nir_ssa_def *non_opt_const = nir_build_load_constant_non_opt(&b->nb, 1, 32, sc_imm); + nir_def *non_opt_const = nir_load_constant_non_opt(&b->nb, 1, 32, sc_imm);
+ +
+ vtn_assert(b->nb.cursor.option == nir_cursor_after_instr); + vtn_assert(b->nb.cursor.option == nir_cursor_after_instr);
+ vtn_assert(b->nb.cursor.instr->type == nir_instr_type_intrinsic); + vtn_assert(b->nb.cursor.instr->type == nir_instr_type_intrinsic);
+ +
+ nir_ssa_def *temp = nir_build_alu(
+ &b->nb,
+ nir_op_iand,
+ non_opt_const,
+ nir_imm_int(&b->nb, 0xbfffffff),
+ NULL,
+ NULL);
+ val->ssa = vtn_create_ssa_value(b, val->type->type); + val->ssa = vtn_create_ssa_value(b, val->type->type);
+ if (val->type->type == glsl_uint_type()) { + if (val->type->type == glsl_uint_type()) {
+ val->ssa->def = temp; + val->ssa->def = non_opt_const;
+ } else if (val->type->type == glsl_bool_type()) { + } else if (val->type->type == glsl_bool_type()) {
+ val->ssa->def = nir_build_alu( + val->ssa->def = nir_build_alu(
+ &b->nb, + &b->nb,
+ nir_op_ine, + nir_op_ine,
+ temp, + non_opt_const,
+ nir_imm_int(&b->nb, 0), + nir_imm_int(&b->nb, 0),
+ NULL, + NULL,
+ NULL); + NULL);
+ } else if (val->type->type == glsl_float_type()) { + } else if (val->type->type == glsl_float_type()) {
+ val->ssa->def = nir_build_alu( + val->ssa->def = non_opt_const;
+ &b->nb,
+ nir_op_ishl,
+ temp,
+ nir_imm_int(&b->nb, 1),
+ NULL,
+ NULL);
+ } else { + } else {
+ vtn_assert(false); + vtn_assert(false);
+ } + }
+ } break; + } break;
+ +
+ case SpvOpSpecConstantComposite: + case SpvOpSpecConstantComposite: {
+ abort(); // Unimplemented + unsigned elem_count = count - 3;
+ vtn_fail_if(elem_count != val->type->length,
+ "%s has %u constituents, expected %u",
+ spirv_op_to_string(opcode), elem_count, val->type->length);
+
+ vtn_assert(b->values[w[2]].value_type == vtn_value_type_ssa);
+ if (!b->values[w[2]].ssa) {
+ b->values[w[2]].value_type = vtn_value_type_invalid; /* Pretend not yet set */
+ vtn_handle_composite(b, SpvOpCompositeConstruct, w, count);
+ }
+ break; + break;
+ }
+ +
+ case SpvOpSpecConstantOp: { + case SpvOpSpecConstantOp: {
+ vtn_assert(val->value_type == vtn_value_type_ssa); + vtn_assert(val->value_type == vtn_value_type_ssa);
@@ -417,7 +639,7 @@ index 5cb7691506..7620fef9f5 100644
static bool static bool
is_glslang(const struct vtn_builder *b) is_glslang(const struct vtn_builder *b)
{ {
@@ -6609,6 +6489,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count, @@ -7376,6 +7155,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
/* Skip the SPIR-V header, handled at vtn_create_builder */ /* Skip the SPIR-V header, handled at vtn_create_builder */
words+= 5; words+= 5;
@@ -426,20 +648,20 @@ index 5cb7691506..7620fef9f5 100644
/* Handle all the preamble instructions */ /* Handle all the preamble instructions */
words = vtn_foreach_instruction(b, words, word_end, words = vtn_foreach_instruction(b, words, word_end,
vtn_handle_preamble_instruction); vtn_handle_preamble_instruction);
@@ -6690,7 +6572,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count, @@ -7461,7 +7242,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
vtn_foreach_function(func, &b->functions) {
if ((options->create_library || func->referenced) && !func->emitted) { if ((options->create_library || func->referenced) && !func->emitted) {
b->const_table = _mesa_pointer_hash_table_create(b); _mesa_hash_table_clear(b->strings, NULL);
- vtn_function_emit(b, func, vtn_handle_body_instruction); - vtn_function_emit(b, func, vtn_handle_body_instruction);
+ vtn_function_emit(b, func, vtn_handle_spec_constant_instructions, preamble_words, vtn_handle_body_instruction); + vtn_function_emit(b, func, vtn_handle_spec_constant_instructions, preamble_words, vtn_handle_body_instruction);
progress = true; progress = true;
} }
} }
diff --git a/godot-mesa/src/compiler/spirv/vtn_cfg.c b/godot-mesa/src/compiler/spirv/vtn_cfg.c diff --git a/godot-mesa/src/compiler/spirv/vtn_cfg.c b/godot-mesa/src/compiler/spirv/vtn_cfg.c
index b02c11b8d7..7d0c647f79 100644 index 83d3228..78aee17 100644
--- a/godot-mesa/src/compiler/spirv/vtn_cfg.c --- a/godot-mesa/src/compiler/spirv/vtn_cfg.c
+++ b/godot-mesa/src/compiler/spirv/vtn_cfg.c +++ b/godot-mesa/src/compiler/spirv/vtn_cfg.c
@@ -1425,6 +1425,8 @@ vtn_emit_cf_func_unstructured(struct vtn_builder *b, struct vtn_function *func, @@ -763,6 +763,8 @@ vtn_emit_cf_func_unstructured(struct vtn_builder *b, struct vtn_function *func,
void void
vtn_function_emit(struct vtn_builder *b, struct vtn_function *func, vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
@@ -448,7 +670,7 @@ index b02c11b8d7..7d0c647f79 100644
vtn_instruction_handler instruction_handler) vtn_instruction_handler instruction_handler)
{ {
static int force_unstructured = -1; static int force_unstructured = -1;
@@ -1440,6 +1442,9 @@ vtn_function_emit(struct vtn_builder *b, struct vtn_function *func, @@ -777,6 +779,9 @@ vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
b->nb.exact = b->exact; b->nb.exact = b->exact;
b->phi_table = _mesa_pointer_hash_table_create(b); b->phi_table = _mesa_pointer_hash_table_create(b);
@@ -459,10 +681,10 @@ index b02c11b8d7..7d0c647f79 100644
impl->structured = false; impl->structured = false;
vtn_emit_cf_func_unstructured(b, func, instruction_handler); vtn_emit_cf_func_unstructured(b, func, instruction_handler);
diff --git a/godot-mesa/src/compiler/spirv/vtn_private.h b/godot-mesa/src/compiler/spirv/vtn_private.h diff --git a/godot-mesa/src/compiler/spirv/vtn_private.h b/godot-mesa/src/compiler/spirv/vtn_private.h
index bd65a60d9b..389f477681 100644 index 5d601f9..4ab1a22 100644
--- a/godot-mesa/src/compiler/spirv/vtn_private.h --- a/godot-mesa/src/compiler/spirv/vtn_private.h
+++ b/godot-mesa/src/compiler/spirv/vtn_private.h +++ b/godot-mesa/src/compiler/spirv/vtn_private.h
@@ -307,6 +307,8 @@ typedef bool (*vtn_instruction_handler)(struct vtn_builder *, SpvOp, @@ -243,6 +243,8 @@ typedef bool (*vtn_instruction_handler)(struct vtn_builder *, SpvOp,
void vtn_build_cfg(struct vtn_builder *b, const uint32_t *words, void vtn_build_cfg(struct vtn_builder *b, const uint32_t *words,
const uint32_t *end); const uint32_t *end);
void vtn_function_emit(struct vtn_builder *b, struct vtn_function *func, void vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
@@ -471,7 +693,7 @@ index bd65a60d9b..389f477681 100644
vtn_instruction_handler instruction_handler); vtn_instruction_handler instruction_handler);
void vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode, void vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count); const uint32_t *w, unsigned count);
@@ -563,6 +565,8 @@ struct vtn_variable { @@ -521,6 +523,8 @@ struct vtn_variable {
unsigned descriptor_set; unsigned descriptor_set;
unsigned binding; unsigned binding;
bool explicit_binding; bool explicit_binding;
@@ -480,7 +702,7 @@ index bd65a60d9b..389f477681 100644
unsigned offset; unsigned offset;
unsigned input_attachment_index; unsigned input_attachment_index;
@@ -633,6 +637,9 @@ struct vtn_value { @@ -594,6 +598,9 @@ struct vtn_value {
struct vtn_ssa_value *ssa; struct vtn_ssa_value *ssa;
vtn_instruction_handler ext_handler; vtn_instruction_handler ext_handler;
}; };
@@ -491,7 +713,7 @@ index bd65a60d9b..389f477681 100644
#define VTN_DEC_DECORATION -1 #define VTN_DEC_DECORATION -1
diff --git a/godot-mesa/src/compiler/spirv/vtn_variables.c b/godot-mesa/src/compiler/spirv/vtn_variables.c diff --git a/godot-mesa/src/compiler/spirv/vtn_variables.c b/godot-mesa/src/compiler/spirv/vtn_variables.c
index 8db61c8e61..8545903165 100644 index 55557e7..16866df 100644
--- a/godot-mesa/src/compiler/spirv/vtn_variables.c --- a/godot-mesa/src/compiler/spirv/vtn_variables.c
+++ b/godot-mesa/src/compiler/spirv/vtn_variables.c +++ b/godot-mesa/src/compiler/spirv/vtn_variables.c
@@ -26,6 +26,8 @@ @@ -26,6 +26,8 @@
@@ -503,7 +725,7 @@ index 8db61c8e61..8545903165 100644
static struct vtn_pointer* static struct vtn_pointer*
vtn_align_pointer(struct vtn_builder *b, struct vtn_pointer *ptr, vtn_align_pointer(struct vtn_builder *b, struct vtn_pointer *ptr,
unsigned alignment) unsigned alignment)
@@ -1407,13 +1409,17 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, @@ -1620,13 +1622,17 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
/* Handle decorations that apply to a vtn_variable as a whole */ /* Handle decorations that apply to a vtn_variable as a whole */
switch (dec->decoration) { switch (dec->decoration) {
@@ -526,10 +748,10 @@ index 8db61c8e61..8545903165 100644
vtn_var->input_attachment_index = dec->operands[0]; vtn_var->input_attachment_index = dec->operands[0];
vtn_var->access |= ACCESS_NON_WRITEABLE; vtn_var->access |= ACCESS_NON_WRITEABLE;
diff --git a/godot-mesa/src/microsoft/compiler/dxil_container.c b/godot-mesa/src/microsoft/compiler/dxil_container.c diff --git a/godot-mesa/src/microsoft/compiler/dxil_container.c b/godot-mesa/src/microsoft/compiler/dxil_container.c
index 209973459d..487cda7a40 100644 index 77a14cd..24d8362 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_container.c --- a/godot-mesa/src/microsoft/compiler/dxil_container.c
+++ b/godot-mesa/src/microsoft/compiler/dxil_container.c +++ b/godot-mesa/src/microsoft/compiler/dxil_container.c
@@ -338,7 +338,8 @@ dxil_container_add_state_validation(struct dxil_container *c, @@ -331,7 +331,8 @@ dxil_container_add_state_validation(struct dxil_container *c,
bool bool
dxil_container_add_module(struct dxil_container *c, dxil_container_add_module(struct dxil_container *c,
@@ -539,7 +761,7 @@ index 209973459d..487cda7a40 100644
{ {
assert(m->buf.buf_bits == 0); // make sure the module is fully flushed assert(m->buf.buf_bits == 0); // make sure the module is fully flushed
uint32_t version = (m->shader_kind << 16) | uint32_t version = (m->shader_kind << 16) |
@@ -352,18 +353,22 @@ dxil_container_add_module(struct dxil_container *c, @@ -345,18 +346,22 @@ dxil_container_add_module(struct dxil_container *c,
uint32_t bitcode_offset = 16; uint32_t bitcode_offset = 16;
uint32_t bitcode_size = m->buf.blob.size; uint32_t bitcode_size = m->buf.blob.size;
@@ -566,7 +788,7 @@ index 209973459d..487cda7a40 100644
{ {
assert(blob->size == 0); assert(blob->size == 0);
if (!blob_write_bytes(blob, &DXIL_DXBC, sizeof(DXIL_DXBC))) if (!blob_write_bytes(blob, &DXIL_DXBC, sizeof(DXIL_DXBC)))
@@ -394,8 +399,12 @@ dxil_container_write(struct dxil_container *c, struct blob *blob) @@ -387,8 +392,12 @@ dxil_container_write(struct dxil_container *c, struct blob *blob)
} }
if (!blob_write_bytes(blob, &c->num_parts, sizeof(c->num_parts)) || if (!blob_write_bytes(blob, &c->num_parts, sizeof(c->num_parts)) ||
@@ -582,7 +804,7 @@ index 209973459d..487cda7a40 100644
return true; return true;
diff --git a/godot-mesa/src/microsoft/compiler/dxil_container.h b/godot-mesa/src/microsoft/compiler/dxil_container.h diff --git a/godot-mesa/src/microsoft/compiler/dxil_container.h b/godot-mesa/src/microsoft/compiler/dxil_container.h
index b3279ee108..08ab970cb8 100644 index 2c3f17c..3eb684f 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_container.h --- a/godot-mesa/src/microsoft/compiler/dxil_container.h
+++ b/godot-mesa/src/microsoft/compiler/dxil_container.h +++ b/godot-mesa/src/microsoft/compiler/dxil_container.h
@@ -123,10 +123,11 @@ dxil_container_add_state_validation(struct dxil_container *c, @@ -123,10 +123,11 @@ dxil_container_add_state_validation(struct dxil_container *c,
@@ -600,7 +822,7 @@ index b3279ee108..08ab970cb8 100644
#ifdef __cplusplus #ifdef __cplusplus
} }
diff --git a/godot-mesa/src/microsoft/compiler/dxil_module.c b/godot-mesa/src/microsoft/compiler/dxil_module.c diff --git a/godot-mesa/src/microsoft/compiler/dxil_module.c b/godot-mesa/src/microsoft/compiler/dxil_module.c
index 773e5640a6..57b6a62ffd 100644 index c70c67c..0634b52 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_module.c --- a/godot-mesa/src/microsoft/compiler/dxil_module.c
+++ b/godot-mesa/src/microsoft/compiler/dxil_module.c +++ b/godot-mesa/src/microsoft/compiler/dxil_module.c
@@ -32,6 +32,8 @@ @@ -32,6 +32,8 @@
@@ -612,7 +834,7 @@ index 773e5640a6..57b6a62ffd 100644
void void
dxil_module_init(struct dxil_module *m, void *ralloc_ctx) dxil_module_init(struct dxil_module *m, void *ralloc_ctx)
{ {
@@ -2630,6 +2632,12 @@ emit_consts(struct dxil_module *m) @@ -2669,6 +2671,12 @@ emit_consts(struct dxil_module *m)
continue; continue;
} }
@@ -626,7 +848,7 @@ index 773e5640a6..57b6a62ffd 100644
case TYPE_INTEGER: case TYPE_INTEGER:
if (!emit_int_value(m, c->int_value)) if (!emit_int_value(m, c->int_value))
diff --git a/godot-mesa/src/microsoft/compiler/dxil_module.h b/godot-mesa/src/microsoft/compiler/dxil_module.h diff --git a/godot-mesa/src/microsoft/compiler/dxil_module.h b/godot-mesa/src/microsoft/compiler/dxil_module.h
index ca170c5d2f..7fab628a22 100644 index 08ba263..d4c412d 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_module.h --- a/godot-mesa/src/microsoft/compiler/dxil_module.h
+++ b/godot-mesa/src/microsoft/compiler/dxil_module.h +++ b/godot-mesa/src/microsoft/compiler/dxil_module.h
@@ -29,6 +29,8 @@ @@ -29,6 +29,8 @@
@@ -638,7 +860,7 @@ index ca170c5d2f..7fab628a22 100644
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -247,6 +249,8 @@ struct dxil_module { @@ -268,6 +270,8 @@ struct dxil_module {
struct rb_tree *functions; struct rb_tree *functions;
struct dxil_func_def *cur_emitting_func; struct dxil_func_def *cur_emitting_func;
@@ -647,60 +869,11 @@ index ca170c5d2f..7fab628a22 100644
}; };
struct dxil_instr; struct dxil_instr;
diff --git a/godot-mesa/src/microsoft/compiler/dxil_validator.cpp b/godot-mesa/src/microsoft/compiler/dxil_validator.cpp
index 4b68957a7d..a926ec991b 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_validator.cpp
+++ b/godot-mesa/src/microsoft/compiler/dxil_validator.cpp
@@ -25,6 +25,7 @@ struct dxil_validator {
extern "C" {
extern IMAGE_DOS_HEADER __ImageBase;
+extern char godot_nir_arch_name[32];
}
static HMODULE
@@ -36,7 +37,10 @@ load_dxil_mod()
#elif defined (_GAMING_XBOX)
HMODULE mod = LoadLibraryA("dxcompiler_x.dll");
#else
- HMODULE mod = LoadLibraryA("DXIL.dll");
+ HMODULE mod = NULL;
+ if (!godot_nir_arch_name[0]) {
+ mod = LoadLibraryA("DXIL.dll");
+ }
#endif
if (mod)
return mod;
@@ -60,12 +64,23 @@ load_dxil_mod()
}
*(last_slash + 1) = '\0';
+
+ if (godot_nir_arch_name[0]) {
+ strcat_s(self_path, godot_nir_arch_name);
+ strcat_s(self_path, "\\");
+ }
+
if (strcat_s(self_path, "DXIL.dll") != 0) {
debug_printf("DXIL: Unable to get path to DXIL.dll next to self");
return NULL;
}
- return LoadLibraryA(self_path);
+ mod = LoadLibraryA(self_path);
+ if (mod)
+ return mod;
+
+ godot_nir_arch_name[0] = '\0';
+ return load_dxil_mod();
}
static IDxcValidator *
diff --git a/godot-mesa/src/microsoft/compiler/nir_to_dxil.c b/godot-mesa/src/microsoft/compiler/nir_to_dxil.c diff --git a/godot-mesa/src/microsoft/compiler/nir_to_dxil.c b/godot-mesa/src/microsoft/compiler/nir_to_dxil.c
index 245c5140f9..d6c9d06c30 100644 index f99cf69..fa5bec7 100644
--- a/godot-mesa/src/microsoft/compiler/nir_to_dxil.c --- a/godot-mesa/src/microsoft/compiler/nir_to_dxil.c
+++ b/godot-mesa/src/microsoft/compiler/nir_to_dxil.c +++ b/godot-mesa/src/microsoft/compiler/nir_to_dxil.c
@@ -43,6 +43,8 @@ @@ -44,6 +44,8 @@
#include <stdint.h> #include <stdint.h>
@@ -709,7 +882,7 @@ index 245c5140f9..d6c9d06c30 100644
int debug_dxil = 0; int debug_dxil = 0;
static const struct debug_named_value static const struct debug_named_value
@@ -1154,6 +1156,8 @@ add_resource(struct ntd_context *ctx, enum dxil_resource_type type, @@ -1226,6 +1228,8 @@ add_resource(struct ntd_context *ctx, enum dxil_resource_type type,
/* No flags supported yet */ /* No flags supported yet */
resource_v1->resource_flags = 0; resource_v1->resource_flags = 0;
} }
@@ -718,19 +891,20 @@ index 245c5140f9..d6c9d06c30 100644
} }
static const struct dxil_value * static const struct dxil_value *
@@ -5079,6 +5083,11 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr) @@ -4963,6 +4967,12 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
case nir_intrinsic_exclusive_scan: return emit_load_unary_external_function(ctx, intr, "dx.op.startInstanceLocation",
return emit_reduce(ctx, intr); DXIL_INTR_START_INSTANCE_LOCATION, nir_type_int);
+ case nir_intrinsic_load_constant_non_opt: + case nir_intrinsic_load_constant_non_opt: {
+ const struct dxil_value* value = get_src(ctx, &intr->src[0], 0, nir_type_uint); + const struct dxil_value* value = get_src(ctx, &intr->src[0], 0, nir_type_uint);
+ store_dest_value(ctx, &intr->dest, 0, value); + store_def(ctx, &intr->def, 0, value);
+ return true; + return true;
+ }
+ +
case nir_intrinsic_load_num_workgroups: case nir_intrinsic_load_num_workgroups:
case nir_intrinsic_load_workgroup_size: case nir_intrinsic_load_workgroup_size:
default: default:
@@ -6644,6 +6653,7 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts, @@ -6618,6 +6628,7 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
MIN2(opts->shader_model_max & 0xffff, validator_version & 0xffff); MIN2(opts->shader_model_max & 0xffff, validator_version & 0xffff);
ctx->mod.major_validator = validator_version >> 16; ctx->mod.major_validator = validator_version >> 16;
ctx->mod.minor_validator = validator_version & 0xffff; ctx->mod.minor_validator = validator_version & 0xffff;
@@ -738,7 +912,7 @@ index 245c5140f9..d6c9d06c30 100644
if (s->info.stage <= MESA_SHADER_FRAGMENT) { if (s->info.stage <= MESA_SHADER_FRAGMENT) {
uint64_t in_mask = uint64_t in_mask =
@@ -6762,19 +6772,23 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts, @@ -6773,19 +6784,23 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
goto out; goto out;
} }
@@ -765,7 +939,7 @@ index 245c5140f9..d6c9d06c30 100644
static int shader_id = 0; static int shader_id = 0;
char buffer[64]; char buffer[64];
diff --git a/godot-mesa/src/microsoft/compiler/nir_to_dxil.h b/godot-mesa/src/microsoft/compiler/nir_to_dxil.h diff --git a/godot-mesa/src/microsoft/compiler/nir_to_dxil.h b/godot-mesa/src/microsoft/compiler/nir_to_dxil.h
index bdfbe23953..b95ca1d79f 100644 index 9890115..abe9e9d 100644
--- a/godot-mesa/src/microsoft/compiler/nir_to_dxil.h --- a/godot-mesa/src/microsoft/compiler/nir_to_dxil.h
+++ b/godot-mesa/src/microsoft/compiler/nir_to_dxil.h +++ b/godot-mesa/src/microsoft/compiler/nir_to_dxil.h
@@ -29,6 +29,8 @@ @@ -29,6 +29,8 @@
@@ -785,8 +959,44 @@ index bdfbe23953..b95ca1d79f 100644
}; };
typedef void (*dxil_msg_callback)(void *priv, const char *msg); typedef void (*dxil_msg_callback)(void *priv, const char *msg);
diff --git a/godot-mesa/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c b/godot-mesa/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c
index 66a996e..4d8eff1 100644
--- a/godot-mesa/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c
+++ b/godot-mesa/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c
@@ -1058,30 +1058,7 @@ dxil_spirv_nir_passes(nir_shader *nir,
NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL);
NIR_PASS(_, nir, nir_opt_dce);
NIR_PASS(_, nir, dxil_nir_lower_double_math);
-
- {
- bool progress;
- do
- {
- progress = false;
- NIR_PASS(progress, nir, nir_copy_prop);
- NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
- NIR_PASS(progress, nir, nir_opt_deref);
- NIR_PASS(progress, nir, nir_opt_dce);
- NIR_PASS(progress, nir, nir_opt_undef);
- NIR_PASS(progress, nir, nir_opt_constant_folding);
- NIR_PASS(progress, nir, nir_opt_cse);
- if (nir_opt_loop(nir)) {
- progress = true;
- NIR_PASS(progress, nir, nir_copy_prop);
- NIR_PASS(progress, nir, nir_opt_dce);
- }
- NIR_PASS(progress, nir, nir_lower_vars_to_ssa);
- NIR_PASS(progress, nir, nir_opt_algebraic);
- NIR_PASS(progress, nir, nir_opt_dead_cf);
- NIR_PASS(progress, nir, nir_opt_remove_phis);
- } while (progress);
- }
+ NIR_PASS(_, nir, nir_lower_vars_to_ssa);
NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
NIR_PASS(_, nir, nir_split_struct_vars, nir_var_function_temp);
diff --git a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c diff --git a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c
index 76cf6b007e..819339adf5 100644 index 1a8e6e2..1b3b9d3 100644
--- a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c --- a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c
+++ b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c +++ b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.c
@@ -32,6 +32,8 @@ @@ -32,6 +32,8 @@
@@ -795,9 +1005,9 @@ index 76cf6b007e..819339adf5 100644
+#include "drivers/d3d12/d3d12_godot_nir_bridge.h" +#include "drivers/d3d12/d3d12_godot_nir_bridge.h"
+ +
static_assert(DXIL_SPIRV_SHADER_NONE == (int)MESA_SHADER_NONE, "must match"); static_assert((mesa_shader_stage)DXIL_SPIRV_SHADER_NONE == MESA_SHADER_NONE, "must match");
static_assert(DXIL_SPIRV_SHADER_VERTEX == (int)MESA_SHADER_VERTEX, "must match"); static_assert((mesa_shader_stage)DXIL_SPIRV_SHADER_VERTEX == MESA_SHADER_VERTEX, "must match");
static_assert(DXIL_SPIRV_SHADER_TESS_CTRL == (int)MESA_SHADER_TESS_CTRL, "must match"); static_assert((mesa_shader_stage)DXIL_SPIRV_SHADER_TESS_CTRL == MESA_SHADER_TESS_CTRL, "must match");
@@ -50,6 +52,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, @@ -50,6 +52,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
const struct dxil_spirv_debug_options *dgb_opts, const struct dxil_spirv_debug_options *dgb_opts,
const struct dxil_spirv_runtime_conf *conf, const struct dxil_spirv_runtime_conf *conf,
@@ -815,7 +1025,7 @@ index 76cf6b007e..819339adf5 100644
const struct spirv_to_nir_options *spirv_opts = dxil_spirv_nir_get_spirv_options(); const struct spirv_to_nir_options *spirv_opts = dxil_spirv_nir_get_spirv_options();
diff --git a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h diff --git a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h
index 40adf761ef..30efbd16dd 100644 index 00b1884..0d10644 100644
--- a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h --- a/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h
+++ b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/godot-mesa/src/microsoft/spirv_to_dxil/spirv_to_dxil.h
@@ -30,6 +30,8 @@ @@ -30,6 +30,8 @@
@@ -827,7 +1037,7 @@ index 40adf761ef..30efbd16dd 100644
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -215,6 +217,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, @@ -234,6 +236,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
const struct dxil_spirv_debug_options *debug_options, const struct dxil_spirv_debug_options *debug_options,
const struct dxil_spirv_runtime_conf *conf, const struct dxil_spirv_runtime_conf *conf,
const struct dxil_spirv_logger *logger, const struct dxil_spirv_logger *logger,
@@ -835,3 +1045,81 @@ index 40adf761ef..30efbd16dd 100644
struct dxil_spirv_object *out_dxil); struct dxil_spirv_object *out_dxil);
/** /**
diff --git a/godot-mesa/src/util/macros.h b/godot-mesa/src/util/macros.h
index 0070067..72410ef 100644
--- a/godot-mesa/src/util/macros.h
+++ b/godot-mesa/src/util/macros.h
@@ -543,14 +543,14 @@ typedef int lock_cap_t;
* SWAP - swap value of @a and @b
*/
#if !defined(_MSC_VER) || _MSC_VER >= 1939 /* MSVC 17.9 or later for __typeof__ */
-#define SWAP(a, b) \
+#define MESA_SWAP(a, b) \
do { \
__typeof__(a) __tmp = (a); \
(a) = (b); \
(b) = __tmp; \
} while (0)
#else
-#define SWAP(a, b) \
+#define MESA_SWAP(a, b) \
do { \
/* NOLINTBEGIN(bugprone-sizeof-expression) */ \
char __tmp[sizeof(a) == sizeof(b) ? (ptrdiff_t)sizeof(a) : -1]; \
diff --git a/godot-mesa/src/util/ralloc.c b/godot-mesa/src/util/ralloc.c
index ba560c8..07379ae 100644
--- a/godot-mesa/src/util/ralloc.c
+++ b/godot-mesa/src/util/ralloc.c
@@ -35,6 +35,8 @@
#include "ralloc.h"
+#include "drivers/d3d12/d3d12_godot_nir_bridge.h"
+
#define CANARY 0x5A1106
#if defined(__LP64__) || defined(_WIN64)
@@ -115,8 +117,8 @@ ralloc_size(const void *ctx, size_t size)
* - Allocations of a size that rounds up to a multiple of 8 bytes and
* not 16 bytes, are only required to have at least 8 byte alignment.
*/
- void *block = malloc(align64(size + sizeof(ralloc_header),
- alignof(ralloc_header)));
+ void *block = godot_nir_malloc(align64(size + sizeof(ralloc_header),
+ alignof(ralloc_header)));
ralloc_header *info;
ralloc_header *parent;
@@ -164,8 +166,8 @@ resize(void *ptr, size_t size)
ralloc_header *child, *old, *info;
old = get_header(ptr);
- info = realloc(old, align64(size + sizeof(ralloc_header),
- alignof(ralloc_header)));
+ info = godot_nir_realloc(old, align64(size + sizeof(ralloc_header),
+ alignof(ralloc_header)));
if (info == NULL)
return NULL;
@@ -323,7 +325,7 @@ unsafe_free(ralloc_header *info)
if (info->destructor != NULL)
info->destructor(PTR_FROM_HEADER(info));
- free(info);
+ godot_nir_free(info);
}
void
diff --git a/godot-mesa/src/util/set.c b/godot-mesa/src/util/set.c
index d6c0623..1eac1e8 100644
--- a/godot-mesa/src/util/set.c
+++ b/godot-mesa/src/util/set.c
@@ -691,7 +691,7 @@ _mesa_set_intersects(struct set *a, struct set *b)
/* iterate over the set with less entries */
if (b->entries < a->entries) {
- SWAP(a, b);
+ MESA_SWAP(a, b);
}
set_foreach(a, entry) {

View File

@@ -1,4 +1,3 @@
import os
import sys import sys
import macos_osxcross import macos_osxcross

View File

@@ -1,7 +1,5 @@
import os
import sys
from SCons.Script import ARGUMENTS from SCons.Script import ARGUMENTS
from SCons.Variables import * from SCons.Variables import BoolVariable, EnumVariable
from SCons.Variables.BoolVariable import _text2bool from SCons.Variables.BoolVariable import _text2bool

View File

@@ -1,17 +1,21 @@
import os
import sys import sys
import my_spawn import my_spawn
from SCons.Tool import msvc, mingw from SCons.Tool import msvc, mingw
from SCons.Variables import * from SCons.Variables import BoolVariable
def options(opts): def options(opts):
mingw = os.getenv("MINGW_PREFIX", "")
opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False)) opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False))
opts.Add(BoolVariable("use_clang_cl", "Use the clang driver instead of MSVC - only effective on Windows", False)) opts.Add(BoolVariable("use_clang_cl", "Use the clang driver instead of MSVC - only effective on Windows", False))
opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True)) opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True))
opts.Add(BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False)) opts.Add(BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False))
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler", False)) opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler", False))
opts.Add("mingw_prefix", "MinGW prefix", mingw)
def exists(env): def exists(env):
@@ -23,12 +27,22 @@ def generate(env):
if not env["use_mingw"] and msvc.exists(env): if not env["use_mingw"] and msvc.exists(env):
if env["arch"] == "x86_64": if env["arch"] == "x86_64":
env["TARGET_ARCH"] = "amd64" env["TARGET_ARCH"] = "amd64"
elif env["arch"] == "arm64":
env["TARGET_ARCH"] = "arm64"
elif env["arch"] == "arm32":
env["TARGET_ARCH"] = "arm"
elif env["arch"] == "x86_32": elif env["arch"] == "x86_32":
env["TARGET_ARCH"] = "x86" env["TARGET_ARCH"] = "x86"
env["MSVC_SETUP_RUN"] = False # Need to set this to re-run the tool
env["MSVS_VERSION"] = None
env["MSVC_VERSION"] = None
env["is_msvc"] = True env["is_msvc"] = True
# MSVC, linker, and archiver. # MSVC, linker, and archiver.
msvc.generate(env) msvc.generate(env)
env.Tool("msvc")
env.Tool("mslib") env.Tool("mslib")
env.Tool("mslink") env.Tool("mslink")
@@ -48,7 +62,7 @@ def generate(env):
env["CC"] = "clang-cl" env["CC"] = "clang-cl"
env["CXX"] = "clang-cl" env["CXX"] = "clang-cl"
elif sys.platform == "win32" or sys.platform == "msys": elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]:
env["use_mingw"] = True env["use_mingw"] = True
mingw.generate(env) mingw.generate(env)
env.Append(CPPDEFINES=["MINGW_ENABLED"]) env.Append(CPPDEFINES=["MINGW_ENABLED"])
@@ -63,17 +77,29 @@ def generate(env):
else: else:
env["use_mingw"] = True env["use_mingw"] = True
# Cross-compilation using MinGW # Cross-compilation using MinGW
prefix = "i686" if env["arch"] == "x86_32" else env["arch"] prefix = ""
if env["mingw_prefix"]:
prefix = env["mingw_prefix"] + "/bin/"
if env["arch"] == "x86_64":
prefix += "x86_64"
elif env["arch"] == "arm64":
prefix += "aarch64"
elif env["arch"] == "arm32":
prefix += "armv7"
elif env["arch"] == "x86_32":
prefix += "i686"
if env["use_llvm"]: if env["use_llvm"]:
env["CXX"] = prefix + "-w64-mingw32-clang" env["CXX"] = prefix + "-w64-mingw32-clang++"
env["CC"] = prefix + "-w64-mingw32-clang++" env["CC"] = prefix + "-w64-mingw32-clang"
env["AR"] = prefix + "-w64-mingw32-ar" env["AR"] = prefix + "-w64-mingw32-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib" env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-clang" env["LINK"] = prefix + "-w64-mingw32-clang"
else: else:
env["CXX"] = prefix + "-w64-mingw32-g++" env["CXX"] = prefix + "-w64-mingw32-g++"
env["CC"] = prefix + "-w64-mingw32-gcc" env["CC"] = prefix + "-w64-mingw32-gcc"
env["AR"] = prefix + "-w64-mingw32-ar" env["AR"] = prefix + "-w64-mingw32-gcc-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib" env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-g++" env["LINK"] = prefix + "-w64-mingw32-g++"
@@ -92,3 +118,6 @@ def generate(env):
"-Wl,--no-undefined", "-Wl,--no-undefined",
] ]
) )
if (sys.platform == "win32" or sys.platform == "msys"):
my_spawn.configure(env)

2
mesa

Submodule mesa updated: 9085c9d43e...5005a50879

44
update_mesa.sh Normal file → Executable file
View File

@@ -36,7 +36,7 @@ run_custom_steps_at_source() {
} }
run_step bin 'git_sha1_gen.py --output $OUTDIR/git_sha1.h' run_step bin 'git_sha1_gen.py --output $OUTDIR/git_sha1.h'
run_step src/compiler/spirv 'spirv_info_c.py spirv.core.grammar.json $OUTDIR/spirv_info.c' run_step src/compiler/spirv 'spirv_info_gen.py --json spirv.core.grammar.json --out-h $OUTDIR/spirv_info.h --out-c $OUTDIR/spirv_info.c'
run_step src/compiler/spirv 'vtn_gather_types_c.py spirv.core.grammar.json $OUTDIR/vtn_gather_types.c' run_step src/compiler/spirv 'vtn_gather_types_c.py spirv.core.grammar.json $OUTDIR/vtn_gather_types.c'
} }
@@ -49,6 +49,9 @@ copy_file() {
} }
copy_custom_steps_sources() { copy_custom_steps_sources() {
copy_file src/compiler builtin_types.py
copy_file src/compiler builtin_types_h.py
copy_file src/compiler builtin_types_c.py
copy_file src/compiler/glsl ir_expression_operation.py copy_file src/compiler/glsl ir_expression_operation.py
copy_file src/compiler/nir nir_builder_opcodes_h.py copy_file src/compiler/nir nir_builder_opcodes_h.py
copy_file src/compiler/nir nir_constant_expressions.py copy_file src/compiler/nir nir_constant_expressions.py
@@ -65,7 +68,7 @@ copy_custom_steps_sources() {
copy_file src/compiler/spirv vtn_generator_ids_h.py copy_file src/compiler/spirv vtn_generator_ids_h.py
copy_file src/microsoft/compiler dxil_nir_algebraic.py copy_file src/microsoft/compiler dxil_nir_algebraic.py
copy_file src/util format_srgb.py copy_file src/util format_srgb.py
copy_file src/util/format u_format.csv copy_file src/util/format u_format.yaml
copy_file src/util/format u_format_pack.py copy_file src/util/format u_format_pack.py
copy_file src/util/format u_format_parse.py copy_file src/util/format u_format_parse.py
copy_file src/util/format u_format_table.py copy_file src/util/format u_format_table.py
@@ -89,7 +92,6 @@ copy_sources() {
} }
# These are the first we know for sure we want to copy. # These are the first we know for sure we want to copy.
copy_file . VERSION
copy_file . .editorconfig copy_file . .editorconfig
copy_subir_sources src/microsoft/compiler copy_subir_sources src/microsoft/compiler
copy_subir_sources src/microsoft/spirv_to_dxil copy_subir_sources src/microsoft/spirv_to_dxil
@@ -106,6 +108,7 @@ copy_sources() {
copy_subir_headers include/KHR copy_subir_headers include/KHR
copy_subir_headers src/c11 copy_subir_headers src/c11
copy_file src/c11/impl threads_win32.* copy_file src/c11/impl threads_win32.*
copy_file src/c11/impl time.c
copy_subir_sources src/compiler copy_subir_sources src/compiler
copy_subir_headers src/compiler/glsl copy_subir_headers src/compiler/glsl
copy_subir_sources src/compiler/nir copy_subir_sources src/compiler/nir
@@ -126,34 +129,52 @@ copy_sources() {
copy_file src/util blob.c copy_file src/util blob.c
copy_file src/util bitscan.c copy_file src/util bitscan.c
copy_file src/util double.c copy_file src/util double.c
copy_file src/util float8.c
copy_file src/util half_float.c copy_file src/util half_float.c
copy_file src/util hash_table.c copy_file src/util hash_table.c
copy_file src/util log.c copy_file src/util log.c
copy_file src/util mesa-blake3.c
copy_file src/util mesa-sha1.c copy_file src/util mesa-sha1.c
copy_file src/util memstream.c copy_file src/util memstream.c
copy_file src/util os_misc.c copy_file src/util os_misc.c
copy_file src/util ralloc.c copy_file src/util ralloc.c
copy_file src/util range_minimum_query.c
copy_file src/util rb_tree.c copy_file src/util rb_tree.c
copy_file src/util rgtc.c copy_file src/util rgtc.c
copy_file src/util set.c copy_file src/util set.c
copy_file src/util simple_mtx.c copy_file src/util simple_mtx.c
copy_file src/util softfloat.c copy_file src/util softfloat.c
copy_file src/util string_buffer.c copy_file src/util string_buffer.c
copy_file src/util strndup.c
copy_file src/util u_call_once.c copy_file src/util u_call_once.c
copy_file src/util u_cpu_detect.c
copy_file src/util u_debug.c copy_file src/util u_debug.c
copy_file src/util u_dynarray.c
copy_file src/util u_printf.c copy_file src/util u_printf.c
copy_file src/util u_qsort.cpp copy_file src/util u_qsort.cpp
copy_file src/util u_thread.c
copy_file src/util u_vector.c copy_file src/util u_vector.c
copy_file src/util u_worklist.c copy_file src/util u_worklist.c
copy_subir_headers src/util/blake3
copy_file src/util/blake3 blake3.c
copy_file src/util/blake3 blake3_dispatch.c
copy_file src/util/blake3 blake3_portable.c
copy_subir_headers src/util/perf
cp ./mesa/VERSION godot-mesa cp ./mesa/VERSION godot-mesa/VERSION.info
check_error check_error
} }
blacklist_sources() { blacklist_sources() {
rm godot-mesa/src/compiler/nir/nir_stub.c
check_error
# These are programs. Not needed and makes build hungrier for dependencies. # These are programs. Not needed and makes build hungrier for dependencies.
rm godot-mesa/src/compiler/spirv/spirv2nir.c rm godot-mesa/src/compiler/spirv/spirv2nir.c
check_error check_error
rm godot-mesa/src/compiler/spirv/vtn_bindgen2.c
check_error
rm godot-mesa/src/microsoft/compiler/dxil_buffer_test.c
check_error
rm godot-mesa/src/microsoft/spirv_to_dxil/spirv2dxil.c rm godot-mesa/src/microsoft/spirv_to_dxil/spirv2dxil.c
check_error check_error
} }
@@ -195,17 +216,20 @@ custom_source_gen() {
run_step 'src/compiler' 'glsl/ir_expression_operation.py enum' 'ir_expression_operation.h' run_step 'src/compiler' 'glsl/ir_expression_operation.py enum' 'ir_expression_operation.h'
run_step 'src/compiler/nir' 'nir_builder_opcodes_h.py' 'nir_builder_opcodes.h' run_step 'src/compiler/nir' 'nir_builder_opcodes_h.py' 'nir_builder_opcodes.h'
run_step 'src/compiler/nir' 'nir_constant_expressions.py' 'nir_constant_expressions.c' run_step 'src/compiler/nir' 'nir_constant_expressions.py' 'nir_constant_expressions.c'
run_step 'src/compiler/nir' 'nir_intrinsics_h.py --outdir $GENDIR' run_step 'src/compiler/nir' 'nir_intrinsics_h.py --out $GENDIR/nir_intrinsics.h'
run_step 'src/compiler/nir' 'nir_intrinsics_c.py --outdir $GENDIR' run_step 'src/compiler/nir' 'nir_intrinsics_c.py --out $GENDIR/nir_intrinsics.c'
run_step 'src/compiler/nir' 'nir_intrinsics_indices_h.py --outdir $GENDIR' run_step 'src/compiler/nir' 'nir_intrinsics_indices_h.py --out $GENDIR/nir_intrinsics_indices.h'
run_step 'src/compiler/nir' 'nir_opcodes_h.py' 'nir_opcodes.h' run_step 'src/compiler/nir' 'nir_opcodes_h.py' 'nir_opcodes.h'
run_step 'src/compiler/nir' 'nir_opcodes_c.py' 'nir_opcodes.c' run_step 'src/compiler/nir' 'nir_opcodes_c.py' 'nir_opcodes.c'
run_step 'src/compiler/nir' 'nir_opt_algebraic.py' 'nir_opt_algebraic.c' run_step 'src/compiler/nir' 'nir_opt_algebraic.py --out $GENDIR/nir_opt_algebraic.c'
run_step 'src/compiler/spirv' 'vtn_generator_ids_h.py spir-v.xml $GENDIR/vtn_generator_ids.h' run_step 'src/compiler/spirv' 'vtn_generator_ids_h.py spir-v.xml $GENDIR/vtn_generator_ids.h'
run_step 'src/microsoft/compiler' 'dxil_nir_algebraic.py -p ../../../src/compiler/nir' 'dxil_nir_algebraic.c' run_step 'src/microsoft/compiler' 'dxil_nir_algebraic.py -p ../../../src/compiler/nir' 'dxil_nir_algebraic.c'
run_step 'src/util' 'format_srgb.py' 'format_srgb.c' run_step 'src/util' 'format_srgb.py' 'format_srgb.c'
run_step 'src/util/format' 'u_format_table.py u_format.csv --header' 'u_format_pack.h' run_step 'src/util/format' 'u_format_table.py u_format.yaml --enums' 'u_format_gen.h'
run_step 'src/util/format' 'u_format_table.py u_format.csv' 'u_format_table.c' run_step 'src/util/format' 'u_format_table.py u_format.yaml --header' 'u_format_pack.h'
run_step 'src/util/format' 'u_format_table.py u_format.yaml' 'u_format_table.c'
run_step 'src/compiler' 'builtin_types_h.py $GENDIR/builtin_types.h'
run_step 'src/compiler' 'builtin_types_c.py $GENDIR/builtin_types.c'
} }