From 66602a79e0ed20bd65228b90df96d6a083970627 Mon Sep 17 00:00:00 2001 From: tobid7 Date: Thu, 19 Mar 2026 15:54:01 +0100 Subject: [PATCH] Replace spirv-helper stuff with a library that combines everything --- .gitmodules | 9 +- backends/CMakeLists.txt | 11 +- backends/include/pd_system/spirv-helper.hpp | 34 --- backends/source/gfx_opengl3.cpp | 2 +- backends/source/spirv-helper.cpp | 224 -------------------- tests/core/CMakeLists.txt | 4 + tests/gfx/CMakeLists.txt | 4 + tests/gfx/source/main.cpp | 13 +- tools/lazyvec/CMakeLists.txt | 3 + tools/pdfm/CMakeLists.txt | 4 + tools/pdlm/CMakeLists.txt | 4 + tools/pdsg/CMakeLists.txt | 23 +- tools/pdsg/include/spirv-helper.hpp | 34 --- tools/pdsg/source/spirv-helper.cpp | 184 ---------------- tools/ppam/CMakeLists.txt | 6 +- vendor/CMakeLists.txt | 12 +- vendor/glslang | 1 - vendor/spirv-cross | 1 - vendor/spirv-helper | 1 + 19 files changed, 50 insertions(+), 524 deletions(-) delete mode 100644 backends/include/pd_system/spirv-helper.hpp delete mode 100644 backends/source/spirv-helper.cpp delete mode 100644 tools/pdsg/include/spirv-helper.hpp delete mode 100644 tools/pdsg/source/spirv-helper.cpp delete mode 160000 vendor/glslang delete mode 160000 vendor/spirv-cross create mode 160000 vendor/spirv-helper diff --git a/.gitmodules b/.gitmodules index 7f58658..ea256f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "vendor/libpicasso"] path = vendor/libpicasso url = https://github.com/tobid7/libpicasso -[submodule "vendor/glslang"] - path = vendor/glslang - url = https://github.com/KhronosGroup/glslang.git -[submodule "vendor/spirv-cross"] - path = vendor/spirv-cross - url = https://github.com/KhronosGroup/SPIRV-Cross.git +[submodule "vendor/spirv-helper"] + path = vendor/spirv-helper + url = https://github.com/tobid7/spirv-helper.git diff --git a/backends/CMakeLists.txt b/backends/CMakeLists.txt index 1decac4..997d027 100644 --- a/backends/CMakeLists.txt +++ b/backends/CMakeLists.txt @@ -11,6 +11,7 @@ option(PD_ENABLE_VULKAN "Not implemented yet" OFF) if(NOT WIN32) # cause we are not on windows... set(PD_ENABLE_DIRECTX9 OFF) endif() + if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") set(PD_ENABLE_OPENGL2 OFF) set(PD_ENABLE_OPENGL3 OFF) @@ -24,7 +25,6 @@ add_library(pd-system STATIC ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/source/spirv-helper.cpp ) target_include_directories(pd-system @@ -47,7 +47,6 @@ target_compile_definitions(pd-system $<$:PD_ENABLE_VULKAN> $<$:PD_ENABLE_DIRECTX9> $<$:PD_ENABLE_CITRO3D> - $<$,$,$>:PD_ENABLE_SPIRV_HELPER> ) # Palladium @@ -79,12 +78,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") else() target_link_libraries(pd-system PUBLIC - spirv-cross-core - spirv-cross-cpp - spirv-cross-glsl - spirv-cross-hlsl - spirv-cross-msl - spirv-cross-reflect - spirv-cross-util + spirv-helper ) endif() diff --git a/backends/include/pd_system/spirv-helper.hpp b/backends/include/pd_system/spirv-helper.hpp deleted file mode 100644 index 12ebfa6..0000000 --- a/backends/include/pd_system/spirv-helper.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include - -struct TBuiltInResource; -namespace PD { -class SpirvHelper { - public: - enum class Format { - GLSL, - HLSL, - MSL, // Not supported yet - SPIRV, - }; - - enum class Stage { - Vertex = 0, - Geometry = 3, - Fragment = 4, - }; - - SpirvHelper() = default; - ~SpirvHelper() = default; - - static void Init(); - static void Finalize(); - static void SetupResources(TBuiltInResource& resources); - static std::vector GLSL2SPV(Stage stage, const char* code, - bool vulkan_mode = false); - static std::string SPV2GLSL(const std::vector& spirv, int version, - bool es = false); - static std::string SPV2HLSL(const std::vector& spirv, int version); -}; -} // namespace PD \ No newline at end of file diff --git a/backends/source/gfx_opengl3.cpp b/backends/source/gfx_opengl3.cpp index 64bc27a..227956e 100644 --- a/backends/source/gfx_opengl3.cpp +++ b/backends/source/gfx_opengl3.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include namespace PD { void GfxOpenGL3::SysInit() { diff --git a/backends/source/spirv-helper.cpp b/backends/source/spirv-helper.cpp deleted file mode 100644 index 2312c98..0000000 --- a/backends/source/spirv-helper.cpp +++ /dev/null @@ -1,224 +0,0 @@ -#if defined(PD_ENABLE_SPIRV_HELPER) -#if defined(PD_INCLUDE_GLSLANG) -#include -#include -#include -#else -struct TBuiltInResource {}; -#endif -#include -#include -#include -#include - -namespace PD { -#if defined(PD_INCLUDE_GLSLANG) -void SpirvHelper::Init() { glslang::InitializeProcess(); } - -void SpirvHelper::Finalize() { glslang::FinalizeProcess(); } -#else -void SpirvHelper::Init() {} - -void SpirvHelper::Finalize() {} -#endif -void SpirvHelper::SetupResources(TBuiltInResource& resources) { -#if defined(PD_INCLUDE_GLSLANG) - resources.maxLights = 32; - resources.maxClipPlanes = 6; - resources.maxTextureUnits = 32; - resources.maxTextureCoords = 32; - resources.maxVertexAttribs = 64; - resources.maxVertexUniformComponents = 4096; - resources.maxVaryingFloats = 64; - resources.maxVertexTextureImageUnits = 32; - resources.maxCombinedTextureImageUnits = 80; - resources.maxTextureImageUnits = 32; - resources.maxFragmentUniformComponents = 4096; - resources.maxDrawBuffers = 32; - resources.maxVertexUniformVectors = 128; - resources.maxVaryingVectors = 8; - resources.maxFragmentUniformVectors = 16; - resources.maxVertexOutputVectors = 16; - resources.maxFragmentInputVectors = 15; - resources.minProgramTexelOffset = -8; - resources.maxProgramTexelOffset = 7; - resources.maxClipDistances = 8; - resources.maxComputeWorkGroupCountX = 65535; - resources.maxComputeWorkGroupCountY = 65535; - resources.maxComputeWorkGroupCountZ = 65535; - resources.maxComputeWorkGroupSizeX = 1024; - resources.maxComputeWorkGroupSizeY = 1024; - resources.maxComputeWorkGroupSizeZ = 64; - resources.maxComputeUniformComponents = 1024; - resources.maxComputeTextureImageUnits = 16; - resources.maxComputeImageUniforms = 8; - resources.maxComputeAtomicCounters = 8; - resources.maxComputeAtomicCounterBuffers = 1; - resources.maxVaryingComponents = 60; - resources.maxVertexOutputComponents = 64; - resources.maxGeometryInputComponents = 64; - resources.maxGeometryOutputComponents = 128; - resources.maxFragmentInputComponents = 128; - resources.maxImageUnits = 8; - resources.maxCombinedImageUnitsAndFragmentOutputs = 8; - resources.maxCombinedShaderOutputResources = 8; - resources.maxImageSamples = 0; - resources.maxVertexImageUniforms = 0; - resources.maxTessControlImageUniforms = 0; - resources.maxTessEvaluationImageUniforms = 0; - resources.maxGeometryImageUniforms = 0; - resources.maxFragmentImageUniforms = 8; - resources.maxCombinedImageUniforms = 8; - resources.maxGeometryTextureImageUnits = 16; - resources.maxGeometryOutputVertices = 256; - resources.maxGeometryTotalOutputComponents = 1024; - resources.maxGeometryUniformComponents = 1024; - resources.maxGeometryVaryingComponents = 64; - resources.maxTessControlInputComponents = 128; - resources.maxTessControlOutputComponents = 128; - resources.maxTessControlTextureImageUnits = 16; - resources.maxTessControlUniformComponents = 1024; - resources.maxTessControlTotalOutputComponents = 4096; - resources.maxTessEvaluationInputComponents = 128; - resources.maxTessEvaluationOutputComponents = 128; - resources.maxTessEvaluationTextureImageUnits = 16; - resources.maxTessEvaluationUniformComponents = 1024; - resources.maxTessPatchComponents = 120; - resources.maxPatchVertices = 32; - resources.maxTessGenLevel = 64; - resources.maxViewports = 16; - resources.maxVertexAtomicCounters = 0; - resources.maxTessControlAtomicCounters = 0; - resources.maxTessEvaluationAtomicCounters = 0; - resources.maxGeometryAtomicCounters = 0; - resources.maxFragmentAtomicCounters = 8; - resources.maxCombinedAtomicCounters = 8; - resources.maxAtomicCounterBindings = 1; - resources.maxVertexAtomicCounterBuffers = 0; - resources.maxTessControlAtomicCounterBuffers = 0; - resources.maxTessEvaluationAtomicCounterBuffers = 0; - resources.maxGeometryAtomicCounterBuffers = 0; - resources.maxFragmentAtomicCounterBuffers = 1; - resources.maxCombinedAtomicCounterBuffers = 1; - resources.maxAtomicCounterBufferSize = 16384; - resources.maxTransformFeedbackBuffers = 4; - resources.maxTransformFeedbackInterleavedComponents = 64; - resources.maxCullDistances = 8; - resources.maxCombinedClipAndCullDistances = 8; - resources.maxSamples = 4; - resources.maxMeshOutputVerticesNV = 256; - resources.maxMeshOutputPrimitivesNV = 512; - resources.maxMeshWorkGroupSizeX_NV = 32; - resources.maxMeshWorkGroupSizeY_NV = 1; - resources.maxMeshWorkGroupSizeZ_NV = 1; - resources.maxTaskWorkGroupSizeX_NV = 32; - resources.maxTaskWorkGroupSizeY_NV = 1; - resources.maxTaskWorkGroupSizeZ_NV = 1; - resources.maxMeshViewCountNV = 4; - resources.limits.nonInductiveForLoops = 1; - resources.limits.whileLoops = 1; - resources.limits.doWhileLoops = 1; - resources.limits.generalUniformIndexing = 1; - resources.limits.generalAttributeMatrixVectorIndexing = 1; - resources.limits.generalVaryingIndexing = 1; - resources.limits.generalSamplerIndexing = 1; - resources.limits.generalVariableIndexing = 1; - resources.limits.generalConstantMatrixVectorIndexing = 1; -#endif -} - -std::vector SpirvHelper::GLSL2SPV(Stage stage, const char* code, - bool vulkan_mode) { - std::vector spv; -#if defined(PD_INCLUDE_GLSLANG) - EShLanguage estage = static_cast(stage); - glslang::TShader shader(estage); - glslang::TProgram program; - const char* strings[1]; - TBuiltInResource resources = {}; - SetupResources(resources); - - EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules); - - strings[0] = code; - shader.setStrings(strings, 1); - shader.setAutoMapBindings(true); - shader.setAutoMapLocations(true); - - if (!shader.parse(&resources, 100, false, messages)) { - puts(shader.getInfoLog()); - puts(shader.getInfoDebugLog()); - return spv; - } - - program.addShader(&shader); - - if (!program.link(messages)) { - puts(shader.getInfoLog()); - puts(shader.getInfoDebugLog()); - fflush(stdout); - return spv; - } - - glslang::GlslangToSpv(*program.getIntermediate(estage), spv); -#endif - return spv; -} - -std::string SpirvHelper::SPV2GLSL(const std::vector& spirv, - int version, bool es) { - std::string ret; - spirv_cross::CompilerGLSL glsl(spirv); - spirv_cross::ShaderResources resources = glsl.get_shader_resources(); - for (auto& resource : resources.stage_inputs) { - glsl.unset_decoration(resource.id, spv::DecorationLocation); - } - for (auto& resource : resources.stage_outputs) { - glsl.unset_decoration(resource.id, spv::DecorationLocation); - } - spirv_cross::CompilerGLSL::Options scoptions; - scoptions.version = version; - scoptions.es = es; - scoptions.emit_uniform_buffer_as_plain_uniforms = true; - scoptions.enable_420pack_extension = false; - glsl.set_common_options(scoptions); - ret = glsl.compile(); - return ret; -} - -std::string SpirvHelper::SPV2HLSL(const std::vector& spirv, - int version) { - std::string ret; - spirv_cross::CompilerHLSL hlsl(spirv); - spirv_cross::CompilerHLSL::Options scoptions; - scoptions.shader_model = version; - scoptions.point_size_compat = false; - scoptions.force_storage_buffer_as_uav = false; - hlsl.set_hlsl_options(scoptions); - ret = hlsl.compile(); - return ret; -} -} // namespace PD -#else -struct TBuiltInResource {}; -namespace PD { -void SpirvHelper::Init() { glslang::InitializeProcess(); } -void SpirvHelper::Finalize() { glslang::FinalizeProcess(); } -void SpirvHelper::SetupResources(TBuiltInResource& resources) {} -std::vector SpirvHelper::GLSL2SPV(Stage stage, const char* code, - bool vulkan_mode) { - std::vector spv; - return spv; -} -std::string SpirvHelper::SPV2GLSL(const std::vector& spirv, - int version, bool es) { - std::string ret; - return ret; -} -std::string SpirvHelper::SPV2HLSL(const std::vector& spirv, - int version) { - std::string ret; - return ret; -} -} // namespace PD -#endif \ No newline at end of file diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index 08bdbe1..9961900 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -4,3 +4,7 @@ project(core-tests) add_executable(core-tests ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp) target_link_libraries(core-tests PRIVATE palladium::palladium) + +install( + TARGETS core-tests +) \ No newline at end of file diff --git a/tests/gfx/CMakeLists.txt b/tests/gfx/CMakeLists.txt index 5e2d4ea..a8d7db0 100644 --- a/tests/gfx/CMakeLists.txt +++ b/tests/gfx/CMakeLists.txt @@ -8,3 +8,7 @@ target_link_libraries(gfx-tests PRIVATE palladium::palladium pd-system stb) if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") target_link_libraries(gfx-tests PRIVATE glfw) endif() + +install( + TARGETS gfx-tests +) \ No newline at end of file diff --git a/tests/gfx/source/main.cpp b/tests/gfx/source/main.cpp index 2696201..7aa3261 100644 --- a/tests/gfx/source/main.cpp +++ b/tests/gfx/source/main.cpp @@ -50,12 +50,19 @@ class App { if (d == Driver::OpenGL2) { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); +#ifdef __APPLE__ + glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, 0); +#endif PD::Gfx::UseDriver(); winname += " (OpenGL2)"; } else if (d == Driver::OpenGL3) { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); +#ifdef __APPLE__ + glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, 0); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, 1); +#endif PD::Gfx::UseDriver(); winname += " (OpenGL3)"; } else if (d == Driver::DirectX9) { @@ -142,11 +149,13 @@ class App { C3D_RenderTargetClear(Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0); #else while (!glfwWindowShouldClose(window)) { - PD::Gfx::SetViewPort(1280, 720); + int ww, wh; + glfwGetFramebufferSize(window, &ww, &wh); + PD::Gfx::SetViewPort(ww, wh); if (pDriver == Driver::OpenGL2 || pDriver == Driver::OpenGL3) { glClearColor(0.1, 0.1, 0.1, 0.1); glClear(GL_COLOR_BUFFER_BIT); - glViewport(0, 0, 1280, 720); + glViewport(0, 0, ww, wh); } else if (pDriver == Driver::DirectX9) { #ifdef _WIN32 if (dx9_device) { diff --git a/tools/lazyvec/CMakeLists.txt b/tools/lazyvec/CMakeLists.txt index 66862e1..f564a06 100755 --- a/tools/lazyvec/CMakeLists.txt +++ b/tools/lazyvec/CMakeLists.txt @@ -16,3 +16,6 @@ add_executable(lazyvec source/lazyswap.cpp ) target_include_directories(lazyvec PUBLIC include) +install( + TARGETS lazyvec +) \ No newline at end of file diff --git a/tools/pdfm/CMakeLists.txt b/tools/pdfm/CMakeLists.txt index 63a1a8e..70352b7 100644 --- a/tools/pdfm/CMakeLists.txt +++ b/tools/pdfm/CMakeLists.txt @@ -9,3 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED true) add_executable(pdfm source/main.cpp ) + +install( + TARGETS pdfm +) \ No newline at end of file diff --git a/tools/pdlm/CMakeLists.txt b/tools/pdlm/CMakeLists.txt index 1db1d98..294fd4e 100755 --- a/tools/pdlm/CMakeLists.txt +++ b/tools/pdlm/CMakeLists.txt @@ -9,3 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED true) add_executable(pdlm source/main.cpp ) + +install( + TARGETS pdlm +) \ No newline at end of file diff --git a/tools/pdsg/CMakeLists.txt b/tools/pdsg/CMakeLists.txt index ca00de3..cef4575 100644 --- a/tools/pdsg/CMakeLists.txt +++ b/tools/pdsg/CMakeLists.txt @@ -2,28 +2,17 @@ cmake_minimum_required(VERSION 3.22) project(pdsg LANGUAGES CXX VERSION 1.0.0) -### Requires C++ 20 +# ## Requires C++ 20 set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED true) add_executable(pdsg ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/source/spirv-helper.cpp -) -target_include_directories(pdsg PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/include ) target_link_libraries(pdsg PRIVATE - glslang - glslang-default-resource-limits - OSDependent - SPIRV - - spirv-cross-core - spirv-cross-cpp - spirv-cross-glsl - spirv-cross-hlsl - spirv-cross-msl - spirv-cross-reflect - spirv-cross-util + spirv-helper::spirv-helper ) + +install( + TARGETS pdsg +) \ No newline at end of file diff --git a/tools/pdsg/include/spirv-helper.hpp b/tools/pdsg/include/spirv-helper.hpp deleted file mode 100644 index ac462ea..0000000 --- a/tools/pdsg/include/spirv-helper.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include - -struct TBuiltInResource; -class SpirvHelper { - public: - enum class Format { - GLSL, - HLSL, - MSL, // Not supported yet - SPIRV, - }; - - enum class Stage { - Vertex = 0, - Geometry = 3, - Fragment = 4, - }; - - SpirvHelper() = default; - ~SpirvHelper() = default; - - static void Init(); - static void Finalize(); - static void SetupResources(TBuiltInResource& resources); - static std::vector GLSL2SPV(Stage stage, const char* code); - static std::string SPV2GLSL(const std::vector& spirv, - int version, bool es = false); - static std::string SPV2HLSL(const std::vector& spirv, - int version); -}; \ No newline at end of file diff --git a/tools/pdsg/source/spirv-helper.cpp b/tools/pdsg/source/spirv-helper.cpp deleted file mode 100644 index 39c703d..0000000 --- a/tools/pdsg/source/spirv-helper.cpp +++ /dev/null @@ -1,184 +0,0 @@ - -#include -#include -#include - -#include -#include -#include -#include - -void SpirvHelper::Init() { glslang::InitializeProcess(); } -void SpirvHelper::Finalize() { glslang::FinalizeProcess(); } -void SpirvHelper::SetupResources(TBuiltInResource& resources) { - resources.maxLights = 32; - resources.maxClipPlanes = 6; - resources.maxTextureUnits = 32; - resources.maxTextureCoords = 32; - resources.maxVertexAttribs = 64; - resources.maxVertexUniformComponents = 4096; - resources.maxVaryingFloats = 64; - resources.maxVertexTextureImageUnits = 32; - resources.maxCombinedTextureImageUnits = 80; - resources.maxTextureImageUnits = 32; - resources.maxFragmentUniformComponents = 4096; - resources.maxDrawBuffers = 32; - resources.maxVertexUniformVectors = 128; - resources.maxVaryingVectors = 8; - resources.maxFragmentUniformVectors = 16; - resources.maxVertexOutputVectors = 16; - resources.maxFragmentInputVectors = 15; - resources.minProgramTexelOffset = -8; - resources.maxProgramTexelOffset = 7; - resources.maxClipDistances = 8; - resources.maxComputeWorkGroupCountX = 65535; - resources.maxComputeWorkGroupCountY = 65535; - resources.maxComputeWorkGroupCountZ = 65535; - resources.maxComputeWorkGroupSizeX = 1024; - resources.maxComputeWorkGroupSizeY = 1024; - resources.maxComputeWorkGroupSizeZ = 64; - resources.maxComputeUniformComponents = 1024; - resources.maxComputeTextureImageUnits = 16; - resources.maxComputeImageUniforms = 8; - resources.maxComputeAtomicCounters = 8; - resources.maxComputeAtomicCounterBuffers = 1; - resources.maxVaryingComponents = 60; - resources.maxVertexOutputComponents = 64; - resources.maxGeometryInputComponents = 64; - resources.maxGeometryOutputComponents = 128; - resources.maxFragmentInputComponents = 128; - resources.maxImageUnits = 8; - resources.maxCombinedImageUnitsAndFragmentOutputs = 8; - resources.maxCombinedShaderOutputResources = 8; - resources.maxImageSamples = 0; - resources.maxVertexImageUniforms = 0; - resources.maxTessControlImageUniforms = 0; - resources.maxTessEvaluationImageUniforms = 0; - resources.maxGeometryImageUniforms = 0; - resources.maxFragmentImageUniforms = 8; - resources.maxCombinedImageUniforms = 8; - resources.maxGeometryTextureImageUnits = 16; - resources.maxGeometryOutputVertices = 256; - resources.maxGeometryTotalOutputComponents = 1024; - resources.maxGeometryUniformComponents = 1024; - resources.maxGeometryVaryingComponents = 64; - resources.maxTessControlInputComponents = 128; - resources.maxTessControlOutputComponents = 128; - resources.maxTessControlTextureImageUnits = 16; - resources.maxTessControlUniformComponents = 1024; - resources.maxTessControlTotalOutputComponents = 4096; - resources.maxTessEvaluationInputComponents = 128; - resources.maxTessEvaluationOutputComponents = 128; - resources.maxTessEvaluationTextureImageUnits = 16; - resources.maxTessEvaluationUniformComponents = 1024; - resources.maxTessPatchComponents = 120; - resources.maxPatchVertices = 32; - resources.maxTessGenLevel = 64; - resources.maxViewports = 16; - resources.maxVertexAtomicCounters = 0; - resources.maxTessControlAtomicCounters = 0; - resources.maxTessEvaluationAtomicCounters = 0; - resources.maxGeometryAtomicCounters = 0; - resources.maxFragmentAtomicCounters = 8; - resources.maxCombinedAtomicCounters = 8; - resources.maxAtomicCounterBindings = 1; - resources.maxVertexAtomicCounterBuffers = 0; - resources.maxTessControlAtomicCounterBuffers = 0; - resources.maxTessEvaluationAtomicCounterBuffers = 0; - resources.maxGeometryAtomicCounterBuffers = 0; - resources.maxFragmentAtomicCounterBuffers = 1; - resources.maxCombinedAtomicCounterBuffers = 1; - resources.maxAtomicCounterBufferSize = 16384; - resources.maxTransformFeedbackBuffers = 4; - resources.maxTransformFeedbackInterleavedComponents = 64; - resources.maxCullDistances = 8; - resources.maxCombinedClipAndCullDistances = 8; - resources.maxSamples = 4; - resources.maxMeshOutputVerticesNV = 256; - resources.maxMeshOutputPrimitivesNV = 512; - resources.maxMeshWorkGroupSizeX_NV = 32; - resources.maxMeshWorkGroupSizeY_NV = 1; - resources.maxMeshWorkGroupSizeZ_NV = 1; - resources.maxTaskWorkGroupSizeX_NV = 32; - resources.maxTaskWorkGroupSizeY_NV = 1; - resources.maxTaskWorkGroupSizeZ_NV = 1; - resources.maxMeshViewCountNV = 4; - resources.limits.nonInductiveForLoops = 1; - resources.limits.whileLoops = 1; - resources.limits.doWhileLoops = 1; - resources.limits.generalUniformIndexing = 1; - resources.limits.generalAttributeMatrixVectorIndexing = 1; - resources.limits.generalVaryingIndexing = 1; - resources.limits.generalSamplerIndexing = 1; - resources.limits.generalVariableIndexing = 1; - resources.limits.generalConstantMatrixVectorIndexing = 1; -} - -std::vector SpirvHelper::GLSL2SPV(Stage stage, const char* code) { - std::vector spv; - EShLanguage estage = static_cast(stage); - glslang::TShader shader(estage); - glslang::TProgram program; - const char* strings[1]; - TBuiltInResource resources = {}; - SetupResources(resources); - - EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules); - - strings[0] = code; - shader.setStrings(strings, 1); - shader.setAutoMapBindings(true); - shader.setAutoMapLocations(true); - - if (!shader.parse(&resources, 100, false, messages)) { - puts(shader.getInfoLog()); - puts(shader.getInfoDebugLog()); - return spv; - } - - program.addShader(&shader); - - if (!program.link(messages)) { - puts(shader.getInfoLog()); - puts(shader.getInfoDebugLog()); - fflush(stdout); - return spv; - } - - glslang::GlslangToSpv(*program.getIntermediate(estage), spv); - return spv; -} - -std::string SpirvHelper::SPV2GLSL(const std::vector& spirv, - int version, bool es) { - std::string ret; - spirv_cross::CompilerGLSL glsl(spirv); - spirv_cross::ShaderResources resources = glsl.get_shader_resources(); - for (auto& resource : resources.stage_inputs) { - glsl.unset_decoration(resource.id, spv::DecorationLocation); - } - for (auto& resource : resources.stage_outputs) { - glsl.unset_decoration(resource.id, spv::DecorationLocation); - } - spirv_cross::CompilerGLSL::Options scoptions; - scoptions.version = version; - scoptions.es = es; - scoptions.emit_uniform_buffer_as_plain_uniforms = true; - scoptions.enable_420pack_extension = false; - glsl.set_common_options(scoptions); - ret = glsl.compile(); - return ret; -} - -std::string SpirvHelper::SPV2HLSL(const std::vector& spirv, - int version) { - std::string ret; - spirv_cross::CompilerHLSL hlsl(spirv); - spirv_cross::CompilerHLSL::Options scoptions; - scoptions.shader_model = version; - scoptions.point_size_compat = false; - scoptions.force_storage_buffer_as_uav = false; - hlsl.set_hlsl_options(scoptions); - ret = hlsl.compile(); - return ret; -} \ No newline at end of file diff --git a/tools/ppam/CMakeLists.txt b/tools/ppam/CMakeLists.txt index 41b8ea1..6886116 100755 --- a/tools/ppam/CMakeLists.txt +++ b/tools/ppam/CMakeLists.txt @@ -2,10 +2,14 @@ cmake_minimum_required(VERSION 3.22) project(ppam LANGUAGES CXX VERSION 1.0.0) -### Requires C++ 20 +# ## Requires C++ 20 set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED true) add_executable(ppam source/main.cpp ) + +install( + TARGETS ppam +) \ No newline at end of file diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 9d59a92..7bde67d 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -5,16 +5,8 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") else() # GLAD add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad) - # SPIRV-Cross - set(SPIRV_CROSS_CLI OFF CACHE BOOL "" FORCE) - set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE BOOL "" FORCE) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross) -endif() - -if(PD_BUILD_TOOLS) - # GLSLANG - set(ENABLE_OPT OFF CACHE BOOL "" FORCE) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glslang) + # SPIRV-Helper + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-helper) endif() # STB diff --git a/vendor/glslang b/vendor/glslang deleted file mode 160000 index 09c541e..0000000 --- a/vendor/glslang +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 09c541ee5b22bbac307987b50d86ec2b4f683d75 diff --git a/vendor/spirv-cross b/vendor/spirv-cross deleted file mode 160000 index a0fba56..0000000 --- a/vendor/spirv-cross +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a0fba56c34a6700f1724bf9b751da5b488a3775c diff --git a/vendor/spirv-helper b/vendor/spirv-helper new file mode 160000 index 0000000..681ab8a --- /dev/null +++ b/vendor/spirv-helper @@ -0,0 +1 @@ +Subproject commit 681ab8a8b3626ff3788cd33d92a67002d513a4d9