From 4fdd10119dc518b5771fce2874c5e7e3eae7a8fe Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 9 Feb 2025 18:57:40 +0100 Subject: [PATCH] Cleanup --- .../g4ong5/kinc/backend/graphics4/G4.c.h | 40 ------------------- armorcore/sources/iron.h | 17 +------- armorcore/sources/kinc/graphics4/graphics.h | 33 --------------- armorcore/sources/kinc/image.h | 27 +------------ armorcore/sources/ts/g4.ts | 12 ------ armorcore/sources/ts/iron.ts | 2 - 6 files changed, 4 insertions(+), 127 deletions(-) diff --git a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h index ecfc8d91..a4568e53 100644 --- a/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h +++ b/armorcore/sources/backends/g4ong5/kinc/backend/graphics4/G4.c.h @@ -554,10 +554,6 @@ void kinc_g4_set_texture_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture } } -void kinc_g4_set_texture3d_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing) { - kinc_g4_set_texture_addressing(unit, dir, addressing); -} - void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter) { for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { @@ -566,10 +562,6 @@ void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t texunit, ki } } -void kinc_g4_set_texture3d_magnification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter) { - kinc_g4_set_texture_magnification_filter(texunit, filter); -} - void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter) { for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { @@ -578,10 +570,6 @@ void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t texunit, kin } } -void kinc_g4_set_texture3d_minification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter) { - kinc_g4_set_texture_minification_filter(texunit, filter); -} - void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t texunit, kinc_g4_mipmap_filter_t filter) { for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { if (texunit.stages[i] >= 0) { @@ -590,10 +578,6 @@ void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t texunit, kinc_g4_m } } -void kinc_g4_set_texture3d_mipmap_filter(kinc_g4_texture_unit_t texunit, kinc_g4_mipmap_filter_t filter) { - kinc_g4_set_texture_mipmap_filter(texunit, filter); -} - void kinc_g4_set_texture_compare_mode(kinc_g4_texture_unit_t unit, bool enabled) { for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { if (unit.stages[i] >= 0) { @@ -718,30 +702,6 @@ void kinc_g4_set_texture(kinc_g4_texture_unit_t unit, kinc_g4_texture_t *texture kinc_g5_command_list_set_texture(&commandList, g5_unit, &texture->impl._texture); } -void kinc_g4_set_image_texture(kinc_g4_texture_unit_t unit, kinc_g4_texture_t *texture) { - assert(KINC_G4_SHADER_TYPE_COUNT == KINC_G5_SHADER_TYPE_COUNT); - kinc_g5_texture_unit_t g5_unit; - memcpy(&g5_unit.stages[0], &unit.stages[0], KINC_G5_SHADER_TYPE_COUNT * sizeof(int)); - - bool found = false; - for (int i = 0; i < current_state.texture_count; ++i) { - if (kinc_g5_texture_unit_equals(¤t_state.texture_units[i], &g5_unit)) { - current_state.textures[i] = &texture->impl._texture; - current_state.texture_units[i] = g5_unit; - found = true; - break; - } - } - if (!found) { - assert(current_state.texture_count < MAX_TEXTURES); - current_state.textures[current_state.texture_count] = &texture->impl._texture; - current_state.texture_units[current_state.texture_count] = g5_unit; - current_state.texture_count += 1; - } - - kinc_g5_command_list_set_image_texture(&commandList, g5_unit, &texture->impl._texture); -} - int kinc_g4_max_bound_textures(void) { return kinc_g5_max_bound_textures(); } diff --git a/armorcore/sources/iron.h b/armorcore/sources/iron.h index 5b32f43e..79befcaa 100644 --- a/armorcore/sources/iron.h +++ b/armorcore/sources/iron.h @@ -1700,10 +1700,6 @@ void iron_g4_set_texture_depth(kinc_g4_texture_unit_t *unit, kinc_g4_render_targ kinc_g4_render_target_use_depth_as_texture(render_target, *unit); } -void iron_g4_set_image_texture(kinc_g4_texture_unit_t *unit, kinc_g4_texture_t *texture) { - kinc_g4_set_image_texture(*unit, texture); -} - void iron_g4_set_texture_parameters(kinc_g4_texture_unit_t *unit, i32 u_addr, i32 v_addr, i32 min_filter, i32 mag_filter, i32 mip_filter) { kinc_g4_set_texture_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_U, (kinc_g4_texture_addressing_t)u_addr); kinc_g4_set_texture_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_V, (kinc_g4_texture_addressing_t)v_addr); @@ -1712,15 +1708,6 @@ void iron_g4_set_texture_parameters(kinc_g4_texture_unit_t *unit, i32 u_addr, i3 kinc_g4_set_texture_mipmap_filter(*unit, (kinc_g4_mipmap_filter_t)mip_filter); } -void iron_g4_set_texture3d_parameters(kinc_g4_texture_unit_t *unit, i32 u_addr, i32 v_addr, i32 w_addr, i32 min_filter, i32 mag_filter, i32 mip_filter) { - kinc_g4_set_texture3d_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_U, (kinc_g4_texture_addressing_t)u_addr); - kinc_g4_set_texture3d_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_V, (kinc_g4_texture_addressing_t)v_addr); - kinc_g4_set_texture3d_addressing(*unit, KINC_G4_TEXTURE_DIRECTION_W, (kinc_g4_texture_addressing_t)w_addr); - kinc_g4_set_texture3d_minification_filter(*unit, (kinc_g4_texture_filter_t)min_filter); - kinc_g4_set_texture3d_magnification_filter(*unit, (kinc_g4_texture_filter_t)mag_filter); - kinc_g4_set_texture3d_mipmap_filter(*unit, (kinc_g4_mipmap_filter_t)mip_filter); -} - void iron_g4_set_bool(kinc_g4_constant_location_t *location, bool value) { kinc_g4_set_bool(*location, value != 0); } @@ -1979,7 +1966,7 @@ int _format_byte_size(kinc_image_format_t format) { buffer_t *iron_g4_get_texture_pixels(kinc_image_t *image) { uint8_t *data = kinc_image_get_pixels(image); - int byte_length = _format_byte_size(image->format) * image->width * image->height * image->depth; + int byte_length = _format_byte_size(image->format) * image->width * image->height; buffer_t *buffer = malloc(sizeof(buffer_t)); buffer->buffer = data; buffer->length = byte_length; @@ -2004,7 +1991,7 @@ void iron_g4_get_render_target_pixels(kinc_g4_render_target_t *rt, buffer_t *dat buffer_t *iron_g4_lock_texture(kinc_g4_texture_t *texture, i32 level) { uint8_t *tex = kinc_g4_texture_lock(texture); int stride = kinc_g4_texture_stride(texture); - int byte_length = stride * texture->tex_height * texture->tex_depth; + int byte_length = stride * texture->tex_height; buffer_t *buffer = malloc(sizeof(buffer_t)); buffer->buffer = tex; buffer->length = byte_length; diff --git a/armorcore/sources/kinc/graphics4/graphics.h b/armorcore/sources/kinc/graphics4/graphics.h index 49d8de24..36b0ea0c 100644 --- a/armorcore/sources/kinc/graphics4/graphics.h +++ b/armorcore/sources/kinc/graphics4/graphics.h @@ -171,8 +171,6 @@ void kinc_g4_draw_indexed_vertices_instanced_from_to(int instanceCount, int star void kinc_g4_set_texture_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing); -void kinc_g4_set_texture3d_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing); - /// /// Sets the pipeline for the next draw-call. The pipeline defines most rendering-state including the shaders to be used. /// @@ -299,13 +297,6 @@ void kinc_g4_set_matrix4(kinc_g4_constant_location_t location, kinc_matrix4x4_t /// The mode to set void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t unit, kinc_g4_texture_filter_t filter); -/// -/// Set the texture-sampling-mode for upscaled 3D-textures. -/// -/// The texture-unit to set the texture-sampling-mode for -/// The mode to set -void kinc_g4_set_texture3d_magnification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter); - /// /// Set the texture-sampling-mode for downscaled textures. /// @@ -313,13 +304,6 @@ void kinc_g4_set_texture3d_magnification_filter(kinc_g4_texture_unit_t texunit, /// The mode to set void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t unit, kinc_g4_texture_filter_t filter); -/// -/// Set the texture-sampling-mode for downscaled 3D-textures. -/// -/// The texture-unit to set the texture-sampling-mode for -/// The mode to set -void kinc_g4_set_texture3d_minification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter); - /// /// Sets the mipmap-sampling-mode which defines whether mipmaps are used at all and if so whether the two neighbouring mipmaps are linearly interpolated. /// @@ -327,14 +311,6 @@ void kinc_g4_set_texture3d_minification_filter(kinc_g4_texture_unit_t texunit, k /// The mode to set void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t unit, kinc_g4_mipmap_filter_t filter); -/// -/// Sets the mipmap-sampling-mode for a 3D-texture which defines whether mipmaps are used at all and if so whether the two neighbouring mipmaps are linearly -/// interpolated. -/// -/// The texture-unit to set the mipmap-sampling-mode for -/// The mode to set -void kinc_g4_set_texture3d_mipmap_filter(kinc_g4_texture_unit_t texunit, kinc_g4_mipmap_filter_t filter); - void kinc_g4_set_texture_compare_mode(kinc_g4_texture_unit_t unit, bool enabled); void kinc_g4_set_texture_compare_func(kinc_g4_texture_unit_t unit, kinc_g4_compare_mode_t mode); @@ -372,15 +348,6 @@ void kinc_g4_set_render_target_face(struct kinc_g4_render_target *texture, int f /// The texture to assign to the unit void kinc_g4_set_texture(kinc_g4_texture_unit_t unit, struct kinc_g4_texture *texture); -/// -/// Assigns a texture to a texture-unit for direct access via GLSL's texelFetch (as -/// opposed to GLSL's texture). The name of this functions is unfortunately based -/// on OpenGL's confusing terminology. -/// -/// The unit to assign this texture to -/// The texture to assign to the unit -void kinc_g4_set_image_texture(kinc_g4_texture_unit_t unit, struct kinc_g4_texture *texture); - /// /// Returns the currently used number of samples for hardware-antialiasing. /// diff --git a/armorcore/sources/kinc/image.h b/armorcore/sources/kinc/image.h index c6516b48..71ca3cd1 100644 --- a/armorcore/sources/kinc/image.h +++ b/armorcore/sources/kinc/image.h @@ -34,7 +34,7 @@ typedef enum kinc_image_format { } kinc_image_format_t; typedef struct kinc_image { - int width, height, depth; + int width, height; kinc_image_format_t format; unsigned internal_format; kinc_image_compression_t compression; @@ -55,12 +55,6 @@ typedef struct kinc_image_read_callbacks { /// The size that's occupied by the image in memory in bytes size_t kinc_image_init(kinc_image_t *image, void *memory, int width, int height, kinc_image_format_t format); -/// -/// Creates a 3D kinc_image in the provided memory. -/// -/// The size that's occupied by the image in memory in bytes -size_t kinc_image_init3d(kinc_image_t *image, void *memory, int width, int height, int depth, kinc_image_format_t format); - /// /// Peeks into an image file and figures out the size it will occupy in memory. /// @@ -105,11 +99,6 @@ size_t kinc_image_init_from_encoded_bytes(kinc_image_t *image, void *memory, voi /// void kinc_image_init_from_bytes(kinc_image_t *image, void *data, int width, int height, kinc_image_format_t format); -/// -/// Creates a 3D image from memory. -/// -void kinc_image_init_from_bytes3d(kinc_image_t *image, void *data, int width, int height, int depth, kinc_image_format_t format); - /// /// Destroys an image. This does not free the user-provided memory. /// @@ -562,27 +551,17 @@ int kinc_image_format_sizeof(kinc_image_format_t format) { //} size_t kinc_image_init(kinc_image_t *image, void *memory, int width, int height, kinc_image_format_t format) { - return kinc_image_init3d(image, memory, width, height, 1, format); -} - -size_t kinc_image_init3d(kinc_image_t *image, void *memory, int width, int height, int depth, kinc_image_format_t format) { image->width = width; image->height = height; - image->depth = depth; image->format = format; image->compression = KINC_IMAGE_COMPRESSION_NONE; image->data = memory; - return width * height * depth * kinc_image_format_sizeof(format); + return width * height * kinc_image_format_sizeof(format); } void kinc_image_init_from_bytes(kinc_image_t *image, void *data, int width, int height, kinc_image_format_t format) { - kinc_image_init_from_bytes3d(image, data, width, height, 1, format); -} - -void kinc_image_init_from_bytes3d(kinc_image_t *image, void *data, int width, int height, int depth, kinc_image_format_t format) { image->width = width; image->height = height; - image->depth = depth; image->format = format; image->compression = KINC_IMAGE_COMPRESSION_NONE; image->data = data; @@ -690,7 +669,6 @@ size_t kinc_image_init_from_file(kinc_image_t *image, void *memory, const char * kinc_file_reader_close(&reader); image->data = memory; image->data_size = dataSize; - image->depth = 1; return dataSize; } return 0; @@ -712,7 +690,6 @@ size_t kinc_image_init_from_encoded_bytes(kinc_image_t *image, void *memory, voi loadImage(callbacks, &image_memory, format, memory, &dataSize, &image->width, &image->height, &image->compression, &image->format, &image->internal_format); image->data = memory; image->data_size = dataSize; - image->depth = 1; return dataSize; } diff --git a/armorcore/sources/ts/g4.ts b/armorcore/sources/ts/g4.ts index 1fd383b6..9a993398 100644 --- a/armorcore/sources/ts/g4.ts +++ b/armorcore/sources/ts/g4.ts @@ -264,21 +264,10 @@ function g4_set_tex_depth(unit: kinc_tex_unit_t, tex: image_t) { iron_g4_set_texture_depth(unit, tex.render_target_); } -function g4_set_image_tex(unit: kinc_tex_unit_t, tex: image_t) { - if (tex == null) { - return; - } - iron_g4_set_image_texture(unit, tex.texture_); -} - function g4_set_tex_params(tex_unit: kinc_tex_unit_t, u_addressing: tex_addressing_t, v_addressing: tex_addressing_t, minification_filter: tex_filter_t, magnification_filter: tex_filter_t, mipmap_filter: mip_map_filter_t) { iron_g4_set_texture_parameters(tex_unit, u_addressing, v_addressing, minification_filter, magnification_filter, mipmap_filter); } -function g4_set_tex_3d_params(tex_unit: kinc_tex_unit_t, u_addressing: tex_addressing_t, v_addressing: tex_addressing_t, w_addressing: tex_addressing_t, minification_filter: tex_filter_t, magnification_filter: tex_filter_t, mipmap_filter: mip_map_filter_t) { - iron_g4_set_texture3d_parameters(tex_unit, u_addressing, v_addressing, w_addressing, minification_filter, magnification_filter, mipmap_filter); -} - function g4_set_pipeline(pipe: pipeline_t) { g4_pipeline_set(pipe); } @@ -519,7 +508,6 @@ declare type image_t = { pixels?: buffer_t; width?: i32; height?: i32; - depth?: i32; }; type pipeline_t = { diff --git a/armorcore/sources/ts/iron.ts b/armorcore/sources/ts/iron.ts index a0528d69..cc5b1315 100644 --- a/armorcore/sources/ts/iron.ts +++ b/armorcore/sources/ts/iron.ts @@ -248,9 +248,7 @@ declare function iron_g4_get_texture_unit(pipeline: any, name: string): any; declare function iron_g4_set_texture(stage: any, texture: any): void; declare function iron_g4_set_render_target(stage: any, render_target: any): void; declare function iron_g4_set_texture_depth(unit: any, texture: any): void; -declare function iron_g4_set_image_texture(stage: any, texture: any): void; declare function iron_g4_set_texture_parameters(tex_unit: any, u_addr: i32, v_addr: i32, min_filter: i32, mag_filter: i32, mip_filter: i32): void; -declare function iron_g4_set_texture3d_parameters(tex_unit: any, u_addr: i32, v_addr: i32, w_addr: i32, min_filter: i32, mag_filter: i32, mip_filter: i32): void; declare function iron_g4_set_bool(location: any, value: bool): void; declare function iron_g4_set_int(location: any, value: i32): void; declare function iron_g4_set_float(location: any, value: f32): void;