More windowing changes for renderdoc

This commit is contained in:
2026-04-07 22:25:13 +02:00
parent 7af42b9bad
commit b6a449d8e3
3 changed files with 283 additions and 62 deletions
+73 -1
View File
@@ -1,6 +1,7 @@
#include "slang-compile.h"
#include "Containers/Array.h"
#include "Graphics/Descriptor.h"
#include <filesystem>
#include <fmt/core.h>
#include <iostream>
#include <slang.h>
@@ -27,9 +28,56 @@ thread_local Slang::ComPtr<slang::IComponentType> specializedComponent;
thread_local Slang::ComPtr<slang::ISession> session;
thread_local Array<std::string> entryPoints;
namespace {
std::filesystem::path getExecutableDirectory() {
std::error_code error;
auto exePath = std::filesystem::read_symlink("/proc/self/exe", error);
if (!error) {
return exePath.parent_path();
}
return std::filesystem::current_path();
}
std::filesystem::path findExistingDirectory(std::initializer_list<std::filesystem::path> candidates) {
for (const auto& candidate : candidates) {
std::error_code error;
if (std::filesystem::exists(candidate, error) && std::filesystem::is_directory(candidate, error)) {
return candidate;
}
}
return {};
}
void configureDownstreamCompilers(slang::IGlobalSession* session) {
const auto executableDirectory = getExecutableDirectory();
const auto currentDirectory = std::filesystem::current_path();
const auto glslangDirectory = findExistingDirectory({
executableDirectory / "Seele",
executableDirectory / "vcpkg_installed" / "x64-linux" / "lib",
currentDirectory / "Seele",
currentDirectory / "vcpkg_installed" / "x64-linux" / "lib",
});
if (!glslangDirectory.empty()) {
const std::string path = glslangDirectory.string();
session->setDownstreamCompilerPath(SLANG_PASS_THROUGH_GLSLANG, path.c_str());
session->setDownstreamCompilerPath(SLANG_PASS_THROUGH_SPIRV_OPT, path.c_str());
session->setDownstreamCompilerPath(SLANG_PASS_THROUGH_SPIRV_DIS, path.c_str());
}
// Avoid optional SPIR-V downstream tools that are often unavailable in RenderDoc launch environments.
session->setDefaultDownstreamCompiler(SLANG_SOURCE_LANGUAGE_SPIRV, SLANG_PASS_THROUGH_NONE);
session->setDownstreamCompilerForTransition(SLANG_SPIRV, SLANG_SPIRV, SLANG_PASS_THROUGH_NONE);
session->setDownstreamCompilerForTransition(SLANG_SPIRV, SLANG_SPIRV_ASM, SLANG_PASS_THROUGH_NONE);
}
}
void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarget target, Gfx::PPipelineLayout layout) {
if (!globalSession) {
slang::createGlobalSession(globalSession.writeRef());
SlangGlobalSessionDesc sessionDesc = {};
sessionDesc.enableGLSL = true;
slang::createGlobalSession(&sessionDesc, globalSession.writeRef());
configureDownstreamCompilers(globalSession);
}
slang::SessionDesc sessionDesc;
sessionDesc.flags = 0;
@@ -42,6 +90,30 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
.intValue0 = info.dumpIntermediate,
},
},
{
.name = slang::CompilerOptionName::Optimization,
.value =
{
.kind = slang::CompilerOptionValueKind::Int,
.intValue0 = SLANG_OPTIMIZATION_LEVEL_NONE,
},
},
{
.name = slang::CompilerOptionName::SkipSPIRVValidation,
.value =
{
.kind = slang::CompilerOptionValueKind::Int,
.intValue0 = 1,
},
},
{
.name = slang::CompilerOptionName::SkipDownstreamLinking,
.value =
{
.kind = slang::CompilerOptionValueKind::Int,
.intValue0 = 1,
},
},
};
sessionDesc.compilerOptionEntries = option.data();