Skip to content
This repository was archived by the owner on May 5, 2026. It is now read-only.
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
12 changes: 6 additions & 6 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Linux Build
name: Linux Build (Vulkan)

on:
push:
branches: [ "main" ]
branches: [ "vulkan" ]
pull_request:
branches: [ "main" ]
branches: [ "vulkan" ]

jobs:
build:
Expand Down Expand Up @@ -88,8 +88,8 @@ jobs:
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GH_TOKEN }}"
automatic_release_tag: "latest-linux"
automatic_release_tag: "latest-linux-vulkan"
prerelease: true
title: "Pre-release Build (Linux)"
title: "Pre-release Build (Linux, Vulkan)"
files: |
builds/ninja-multi-vcpkg/Release/ion-latest-linux.zip
builds/ninja-multi-vcpkg/Release/ion-latest-linux-vulkan.zip
12 changes: 6 additions & 6 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Windows Build
name: Windows Build (Vulkan)

on:
push:
branches: [ "main" ]
branches: [ "vulkan" ]
pull_request:
branches: [ "main" ]
branches: [ "vulkan" ]

jobs:
build:
Expand Down Expand Up @@ -84,8 +84,8 @@ jobs:
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GH_TOKEN }}"
automatic_release_tag: "latest-windows"
automatic_release_tag: "latest-windows-vulkan"
prerelease: true
title: "Pre-release Build (Windows)"
title: "Pre-release Build (Windows, Vulkan Branch)"
files: |
builds/ninja-multi-vcpkg/Release/ion-latest-windows.zip
builds/ninja-multi-vcpkg/Release/ion-latest-windows-vulkan.zip
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ find_package(glad CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)
find_package(ImGui CONFIG REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Vulkan REQUIRED)
find_package(Stb REQUIRED)
find_package(tinyfiledialogs CONFIG REQUIRED)
find_package(Python3 COMPONENTS Development REQUIRED)
find_package(pugixml CONFIG REQUIRED)

