diff --git a/base/sources/backends/direct3d12_gpu.c b/base/sources/backends/direct3d12_gpu.c index 0b3d7b3b..3abd95c4 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -44,7 +44,7 @@ static ID3D12Resource *readback_buffer = NULL; static int readback_buffer_size = 0; static ID3D12Resource *upload_buffer = NULL; static int upload_buffer_size = 0; -static ID3D12Resource *resources_to_destroy[256]; +static ID3D12Resource *resources_to_destroy[512]; static int resources_to_destroy_count = 0; static char device_name[256]; @@ -980,7 +980,7 @@ void gpu_render_target_init(gpu_texture_t *target, int width, int height, gpu_te void _gpu_buffer_init(ID3D12Resource **buffer, int size, D3D12_HEAP_TYPE heap_type) { if (*buffer != NULL) { - assert(resources_to_destroy_count < 256); + assert(resources_to_destroy_count < 512); resources_to_destroy[resources_to_destroy_count] = *buffer; resources_to_destroy_count++; } diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 8818fcf1..86e65b0d 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -39,8 +39,8 @@ static VkSampler linear_sampler; static VkSampler point_sampler; static bool linear_sampling = true; static VkCommandBuffer command_buffer; -static VkBuffer buffers_to_destroy[256]; -static VkDeviceMemory buffer_memories_to_destroy[256]; +static VkBuffer buffers_to_destroy[512]; +static VkDeviceMemory buffer_memories_to_destroy[512]; static int buffers_to_destroy_count = 0; static char device_name[256]; @@ -1760,7 +1760,7 @@ void gpu_render_target_init(gpu_texture_t *target, int width, int height, gpu_te void _gpu_buffer_init(gpu_buffer_impl_t *buffer, int size, int usage, int memory_requirements) { if (buffer->buf != NULL) { - assert(buffers_to_destroy_count < 256); + assert(buffers_to_destroy_count < 512); buffers_to_destroy[buffers_to_destroy_count] = buffer->buf; buffer_memories_to_destroy[buffers_to_destroy_count] = buffer->mem; buffers_to_destroy_count++; diff --git a/base/sources/iron_gpu.c b/base/sources/iron_gpu.c index f3e5ea1c..44df2fba 100644 --- a/base/sources/iron_gpu.c +++ b/base/sources/iron_gpu.c @@ -5,7 +5,7 @@ static gpu_buffer_t constant_buffer; static bool gpu_thrown = false; static gpu_texture_t textures_to_destroy[128]; static gpu_buffer_t buffers_to_destroy[128]; -static gpu_pipeline_t pipelines_to_destroy[32]; +static gpu_pipeline_t pipelines_to_destroy[128]; static int textures_to_destroy_count = 0; static int buffers_to_destroy_count = 0; static int pipelines_to_destroy_count = 0; @@ -94,11 +94,7 @@ void gpu_end() { gpu_end_internal(); } -void gpu_present() { - gpu_present_internal(); - draw_calls_last = draw_calls; - draw_calls = 0; - +void gpu_cleanup() { while (textures_to_destroy_count > 0) { textures_to_destroy_count--; gpu_texture_destroy_internal(&textures_to_destroy[textures_to_destroy_count]); @@ -113,6 +109,13 @@ void gpu_present() { } } +void gpu_present() { + gpu_present_internal(); + draw_calls_last = draw_calls; + draw_calls = 0; + gpu_cleanup(); +} + void gpu_resize(int width, int height) { if (width == 0 || height == 0) { return; @@ -277,16 +280,28 @@ void gpu_create_framebuffers(int depth_buffer_bits) { void gpu_texture_destroy(gpu_texture_t *texture) { textures_to_destroy[textures_to_destroy_count] = *texture; textures_to_destroy_count++; + if (textures_to_destroy_count >= 128) { + gpu_execute_and_wait(); + gpu_cleanup(); + } } void gpu_pipeline_destroy(gpu_pipeline_t *pipeline) { pipelines_to_destroy[pipelines_to_destroy_count] = *pipeline; pipelines_to_destroy_count++; + if (pipelines_to_destroy_count >= 128) { + gpu_execute_and_wait(); + gpu_cleanup(); + } } void gpu_buffer_destroy(gpu_buffer_t *buffer) { buffers_to_destroy[buffers_to_destroy_count] = *buffer; buffers_to_destroy_count++; + if (buffers_to_destroy_count >= 128) { + gpu_execute_and_wait(); + gpu_cleanup(); + } } int gpu_vertex_data_size(gpu_vertex_data_t data) { diff --git a/base/sources/libs/kong/functions.c b/base/sources/libs/kong/functions.c index 8c4c300d..8ba438e3 100644 --- a/base/sources/libs/kong/functions.c +++ b/base/sources/libs/kong/functions.c @@ -323,8 +323,10 @@ static void add_func_void_uint_uint(char *name) { f->parameter_names[0] = add_name("a"); f->parameter_names[1] = add_name("b"); for (int i = 0; i < 2; ++i) { - init_type_ref(&f->parameter_types[0], add_name("uint")); - f->parameter_types[0].type = find_type_by_ref(&f->parameter_types[0]); + //// + init_type_ref(&f->parameter_types[i], add_name("uint")); + f->parameter_types[i].type = find_type_by_ref(&f->parameter_types[i]); + //// } f->parameters_size = 2; diff --git a/paint/sources/node_shader.ts b/paint/sources/node_shader.ts index c86cb473..792b11fd 100644 --- a/paint/sources/node_shader.ts +++ b/paint/sources/node_shader.ts @@ -89,14 +89,11 @@ function node_shader_add_constant(raw: node_shader_t, s: string, link: string = } } -function node_shader_add_texture(raw: node_shader_t, s: string, link: string = null) { +function node_shader_add_texture(raw: node_shader_t, name: string, link: string = null) { // mytex: tex2d - if (array_index_of(raw.textures, s) == -1) { - let ar: string[] = string_split(s, ": "); - let uname: string = ar[0]; - let utype: string = ar[1]; - array_push(raw.textures, s); - node_shader_context_add_texture_unit(raw.context, utype, uname, link); + if (array_index_of(raw.textures, name) == -1) { + array_push(raw.textures, name); + node_shader_context_add_texture_unit(raw.context, name, link); } } diff --git a/paint/sources/node_shader_context.ts b/paint/sources/node_shader_context.ts index ef5bbb08..b5fe2fe0 100644 --- a/paint/sources/node_shader_context.ts +++ b/paint/sources/node_shader_context.ts @@ -110,7 +110,7 @@ function node_shader_context_add_constant(raw: node_shader_context_t, ctype: str array_push(consts, c); } -function node_shader_context_add_texture_unit(raw: node_shader_context_t, ctype: string, name: string, link: string = null) { +function node_shader_context_add_texture_unit(raw: node_shader_context_t, name: string, link: string = null) { for (let i: i32 = 0; i < raw.data.texture_units.length; ++i) { let c: tex_unit_t = raw.data.texture_units[i]; if (c.name == name) { diff --git a/paint/sources/project.ts b/paint/sources/project.ts index 2b04b82d..0fcaa9fe 100644 --- a/paint/sources/project.ts +++ b/paint/sources/project.ts @@ -254,6 +254,7 @@ function project_new(reset_layers: bool = true) { context_raw.picked_color = make_swatch(); context_raw.color_picker_callback = null; history_reset(); + make_material_parse_paint_material(); make_material_parse_brush(); util_render_make_material_preview();