Trying to add fluid simulation

This commit is contained in:
2026-04-12 20:49:02 +02:00
parent 056589a6f9
commit ac317a3829
65 changed files with 2708 additions and 371 deletions
+63 -16
View File
@@ -48,21 +48,79 @@ std::filesystem::path findExistingDirectory(std::initializer_list<std::filesyste
return {};
}
bool containsDownstreamCompilerArtifacts(const std::filesystem::path& directory) {
std::error_code error;
if (!std::filesystem::exists(directory, error) || !std::filesystem::is_directory(directory, error)) {
return false;
}
for (const auto& entry : std::filesystem::directory_iterator(directory, error)) {
if (error || !entry.is_regular_file(error)) {
continue;
}
const auto fileName = entry.path().filename().string();
if (fileName.rfind("slang-glslang", 0) == 0 || fileName.rfind("spirv-opt", 0) == 0 || fileName.rfind("spirv-dis", 0) == 0) {
return true;
}
}
return false;
}
bool hasArtifactWithPrefix(const std::filesystem::path& directory, const char* prefix) {
std::error_code error;
if (!std::filesystem::exists(directory, error) || !std::filesystem::is_directory(directory, error)) {
return false;
}
for (const auto& entry : std::filesystem::directory_iterator(directory, error)) {
if (error || !entry.is_regular_file(error)) {
continue;
}
if (entry.path().filename().string().rfind(prefix, 0) == 0) {
return true;
}
}
return false;
}
std::filesystem::path findDownstreamCompilerDirectory(std::initializer_list<std::filesystem::path> candidates) {
for (const auto& candidate : candidates) {
if (containsDownstreamCompilerArtifacts(candidate)) {
return candidate;
}
}
return findExistingDirectory(candidates);
}
void configureDownstreamCompilers(slang::IGlobalSession* session) {
const auto executableDirectory = getExecutableDirectory();
const auto currentDirectory = std::filesystem::current_path();
const auto glslangDirectory = findExistingDirectory({
const auto glslangDirectory = findDownstreamCompilerDirectory({
executableDirectory,
executableDirectory / "Seele",
executableDirectory / "vcpkg_installed" / "x64-linux" / "lib",
currentDirectory / "build",
currentDirectory / "build" / "Seele",
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());
if (hasArtifactWithPrefix(glslangDirectory, "slang-glslang") || hasArtifactWithPrefix(glslangDirectory, "libslang-glslang")) {
session->setDownstreamCompilerPath(SLANG_PASS_THROUGH_GLSLANG, path.c_str());
}
if (hasArtifactWithPrefix(glslangDirectory, "spirv-opt")) {
session->setDownstreamCompilerPath(SLANG_PASS_THROUGH_SPIRV_OPT, path.c_str());
}
if (hasArtifactWithPrefix(glslangDirectory, "spirv-dis")) {
session->setDownstreamCompilerPath(SLANG_PASS_THROUGH_SPIRV_DIS, path.c_str());
}
}
// Avoid optional SPIR-V downstream tools that are often unavailable in RenderDoc launch environments.
@@ -130,10 +188,9 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
sessionDesc.preprocessorMacros = macros.data();
slang::TargetDesc targetDesc = {};
targetDesc.format = target;
targetDesc.flags = SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY;
sessionDesc.targetCount = 1;
sessionDesc.targets = &targetDesc;
StaticArray<const char*, 7> searchPaths = {"shaders/", "shaders/lib/", "shaders/raytracing/", "shaders/terrain", "shaders/game", "shaders/generated/", "Seele/shaders/lib/"};
StaticArray<const char*, 7> searchPaths = {"shaders/", "shaders/lib/", "shaders/raytracing/", "shaders/terrain", "shaders/game", "shaders/generated/", "shaders/fluid"};
sessionDesc.searchPaths = searchPaths.data();
sessionDesc.searchPathCount = searchPaths.size();
@@ -184,16 +241,6 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
layout->addMapping(param->getName(), param->getBindingIndex());
}
// workaround
if (info.name == "RayGenMiss")
{
layout->addMapping("pScene", 2);
layout->addMapping("pLightEnv", 3);
layout->addMapping("pResources", 4);
layout->addMapping("pRayTracingParams", 5);
}
//layout->addMapping("pVertexData", 1);
// layout->addMapping("pWaterMaterial", 1);
}
Pair<Slang::ComPtr<slang::IBlob>, std::string> Seele::generateShader(const ShaderCreateInfo& createInfo) {