30 Commits

Author SHA1 Message Date
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
7 changed files with 307 additions and 108 deletions

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

@@ -0,0 +1,175 @@
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: 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

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 platform
import sys
import subprocess
from pathlib import Path
from SCons.Errors import UserError
EnsureSConsVersion(4, 0)
@@ -119,6 +117,7 @@ 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)
target_tool = Tool("targets", toolpath=["godot-tools"])
@@ -191,6 +190,12 @@ if env["platform"] == "macos":
elif env["platform"] == "windows":
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")
if scons_cache_path is not None:
@@ -287,6 +292,9 @@ extra_defines = [
"WINDOWS_NO_FUTEX",
]
if env["optimize"] != "debug":
extra_defines += ["NDEBUG"]
# These defines are inspired by the Meson build scripts in the original repo.
extra_defines += [
"__STDC_CONSTANT_MACROS",
@@ -317,7 +325,6 @@ if env.get("is_msvc", False):
else:
env.Append(
CPPDEFINES=[
("__MSVCRT_VERSION__", 0x0700),
"HAVE_STRUCT_TIMESPEC",
]
)
@@ -326,6 +333,7 @@ else:
if env.get("use_llvm", False):
extra_defines += [
("__MSVCRT_VERSION__", 0x0700),
"HAVE_TIMESPEC_GET",
"_UCRT",
]

View File

@@ -1,5 +1,5 @@
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 7474afb..119b832 100644
--- a/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
@@ -13,7 +13,7 @@ index fcb8a9885c..54e199cc43 100644
load("global", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
# src[] = { address }.
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 6f87ff9..3684b32 100644
--- a/godot-mesa/src/compiler/spirv/spirv_to_nir.c
+++ b/godot-mesa/src/compiler/spirv/spirv_to_nir.c
@@ -39,6 +39,8 @@
@@ -41,7 +41,7 @@ index 5cb7691506..7620fef9f5 100644
case SpvDecorationAliased:
case SpvDecorationConstant:
case SpvDecorationIndex:
@@ -1938,7 +1940,7 @@ vtn_null_constant(struct vtn_builder *b, struct vtn_type *type)
@@ -1942,7 +1944,7 @@ vtn_null_constant(struct vtn_builder *b, struct vtn_type *type)
}
static void
@@ -50,7 +50,7 @@ index 5cb7691506..7620fef9f5 100644
ASSERTED int member,
const struct vtn_decoration *dec, void *data)
{
@@ -1946,13 +1948,8 @@ spec_constant_decoration_cb(struct vtn_builder *b, UNUSED struct vtn_value *val,
@@ -1950,13 +1952,8 @@ spec_constant_decoration_cb(struct vtn_builder *b, UNUSED struct vtn_value *val,
if (dec->decoration != SpvDecorationSpecId)
return;
@@ -66,7 +66,7 @@ index 5cb7691506..7620fef9f5 100644
}
static void
@@ -1976,6 +1973,12 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
@@ -1980,6 +1977,12 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
{
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_constant);
@@ -79,7 +79,7 @@ index 5cb7691506..7620fef9f5 100644
val->constant = rzalloc(b, nir_constant);
switch (opcode) {
case SpvOpConstantTrue:
@@ -1993,7 +1996,7 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
@@ -1997,7 +2000,7 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
if (opcode == SpvOpSpecConstantTrue ||
opcode == SpvOpSpecConstantFalse)
@@ -88,7 +88,7 @@ index 5cb7691506..7620fef9f5 100644
val->constant->values[0].b = u32val.u32 != 0;
break;
@@ -2024,11 +2027,10 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
@@ -2028,11 +2031,10 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
if (opcode == SpvOpSpecConstant)
vtn_foreach_decoration(b, val, spec_constant_decoration_cb,
@@ -101,7 +101,7 @@ index 5cb7691506..7620fef9f5 100644
case SpvOpConstantComposite: {
unsigned elem_count = count - 3;
vtn_fail_if(elem_count != val->type->length,
@@ -2076,218 +2078,6 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
@@ -2080,218 +2082,6 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
break;
}
@@ -320,7 +320,7 @@ index 5cb7691506..7620fef9f5 100644
case SpvOpConstantNull:
val->constant = vtn_null_constant(b, val->type);
val->is_null_constant = true;
@@ -6370,6 +6160,96 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
@@ -6393,6 +6183,93 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
return true;
}
@@ -357,40 +357,37 @@ index 5cb7691506..7620fef9f5 100644
+ vtn_assert(b->nb.cursor.option == nir_cursor_after_instr);
+ 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);
+ 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()) {
+ val->ssa->def = nir_build_alu(
+ &b->nb,
+ nir_op_ine,
+ temp,
+ non_opt_const,
+ nir_imm_int(&b->nb, 0),
+ NULL,
+ NULL);
+ } else if (val->type->type == glsl_float_type()) {
+ val->ssa->def = nir_build_alu(
+ &b->nb,
+ nir_op_ishl,
+ temp,
+ nir_imm_int(&b->nb, 1),
+ NULL,
+ NULL);
+ val->ssa->def = non_opt_const;
+ } else {
+ vtn_assert(false);
+ }
+ } break;
+
+ case SpvOpSpecConstantComposite:
+ abort(); // Unimplemented
+ case SpvOpSpecConstantComposite: {
+ 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;
+ }
+
+ case SpvOpSpecConstantOp: {
+ vtn_assert(val->value_type == vtn_value_type_ssa);
@@ -417,7 +414,7 @@ index 5cb7691506..7620fef9f5 100644
static bool
is_glslang(const struct vtn_builder *b)
{
@@ -6609,6 +6489,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
@@ -6632,6 +6509,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
/* Skip the SPIR-V header, handled at vtn_create_builder */
words+= 5;
@@ -426,7 +423,7 @@ index 5cb7691506..7620fef9f5 100644
/* Handle all the preamble instructions */
words = vtn_foreach_instruction(b, words, word_end,
vtn_handle_preamble_instruction);
@@ -6690,7 +6572,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
@@ -6713,7 +6592,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
if ((options->create_library || func->referenced) && !func->emitted) {
b->const_table = _mesa_pointer_hash_table_create(b);
@@ -436,7 +433,7 @@ index 5cb7691506..7620fef9f5 100644
}
}
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 b02c11b..7d0c647 100644
--- a/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,
@@ -459,7 +456,7 @@ index b02c11b8d7..7d0c647f79 100644
impl->structured = false;
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
index bd65a60d9b..389f477681 100644
index b1ec64d..1bdb3c8 100644
--- a/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,
@@ -491,7 +488,7 @@ index bd65a60d9b..389f477681 100644
#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
index 8db61c8e61..8545903165 100644
index 8db61c8..8545903 100644
--- a/godot-mesa/src/compiler/spirv/vtn_variables.c
+++ b/godot-mesa/src/compiler/spirv/vtn_variables.c
@@ -26,6 +26,8 @@
@@ -526,7 +523,7 @@ index 8db61c8e61..8545903165 100644
vtn_var->input_attachment_index = dec->operands[0];
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
index 209973459d..487cda7a40 100644
index 2099734..487cda7 100644
--- a/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,
@@ -582,7 +579,7 @@ index 209973459d..487cda7a40 100644
return true;
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 b3279ee..08ab970 100644
--- a/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,
@@ -600,7 +597,7 @@ index b3279ee108..08ab970cb8 100644
#ifdef __cplusplus
}
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 773e564..57b6a62 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_module.c
+++ b/godot-mesa/src/microsoft/compiler/dxil_module.c
@@ -32,6 +32,8 @@
@@ -626,7 +623,7 @@ index 773e5640a6..57b6a62ffd 100644
case TYPE_INTEGER:
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
index ca170c5d2f..7fab628a22 100644
index ca170c5..7fab628 100644
--- a/godot-mesa/src/microsoft/compiler/dxil_module.h
+++ b/godot-mesa/src/microsoft/compiler/dxil_module.h
@@ -29,6 +29,8 @@
@@ -647,57 +644,8 @@ index ca170c5d2f..7fab628a22 100644
};
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
index 245c5140f9..d6c9d06c30 100644
index c4de9dd..3c0223f 100644
--- a/godot-mesa/src/microsoft/compiler/nir_to_dxil.c
+++ b/godot-mesa/src/microsoft/compiler/nir_to_dxil.c
@@ -43,6 +43,8 @@
@@ -718,7 +666,7 @@ index 245c5140f9..d6c9d06c30 100644
}
static const struct dxil_value *
@@ -5079,6 +5083,12 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
@@ -5091,6 +5095,12 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
case nir_intrinsic_exclusive_scan:
return emit_reduce(ctx, intr);
@@ -731,7 +679,7 @@ index 245c5140f9..d6c9d06c30 100644
case nir_intrinsic_load_num_workgroups:
case nir_intrinsic_load_workgroup_size:
default:
@@ -6644,6 +6653,7 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
@@ -6656,6 +6666,7 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
MIN2(opts->shader_model_max & 0xffff, validator_version & 0xffff);
ctx->mod.major_validator = validator_version >> 16;
ctx->mod.minor_validator = validator_version & 0xffff;
@@ -739,7 +687,7 @@ index 245c5140f9..d6c9d06c30 100644
if (s->info.stage <= MESA_SHADER_FRAGMENT) {
uint64_t in_mask =
@@ -6762,19 +6772,23 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
@@ -6774,19 +6785,23 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
goto out;
}
@@ -766,7 +714,7 @@ index 245c5140f9..d6c9d06c30 100644
static int shader_id = 0;
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
index bdfbe23953..b95ca1d79f 100644
index bdfbe23..b95ca1d 100644
--- a/godot-mesa/src/microsoft/compiler/nir_to_dxil.h
+++ b/godot-mesa/src/microsoft/compiler/nir_to_dxil.h
@@ -29,6 +29,8 @@
@@ -786,8 +734,42 @@ index bdfbe23953..b95ca1d79f 100644
};
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 43de965..8965ecc 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
@@ -1068,28 +1068,7 @@ dxil_spirv_nir_passes(nir_shader *nir,
NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL);
NIR_PASS_V(nir, nir_opt_dce);
NIR_PASS_V(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_trivial_continues(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);
- } while (progress);
- }
+ NIR_PASS_V(nir, nir_lower_vars_to_ssa);
if (conf->declared_read_only_images_as_srvs)
NIR_PASS_V(nir, nir_lower_readonly_images_to_tex, true);
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 76cf6b0..819339a 100644
--- a/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 @@
@@ -816,7 +798,7 @@ index 76cf6b007e..819339adf5 100644
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
index 40adf761ef..30efbd16dd 100644
index 40adf76..30efbd1 100644
--- a/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 @@

