Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 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
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
31 changes: 26 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ project(graphite)
# C++ standard version
set(CMAKE_CXX_STANDARD 17 CACHE STRING "" FORCE)

# Options
option(GRAPHITE_SAMPLES "Include Graphite samples directory." ON)
set(GRAPHITE_PLATFORM "Vulkan")

# Library target
add_library(graphite)
# set_target_properties(graphite PROPERTIES OUTPUT_NAME ${CMAKE_PROJECT_NAME})

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

# Target build platform
set(GRAPHITE_PLATFORM "Vulkan")

if(GRAPHITE_PLATFORM STREQUAL "Vulkan")
set(PLATFORM_EXT vk)
set(PLATFORM vulkan)
Expand All @@ -23,6 +24,28 @@ 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
target_sources(graphite
PRIVATE "${GRAPHITE_IMGUI_DIR}/backends/imgui_impl_vulkan.cpp"
)

# Includes
target_include_directories(graphite
PUBLIC "${GRAPHITE_IMGUI_DIR}"
PUBLIC "${GRAPHITE_IMGUI_DIR}/backends"
)

target_compile_definitions(graphite PUBLIC GRAPHITE_IMGUI=1)
endif()

# Include directories
target_include_directories(graphite PUBLIC "./src/")
target_include_directories(graphite PUBLIC "./src/platform/")
Expand Down Expand Up @@ -70,7 +93,5 @@ if(GRAPHITE_PLATFORM STREQUAL "Vulkan")
)
endif()

add_subdirectory("samples")

# External dependencies
add_subdirectory("extern")
2 changes: 2 additions & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ if(GRAPHITE_PLATFORM STREQUAL "Vulkan")
# Meta-loader for Vulkan
add_subdirectory("volk")
target_link_libraries(graphite PUBLIC volk)
target_compile_definitions(graphite PUBLIC IMGUI_IMPL_VULKAN_USE_VOLK)

# VMA
target_compile_definitions(graphite PRIVATE NOMINMAX)
target_include_directories(graphite PUBLIC "./vma")
endif()
173 changes: 145 additions & 28 deletions extern/volk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,145 @@
cmake_minimum_required(VERSION 3.15)
project(volk VERSION 313 LANGUAGES C)

# Volk library
add_library(volk STATIC volk.h volk.c)
add_library(volk::volk ALIAS volk)
target_compile_definitions(volk PRIVATE VK_USE_PLATFORM_WIN32_KHR)
target_include_directories(volk PUBLIC ".")

# Vulkan
# find_package(Vulkan REQUIRED)
target_compile_definitions(volk PRIVATE VK_USE_PLATFORM_WIN32_KHR)
target_compile_definitions(volk PRIVATE VK_NO_PROTOTYPES)
# if(TARGET Vulkan::Vulkan)
# Note: We don't use target_link_libraries for Vulkan::Vulkan to avoid a static dependency on libvulkan1
# target_include_directories(volk PUBLIC ${Vulkan_INCLUDE_DIRS})
# elseif(DEFINED ENV{VULKAN_SDK})
#target_include_directories(volk PUBLIC "$ENV{VULKAN_SDK}/include")
# endif()

if(DEFINED ENV{VULKAN_SDK_INSTALL_DIR})
target_include_directories(volk PUBLIC "$ENV{VULKAN_SDK_INSTALL_DIR}/include")
elseif(DEFINED ENV{VULKAN_SDK})
target_include_directories(volk PUBLIC "$ENV{VULKAN_SDK}/include")
else()
message(FATAL_ERROR "No Vulkan SDK found!")
endif()

cmake_minimum_required(VERSION 3.5...3.30)

project(volk VERSION
# VOLK_GENERATE_VERSION
334
# VOLK_GENERATE_VERSION
LANGUAGES C
)

# CMake 3.12 changes the default behaviour of option() to leave local variables
# unchanged if they exist (which we want), but we must work with older CMake versions.
if(NOT DEFINED VOLK_STATIC_DEFINES)
set(VOLK_STATIC_DEFINES "" CACHE STRING "Additional defines for building the volk static library, e.g. Vulkan platform defines")
endif()
if(NOT DEFINED VOLK_PULL_IN_VULKAN)
option(VOLK_PULL_IN_VULKAN "Vulkan as a transitive dependency" ON)
endif()
if(NOT DEFINED VOLK_INSTALL)
option(VOLK_INSTALL "Create installation targets" OFF)
endif()
if(NOT DEFINED VOLK_NAMESPACE)
option(VOLK_NAMESPACE "Use C++ namespace for vk* functions" OFF)
endif()
if(NOT DEFINED VOLK_HEADERS_ONLY)
option(VOLK_HEADERS_ONLY "Add interface library only" OFF)
endif()
if(NOT DEFINED VULKAN_HEADERS_INSTALL_DIR)
set(VULKAN_HEADERS_INSTALL_DIR "" CACHE PATH "Where to get the Vulkan headers")
endif()

