Gpu cleanup

This commit is contained in:
luboslenco
2025-09-26 10:48:18 +02:00
parent 06c094313e
commit ef7f28aa34
9 changed files with 16 additions and 13 deletions
+1 -1
View File
@@ -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]);
}
+1 -1
View File
@@ -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<MTLTexture>)current_render_targets[i]->impl._tex;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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");
+8 -5
View File
@@ -9,9 +9,6 @@
#include <iron_array.h>
#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);
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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();
}