add_library(ion-base SHARED)
add_library(ion-base STATIC)
target_compile_features(ion-base PRIVATE cxx_std_20)
target_compile_definitions(ion-base PRIVATE ION_EXPORTS)
#target_compile_definitions(ion-base PRIVATE ION_EXPORTS)
target_compile_definitions(ion-base PRIVATE ION_BUILD_VERSION="${PROJECT_VERSION}")
target_sources(ion-base PRIVATE
src/base/assets.cc
Expand All @@ -27,6 +27,18 @@ target_sources(ion-base PRIVATE
src/base/texture.cc
src/base/physics.cc
src/base/world.cc
src/development/id.cc
src/base/render/api.cc
src/base/render/command.cc
src/base/render/debug.cc
src/base/render/devices.cc
src/base/render/framebuffers.cc
src/base/render/image_views.cc
src/base/render/instance.cc
src/base/render/pipeline.cc
src/base/render/render_pass.cc
src/base/render/surface.cc
src/base/render/swapchain.cc
)
set_target_properties(ion-base PROPERTIES PRIVATE ${PROJECT_VERSION})
set_target_properties(ion-base PROPERTIES PRIVATE ${PROJECT_VERSION_MAJOR})
Expand All @@ -37,15 +49,15 @@ target_link_libraries(ion-base PUBLIC
glfw
glm::glm
imgui::imgui
OpenGL::GL
Vulkan::Vulkan
tinyfiledialogs::tinyfiledialogs
Python3::Python
pugixml::pugixml
)

add_library(ion-game SHARED)
add_library(ion-game STATIC)
target_compile_features(ion-game PRIVATE cxx_std_20)
target_compile_definitions(ion-game PRIVATE ION_EXPORTS)
#target_compile_definitions(ion-game PRIVATE ION_EXPORTS)
target_compile_definitions(ion-game PRIVATE ION_BUILD_VERSION="${PROJECT_VERSION}")
target_sources(ion-game PRIVATE
src/game/game.cc
Expand All @@ -69,7 +81,7 @@ target_sources(ion-development PRIVATE
target_compile_definitions(ion-development PRIVATE
ION_BUILD_VERSION="${PROJECT_VERSION}"
ION_DEVELOPMENT
ION_IMPORTS
#ION_IMPORTS
)
set_target_properties(ion-development PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(ion-development PRIVATE ${CMAKE_SOURCE_DIR}/include)
Expand All @@ -90,4 +102,4 @@ target_include_directories(ion-run PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(ion-run PRIVATE
ion-base
ion-game
)
)
Binary file added assets/test/fs.spv
Binary file not shown.
9 changes: 9 additions & 0 deletions assets/test/shader.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 450

layout(location = 0) in vec3 fragColor;

layout(location = 0) out vec4 outColor;

void main() {
outColor = vec4(fragColor, 1.0);
}
20 changes: 20 additions & 0 deletions assets/test/shader.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 450

layout(location = 0) out vec3 fragColor;

vec2 positions[3] = vec2[](
vec2(0.0, -0.5),
vec2(0.5, 0.5),
vec2(-0.5, 0.5)
);

vec3 colors[3] = vec3[](
vec3(1.0, 0.0, 0.0),
vec3(0.0, 1.0, 0.0),
vec3(0.0, 0.0, 1.0)
);

void main() {
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
fragColor = colors[gl_VertexIndex];
}
Binary file added assets/test/vs.spv
Binary file not shown.
36 changes: 2 additions & 34 deletions include/ion/development/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,7 @@ namespace ion {
static std::uniform_int_distribution<> distribution(0, 15);
static std::uniform_int_distribution<> distribution_2(8, 11);

std::string GenerateUUID() {
std::stringstream ss;
int i;
ss << std::hex;
for (i = 0; i < 8; i++) {
ss << distribution(gen);
}
ss << "-";
for (i = 0; i < 4; i++) {
ss << distribution(gen);
}
ss << "-4";
for (i = 0; i < 3; i++) {
ss << distribution(gen);
}
ss << "-";
ss << distribution_2(gen);
for (i = 0; i < 3; i++) {
ss << distribution(gen);
}
ss << "-";
for (i = 0; i < 12; i++) {
ss << distribution(gen);
};
return ss.str();
}

std::string GenerateHashFromString(const std::string& input) {
std::hash<std::string> hasher;
size_t hash = hasher(input);
std::stringstream ss;
ss << std::hex << hash;
return ss.str();
}
std::string GenerateUUID();
std::string GenerateHashFromString(const std::string& input);
} // namespace uuid
} // namespace ion
8 changes: 4 additions & 4 deletions include/ion/render.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma once
#include "component.h"
#include "gpu_data.h"
// #include <GLFW/glfw3.h>
#include "exports.h"
#include "gpu_data.h"
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <map>
#include <memory>
#include <string>
#include <vector>

struct Transform;
struct Texture;
Expand Down Expand Up @@ -63,7 +62,8 @@ void UpdateFramebuffers();
void BindFramebuffer(std::shared_ptr<Framebuffer>);
void UnbindFramebuffer();
void DrawFramebuffer(std::shared_ptr<Framebuffer>, std::shared_ptr<Shader>,
std::shared_ptr<GPUData> quad, std::shared_ptr<Framebuffer> = nullptr);
std::shared_ptr<GPUData> quad,
std::shared_ptr<Framebuffer> = nullptr);
const std::map<std::shared_ptr<Framebuffer>, std::string> &GetFramebuffers();

void BindTexture(std::shared_ptr<Texture> texture, int slot);
Expand Down
85 changes: 85 additions & 0 deletions include/ion/render/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#pragma once
#include <cstdio>
#include <optional>
#include <vector>
#include <vulkan/vulkan.h>

namespace ion::render::api {

struct QueueFamilyIndices {
std::optional<uint32_t> graphics_family, present_family;
};

struct SwapchainSupportInfo {
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> present_modes;
};

namespace internal {
const int max_frames_in_flight = 2;

#ifdef NDEBUG
static const bool enable_validation_layers = false;
#else
static const bool enable_validation_layers = true;
#endif
static bool using_fallback_layer = false;

static const std::vector<const char *>
validation_layers = {"VK_LAYER_KHRONOS_validation"},
device_extensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};

static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT severity,
VkDebugUtilsMessageTypeFlagsEXT type,
const VkDebugUtilsMessengerCallbackDataEXT *data, void *user_data) {
printf("Validation Layer: %s\n", data->pMessage);
return false;
}

QueueFamilyIndices FindQueueFamilies(VkPhysicalDevice device);
SwapchainSupportInfo QuerySwapchainSupport(VkPhysicalDevice device);

extern VkInstance instance;
extern VkDebugUtilsMessengerEXT messenger;
extern VkPhysicalDevice physical_device;
extern VkDevice device;
extern VkQueue graphics_queue, present_queue;
extern VkSurfaceKHR surface;
extern VkSwapchainKHR swapchain;
extern std::vector<VkImageView> swapchain_image_views;
extern std::vector<VkImage> swapchain_images;
extern VkFormat swapchain_image_format;
extern VkExtent2D swapchain_extent;
extern VkRenderPass render_pass;
extern VkPipelineLayout pipeline_layout;
extern VkPipeline graphics_pipeline;
extern std::vector<VkFramebuffer> swapchain_framebuffers;
extern VkCommandPool command_pool;
extern std::vector<VkCommandBuffer> command_buffer;
extern std::vector<VkSemaphore> image_available_semaphore, render_finished_semaphore;
extern std::vector<VkFence> in_flight_fence;

extern VkDescriptorPool descriptor_pool;
} // namespace internal

void CreateInstance();
void CreateMessenger();
void CreateSurface();
void CreateDevice();
void CreateSwapchain();
void CreateImageViews();
void CreatePipeline();
void CreateRenderPass();
void CreateFramebuffers();
void CreateSyncObjects();
void CreateCommandPool();
void CreateCommandBuffer();

void RecordCommandBuffer(VkCommandBuffer, uint32_t);
void Render();

void DestroyMessenger();
void Quit();
} // namespace ion::render::api
10 changes: 5 additions & 5 deletions src/base/assets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ ION_API bool ion::res::CheckApplicationStructure() {
auto dir = tinyfd_selectFolderDialog("Select Assets Directory", nullptr);
if (std::filesystem::exists({dir})) {
std::filesystem::create_directory("assets");
for (const auto& entry : std::filesystem::directory_iterator(dir)) {
for (const auto &entry : std::filesystem::directory_iterator(dir)) {
if (entry.is_directory()) {
std::filesystem::create_directory("assets" /
entry.path().filename());
entry.path().filename());
}
std::filesystem::copy(
entry.path(), "assets" / entry.path().filename(),
std::filesystem::copy_options::recursive |
std::filesystem::copy_options::update_existing);
entry.path(), "assets" / entry.path().filename(),
std::filesystem::copy_options::recursive |
std::filesystem::copy_options::update_existing);
}
} else {
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/base/base_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BasePipeline::BasePipeline() {
bloom_buffer_2 = ion::render::CreateFramebuffer(
FramebufferInfo{.recreate_on_resize = true, .name = "Bloom 2"});
output_buffer = ion::render::CreateFramebuffer(
FramebufferInfo{ .recreate_on_resize = true, .name = "Output" });
FramebufferInfo{.recreate_on_resize = true, .name = "Output"});
deferred_shader =
ion::res::LoadAsset<Shader>("assets/deferred_shader", false);
screen_shader = ion::res::LoadAsset<Shader>("assets/screen_shader", false);
Expand Down Expand Up @@ -70,11 +70,11 @@ void BasePipeline::Render(std::shared_ptr<World> world,
}

if (settings.render_to_output_buffer) {
ion::render::BindFramebuffer(output_buffer);
ion::render::BindFramebuffer(output_buffer);
ion::render::Clear();
ion::render::DrawFramebuffer(shaded, screen_shader, screen_data, output_buffer);
}
else {
ion::render::DrawFramebuffer(shaded, screen_shader, screen_data,
output_buffer);
} else {
ion::render::DrawFramebuffer(shaded, screen_shader, screen_data);
}
}
Loading
Loading