Merge branch 'dev-0.7-rewrite' of ssh://dev.npid7.de:222/tobid7/palladium into dev-0.7-rewrite

This commit is contained in:
2026-03-19 16:26:07 +01:00
19 changed files with 50 additions and 524 deletions

9
.gitmodules vendored
View File

@@ -7,9 +7,6 @@
[submodule "vendor/libpicasso"] [submodule "vendor/libpicasso"]
path = vendor/libpicasso path = vendor/libpicasso
url = https://github.com/tobid7/libpicasso url = https://github.com/tobid7/libpicasso
[submodule "vendor/glslang"] [submodule "vendor/spirv-helper"]
path = vendor/glslang path = vendor/spirv-helper
url = https://github.com/KhronosGroup/glslang.git url = https://github.com/tobid7/spirv-helper.git
[submodule "vendor/spirv-cross"]
path = vendor/spirv-cross
url = https://github.com/KhronosGroup/SPIRV-Cross.git

View File

@@ -11,6 +11,7 @@ option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
if(NOT WIN32) # cause we are not on windows... if(NOT WIN32) # cause we are not on windows...
set(PD_ENABLE_DIRECTX9 OFF) set(PD_ENABLE_DIRECTX9 OFF)
endif() endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
set(PD_ENABLE_OPENGL2 OFF) set(PD_ENABLE_OPENGL2 OFF)
set(PD_ENABLE_OPENGL3 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_opengl3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/spirv-helper.cpp
) )
target_include_directories(pd-system target_include_directories(pd-system
@@ -47,7 +47,6 @@ target_compile_definitions(pd-system
$<$<BOOL:${PD_ENABLE_VULKAN}>:PD_ENABLE_VULKAN> $<$<BOOL:${PD_ENABLE_VULKAN}>:PD_ENABLE_VULKAN>
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9> $<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9>
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D> $<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
$<$<OR:$<BOOL:${PD_ENABLE_OPENGL2}>,$<BOOL:${PD_ENABLE_OPENGL3}>,$<BOOL:${PD_ENABLE_VULKAN}>>:PD_ENABLE_SPIRV_HELPER>
) )
# Palladium # Palladium
@@ -79,12 +78,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
else() else()
target_link_libraries(pd-system target_link_libraries(pd-system
PUBLIC PUBLIC
spirv-cross-core spirv-helper
spirv-cross-cpp
spirv-cross-glsl
spirv-cross-hlsl
spirv-cross-msl
spirv-cross-reflect
spirv-cross-util
) )
endif() endif()

View File

@@ -1,34 +0,0 @@
#pragma once
#include <pd/common.hpp>
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<PD::u32> GLSL2SPV(Stage stage, const char* code,
bool vulkan_mode = false);
static std::string SPV2GLSL(const std::vector<PD::u32>& spirv, int version,
bool es = false);
static std::string SPV2HLSL(const std::vector<PD::u32>& spirv, int version);
};
} // namespace PD

View File

