base: fix warnings

This commit is contained in:
luboslenco
2026-05-22 07:57:44 +02:00
parent 6698870b46
commit eeeae64a36
3 changed files with 59 additions and 34 deletions
+12 -1
View File
@@ -130,7 +130,18 @@ if (graphics == "metal" || (graphics == "vulkan" && platform != "android")) {
if (flags.with_kong) {
project.add_define("WITH_KONG");
project.add_cfiles("sources/kong/*.c");
project.add_cfiles("sources/kong/dir.c");
project.add_cfiles("sources/kong/kong.c");
project.add_cfiles("sources/kong/kong_cstyle.c");
project.add_cfiles("sources/kong/stb_ds.c");
project.add_cfiles("sources/kong/kong_spirv.c");
project.add_cfiles("sources/kong/kong_wgsl.c");
if (platform == "windows") {
project.add_cfiles("sources/kong/kong_hlsl.c");
}
if (platform == "macos" || platform == "ios") {
project.add_cfiles("sources/kong/kong_metal.c");
}
}
if (flags.with_plugins) {
+27 -17
View File
@@ -6033,10 +6033,12 @@ void indent(char *code, size_t *offset, int indentation) {
*offset += sprintf(&code[*offset], "%s", str);
}
#ifdef IRON_METAL
extern size_t vertex_inputs_size;
extern size_t fragment_inputs_size;
extern size_t vertex_functions_size;
extern size_t fragment_functions_size;
#endif
uint64_t _next_variable_id;
size_t _allocated_globals_size;
@@ -6090,33 +6092,41 @@ void gpu_create_shaders_from_kong(char *kong, char **vs, char **fs, int *vs_size
types_init();
functions_init();
_next_variable_id = next_variable_id;
_allocated_globals_size = allocated_globals_size;
_next_function_index = next_function_index;
_globals_size = globals_size;
_names_index = names_index;
_sets_count = sets_count;
_next_type_index = next_type_index;
_next_variable_id = next_variable_id;
_allocated_globals_size = allocated_globals_size;
_next_function_index = next_function_index;
_globals_size = globals_size;
_names_index = names_index;
_sets_count = sets_count;
_next_type_index = next_type_index;
#ifdef IRON_METAL
_vertex_inputs_size = vertex_inputs_size;
_fragment_inputs_size = fragment_inputs_size;
_vertex_functions_size = vertex_functions_size;
_fragment_functions_size = fragment_functions_size;
_hash = _clone_hash(hash);
_expression_index = expression_index;
_statement_index = statement_index;
#endif
_hash = _clone_hash(hash);
_expression_index = expression_index;
_statement_index = statement_index;
}
else {
next_variable_id = _next_variable_id;
allocated_globals_size = _allocated_globals_size;
next_function_index = _next_function_index;
globals_size = _globals_size;
names_index = _names_index;
sets_count = _sets_count;
next_type_index = _next_type_index;
next_variable_id = _next_variable_id;
allocated_globals_size = _allocated_globals_size;
next_function_index = _next_function_index;
globals_size = _globals_size;
names_index = _names_index;
sets_count = _sets_count;
next_type_index = _next_type_index;
#ifdef IRON_METAL
vertex_inputs_size = _vertex_inputs_size;
fragment_inputs_size = _fragment_inputs_size;
vertex_functions_size = _vertex_functions_size;
fragment_functions_size = _fragment_functions_size;
#endif
shfree(hash);
hash = _clone_hash(_hash);
expression_index = _expression_index;
+20 -16
View File
@@ -1,12 +1,12 @@
// kong wrapper
#include "../../sources/kong/kong.h"
#include "iron_string.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../sources/kong/kong.h"
#ifdef _WIN32
#include <D3Dcompiler.h>
@@ -23,8 +23,8 @@ char *hlsl_to_bin(char *source, char *shader_type, char *to) {
ID3DBlob *error_message;
ID3DBlob *shader_buffer;
UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL3;
HRESULT hr = D3DCompile(source, strlen(source) + 1, NULL, NULL, NULL, "main", type, flags, 0, &shader_buffer, &error_message);
UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL3;
HRESULT hr = D3DCompile(source, strlen(source) + 1, NULL, NULL, NULL, "main", type, flags, 0, &shader_buffer, &error_message);
if (hr != S_OK) {
printf("%s\n", (char *)error_message->lpVtbl->GetBufferPointer(error_message));
return NULL;
@@ -48,10 +48,12 @@ extern type_id next_type_index;
void hlsl_export2(char **vs, char **fs, api_kind d3d, bool debug);
void spirv_export2(char **vs, char **fs, int *vs_size, int *fs_size, bool debug);
void wgsl_export2(char **vs, char **fs);
extern size_t vertex_inputs_size;
extern size_t fragment_inputs_size;
extern size_t vertex_functions_size;
extern size_t fragment_functions_size;
#ifdef IRON_METAL
extern size_t vertex_inputs_size;
extern size_t fragment_inputs_size;
extern size_t vertex_functions_size;
extern size_t fragment_functions_size;
#endif
void kong_compile(char *shader_lang, const char *from, const char *to) {
FILE *fp = fopen(from, "rb");
@@ -63,17 +65,19 @@ void kong_compile(char *shader_lang, const char *from, const char *to) {
fread(data, size, 1, fp);
fclose(fp);
next_variable_id = 1;
allocated_globals_size = 0;
next_function_index = 0;
globals_size = 0;
names_index = 1;
sets_count = 0;
next_type_index = 0;
next_variable_id = 1;
allocated_globals_size = 0;
next_function_index = 0;
globals_size = 0;
names_index = 1;
sets_count = 0;
next_type_index = 0;
#ifdef IRON_METAL
vertex_inputs_size = 0;
fragment_inputs_size = 0;
vertex_functions_size = 0;
fragment_functions_size = 0;
#endif
names_init();
types_init();
functions_init();
@@ -97,7 +101,7 @@ void kong_compile(char *shader_lang, const char *from, const char *to) {
to_[strlen(to_) - 4] = '\0';
strcat(to_, "vert.wgsl");
FILE *fp = fopen(to_, "wb");
FILE *fp = fopen(to_, "wb");
fwrite(vs, 1, strlen(vs), fp);
fclose(fp);
@@ -105,7 +109,7 @@ void kong_compile(char *shader_lang, const char *from, const char *to) {
to_[strlen(to_) - 4] = '\0';
strcat(to_, "frag.wgsl");
fp = fopen(to_, "wb");
fp = fopen(to_, "wb");
fwrite(fs, 1, strlen(fs), fp);
fclose(fp);