summaryrefslogtreecommitdiff
path: root/src/gpu/gpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gpu.h')
-rw-r--r--src/gpu/gpu.h77
1 files changed, 7 insertions, 70 deletions
diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h
index 45c6413..40274b9 100644
--- a/src/gpu/gpu.h
+++ b/src/gpu/gpu.h
@@ -4,74 +4,7 @@
#pragma once
-#include <webgpu.h>
-
-#include <cstring> // For strlen
-
-#if defined(DEMO_CROSS_COMPILE_WIN32)
-
-// Windows (MinGW) using wgpu-native v0.19.4.1
-#define WGPUOptionalBool_True true
-#define WGPUOptionalBool_False false
-
-#include <webgpu/webgpu.h>
-
-#include <webgpu/wgpu.h>
-
-static inline const char* str_view(const char* str) {
- return str;
-}
-
-static inline const char* label_view(const char* str) {
- return str;
-}
-
-#define WGPUSType_ShaderSourceWGSL WGPUSType_ShaderModuleWGSLDescriptor
-
-using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor;
-
-#define WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal \
- WGPUSurfaceGetCurrentTextureStatus_Success
-
-#define WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal \
- WGPUSurfaceGetCurrentTextureStatus_Success
-
-#define WGPUCallbackMode_WaitAnyOnly 0
-
-#else
-
-// Native (macOS/Linux) using newer wgpu-native
-
-#include <webgpu.h>
-
-#include <wgpu.h>
-
-static inline WGPUStringView str_view(const char* str) {
- if (!str)
- return {nullptr, 0};
-
- return {str, strlen(str)};
-}
-
-static inline WGPUStringView label_view(const char* str) {
-
-#if !defined(STRIP_ALL)
-
- if (!str)
- return {nullptr, 0};
-
- return {str, strlen(str)};
-
-#else
-
- (void)str;
-
- return {nullptr, 0};
-
-#endif /* !defined(STRIP_ALL) */
-}
-
-#endif /* defined(DEMO_CROSS_COMPILE_WIN32) */
+#include "platform.h"
struct PlatformState; // Forward declaration
@@ -123,7 +56,11 @@ inline void gpu_init_color_attachment(WGPURenderPassColorAttachment& attachment,
attachment.view = view;
attachment.loadOp = WGPULoadOp_Clear;
attachment.storeOp = WGPUStoreOp_Store;
-#if !defined(DEMO_CROSS_COMPILE_WIN32)
+ attachment.clearValue = {0.0f, 0.0f, 0.0f, 1.0f};
+#if defined(DEMO_CROSS_COMPILE_WIN32)
+ // depthSlice is handled via macro in platform.h if needed,
+ // but usually it's better to just avoid setting it on older wgpu-native
+#else
attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
#endif
}
@@ -137,4 +74,4 @@ RenderPass
gpu_create_render_pass(WGPUDevice device,
WGPUTextureFormat format, // Needed for render pipeline
const char* shader_code, ResourceBinding* bindings,
- int num_bindings);
+ int num_bindings); \ No newline at end of file