diff --git a/base/sources/backends/direct3d12_gpu.c b/base/sources/backends/direct3d12_gpu.c index 210af2c2..3d59e7e5 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -363,7 +363,7 @@ void gpu_init_internal(int depth_buffer_bits, bool vsync) { device->lpVtbl->CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, command_allocator, NULL, &IID_ID3D12CommandList, &command_list); } -void gpu_begin_internal(unsigned flags, unsigned color, float depth) { +void gpu_begin_internal(gpu_clear_t flags, unsigned color, float depth) { for (int i = 0; i < current_render_targets_count; ++i) { current_render_targets[i]->impl.rtv_descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(current_render_targets[i]->impl.rtv_descriptor_heap, &target_descriptors[i]); } diff --git a/base/sources/backends/metal_gpu.m b/base/sources/backends/metal_gpu.m index 9587cd20..8e672a60 100644 --- a/base/sources/backends/metal_gpu.m +++ b/base/sources/backends/metal_gpu.m @@ -174,7 +174,7 @@ void gpu_init_internal(int depth_buffer_bits, bool vsync) { next_drawable(); } -void gpu_begin_internal(unsigned flags, unsigned color, float depth) { +void gpu_begin_internal(gpu_clear_t flags, unsigned color, float depth) { render_pass_desc = [MTLRenderPassDescriptor renderPassDescriptor]; for (int i = 0; i < current_render_targets_count; ++i) { render_pass_desc.colorAttachments[i].texture = (__bridge id)current_render_targets[i]->impl._tex; diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 682c35f2..a7a0e317 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -1018,7 +1018,7 @@ bool iron_vulkan_get_size(int *width, int *height) { return false; } -void gpu_begin_internal(unsigned flags, unsigned color, float depth) { +void gpu_begin_internal(gpu_clear_t flags, unsigned color, float depth) { if (!framebuffer_acquired) { acquire_next_image(); framebuffer_acquired = true; diff --git a/base/sources/backends/webgpu_gpu.c b/base/sources/backends/webgpu_gpu.c index d7eed703..fdf7713b 100644 --- a/base/sources/backends/webgpu_gpu.c +++ b/base/sources/backends/webgpu_gpu.c @@ -50,7 +50,7 @@ void gpu_init_internal(int depth_bits, bool vsync) { swapChain = wgpuDeviceCreateSwapChain(device, surface, &scDesc); } -void gpu_begin_internal(unsigned flags, unsigned color, float depth) { +void gpu_begin_internal(gpu_clear_t flags, unsigned color, float depth) { WGPUCommandEncoderDescriptor ceDesc; memset(&ceDesc, 0, sizeof(ceDesc)); encoder = wgpuDeviceCreateCommandEncoder(device, &ceDesc); diff --git a/base/sources/iron.h b/base/sources/iron.h index e24b9f54..54038a26 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -1264,7 +1264,7 @@ buffer_t *gpu_get_texture_pixels(gpu_texture_t *image) { return image->buffer; } -void _gpu_begin(gpu_texture_t *render_target, any_array_t *additional, gpu_texture_t *depth_buffer, unsigned flags, unsigned color, float depth) { +void _gpu_begin(gpu_texture_t *render_target, any_array_t *additional, gpu_texture_t *depth_buffer, gpu_clear_t flags, unsigned color, float depth) { if (render_target == NULL) { gpu_begin(NULL, 0, NULL, flags, color, depth); } diff --git a/base/sources/iron_gpu.c b/base/sources/iron_gpu.c index 6ddcab1d..3f934ac2 100644 --- a/base/sources/iron_gpu.c +++ b/base/sources/iron_gpu.c @@ -33,7 +33,7 @@ void gpu_init(int depth_buffer_bits, bool vsync) { gpu_constant_buffer_lock(&constant_buffer, 0, GPU_CONSTANT_BUFFER_SIZE); } -void gpu_begin(gpu_texture_t **targets, int count, gpu_texture_t *depth_buffer, unsigned flags, unsigned color, float depth) { +void gpu_begin(gpu_texture_t **targets, int count, gpu_texture_t *depth_buffer, gpu_clear_t flags, unsigned color, float depth) { if (gpu_in_use && !gpu_thrown) { gpu_thrown = true; iron_log("End before you begin"); diff --git a/base/sources/iron_gpu.h b/base/sources/iron_gpu.h index b627d029..969de463 100644 --- a/base/sources/iron_gpu.h +++ b/base/sources/iron_gpu.h @@ -9,9 +9,6 @@ #include #include BACKEND_GPU_H -#define GPU_CLEAR_NONE 0 -#define GPU_CLEAR_COLOR 1 -#define GPU_CLEAR_DEPTH 2 #define GPU_MAX_VERTEX_ELEMENTS 16 #define GPU_MAX_TEXTURES 16 #define GPU_CONSTANT_BUFFER_SIZE 512 @@ -22,6 +19,12 @@ #define GPU_FRAMEBUFFER_COUNT 3 #endif +typedef enum gpu_clear { + GPU_CLEAR_NONE = 0, + GPU_CLEAR_COLOR = 1, + GPU_CLEAR_DEPTH = 2, +} gpu_clear_t; + typedef enum gpu_texture_state { GPU_TEXTURE_STATE_SHADER_RESOURCE, GPU_TEXTURE_STATE_RENDER_TARGET, @@ -144,8 +147,8 @@ typedef struct gpu_raytrace_acceleration_structure { } gpu_raytrace_acceleration_structure_t; int gpu_max_bound_textures(void); -void gpu_begin(gpu_texture_t **targets, int count, gpu_texture_t *depth_buffer, unsigned flags, unsigned color, float depth); -void gpu_begin_internal(unsigned flags, unsigned color, float depth); +void gpu_begin(gpu_texture_t **targets, int count, gpu_texture_t *depth_buffer, gpu_clear_t flags, unsigned color, float depth); +void gpu_begin_internal(gpu_clear_t flags, unsigned color, float depth); void gpu_end(void); void gpu_end_internal(void); void gpu_execute_and_wait(void); diff --git a/base/sources/ts/iron.ts b/base/sources/ts/iron.ts index 324aebdd..026c74c4 100644 --- a/base/sources/ts/iron.ts +++ b/base/sources/ts/iron.ts @@ -276,7 +276,7 @@ declare function gpu_get_texture_pixels(texture: any): buffer_t; declare function gpu_viewport(x: i32, y: i32, width: i32, height: i32): void; declare function gpu_scissor(x: i32, y: i32, width: i32, height: i32): void; declare function gpu_disable_scissor(): void; -declare function _gpu_begin(render_target: gpu_texture_t, additional: gpu_texture_t[] = null, depth_buffer: gpu_texture_t = null, flags: i32 = clear_flag_t.NONE, color: i32 = 0, depth: f32 = 0.0): void; +declare function _gpu_begin(render_target: gpu_texture_t, additional: gpu_texture_t[] = null, depth_buffer: gpu_texture_t = null, flags: clear_flag_t = clear_flag_t.NONE, color: i32 = 0, depth: f32 = 0.0): void; declare function gpu_end(): void; declare function gpu_present(): void; declare function iron_file_save_bytes(path: string, bytes: buffer_t, length: i32 = 0): void; diff --git a/base/sources/ts/render_path.ts b/base/sources/ts/render_path.ts index ee8245bb..246fcdf9 100644 --- a/base/sources/ts/render_path.ts +++ b/base/sources/ts/render_path.ts @@ -64,7 +64,7 @@ function render_path_render_frame() { _render_path_frame++; } -function render_path_set_target(target: string, additional: string[] = null, depth_buffer: string = null, flags: i32 = clear_flag_t.NONE, color: i32 = 0, depth: f32 = 0.0) { +function render_path_set_target(target: string, additional: string[] = null, depth_buffer: string = null, flags: clear_flag_t = clear_flag_t.NONE, color: i32 = 0, depth: f32 = 0.0) { if (_render_path_current_image != null) { render_path_end(); }