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.h38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h
index 41eeb29..d6c0255 100644
--- a/src/gpu/gpu.h
+++ b/src/gpu/gpu.h
@@ -1,27 +1,23 @@
// This file is part of the 64k demo project.
-// It defines the public interface for the GPU rendering system.
-// Coordinates WebGPU lifecycle and draw calls.
+// GPU rendering system interface.
#pragma once
#include "platform/platform.h"
-struct PlatformState; // Forward declaration
+struct PlatformState;
-// GPU context bundling device, queue, and surface format
struct GpuContext {
WGPUDevice device;
WGPUQueue queue;
WGPUTextureFormat format;
};
-// Basic wrapper for WebGPU buffers
struct GpuBuffer {
WGPUBuffer buffer;
size_t size;
};
-// Encapsulates a compute operation
struct ComputePass {
WGPUComputePipeline pipeline;
WGPUBindGroup bind_group;
@@ -30,7 +26,6 @@ struct ComputePass {
uint32_t workgroup_size_z;
};
-// Encapsulates a render operation
struct RenderPass {
WGPURenderPipeline pipeline;
WGPUBindGroup bind_group;
@@ -48,33 +43,35 @@ WGPUSurface gpu_get_surface();
const GpuContext* gpu_get_context();
-// Placeholder for GPU performance capture.
-// This define can be controlled via CMake to conditionally enable profiling
-// code. #define ENABLE_GPU_PERF_CAPTURE
-
-// Helper functions (exposed for internal/future use)
struct ResourceBinding {
GpuBuffer buffer;
- WGPUBufferBindingType type; // e.g., WGPUBufferBindingType_Uniform,
- // WGPUBufferBindingType_Storage
+ WGPUBufferBindingType type;
};
-// Cross-platform helper for color attachment initialization
inline void gpu_init_color_attachment(WGPURenderPassColorAttachment& attachment,
WGPUTextureView view) {
attachment.view = view;
attachment.loadOp = WGPULoadOp_Clear;
attachment.storeOp = WGPUStoreOp_Store;
attachment.clearValue = {0.0f, 0.0f, 0.0f, 1.0f};
+#if !defined(DEMO_CROSS_COMPILE_WIN32)
attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
+#endif
}
-// Texture creation helper
struct TextureWithView {
WGPUTexture texture;
WGPUTextureView view;
};
+#if defined(DEMO_CROSS_COMPILE_WIN32)
+using GpuTextureCopyInfo = WGPUImageCopyTexture;
+using GpuTextureDataLayout = WGPUTextureDataLayout;
+#else
+using GpuTextureCopyInfo = WGPUTexelCopyTextureInfo;
+using GpuTextureDataLayout = WGPUTexelCopyBufferLayout;
+#endif
+
GpuBuffer gpu_create_buffer(WGPUDevice device, size_t size, uint32_t usage,
const void* data = nullptr);
TextureWithView gpu_create_texture_2d(WGPUDevice device, uint32_t width,
@@ -100,4 +97,11 @@ RenderPass
gpu_create_render_pass(WGPUDevice device,
WGPUTextureFormat format, // Needed for render pipeline
const char* shader_code, ResourceBinding* bindings,
- int num_bindings); \ No newline at end of file
+ int num_bindings);
+
+// Common sampler configurations
+WGPUSampler gpu_create_linear_sampler(WGPUDevice device);
+WGPUSampler gpu_create_nearest_sampler(WGPUDevice device);
+
+// Dummy 1x1 texture for scene effects (don't need texture input)
+TextureWithView gpu_create_dummy_scene_texture(WGPUDevice device); \ No newline at end of file