summaryrefslogtreecommitdiff
path: root/src/gpu/gpu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gpu.cc')
-rw-r--r--src/gpu/gpu.cc60
1 files changed, 6 insertions, 54 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc
index e76aecc..db79b9d 100644
--- a/src/gpu/gpu.cc
+++ b/src/gpu/gpu.cc
@@ -22,66 +22,20 @@
// --- WebGPU Headers & Compatibility ---
#if defined(DEMO_CROSS_COMPILE_WIN32)
-// Windows (MinGW) using wgpu-native v0.19.4.1
-#include <webgpu/webgpu.h>
-#include <webgpu/wgpu.h>
-
-// Type Shims
-using WGPUStringView = const char *;
-static const char *str_view(const char *str) {
- return str;
-}
-static const char *label_view(const char *str) {
- return str;
-}
-
// Renamed Types/Enums
#define WGPUSType_ShaderSourceWGSL WGPUSType_ShaderModuleWGSLDescriptor
using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor;
-#define WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal \
- WGPUSurfaceGetCurrentTextureStatus_Success
-#define WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal \
- WGPUSurfaceGetCurrentTextureStatus_Success
-
-// Callback Mode Shim (Not used in old API signatures, but needed for ifdef
-// logic)
+#define WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal WGPUSurfaceGetCurrentTextureStatus_Success
+#define WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal WGPUSurfaceGetCurrentTextureStatus_Success
#define WGPUCallbackMode_WaitAnyOnly 0
-
-// Wait Shim
-static void wgpuInstanceWaitAny(WGPUInstance instance, size_t, void *,
- uint64_t) {
+static void wgpuInstanceWaitAny(WGPUInstance instance, size_t, void *, uint64_t) {
wgpuInstanceProcessEvents(instance);
}
-
-// Uncaptured Error Callback Helper
static void set_error_callback(WGPUDevice device, WGPUErrorCallback callback) {
wgpuDeviceSetUncapturedErrorCallback(device, callback, nullptr);
}
-
#else
-// Native (macOS/Linux) using newer wgpu-native
-#include <webgpu.h>
-#include <wgpu.h>
-
-static WGPUStringView label_view(const char *str) {
-#ifndef STRIP_ALL
- if (!str)
- return {nullptr, 0};
- return {str, strlen(str)};
-#else
- (void)str;
- return {nullptr, 0};
-#endif
-}
-
-static WGPUStringView str_view(const char *str) {
- if (!str)
- return {nullptr, 0};
- return {str, strlen(str)};
-}
-
-static void set_error_callback(WGPUDevice device,
- WGPUUncapturedErrorCallback callback) {
+static void set_error_callback(WGPUDevice device, WGPUUncapturedErrorCallback callback) {
// Handled in descriptor for new API.
}
#endif
@@ -353,7 +307,7 @@ static void handle_request_device(WGPURequestDeviceStatus status,
#endif
#endif
-void gpu_init(GLFWwindow *window) {
+void gpu_init(GLFWwindow *window, int width, int height) {
g_instance = wgpuCreateInstance(nullptr);
g_surface = platform_create_wgpu_surface(g_instance);
@@ -404,8 +358,6 @@ void gpu_init(GLFWwindow *window) {
wgpuSurfaceGetCapabilities(g_surface, g_adapter, &caps);
WGPUTextureFormat swap_chain_format = caps.formats[0];
- int width, height;
- glfwGetFramebufferSize(window, &width, &height);
g_config.device = g_device;
g_config.format = swap_chain_format;
g_config.usage = WGPUTextureUsage_RenderAttachment;
@@ -415,7 +367,7 @@ void gpu_init(GLFWwindow *window) {
g_config.alphaMode = WGPUCompositeAlphaMode_Opaque;
wgpuSurfaceConfigure(g_surface, &g_config);
- g_main_sequence.init(g_device, g_queue, g_config.format);
+ g_main_sequence.init(g_device, g_queue, g_config.format, width, height);
LoadTimeline(g_main_sequence, g_device, g_queue, g_config.format);
}