From 5841bfbff25a671316b3dd7db522674d50968aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 11 Sep 2023 12:23:33 +0200 Subject: [PATCH] fwk: sync up --- demos/99-spot.c | 12 ++++++------ engine/bind/v4k.lua | 4 ++-- engine/joint/v4k.h | 32 +++++++++++++++++++++----------- engine/split/v4k_file.c | 17 ++++++++++++++--- engine/split/v4k_render.h | 15 +++++++-------- engine/v4k.c | 17 ++++++++++++++--- engine/v4k.h | 15 +++++++-------- tools/cook.ini | 2 +- 8 files changed, 72 insertions(+), 42 deletions(-) diff --git a/demos/99-spot.c b/demos/99-spot.c index f39d0c0..090fdca 100644 --- a/demos/99-spot.c +++ b/demos/99-spot.c @@ -20,12 +20,12 @@ // status: CUBE(1)+BLUR(1): ok // status: CUBE(1)+BLUR(0): ok // status: CUBE(?)+BLUR(?): no { -// 003.470s|!cannot find uniform 'shadowMap' in shader program 21 |shader_uniform|fwk_render.c:772 -// 001: 00007FF7AF6A3FDA callstack (C:\prj\thread\FWK\fwk_system.c:250) -// 002: 00007FF7AF8E7CBC shader_uniform (C:\prj\thread\FWK\fwk_render.c:772) -// 003: 00007FF7AF691C27 shader_int (C:\prj\thread\FWK\fwk_render.c:777) -// 004: 00007FF7AF8F54EF color_begin (C:\prj\thread\FWK\spot.c:525) -// 005: 00007FF7AF8F5BF7 main (C:\prj\thread\FWK\spot.c:607) +// 003.470s|!cannot find uniform 'shadowMap' in shader program 21 |shader_uniform|v4k_render.c:772 +// 001: 00007FF7AF6A3FDA callstack (C:\prj\thread\V4K\v4k_system.c:250) +// 002: 00007FF7AF8E7CBC shader_uniform (C:\prj\thread\V4K\v4k_render.c:772) +// 003: 00007FF7AF691C27 shader_int (C:\prj\thread\V4K\v4k_render.c:777) +// 004: 00007FF7AF8F54EF color_begin (C:\prj\thread\V4K\spot.c:525) +// 005: 00007FF7AF8F5BF7 main (C:\prj\thread\V4K\spot.c:607) // } #ifndef VSMCUBE diff --git a/engine/bind/v4k.lua b/engine/bind/v4k.lua index 02bc5fb..f97f94d 100644 --- a/engine/bind/v4k.lua +++ b/engine/bind/v4k.lua @@ -2360,7 +2360,7 @@ int texture_width; void shader_colormap(const char *name, colormap_t cm); unsigned shader_get_active(); void shader_destroy(unsigned shader); -enum BUFFER_ACCESS_MODE { +enum BUFFER_MODE { BUFFER_READ, BUFFER_WRITE, BUFFER_READ_WRITE @@ -2371,7 +2371,7 @@ BUFFER_READ_WRITE void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access); void image_write_barrier(); void write_barrier(); -enum SSBO_USAGE_MODE { +enum SSBO_USAGE { STATIC_DRAW, STATIC_READ, STATIC_COPY, diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 5966866..0b35d4b 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -16491,14 +16491,13 @@ API void shader_colormap(const char *name, colormap_t cm); API unsigned shader_get_active(); API void shader_destroy(unsigned shader); -enum BUFFER_ACCESS_MODE { +// compute shaders +enum BUFFER_MODE { BUFFER_READ, BUFFER_WRITE, BUFFER_READ_WRITE }; -// compute shaders - /// Loads the compute shader and compiles a GL program. /// return: GL program, 0 if failed. /// cs: shader source code @@ -16517,7 +16516,7 @@ API void compute_dispatch(unsigned wx, unsigned wy, unsigned wz); /// level: texture level access (MIP0, MIP1, ...) /// layer: bind layer /// access: texture access policy -/// see: ACCESS_MODE +/// see: BUFFER_MODE API void shader_image(texture_t t, unsigned unit, unsigned level, int layer, unsigned access); /// Binds a texture to the program @@ -16528,7 +16527,7 @@ API void shader_image(texture_t t, unsigned unit, unsigned level, int layer, uns /// layer: bind layer /// texel_type: image texel format (RGBA8, RGBA32F, ...) /// access: texture access policy -/// see: ACCESS_MODE +/// see: BUFFER_MODE API void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access); // gpu memory barriers @@ -16544,7 +16543,7 @@ API void write_barrier(); /// `DRAW` favors CPU->GPU operations. /// `READ` favors GPU->CPU operations. /// `COPY` favors CPU->GPU->CPU operations. -enum SSBO_USAGE_MODE { +enum SSBO_USAGE { STATIC_DRAW, STATIC_READ, STATIC_COPY, @@ -16569,7 +16568,7 @@ enum SSBO_ACCESS { /// data: optional pointer to data to upload /// len: buffer size, must not be 0 /// usage: buffer usage policy -/// see: USAGE_MODE +/// see: SSBO_USAGE API unsigned ssbo_create(const void *data, int len, unsigned usage); /// Destroys an SSBO resource @@ -16591,7 +16590,7 @@ API void ssbo_bind(unsigned ssbo, unsigned unit); /// !!! Make sure to `ssbo_unmap` the buffer once done working with it. /// access: buffer access policy /// return: pointer to physical memory of the buffer -/// see: ACCESS_MODE +/// see: SSBO_ACCESS API void *ssbo_map(unsigned access); /// Unmaps an SSBO resource @@ -333729,13 +333728,15 @@ void vfs_reload() { // mount virtual filesystems later (mounting order matters: low -> to -> high priority) #if defined(EMSCRIPTEN) + vfs_mount("index.zip"); +#else + /* // old way for( int i = 0; i < JOBS_MAX; ++i) { if( vfs_mount(va(".art[%02x].zip", i)) ) continue; if( vfs_mount(va("%s[%02x].zip", app, i)) ) continue; if( vfs_mount(va("%s%02x.zip", app, i)) ) continue; - //if( vfs_mount(va("%s.%02x", app, i)) ) continue; - } -#else + // if( vfs_mount(va("%s.%02x", app, i)) ) continue; + } */ // faster way for( const char **file = file_list("./","*.zip"); *file; ++file) vfs_mount(*file); #endif @@ -334016,6 +334017,15 @@ if( found && *found == 0 ) { last_size = size; } + // yet another last resort: redirect vfs_load() calls to file_load() + // (for environments without tools or cooked assets) + if(!ptr) { + static bool have_tools; do_once have_tools = file_exist(COOK_INI); + if( !have_tools ) { + ptr = file_load(pathfile, size_out); + } + } + if(!ptr) { PRINTF("Loading %s (not found)\n", pathfile); } diff --git a/engine/split/v4k_file.c b/engine/split/v4k_file.c index 49be99b..d93a935 100644 --- a/engine/split/v4k_file.c +++ b/engine/split/v4k_file.c @@ -516,13 +516,15 @@ void vfs_reload() { // mount virtual filesystems later (mounting order matters: low -> to -> high priority) #if defined(EMSCRIPTEN) + vfs_mount("index.zip"); +#else + /* // old way for( int i = 0; i < JOBS_MAX; ++i) { if( vfs_mount(va(".art[%02x].zip", i)) ) continue; if( vfs_mount(va("%s[%02x].zip", app, i)) ) continue; if( vfs_mount(va("%s%02x.zip", app, i)) ) continue; - //if( vfs_mount(va("%s.%02x", app, i)) ) continue; - } -#else + // if( vfs_mount(va("%s.%02x", app, i)) ) continue; + } */ // faster way for( const char **file = file_list("./","*.zip"); *file; ++file) vfs_mount(*file); #endif @@ -803,6 +805,15 @@ if( found && *found == 0 ) { last_size = size; } + // yet another last resort: redirect vfs_load() calls to file_load() + // (for environments without tools or cooked assets) + if(!ptr) { + static bool have_tools; do_once have_tools = file_exist(COOK_INI); + if( !have_tools ) { + ptr = file_load(pathfile, size_out); + } + } + if(!ptr) { PRINTF("Loading %s (not found)\n", pathfile); } diff --git a/engine/split/v4k_render.h b/engine/split/v4k_render.h index 5cccc91..e627cd2 100644 --- a/engine/split/v4k_render.h +++ b/engine/split/v4k_render.h @@ -335,14 +335,13 @@ API void shader_colormap(const char *name, colormap_t cm); API unsigned shader_get_active(); API void shader_destroy(unsigned shader); -enum BUFFER_ACCESS_MODE { +// compute shaders +enum BUFFER_MODE { BUFFER_READ, BUFFER_WRITE, BUFFER_READ_WRITE }; -// compute shaders - /// Loads the compute shader and compiles a GL program. /// return: GL program, 0 if failed. /// cs: shader source code @@ -361,7 +360,7 @@ API void compute_dispatch(unsigned wx, unsigned wy, unsigned wz); /// level: texture level access (MIP0, MIP1, ...) /// layer: bind layer /// access: texture access policy -/// see: ACCESS_MODE +/// see: BUFFER_MODE API void shader_image(texture_t t, unsigned unit, unsigned level, int layer, unsigned access); /// Binds a texture to the program @@ -372,7 +371,7 @@ API void shader_image(texture_t t, unsigned unit, unsigned level, int layer, uns /// layer: bind layer /// texel_type: image texel format (RGBA8, RGBA32F, ...) /// access: texture access policy -/// see: ACCESS_MODE +/// see: BUFFER_MODE API void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access); // gpu memory barriers @@ -388,7 +387,7 @@ API void write_barrier(); /// `DRAW` favors CPU->GPU operations. /// `READ` favors GPU->CPU operations. /// `COPY` favors CPU->GPU->CPU operations. -enum SSBO_USAGE_MODE { +enum SSBO_USAGE { STATIC_DRAW, STATIC_READ, STATIC_COPY, @@ -413,7 +412,7 @@ enum SSBO_ACCESS { /// data: optional pointer to data to upload /// len: buffer size, must not be 0 /// usage: buffer usage policy -/// see: USAGE_MODE +/// see: SSBO_USAGE API unsigned ssbo_create(const void *data, int len, unsigned usage); /// Destroys an SSBO resource @@ -435,7 +434,7 @@ API void ssbo_bind(unsigned ssbo, unsigned unit); /// !!! Make sure to `ssbo_unmap` the buffer once done working with it. /// access: buffer access policy /// return: pointer to physical memory of the buffer -/// see: ACCESS_MODE +/// see: SSBO_ACCESS API void *ssbo_map(unsigned access); /// Unmaps an SSBO resource diff --git a/engine/v4k.c b/engine/v4k.c index 8ffc898..2d73a23 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -4638,13 +4638,15 @@ void vfs_reload() { // mount virtual filesystems later (mounting order matters: low -> to -> high priority) #if defined(EMSCRIPTEN) + vfs_mount("index.zip"); +#else + /* // old way for( int i = 0; i < JOBS_MAX; ++i) { if( vfs_mount(va(".art[%02x].zip", i)) ) continue; if( vfs_mount(va("%s[%02x].zip", app, i)) ) continue; if( vfs_mount(va("%s%02x.zip", app, i)) ) continue; - //if( vfs_mount(va("%s.%02x", app, i)) ) continue; - } -#else + // if( vfs_mount(va("%s.%02x", app, i)) ) continue; + } */ // faster way for( const char **file = file_list("./","*.zip"); *file; ++file) vfs_mount(*file); #endif @@ -4925,6 +4927,15 @@ if( found && *found == 0 ) { last_size = size; } + // yet another last resort: redirect vfs_load() calls to file_load() + // (for environments without tools or cooked assets) + if(!ptr) { + static bool have_tools; do_once have_tools = file_exist(COOK_INI); + if( !have_tools ) { + ptr = file_load(pathfile, size_out); + } + } + if(!ptr) { PRINTF("Loading %s (not found)\n", pathfile); } diff --git a/engine/v4k.h b/engine/v4k.h index 681a4fc..1265529 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -2574,14 +2574,13 @@ API void shader_colormap(const char *name, colormap_t cm); API unsigned shader_get_active(); API void shader_destroy(unsigned shader); -enum BUFFER_ACCESS_MODE { +// compute shaders +enum BUFFER_MODE { BUFFER_READ, BUFFER_WRITE, BUFFER_READ_WRITE }; -// compute shaders - /// Loads the compute shader and compiles a GL program. /// return: GL program, 0 if failed. /// cs: shader source code @@ -2600,7 +2599,7 @@ API void compute_dispatch(unsigned wx, unsigned wy, unsigned wz); /// level: texture level access (MIP0, MIP1, ...) /// layer: bind layer /// access: texture access policy -/// see: ACCESS_MODE +/// see: BUFFER_MODE API void shader_image(texture_t t, unsigned unit, unsigned level, int layer, unsigned access); /// Binds a texture to the program @@ -2611,7 +2610,7 @@ API void shader_image(texture_t t, unsigned unit, unsigned level, int layer, uns /// layer: bind layer /// texel_type: image texel format (RGBA8, RGBA32F, ...) /// access: texture access policy -/// see: ACCESS_MODE +/// see: BUFFER_MODE API void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access); // gpu memory barriers @@ -2627,7 +2626,7 @@ API void write_barrier(); /// `DRAW` favors CPU->GPU operations. /// `READ` favors GPU->CPU operations. /// `COPY` favors CPU->GPU->CPU operations. -enum SSBO_USAGE_MODE { +enum SSBO_USAGE { STATIC_DRAW, STATIC_READ, STATIC_COPY, @@ -2652,7 +2651,7 @@ enum SSBO_ACCESS { /// data: optional pointer to data to upload /// len: buffer size, must not be 0 /// usage: buffer usage policy -/// see: USAGE_MODE +/// see: SSBO_USAGE API unsigned ssbo_create(const void *data, int len, unsigned usage); /// Destroys an SSBO resource @@ -2674,7 +2673,7 @@ API void ssbo_bind(unsigned ssbo, unsigned unit); /// !!! Make sure to `ssbo_unmap` the buffer once done working with it. /// access: buffer access policy /// return: pointer to physical memory of the buffer -/// see: ACCESS_MODE +/// see: SSBO_ACCESS API void *ssbo_map(unsigned access); /// Unmaps an SSBO resource diff --git a/tools/cook.ini b/tools/cook.ini index 969fb7d..501682a 100644 --- a/tools/cook.ini +++ b/tools/cook.ini @@ -1,4 +1,4 @@ -; this is where you specify and configure the FWK pipeline. +; this is where you specify and configure the V4K pipeline. ; tweak the pipeline and add new importers just by editing this file. ; there is no flow control in this script file: lines are parsed and evaluated, from top to bottom.