# -----------------------------------------------------
# Static library

if(NOT VOLK_HEADERS_ONLY OR VOLK_INSTALL)
add_library(volk STATIC volk.h volk.c)
add_library(volk::volk ALIAS volk)
target_compile_definitions(volk PRIVATE VK_USE_PLATFORM_WIN32_KHR)
target_include_directories(volk PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:include>
)
if(VOLK_NAMESPACE)
target_compile_definitions(volk PUBLIC VOLK_NAMESPACE)
set_source_files_properties(volk.c PROPERTIES LANGUAGE CXX)
endif()
if(VOLK_STATIC_DEFINES)
target_compile_definitions(volk PUBLIC ${VOLK_STATIC_DEFINES})
endif()
if (NOT WIN32)
target_link_libraries(volk PUBLIC ${CMAKE_DL_LIBS})
endif()
endif()

# -----------------------------------------------------
# Interface library

add_library(volk_headers INTERFACE)
add_library(volk::volk_headers ALIAS volk_headers)
target_include_directories(volk_headers INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:include>
)
if (NOT WIN32)
target_link_libraries(volk_headers INTERFACE ${CMAKE_DL_LIBS})
endif()

# -----------------------------------------------------
# Vulkan transitive dependency

if(VOLK_PULL_IN_VULKAN)
# Try an explicit CMake variable first, then any Vulkan paths
# discovered by FindVulkan.cmake, then the $VULKAN_SDK environment
# variable if nothing else works.
if(VULKAN_HEADERS_INSTALL_DIR)
message("volk: using VULKAN_HEADERS_INSTALL_DIR option")
set(VOLK_INCLUDES "${VULKAN_HEADERS_INSTALL_DIR}/include")
else()
# If CMake has the FindVulkan module and it works, use it.
find_package(Vulkan QUIET)
if(Vulkan_INCLUDE_DIRS)
message("volk: using Vulkan_INCLUDE_DIRS from FindVulkan module")
set(VOLK_INCLUDES "${Vulkan_INCLUDE_DIRS}")
elseif(DEFINED ENV{VULKAN_SDK})
message("volk: using VULKAN_SDK environment variable")
set(VOLK_INCLUDES "$ENV{VULKAN_SDK}/include")
elseif(TARGET Vulkan-Headers)
message("volk: using Vulkan-Headers include directories")
get_target_property(VOLK_INCLUDES Vulkan-Headers INTERFACE_INCLUDE_DIRECTORIES)
endif()
endif()

if(VOLK_INCLUDES)
if(TARGET volk)
target_include_directories(volk PUBLIC "${VOLK_INCLUDES}")
endif()
target_include_directories(volk_headers INTERFACE "${VOLK_INCLUDES}")
endif()
endif()

# -----------------------------------------------------
# Installation

if(VOLK_INSTALL)

include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/volk)

# Install files
install(FILES volk.h volk.c DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Install library target and add it and any dependencies to export set.
install(TARGETS volk volk_headers
EXPORT volk-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Actually write exported config w/ imported targets
install(EXPORT volk-targets
FILE volkTargets.cmake
NAMESPACE volk::
DESTINATION ${INSTALL_CONFIGDIR}
)

# Create a ConfigVersion.cmake file:
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/volkConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)

# Configure config file
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/volkConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/volkConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)

# Install the fully generated config and configVersion files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/volkConfig.cmake
${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.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import common;
RWTexture2D<float4> out_texture;
ConstantBuffer<FrameData> frame_data;
//StructuredBuffer<Pixel> in_buffer;
Texture2D<float4> debug_tex;
Texture2D<float4> attachment_tex;
SamplerState linear_sampler;

/* Source: XorDev <https://www.shadertoy.com/view/WclSWn> */
Expand Down Expand Up @@ -62,5 +62,10 @@ void entry(int2 thread_id: SV_DispatchThreadID) {
StructuredBuffer<Pixel> buf = bindless::storage_buffer<StructuredBuffer<Pixel>>(3);
out_texture[thread_id] = buf[int(thread_id.x + thread_id.y * frame_data.win_width)].color;

out_texture[thread_id] = debug_tex.SampleLevel(linear_sampler, uv, 0);
uint2 resolution = 0;
attachment_tex.GetDimensions(resolution.x, resolution.y);

uint2 pixel = thread_id.xy;
float2 attachment_tex_uv = (float2(pixel) + 0.5f) / float2(resolution);
out_texture[thread_id] = attachment_tex.SampleLevel(linear_sampler, attachment_tex_uv, 0);
}
Loading