Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
312c41a
lib: cth with the input types and the keys by scan code
codethinki Nov 21, 2026
ac716b9
rgfw: current upstream, cgfw initializes RGFW for the first window
codethinki Nov 21, 2026
a144885
lib: rgfw with the OS time in the input events (ColleagueRiley/RGFW#615)
codethinki Nov 21, 2026
673ade1
agents: the pull request of a work branch is a normal pull request
codethinki Nov 21, 2026
b494c78
agents: the pull request of a work branch stays a draft until the wor…
codethinki Nov 21, 2026
ea2c793
cgfw: window events, keys, axes, text and focus
codethinki Nov 21, 2026
d832928
cgfw: Key::DELETE next to windows.h, which defines DELETE
codethinki Nov 21, 2026
7dc7697
rgfw: our fixes for keycodes, init and deinit, key repeat, Vulkan sur…
codethinki Nov 21, 2026
60e4945
cgfw: Key::DEL, no DELETE guards; lib: cth with Key::DEL, rgfw with t…
codethinki Nov 21, 2026
1cfee16
timgui: ImGui and ImPlot on jvk and cgfw, the cube demo shows the fra…
codethinki Nov 21, 2026
ebfa76d
lib: rgfw with the window list setup after the platform creation (Col…
codethinki Nov 21, 2026
8f3e07d
demo/cube: frame time window, median, p75 and p99 of the last 240 fra…
codethinki Nov 21, 2026
7515908
cmake: glslc from the vcpkg port shaderc, one lookup for timgui and t…
codethinki Nov 21, 2026
ea8731d
cmake: glslc from the Vulkan SDK or the system, not from vcpkg
codethinki Nov 21, 2026
b8e19be
timgui: Config::stencilFormat, the stencil attachment of the renderin…
codethinki Nov 21, 2026
68c4e78
lib: rgfw without VK_USE_PLATFORM_* in RGFW.h, the platform of vulkan…
codethinki Nov 21, 2026
9912c15
ci: buildcache log of the Windows clang build, TEMP diagnosis of the …
codethinki Nov 21, 2026
e830a06
cmake: shaders with the GLSL language of cth_cmake, no run-time shade…
codethinki Nov 21, 2026
d1b8ac3
lib: cth_cmake with cth_assert_true in the GLSL compiler check (codet…
codethinki Nov 21, 2026
72abb52
jvk: lifecycle of the command buffers, review markers of the first ba…
codethinki Nov 21, 2026
0ab2708
jvk, cvk: review markers of the second batch, Queues into Core, Resou…
codethinki Nov 21, 2026
6a376c9
jvk: the submitted values of the semaphores in a cth::co::counter_eve…
codethinki Nov 21, 2026
7e81a95
lib: cth with the lifetime fix of counter_event (codethinki/cth#34)
codethinki Nov 21, 2026
a72ba92
jvk: Queue::submit() and Queue::present() with jvk::SubmitInfo, no vk…
codethinki Nov 21, 2026
0d3567d
jvk: Core moves while it is not created
codethinki Nov 21, 2026
dec6367
ci: buildcache direct mode off in the Windows CI, TEMP for the stale …
codethinki Nov 21, 2026
baadb3e
jvk: an out of date present sets the out of date flag of the presente…
codethinki Nov 22, 2026
1f2b14c
demo/cube: the mip levels of the texture in a constant, no narrowing …
codethinki Nov 22, 2026
d1977e8
jvk: acquire() waits for the end of the last present job, the out of …
codethinki Nov 22, 2026
96acb11
jvk: cth::co::catching_scope replaces dev::first_error, the jobs term…
codethinki Nov 22, 2026
bb85977
jvk: the gpu wait of a semaphore without allocation, the reactor resu…
codethinki Nov 22, 2026
ddffabd
jvk, cvk: the submit infos without allocations per frame
codethinki Nov 22, 2026
c6dcb68
jvk: the reactor keeps its waiters in one std::vector, no intrusive list
codethinki Nov 22, 2026
ac45bab
lib: cth with co::all() over a range without allocations for ready ch…
codethinki Nov 22, 2026
c7727bd
jvk: dev::fallback_submit() is dev::skip_submit(), one name for the s…
codethinki Nov 22, 2026
bcdd1ce
jvk: the workers of the core are a plain cth::co::scheduler again
codethinki Nov 22, 2026
71eb2c9
lib: cth with the fix of a foreign thread that calls into a context a…
codethinki Nov 22, 2026
4eb7154
jvk: the attachment accesses without a vector per rendering, 4 worker…
codethinki Nov 22, 2026
f6f9ec2
jvk, cvk: Queue::transfer() for both halves of a family transfer, one…
codethinki Nov 23, 2026
c11f6a1
jvk: Presenter is jvk::Surface, no behavior change
codethinki Nov 23, 2026
094233e
jvk: acquire and present split across stages, the present fused into …
codethinki Nov 23, 2026
b74cf1f
jvk: Queue without mutable members, its submits, presents and transfe…
codethinki Nov 23, 2026
807efaf
docs: private members and module helpers get no doc, only a comment f…
codethinki Nov 23, 2026
cb8e1b4
docs: the quirks of private members as normal doc comments
codethinki Nov 23, 2026
ded06c7
lib: cth with CTH_CRITICAL_MODE and scoped detaches without the sched…
codethinki Nov 23, 2026
2393ad7
jvk: Surface::acquire() checks that the present stage waits for the a…
codethinki Nov 23, 2026
ed2b4b2
jvk: the check of the present stage's wait in Surface::acquire() goes…
codethinki Nov 23, 2026
af46d31
lib: cth with the TODO for [[assume]] in CTH_CRITICAL
codethinki Nov 23, 2026
0f07849
jvk: the jobs of the graph are submissions, a submission waits for th…
codethinki Nov 23, 2026
6deca4c
jvk: submit() and skip() store their failure, the frame flow has no i…
codethinki Nov 24, 2026
6416f9b
jvk: a failed skip in ~StageGraph() logs and terminates
codethinki Nov 24, 2026
70adf52
tests: no death tests
codethinki Nov 24, 2026
9b14a83
jvk: core_test without the compile check of the graph headers, their …
codethinki Nov 24, 2026
70b653a
jvk: SamplerHeap has the lifecycle of ResourceHeap, Core holds it wit…
codethinki Nov 24, 2026
ad3bc95
lib: cth_cmake on main after #11, same content
codethinki Nov 24, 2026
94c06c6
lib: cth on master after #34, same content
codethinki Nov 24, 2026
6aba0c1
jvk: the present is a use of the image in the epilogue of the present…
codethinki Nov 24, 2026
6c91d13
demo: the cube demo has a scene stage and a ui stage
codethinki Nov 24, 2026
2e67115
jvk, demo: cth::co::all() with execution policies, the cube stages re…
codethinki Nov 24, 2026
abb80e7
jvk: Queue::tryAcquire(), Surface::acquire() tries the acquire in the…
codethinki Nov 25, 2026
66f8615
jvk: Presenter, the images of one swapchain behind acquire, present a…
codethinki Nov 25, 2026
2e723ea
cvk, jvk: no acquired tracking in cvk::Swapchain
codethinki Nov 25, 2026
3bd4259
jvk: Presenter::Image is Presenter::AcquiredImage
codethinki Nov 25, 2026
72ef756
timgui: persistent vertex and index buffers per frame slot
codethinki Nov 25, 2026
f25e3c7
cvk, jvk: the Presenter orchestrates every acquire and present
codethinki Nov 25, 2026
dd6e0db
cvk, jvk: the presenter tracks the pending present fences, cvk waits …
codethinki Nov 25, 2026
c7a619b
jvk, demo: presenting without the graph, Frame::acquire() is the bridge
codethinki Nov 25, 2026
177a352
lib: cth on master after #36, same content
codethinki Nov 25, 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
12 changes: 11 additions & 1 deletion .github/actions/setup-windows/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Setup Windows Environment'
description: 'Sets up MSVC, Vcpkg, BuildCache, CMake and Ninja'
description: 'Sets up MSVC, Vcpkg, BuildCache, the Vulkan SDK, CMake and Ninja'
inputs:
compiler:
description: 'compiler of the CI preset (msvc or clang)'
Expand Down Expand Up @@ -27,6 +27,16 @@ runs:
Expand-Archive buildcache.zip -DestinationPath c:\buildcache
echo "c:\buildcache\buildcache\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install Vulkan SDK
shell: pwsh
run: |
# glslc compiles the shaders: the latest SDK of LunarG
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" -OutFile "$env:RUNNER_TEMP\vulkan-sdk.exe"
Start-Process -FilePath "$env:RUNNER_TEMP\vulkan-sdk.exe" -ArgumentList "--root", "C:\VulkanSDK", "--accept-licenses", "--default-answer", "--confirm-command", "install" -Wait -NoNewWindow
& "C:\VulkanSDK\Bin\glslc.exe" --version
"VULKAN_SDK=C:\VulkanSDK" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "C:\VulkanSDK\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install LLVM
if: inputs.compiler == 'clang'
shell: pwsh
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/windows-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ jobs:
build:
name: Windows (${{ inputs.compiler }})
runs-on: windows-latest
#TEMP buildcache direct mode gives stale precompiled headers
# - direct mode keys on the headers of clang -H, -H does not list the headers of -include
# - CMake includes the precompiled header with -include: a changed header of it still hits,
# the build takes the old precompiled header and old objects, no error
# - only Windows: buildcache 0.31.7 of this job has direct mode on by default, the
# buildcache-git 0.28.1 of the Linux image (cachyos repo) has it off
# - remove when direct mode takes its inputs from the depfile or the -include operands
env:
BUILDCACHE_DIRECT_MODE: false
defaults:
run:
shell: bash # Forces Git Bash for consistency with Linux scripts
Expand Down
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Read it before you change a file. Match the existing code.
| `cvk/` | C++ wrapper of the Vulkan C API: one class per Vulkan object, objects own their handle |
| `cgfw/` | C++ wrapper of RGFW: windows of the platform (Win32, Wayland) and their Vulkan surface |
| `jvk/` | coroutine layer on top of `cvk` (in progress): threads, queues, stage graph, object lifetimes |
| `timgui/` | ImGui on `jvk` and `cgfw`: input from a window, draws into a rendering |
| `tests/` | loader smoke tests |
| `lib/cth` | cth (submodule), `lib/cmake/cth.cmake` adds it with only the components the engine needs |
| `lib/cth_cmake` | cmake utilities (submodule) |
Expand All @@ -33,7 +34,8 @@ Read it before you change a file. Match the existing code.
## Branches

- `master` is the main branch.
- Work happens on a work branch off `master`. Its draft pull request into `master` runs the CI on every push.
- Work happens on a work branch off `master`. Its pull request into `master` runs the CI on every push.
- The pull request of a work branch stays a draft until the work is finished.
- `v2`, `_v2/...`, `dev` and `_dev/...` are old. Do not use them.
- Work locally. Do not open pull requests for single steps.
- CI runs on pushes and pull requests to `master`.
Expand All @@ -55,6 +57,8 @@ ctest --test-dir out/build/gcc_release --output-on-failure
- Tests that need a device use `test::Context` (`cvk/tests/src/context.hpp`). It fails the test on validation errors,
leaked objects included.
- `VCPKG_ROOT` must point at vcpkg.
- `glslc` and the validation layers come from the Vulkan SDK (Windows) or the system packages (Linux), not from
vcpkg.
- `doxygen` in the repository root checks the docs (`Doxyfile`, output in `out/doxygen`). A change adds no doxygen
warning.

Expand Down Expand Up @@ -323,6 +327,8 @@ this code base.
``@details calls @ref Instance(Config), `wrap()` ``, `@ref create(Config const&)`.
Do not write `(...)`: it does not link.
- Do not document what the signature already tells. A getter without conditions needs no comment.
- Docs are for the users of the API: private members and the helpers that only the module uses get a doc only for a
quirk that the code cannot say.
- The brief is the purpose. Side effects the caller must know go to `@details`.
- `@details` holds one fact per line, starting with its keyword, so a reader can scan for it. No text walls.
- one item: inline on the tag line: ``@details calls `optEnd()` on the secondaries``
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ include(cth_setup_utilities)
cth_set_compiler_specifics()
cth_set_latest_c_cpp_standard()

# the shaders: the GLSL language of cth_cmake, glslc of the Vulkan SDK or of the system
enable_language(GLSL)
# the Vulkan of the engine is a requirement of the project, no user flag of CMAKE_GLSL_FLAGS
add_compile_options($<$<COMPILE_LANGUAGE:GLSL>:--target-env=vulkan1.3>)

set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# lld links much faster than the default linker
Expand All @@ -27,6 +32,7 @@ endif ()
add_subdirectory(cvk)
add_subdirectory(cgfw)
add_subdirectory(jvk)
add_subdirectory(timgui)

# Demos
add_subdirectory(demo/triangle)
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# only the values that differ from the doxygen defaults, run: doxygen (from the repository root)
PROJECT_NAME = cth_engine
OUTPUT_DIRECTORY = out/doxygen
INPUT = cvk/incl jvk/incl cgfw/incl
INPUT = cvk/incl jvk/incl cgfw/incl timgui/incl
RECURSIVE = YES
FILE_PATTERNS = *.hpp
JAVADOC_AUTOBRIEF = YES
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ built and tested with:
- [vcpkg](https://github.com/microsoft/vcpkg) with `VCPKG_ROOT` set
- gcc 16, clang 23 or msvc
- a vulkan 1.3 driver
- windows: the [vulkan sdk](https://vulkan.lunarg.com/sdk/home), linux: the packages of the validation layers and shaderc
- glslc compiles the shaders, debug builds enable the validation layers

## build & test
```bash
Expand Down
39 changes: 39 additions & 0 deletions cgfw/incl/cgfw/window/event.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
#include <cth/chrono.hpp>
#include <cth/io/axis.hpp>
#include <cth/io/keybd/keys.hpp>

#include <string>
#include <variant>


namespace cgfw {
/**
* text input of a window
* @details one event per character, a dead key and the next key give one character
*/
struct TextEvent {
std::string text; ///< UTF-8
cth::chrono::time_point_t time;

[[nodiscard]] constexpr bool operator==(TextEvent const&) const = default;
};

/**
* the window gets or loses the keyboard focus
*/
struct FocusEvent {
bool focused;
cth::chrono::time_point_t time;

[[nodiscard]] constexpr bool operator==(FocusEvent const&) const = default;
};

/**
* input event of a window
* @details
* - keys and mouse buttons: `cth::io::key_update`
* - mouse position and scroll: `cth::io::axis_update`
*/
using window_event = std::variant<cth::io::key_update, cth::io::axis_update, TextEvent, FocusEvent>;
}
38 changes: 25 additions & 13 deletions cgfw/incl/cgfw/window/window.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#include "cgfw/window/event.hpp"

#include "cvk/surface/surface.hpp"
#include "cvk/utility/constants.hpp"
#include "cvk/utility/handle/unique_handle.hpp"
Expand All @@ -11,6 +13,7 @@
#include <cth/ptr/not_null.hpp>

#include <cstdint>
#include <span>
#include <string>
#include <vector>

Expand All @@ -33,7 +36,7 @@ enum class WindowFlags : uint32_t {
NONE = 0,
NO_BORDER = cth::en::flag_val(0),
NO_RESIZE = cth::en::flag_val(1),
FULLSCREEN = cth::en::flag_val(4),
FULLSCREEN = cth::en::flag_val(19), ///< borderless, the monitor keeps its video mode
CENTER = cth::en::flag_val(6),
SCALE_TO_MONITOR = cth::en::flag_val(8),
/**
Expand Down Expand Up @@ -62,9 +65,6 @@ struct native_window {
};

namespace dev {
/**
* deleter of a window, without context
*/
struct window_deleter {
void operator()(RGFW_window*) const;
};
Expand All @@ -75,6 +75,7 @@ namespace dev {
* @details a window of the platform: Win32 or Wayland
* @details the first window initializes RGFW, the destruction of the last one deinitializes it
* @details `pollEvents()` handles the events of every window
* @details `events()` holds the input events of the window
* @attention not thread safe, also across windows
*/
class Window {
Expand Down Expand Up @@ -131,10 +132,11 @@ class Window {

/**
* creates the window with the config
* @details no window exists -> initializes RGFW first
* @details RGFW is not initialized -> initializes RGFW with Vulkan first
* @pre `Config::debug_check()` passes for the config
* @post `created()`
* @note calls `optDestroy()`
* @throws cgfw::cgfw_exception reason: `RGFW_init()` failed, e.g. no display
* @throws cgfw::cgfw_exception reason: `RGFW_createWindow()` failed
*/
void create();
Expand Down Expand Up @@ -171,20 +173,29 @@ class Window {
*/
[[nodiscard]] cvk::Surface surface(cvk::Instance const&) const;

//TODO review the size of RGFW: our fork keeps the buffer scale of Wayland at 1, the size is in buffer pixels
//TODO the buffer scale of Wayland (HiDPI): the surface stays at scale 1, a scaled output upscales the window
//TODO the buffer scale of Wayland (HiDPI): the size is in buffer pixels, our fork of RGFW keeps
// the buffer scale at 1, a scaled output upscales the window
/**
* @return current size of the framebuffer in pixels
* @pre `created()`
*/
[[nodiscard]] VkExtent2D extent() const;

/**
* handles the pending events of every window
* @details returns at once, no wait for an event: for a render loop, it answers the pings of the compositor
* handles the pending events of every window, keeps the input events of this window
* @details
* - returns at once, no wait for an event: for a render loop, it answers the pings of the compositor
* - replaces `events()`
* - the events of the other windows stay queued until their `pollEvents()`
* @pre `created()`
*/
void pollEvents() const;
void pollEvents();

/**
* @return the input events of the last `pollEvents()`, in order
* @details valid until the next `pollEvents()`
*/
[[nodiscard]] std::span<window_event const> events() const { return _events; }

/**
* @return the user or the platform requested to close the window
Expand All @@ -201,9 +212,9 @@ class Window {

/**
* closes the window and frees it
* @pre the window is not `nullptr`
* @details the last window of RGFW deinitializes RGFW
*/
static void destroy(RGFW_window*);
static void destroy(RGFW_window&);

[[nodiscard]] constexpr bool created() const { return static_cast<bool>(_handle); }
[[nodiscard]] constexpr handle_t get() const { return _handle.get(); }
Expand All @@ -214,6 +225,7 @@ class Window {

Config _config;
cvk::unique_handle<handle_t, dev::window_deleter> _handle{};
std::vector<window_event> _events{};

public:
Window(Window const& other) = delete;
Expand All @@ -232,7 +244,7 @@ class Window {

namespace cgfw {
struct Window::State {
//TODO review stays a not_null pointer: the raw handle of RGFW, like vk_not_null for Vulkan handles
// stays a not_null pointer: the raw handle of RGFW, like vk_not_null for Vulkan handles
cth::not_null_ptr<RGFW_window> rgfwWindow;
};
}
Expand Down
6 changes: 6 additions & 0 deletions cgfw/src/window/rgfw.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// the RGFW implementation, no other source file defines RGFW_IMPLEMENTATION
// C: the Wayland part of RGFW is no valid C++ (void* conversions, designator order)
#include "window/rgfw_info.h"

// volk first: RGFW includes vulkan.h, volk needs VK_NO_PROTOTYPES before it
#include <volk.h>

#define RGFW_IMPLEMENTATION
#include <RGFW.h>

size_t cgfw_rgfw_window_count(void) {
RGFW_info const* const info = RGFW_getInfo();
return info == NULL ? 0 : (size_t)info->windowCount;
}
100 changes: 100 additions & 0 deletions cgfw/src/window/rgfw_event.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include "window/rgfw_event.hpp"

#include <cth/os/osdef.hpp>

#ifdef CTH_PLATFORM_WINDOWS
#include <windows.h>
#else
#include <time.h>
#endif


namespace cgfw::dev {
uint32_t os_input_time() {
#ifdef CTH_PLATFORM_WINDOWS
return static_cast<uint32_t>(GetTickCount());
#else
timespec time{};
clock_gettime(CLOCK_MONOTONIC, &time);

// the input times wrap at 2^32 milliseconds, the truncation wraps the same
auto const milliseconds = static_cast<uint64_t>(time.tv_sec) * 1000
+ static_cast<uint64_t>(time.tv_nsec) / 1'000'000;
return static_cast<uint32_t>(milliseconds);
#endif
}

std::optional<window_event> to_event(
RGFW_event const& rgfwEvent,
input_clock const& clock,
u32 (*keyChar)(RGFW_key)
) {
using cth::io::Axis;
using cth::io::axis_state;
using cth::io::axis_update;
using cth::io::key_state;
using cth::io::key_update;

switch(rgfwEvent.common.type) {
case RGFW_keyPressed:
case RGFW_keyReleased: {
auto const& key = rgfwEvent.key;
auto const exKey = to_ex_key(key.value);
if(!exKey)
return std::nullopt;

return key_update{
.data = key_state{
*exKey,
key.state != RGFW_FALSE,
to_utf8(static_cast<char32_t>(keyChar(key.value))),
key.repeat != RGFW_FALSE
},
.time = clock.timePoint(key.time)
};
}
case RGFW_mouseButtonPressed:
case RGFW_mouseButtonReleased: {
auto const& button = rgfwEvent.button;
auto const key = to_mouse_key(button.value);
if(!key)
return std::nullopt;

return key_update{
.data = key_state{*key, false, button.state != RGFW_FALSE},
.time = clock.timePoint(button.time)
};
}
case RGFW_mouseMotion: {
auto const& mouse = rgfwEvent.mouse;
return axis_update{
.data = axis_state{
.axis = Axis::MOUSE_POSITION,
.value = {static_cast<float>(mouse.x), static_cast<float>(mouse.y)}
},
.time = clock.timePoint(mouse.time)
};
}
case RGFW_mouseScroll: {
auto const& delta = rgfwEvent.delta;
return axis_update{
.data = axis_state{.axis = Axis::MOUSE_SCROLL, .value = {delta.x, delta.y}},
.time = clock.timePoint(delta.time)
};
}
case RGFW_keyChar: {
auto const& keyCharEvent = rgfwEvent.keyChar;
auto text = to_utf8(static_cast<char32_t>(keyCharEvent.value));
if(text.empty())
return std::nullopt;

return TextEvent{.text = std::move(text), .time = clock.timePoint(keyCharEvent.time)};
}
// RGFW gives focus events no OS time
case RGFW_windowFocusIn: return FocusEvent{.focused = true, .time = clock.now};
case RGFW_windowFocusOut: return FocusEvent{.focused = false, .time = clock.now};

default: return std::nullopt;
}
}
}
Loading
Loading