From 7bbc063fac365570baab9b3475c172dbf59d7cee Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 9 Feb 2025 18:49:02 +0100 Subject: [PATCH] Cleanup --- .../kinc/backend/graphics5/texture.c.h | 1 - .../g4ong5/kinc/backend/graphics4/texture.c.h | 8 ----- armorcore/sources/iron.h | 35 ------------------- armorcore/sources/kinc/graphics4/texture.h | 22 ------------ armorcore/sources/ts/g4.ts | 21 ----------- armorcore/sources/ts/iron.ts | 3 -- armorcore/sources/ts/scene.ts | 13 ++----- 7 files changed, 2 insertions(+), 101 deletions(-) diff --git a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/texture.c.h b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/texture.c.h index 6b406d63..c00cebd4 100644 --- a/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/texture.c.h +++ b/armorcore/sources/backends/direct3d12/kinc/backend/graphics5/texture.c.h @@ -364,7 +364,6 @@ void kinc_g5_texture_init(struct kinc_g5_texture *texture, int width, int height } void kinc_g5_texture_init3d(kinc_g5_texture_t *texture, int width, int height, int depth, kinc_image_format_t format) { - // kinc_image_init3d(&texture->image, width, height, depth, format, readable); } void kinc_g5_texture_init_non_sampled_access(struct kinc_g5_texture *texture, int width, int height, kinc_image_format_t format) { diff --git a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/texture.c.h b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/texture.c.h index 3e762274..0d1b3017 100644 --- a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/texture.c.h +++ b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/texture.c.h @@ -14,8 +14,6 @@ void kinc_g4_texture_init_from_image(kinc_g4_texture_t *texture, kinc_image_t *i texture->format = image->format; } -void kinc_g4_texture_init_from_image3d(kinc_g4_texture_t *texture, kinc_image_t *image) {} - void kinc_g4_texture_init(kinc_g4_texture_t *texture, int width, int height, kinc_image_format_t format) { texture->impl._uploaded = true; kinc_g5_texture_init(&texture->impl._texture, width, height, format); @@ -25,8 +23,6 @@ void kinc_g4_texture_init(kinc_g4_texture_t *texture, int width, int height, kin texture->format = format; } -void kinc_g4_texture_init3d(kinc_g4_texture_t *texture, int width, int height, int depth, kinc_image_format_t format) {} - void kinc_g4_texture_init_from_bytes(kinc_g4_texture_t *texture, void *data, int size, const char *format) {} void kinc_g4_texture_init_from_bytes3d(kinc_g4_texture_t *texture, void *data, int width, int height, int depth, int format, bool readable) {} @@ -53,10 +49,6 @@ void kinc_g4_texture_unlock(kinc_g4_texture_t *texture) { texture->impl._uploaded = false; } -void kinc_g4_texture_clear(kinc_g4_texture_t *texture, int x, int y, int z, int width, int height, int depth, unsigned color) { - kinc_g5_texture_clear(&texture->impl._texture, x, y, z, width, height, depth, color); -} - int kinc_g4_texture_stride(kinc_g4_texture_t *texture) { return kinc_g5_texture_stride(&texture->impl._texture); } diff --git a/armorcore/sources/iron.h b/armorcore/sources/iron.h index 112fe4d8..5b32f43e 100644 --- a/armorcore/sources/iron.h +++ b/armorcore/sources/iron.h @@ -1873,12 +1873,6 @@ kinc_g4_texture_t *iron_g4_create_texture(i32 width, i32 height, i32 format) { return texture; } -kinc_g4_texture_t *iron_g4_create_texture3d(i32 width, i32 height, i32 depth, i32 format) { - kinc_g4_texture_t *texture = (kinc_g4_texture_t *)malloc(sizeof(kinc_g4_texture_t)); - kinc_g4_texture_init3d(texture, width, height, depth, (kinc_image_format_t)format); - return texture; -} - kinc_g4_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, i32 height, i32 format, bool readable) { kinc_g4_texture_t *texture = (kinc_g4_texture_t *)malloc(sizeof(kinc_g4_texture_t)); kinc_image_t *image = (kinc_image_t *)malloc(sizeof(kinc_image_t)); @@ -1903,31 +1897,6 @@ kinc_g4_texture_t *iron_g4_create_texture_from_bytes(buffer_t *data, i32 width, return texture; } -kinc_g4_texture_t *iron_g4_create_texture_from_bytes3d(buffer_t *data, i32 width, i32 height, i32 depth, i32 format, bool readable) { - kinc_g4_texture_t *texture = (kinc_g4_texture_t *)malloc(sizeof(kinc_g4_texture_t)); - kinc_image_t *image = (kinc_image_t *)malloc(sizeof(kinc_image_t)); - void *image_data; - if (readable) { - image_data = malloc(data->length); - memcpy(image_data, data->buffer, data->length); - } - else { - image_data = data->buffer; - } - - kinc_image_init3d(image, image_data, width, height, depth, (kinc_image_format_t)format); - kinc_g4_texture_init_from_image3d(texture, image); - - if (!readable) { - kinc_image_destroy(image); - free(image); - } - else { - texture->image = image; - } - return texture; -} - kinc_g4_texture_t *iron_g4_create_texture_from_encoded_bytes(buffer_t *data, string_t *format, bool readable) { kinc_g4_texture_t *texture = (kinc_g4_texture_t *)malloc(sizeof(kinc_g4_texture_t)); kinc_image_t *image = (kinc_image_t *)malloc(sizeof(kinc_image_t)); @@ -2046,10 +2015,6 @@ void iron_g4_unlock_texture(kinc_g4_texture_t *texture) { kinc_g4_texture_unlock(texture); } -void iron_g4_clear_texture(kinc_g4_texture_t *texture, i32 x, i32 y, i32 z, i32 width, i32 height, i32 depth, i32 color) { - kinc_g4_texture_clear(texture, x, y, z, width, height, depth, color); -} - void iron_g4_generate_texture_mipmaps(kinc_g4_texture_t *texture, i32 levels) { kinc_g4_texture_generate_mipmaps(texture, levels); } diff --git a/armorcore/sources/kinc/graphics4/texture.h b/armorcore/sources/kinc/graphics4/texture.h index 48a62543..8579b128 100644 --- a/armorcore/sources/kinc/graphics4/texture.h +++ b/armorcore/sources/kinc/graphics4/texture.h @@ -33,16 +33,6 @@ typedef struct kinc_g4_texture { /// The format of the texture to create void kinc_g4_texture_init(kinc_g4_texture_t *texture, int width, int height, kinc_image_format_t format); -/// -/// Allocates and initializes a 3d-texture without copying any data into it. -/// -/// The texture to initialize -/// The width of the texture to create -/// The height of the texture to create -/// The depth of the texture to create -/// The format of the texture to create -void kinc_g4_texture_init3d(kinc_g4_texture_t *texture, int width, int height, int depth, kinc_image_format_t format); - /// /// Allocates and initializes a texture and copies image-data into it. /// @@ -50,13 +40,6 @@ void kinc_g4_texture_init3d(kinc_g4_texture_t *texture, int width, int height, i /// The image which's data is copied into the texture void kinc_g4_texture_init_from_image(kinc_g4_texture_t *texture, kinc_image_t *image); -/// -/// Allocates and initializes a texture and copies image-data into it. -/// -/// The texture to initialize -/// The image which's data is copied into the texture -void kinc_g4_texture_init_from_image3d(kinc_g4_texture_t *texture, kinc_image_t *image); - /// /// Deallocates and destroys a texture. /// @@ -67,11 +50,6 @@ unsigned char *kinc_g4_texture_lock(kinc_g4_texture_t *texture); void kinc_g4_texture_unlock(kinc_g4_texture_t *texture); -/// -/// Clears parts of a texture to a color. -/// -void kinc_g4_texture_clear(kinc_g4_texture_t *texture, int x, int y, int z, int width, int height, int depth, unsigned color); - /// /// Generates the mipmap-chain for a texture. /// diff --git a/armorcore/sources/ts/g4.ts b/armorcore/sources/ts/g4.ts index d44c9682..1fd383b6 100644 --- a/armorcore/sources/ts/g4.ts +++ b/armorcore/sources/ts/g4.ts @@ -417,15 +417,6 @@ function image_from_bytes(buffer: buffer_t, width: i32, height: i32, format: tex return image; } -function image_from_bytes_3d(buffer: buffer_t, width: i32, height: i32, depth: i32, format: tex_format_t = tex_format_t.RGBA32): image_t { - let readable: bool = true; - let image: image_t = _image_create(null); - image.format = format; - image.texture_ = iron_g4_create_texture_from_bytes3d(buffer, width, height, depth, image_get_tex_format(format), readable); - _image_set_size_from_texture(image, image.texture_); - return image; -} - function image_from_encoded_bytes(buffer: buffer_t, format: string, readable: bool = false): image_t { let image: image_t = _image_create(null); image.texture_ = iron_g4_create_texture_from_encoded_bytes(buffer, format, readable); @@ -441,14 +432,6 @@ function image_create(width: i32, height: i32, format: tex_format_t = tex_format return image; } -function image_create_3d(width: i32, height: i32, depth: i32, format: tex_format_t = tex_format_t.RGBA32): image_t { - let image: image_t = _image_create(null); - image.format = format; - image.texture_ = iron_g4_create_texture3d(width, height, depth, image_get_tex_format(format)); - _image_set_size_from_texture(image, image.texture_); - return image; -} - function image_create_render_target(width: i32, height: i32, format: tex_format_t = tex_format_t.RGBA32, depth_format: depth_format_t = depth_format_t.NO_DEPTH): image_t { let image: image_t = _image_create(null); image.format = format; @@ -528,10 +511,6 @@ function image_set_depth_from(raw: image_t, image: image_t) { iron_g4_set_depth_from(raw.render_target_, image.render_target_); } -function image_clear(raw: image_t, x: i32, y: i32, z: i32, width: i32, height: i32, depth: i32, color: color_t) { - iron_g4_clear_texture(raw.texture_, x, y, z, width, height, depth, color); -} - declare type image_t = { texture_?: any; render_target_?: any; diff --git a/armorcore/sources/ts/iron.ts b/armorcore/sources/ts/iron.ts index 8899e02f..a0528d69 100644 --- a/armorcore/sources/ts/iron.ts +++ b/armorcore/sources/ts/iron.ts @@ -284,15 +284,12 @@ declare function iron_read_storage(name: string): buffer_t; declare function iron_g4_create_render_target(width: i32, height: i32, format: i32, depth_buffer_bits: i32, stencil_buffer_bits: i32): any; declare function iron_g4_create_texture(width: i32, height: i32, format: i32): any; -declare function iron_g4_create_texture3d(width: i32, height: i32, depth: i32, format: i32): any; declare function iron_g4_create_texture_from_bytes(data: buffer_t, width: i32, height: i32, format: i32, readable: bool): any; -declare function iron_g4_create_texture_from_bytes3d(data: buffer_t, width: i32, height: i32, depth: i32, format: i32, readable: bool): any; declare function iron_g4_create_texture_from_encoded_bytes(data: buffer_t, format: string, readable: bool): any; declare function iron_g4_get_texture_pixels(texture: any): buffer_t; declare function iron_g4_get_render_target_pixels(render_target: any, data: buffer_t): void; declare function iron_g4_lock_texture(texture: any, level: i32): buffer_t; declare function iron_g4_unlock_texture(texture: any): void; -declare function iron_g4_clear_texture(target: any, x: i32, y: i32, z: i32, width: i32, height: i32, depth: i32, color: i32): void; declare function iron_g4_generate_texture_mipmaps(texture: any, levels: i32): void; declare function iron_g4_generate_render_target_mipmaps(render_target: any, levels: i32): void; declare function iron_g4_set_mipmaps(texture: any, mipmaps: image_t[]): void; diff --git a/armorcore/sources/ts/scene.ts b/armorcore/sources/ts/scene.ts index 4455a7db..6b348dc3 100644 --- a/armorcore/sources/ts/scene.ts +++ b/armorcore/sources/ts/scene.ts @@ -480,17 +480,8 @@ function scene_load_embedded_data(datas: string[]) { } function scene_embed_data(file: string) { - if (ends_with(file, ".raw")) { - let b: buffer_t = data_get_blob(file); - // Raw 3D texture bytes - let w: i32 = math_floor(math_pow(b.length, 1 / 3)) + 1; - let image: image_t = image_from_bytes_3d(b, w, w, w, tex_format_t.R8); - map_set(scene_embedded, file, image); - } - else { - let image: image_t = data_get_image(file); - map_set(scene_embedded, file, image); - } + let image: image_t = data_get_image(file); + map_set(scene_embedded, file, image); } type scene_t = {