Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a105b9e
feat: clear screen option for imgui
mxcop Nov 27, 2025
b7bdc3e
feat: raster node load operation
mxcop Nov 27, 2025
e617e78
fix: add imgui volk compile definition
mxcop Nov 27, 2025
5d2d77d
fix: wait queue idle only for render targets
mxcop Nov 28, 2025
ea08934
fix: reserve staging copy command vectors
mxcop Nov 28, 2025
867e773
fix: queue all staging copy commands
mxcop Nov 28, 2025
af7a5b1
fix: remove unused forward declaration
mxcop Dec 1, 2025
0d080fe
fix: do not upload if size is zero
mxcop Dec 1, 2025
b3dfc29
feat: render target vsync option
mxcop Dec 3, 2025
5751f4f
fix: resource reference counting
mxcop Dec 4, 2025
a63c243
feat: resize texture function
Gikster007 Dec 8, 2025
15f96d3
wip: texture resize test
Gikster007 Dec 8, 2025
ed1dd9f
fix: correct layout for attachment
Gikster007 Dec 8, 2025
0871d48
wip: texture resize
Gikster007 Dec 8, 2025
3ce43ba
fix: update old layout on resize
Gikster007 Dec 8, 2025
59b66e1
feat: imgui clear screen option
mxcop Dec 9, 2025
4257c24
Merge branch 'thermite-engine' of https://github.com/mxcop/graphite i…
mxcop Dec 9, 2025
619b21a
fix: clear staging commands on window minimize
Gikster007 Dec 9, 2025
92011fc
feat: imgui fixes
Gikster007 Dec 9, 2025
7dfe139
fix: resize texture size too large
Gikster007 Dec 10, 2025
4c162b6
fix: mem leak fixed
Gikster007 Dec 10, 2025
628332b
refactor: imgui support
mxcop Dec 10, 2025
e3c2690
feat: user set max resources count
Gikster007 Dec 15, 2025
fff46b8
fix: remove windows min & max
mxcop Dec 16, 2025
bedc4bf
Merge branch 'thermite-engine' of https://github.com/mxcop/graphite i…
mxcop Dec 16, 2025
e491e80
fix: graphite sample
mxcop Dec 16, 2025
89c7809
fix: render target present mode
mxcop Dec 17, 2025
9fe0afe
feat: shader draw params extension
Gikster007 Dec 18, 2025
6130daa
feat: ufloat texture format
mxcop Dec 24, 2025
5c84bf0
fix: merge conflicts
mxcop Dec 24, 2025
c62bec0
feat: indirect dispatch and draw
Gikster007 Dec 25, 2025
c79a93e
Merge branch 'thermite-engine' of https://github.com/mxcop/graphite i…
Gikster007 Dec 25, 2025
369bd51
feat: add 64 bit int support
mxcop Dec 30, 2025
496299f
feat: enable 64 bit atomics
mxcop Dec 30, 2025
498a2c9
feat: buffer resize function
mxcop Jan 2, 2026
41d0449
fix: destroy swapchain after image views
mxcop Jan 2, 2026
c72d91a
feat: merge main
mxcop Jan 3, 2026
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
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ endif()
target_compile_definitions(graphite PUBLIC PLATFORM_EXT=${PLATFORM_EXT})
target_compile_definitions(graphite PUBLIC PLATFORM=${PLATFORM})

# Samples directory
if(GRAPHITE_SAMPLES)
add_subdirectory("sample")
set(GRAPHITE_IMGUI_DIR "${CMAKE_SOURCE_DIR}/sample/extern/imgui/")
endif()

# ImGUI support
if(GRAPHITE_IMGUI_DIR)
# Sources
Expand Down Expand Up @@ -87,10 +93,5 @@ if(GRAPHITE_PLATFORM STREQUAL "Vulkan")
)
endif()

# Samples directory
if(GRAPHITE_SAMPLES)
add_subdirectory("samples")
endif()

# External dependencies
add_subdirectory("extern")
1 change: 1 addition & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ if(GRAPHITE_PLATFORM STREQUAL "Vulkan")
target_compile_definitions(graphite PUBLIC IMGUI_IMPL_VULKAN_USE_VOLK)

# VMA
target_compile_definitions(graphite PRIVATE NOMINMAX)
target_include_directories(graphite PUBLIC "./vma")
endif()
1 change: 0 additions & 1 deletion extern/volk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,4 @@ if(VOLK_INSTALL)
${CMAKE_CURRENT_BINARY_DIR}/volkConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)

endif()
20 changes: 20 additions & 0 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(SAMPLE_DIR .)
set(EXE_NAME sample)

