From 44b8ab08af2f7acf9bd30b75d07e8adf97884142 Mon Sep 17 00:00:00 2001 From: Fabrice Date: Tue, 10 Feb 2026 14:42:16 +0100 Subject: creating wgpu instance --- .gitmodules | 3 +++ Makefile | 25 ++++++++++++++++++++++--- src/wayclock.cc | 7 +++++++ wgpu | 1 + 4 files changed, 33 insertions(+), 3 deletions(-) create mode 160000 wgpu diff --git a/.gitmodules b/.gitmodules index e48e435..5fc57bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "hashmap"] path = hashmap url = https://github.com/tidwall/hashmap.c.git +[submodule "wgpu"] + path = wgpu + url = https://github.com/gfx-rs/wgpu-native.git diff --git a/Makefile b/Makefile index 5837100..0d03f50 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ CXX = clang++ CXX_STD = -std=c++11 CXX_FLAGS = -fno-rtti -fno-exceptions $(CXX_STD) $(CSH_FLAGS) +CARGO = cargo RM = rm -rf ECHO = echo CMAKE = cmake @@ -35,7 +36,20 @@ MI_FLAGS = \ HASHMAP_DIR = $(WORK_DIR)/hashmap HASHMAP_SOURCE = $(HASHMAP_DIR)/hashmap.c -CSH_FLAGS += -I$(MI_INCLUDE) -I$(HASHMAP_DIR) +WGPU_DIR = $(WORK_DIR)/wgpu +WGPU_MANIFEST = $(WGPU_DIR)/Cargo.toml +WGPU_INCLUDE = $(WGPU_DIR)/ffi +WGPU_WEBGPU_INCLUDE = $(WGPU_INCLUDE)/webgpu-headers +WGPU_BUILD = $(WGPU_DIR)/target/release +WGPU_LIB = $(WGPU_BUILD)/libwgpu_native.a +WGPU_MANIFEST_FLAG = --manifest-path $(WGPU_MANIFEST) +WGPU_FLAGS = --release $(WGPU_MANIFEST_FLAG) + +CSH_FLAGS += \ + -I$(MI_INCLUDE) \ + -I$(HASHMAP_DIR) \ + -I$(WGPU_INCLUDE) \ + -I$(WGPU_WEBGPU_INCLUDE) MI_GENERATOR = "Unix Makefiles" @@ -58,10 +72,14 @@ OBJECTS += $(MI_OBJECT) DEPS = $(OBJECTS:.o=.d) -LIBRARIES = -lwayland-client -lvulkan +LIBRARIES = -lwayland-client -lvulkan $(WGPU_LIB) all: $(WAYCLOCK) +$(WGPU_LIB): + @echo " CARGO $@" + @$(CARGO) build $(WGPU_FLAGS) + $(MI_BUILD): @echo " CMAKE $@" @$(CMAKE) $(MI_DIR) -B $@ -G $(MI_GENERATOR) $(MI_FLAGS) @@ -70,7 +88,7 @@ $(MI_OBJECT): | $(MI_BUILD) @echo " MAKE $@" @$(MAKE) -C $(MI_BUILD) -$(WAYCLOCK): $(OBJECTS) +$(WAYCLOCK): $(OBJECTS) $(LIBRARIES) @echo " LD $@" @$(CXX) $(CXX_FLAGS) -o $@ $^ $(LIBRARIES) @@ -84,6 +102,7 @@ $(WAYCLOCK): $(OBJECTS) .PHONY: clean clean: + @$(CARGO) clean $(WGPU_MANIFEST_FLAG) @$(RM) $(OBJECTS) $(DEPS) @$(RM) $(WAYCLOCK) @$(RM) $(MI_BUILD) diff --git a/src/wayclock.cc b/src/wayclock.cc index af54543..07d767e 100644 --- a/src/wayclock.cc +++ b/src/wayclock.cc @@ -1,7 +1,10 @@ +#include + #include #include "events.h" #include "graphics.h" +#include "webgpu.h" #include "window.h" #define WAYC_APP_NAME "Wayclock" @@ -39,6 +42,9 @@ void handle(struct eventloop_s* loop, struct event_s* event) { } int main() { + WGPUInstance instance = wgpuCreateInstance(nullptr); + if (instance == nullptr) wayc_panic("Failed to create WGPU instance"); + struct graphics_s graphics; if (wayc_graphics_init(&graphics) != GRAPHICS_ERROR_NONE) wayc_panic("Failed to initialize graphics"); @@ -63,5 +69,6 @@ int main() { wayc_window_deinit(&window); wayc_eventloop_deinit(&loop); wayc_graphics_deinit(&graphics); + wgpuInstanceRelease(instance); return 0; } \ No newline at end of file diff --git a/wgpu b/wgpu new file mode 160000 index 0000000..d53a603 --- /dev/null +++ b/wgpu @@ -0,0 +1 @@ +Subproject commit d53a603900009077c6e09676c3e3a13719e6f070 -- cgit v1.2.3