Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/xmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
- { runner: windows-2025, os: windows, arch: x64, toolchain: msvc, mode: release, runtime: MT }
- { runner: windows-2025, os: windows, arch: x64, toolchain: msvc, mode: debug, runtime: MTd }

- { runner: windows-2025, os: windows, arch: x64, toolchain: clang-cl, mode: release, runtime: MT }
- { runner: windows-2025, os: windows, arch: x64, toolchain: clang-cl, mode: debug, runtime: MTd }
# - { runner: windows-2025, os: windows, arch: x64, toolchain: clang-cl, mode: release, runtime: MT }
# - { runner: windows-2025, os: windows, arch: x64, toolchain: clang-cl, mode: debug, runtime: MTd }

- { runner: ubuntu-latest, os: linux, arch: x86_64, toolchain: clang-20, mode: release, runtime: c++_static }
- { runner: ubuntu-latest, os: linux, arch: x86_64, toolchain: clang-20, mode: debug, runtime: c++_static }
Expand Down
6 changes: 3 additions & 3 deletions Oxylus/include/Asset/EmbedAsset.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include <string>
#include <vuk/runtime/vk/VkRuntime.hpp>

namespace ox {
class EmbedAsset {
public:
static auto embed_texture(
const std::string& tex_file_path, const std::string& out_path, const std::string& array_name
) -> void;
static auto embed_shader(vuk::Runtime& runtime, const std::string& shader_path, const std::string& out_path, const std::string& entry_point)
static auto embed_shader(const std::string& shader_path, const std::string& out_path, const std::string& entry_point)
-> void;
static auto embed_binary(const std::string& binary_path, const std::string& out_path, const std::string& array_name)
-> void;
static auto embed_binary(const std::string& binary_path, const std::string& out_path, const std::string& array_name) -> void;
};
} // namespace ox
26 changes: 6 additions & 20 deletions Oxylus/include/Render/Slang/Compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,26 @@

namespace ox {
struct SlangSessionInfo {
i32 optimizaton_level;
std::string name = {};
i32 optimizaton_level = 3;
std::vector<std::pair<std::string, std::string>> definitions = {};
std::filesystem::path root_directory = {};
};

struct SlangModuleInfo {
struct SlangShaderInfo {
std::filesystem::path path = {};
std::string module_name = {};
std::vector<std::string> entry_points = {};
};

struct SlangEntryPoint {
std::vector<u32> ir = {};
};

struct ShaderReflection {
u32 pipeline_layout_index = 0;
glm::u64vec3 thread_group_size = {};
};

struct SlangSession;
struct SlangModule : Handle<SlangModule> {
void destroy();

option<SlangEntryPoint> get_entry_point(std::string_view name);
ShaderReflection get_reflection();
SlangSession session();
std::vector<u32> code = {};
};

struct SlangSession : Handle<SlangSession> {
friend SlangModule;

auto destroy() -> void;

option<SlangModule> load_module(const SlangModuleInfo& info);
auto compile_shader(const SlangShaderInfo& info) -> option<std::vector<SlangEntryPoint>>;
};

struct SlangCompiler : Handle<SlangCompiler> {
Expand Down
42 changes: 0 additions & 42 deletions Oxylus/include/Render/Slang/Slang.hpp

This file was deleted.

11 changes: 11 additions & 0 deletions Oxylus/include/Render/Vulkan/VkContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
#include "Render/Slang/Compiler.hpp"

namespace ox {
struct PipelineCompileInfo {
std::filesystem::path path = {};
std::string module_name = {};
std::vector<std::string> entry_points = {};
vuk::PersistentDescriptorSet* persistent_set = nullptr;
};

struct Window;
class TracyProfiler;

Expand Down Expand Up @@ -93,6 +100,10 @@ class VkContext {
) -> vuk::PersistentDescriptorSet;
auto commit_descriptor_set(this VkContext&, std::span<VkWriteDescriptorSet> writes) -> void;

auto create_pipelines(
this VkContext& self, const SlangSessionInfo& session_info, const std::vector<PipelineCompileInfo>& pipeline_infos
) -> bool;

auto allocate_image(const vuk::ImageAttachment& image_attachment) -> ImageID;
auto destroy_image(const ImageID id) -> void;
auto image(const ImageID id) -> vuk::Image;
Expand Down
36 changes: 22 additions & 14 deletions Oxylus/src/Asset/EmbedAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "Core/App.hpp"
#include "OS/File.hpp"
#include "OS/OS.hpp"
#include "Render/Slang/Slang.hpp"
#include "Utils/Log.hpp"

namespace ox {
Expand Down Expand Up @@ -72,34 +71,43 @@ auto EmbedAsset::embed_texture(
}

auto EmbedAsset::embed_shader(
vuk::Runtime& runtime, const std::string& shader_path, const std::string& out_path, const std::string& entry_point
const std::string& shader_path, const std::string& out_path, const std::string& entry_point
) -> void {
auto& vfs = App::get_vfs();
auto shaders_dir = vfs.resolve_physical_dir(VFS::APP_DIR, "Shaders");

Slang slang = {};
slang.create_session({.root_directory = shaders_dir, .definitions = {}});

vuk::PipelineBaseCreateInfo pipeline_ci = {};
const auto full_shader_path = shaders_dir / shader_path;

if (!std::filesystem::exists(full_shader_path)) {
OX_LOG_ERROR("Shader file not found: {}", full_shader_path.string());
return;
}

slang.add_shader(pipeline_ci, {.path = full_shader_path, .entry_points = {entry_point}});
auto slang_global_session = SlangCompiler::create();
if (!slang_global_session.has_value()) {
return;
}
auto slang_session = slang_global_session->new_session({.root_directory = shaders_dir});
if (!slang_session.has_value()) {
return;
}

OX_DEFER(&) {
if (slang_global_session.has_value())
slang_global_session->destroy();
if (slang_session.has_value())
slang_session->destroy();
};

if (pipeline_ci.shaders.empty()) {
auto compiled_entry_points = slang_session->compile_shader({.module_name = "main", .entry_points = {entry_point}});
if (!compiled_entry_points.has_value()) {
OX_LOG_ERROR("Failed to compile shader: {}", shader_path);
return;
}

auto& shader = pipeline_ci.shaders.front();
const auto& spirv_data = shader.data;
const u32 spirv_size = shader.size;
auto& shader = compiled_entry_points->front();
const auto& spirv_data = shader.code;
const u32 spirv_size = shader.code.size();

if (spirv_data.empty() || spirv_size == 0) {
if (spirv_size == 0) {
OX_LOG_ERROR("Compiled shader is empty: {}", shader_path);
return;
}
Expand Down
Loading