# Executable target
project(${EXE_NAME})
add_executable(${EXE_NAME} "${SAMPLE_DIR}/src/main.cc")
set_target_properties(${EXE_NAME} PROPERTIES OUTPUT_NAME ${EXE_NAME})

# Add compiler definitions
target_compile_definitions(${EXE_NAME} PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
target_compile_definitions(${EXE_NAME} PRIVATE $<$<CONFIG:Release>:NDEBUG=1>)

# Include directories
target_include_directories(${EXE_NAME} PRIVATE "${SAMPLE_DIR}/src/")

# Link to the Graphite library
target_link_libraries(${EXE_NAME} PRIVATE graphite)

# External dependencies
add_subdirectory("extern")
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# GLFW
add_subdirectory("glfw")
target_link_libraries(sample-testing PRIVATE glfw)
target_link_libraries(sample PRIVATE glfw)

# ImGUI
target_sources(sample-testing
target_sources(sample
PRIVATE "./imgui/imgui_demo.cpp"
PRIVATE "./imgui/imgui_draw.cpp"
PRIVATE "./imgui/imgui_tables.cpp"
Expand All @@ -13,12 +13,12 @@ target_sources(sample-testing
PRIVATE "./imgui/backends/imgui_impl_vulkan.cpp"
PRIVATE "./imgui/backends/imgui_impl_win32.cpp"
)
target_include_directories(sample-testing
target_include_directories(sample
PRIVATE "./imgui"
PRIVATE "./imgui/backends"
)

# STB Image
target_include_directories(sample-testing
target_include_directories(sample
PRIVATE "./stb_image"
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
//#define IMGUI_DEBUG_PARANOID

//---- Indicate we're using VOLK for the render graph
#define IMGUI_IMPL_VULKAN_USE_VOLK
//#define IMGUI_IMPL_VULKAN_USE_VOLK

//---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files)
/*
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions samples/testing/src/main.cc → sample/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main() {

/* Initialize the Render Graph */
RenderGraph rg = RenderGraph();
rg.set_shader_path("samples/testing/kernels");
rg.set_shader_path("sample/kernels");
rg.set_max_graphs_in_flight(2u); /* Double buffering */
if (const Result r = rg.init(gpu); r.is_err()) {
printf("failed to initialize render graph.\nreason: %s\n", r.unwrap_err().c_str());
Expand Down Expand Up @@ -191,7 +191,7 @@ int main() {
ImGui::CreateContext();
ImGui_ImplGlfw_InitForVulkan(win, true);
ImGUI imgui = ImGUI();
if (const Result r = imgui.init(gpu, rt, IMGUI_FUNCTIONS); r.is_err()) {
if (const Result r = imgui.init(gpu, rt); r.is_err()) {
printf("failed to initialize imgui.\nreason: %s\n", r.unwrap_err().c_str());
return EXIT_SUCCESS;
}
Expand Down
24 changes: 0 additions & 24 deletions samples/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion samples/testing/CMakeLists.txt

This file was deleted.

12 changes: 12 additions & 0 deletions src/core/graphite/gpu_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ void AgnGPUAdapter::deinit_vram_bank() { delete vram_bank; }
VRAMBank& AgnGPUAdapter::get_vram_bank() {
return *vram_bank;
}

void AgnGPUAdapter::set_max_render_targets(const u32 count) { max_render_targets = count; }
void AgnGPUAdapter::set_max_buffers(const u32 count) { max_buffers = count; }
void AgnGPUAdapter::set_max_textures(const u32 count) { max_textures = count; }
void AgnGPUAdapter::set_max_images(const u32 count) { max_images = count; }
void AgnGPUAdapter::set_max_samplers(const u32 count) { max_samplers = count; }

u32 AgnGPUAdapter::get_max_render_targets() const { return max_render_targets; }
u32 AgnGPUAdapter::get_max_buffers() const { return max_buffers; }
u32 AgnGPUAdapter::get_max_textures() const { return max_textures; }
u32 AgnGPUAdapter::get_max_images() const { return max_images; }
u32 AgnGPUAdapter::get_max_samplers() const { return max_samplers; }
23 changes: 23 additions & 0 deletions src/core/graphite/gpu_adapter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "utils/result.hh"
#include "utils/debug.hh"

#include "utils/types.hh"

class VRAMBank;

/* Debug logger data. */
Expand All @@ -25,6 +27,13 @@ protected:

/* VRAM bank for this GPU adapter. */
VRAMBank* vram_bank = nullptr;

/* Maximum amount of resources. */
u32 max_render_targets = 8u;
u32 max_buffers = 8u;
u32 max_textures = 8u;
u32 max_images = 8u;
u32 max_samplers = 8u;

/* Log a message using the active debug logger. */
void log(DebugSeverity severity, const char* msg);
Expand All @@ -47,6 +56,20 @@ public:

/* De-initialize the GPU adapter, free all its resources. */
PLATFORM_SPECIFIC Result<void> deinit() = 0;

/* Set maximum resource count. */
void set_max_render_targets(const u32 count);
void set_max_buffers(const u32 count);
void set_max_textures(const u32 count);
void set_max_images(const u32 count);
void set_max_samplers(const u32 count);

/* Get maximum resource count. */
u32 get_max_render_targets() const;
u32 get_max_buffers() const;
u32 get_max_textures() const;
u32 get_max_images() const;
u32 get_max_samplers() const;
};

#include PLATFORM_INCLUDE(gpu_adapter)
7 changes: 7 additions & 0 deletions src/core/graphite/nodes/compute_node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public:

u32 group_x = 1u, group_y = 1u, group_z = 1u; /* Thread group size */
u32 work_x = 1u, work_y = 1u, work_z = 1u; /* Work size */

/* Indirect Dispatch. */
Buffer indirect_buffer {};
uint32_t indirect_offset = 0u;

/* No copies allowed */
ComputeNode(const ComputeNode&) = delete;
Expand All @@ -36,6 +40,9 @@ public:
/* Set the work size for this node. (this will be divided by the `group_size` to get the dispatch size) */
inline ComputeNode& work_size(u32 x, u32 y = 1u, u32 z = 1u) { work_x = x; work_y = y; work_z = z; return *this; }

/* Set the indirect_buffer which will be used to get the dispatch args buffer for the vkCmdDispatchIndirect call. */
inline ComputeNode& indirect_size(Buffer buffer) { indirect_buffer = buffer; return *this; }

/* To access constructors */
friend class AgnRenderGraph;
};
11 changes: 11 additions & 0 deletions src/core/graphite/nodes/raster_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ DrawCall& RasterNode::draw(
return draws.emplace_back(*this, vertex_buffer, vertex_count, vertex_offset, instance_count, instance_offset);
}

DrawCall& RasterNode::draw_indirect(const Buffer vertex_buffer, const Buffer indirect_buffer) {
return draws.emplace_back(*this, vertex_buffer, indirect_buffer);
}

RasterNode& RasterNode::attribute(const AttrFormat format) {
attributes.emplace_back(format);
return *this;
Expand Down Expand Up @@ -64,3 +68,10 @@ DrawCall::DrawCall(
vertex_buffer, DependencyFlags::Readonly | DependencyFlags::Unbound, DependencyStages::Vertex
);
}

DrawCall::DrawCall(RasterNode& parent_pass, const Buffer vertex_buffer, const Buffer indirect_buffer)
: parent_pass(parent_pass), vertex_buffer(vertex_buffer), indirect_buffer(indirect_buffer) {
parent_pass.dependencies.emplace_back(
vertex_buffer, DependencyFlags::Readonly | DependencyFlags::Unbound, DependencyStages::Vertex
);
}
5 changes: 5 additions & 0 deletions src/core/graphite/nodes/raster_node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class RasterNode : public Node {
const Buffer vertex_buffer, const u32 vertex_count, const u32 vertex_offset = 0u, const u32 instance_count = 1u,
const u32 instance_offset = 0u
);
/* Create an indirect draw call for this raster pass. */
DrawCall& draw_indirect(const Buffer vertex_buffer, const Buffer indirect_buffer);

/* To access constructors */
friend class AgnRenderGraph;
Expand All @@ -95,6 +97,7 @@ struct DrawCall {
RasterNode& parent_pass;

Buffer vertex_buffer {};
Buffer indirect_buffer {};
u32 vertex_count = 0u, vertex_offset = 0u;
u32 instance_count = 0u, instance_offset = 0u;

Expand All @@ -103,4 +106,6 @@ struct DrawCall {
RasterNode& parent_pass, const Buffer vertex_buffer, const u32 vertex_count, const u32 vertex_offset,
const u32 instance_count, const u32 instance_offset
);
/* Vertex buffer and indirect draw call constructor. */
DrawCall(RasterNode& parent_pass, const Buffer vertex_buffer, const Buffer indirect_buffer);
};
13 changes: 7 additions & 6 deletions src/core/graphite/resources/buffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

/* Buffer usage flags. */
enum class BufferUsage : u32 {
Invalid = 0u, /* Invalid buffer usage. */
TransferDst = 1u << 1u, /* This buffer can be a GPU transfer destination. */
TransferSrc = 1u << 2u, /* This buffer can be a GPU transfer source. */
Constant = 1u << 3u, /* Read-only buffer, aka. `UniformBuffer` */
Storage = 1u << 4u, /* Read/Write buffer, aka. `StructuredBuffer` */
Vertex = 1u << 5u, /* Vertex buffer */
Invalid = 0u, /* Invalid buffer usage. */
TransferDst = 1u << 1u, /* This buffer can be a GPU transfer destination. */
TransferSrc = 1u << 2u, /* This buffer can be a GPU transfer source. */
Constant = 1u << 3u, /* Read-only buffer, aka. `UniformBuffer` */
Storage = 1u << 4u, /* Read/Write buffer, aka. `StructuredBuffer` */
Vertex = 1u << 5u, /* Vertex buffer */
Indirect = 1u << 6u, /* Draw/Dispatch Indirect Commands */
};
ENUM_CLASS_FLAGS(BufferUsage);
8 changes: 5 additions & 3 deletions src/core/graphite/resources/texture.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ ENUM_CLASS_FLAGS(TextureUsage);

/* Texture formats. */
enum class TextureFormat : u32 {
Invalid = 0u, /* Invalid texture format. */
RGBA8Unorm, /* RGBA 8 bits per channel, unsigned normalized. */
EnumLimit /* Anything above or equal is invalid. */
Invalid = 0u, /* Invalid texture format. */
RGBA8Unorm, /* RGBA 8 bits per channel, unsigned normalized. */
RG32Uint, /* RG 32 bits per channel, unsigned integer. */
RG11B10Ufloat, /* RG 11 bits per channel, B 10 bits per channel, unsigned float. */
EnumLimit /* Anything above or equal is invalid. */
};

/* Texture meta data. */
Expand Down
2 changes: 2 additions & 0 deletions src/core/graphite/vram_bank.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public:
PLATFORM_SPECIFIC Result<void> resize_render_target(RenderTarget& render_target, u32 width, u32 height) = 0;
/* Resize a texture resource. */
PLATFORM_SPECIFIC Result<void> resize_texture(Texture& texture, Size3D size) = 0;
/* Resize a buffer resource. */
PLATFORM_SPECIFIC Result<void> resize_buffer(Buffer& buffer, u64 count, u64 stride = 0) = 0;

/* Upload data to a GPU buffer resource. */
PLATFORM_SPECIFIC Result<void> upload_buffer(Buffer& buffer, const void* data, u64 dst_offset, u64 size) = 0;
Expand Down
24 changes: 15 additions & 9 deletions src/platform/vulkan/gpu_adapter_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,32 +109,38 @@ Result<void> GPUAdapter::init(bool debug_mode) {
device_queues_ci[2].queueCount = 1u;
device_queues_ci[2].pQueuePriorities = &priority;

/* Enable descriptor indexing features */
VkPhysicalDeviceDescriptorIndexingFeaturesEXT desc_features { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES };
desc_features.descriptorBindingSampledImageUpdateAfterBind = true;
desc_features.descriptorBindingStorageBufferUpdateAfterBind = true;
desc_features.descriptorBindingPartiallyBound = true;
desc_features.runtimeDescriptorArray = true;

/* Enable synchronization 2.0 features */
VkPhysicalDeviceSynchronization2Features sync_features { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES };
sync_features.pNext = &desc_features;
sync_features.synchronization2 = true;

/* Enable dynamic rendering features */
VkPhysicalDeviceDynamicRenderingFeatures render_features { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES };
render_features.pNext = (void*)&sync_features;
render_features.dynamicRendering = true;

/* Vulkan 1.2 features */
VkPhysicalDeviceVulkan12Features vulkan_features { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES };
vulkan_features.pNext = &render_features;
vulkan_features.shaderBufferInt64Atomics = true;
vulkan_features.descriptorBindingSampledImageUpdateAfterBind = true;
vulkan_features.descriptorBindingStorageBufferUpdateAfterBind = true;
vulkan_features.descriptorBindingPartiallyBound = true;
vulkan_features.runtimeDescriptorArray = true;

/* Enable modern device features */
VkPhysicalDeviceFeatures device_features {};
device_features.shaderInt64 = true; /* 64-bit integer support */

/* Vulkan device creation info */
VkDeviceCreateInfo device_ci { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
device_ci.pNext = &render_features;
device_ci.pNext = &vulkan_features;
device_ci.queueCreateInfoCount = 3u;
device_ci.pQueueCreateInfos = device_queues_ci;
device_ci.enabledLayerCount = instance_layers_count;
device_ci.ppEnabledLayerNames = instance_layers;
device_ci.enabledExtensionCount = device_ext_count;
device_ci.ppEnabledExtensionNames = device_ext;
device_ci.pEnabledFeatures = &device_features;

/* Create a Vulkan logical device */
if (const VkResult r = vkCreateDevice(physical_device, &device_ci, nullptr, &logical_device); r != VK_SUCCESS) {
Expand Down
Loading