From 4d1f1bad8b576a8661115cf8878215c7e358ab31 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Wed, 23 Apr 2025 12:55:59 +0300 Subject: [PATCH 01/11] Fix linker error for linux --- Modules/glslang/Package.swift | 17 ++++++++++- .../glslang}/SPIRVCompiler/BUILD.bazel | 0 .../SPIRVCompiler/include}/spirv_compiler.h | 0 .../glslang}/SPIRVCompiler/spirv_compiler.cpp | 10 +++---- .../OGLCompilersDLL/CMakeLists.txt | 0 .../OGLCompilersDLL/InitializeDll.cpp | 0 .../OGLCompilersDLL/InitializeDll.h | 0 .../{ => Sources}/SPIRV/GLSL.ext.AMD.h | 0 .../{ => Sources}/SPIRV/GLSL.ext.EXT.h | 0 .../{ => Sources}/SPIRV/GLSL.ext.KHR.h | 0 .../glslang/{ => Sources}/SPIRV/GLSL.ext.NV.h | 0 .../{ => Sources}/SPIRV/GLSL.std.450.h | 0 .../{ => Sources}/SPIRV/GlslangToSpv.cpp | 0 .../{ => Sources}/SPIRV/GlslangToSpv.h | 0 .../{ => Sources}/SPIRV/InReadableOrder.cpp | 0 .../glslang/{ => Sources}/SPIRV/Logger.cpp | 0 Modules/glslang/{ => Sources}/SPIRV/Logger.h | 0 .../SPIRV/NonSemanticDebugPrintf.h | 0 .../SPIRV/NonSemanticShaderDebugInfo100.h | 0 .../{ => Sources}/SPIRV/SPVRemapper.cpp | 0 .../glslang/{ => Sources}/SPIRV/SPVRemapper.h | 0 .../{ => Sources}/SPIRV/SpvBuilder.cpp | 0 .../glslang/{ => Sources}/SPIRV/SpvBuilder.h | 0 .../{ => Sources}/SPIRV/SpvPostProcess.cpp | 0 .../glslang/{ => Sources}/SPIRV/SpvTools.cpp | 0 .../glslang/{ => Sources}/SPIRV/SpvTools.h | 0 .../glslang/{ => Sources}/SPIRV/bitutils.h | 0 .../{ => Sources}/SPIRV/disassemble.cpp | 0 .../glslang/{ => Sources}/SPIRV/disassemble.h | 0 Modules/glslang/{ => Sources}/SPIRV/doc.cpp | 0 Modules/glslang/{ => Sources}/SPIRV/doc.h | 0 .../glslang/{ => Sources}/SPIRV/hex_float.h | 0 Modules/glslang/{ => Sources}/SPIRV/spirv.hpp | 0 Modules/glslang/{ => Sources}/SPIRV/spvIR.h | 0 .../CInterface/glslang_c_interface.cpp | 0 .../{ => Sources}/glslang/CMakeLists.txt | 0 .../GL_EXT_shader_realtime_clock.glsl | 0 .../glslang/GenericCodeGen/CodeGen.cpp | 0 .../glslang/GenericCodeGen/Link.cpp | 0 .../glslang/HLSL/hlslAttributes.cpp | 0 .../glslang/HLSL/hlslAttributes.h | 0 .../glslang/HLSL/hlslGrammar.cpp | 0 .../{ => Sources}/glslang/HLSL/hlslGrammar.h | 0 .../{ => Sources}/glslang/HLSL/hlslOpMap.cpp | 0 .../{ => Sources}/glslang/HLSL/hlslOpMap.h | 0 .../glslang/HLSL/hlslParseHelper.cpp | 0 .../glslang/HLSL/hlslParseHelper.h | 0 .../glslang/HLSL/hlslParseables.cpp | 0 .../glslang/HLSL/hlslParseables.h | 0 .../glslang/HLSL/hlslScanContext.cpp | 0 .../glslang/HLSL/hlslScanContext.h | 0 .../glslang/HLSL/hlslTokenStream.cpp | 0 .../glslang/HLSL/hlslTokenStream.h | 0 .../{ => Sources}/glslang/HLSL/hlslTokens.h | 0 .../glslang/{ => Sources}/glslang/HLSL/pch.h | 0 .../{ => Sources}/glslang/Include/BaseTypes.h | 0 .../{ => Sources}/glslang/Include/Common.h | 0 .../glslang/Include/ConstantUnion.h | 0 .../{ => Sources}/glslang/Include/InfoSink.h | 0 .../glslang/Include/InitializeGlobals.h | 0 .../{ => Sources}/glslang/Include/PoolAlloc.h | 0 .../glslang/Include/ResourceLimits.h | 0 .../{ => Sources}/glslang/Include/ShHandle.h | 0 .../glslang/Include/SpirvIntrinsics.h | 0 .../{ => Sources}/glslang/Include/Types.h | 0 .../{ => Sources}/glslang/Include/arrays.h | 0 .../glslang/Include/glslang_c_interface.h | 0 .../glslang/Include/glslang_c_shader_types.h | 0 .../glslang/Include/intermediate.h | 0 .../glslang/MachineIndependent/Constant.cpp | 0 .../glslang/MachineIndependent/InfoSink.cpp | 0 .../glslang/MachineIndependent/Initialize.cpp | 0 .../glslang/MachineIndependent/Initialize.h | 0 .../MachineIndependent/IntermTraverse.cpp | 0 .../MachineIndependent/Intermediate.cpp | 0 .../MachineIndependent/LiveTraverser.h | 0 .../MachineIndependent/ParseContextBase.cpp | 0 .../MachineIndependent/ParseHelper.cpp | 0 .../glslang/MachineIndependent/ParseHelper.h | 0 .../glslang/MachineIndependent/PoolAlloc.cpp | 0 .../glslang/MachineIndependent/RemoveTree.cpp | 0 .../glslang/MachineIndependent/RemoveTree.h | 0 .../glslang/MachineIndependent/Scan.cpp | 0 .../glslang/MachineIndependent/Scan.h | 0 .../glslang/MachineIndependent/ScanContext.h | 0 .../glslang/MachineIndependent/ShaderLang.cpp | 0 .../MachineIndependent/SpirvIntrinsics.cpp | 0 .../MachineIndependent/SymbolTable.cpp | 0 .../glslang/MachineIndependent/SymbolTable.h | 0 .../glslang/MachineIndependent/Versions.cpp | 0 .../glslang/MachineIndependent/Versions.h | 0 .../glslang/MachineIndependent/attribute.cpp | 0 .../glslang/MachineIndependent/attribute.h | 0 .../glslang/MachineIndependent/gl_types.h | 0 .../glslang/MachineIndependent/glslang.m4 | 0 .../glslang/MachineIndependent/glslang.y | 0 .../MachineIndependent/glslang_tab.cpp | 0 .../MachineIndependent/glslang_tab.cpp.h | 0 .../glslang/MachineIndependent/intermOut.cpp | 0 .../glslang/MachineIndependent/iomapper.cpp | 0 .../glslang/MachineIndependent/iomapper.h | 0 .../glslang/MachineIndependent/limits.cpp | 0 .../MachineIndependent/linkValidate.cpp | 0 .../MachineIndependent/localintermediate.h | 0 .../glslang/MachineIndependent/parseConst.cpp | 0 .../MachineIndependent/parseVersions.h | 0 .../glslang/MachineIndependent/pch.h | 0 .../MachineIndependent/preprocessor/Pp.cpp | 0 .../preprocessor/PpAtom.cpp | 0 .../preprocessor/PpContext.cpp | 0 .../preprocessor/PpContext.h | 0 .../preprocessor/PpScanner.cpp | 0 .../preprocessor/PpTokens.cpp | 0 .../preprocessor/PpTokens.h | 0 .../propagateNoContraction.cpp | 0 .../propagateNoContraction.h | 0 .../glslang/MachineIndependent/reflection.cpp | 0 .../glslang/MachineIndependent/reflection.h | 0 .../glslang/OSDependent/Unix/CMakeLists.txt | 0 .../glslang/OSDependent/Unix/ossource.cpp | 0 .../glslang/OSDependent/Web/CMakeLists.txt | 0 .../glslang/OSDependent/Web/glslang.after.js | 0 .../glslang/OSDependent/Web/glslang.js.cpp | 0 .../glslang/OSDependent/Web/glslang.pre.js | 0 .../OSDependent/Windows/CMakeLists.txt | 0 .../glslang/OSDependent/Windows/ossource.cpp | 0 .../glslang/OSDependent/osinclude.h | 0 .../glslang/Public/ResourceLimits.h | 0 .../{ => Sources}/glslang/Public/ShaderLang.h | 0 .../glslang/Public/resource_limits_c.h | 0 .../glslang/ResourceLimits/ResourceLimits.cpp | 0 .../ResourceLimits/resource_limits_c.cpp | 0 .../{ => Sources}/glslang/build_info.h | 0 .../{ => Sources}/glslang/updateGrammar | 0 .../AtlasFontGenerator/AtlasFontGenerator.cpp | 0 .../AtlasFontGenerator/AtlasFontGenerator.h | 0 .../AtlasFontGenerator/BUILD.bazel | 0 .../AtlasFontGenerator/FontHolder.cpp | 0 .../AtlasFontGenerator/FontHolder.h | 0 .../AtlasFontGenerator/atlas_font_gen.cpp | 0 .../include/atlas_font_gen.h | 0 .../AtlasFontGenerator/module.modulemap | 0 Modules/msdf-atlas-gen/Package.swift | 15 +++++++--- Package.swift | 28 ++----------------- 144 files changed, 35 insertions(+), 35 deletions(-) rename {Sources => Modules/glslang}/SPIRVCompiler/BUILD.bazel (100%) rename {Sources/SPIRVCompiler => Modules/glslang/SPIRVCompiler/include}/spirv_compiler.h (100%) rename {Sources => Modules/glslang}/SPIRVCompiler/spirv_compiler.cpp (97%) rename Modules/glslang/{ => Sources}/OGLCompilersDLL/CMakeLists.txt (100%) rename Modules/glslang/{ => Sources}/OGLCompilersDLL/InitializeDll.cpp (100%) rename Modules/glslang/{ => Sources}/OGLCompilersDLL/InitializeDll.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/GLSL.ext.AMD.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/GLSL.ext.EXT.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/GLSL.ext.KHR.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/GLSL.ext.NV.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/GLSL.std.450.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/GlslangToSpv.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/GlslangToSpv.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/InReadableOrder.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/Logger.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/Logger.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/NonSemanticDebugPrintf.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/NonSemanticShaderDebugInfo100.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/SPVRemapper.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/SPVRemapper.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/SpvBuilder.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/SpvBuilder.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/SpvPostProcess.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/SpvTools.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/SpvTools.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/bitutils.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/disassemble.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/disassemble.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/doc.cpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/doc.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/hex_float.h (100%) rename Modules/glslang/{ => Sources}/SPIRV/spirv.hpp (100%) rename Modules/glslang/{ => Sources}/SPIRV/spvIR.h (100%) rename Modules/glslang/{ => Sources}/glslang/CInterface/glslang_c_interface.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/CMakeLists.txt (100%) rename Modules/glslang/{ => Sources}/glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl (100%) rename Modules/glslang/{ => Sources}/glslang/GenericCodeGen/CodeGen.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/GenericCodeGen/Link.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslAttributes.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslAttributes.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslGrammar.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslGrammar.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslOpMap.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslOpMap.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslParseHelper.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslParseHelper.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslParseables.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslParseables.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslScanContext.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslScanContext.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslTokenStream.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslTokenStream.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/hlslTokens.h (100%) rename Modules/glslang/{ => Sources}/glslang/HLSL/pch.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/BaseTypes.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/Common.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/ConstantUnion.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/InfoSink.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/InitializeGlobals.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/PoolAlloc.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/ResourceLimits.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/ShHandle.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/SpirvIntrinsics.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/Types.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/arrays.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/glslang_c_interface.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/glslang_c_shader_types.h (100%) rename Modules/glslang/{ => Sources}/glslang/Include/intermediate.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Constant.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/InfoSink.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Initialize.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Initialize.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/IntermTraverse.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Intermediate.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/LiveTraverser.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/ParseContextBase.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/ParseHelper.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/ParseHelper.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/PoolAlloc.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/RemoveTree.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/RemoveTree.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Scan.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Scan.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/ScanContext.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/ShaderLang.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/SpirvIntrinsics.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/SymbolTable.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/SymbolTable.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Versions.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/Versions.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/attribute.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/attribute.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/gl_types.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/glslang.m4 (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/glslang.y (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/glslang_tab.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/glslang_tab.cpp.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/intermOut.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/iomapper.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/iomapper.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/limits.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/linkValidate.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/localintermediate.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/parseConst.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/parseVersions.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/pch.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/Pp.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/PpAtom.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/PpContext.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/PpContext.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/PpScanner.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/PpTokens.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/preprocessor/PpTokens.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/propagateNoContraction.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/propagateNoContraction.h (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/reflection.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/MachineIndependent/reflection.h (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Unix/CMakeLists.txt (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Unix/ossource.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Web/CMakeLists.txt (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Web/glslang.after.js (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Web/glslang.js.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Web/glslang.pre.js (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Windows/CMakeLists.txt (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/Windows/ossource.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/OSDependent/osinclude.h (100%) rename Modules/glslang/{ => Sources}/glslang/Public/ResourceLimits.h (100%) rename Modules/glslang/{ => Sources}/glslang/Public/ShaderLang.h (100%) rename Modules/glslang/{ => Sources}/glslang/Public/resource_limits_c.h (100%) rename Modules/glslang/{ => Sources}/glslang/ResourceLimits/ResourceLimits.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/ResourceLimits/resource_limits_c.cpp (100%) rename Modules/glslang/{ => Sources}/glslang/build_info.h (100%) rename Modules/glslang/{ => Sources}/glslang/updateGrammar (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/AtlasFontGenerator.cpp (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/AtlasFontGenerator.h (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/BUILD.bazel (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/FontHolder.cpp (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/FontHolder.h (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/atlas_font_gen.cpp (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/include/atlas_font_gen.h (100%) rename {Sources => Modules/msdf-atlas-gen}/AtlasFontGenerator/module.modulemap (100%) diff --git a/Modules/glslang/Package.swift b/Modules/glslang/Package.swift index 4f99da172..d5aba620f 100644 --- a/Modules/glslang/Package.swift +++ b/Modules/glslang/Package.swift @@ -60,17 +60,32 @@ let package = Package( .library( name: "glslang", targets: ["glslang"] + ), + .library( + name: "SPIRVCompiler", + targets: ["SPIRVCompiler"] ) ], targets: [ .target( name: "glslang", - path: ".", + path: "Sources", sources: glslangSources, publicHeadersPath: ".", cxxSettings: [ .define("ENABLE_OPT", to: "0"), ] + ), + .target( + name: "SPIRVCompiler", + dependencies: [ + "glslang" + ], + path: "SPIRVCompiler", + cxxSettings: [ + .headerSearchPath("../Sources/glslang/Include/"), + .headerSearchPath("../Sources/glslang/SPIRV/") + ] ) ], cxxLanguageStandard: .cxx17 diff --git a/Sources/SPIRVCompiler/BUILD.bazel b/Modules/glslang/SPIRVCompiler/BUILD.bazel similarity index 100% rename from Sources/SPIRVCompiler/BUILD.bazel rename to Modules/glslang/SPIRVCompiler/BUILD.bazel diff --git a/Sources/SPIRVCompiler/spirv_compiler.h b/Modules/glslang/SPIRVCompiler/include/spirv_compiler.h similarity index 100% rename from Sources/SPIRVCompiler/spirv_compiler.h rename to Modules/glslang/SPIRVCompiler/include/spirv_compiler.h diff --git a/Sources/SPIRVCompiler/spirv_compiler.cpp b/Modules/glslang/SPIRVCompiler/spirv_compiler.cpp similarity index 97% rename from Sources/SPIRVCompiler/spirv_compiler.cpp rename to Modules/glslang/SPIRVCompiler/spirv_compiler.cpp index 954b6f313..12befc3e6 100644 --- a/Sources/SPIRVCompiler/spirv_compiler.cpp +++ b/Modules/glslang/SPIRVCompiler/spirv_compiler.cpp @@ -5,12 +5,12 @@ // Created by v.prusakov on 3/11/23. // -#include "spirv_compiler.h" +#include "include/spirv_compiler.h" -#include -#include -#include -#include +#include "glslang/Include/ResourceLimits.h" +#include "glslang/Include/Types.h" +#include "glslang/Public/ShaderLang.h" +#include "SPIRV/GlslangToSpv.h" const TBuiltInResource DefaultTBuiltInResource = { /* .MaxLights = */ 32, diff --git a/Modules/glslang/OGLCompilersDLL/CMakeLists.txt b/Modules/glslang/Sources/OGLCompilersDLL/CMakeLists.txt similarity index 100% rename from Modules/glslang/OGLCompilersDLL/CMakeLists.txt rename to Modules/glslang/Sources/OGLCompilersDLL/CMakeLists.txt diff --git a/Modules/glslang/OGLCompilersDLL/InitializeDll.cpp b/Modules/glslang/Sources/OGLCompilersDLL/InitializeDll.cpp similarity index 100% rename from Modules/glslang/OGLCompilersDLL/InitializeDll.cpp rename to Modules/glslang/Sources/OGLCompilersDLL/InitializeDll.cpp diff --git a/Modules/glslang/OGLCompilersDLL/InitializeDll.h b/Modules/glslang/Sources/OGLCompilersDLL/InitializeDll.h similarity index 100% rename from Modules/glslang/OGLCompilersDLL/InitializeDll.h rename to Modules/glslang/Sources/OGLCompilersDLL/InitializeDll.h diff --git a/Modules/glslang/SPIRV/GLSL.ext.AMD.h b/Modules/glslang/Sources/SPIRV/GLSL.ext.AMD.h similarity index 100% rename from Modules/glslang/SPIRV/GLSL.ext.AMD.h rename to Modules/glslang/Sources/SPIRV/GLSL.ext.AMD.h diff --git a/Modules/glslang/SPIRV/GLSL.ext.EXT.h b/Modules/glslang/Sources/SPIRV/GLSL.ext.EXT.h similarity index 100% rename from Modules/glslang/SPIRV/GLSL.ext.EXT.h rename to Modules/glslang/Sources/SPIRV/GLSL.ext.EXT.h diff --git a/Modules/glslang/SPIRV/GLSL.ext.KHR.h b/Modules/glslang/Sources/SPIRV/GLSL.ext.KHR.h similarity index 100% rename from Modules/glslang/SPIRV/GLSL.ext.KHR.h rename to Modules/glslang/Sources/SPIRV/GLSL.ext.KHR.h diff --git a/Modules/glslang/SPIRV/GLSL.ext.NV.h b/Modules/glslang/Sources/SPIRV/GLSL.ext.NV.h similarity index 100% rename from Modules/glslang/SPIRV/GLSL.ext.NV.h rename to Modules/glslang/Sources/SPIRV/GLSL.ext.NV.h diff --git a/Modules/glslang/SPIRV/GLSL.std.450.h b/Modules/glslang/Sources/SPIRV/GLSL.std.450.h similarity index 100% rename from Modules/glslang/SPIRV/GLSL.std.450.h rename to Modules/glslang/Sources/SPIRV/GLSL.std.450.h diff --git a/Modules/glslang/SPIRV/GlslangToSpv.cpp b/Modules/glslang/Sources/SPIRV/GlslangToSpv.cpp similarity index 100% rename from Modules/glslang/SPIRV/GlslangToSpv.cpp rename to Modules/glslang/Sources/SPIRV/GlslangToSpv.cpp diff --git a/Modules/glslang/SPIRV/GlslangToSpv.h b/Modules/glslang/Sources/SPIRV/GlslangToSpv.h similarity index 100% rename from Modules/glslang/SPIRV/GlslangToSpv.h rename to Modules/glslang/Sources/SPIRV/GlslangToSpv.h diff --git a/Modules/glslang/SPIRV/InReadableOrder.cpp b/Modules/glslang/Sources/SPIRV/InReadableOrder.cpp similarity index 100% rename from Modules/glslang/SPIRV/InReadableOrder.cpp rename to Modules/glslang/Sources/SPIRV/InReadableOrder.cpp diff --git a/Modules/glslang/SPIRV/Logger.cpp b/Modules/glslang/Sources/SPIRV/Logger.cpp similarity index 100% rename from Modules/glslang/SPIRV/Logger.cpp rename to Modules/glslang/Sources/SPIRV/Logger.cpp diff --git a/Modules/glslang/SPIRV/Logger.h b/Modules/glslang/Sources/SPIRV/Logger.h similarity index 100% rename from Modules/glslang/SPIRV/Logger.h rename to Modules/glslang/Sources/SPIRV/Logger.h diff --git a/Modules/glslang/SPIRV/NonSemanticDebugPrintf.h b/Modules/glslang/Sources/SPIRV/NonSemanticDebugPrintf.h similarity index 100% rename from Modules/glslang/SPIRV/NonSemanticDebugPrintf.h rename to Modules/glslang/Sources/SPIRV/NonSemanticDebugPrintf.h diff --git a/Modules/glslang/SPIRV/NonSemanticShaderDebugInfo100.h b/Modules/glslang/Sources/SPIRV/NonSemanticShaderDebugInfo100.h similarity index 100% rename from Modules/glslang/SPIRV/NonSemanticShaderDebugInfo100.h rename to Modules/glslang/Sources/SPIRV/NonSemanticShaderDebugInfo100.h diff --git a/Modules/glslang/SPIRV/SPVRemapper.cpp b/Modules/glslang/Sources/SPIRV/SPVRemapper.cpp similarity index 100% rename from Modules/glslang/SPIRV/SPVRemapper.cpp rename to Modules/glslang/Sources/SPIRV/SPVRemapper.cpp diff --git a/Modules/glslang/SPIRV/SPVRemapper.h b/Modules/glslang/Sources/SPIRV/SPVRemapper.h similarity index 100% rename from Modules/glslang/SPIRV/SPVRemapper.h rename to Modules/glslang/Sources/SPIRV/SPVRemapper.h diff --git a/Modules/glslang/SPIRV/SpvBuilder.cpp b/Modules/glslang/Sources/SPIRV/SpvBuilder.cpp similarity index 100% rename from Modules/glslang/SPIRV/SpvBuilder.cpp rename to Modules/glslang/Sources/SPIRV/SpvBuilder.cpp diff --git a/Modules/glslang/SPIRV/SpvBuilder.h b/Modules/glslang/Sources/SPIRV/SpvBuilder.h similarity index 100% rename from Modules/glslang/SPIRV/SpvBuilder.h rename to Modules/glslang/Sources/SPIRV/SpvBuilder.h diff --git a/Modules/glslang/SPIRV/SpvPostProcess.cpp b/Modules/glslang/Sources/SPIRV/SpvPostProcess.cpp similarity index 100% rename from Modules/glslang/SPIRV/SpvPostProcess.cpp rename to Modules/glslang/Sources/SPIRV/SpvPostProcess.cpp diff --git a/Modules/glslang/SPIRV/SpvTools.cpp b/Modules/glslang/Sources/SPIRV/SpvTools.cpp similarity index 100% rename from Modules/glslang/SPIRV/SpvTools.cpp rename to Modules/glslang/Sources/SPIRV/SpvTools.cpp diff --git a/Modules/glslang/SPIRV/SpvTools.h b/Modules/glslang/Sources/SPIRV/SpvTools.h similarity index 100% rename from Modules/glslang/SPIRV/SpvTools.h rename to Modules/glslang/Sources/SPIRV/SpvTools.h diff --git a/Modules/glslang/SPIRV/bitutils.h b/Modules/glslang/Sources/SPIRV/bitutils.h similarity index 100% rename from Modules/glslang/SPIRV/bitutils.h rename to Modules/glslang/Sources/SPIRV/bitutils.h diff --git a/Modules/glslang/SPIRV/disassemble.cpp b/Modules/glslang/Sources/SPIRV/disassemble.cpp similarity index 100% rename from Modules/glslang/SPIRV/disassemble.cpp rename to Modules/glslang/Sources/SPIRV/disassemble.cpp diff --git a/Modules/glslang/SPIRV/disassemble.h b/Modules/glslang/Sources/SPIRV/disassemble.h similarity index 100% rename from Modules/glslang/SPIRV/disassemble.h rename to Modules/glslang/Sources/SPIRV/disassemble.h diff --git a/Modules/glslang/SPIRV/doc.cpp b/Modules/glslang/Sources/SPIRV/doc.cpp similarity index 100% rename from Modules/glslang/SPIRV/doc.cpp rename to Modules/glslang/Sources/SPIRV/doc.cpp diff --git a/Modules/glslang/SPIRV/doc.h b/Modules/glslang/Sources/SPIRV/doc.h similarity index 100% rename from Modules/glslang/SPIRV/doc.h rename to Modules/glslang/Sources/SPIRV/doc.h diff --git a/Modules/glslang/SPIRV/hex_float.h b/Modules/glslang/Sources/SPIRV/hex_float.h similarity index 100% rename from Modules/glslang/SPIRV/hex_float.h rename to Modules/glslang/Sources/SPIRV/hex_float.h diff --git a/Modules/glslang/SPIRV/spirv.hpp b/Modules/glslang/Sources/SPIRV/spirv.hpp similarity index 100% rename from Modules/glslang/SPIRV/spirv.hpp rename to Modules/glslang/Sources/SPIRV/spirv.hpp diff --git a/Modules/glslang/SPIRV/spvIR.h b/Modules/glslang/Sources/SPIRV/spvIR.h similarity index 100% rename from Modules/glslang/SPIRV/spvIR.h rename to Modules/glslang/Sources/SPIRV/spvIR.h diff --git a/Modules/glslang/glslang/CInterface/glslang_c_interface.cpp b/Modules/glslang/Sources/glslang/CInterface/glslang_c_interface.cpp similarity index 100% rename from Modules/glslang/glslang/CInterface/glslang_c_interface.cpp rename to Modules/glslang/Sources/glslang/CInterface/glslang_c_interface.cpp diff --git a/Modules/glslang/glslang/CMakeLists.txt b/Modules/glslang/Sources/glslang/CMakeLists.txt similarity index 100% rename from Modules/glslang/glslang/CMakeLists.txt rename to Modules/glslang/Sources/glslang/CMakeLists.txt diff --git a/Modules/glslang/glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl b/Modules/glslang/Sources/glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl similarity index 100% rename from Modules/glslang/glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl rename to Modules/glslang/Sources/glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl diff --git a/Modules/glslang/glslang/GenericCodeGen/CodeGen.cpp b/Modules/glslang/Sources/glslang/GenericCodeGen/CodeGen.cpp similarity index 100% rename from Modules/glslang/glslang/GenericCodeGen/CodeGen.cpp rename to Modules/glslang/Sources/glslang/GenericCodeGen/CodeGen.cpp diff --git a/Modules/glslang/glslang/GenericCodeGen/Link.cpp b/Modules/glslang/Sources/glslang/GenericCodeGen/Link.cpp similarity index 100% rename from Modules/glslang/glslang/GenericCodeGen/Link.cpp rename to Modules/glslang/Sources/glslang/GenericCodeGen/Link.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslAttributes.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslAttributes.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslAttributes.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslAttributes.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslAttributes.h b/Modules/glslang/Sources/glslang/HLSL/hlslAttributes.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslAttributes.h rename to Modules/glslang/Sources/glslang/HLSL/hlslAttributes.h diff --git a/Modules/glslang/glslang/HLSL/hlslGrammar.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslGrammar.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslGrammar.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslGrammar.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslGrammar.h b/Modules/glslang/Sources/glslang/HLSL/hlslGrammar.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslGrammar.h rename to Modules/glslang/Sources/glslang/HLSL/hlslGrammar.h diff --git a/Modules/glslang/glslang/HLSL/hlslOpMap.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslOpMap.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslOpMap.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslOpMap.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslOpMap.h b/Modules/glslang/Sources/glslang/HLSL/hlslOpMap.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslOpMap.h rename to Modules/glslang/Sources/glslang/HLSL/hlslOpMap.h diff --git a/Modules/glslang/glslang/HLSL/hlslParseHelper.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslParseHelper.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslParseHelper.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslParseHelper.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslParseHelper.h b/Modules/glslang/Sources/glslang/HLSL/hlslParseHelper.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslParseHelper.h rename to Modules/glslang/Sources/glslang/HLSL/hlslParseHelper.h diff --git a/Modules/glslang/glslang/HLSL/hlslParseables.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslParseables.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslParseables.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslParseables.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslParseables.h b/Modules/glslang/Sources/glslang/HLSL/hlslParseables.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslParseables.h rename to Modules/glslang/Sources/glslang/HLSL/hlslParseables.h diff --git a/Modules/glslang/glslang/HLSL/hlslScanContext.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslScanContext.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslScanContext.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslScanContext.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslScanContext.h b/Modules/glslang/Sources/glslang/HLSL/hlslScanContext.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslScanContext.h rename to Modules/glslang/Sources/glslang/HLSL/hlslScanContext.h diff --git a/Modules/glslang/glslang/HLSL/hlslTokenStream.cpp b/Modules/glslang/Sources/glslang/HLSL/hlslTokenStream.cpp similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslTokenStream.cpp rename to Modules/glslang/Sources/glslang/HLSL/hlslTokenStream.cpp diff --git a/Modules/glslang/glslang/HLSL/hlslTokenStream.h b/Modules/glslang/Sources/glslang/HLSL/hlslTokenStream.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslTokenStream.h rename to Modules/glslang/Sources/glslang/HLSL/hlslTokenStream.h diff --git a/Modules/glslang/glslang/HLSL/hlslTokens.h b/Modules/glslang/Sources/glslang/HLSL/hlslTokens.h similarity index 100% rename from Modules/glslang/glslang/HLSL/hlslTokens.h rename to Modules/glslang/Sources/glslang/HLSL/hlslTokens.h diff --git a/Modules/glslang/glslang/HLSL/pch.h b/Modules/glslang/Sources/glslang/HLSL/pch.h similarity index 100% rename from Modules/glslang/glslang/HLSL/pch.h rename to Modules/glslang/Sources/glslang/HLSL/pch.h diff --git a/Modules/glslang/glslang/Include/BaseTypes.h b/Modules/glslang/Sources/glslang/Include/BaseTypes.h similarity index 100% rename from Modules/glslang/glslang/Include/BaseTypes.h rename to Modules/glslang/Sources/glslang/Include/BaseTypes.h diff --git a/Modules/glslang/glslang/Include/Common.h b/Modules/glslang/Sources/glslang/Include/Common.h similarity index 100% rename from Modules/glslang/glslang/Include/Common.h rename to Modules/glslang/Sources/glslang/Include/Common.h diff --git a/Modules/glslang/glslang/Include/ConstantUnion.h b/Modules/glslang/Sources/glslang/Include/ConstantUnion.h similarity index 100% rename from Modules/glslang/glslang/Include/ConstantUnion.h rename to Modules/glslang/Sources/glslang/Include/ConstantUnion.h diff --git a/Modules/glslang/glslang/Include/InfoSink.h b/Modules/glslang/Sources/glslang/Include/InfoSink.h similarity index 100% rename from Modules/glslang/glslang/Include/InfoSink.h rename to Modules/glslang/Sources/glslang/Include/InfoSink.h diff --git a/Modules/glslang/glslang/Include/InitializeGlobals.h b/Modules/glslang/Sources/glslang/Include/InitializeGlobals.h similarity index 100% rename from Modules/glslang/glslang/Include/InitializeGlobals.h rename to Modules/glslang/Sources/glslang/Include/InitializeGlobals.h diff --git a/Modules/glslang/glslang/Include/PoolAlloc.h b/Modules/glslang/Sources/glslang/Include/PoolAlloc.h similarity index 100% rename from Modules/glslang/glslang/Include/PoolAlloc.h rename to Modules/glslang/Sources/glslang/Include/PoolAlloc.h diff --git a/Modules/glslang/glslang/Include/ResourceLimits.h b/Modules/glslang/Sources/glslang/Include/ResourceLimits.h similarity index 100% rename from Modules/glslang/glslang/Include/ResourceLimits.h rename to Modules/glslang/Sources/glslang/Include/ResourceLimits.h diff --git a/Modules/glslang/glslang/Include/ShHandle.h b/Modules/glslang/Sources/glslang/Include/ShHandle.h similarity index 100% rename from Modules/glslang/glslang/Include/ShHandle.h rename to Modules/glslang/Sources/glslang/Include/ShHandle.h diff --git a/Modules/glslang/glslang/Include/SpirvIntrinsics.h b/Modules/glslang/Sources/glslang/Include/SpirvIntrinsics.h similarity index 100% rename from Modules/glslang/glslang/Include/SpirvIntrinsics.h rename to Modules/glslang/Sources/glslang/Include/SpirvIntrinsics.h diff --git a/Modules/glslang/glslang/Include/Types.h b/Modules/glslang/Sources/glslang/Include/Types.h similarity index 100% rename from Modules/glslang/glslang/Include/Types.h rename to Modules/glslang/Sources/glslang/Include/Types.h diff --git a/Modules/glslang/glslang/Include/arrays.h b/Modules/glslang/Sources/glslang/Include/arrays.h similarity index 100% rename from Modules/glslang/glslang/Include/arrays.h rename to Modules/glslang/Sources/glslang/Include/arrays.h diff --git a/Modules/glslang/glslang/Include/glslang_c_interface.h b/Modules/glslang/Sources/glslang/Include/glslang_c_interface.h similarity index 100% rename from Modules/glslang/glslang/Include/glslang_c_interface.h rename to Modules/glslang/Sources/glslang/Include/glslang_c_interface.h diff --git a/Modules/glslang/glslang/Include/glslang_c_shader_types.h b/Modules/glslang/Sources/glslang/Include/glslang_c_shader_types.h similarity index 100% rename from Modules/glslang/glslang/Include/glslang_c_shader_types.h rename to Modules/glslang/Sources/glslang/Include/glslang_c_shader_types.h diff --git a/Modules/glslang/glslang/Include/intermediate.h b/Modules/glslang/Sources/glslang/Include/intermediate.h similarity index 100% rename from Modules/glslang/glslang/Include/intermediate.h rename to Modules/glslang/Sources/glslang/Include/intermediate.h diff --git a/Modules/glslang/glslang/MachineIndependent/Constant.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/Constant.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Constant.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/Constant.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/InfoSink.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/InfoSink.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/InfoSink.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/InfoSink.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/Initialize.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/Initialize.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Initialize.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/Initialize.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/Initialize.h b/Modules/glslang/Sources/glslang/MachineIndependent/Initialize.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Initialize.h rename to Modules/glslang/Sources/glslang/MachineIndependent/Initialize.h diff --git a/Modules/glslang/glslang/MachineIndependent/IntermTraverse.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/IntermTraverse.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/IntermTraverse.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/IntermTraverse.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/Intermediate.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/Intermediate.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Intermediate.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/Intermediate.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/LiveTraverser.h b/Modules/glslang/Sources/glslang/MachineIndependent/LiveTraverser.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/LiveTraverser.h rename to Modules/glslang/Sources/glslang/MachineIndependent/LiveTraverser.h diff --git a/Modules/glslang/glslang/MachineIndependent/ParseContextBase.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/ParseContextBase.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/ParseContextBase.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/ParseContextBase.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/ParseHelper.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/ParseHelper.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/ParseHelper.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/ParseHelper.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/ParseHelper.h b/Modules/glslang/Sources/glslang/MachineIndependent/ParseHelper.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/ParseHelper.h rename to Modules/glslang/Sources/glslang/MachineIndependent/ParseHelper.h diff --git a/Modules/glslang/glslang/MachineIndependent/PoolAlloc.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/PoolAlloc.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/PoolAlloc.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/PoolAlloc.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/RemoveTree.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/RemoveTree.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/RemoveTree.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/RemoveTree.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/RemoveTree.h b/Modules/glslang/Sources/glslang/MachineIndependent/RemoveTree.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/RemoveTree.h rename to Modules/glslang/Sources/glslang/MachineIndependent/RemoveTree.h diff --git a/Modules/glslang/glslang/MachineIndependent/Scan.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/Scan.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Scan.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/Scan.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/Scan.h b/Modules/glslang/Sources/glslang/MachineIndependent/Scan.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Scan.h rename to Modules/glslang/Sources/glslang/MachineIndependent/Scan.h diff --git a/Modules/glslang/glslang/MachineIndependent/ScanContext.h b/Modules/glslang/Sources/glslang/MachineIndependent/ScanContext.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/ScanContext.h rename to Modules/glslang/Sources/glslang/MachineIndependent/ScanContext.h diff --git a/Modules/glslang/glslang/MachineIndependent/ShaderLang.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/ShaderLang.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/ShaderLang.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/ShaderLang.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/SpirvIntrinsics.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/SpirvIntrinsics.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/SpirvIntrinsics.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/SpirvIntrinsics.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/SymbolTable.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/SymbolTable.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/SymbolTable.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/SymbolTable.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/SymbolTable.h b/Modules/glslang/Sources/glslang/MachineIndependent/SymbolTable.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/SymbolTable.h rename to Modules/glslang/Sources/glslang/MachineIndependent/SymbolTable.h diff --git a/Modules/glslang/glslang/MachineIndependent/Versions.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/Versions.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Versions.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/Versions.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/Versions.h b/Modules/glslang/Sources/glslang/MachineIndependent/Versions.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/Versions.h rename to Modules/glslang/Sources/glslang/MachineIndependent/Versions.h diff --git a/Modules/glslang/glslang/MachineIndependent/attribute.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/attribute.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/attribute.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/attribute.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/attribute.h b/Modules/glslang/Sources/glslang/MachineIndependent/attribute.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/attribute.h rename to Modules/glslang/Sources/glslang/MachineIndependent/attribute.h diff --git a/Modules/glslang/glslang/MachineIndependent/gl_types.h b/Modules/glslang/Sources/glslang/MachineIndependent/gl_types.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/gl_types.h rename to Modules/glslang/Sources/glslang/MachineIndependent/gl_types.h diff --git a/Modules/glslang/glslang/MachineIndependent/glslang.m4 b/Modules/glslang/Sources/glslang/MachineIndependent/glslang.m4 similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/glslang.m4 rename to Modules/glslang/Sources/glslang/MachineIndependent/glslang.m4 diff --git a/Modules/glslang/glslang/MachineIndependent/glslang.y b/Modules/glslang/Sources/glslang/MachineIndependent/glslang.y similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/glslang.y rename to Modules/glslang/Sources/glslang/MachineIndependent/glslang.y diff --git a/Modules/glslang/glslang/MachineIndependent/glslang_tab.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/glslang_tab.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/glslang_tab.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/glslang_tab.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/glslang_tab.cpp.h b/Modules/glslang/Sources/glslang/MachineIndependent/glslang_tab.cpp.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/glslang_tab.cpp.h rename to Modules/glslang/Sources/glslang/MachineIndependent/glslang_tab.cpp.h diff --git a/Modules/glslang/glslang/MachineIndependent/intermOut.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/intermOut.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/intermOut.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/intermOut.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/iomapper.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/iomapper.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/iomapper.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/iomapper.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/iomapper.h b/Modules/glslang/Sources/glslang/MachineIndependent/iomapper.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/iomapper.h rename to Modules/glslang/Sources/glslang/MachineIndependent/iomapper.h diff --git a/Modules/glslang/glslang/MachineIndependent/limits.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/limits.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/limits.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/limits.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/linkValidate.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/linkValidate.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/linkValidate.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/linkValidate.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/localintermediate.h b/Modules/glslang/Sources/glslang/MachineIndependent/localintermediate.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/localintermediate.h rename to Modules/glslang/Sources/glslang/MachineIndependent/localintermediate.h diff --git a/Modules/glslang/glslang/MachineIndependent/parseConst.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/parseConst.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/parseConst.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/parseConst.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/parseVersions.h b/Modules/glslang/Sources/glslang/MachineIndependent/parseVersions.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/parseVersions.h rename to Modules/glslang/Sources/glslang/MachineIndependent/parseVersions.h diff --git a/Modules/glslang/glslang/MachineIndependent/pch.h b/Modules/glslang/Sources/glslang/MachineIndependent/pch.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/pch.h rename to Modules/glslang/Sources/glslang/MachineIndependent/pch.h diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/Pp.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/Pp.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpAtom.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpAtom.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpContext.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpContext.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/PpContext.h b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpContext.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/PpContext.h rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpContext.h diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpScanner.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpScanner.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpTokens.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpTokens.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h b/Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpTokens.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h rename to Modules/glslang/Sources/glslang/MachineIndependent/preprocessor/PpTokens.h diff --git a/Modules/glslang/glslang/MachineIndependent/propagateNoContraction.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/propagateNoContraction.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/propagateNoContraction.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/propagateNoContraction.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/propagateNoContraction.h b/Modules/glslang/Sources/glslang/MachineIndependent/propagateNoContraction.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/propagateNoContraction.h rename to Modules/glslang/Sources/glslang/MachineIndependent/propagateNoContraction.h diff --git a/Modules/glslang/glslang/MachineIndependent/reflection.cpp b/Modules/glslang/Sources/glslang/MachineIndependent/reflection.cpp similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/reflection.cpp rename to Modules/glslang/Sources/glslang/MachineIndependent/reflection.cpp diff --git a/Modules/glslang/glslang/MachineIndependent/reflection.h b/Modules/glslang/Sources/glslang/MachineIndependent/reflection.h similarity index 100% rename from Modules/glslang/glslang/MachineIndependent/reflection.h rename to Modules/glslang/Sources/glslang/MachineIndependent/reflection.h diff --git a/Modules/glslang/glslang/OSDependent/Unix/CMakeLists.txt b/Modules/glslang/Sources/glslang/OSDependent/Unix/CMakeLists.txt similarity index 100% rename from Modules/glslang/glslang/OSDependent/Unix/CMakeLists.txt rename to Modules/glslang/Sources/glslang/OSDependent/Unix/CMakeLists.txt diff --git a/Modules/glslang/glslang/OSDependent/Unix/ossource.cpp b/Modules/glslang/Sources/glslang/OSDependent/Unix/ossource.cpp similarity index 100% rename from Modules/glslang/glslang/OSDependent/Unix/ossource.cpp rename to Modules/glslang/Sources/glslang/OSDependent/Unix/ossource.cpp diff --git a/Modules/glslang/glslang/OSDependent/Web/CMakeLists.txt b/Modules/glslang/Sources/glslang/OSDependent/Web/CMakeLists.txt similarity index 100% rename from Modules/glslang/glslang/OSDependent/Web/CMakeLists.txt rename to Modules/glslang/Sources/glslang/OSDependent/Web/CMakeLists.txt diff --git a/Modules/glslang/glslang/OSDependent/Web/glslang.after.js b/Modules/glslang/Sources/glslang/OSDependent/Web/glslang.after.js similarity index 100% rename from Modules/glslang/glslang/OSDependent/Web/glslang.after.js rename to Modules/glslang/Sources/glslang/OSDependent/Web/glslang.after.js diff --git a/Modules/glslang/glslang/OSDependent/Web/glslang.js.cpp b/Modules/glslang/Sources/glslang/OSDependent/Web/glslang.js.cpp similarity index 100% rename from Modules/glslang/glslang/OSDependent/Web/glslang.js.cpp rename to Modules/glslang/Sources/glslang/OSDependent/Web/glslang.js.cpp diff --git a/Modules/glslang/glslang/OSDependent/Web/glslang.pre.js b/Modules/glslang/Sources/glslang/OSDependent/Web/glslang.pre.js similarity index 100% rename from Modules/glslang/glslang/OSDependent/Web/glslang.pre.js rename to Modules/glslang/Sources/glslang/OSDependent/Web/glslang.pre.js diff --git a/Modules/glslang/glslang/OSDependent/Windows/CMakeLists.txt b/Modules/glslang/Sources/glslang/OSDependent/Windows/CMakeLists.txt similarity index 100% rename from Modules/glslang/glslang/OSDependent/Windows/CMakeLists.txt rename to Modules/glslang/Sources/glslang/OSDependent/Windows/CMakeLists.txt diff --git a/Modules/glslang/glslang/OSDependent/Windows/ossource.cpp b/Modules/glslang/Sources/glslang/OSDependent/Windows/ossource.cpp similarity index 100% rename from Modules/glslang/glslang/OSDependent/Windows/ossource.cpp rename to Modules/glslang/Sources/glslang/OSDependent/Windows/ossource.cpp diff --git a/Modules/glslang/glslang/OSDependent/osinclude.h b/Modules/glslang/Sources/glslang/OSDependent/osinclude.h similarity index 100% rename from Modules/glslang/glslang/OSDependent/osinclude.h rename to Modules/glslang/Sources/glslang/OSDependent/osinclude.h diff --git a/Modules/glslang/glslang/Public/ResourceLimits.h b/Modules/glslang/Sources/glslang/Public/ResourceLimits.h similarity index 100% rename from Modules/glslang/glslang/Public/ResourceLimits.h rename to Modules/glslang/Sources/glslang/Public/ResourceLimits.h diff --git a/Modules/glslang/glslang/Public/ShaderLang.h b/Modules/glslang/Sources/glslang/Public/ShaderLang.h similarity index 100% rename from Modules/glslang/glslang/Public/ShaderLang.h rename to Modules/glslang/Sources/glslang/Public/ShaderLang.h diff --git a/Modules/glslang/glslang/Public/resource_limits_c.h b/Modules/glslang/Sources/glslang/Public/resource_limits_c.h similarity index 100% rename from Modules/glslang/glslang/Public/resource_limits_c.h rename to Modules/glslang/Sources/glslang/Public/resource_limits_c.h diff --git a/Modules/glslang/glslang/ResourceLimits/ResourceLimits.cpp b/Modules/glslang/Sources/glslang/ResourceLimits/ResourceLimits.cpp similarity index 100% rename from Modules/glslang/glslang/ResourceLimits/ResourceLimits.cpp rename to Modules/glslang/Sources/glslang/ResourceLimits/ResourceLimits.cpp diff --git a/Modules/glslang/glslang/ResourceLimits/resource_limits_c.cpp b/Modules/glslang/Sources/glslang/ResourceLimits/resource_limits_c.cpp similarity index 100% rename from Modules/glslang/glslang/ResourceLimits/resource_limits_c.cpp rename to Modules/glslang/Sources/glslang/ResourceLimits/resource_limits_c.cpp diff --git a/Modules/glslang/glslang/build_info.h b/Modules/glslang/Sources/glslang/build_info.h similarity index 100% rename from Modules/glslang/glslang/build_info.h rename to Modules/glslang/Sources/glslang/build_info.h diff --git a/Modules/glslang/glslang/updateGrammar b/Modules/glslang/Sources/glslang/updateGrammar similarity index 100% rename from Modules/glslang/glslang/updateGrammar rename to Modules/glslang/Sources/glslang/updateGrammar diff --git a/Sources/AtlasFontGenerator/AtlasFontGenerator.cpp b/Modules/msdf-atlas-gen/AtlasFontGenerator/AtlasFontGenerator.cpp similarity index 100% rename from Sources/AtlasFontGenerator/AtlasFontGenerator.cpp rename to Modules/msdf-atlas-gen/AtlasFontGenerator/AtlasFontGenerator.cpp diff --git a/Sources/AtlasFontGenerator/AtlasFontGenerator.h b/Modules/msdf-atlas-gen/AtlasFontGenerator/AtlasFontGenerator.h similarity index 100% rename from Sources/AtlasFontGenerator/AtlasFontGenerator.h rename to Modules/msdf-atlas-gen/AtlasFontGenerator/AtlasFontGenerator.h diff --git a/Sources/AtlasFontGenerator/BUILD.bazel b/Modules/msdf-atlas-gen/AtlasFontGenerator/BUILD.bazel similarity index 100% rename from Sources/AtlasFontGenerator/BUILD.bazel rename to Modules/msdf-atlas-gen/AtlasFontGenerator/BUILD.bazel diff --git a/Sources/AtlasFontGenerator/FontHolder.cpp b/Modules/msdf-atlas-gen/AtlasFontGenerator/FontHolder.cpp similarity index 100% rename from Sources/AtlasFontGenerator/FontHolder.cpp rename to Modules/msdf-atlas-gen/AtlasFontGenerator/FontHolder.cpp diff --git a/Sources/AtlasFontGenerator/FontHolder.h b/Modules/msdf-atlas-gen/AtlasFontGenerator/FontHolder.h similarity index 100% rename from Sources/AtlasFontGenerator/FontHolder.h rename to Modules/msdf-atlas-gen/AtlasFontGenerator/FontHolder.h diff --git a/Sources/AtlasFontGenerator/atlas_font_gen.cpp b/Modules/msdf-atlas-gen/AtlasFontGenerator/atlas_font_gen.cpp similarity index 100% rename from Sources/AtlasFontGenerator/atlas_font_gen.cpp rename to Modules/msdf-atlas-gen/AtlasFontGenerator/atlas_font_gen.cpp diff --git a/Sources/AtlasFontGenerator/include/atlas_font_gen.h b/Modules/msdf-atlas-gen/AtlasFontGenerator/include/atlas_font_gen.h similarity index 100% rename from Sources/AtlasFontGenerator/include/atlas_font_gen.h rename to Modules/msdf-atlas-gen/AtlasFontGenerator/include/atlas_font_gen.h diff --git a/Sources/AtlasFontGenerator/module.modulemap b/Modules/msdf-atlas-gen/AtlasFontGenerator/module.modulemap similarity index 100% rename from Sources/AtlasFontGenerator/module.modulemap rename to Modules/msdf-atlas-gen/AtlasFontGenerator/module.modulemap diff --git a/Modules/msdf-atlas-gen/Package.swift b/Modules/msdf-atlas-gen/Package.swift index abf8a708b..b2f1b9881 100644 --- a/Modules/msdf-atlas-gen/Package.swift +++ b/Modules/msdf-atlas-gen/Package.swift @@ -14,13 +14,20 @@ let package = Package( ], products: [ .library( - name: "MSDFAtlasGen", - targets: ["MSDFAtlasGen"] + name: "AtlasFontGenerator", + targets: ["AtlasFontGenerator"] ) ], targets: [ .target( - name: "MSDFGen", + name: "AtlasFontGenerator", + dependencies: [ + "MSDFAtlasGen", + ], + path: "AtlasFontGenerator" + ), + .target( + name: "msdfgen", dependencies: [ "freetype", "tinyxml" @@ -35,7 +42,7 @@ let package = Package( .target( name: "MSDFAtlasGen", dependencies: [ - "MSDFGen" + "msdfgen" ], path: "msdf-atlas-gen", publicHeadersPath: ".", diff --git a/Package.swift b/Package.swift index 6c8e5c217..aa93a0327 100644 --- a/Package.swift +++ b/Package.swift @@ -129,12 +129,12 @@ var adaEngineDependencies: [Target.Dependency] = [ .product(name: "Collections", package: "swift-collections"), .product(name: "BitCollections", package: "swift-collections"), .product(name: "Logging", package: "swift-log"), + .product(name: "AtlasFontGenerator", package: "msdf-atlas-gen"), + .product(name: "SPIRVCompiler", package: "glslang"), "miniaudio", - "AtlasFontGenerator", "Yams", "libpng", "SPIRV-Cross", - "SPIRVCompiler", "box2d", "AdaEngineMacros" ] @@ -200,7 +200,7 @@ var targets: [Target] = [ // MARK: Extra -#if os(Android) || os(Linux) +#if os(Linux) targets += [ .systemLibrary( name: "X11", @@ -211,28 +211,6 @@ targets += [ ] #endif -// MARK: - CXX Internal Targets - -targets += [ - .target( - name: "AtlasFontGenerator", - dependencies: [ - .product(name: "MSDFAtlasGen", package: "msdf-atlas-gen") - ], - publicHeadersPath: "include" - ), - .target( - name: "SPIRVCompiler", - dependencies: [ - "glslang" - ], - publicHeadersPath: ".", - linkerSettings: [ - .linkedLibrary("m", .when(platforms: [.linux])) - ] - ) -] - // MARK: - Tests targets += [ From eed4aa29e20d9b68e388f170a8ddaa68654d3584 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Wed, 23 Apr 2025 12:58:23 +0300 Subject: [PATCH 02/11] Fix capitalized --- Sources/AdaEngineMacros/ComponentMacro.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/AdaEngineMacros/ComponentMacro.swift b/Sources/AdaEngineMacros/ComponentMacro.swift index d57d735d9..7c066f3af 100644 --- a/Sources/AdaEngineMacros/ComponentMacro.swift +++ b/Sources/AdaEngineMacros/ComponentMacro.swift @@ -5,6 +5,7 @@ // Created by v.prusakov on 2/14/24. // +import Foundation import SwiftDiagnostics import SwiftOperators import SwiftSyntax From 65bc89a2fa980f228ed9cbabb34e9b92ecbb07c5 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Wed, 23 Apr 2025 13:17:56 +0300 Subject: [PATCH 03/11] Fix x11 --- Package.swift | 13 ++++++++----- .../Platforms/Linux/LinuxApplication.swift | 4 +++- .../Platforms/Linux/LinuxWindowManager.swift | 4 +++- Sources/X11/{x11-umbrella => macros.h} | 0 Sources/X11/module.modulemap | 12 ++++++++---- 5 files changed, 22 insertions(+), 11 deletions(-) rename Sources/X11/{x11-umbrella => macros.h} (100%) diff --git a/Package.swift b/Package.swift index aa93a0327..06afb886a 100644 --- a/Package.swift +++ b/Package.swift @@ -92,7 +92,9 @@ var swiftSettings: [SwiftSetting] = [ if isVulkanEnabled { swiftSettings.append(.define("VULKAN")) } else { + #if canImport(Metal) swiftSettings.append(.define("METAL")) + #endif } let editorTarget: Target = .executableTarget( @@ -202,12 +204,13 @@ var targets: [Target] = [ #if os(Linux) targets += [ - .systemLibrary( + .target( name: "X11", - pkgConfig: "x11", - providers: [ - .apt(["libx11-dev"]) - ]), + exclude: [ + "BUILD.bazel" + ], + publicHeadersPath: "." + ) ] #endif diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift index 9d0675119..60460b2f0 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift @@ -6,7 +6,9 @@ // #if LINUX -import X11 +import X11.Xlib +import X11.X + final class LinuxApplication: Application { override init(argc: Int32, argv: UnsafeMutablePointer?>) throws { diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift index d346a6189..108bf1f41 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift @@ -6,7 +6,9 @@ // #if LINUX -import X11 +import X11.Xlib +import X11.X + final class LinuxWindowManager: WindowManager { diff --git a/Sources/X11/x11-umbrella b/Sources/X11/macros.h similarity index 100% rename from Sources/X11/x11-umbrella rename to Sources/X11/macros.h diff --git a/Sources/X11/module.modulemap b/Sources/X11/module.modulemap index 3370c9cd4..f445ecf24 100644 --- a/Sources/X11/module.modulemap +++ b/Sources/X11/module.modulemap @@ -1,6 +1,10 @@ module X11 [system] { - umbrella header "x11-umbrella.h" + header "macros.h" + module Xlib { + header "/usr/include/X11/Xlib.h" + } + module X { + header "/usr/include/X11/X.h" + } link "X11" - export * - module * { export * } -} +} \ No newline at end of file From f9de45cad96315326ad61b22506fb1d5e3eeab1a Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Thu, 24 Apr 2025 21:33:23 +0300 Subject: [PATCH 04/11] some updates --- Package.swift | 13 +++++++++++-- Sources/OpenGL/OpenGL.h | 8 ++++++++ Sources/OpenGL/module.modulemap | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Sources/OpenGL/OpenGL.h create mode 100644 Sources/OpenGL/module.modulemap diff --git a/Package.swift b/Package.swift index 06afb886a..63fa83f71 100644 --- a/Package.swift +++ b/Package.swift @@ -142,7 +142,11 @@ var adaEngineDependencies: [Target.Dependency] = [ ] #if os(Linux) -adaEngineDependencies += ["X11"] + +adaEngineDependencies += [ + "X11", + "OpenGL" +] #endif let adaEngineTarget: Target = .target( @@ -210,7 +214,12 @@ targets += [ "BUILD.bazel" ], publicHeadersPath: "." - ) + ), + .systemLibrary( + name: "OpenGL", + pkgConfig: "gl", + providers: [.apt(["libglu1-mesa-dev", "mesa-common-dev"])] + ), ] #endif diff --git a/Sources/OpenGL/OpenGL.h b/Sources/OpenGL/OpenGL.h new file mode 100644 index 000000000..d0b466c46 --- /dev/null +++ b/Sources/OpenGL/OpenGL.h @@ -0,0 +1,8 @@ +#ifdef __APPLE__ +#include +#else +#include +#include +#include +#include +#endif \ No newline at end of file diff --git a/Sources/OpenGL/module.modulemap b/Sources/OpenGL/module.modulemap new file mode 100644 index 000000000..1fc2528d5 --- /dev/null +++ b/Sources/OpenGL/module.modulemap @@ -0,0 +1,5 @@ +module OpenGL [system] { + umbrella header "OpenGL.h" + link "GL" + export * +} \ No newline at end of file From 910ecdf3ee8d24a41a0b30b3fc58881712d69926 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Sat, 26 Apr 2025 18:53:38 +0300 Subject: [PATCH 05/11] some updates --- Modules/libpng/Package.swift | 6 +++++- Package.swift | 11 +++++------ .../AdaEngine/Platforms/Linux/LinuxApplication.swift | 3 +-- .../Platforms/Linux/LinuxWindowManager.swift | 10 +++------- .../Backends/OpenGL/Misc/OpenGLTexture.swift | 2 ++ .../Rendering/Backends/OpenGL/OpenGLBackend.swift | 11 ----------- .../AdaEngine/Scene/Physics/Physics2D/Body2D.swift | 2 +- .../Physics/Physics2D/DebugPhysics2DSystem.swift | 2 +- .../Scene/Physics/Physics2D/Physics2DSystem.swift | 2 +- .../Scene/Physics/Physics2D/PhysicsWorld2D.swift | 2 +- Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift | 2 +- Sources/AdaEngine/Text/Font/FontHandle.swift | 2 +- Sources/AdaEngine/UI/DSL/ScrollViewReader.swift | 2 ++ Sources/AdaEngine/Utils/FileWatcher.swift | 5 ++++- Sources/X11/module.modulemap | 10 +++------- 15 files changed, 31 insertions(+), 41 deletions(-) diff --git a/Modules/libpng/Package.swift b/Modules/libpng/Package.swift index 94c4f8d25..3c40442cd 100644 --- a/Modules/libpng/Package.swift +++ b/Modules/libpng/Package.swift @@ -48,6 +48,10 @@ let package = Package( publicHeadersPath: "include", cSettings: [ .define("PNG_ARM_NEON_OPT", to: useNeon ? "2" : "0") - ]) + ], + linkerSettings: [ + .linkedFramework("z", .when(platforms: [.linux])) + ] + ) ] ) diff --git a/Package.swift b/Package.swift index 63fa83f71..56efc9224 100644 --- a/Package.swift +++ b/Package.swift @@ -161,7 +161,8 @@ let adaEngineTarget: Target = .target( .copy("Assets/Images") ], cSettings: [ - .define("GL_SILENCE_DEPRECATION") + .define("GL_SILENCE_DEPRECATION", .when(platforms: applePlatforms)), + .define("GL_GLEXT_PROTOTYPES", .when(platforms: [.android, .linux, .windows])), ], swiftSettings: adaEngineSwiftSettings, plugins: commonPlugins @@ -208,12 +209,10 @@ var targets: [Target] = [ #if os(Linux) targets += [ - .target( + .systemLibrary( name: "X11", - exclude: [ - "BUILD.bazel" - ], - publicHeadersPath: "." + pkgConfig: "x11", + providers: [.apt(["libx11-dev"])] ), .systemLibrary( name: "OpenGL", diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift index 60460b2f0..229fe9efe 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift @@ -6,8 +6,7 @@ // #if LINUX -import X11.Xlib -import X11.X +import X11 final class LinuxApplication: Application { diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift index 108bf1f41..5ce0b6f68 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift @@ -6,16 +6,12 @@ // #if LINUX -import X11.Xlib -import X11.X +import X11 - -final class LinuxWindowManager: WindowManager { - - override func createWindow(for window: Window) { +final class LinuxWindowManager: UIWindowManager { + override func createWindow(for window: UIWindow) { fatalErrorMethodNotImplemented() } - } #endif diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift index 75f6f0b2d..5a460f90d 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift @@ -107,6 +107,7 @@ final class OpenGLTexture: GPUTexture { pointer?.baseAddress ) case .texture2DMultisample, .texture2DMultisampleArray: + #if !os(Linux) glTexImage2DMultisample( glType, GLsizei(0), @@ -115,6 +116,7 @@ final class OpenGLTexture: GPUTexture { GLsizei(descriptor.height), GLboolean(GL_TRUE) ) + #endif default: fatalErrorMethodNotImplemented() } diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift index 3d1af04e8..2d06d6933 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift @@ -34,17 +34,6 @@ final class OpenGLBackend: RenderBackend { init(appName: String) { self.context = Context() self.renderDevice = OpenGLRenderDevice(context: context) - - #if !METAL && DEBUG - glEnable(GLenum(GL_DEBUG_OUTPUT)) - glEnable(GLenum(GL_DEBUG_OUTPUT_SYNCHRONOUS)) - glDebugMessageCallback({ (source: GLenum, type: GLenum, id: GLuint, severity: GLenum, length: GLsizei, message: UnsafePointer?, userParam: UnsafeMutableRawPointer?) in - let msg = String(cString: message!) - print("OpenGL Debug Message: \(msg)") - }, nil) - - glDebugMessageControl(GLenum(GL_DONT_CARE), GLenum(GL_DONT_CARE), GLenum(GL_DEBUG_SEVERITY_NOTIFICATION), 0, nil, GLboolean(GL_FALSE)) - #endif } func createLocalRenderDevice() -> any RenderDevice { diff --git a/Sources/AdaEngine/Scene/Physics/Physics2D/Body2D.swift b/Sources/AdaEngine/Scene/Physics/Physics2D/Body2D.swift index e61e4a32b..6ff27d0b0 100644 --- a/Sources/AdaEngine/Scene/Physics/Physics2D/Body2D.swift +++ b/Sources/AdaEngine/Scene/Physics/Physics2D/Body2D.swift @@ -5,7 +5,7 @@ // Created by v.prusakov on 3/19/23. // -@_implementationOnly import box2d +import box2d import Math // An object that represents physics 2D body. diff --git a/Sources/AdaEngine/Scene/Physics/Physics2D/DebugPhysics2DSystem.swift b/Sources/AdaEngine/Scene/Physics/Physics2D/DebugPhysics2DSystem.swift index 5d6d76ae5..daba79668 100644 --- a/Sources/AdaEngine/Scene/Physics/Physics2D/DebugPhysics2DSystem.swift +++ b/Sources/AdaEngine/Scene/Physics/Physics2D/DebugPhysics2DSystem.swift @@ -5,7 +5,7 @@ // Created by v.prusakov on 2/26/23. // -@_implementationOnly import box2d +import box2d import Math @Component diff --git a/Sources/AdaEngine/Scene/Physics/Physics2D/Physics2DSystem.swift b/Sources/AdaEngine/Scene/Physics/Physics2D/Physics2DSystem.swift index be56af71e..667a143e5 100644 --- a/Sources/AdaEngine/Scene/Physics/Physics2D/Physics2DSystem.swift +++ b/Sources/AdaEngine/Scene/Physics/Physics2D/Physics2DSystem.swift @@ -5,7 +5,7 @@ // Created by v.prusakov on 7/8/22. // -@_implementationOnly import box2d +import box2d import Math // - TODO: (Vlad) Runtime update shape resource diff --git a/Sources/AdaEngine/Scene/Physics/Physics2D/PhysicsWorld2D.swift b/Sources/AdaEngine/Scene/Physics/Physics2D/PhysicsWorld2D.swift index 7ea1e8ad2..59ce4af35 100644 --- a/Sources/AdaEngine/Scene/Physics/Physics2D/PhysicsWorld2D.swift +++ b/Sources/AdaEngine/Scene/Physics/Physics2D/PhysicsWorld2D.swift @@ -5,7 +5,7 @@ // Created by v.prusakov on 7/6/22. // -@_implementationOnly import box2d +import box2d import Math public protocol PhysicsWorld2DDelegate: AnyObject { diff --git a/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift b/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift index baf88101d..2206ca42d 100644 --- a/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift +++ b/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift @@ -5,7 +5,7 @@ // Created by v.prusakov on 3/5/23. // -@_implementationOnly import AtlasFontGenerator +import AtlasFontGenerator import Foundation public struct FontDescriptor { diff --git a/Sources/AdaEngine/Text/Font/FontHandle.swift b/Sources/AdaEngine/Text/Font/FontHandle.swift index 3f8237392..e41cec909 100644 --- a/Sources/AdaEngine/Text/Font/FontHandle.swift +++ b/Sources/AdaEngine/Text/Font/FontHandle.swift @@ -5,7 +5,7 @@ // Created by v.prusakov on 3/19/23. // -@_implementationOnly import AtlasFontGenerator +import AtlasFontGenerator /// Hold information about font data and atlas. final class FontHandle: Hashable, @unchecked Sendable { diff --git a/Sources/AdaEngine/UI/DSL/ScrollViewReader.swift b/Sources/AdaEngine/UI/DSL/ScrollViewReader.swift index b57871119..7c4bc58ae 100644 --- a/Sources/AdaEngine/UI/DSL/ScrollViewReader.swift +++ b/Sources/AdaEngine/UI/DSL/ScrollViewReader.swift @@ -5,6 +5,8 @@ // Created by Vladislav Prusakov on 26.07.2024. // +import Observation + /// A proxy value that supports programmatic scrolling of the scrollable views within a view hierarchy. /// /// You don’t create instances of ScrollViewProxy directly. diff --git a/Sources/AdaEngine/Utils/FileWatcher.swift b/Sources/AdaEngine/Utils/FileWatcher.swift index e74c509b7..e0b467582 100644 --- a/Sources/AdaEngine/Utils/FileWatcher.swift +++ b/Sources/AdaEngine/Utils/FileWatcher.swift @@ -28,6 +28,7 @@ public final class FileWatcher { } public func observe(on queue: DispatchQueue? = nil, block: @escaping (FileWatcher.Event) -> Void) throws -> Cancellable { + #if !os(Linux) let handle = open(url.path(), O_EVTONLY) if handle == -1 { @@ -78,6 +79,8 @@ public final class FileWatcher { source.resume() return AnyCancellable(cancel) + #else + fatalError("FileWatcher is not supported on Linux") + #endif } - } diff --git a/Sources/X11/module.modulemap b/Sources/X11/module.modulemap index f445ecf24..da445eb3f 100644 --- a/Sources/X11/module.modulemap +++ b/Sources/X11/module.modulemap @@ -1,10 +1,6 @@ module X11 [system] { - header "macros.h" - module Xlib { - header "/usr/include/X11/Xlib.h" - } - module X { - header "/usr/include/X11/X.h" - } + umbrella header "macros.h" link "X11" + export * + module * { export * } } \ No newline at end of file From b37a29f42ceb76bc032e2bef389fce43958e3163 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Fri, 16 May 2025 00:13:09 +0300 Subject: [PATCH 06/11] Add wayland interface --- Package.swift | 34 +++-- .../Platforms/Linux/LinuxApplication.swift | 3 +- .../Platforms/Linux/LinuxWindowManager.swift | 107 ++++++++++++++- .../Platforms/Linux/WaylandView.swift | 125 ++++++++++++++++++ .../Backends/OpenGL/Misc/OpenGLBuffer.swift | 4 + .../OpenGL/Misc/OpenGLFramebuffer.swift | 4 + .../OpenGL/Misc/OpenGLRenderPipeline.swift | 4 + .../Backends/OpenGL/Misc/OpenGLSampler.swift | 4 + .../Backends/OpenGL/Misc/OpenGLShader.swift | 4 + .../Backends/OpenGL/Misc/OpenGLTexture.swift | 4 + .../OpenGL/Misc/OpenGLUniformBuffer.swift | 3 + .../OpenGL/Misc/OpenGLVertexBuffer.swift | 4 + .../Backends/OpenGL/OpenGLBackend.swift | 4 + .../Backends/OpenGL/OpenGLContext.swift | 4 + .../Backends/OpenGL/OpenGLRenderDevice.swift | 4 + .../Backends/Vulkan/Misc/VulkanBuffer.swift | 2 +- .../Vulkan/Misc/VulkanFramebuffer.swift | 2 +- .../Vulkan/Misc/VulkanIndexBuffer.swift | 2 +- .../Vulkan/Misc/VulkanRenderPipeline.swift | 2 +- .../Backends/Vulkan/Misc/VulkanSampler.swift | 1 - .../Backends/Vulkan/Misc/VulkanShader.swift | 2 +- .../Vulkan/Misc/VulkanUniformBuffer.swift | 2 +- .../Vulkan/Misc/VulkanVertexBuffer.swift | 2 +- .../Backends/Vulkan/VulkanRenderBackend.swift | 2 +- .../Backends/Vulkan/VulkanRenderContext.swift | 124 ++++++++++++++++- .../AdaEngine/Rendering/RenderEngine.swift | 30 ++++- .../AssetsCodable/TextAssetEncoder.swift | 6 +- .../Text/Font/FontAtlasGenerator.swift | 8 +- Sources/CVulkan/cvulkan.h | 1 - Sources/CVulkan/module.modulemap | 2 +- Sources/Vulkan/Buffer.swift | 2 +- Sources/Vulkan/CommandBuffer.swift | 2 +- .../Definitions/DeviceQueueCreateInfo.swift | 2 +- .../Definitions/QueueFamilyProperties.swift | 2 +- Sources/Vulkan/Definitions/VKError.swift | 5 + Sources/Vulkan/Surface.swift | 36 +---- Sources/Wayland/module.modulemap | 5 + Sources/Wayland/wayland.h | 1 + utils/scripts/install_vulkan_macos.sh | 92 +++++++++++++ 39 files changed, 564 insertions(+), 83 deletions(-) create mode 100644 Sources/AdaEngine/Platforms/Linux/WaylandView.swift create mode 100644 Sources/Wayland/module.modulemap create mode 100644 Sources/Wayland/wayland.h create mode 100755 utils/scripts/install_vulkan_macos.sh diff --git a/Package.swift b/Package.swift index 56efc9224..686fe50ed 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ import AppleProductTypes #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) import Darwin.C -let isVulkanEnabled = false +let isVulkanEnabled = true #else #if os(Linux) @@ -23,7 +23,7 @@ import Glibc import WinSDK #endif -let isVulkanEnabled = false +let isVulkanEnabled = true #endif let applePlatforms: [Platform] = [.iOS, .macOS, .tvOS, .watchOS, .visionOS] @@ -142,10 +142,9 @@ var adaEngineDependencies: [Target.Dependency] = [ ] #if os(Linux) - adaEngineDependencies += [ - "X11", - "OpenGL" + "Wayland", + // "OpenGL" ] #endif @@ -210,15 +209,20 @@ var targets: [Target] = [ #if os(Linux) targets += [ .systemLibrary( - name: "X11", - pkgConfig: "x11", - providers: [.apt(["libx11-dev"])] - ), - .systemLibrary( - name: "OpenGL", - pkgConfig: "gl", - providers: [.apt(["libglu1-mesa-dev", "mesa-common-dev"])] + name: "Wayland", + pkgConfig: "wayland-client", + providers: [.apt(["libwayland-dev"])] ), + // .systemLibrary( + // name: "X11", + // pkgConfig: "x11", + // providers: [.apt(["libx11-dev"])] + // ), + // .systemLibrary( + // name: "OpenGL", + // pkgConfig: "gl", + // providers: [.apt(["libglu1-mesa-dev", "mesa-common-dev"])] + // ), ] #endif @@ -304,6 +308,10 @@ if isVulkanEnabled { // Windows .define("VK_USE_PLATFORM_WIN32_KHR", .when(platforms: [.windows])), + + // Linux + .define("VK_USE_PLATFORM_XCB_KHR", .when(platforms: [.linux])), + .define("VK_USE_PLATFORM_WAYLAND_KHR", .when(platforms: [.linux])), ] ), .systemLibrary( diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift index 229fe9efe..b67bbaeb0 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift @@ -6,8 +6,7 @@ // #if LINUX -import X11 - +import Wayland final class LinuxApplication: Application { override init(argc: Int32, argv: UnsafeMutablePointer?>) throws { diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift index 5ce0b6f68..ce9fbe665 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift @@ -6,12 +6,115 @@ // #if LINUX -import X11 +import Wayland +@MainActor final class LinuxWindowManager: UIWindowManager { + private(set) var display: OpaquePointer? + private(set) var registry: OpaquePointer? + private(set) var compositor: OpaquePointer? + private(set) var shell: OpaquePointer? + private(set) var shm: OpaquePointer? + + override init() { + super.init() + Task { @MainActor in + setupWayland() + } + } + + private func setupWayland() { + display = wl_display_connect(nil) + guard display != nil else { + fatalError("Failed to connect to Wayland display") + } + + registry = wl_display_get_registry(display) + wl_registry_add_listener(registry, ®istryListener, UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())) + wl_display_roundtrip(display) + } + override func createWindow(for window: UIWindow) { - fatalErrorMethodNotImplemented() + let minSize = UIWindow.defaultMinimumSize + let frame = window.frame + let size = frame.size == .zero ? minSize : frame.size + + let waylandView = WaylandView(windowId: window.id, frame: frame) + let sizeInt = SizeInt(width: Int(size.width), height: Int(size.height)) + + try? RenderEngine.shared.createWindow(window.id, for: waylandView, size: sizeInt) + + window.systemWindow = waylandView + window.minSize = minSize + + super.createWindow(for: window) + } + + override func resizeWindow(_ window: UIWindow, size: Size) { + guard let waylandView = window.systemWindow as? WaylandView else { return } + waylandView.resize(to: size) + } + + override func setWindowMode(_ window: UIWindow, mode: UIWindow.Mode) { + guard let waylandView = window.systemWindow as? WaylandView else { return } + waylandView.setWindowMode(mode) + } + + override func closeWindow(_ window: UIWindow) { + guard let waylandView = window.systemWindow as? WaylandView else { return } + waylandView.close() + } + + override func showWindow(_ window: UIWindow, isFocused: Bool) { + guard let waylandView = window.systemWindow as? WaylandView else { return } + waylandView.show(isFocused: isFocused) + } + + override func setMinimumSize(_ size: Size, for window: UIWindow) { + guard let waylandView = window.systemWindow as? WaylandView else { return } + waylandView.setMinimumSize(size) + } + + override func updateCursor() { + // Implement cursor updates for Wayland + } + + override func getScreen(for window: UIWindow) -> Screen? { + // Implement screen information for Wayland + return nil + } + + deinit { + // if let registry = registry { + // wl_registry_destroy(registry) + // } + // if let display = display { + // wl_display_disconnect(display) + // } } } +extension WaylandView: RenderSurface {} + +// Wayland registry listener +nonisolated(unsafe) +private var registryListener = wl_registry_listener( + global: { data, registry, id, interface, version in + let windowManager = Unmanaged.fromOpaque(data!).takeUnretainedValue() + let interfaceName = String(cString: interface!) + + // switch interfaceName { + // case "wl_compositor": + // windowManager.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, min(version, 4)) + // case "wl_shell": + // windowManager.shell = wl_registry_bind(registry, id, wl_shell_interface, min(version, 1)) + // case "wl_shm": + // windowManager.shm = wl_registry_bind(registry, id, wl_shm_interface, min(version, 1)) + // default: + // break + // } + }, + global_remove: { _, _, _ in } +) + #endif diff --git a/Sources/AdaEngine/Platforms/Linux/WaylandView.swift b/Sources/AdaEngine/Platforms/Linux/WaylandView.swift new file mode 100644 index 000000000..73ac12a1b --- /dev/null +++ b/Sources/AdaEngine/Platforms/Linux/WaylandView.swift @@ -0,0 +1,125 @@ +#if LINUX +import Wayland +import Math + +@MainActor +final class WaylandView: SystemWindow { + private(set) var surface: OpaquePointer? + private(set) var shellSurface: OpaquePointer? + private(set) var window: OpaquePointer? + private var frame: Rect + private var _title: String = "" + private var _position: Point = .zero + private var _minSize: Size = .zero + + let windowId: UIWindow.ID + + init(windowId: UIWindow.ID, frame: Rect) { + self.windowId = windowId + self.frame = frame + setupWaylandSurface() + } + + private func setupWaylandSurface() { + guard let windowManager = Application.shared.windowManager as? LinuxWindowManager else { + fatalError("Window manager is not LinuxWindowManager") + } + + // Create surface + surface = wl_compositor_create_surface(windowManager.compositor) + guard surface != nil else { + fatalError("Failed to create Wayland surface") + } + + // Create shell surface + shellSurface = wl_shell_get_shell_surface(windowManager.shell, surface) + guard shellSurface != nil else { + fatalError("Failed to create shell surface") + } + + // Set up shell surface callbacks + wl_shell_surface_add_listener(shellSurface, &shellSurfaceListener, UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())) + + // Set initial window properties + wl_shell_surface_set_title(shellSurface, _title) + wl_shell_surface_set_toplevel(shellSurface) + } + + // MARK: - SystemWindow Protocol + + var title: String { + get { _title } + set { + _title = newValue + wl_shell_surface_set_title(shellSurface, newValue) + } + } + + var size: Size { + get { frame.size } + set { + frame.size = newValue + wl_surface_commit(surface) + } + } + + var position: Point { + get { _position } + set { + _position = newValue + frame.origin = newValue + wl_surface_commit(surface) + } + } + + func resize(to size: Size) { + self.size = size + } + + func setWindowMode(_ mode: UIWindow.Mode) { + switch mode { + case .windowed: + wl_shell_surface_set_toplevel(shellSurface) + case .fullscreen: + fatalError("fullscreen") + // wl_shell_surface_set_fullscreen(shellSurface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, nil) + } + } + + func close() { + if let shellSurface = shellSurface { + wl_shell_surface_destroy(shellSurface) + } + if let surface = surface { + wl_surface_destroy(surface) + } + } + + func show(isFocused: Bool) { + wl_surface_commit(surface) + } + + func setMinimumSize(_ size: Size) { + _minSize = size + } + + deinit { + // close() + } +} + +// Wayland shell surface listener +nonisolated(unsafe) +private var shellSurfaceListener = wl_shell_surface_listener( + ping: { _, shellSurface, serial in + wl_shell_surface_pong(shellSurface, serial) + }, + configure: { _, shellSurface, edges, width, height in + // Handle window configuration changes + }, + popup_done: { _, _ in + // Handle popup done event + } +) + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLBuffer.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLBuffer.swift index eff911fa5..a4a5edcc5 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLBuffer.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -73,3 +75,5 @@ extension ResourceOptions { } } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLFramebuffer.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLFramebuffer.swift index aa05bd3e7..7d38b8c94 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLFramebuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLFramebuffer.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -179,3 +181,5 @@ final class OpenGLFramebuffer: Framebuffer, @unchecked Sendable { glBindFramebuffer(GLenum(GL_FRAMEBUFFER), 0) } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLRenderPipeline.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLRenderPipeline.swift index f6bf65d46..5f904833f 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLRenderPipeline.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLRenderPipeline.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -38,3 +40,5 @@ final class OpenGLRenderPipeline: RenderPipeline { self.program.validate() } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLSampler.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLSampler.swift index 5842ae924..9e23abaac 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLSampler.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLSampler.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -43,3 +45,5 @@ final class OpenGLSampler: Sampler { glBindSampler(0, sampler) } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLShader.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLShader.swift index 47fe0a5d7..7b87a60b3 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLShader.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLShader.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -124,3 +126,5 @@ final class OpenGLProgram: @unchecked Sendable { glDeleteProgram(program) } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift index 5a460f90d..51e44d68b 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLTexture.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -274,3 +276,5 @@ struct OpenGLError: LocalizedError { return "OpenGL error \(error)" } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLUniformBuffer.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLUniformBuffer.swift index 30aff1491..06a2ab3bd 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLUniformBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLUniformBuffer.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -32,3 +34,4 @@ final class OpenGLUniformBuffer: OpenGLBuffer, UniformBuffer, @unchecked Sendabl } } +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLVertexBuffer.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLVertexBuffer.swift index f965961c5..281fafc41 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLVertexBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/Misc/OpenGLVertexBuffer.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -28,3 +30,5 @@ final class OpenGLVertexBuffer: OpenGLBuffer, VertexBuffer, @unchecked Sendable glBindBufferBase(target, GLuint(binding), buffer) } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift index 2d06d6933..0c81993ed 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLBackend.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -65,3 +67,5 @@ final class OpenGLBackend: RenderBackend { currentFrameIndex = (currentFrameIndex + 1) % RenderEngine.configurations.maxFramesInFlight } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLContext.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLContext.swift index bfd4c989e..e857d229a 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLContext.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLContext.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -148,3 +150,5 @@ extension NSOpenGLContext: OpenGLContext { } } #endif + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLRenderDevice.swift b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLRenderDevice.swift index a8aa30b83..1cc3eae11 100644 --- a/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLRenderDevice.swift +++ b/Sources/AdaEngine/Rendering/Backends/OpenGL/OpenGLRenderDevice.swift @@ -5,6 +5,8 @@ // Created by vladislav.prusakov on 13.03.2025. // +#if ENABLE_OPENGL + #if WASM import WebGL #endif @@ -260,3 +262,5 @@ extension TriangleFillMode { } } } + +#endif \ No newline at end of file diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanBuffer.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanBuffer.swift index 1bd7784e0..836f9e58f 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanBuffer.swift @@ -9,7 +9,7 @@ import CVulkan import Vulkan -class VulkanBuffer: Buffer { +class VulkanBuffer: Buffer, @unchecked Sendable { private let buffer: Vulkan.Buffer private unowned let logicalDevice: Device diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanFramebuffer.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanFramebuffer.swift index 321e78bbe..17fa72071 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanFramebuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanFramebuffer.swift @@ -10,7 +10,7 @@ import CVulkan import Vulkan import Math -final class VulkanFramebuffer: Framebuffer { +final class VulkanFramebuffer: Framebuffer, @unchecked Sendable { private(set) var attachments: [FramebufferAttachment] private(set) var descriptor: FramebufferDescriptor diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanIndexBuffer.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanIndexBuffer.swift index 6a7250137..199995ce2 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanIndexBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanIndexBuffer.swift @@ -9,7 +9,7 @@ import CVulkan import Vulkan -final class VulkanIndexBuffer: VulkanBuffer, IndexBuffer { +final class VulkanIndexBuffer: VulkanBuffer, IndexBuffer, @unchecked Sendable { let indexFormat: IndexBufferFormat diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanRenderPipeline.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanRenderPipeline.swift index f739e79d6..ef1f9d2fe 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanRenderPipeline.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanRenderPipeline.swift @@ -10,7 +10,7 @@ import CVulkan import Vulkan -class VulkanRenderPipeline: RenderPipeline { +final class VulkanRenderPipeline: RenderPipeline, @unchecked Sendable { let descriptor: RenderPipelineDescriptor private unowned let device: Device diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanSampler.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanSampler.swift index adf61b8e8..99662eeb5 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanSampler.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanSampler.swift @@ -6,7 +6,6 @@ // #if VULKAN - import CVulkan import Vulkan diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift index 13b04d22e..1aa16d9d2 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift @@ -10,7 +10,7 @@ import CVulkan import Vulkan -final class VulkanShader: CompiledShader { +final class VulkanShader: CompiledShader, @unchecked Sendable { private(set) var shaderModule: VkShaderModule private unowned let device: Device diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanUniformBuffer.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanUniformBuffer.swift index e8c3d8e5f..1afdf24de 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanUniformBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanUniformBuffer.swift @@ -9,7 +9,7 @@ import CVulkan import Vulkan -final class VulkanUniformBuffer: VulkanBuffer, UniformBuffer { +final class VulkanUniformBuffer: VulkanBuffer, UniformBuffer, @unchecked Sendable { let binding: Int init( diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanVertexBuffer.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanVertexBuffer.swift index 5fcba0b32..797b88802 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanVertexBuffer.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanVertexBuffer.swift @@ -9,7 +9,7 @@ import CVulkan import Vulkan -class VulkanVertexBuffer: VulkanBuffer, VertexBuffer { +final class VulkanVertexBuffer: VulkanBuffer, VertexBuffer, @unchecked Sendable { var binding: Int diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderBackend.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderBackend.swift index 668270db1..88034721a 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderBackend.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderBackend.swift @@ -126,7 +126,7 @@ extension Texture.TextureType { } } -class VulkanRenderCommandBuffer: DrawCommandBuffer { +final class VulkanRenderCommandBuffer: DrawCommandBuffer, @unchecked Sendable { let framebuffer: VulkanFramebuffer init(framebuffer: VulkanFramebuffer) { diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift index c26d36b8d..3cf227947 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift @@ -10,7 +10,22 @@ import Foundation import Vulkan import CVulkan import Math + +#if canImport(Win32) +import Win32 +#endif + +#if canImport(X11) +import X11 +#endif + +#if canImport(Wayland) +import Wayland +#endif + +#if canImport(MetalKit) import MetalKit +#endif extension VulkanRenderBackend { @@ -273,14 +288,14 @@ extension VulkanRenderBackend { #endif } + @MainActor func createRenderWindow(with id: UIWindow.ID, view: RenderSurface, size: Math.SizeInt) throws { if self.windows[id] != nil { throw ContextError.creationWindowAlreadyExists } let holder = VulkanUtils.TemporaryBufferHolder(label: "Create Vulkan Window") - - let surface = try Surface(vulkan: self.instance, view: view as! MTKView) + let surface = try Surface.createSurface(vulkan: self.instance, view: view) let formats = try self.physicalDevice.surfaceFormats(for: surface) var format: VkFormat = VK_FORMAT_UNDEFINED @@ -462,4 +477,109 @@ extension VulkanRenderBackend { } } } + +private extension Surface { + @MainActor + static func createSurface(vulkan: VulkanInstance, view: RenderSurface) throws -> Surface { + #if canImport(MetalKit) + guard let layer = (view as? MTKView)?.layer as? CAMetalLayer else { + throw VKError(code: VK_ERROR_INITIALIZATION_FAILED, message: "Can't cast layer to CAMetalLayer") + } + + var createInfo = VkMetalSurfaceCreateInfoEXT() + createInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + createInfo.pLayer = layer + + var surface: VkSurfaceKHR? + let result = withUnsafePointer(to: &createInfo) { ptr in + vkCreateMetalSurfaceEXT(vulkan.pointer, ptr, nil, &surface) + } + + guard let surface = surface, result == VK_SUCCESS else { + throw VKError(code: result, message: "Can't create macOS surface") + } + + return Surface(vulkan: vulkan, surface: surface) + #elseif os(Linux) + return makeSurfaceLinux(vulkan: vulkan, view: view) + #elseif os(Windows) + var createInfo = VkWin32SurfaceCreateInfoKHR() + createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR + createInfo.hinstance = display + createInfo.hwnd = window + + var surface: VkSurfaceKHR? + let result = withUnsafePointer(to: &createInfo) { ptr in + vkCreateWin32SurfaceKHR(vulkan.pointer, ptr, nil, &surface) + } + + guard let surface = surface, result == VK_SUCCESS else { + throw VKError(code: result, message: "Can't create Windows surface") + } + + return Surface(vulkan: vulkan, surface: surface) + #elseif os(Android) + var createInfo = VkAndroidSurfaceCreateInfoKHR() + createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR + // createInfo.window = window + + var surface: VkSurfaceKHR? + let result = withUnsafePointer(to: &createInfo) { ptr in + vkCreateAndroidSurfaceKHR(vulkan.pointer, ptr, nil, &surface) + } + + guard let surface = surface, result == VK_SUCCESS else { + throw VKError(code: result, message: "Can't create Android surface") + } + + return Surface(vulkan: vulkan, surface: surface) + #else + fatalError("No render surface selected") + #endif + } + + #if os(Linux) + private static func makeSurfaceLinux(vulkan: VulkanInstance, view: RenderSurface) -> Surface { + #if canImport(X11) + var createInfo = VkXlibSurfaceCreateInfoKHR() + createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR + createInfo.dpy = display + createInfo.window = window + + var surface: VkSurfaceKHR? + let result = withUnsafePointer(to: &createInfo) { ptr in + vkCreateXlibSurfaceKHR(vulkan.pointer, ptr, nil, &surface) + } + + guard let surface = surface, result == VK_SUCCESS else { + throw VKError(code: result, message: "Can't create Linux X11 surface") + } + + self.init(vulkan: vulkan, surface: surface) + #elseif canImport(Wayland) + let waylandView = view as! WaylandView + + var createInfo = VkWaylandSurfaceCreateInfoKHR() + createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR + createInfo.dpy = waylandView.surface + createInfo.window = waylandView.window + + var surface: VkSurfaceKHR? + let result = withUnsafePointer(to: &createInfo) { ptr in + vkCreateWaylandSurfaceKHR(vulkan.pointer, ptr, nil, &surface) + } + + guard let surface = surface, result == VK_SUCCESS else { + throw VKError(code: result, message: "Can't create Linux Wayland surface") + } + + return Surface(vulkan: vulkan, surface: surface) + #else + #error("Not supported surface") + fatalError("Not supported surface") + #endif + } + #endif +} + #endif diff --git a/Sources/AdaEngine/Rendering/RenderEngine.swift b/Sources/AdaEngine/Rendering/RenderEngine.swift index 708f5aed3..1db59a270 100644 --- a/Sources/AdaEngine/Rendering/RenderEngine.swift +++ b/Sources/AdaEngine/Rendering/RenderEngine.swift @@ -17,6 +17,8 @@ public final class RenderEngine: RenderBackend { public struct Configuration { public var maxFramesInFlight: Int = 3 + /// Select render backend. + public var renderBackend: RenderBackendType = .metal public init() {} } @@ -29,13 +31,27 @@ public final class RenderEngine: RenderBackend { let appName = "AdaEngine" - #if METAL - renderBackend = MetalRenderBackend(appName: appName) - #elseif VULKAN - renderBackend = VulkanRenderBackend(appName: appName) - #else - renderBackend = OpenGLBackend(appName: appName) - #endif + /// Select render backend based on the platform. + switch configurations.renderBackend { + case .metal: + #if METAL + renderBackend = MetalRenderBackend(appName: appName) + #else + fatalError("Metal is not enabled") + #endif + case .vulkan: + #if ENABLE_VULKAN + renderBackend = VulkanRenderBackend(appName: appName) + #else + fatalError("Vulkan is not enabled") + #endif + case .opengl: + #if ENABLE_OPENGL + renderBackend = OpenGLBackend(appName: appName) + #else + fatalError("No render backend selected") + #endif + } return RenderEngine(renderBackend: renderBackend) }() diff --git a/Sources/AdaEngine/Scene/Resources/AssetsCodable/TextAssetEncoder.swift b/Sources/AdaEngine/Scene/Resources/AssetsCodable/TextAssetEncoder.swift index 2b98b4ef4..548e90f6a 100644 --- a/Sources/AdaEngine/Scene/Resources/AssetsCodable/TextAssetEncoder.swift +++ b/Sources/AdaEngine/Scene/Resources/AssetsCodable/TextAssetEncoder.swift @@ -33,19 +33,19 @@ public final class TextAssetEncoder: AssetEncoder, @unchecked Sendable { } protocol AnyEncoder: Sendable { - func encode(_ value: T, userInfo: [CodingUserInfoKey: Any]) throws -> Data + func encode(_ value: T, userInfo: [CodingUserInfoKey: any Sendable]) throws -> Data } extension YAMLEncoder: @unchecked @retroactive Sendable {} extension YAMLEncoder: AnyEncoder { - func encode(_ value: T, userInfo: [CodingUserInfoKey : Any]) throws -> Data where T : Encodable { + func encode(_ value: T, userInfo: [CodingUserInfoKey : any Sendable]) throws -> Data where T : Encodable { return try self.encode(value, userInfo: userInfo).data(using: .utf8)! } } extension JSONEncoder: AnyEncoder { - func encode(_ value: T, userInfo: [CodingUserInfoKey : Any]) throws -> Data where T : Encodable { + func encode(_ value: T, userInfo: [CodingUserInfoKey : any Sendable]) throws -> Data where T : Encodable { self.userInfo = userInfo return try self.encode(value) } diff --git a/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift b/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift index 2206ca42d..b4e11ee2d 100644 --- a/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift +++ b/Sources/AdaEngine/Text/Font/FontAtlasGenerator.swift @@ -139,12 +139,12 @@ final class FontAtlasGenerator { var header = AtlasHeader(width: width, height: height, dataSize: data.count) withUnsafeBytes(of: &header) { ptr in let bytes = ptr.baseAddress!.assumingMemoryBound(to: UInt8.self) - stream.write(bytes, maxLength: MemoryLayout.stride) + _ = stream.write(bytes, maxLength: MemoryLayout.stride) } data.withUnsafeBytes { (bufferPtr: UnsafeRawBufferPointer) in let bytes = bufferPtr.baseAddress!.assumingMemoryBound(to: UInt8.self) - stream.write(bytes, maxLength: data.count) + _ = stream.write(bytes, maxLength: data.count) } stream.close() @@ -170,11 +170,11 @@ final class FontAtlasGenerator { stream.open() let headerData: UnsafeMutablePointer = UnsafeMutablePointer.allocate(capacity: MemoryLayout.stride) - stream.read(headerData, maxLength: MemoryLayout.size) + _ = stream.read(headerData, maxLength: MemoryLayout.size) let atlasHeader = UnsafeRawPointer(headerData).load(as: AtlasHeader.self) let atlasData: UnsafeMutablePointer = UnsafeMutablePointer.allocate(capacity: atlasHeader.dataSize) - stream.read(atlasData, maxLength: atlasHeader.dataSize) + _ = stream.read(atlasData, maxLength: atlasHeader.dataSize) let data = Data(bytes: UnsafeRawPointer(atlasData), count: atlasHeader.dataSize) defer { diff --git a/Sources/CVulkan/cvulkan.h b/Sources/CVulkan/cvulkan.h index a25fcfc60..4384c7470 100644 --- a/Sources/CVulkan/cvulkan.h +++ b/Sources/CVulkan/cvulkan.h @@ -18,7 +18,6 @@ #include "/usr/local/include/vulkan/vulkan.h" #endif - static uint32_t vkApiVersion_1_2() { return VK_API_VERSION_1_2; } diff --git a/Sources/CVulkan/module.modulemap b/Sources/CVulkan/module.modulemap index 47dee929c..a8847fbdb 100644 --- a/Sources/CVulkan/module.modulemap +++ b/Sources/CVulkan/module.modulemap @@ -1,5 +1,5 @@ module CVulkan [system] { umbrella header "cvulkan.h" - link "vulkan" + link "vulkan-1" export * } diff --git a/Sources/Vulkan/Buffer.swift b/Sources/Vulkan/Buffer.swift index 75a225b16..8fa3f5e30 100644 --- a/Sources/Vulkan/Buffer.swift +++ b/Sources/Vulkan/Buffer.swift @@ -109,7 +109,7 @@ public final class Buffer { } public extension Buffer { - struct Usage: OptionSet { + struct Usage: OptionSet, Sendable { public var rawValue: UInt32 public init(rawValue: UInt32) { diff --git a/Sources/Vulkan/CommandBuffer.swift b/Sources/Vulkan/CommandBuffer.swift index 855d67a90..17e7cbe9d 100644 --- a/Sources/Vulkan/CommandBuffer.swift +++ b/Sources/Vulkan/CommandBuffer.swift @@ -152,7 +152,7 @@ public extension CommandBuffer { } } - struct BeginFlags: OptionSet { + struct BeginFlags: OptionSet, Sendable { public var rawValue: UInt32 public init(rawValue: UInt32) { diff --git a/Sources/Vulkan/Definitions/DeviceQueueCreateInfo.swift b/Sources/Vulkan/Definitions/DeviceQueueCreateInfo.swift index 16b6499f3..494534149 100644 --- a/Sources/Vulkan/Definitions/DeviceQueueCreateInfo.swift +++ b/Sources/Vulkan/Definitions/DeviceQueueCreateInfo.swift @@ -12,7 +12,7 @@ public struct DeviceQueueCreateInfo { public let queuePriorities: [Float] public let flags: Flags - public struct Flags: OptionSet { + public struct Flags: OptionSet, Sendable { public let rawValue: UInt32 public init(rawValue: UInt32) { diff --git a/Sources/Vulkan/Definitions/QueueFamilyProperties.swift b/Sources/Vulkan/Definitions/QueueFamilyProperties.swift index 72abdcc2c..60f941615 100644 --- a/Sources/Vulkan/Definitions/QueueFamilyProperties.swift +++ b/Sources/Vulkan/Definitions/QueueFamilyProperties.swift @@ -26,7 +26,7 @@ public struct QueueFamilyProperties { self.minImageTransferGranularity = minImageTransferGranularity } - public struct Flags: OptionSet { + public struct Flags: OptionSet, Sendable { public let rawValue: UInt32 public init(rawValue: UInt32) { diff --git a/Sources/Vulkan/Definitions/VKError.swift b/Sources/Vulkan/Definitions/VKError.swift index 41251ad07..fce10a43c 100644 --- a/Sources/Vulkan/Definitions/VKError.swift +++ b/Sources/Vulkan/Definitions/VKError.swift @@ -13,6 +13,11 @@ public struct VKError: LocalizedError { public let code: VkResult public let message: String + public init(code: VkResult, message: String) { + self.code = code + self.message = message + } + public var errorDescription: String? { return "Vulkan Error \(code.rawValue): \(self.message)" } diff --git a/Sources/Vulkan/Surface.swift b/Sources/Vulkan/Surface.swift index 46b423970..e5fb32683 100644 --- a/Sources/Vulkan/Surface.swift +++ b/Sources/Vulkan/Surface.swift @@ -28,38 +28,4 @@ public final class Surface { self.rawValue = rawValue } } -} - -// TODO: Make common surface for Metal family - -#if os(iOS) || os(tvOS) || os(macOS) - -import MetalKit - -public extension Surface { - convenience init( - vulkan: VulkanInstance, - view: MTKView - ) throws { - guard let layer = view.layer as? CAMetalLayer else { - throw VKError(code: VK_ERROR_INITIALIZATION_FAILED, message: "Can't cast layer to CAMetalLayer") - } - - var createInfo = VkMetalSurfaceCreateInfoEXT() - createInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; - createInfo.pLayer = layer - - var surface: VkSurfaceKHR? - let result = withUnsafePointer(to: &createInfo) { ptr in - vkCreateMetalSurfaceEXT(vulkan.pointer, ptr, nil, &surface) - } - - guard let surface = surface, result == VK_SUCCESS else { - throw VKError(code: result, message: "Can't create macOS surface") - } - - self.init(vulkan: vulkan, surface: surface) - } -} - -#endif +} \ No newline at end of file diff --git a/Sources/Wayland/module.modulemap b/Sources/Wayland/module.modulemap new file mode 100644 index 000000000..25c14114f --- /dev/null +++ b/Sources/Wayland/module.modulemap @@ -0,0 +1,5 @@ +module Wayland [system] { + header "wayland.h" + link "wayland-client" + export * +} \ No newline at end of file diff --git a/Sources/Wayland/wayland.h b/Sources/Wayland/wayland.h new file mode 100644 index 000000000..d4d349ffa --- /dev/null +++ b/Sources/Wayland/wayland.h @@ -0,0 +1 @@ +#include \ No newline at end of file diff --git a/utils/scripts/install_vulkan_macos.sh b/utils/scripts/install_vulkan_macos.sh new file mode 100755 index 000000000..a63268e02 --- /dev/null +++ b/utils/scripts/install_vulkan_macos.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Function to print colored messages +print_message() { + echo -e "${2}${1}${NC}" +} + +# Function to check if a command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Check if running on macOS +if [[ "$OSTYPE" != "darwin"* ]]; then + print_message "This script is intended for macOS only." "$RED" + exit 1 +fi + +# Check if Vulkan SDK is installed +if [ -d "/usr/local/share/vulkan" ] || [ -d "$HOME/vulkansdk" ]; then + print_message "Vulkan SDK is already installed." "$GREEN" + exit 0 +fi + +print_message "Vulkan SDK not found. Starting installation..." "$YELLOW" + +# Create temporary directory +TEMP_DIR=$(mktemp -d) +cd "$TEMP_DIR" || exit 1 + +# Get the latest Vulkan SDK version +print_message "Fetching latest Vulkan SDK version..." "$YELLOW" +LATEST_VERSION=$(curl -s https://vulkan.lunarg.com/sdk/latest/mac.json | grep -o '"version": "[^"]*' | cut -d'"' -f4) + +if [ -z "$LATEST_VERSION" ]; then + print_message "Failed to fetch latest version. Please check your internet connection." "$RED" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Download the SDK +DOWNLOAD_URL="https://sdk.lunarg.com/sdk/download/${LATEST_VERSION}/mac/vulkansdk-macos-${LATEST_VERSION}.dmg" +print_message "Downloading Vulkan SDK ${LATEST_VERSION}..." "$YELLOW" + +if ! curl -L -o vulkansdk.dmg "$DOWNLOAD_URL"; then + print_message "Failed to download Vulkan SDK." "$RED" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Mount the DMG +print_message "Installing Vulkan SDK..." "$YELLOW" +hdiutil attach vulkansdk.dmg + +# Find the mounted volume +VOLUME_PATH=$(hdiutil info | grep "VulkanSDK" | awk '{print $3}') + +if [ -z "$VOLUME_PATH" ]; then + print_message "Failed to mount Vulkan SDK installer." "$RED" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Install the SDK +if ! cp -R "$VOLUME_PATH/VulkanSDK" "$HOME/"; then + print_message "Failed to install Vulkan SDK." "$RED" + hdiutil detach "$VOLUME_PATH" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Unmount the DMG +hdiutil detach "$VOLUME_PATH" + +# Clean up +rm -rf "$TEMP_DIR" + +# Set up environment variables +print_message "Setting up environment variables..." "$YELLOW" +echo 'export VULKAN_SDK=$HOME/vulkansdk/macOS' >> ~/.zshrc +echo 'export PATH=$VULKAN_SDK/bin:$PATH' >> ~/.zshrc +echo 'export DYLD_LIBRARY_PATH=$VULKAN_SDK/lib:$DYLD_LIBRARY_PATH' >> ~/.zshrc +echo 'export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json' >> ~/.zshrc + +print_message "Vulkan SDK ${LATEST_VERSION} has been successfully installed!" "$GREEN" +print_message "Please restart your terminal or run 'source ~/.zshrc' to apply the changes." "$YELLOW" From 9dd5182cbb24865cd635c1d13a142c2fb6c2d885 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Fri, 16 May 2025 00:21:41 +0300 Subject: [PATCH 07/11] Add wayland to vulkan --- .../Rendering/Backends/Vulkan/VulkanRenderContext.swift | 9 +++++---- Sources/CVulkan/cvulkan.h | 5 +++++ Sources/CVulkan/module.modulemap | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift index 3cf227947..2e2b5262f 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift @@ -501,7 +501,7 @@ private extension Surface { return Surface(vulkan: vulkan, surface: surface) #elseif os(Linux) - return makeSurfaceLinux(vulkan: vulkan, view: view) + return try makeSurfaceLinux(vulkan: vulkan, view: view) #elseif os(Windows) var createInfo = VkWin32SurfaceCreateInfoKHR() createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR @@ -539,7 +539,8 @@ private extension Surface { } #if os(Linux) - private static func makeSurfaceLinux(vulkan: VulkanInstance, view: RenderSurface) -> Surface { + @MainActor + private static func makeSurfaceLinux(vulkan: VulkanInstance, view: RenderSurface) throws -> Surface { #if canImport(X11) var createInfo = VkXlibSurfaceCreateInfoKHR() createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR @@ -561,8 +562,8 @@ private extension Surface { var createInfo = VkWaylandSurfaceCreateInfoKHR() createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR - createInfo.dpy = waylandView.surface - createInfo.window = waylandView.window + createInfo.surface = waylandView.surface + createInfo.display = waylandView.window var surface: VkSurfaceKHR? let result = withUnsafePointer(to: &createInfo) { ptr in diff --git a/Sources/CVulkan/cvulkan.h b/Sources/CVulkan/cvulkan.h index 4384c7470..af68a5e1c 100644 --- a/Sources/CVulkan/cvulkan.h +++ b/Sources/CVulkan/cvulkan.h @@ -14,6 +14,11 @@ #include #endif +#if __has_include() +#include +#include +#endif + #else #include "/usr/local/include/vulkan/vulkan.h" #endif diff --git a/Sources/CVulkan/module.modulemap b/Sources/CVulkan/module.modulemap index a8847fbdb..47dee929c 100644 --- a/Sources/CVulkan/module.modulemap +++ b/Sources/CVulkan/module.modulemap @@ -1,5 +1,5 @@ module CVulkan [system] { umbrella header "cvulkan.h" - link "vulkan-1" + link "vulkan" export * } From b4487b2a6de1792ab0cc1c914e70db6f0856d285 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Fri, 16 May 2025 01:06:10 +0300 Subject: [PATCH 08/11] Fix libObservation bug --- Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift b/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift index 007c9f9c1..eb8fea3e6 100644 --- a/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift +++ b/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift @@ -7,6 +7,12 @@ @preconcurrency import Observation +// FIXME: This is a little hack to avoid crash +#if os(Android) || os(Linux) +@_cdecl("_ZN5swift9threading5fatalEPKcz") +func swiftThreadingFatal() { } +#endif + public extension View { /// Places an observable object in the view's environment. From 6ca3f78dad8690b87dcca7b585dcd94c9989ea5b Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Fri, 16 May 2025 01:13:06 +0300 Subject: [PATCH 09/11] Some fixes --- .../Platforms/Linux/LinuxApplication.swift | 36 +++++++++++++++++++ .../UI/DSL/Modifiers/View+Observable.swift | 3 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift index b67bbaeb0..1d5ca56c6 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift @@ -9,11 +9,47 @@ import Wayland final class LinuxApplication: Application { + private var task: Task? + override init(argc: Int32, argv: UnsafeMutablePointer?>) throws { try super.init(argc: argc, argv: argv) self.windowManager = LinuxWindowManager() } + + override func run() { + print("LinuxApplication.run()") + task = Task { @MainActor in + self.gameLoop.setup() + do { + while true { + try Task.checkCancellation() + self.processEvents() + try await self.gameLoop.iterate() + } + } catch { + fatalError("LinuxApplication.run() error: \(error)") + let alert = Alert(title: "AdaEngine finished with Error", message: error.localizedDescription, buttons: [.cancel("OK", action: { + exit(EXIT_FAILURE) + })]) + + Application.shared.showAlert(alert) + } + } + } + + override func openURL(_ url: URL) -> Bool { + // TODO: Implement Wayland URL opening + return false + } + + override func showAlert(_ alert: Alert) { + // TODO: Implement Wayland alert + } + + func processEvents() { + // TODO: Implement Wayland events processing + } } #endif diff --git a/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift b/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift index eb8fea3e6..e6b5ea664 100644 --- a/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift +++ b/Sources/AdaEngine/UI/DSL/Modifiers/View+Observable.swift @@ -7,7 +7,8 @@ @preconcurrency import Observation -// FIXME: This is a little hack to avoid crash +// https://github.com/swiftlang/swift/pull/77890#issuecomment-2645596313 +// FIXME: This is a little hack to avoid crash #if os(Android) || os(Linux) @_cdecl("_ZN5swift9threading5fatalEPKcz") func swiftThreadingFatal() { } From bb88dc2e2e9baab57dd092097bbd5ee7809f6752 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Fri, 16 May 2025 13:36:48 +0300 Subject: [PATCH 10/11] Update run loop --- .../Logs/Launch/LogStoreManifest.plist | 10 +++ .../Logs/Localization/LogStoreManifest.plist | 10 +++ .../Logs/Package/LogStoreManifest.plist | 10 +++ .derivedData/Logs/Test/LogStoreManifest.plist | 10 +++ Package.swift | 2 +- .../Application/AppCreate/AppContext.swift | 7 ++ .../AdaEngine/Application/Application.swift | 18 ++--- Sources/AdaEngine/GameLoop.swift | 54 +++++++------ .../Platforms/Apple/iOS/iOSApplication.swift | 9 ++- .../Apple/iOS/iOSWindowManager.swift | 3 - .../Apple/macOS/MacAppDelegate.swift | 8 +- .../Apple/macOS/MacApplication.swift | 75 +++++++++++++------ .../Apple/macOS/MacOSWindowManager.swift | 2 - .../Platforms/Linux/LinuxApplication.swift | 40 +++++----- .../Platforms/Linux/LinuxWindowManager.swift | 6 +- .../Platforms/Linux/WaylandView.swift | 15 +++- .../Backends/Vulkan/VulkanRenderContext.swift | 12 +-- .../AdaEngine/Rendering/RenderEngine.swift | 2 +- Sources/AdaEngine/UI/UIWindowManager.swift | 2 +- .../ApplePlatforms/AppleWindowManager.swift | 2 +- Sources/CVulkan/cvulkan.h | 29 +++++-- Tests/AdaEngineTests/TestApplication.swift | 5 +- 22 files changed, 223 insertions(+), 108 deletions(-) create mode 100644 .derivedData/Logs/Launch/LogStoreManifest.plist create mode 100644 .derivedData/Logs/Localization/LogStoreManifest.plist create mode 100644 .derivedData/Logs/Package/LogStoreManifest.plist create mode 100644 .derivedData/Logs/Test/LogStoreManifest.plist diff --git a/.derivedData/Logs/Launch/LogStoreManifest.plist b/.derivedData/Logs/Launch/LogStoreManifest.plist new file mode 100644 index 000000000..f38de4428 --- /dev/null +++ b/.derivedData/Logs/Launch/LogStoreManifest.plist @@ -0,0 +1,10 @@ + + + + + logFormatVersion + 11 + logs + + + diff --git a/.derivedData/Logs/Localization/LogStoreManifest.plist b/.derivedData/Logs/Localization/LogStoreManifest.plist new file mode 100644 index 000000000..f38de4428 --- /dev/null +++ b/.derivedData/Logs/Localization/LogStoreManifest.plist @@ -0,0 +1,10 @@ + + + + + logFormatVersion + 11 + logs + + + diff --git a/.derivedData/Logs/Package/LogStoreManifest.plist b/.derivedData/Logs/Package/LogStoreManifest.plist new file mode 100644 index 000000000..f38de4428 --- /dev/null +++ b/.derivedData/Logs/Package/LogStoreManifest.plist @@ -0,0 +1,10 @@ + + + + + logFormatVersion + 11 + logs + + + diff --git a/.derivedData/Logs/Test/LogStoreManifest.plist b/.derivedData/Logs/Test/LogStoreManifest.plist new file mode 100644 index 000000000..f38de4428 --- /dev/null +++ b/.derivedData/Logs/Test/LogStoreManifest.plist @@ -0,0 +1,10 @@ + + + + + logFormatVersion + 11 + logs + + + diff --git a/Package.swift b/Package.swift index 686fe50ed..5878ac1ea 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ import AppleProductTypes #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) import Darwin.C -let isVulkanEnabled = true +let isVulkanEnabled = false #else #if os(Linux) diff --git a/Sources/AdaEngine/Application/AppCreate/AppContext.swift b/Sources/AdaEngine/Application/AppCreate/AppContext.swift index 1467728cc..c9e620126 100644 --- a/Sources/AdaEngine/Application/AppCreate/AppContext.swift +++ b/Sources/AdaEngine/Application/AppCreate/AppContext.swift @@ -15,6 +15,12 @@ public final class AppContext { private var application: Application! init() throws { + #if METAL + /// By default, the render backend is set to Vulkan. + /// But if the Metal backend is available, it will be used instead. + RenderEngine.configurations.renderBackend = .metal + #endif + self.app = T.init() let argc = CommandLine.argc @@ -46,6 +52,7 @@ public final class AppContext { } @_spi(Internal) + @MainActor public func setup() async throws { try ResourceManager.initialize() try AudioServer.initialize() diff --git a/Sources/AdaEngine/Application/Application.swift b/Sources/AdaEngine/Application/Application.swift index e168f98b7..d7da4018d 100644 --- a/Sources/AdaEngine/Application/Application.swift +++ b/Sources/AdaEngine/Application/Application.swift @@ -10,9 +10,6 @@ /// To get access to the application instance, use static property `shared` @MainActor open class Application { - - // MARK: - Public - /// Contains application instance if application created from ``App``. @MainActor public internal(set) static var shared: Application! @@ -38,10 +35,14 @@ open class Application { return .android #endif } + + public class var windowManagerClass: UIWindowManager.Type { + UIWindowManager.self + } @_spi(Internal) - @MainActor @preconcurrency - public var windowManager: UIWindowManager = UIWindowManager() + @preconcurrency + public let windowManager: UIWindowManager /// Contains world which can render on screen. public let renderWorld = RenderWorld() @@ -51,7 +52,9 @@ open class Application { public init( argc: Int32, argv: UnsafeMutablePointer?> - ) throws { } + ) throws { + self.windowManager = Self.windowManagerClass.init() + } /// Call this method to start main loop. func run() throws { @@ -61,13 +64,11 @@ open class Application { // MARK: - Public methods /// Call this method to terminate app execution with 0 status code. - @MainActor open func terminate() { exit(EXIT_SUCCESS) } /// Method to open url. - @MainActor @discardableResult open func openURL(_ url: URL) -> Bool { assertionFailure("Not implemented") @@ -75,7 +76,6 @@ open class Application { } /// Call this method to show specific alert. - @MainActor open func showAlert(_ alert: Alert) { assertionFailure("Not implemented") } diff --git a/Sources/AdaEngine/GameLoop.swift b/Sources/AdaEngine/GameLoop.swift index aa0344ade..3b3eaaa52 100644 --- a/Sources/AdaEngine/GameLoop.swift +++ b/Sources/AdaEngine/GameLoop.swift @@ -13,7 +13,7 @@ public final class GameLoop { public private(set) static var current: GameLoop = GameLoop() private var lastUpdate: LongTimeInterval = 0 - + private var error: Error? private(set) var isIterating = false private var isFirstTick: Bool = true @@ -24,36 +24,46 @@ public final class GameLoop { let physicsTickPerSecond = Engine.shared.physicsTickPerSecond self.fixedTimestep.step = 1 / TimeInterval(physicsTickPerSecond) } - - public func iterate() async throws { - if self.isIterating { - return + + public func iterate() throws { + if let error = self.error { + throw error } - self.isIterating = true - defer { self.isIterating = false } + Task { @MainActor in + do { + if self.isIterating { + return + } - let now = Time.absolute - let deltaTime = TimeInterval(max(0, now - self.lastUpdate)) - self.lastUpdate = now + self.isIterating = true + defer { self.isIterating = false } - // that little hack to avoid big delta in the first tick, because delta is equals Time.absolute value. - if self.isFirstTick { - self.isFirstTick = false - return - } + let now = Time.absolute + let deltaTime = TimeInterval(max(0, now - self.lastUpdate)) + self.lastUpdate = now - EventManager.default.send(EngineEvents.GameLoopBegan(deltaTime: deltaTime)) + // that little hack to avoid big delta in the first tick, because delta is equals Time.absolute value. + if self.isFirstTick { + self.isFirstTick = false + return + } - try RenderEngine.shared.beginFrame() + EventManager.default.send(EngineEvents.GameLoopBegan(deltaTime: deltaTime)) - try await Application.shared.renderWorld.update(deltaTime) - await Application.shared.windowManager.update(deltaTime) + try RenderEngine.shared.beginFrame() - try RenderEngine.shared.endFrame() + try await Application.shared.renderWorld.update(deltaTime) + await Application.shared.windowManager.update(deltaTime) - Input.shared.removeEvents() + try RenderEngine.shared.endFrame() - FPSCounter.shared.tick() + Input.shared.removeEvents() + + FPSCounter.shared.tick() + } catch { + self.error = error + } + } } } diff --git a/Sources/AdaEngine/Platforms/Apple/iOS/iOSApplication.swift b/Sources/AdaEngine/Platforms/Apple/iOS/iOSApplication.swift index e2d61e0a3..f08a65302 100644 --- a/Sources/AdaEngine/Platforms/Apple/iOS/iOSApplication.swift +++ b/Sources/AdaEngine/Platforms/Apple/iOS/iOSApplication.swift @@ -12,8 +12,12 @@ import UIKit @MainActor final class iOSApplication: Application { - let argc: Int32 - let argv: UnsafeMutablePointer?> + private let argc: Int32 + private let argv: UnsafeMutablePointer?> + + override class var windowManagerClass: UIWindowManager.Type { + iOSWindowManager.self + } var displayLink: CADisplayLink! @@ -22,7 +26,6 @@ final class iOSApplication: Application { self.argc = argc try super.init(argc: argc, argv: argv) - self.windowManager = iOSWindowManager() } override func run() throws { diff --git a/Sources/AdaEngine/Platforms/Apple/iOS/iOSWindowManager.swift b/Sources/AdaEngine/Platforms/Apple/iOS/iOSWindowManager.swift index f14baf553..54880a2df 100644 --- a/Sources/AdaEngine/Platforms/Apple/iOS/iOSWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Apple/iOS/iOSWindowManager.swift @@ -12,7 +12,6 @@ import UIKit final class iOSWindowManager: WindowManager { override func createWindow(for window: Window) { - let screen = UIScreen.main let frame = screen.bounds.toEngineRect @@ -46,9 +45,7 @@ final class iOSWindowManager: WindowManager { } uiWindow.makeKeyAndVisible() - window.windowDidAppear() - self.setActiveWindow(window) } diff --git a/Sources/AdaEngine/Platforms/Apple/macOS/MacAppDelegate.swift b/Sources/AdaEngine/Platforms/Apple/macOS/MacAppDelegate.swift index bca5b4830..feb47f678 100644 --- a/Sources/AdaEngine/Platforms/Apple/macOS/MacAppDelegate.swift +++ b/Sources/AdaEngine/Platforms/Apple/macOS/MacAppDelegate.swift @@ -10,7 +10,13 @@ import AppKit import MetalKit final class MacAppDelegate: NSObject, NSApplicationDelegate { - + func applicationDidFinishLaunching(_ aNotification: Notification) { + print("applicationDidFinishLaunching") + } + + func applicationWillTerminate(_ aNotification: Notification) { + print("applicationWillTerminate") + } } #endif diff --git a/Sources/AdaEngine/Platforms/Apple/macOS/MacApplication.swift b/Sources/AdaEngine/Platforms/Apple/macOS/MacApplication.swift index 2d6f2c995..33f6d7ded 100644 --- a/Sources/AdaEngine/Platforms/Apple/macOS/MacApplication.swift +++ b/Sources/AdaEngine/Platforms/Apple/macOS/MacApplication.swift @@ -9,13 +9,35 @@ import AppKit import MetalKit +// This hack to avoid using NSApplication.shared.run(). +func runLoopObserverCallback( + observer: CFRunLoopObserver?, + activity: CFRunLoopActivity, + info: UnsafeMutableRawPointer? +) { + MainActor.assumeIsolated { + let gameLoop = Application.shared.gameLoop + do { + if !gameLoop.isIterating { + try gameLoop.iterate() + } + } catch { + print("error", error) + } + } + CFRunLoopWakeUp(CFRunLoopGetCurrent()) +} + final class MacApplication: Application { private let delegate = MacAppDelegate() + override class var windowManagerClass: UIWindowManager.Type { + MacOSWindowManager.self + } + override init(argc: Int32, argv: UnsafeMutablePointer?>) throws { try super.init(argc: argc, argv: argv) - self.windowManager = MacOSWindowManager() // Create application let app = AdaApplication.shared @@ -24,36 +46,43 @@ final class MacApplication: Application { app.finishLaunching() app.delegate = self.delegate - self.processEvents() + let observer = CFRunLoopObserverCreate( + kCFAllocatorDefault, + CFRunLoopActivity.beforeWaiting.rawValue, + true, + 0, + runLoopObserverCallback, + nil + ) + CFRunLoopAddObserver(CFRunLoopGetCurrent(), observer, CFRunLoopMode.defaultMode) + self.processEvents() app.activate(ignoringOtherApps: true) } - private var task: Task? - override func run() throws { - task = Task { @MainActor in - self.gameLoop.setup() - do { - while true { - try Task.checkCancellation() - self.processEvents() - try await self.gameLoop.iterate() - } - } catch { - let alert = Alert(title: "AdaEngine finished with Error", message: error.localizedDescription, buttons: [.cancel("OK", action: { - exit(EXIT_FAILURE) - })]) - - Application.shared.showAlert(alert) + self.gameLoop.setup() + do { + while true { + self.processEvents() + try self.gameLoop.iterate() } + } catch { + let alert = Alert( + title: "AdaEngine finished with Error", message: error.localizedDescription, + buttons: [ + .cancel( + "OK", + action: { + exit(EXIT_FAILURE) + }) + ]) + + Application.shared.showAlert(alert) } - - NSApplication.shared.run() } override func terminate() { - self.task?.cancel() NSApplication.shared.terminate(nil) } @@ -77,7 +106,7 @@ final class MacApplication: Application { } } - let result = nsAlert.runModal() // synchronous call + let result = nsAlert.runModal() // synchronous call // hack from that thread: https://stackoverflow.com/a/59245758 let index = result.rawValue - 1000 @@ -88,7 +117,7 @@ final class MacApplication: Application { // MARK: - Private - func processEvents() { + func processEvents(_ until: Date = .distantPast) { while true { let event = NSApp.nextEvent( matching: .any, diff --git a/Sources/AdaEngine/Platforms/Apple/macOS/MacOSWindowManager.swift b/Sources/AdaEngine/Platforms/Apple/macOS/MacOSWindowManager.swift index 243fdf88b..cee6b9fff 100644 --- a/Sources/AdaEngine/Platforms/Apple/macOS/MacOSWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Apple/macOS/MacOSWindowManager.swift @@ -14,8 +14,6 @@ final class MacOSWindowManager: UIWindowManager { private lazy var nsWindowDelegate = NSWindowDelegateObject(windowManager: self) - public nonisolated override init() { } - private var menus: [UIWindow.ID: MacOSUIMenuBuilder] = [:] override func createWindow(for window: UIWindow) { diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift index 1d5ca56c6..c5f8bb02c 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift @@ -9,32 +9,34 @@ import Wayland final class LinuxApplication: Application { - private var task: Task? + override class var windowManagerClass: UIWindowManager.Type { + LinuxWindowManager.self + } - override init(argc: Int32, argv: UnsafeMutablePointer?>) throws { - try super.init(argc: argc, argv: argv) - - self.windowManager = LinuxWindowManager() + private var linuxWindowManager: LinuxWindowManager { + windowManager as! LinuxWindowManager } override func run() { - print("LinuxApplication.run()") - task = Task { @MainActor in - self.gameLoop.setup() - do { - while true { - try Task.checkCancellation() - self.processEvents() - try await self.gameLoop.iterate() + guard let display = linuxWindowManager.display else { + fatalError("Display is not set") + } + + self.gameLoop.setup() + + do { + while true { + while wl_display_prepare_read(display) != 0 { + wl_display_dispatch_pending(display) } - } catch { - fatalError("LinuxApplication.run() error: \(error)") - let alert = Alert(title: "AdaEngine finished with Error", message: error.localizedDescription, buttons: [.cancel("OK", action: { - exit(EXIT_FAILURE) - })]) + wl_display_flush(display) + wl_display_read_events(display) + wl_display_dispatch_pending(display) - Application.shared.showAlert(alert) + try self.gameLoop.iterate() } + } catch { + print("error", error) } } diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift index ce9fbe665..7c3470aa3 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift @@ -39,7 +39,11 @@ final class LinuxWindowManager: UIWindowManager { let frame = window.frame let size = frame.size == .zero ? minSize : frame.size - let waylandView = WaylandView(windowId: window.id, frame: frame) + let waylandView = WaylandView( + windowId: window.id, + frame: frame, + windowManager: self + ) let sizeInt = SizeInt(width: Int(size.width), height: Int(size.height)) try? RenderEngine.shared.createWindow(window.id, for: waylandView, size: sizeInt) diff --git a/Sources/AdaEngine/Platforms/Linux/WaylandView.swift b/Sources/AdaEngine/Platforms/Linux/WaylandView.swift index 73ac12a1b..27d96b24c 100644 --- a/Sources/AdaEngine/Platforms/Linux/WaylandView.swift +++ b/Sources/AdaEngine/Platforms/Linux/WaylandView.swift @@ -11,20 +11,27 @@ final class WaylandView: SystemWindow { private var _title: String = "" private var _position: Point = .zero private var _minSize: Size = .zero + + weak var windowManager: LinuxWindowManager? let windowId: UIWindow.ID - init(windowId: UIWindow.ID, frame: Rect) { + init( + windowId: UIWindow.ID, + frame: Rect, + windowManager: LinuxWindowManager + ) { self.windowId = windowId self.frame = frame + self.windowManager = windowManager setupWaylandSurface() } private func setupWaylandSurface() { - guard let windowManager = Application.shared.windowManager as? LinuxWindowManager else { - fatalError("Window manager is not LinuxWindowManager") + guard let windowManager = windowManager else { + fatalError("Window manager is not set") } - + // Create surface surface = wl_compositor_create_surface(windowManager.compositor) guard surface != nil else { diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift index 2e2b5262f..234a0b0ee 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/VulkanRenderContext.swift @@ -11,8 +11,8 @@ import Vulkan import CVulkan import Math -#if canImport(Win32) -import Win32 +#if canImport(WinSDK) +import WinSDK #endif #if canImport(X11) @@ -486,13 +486,13 @@ private extension Surface { throw VKError(code: VK_ERROR_INITIALIZATION_FAILED, message: "Can't cast layer to CAMetalLayer") } - var createInfo = VkMetalSurfaceCreateInfoEXT() + var createInfo = VkMacOSSurfaceCreateInfoMVK() createInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; - createInfo.pLayer = layer + createInfo.pView = UnsafeRawPointer(Unmanaged.passUnretained(layer).toOpaque()) var surface: VkSurfaceKHR? let result = withUnsafePointer(to: &createInfo) { ptr in - vkCreateMetalSurfaceEXT(vulkan.pointer, ptr, nil, &surface) + vkCreateMacOSSurfaceMVK(vulkan.pointer, ptr, nil, &surface) } guard let surface = surface, result == VK_SUCCESS else { @@ -563,7 +563,7 @@ private extension Surface { var createInfo = VkWaylandSurfaceCreateInfoKHR() createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR createInfo.surface = waylandView.surface - createInfo.display = waylandView.window + createInfo.display = waylandView.windowManager?.display var surface: VkSurfaceKHR? let result = withUnsafePointer(to: &createInfo) { ptr in diff --git a/Sources/AdaEngine/Rendering/RenderEngine.swift b/Sources/AdaEngine/Rendering/RenderEngine.swift index 1db59a270..fbf21a4bb 100644 --- a/Sources/AdaEngine/Rendering/RenderEngine.swift +++ b/Sources/AdaEngine/Rendering/RenderEngine.swift @@ -18,7 +18,7 @@ public final class RenderEngine: RenderBackend { public struct Configuration { public var maxFramesInFlight: Int = 3 /// Select render backend. - public var renderBackend: RenderBackendType = .metal + public var renderBackend: RenderBackendType = .vulkan public init() {} } diff --git a/Sources/AdaEngine/UI/UIWindowManager.swift b/Sources/AdaEngine/UI/UIWindowManager.swift index 47ab4ce1f..6a9f38f14 100644 --- a/Sources/AdaEngine/UI/UIWindowManager.swift +++ b/Sources/AdaEngine/UI/UIWindowManager.swift @@ -29,7 +29,7 @@ open class UIWindowManager { /// Contains active window if available. public private(set) var activeWindow: UIWindow? - public nonisolated init() { } + public required init() { } /// Called each frame to update windows. func update(_ deltaTime: TimeInterval) async { diff --git a/Sources/AdaEngineEmbeddable/ApplePlatforms/AppleWindowManager.swift b/Sources/AdaEngineEmbeddable/ApplePlatforms/AppleWindowManager.swift index 8708b631e..857f996b0 100644 --- a/Sources/AdaEngineEmbeddable/ApplePlatforms/AppleWindowManager.swift +++ b/Sources/AdaEngineEmbeddable/ApplePlatforms/AppleWindowManager.swift @@ -14,7 +14,7 @@ final class AppleWindowManager: UIWindowManager { weak var nativeView: MetalView? - override init() { } + override required init() { } override func resizeWindow(_ window: UIWindow, size: Size) { diff --git a/Sources/CVulkan/cvulkan.h b/Sources/CVulkan/cvulkan.h index af68a5e1c..14c3536e6 100644 --- a/Sources/CVulkan/cvulkan.h +++ b/Sources/CVulkan/cvulkan.h @@ -19,6 +19,26 @@ #include #endif +#if __has_include() +#include + +typedef struct VkMetalSurfaceCreateInfoEXT_Swift { + VkStructureType sType; + const void* pNext; + VkFlags flags; + const void* pLayer; +} VkMetalSurfaceCreateInfoEXT_Swift; + +#endif + +#if __has_include() +#include +#endif + +#if __has_include() +#include +#endif + #else #include "/usr/local/include/vulkan/vulkan.h" #endif @@ -45,11 +65,4 @@ static uint32_t vkVersionMinor(uint32_t version) { static uint32_t vkVersionPatch(uint32_t version) { return VK_VERSION_PATCH(version); -} - -typedef struct VkMetalSurfaceCreateInfoEXT_Swift { - VkStructureType sType; - const void* pNext; - VkFlags flags; - const void* pLayer; -} VkMetalSurfaceCreateInfoEXT_Swift; +} \ No newline at end of file diff --git a/Tests/AdaEngineTests/TestApplication.swift b/Tests/AdaEngineTests/TestApplication.swift index a1f2ec605..702a284f0 100644 --- a/Tests/AdaEngineTests/TestApplication.swift +++ b/Tests/AdaEngineTests/TestApplication.swift @@ -8,9 +8,8 @@ @_spi(Internal) @testable import AdaEngine class TestApplication: Application { - override init(argc: Int32, argv: UnsafeMutablePointer?>) throws { - try super.init(argc: argc, argv: argv) - self.windowManager = MockUIWindowManager() + override class var windowManagerClass: UIWindowManager.Type { + MockUIWindowManager.self } convenience init() throws { From 47394cd3a3da9d219ad09dc9aab8aa177bc32fe7 Mon Sep 17 00:00:00 2001 From: Vladislav Prusakov Date: Fri, 16 May 2025 15:15:49 +0300 Subject: [PATCH 11/11] some fixes --- .../Platforms/Linux/LinuxApplication.swift | 13 ++++ .../Platforms/Linux/LinuxWindowManager.swift | 65 +++++++++++-------- .../Platforms/Linux/WaylandView.swift | 3 + .../Backends/Vulkan/Misc/VulkanShader.swift | 22 ++++--- 4 files changed, 65 insertions(+), 38 deletions(-) diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift index c5f8bb02c..4b332d830 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxApplication.swift @@ -18,26 +18,39 @@ final class LinuxApplication: Application { } override func run() { + print("run") guard let display = linuxWindowManager.display else { fatalError("Display is not set") } self.gameLoop.setup() + print("setup") + do { while true { while wl_display_prepare_read(display) != 0 { wl_display_dispatch_pending(display) + print("dispatch") } wl_display_flush(display) wl_display_read_events(display) wl_display_dispatch_pending(display) try self.gameLoop.iterate() + print("tick") + + let next = RunLoop.main.limitDate(forMode: .default) + let s = next?.timeIntervalSinceNow ?? 1.0 + if s > 0.0 { + sleep(10) + } } } catch { print("error", error) } + + print("Finished") } override func openURL(_ url: URL) -> Bool { diff --git a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift index 7c3470aa3..1f9555b5b 100644 --- a/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift +++ b/Sources/AdaEngine/Platforms/Linux/LinuxWindowManager.swift @@ -12,15 +12,45 @@ import Wayland final class LinuxWindowManager: UIWindowManager { private(set) var display: OpaquePointer? private(set) var registry: OpaquePointer? - private(set) var compositor: OpaquePointer? - private(set) var shell: OpaquePointer? - private(set) var shm: OpaquePointer? + var compositor: OpaquePointer? + var shell: OpaquePointer? + var shm: OpaquePointer? + + // Wayland registry listener + private var registryListener = wl_registry_listener( + global: { data, registry, id, interface, version in + let windowManager = Unmanaged.fromOpaque(data!).takeUnretainedValue() + let interfaceName = String(cString: interface!) + print("Wayland interface name", interfaceName) + switch interfaceName { + case "wl_compositor": + var wl_compositor_interface_ptr = wl_compositor_interface + windowManager.compositor = OpaquePointer( + wl_registry_bind(registry, id, &wl_compositor_interface_ptr, min(version, 4)) + ) + print("new compositor", windowManager.compositor) + case "wl_shell": + var wl_shell_interface_ptr = wl_shell_interface + windowManager.shell = OpaquePointer( + wl_registry_bind(registry, id, &wl_shell_interface_ptr, min(version, 1)) + ) + print("new shell", windowManager.shell) + case "wl_shm": + var wl_shm_interface_ptr = wl_shm_interface + windowManager.shm = OpaquePointer( + wl_registry_bind(registry, id, &wl_shm_interface_ptr, min(version, 1)) + ) + print("new shm", windowManager.shm) + default: + break + } + }, + global_remove: { _, _, _ in } + ) - override init() { + required init() { super.init() - Task { @MainActor in - setupWayland() - } + setupWayland() } private func setupWayland() { @@ -100,25 +130,4 @@ final class LinuxWindowManager: UIWindowManager { extension WaylandView: RenderSurface {} -// Wayland registry listener -nonisolated(unsafe) -private var registryListener = wl_registry_listener( - global: { data, registry, id, interface, version in - let windowManager = Unmanaged.fromOpaque(data!).takeUnretainedValue() - let interfaceName = String(cString: interface!) - - // switch interfaceName { - // case "wl_compositor": - // windowManager.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, min(version, 4)) - // case "wl_shell": - // windowManager.shell = wl_registry_bind(registry, id, wl_shell_interface, min(version, 1)) - // case "wl_shm": - // windowManager.shm = wl_registry_bind(registry, id, wl_shm_interface, min(version, 1)) - // default: - // break - // } - }, - global_remove: { _, _, _ in } -) - #endif diff --git a/Sources/AdaEngine/Platforms/Linux/WaylandView.swift b/Sources/AdaEngine/Platforms/Linux/WaylandView.swift index 27d96b24c..666e2d54f 100644 --- a/Sources/AdaEngine/Platforms/Linux/WaylandView.swift +++ b/Sources/AdaEngine/Platforms/Linux/WaylandView.swift @@ -32,6 +32,9 @@ final class WaylandView: SystemWindow { fatalError("Window manager is not set") } + print(#function) + print("Setup surface compositor", windowManager.compositor) + // Create surface surface = wl_compositor_create_surface(windowManager.compositor) guard surface != nil else { diff --git a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift index 1aa16d9d2..7d8034318 100644 --- a/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift +++ b/Sources/AdaEngine/Rendering/Backends/Vulkan/Misc/VulkanShader.swift @@ -122,18 +122,20 @@ final class VulkanShader: CompiledShader, @unchecked Sendable { layoutBindings.append(layout) writeDescriptorSet.append(set) } - - var createInfo = VkDescriptorSetLayoutCreateInfo( - sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, - pNext: nil, - flags: 0, - bindingCount: UInt32(layoutBindings.count), - pBindings: &layoutBindings - ) - + var descriptorSetLayout: VkDescriptorSetLayout? - let result = vkCreateDescriptorSetLayout(self.device.rawPointer, &createInfo, nil, &descriptorSetLayout) + let result = layoutBindings.withUnsafeBufferPointer { pBindings in + var createInfo = VkDescriptorSetLayoutCreateInfo( + sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, + pNext: nil, + flags: 0, + bindingCount: UInt32(layoutBindings.count), + pBindings: pBindings.baseAddress + ) + return vkCreateDescriptorSetLayout(self.device.rawPointer, &createInfo, nil, &descriptorSetLayout) + } + if let descriptorSetLayout, result == VK_SUCCESS { descriptorSetLayouts.append(descriptorSetLayout) } else {