@@ -7,7 +7,7 @@
#include <pd/drivers/drivers.hpp> #include <pd/drivers/drivers.hpp>
#include <pd_system/gl-helper.hpp> #include <pd_system/gl-helper.hpp>
#include <pd_system/shaders.hpp> #include <pd_system/shaders.hpp>
#include <pd_system/spirv-helper.hpp> #include <spirv-helper.hpp>
namespace PD { namespace PD {
void GfxOpenGL3::SysInit() { void GfxOpenGL3::SysInit() {

View File

@@ -1,224 +0,0 @@
#if defined(PD_ENABLE_SPIRV_HELPER)
#if defined(PD_INCLUDE_GLSLANG)
#include <SPIRV/GlslangToSpv.h>
#include <glslang/Public/ResourceLimits.h>
#include <glslang/Public/ShaderLang.h>
#else
struct TBuiltInResource {};
#endif
#include <pd_system/spirv-helper.hpp>
#include <spirv.hpp>
#include <spirv_glsl.hpp>
#include <spirv_hlsl.hpp>
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<PD::u32> SpirvHelper::GLSL2SPV(Stage stage, const char* code,
bool vulkan_mode) {
std::vector<PD::u32> spv;
#if defined(PD_INCLUDE_GLSLANG)
EShLanguage estage = static_cast<EShLanguage>(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<PD::u32>& 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<PD::u32>& 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<PD::u32> SpirvHelper::GLSL2SPV(Stage stage, const char* code,
bool vulkan_mode) {
std::vector<PD::u32> spv;
return spv;
}
std::string SpirvHelper::SPV2GLSL(const std::vector<PD::u32>& spirv,
int version, bool es) {
std::string ret;
return ret;
}
std::string SpirvHelper::SPV2HLSL(const std::vector<PD::u32>& spirv,
int version) {
std::string ret;
return ret;
}
} // namespace PD
#endif

View File

@@ -4,3 +4,7 @@ project(core-tests)
add_executable(core-tests ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp) add_executable(core-tests ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp)
target_link_libraries(core-tests PRIVATE palladium::palladium) target_link_libraries(core-tests PRIVATE palladium::palladium)
install(
TARGETS core-tests
)

View File

@@ -8,3 +8,7 @@ target_link_libraries(gfx-tests PRIVATE palladium::palladium pd-system stb)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
target_link_libraries(gfx-tests PRIVATE glfw) target_link_libraries(gfx-tests PRIVATE glfw)
endif() endif()
install(
TARGETS gfx-tests
)

View File

@@ -50,12 +50,19 @@ class App {
if (d == Driver::OpenGL2) { if (d == Driver::OpenGL2) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
#ifdef __APPLE__
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, 0);
#endif
PD::Gfx::UseDriver<PD::GfxOpenGL2>(); PD::Gfx::UseDriver<PD::GfxOpenGL2>();
winname += " (OpenGL2)"; winname += " (OpenGL2)";
} else if (d == Driver::OpenGL3) { } else if (d == Driver::OpenGL3) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 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<PD::GfxOpenGL3>(); PD::Gfx::UseDriver<PD::GfxOpenGL3>();
winname += " (OpenGL3)"; winname += " (OpenGL3)";
} else if (d == Driver::DirectX9) { } else if (d == Driver::DirectX9) {
@@ -142,11 +149,13 @@ class App {
C3D_RenderTargetClear(Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0); C3D_RenderTargetClear(Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
#else #else
while (!glfwWindowShouldClose(window)) { 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) { if (pDriver == Driver::OpenGL2 || pDriver == Driver::OpenGL3) {
glClearColor(0.1, 0.1, 0.1, 0.1); glClearColor(0.1, 0.1, 0.1, 0.1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 1280, 720); glViewport(0, 0, ww, wh);
} else if (pDriver == Driver::DirectX9) { } else if (pDriver == Driver::DirectX9) {
#ifdef _WIN32 #ifdef _WIN32
if (dx9_device) { if (dx9_device) {

View File

@@ -16,3 +16,6 @@ add_executable(lazyvec
source/lazyswap.cpp source/lazyswap.cpp
) )
target_include_directories(lazyvec PUBLIC include) target_include_directories(lazyvec PUBLIC include)
install(
TARGETS lazyvec
)

View File

@@ -9,3 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED true)
add_executable(pdfm add_executable(pdfm
source/main.cpp source/main.cpp
) )
install(
TARGETS pdfm
)

View File

@@ -9,3 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED true)
add_executable(pdlm add_executable(pdlm
source/main.cpp source/main.cpp
) )
install(
TARGETS pdlm
)

View File

@@ -8,22 +8,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED true)
add_executable(pdsg add_executable(pdsg
${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp ${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 target_link_libraries(pdsg PRIVATE
glslang spirv-helper::spirv-helper
glslang-default-resource-limits )
OSDependent
SPIRV install(
TARGETS pdsg
spirv-cross-core
spirv-cross-cpp
spirv-cross-glsl
spirv-cross-hlsl
spirv-cross-msl
spirv-cross-reflect
spirv-cross-util
) )

View File

@@ -1,34 +0,0 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
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<unsigned int> GLSL2SPV(Stage stage, const char* code);
static std::string SPV2GLSL(const std::vector<unsigned int>& spirv,
int version, bool es = false);
static std::string SPV2HLSL(const std::vector<unsigned int>& spirv,
int version);
};

View File

@@ -1,184 +0,0 @@
#include <SPIRV/GlslangToSpv.h>
#include <glslang/Public/ResourceLimits.h>
#include <glslang/Public/ShaderLang.h>
#include <spirv-helper.hpp>
#include <spirv.hpp>
#include <spirv_glsl.hpp>
#include <spirv_hlsl.hpp>
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<unsigned int> SpirvHelper::GLSL2SPV(Stage stage, const char* code) {
std::vector<unsigned int> spv;
EShLanguage estage = static_cast<EShLanguage>(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<unsigned int>& 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<unsigned int>& 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;
}

View File

@@ -9,3 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED true)
add_executable(ppam add_executable(ppam
source/main.cpp source/main.cpp
) )
install(
TARGETS ppam
)

12
vendor/CMakeLists.txt vendored
View File

@@ -5,16 +5,8 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
else() else()
# GLAD # GLAD
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad)
# SPIRV-Cross # SPIRV-Helper
set(SPIRV_CROSS_CLI OFF CACHE BOOL "" FORCE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-helper)
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)
endif() endif()
# STB # STB

1
vendor/glslang vendored

Submodule vendor/glslang deleted from 09c541ee5b

1
vendor/spirv-cross vendored

Submodule vendor/spirv-cross deleted from a0fba56c34

1
vendor/spirv-helper vendored Submodule

Submodule vendor/spirv-helper added at 681ab8a8b3