From 8384b3ae67330aeaab6ae509faf89555b54cc480 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 24 Aug 2025 10:30:41 +0200 Subject: [PATCH] Add gpu_device_name --- base/sources/backends/direct3d12_gpu.c | 5 +++++ base/sources/backends/metal_gpu.m | 4 ++++ base/sources/backends/vulkan_gpu.c | 6 ++++++ base/sources/iron_gpu.h | 1 + base/sources/ts/iron/iron.ts | 1 + base/sources/ts/ui_menubar.ts | 30 +------------------------- 6 files changed, 18 insertions(+), 29 deletions(-) diff --git a/base/sources/backends/direct3d12_gpu.c b/base/sources/backends/direct3d12_gpu.c index 9d202ce4..21349afb 100644 --- a/base/sources/backends/direct3d12_gpu.c +++ b/base/sources/backends/direct3d12_gpu.c @@ -46,6 +46,7 @@ static ID3D12Resource *upload_buffer = NULL; static int upload_buffer_size = 0; static ID3D12Resource *resources_to_destroy[256]; static int resources_to_destroy_count = 0; +static char device_name[256]; static D3D12_BLEND convert_blend_factor(gpu_blending_factor_t factor) { switch (factor) { @@ -1114,6 +1115,10 @@ void gpu_buffer_destroy_internal(gpu_buffer_t *buffer) { buffer->impl.buffer = NULL; } +char *gpu_device_name() { + return device_name; +} + typedef struct inst { iron_matrix4x4_t m; int i; diff --git a/base/sources/backends/metal_gpu.m b/base/sources/backends/metal_gpu.m index 8d10a7f4..e6d3aa26 100644 --- a/base/sources/backends/metal_gpu.m +++ b/base/sources/backends/metal_gpu.m @@ -643,6 +643,10 @@ void *gpu_index_buffer_lock(gpu_buffer_t *buffer) { void gpu_index_buffer_unlock(gpu_buffer_t *buffer) { } +char *gpu_device_name() { + return ""; +} + typedef struct inst { iron_matrix4x4_t m; int i; diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 01544caa..df25710a 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -42,6 +42,7 @@ static VkCommandBuffer command_buffer; static VkBuffer buffers_to_destroy[256]; static VkDeviceMemory buffer_memories_to_destroy[256]; static int buffers_to_destroy_count = 0; +static char device_name[256]; static VkInstance instance; static VkPhysicalDevice gpu; @@ -753,6 +754,7 @@ void gpu_init_internal(int depth_buffer_bits, bool vsync) { VkPhysicalDeviceProperties properties; vkGetPhysicalDeviceProperties(gpu, &properties); iron_log("Chosen Vulkan device: %s", properties.deviceName); + strcpy(device_name, properties.deviceName); is_amd = properties.vendorID == 0x1002; free(physical_devices); } @@ -1872,6 +1874,10 @@ void gpu_buffer_destroy_internal(gpu_buffer_t *buffer) { vkDestroyBuffer(device, buffer->impl.buf, NULL); } +char *gpu_device_name() { + return device_name; +} + typedef struct inst { iron_matrix4x4_t m; int i; diff --git a/base/sources/iron_gpu.h b/base/sources/iron_gpu.h index 0ada8189..3a6acc01 100644 --- a/base/sources/iron_gpu.h +++ b/base/sources/iron_gpu.h @@ -209,6 +209,7 @@ void gpu_set_constant_buffer(gpu_buffer_t *buffer, int offset, size_t size); void gpu_get_render_target_pixels(gpu_texture_t *render_target, uint8_t *data); void gpu_set_texture(int unit, gpu_texture_t *texture); void gpu_use_linear_sampling(bool b); +char *gpu_device_name(); bool gpu_raytrace_supported(void); void gpu_raytrace_pipeline_init(gpu_raytrace_pipeline_t *pipeline, void *ray_shader, int ray_shader_size, gpu_buffer_t *constant_buffer); diff --git a/base/sources/ts/iron/iron.ts b/base/sources/ts/iron/iron.ts index c0ac500d..cf55fc36 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -249,6 +249,7 @@ declare function gpu_set_floats(location: i32, values: f32_array_t): void; declare function gpu_set_matrix4(location: i32, matrix: mat4_t): void; declare function gpu_set_matrix3(location: i32, matrix: mat3_t): void; declare function gpu_use_linear_sampling(b: bool): void; +declare function gpu_device_name(): string; declare function iron_time(): f32; declare function iron_window_width(): i32; diff --git a/base/sources/ts/ui_menubar.ts b/base/sources/ts/ui_menubar.ts index 0c5f8a23..cc3b1999 100644 --- a/base/sources/ts/ui_menubar.ts +++ b/base/sources/ts/ui_menubar.ts @@ -674,36 +674,8 @@ function ui_menubar_draw_category_items() { let msg: string = manifest_title + ".org - v" + manifest_version + " (" + config_get_date() + ") - " + config_get_sha() + "\n"; msg += iron_system_id() + " - " + strings_graphics_api(); - ///if arm_windows - let save: string; - if (path_is_protected()) { - save = iron_internal_save_path(); - } - else { - save = path_data(); - } - save += path_sep + "tmp.txt"; - iron_sys_command("wmic path win32_VideoController get name > \"" + save + "\""); - let blob: buffer_t = iron_load_blob(save); - let u8: u8_array_t = blob; - let gpu_raw: string = ""; - for (let i: i32 = 0; i < math_floor(u8.length / 2); ++i) { - let c: string = string_from_char_code(u8[i * 2]); - gpu_raw += c; - } - - let gpus: string[] = string_split(gpu_raw, "\n"); - array_splice(gpus, 1, gpus.length - 2); - let gpu: string = ""; - for (let i: i32 = 0; i < gpus.length; ++i) { - let g: string = gpus[i]; - gpu += trim_end(g) + ", "; - } - gpu = substring(gpu, 0, gpu.length - 2); + let gpu: string = gpu_device_name(); msg += "\n" + gpu; - ///else - // { lshw -C display } - ///end _ui_menu_render_msg = msg;