View File

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

View File

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

View File

@@ -1,17 +1,21 @@
import os
import sys
import my_spawn
from SCons.Tool import msvc, mingw
from SCons.Variables import *
from SCons.Variables import BoolVariable
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_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("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False))
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler", False))
opts.Add("mingw_prefix", "MinGW prefix", mingw)
def exists(env):
@@ -30,10 +34,15 @@ def generate(env):
elif env["arch"] == "x86_32":
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
# MSVC, linker, and archiver.
msvc.generate(env)
env.Tool("msvc")
env.Tool("mslib")
env.Tool("mslink")
@@ -53,7 +62,7 @@ def generate(env):
env["CC"] = "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
mingw.generate(env)
env.Append(CPPDEFINES=["MINGW_ENABLED"])
@@ -68,25 +77,29 @@ def generate(env):
else:
env["use_mingw"] = True
# Cross-compilation using MinGW
prefix = ""
if env["mingw_prefix"]:
prefix = env["mingw_prefix"] + "/bin/"
if env["arch"] == "x86_64":
prefix = "x86_64"
prefix += "x86_64"
elif env["arch"] == "arm64":
prefix = "aarch64"
prefix += "aarch64"
elif env["arch"] == "arm32":
prefix = "armv7"
prefix += "armv7"
elif env["arch"] == "x86_32":
prefix = "i686"
prefix += "i686"
if env["use_llvm"]:
env["CXX"] = prefix + "-w64-mingw32-clang"
env["CC"] = prefix + "-w64-mingw32-clang++"
env["CXX"] = prefix + "-w64-mingw32-clang++"
env["CC"] = prefix + "-w64-mingw32-clang"
env["AR"] = prefix + "-w64-mingw32-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-clang"
else:
env["CXX"] = prefix + "-w64-mingw32-g++"
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["LINK"] = prefix + "-w64-mingw32-g++"
@@ -105,3 +118,6 @@ def generate(env):
"-Wl,--no-undefined",
]
)
if (sys.platform == "win32" or sys.platform == "msys"):
my_spawn.configure(env)