render: api adjustments

main
Dominik Madarász 2023-09-10 18:16:25 +02:00
parent b8422c6eb9
commit 495f9972e5
9 changed files with 64 additions and 31 deletions

View File

@ -43,6 +43,7 @@ if "%1"=="help" (
echo nov4k \ do not compile framework echo nov4k \ do not compile framework
echo demos ^| do compile demos echo demos ^| do compile demos
echo editor / do compile editor echo editor / do compile editor
echo run ^| run compiled .exe
echo vis ^> visualize invokation cmdline. echo vis ^> visualize invokation cmdline.
echo args ^> after `--` separator is found, pass all remaining arguments to compiler as-is echo args ^> after `--` separator is found, pass all remaining arguments to compiler as-is
echo. echo.
@ -359,6 +360,7 @@ set editor=no
set vis=no set vis=no
set proj=no set proj=no
set rc=0 set rc=0
set run=no
:parse_args :parse_args
if "%1"=="--" shift && goto parse_compiler_args if "%1"=="--" shift && goto parse_compiler_args
@ -386,6 +388,7 @@ set rc=0
if "%1"=="noeditor" set "editor=no" && goto loop if "%1"=="noeditor" set "editor=no" && goto loop
if "%1"=="hello" set "hello=yes" && goto loop if "%1"=="hello" set "hello=yes" && goto loop
if "%1"=="editor" set "editor=yes" && set "hello=no"&& goto loop if "%1"=="editor" set "editor=yes" && set "hello=no"&& goto loop
if "%1"=="run" set "run=yes" && goto loop
if "%1"=="all" set "v4k=yes" && set "demos=yes" && set "extras=yes" && set "editor=yes" && set "hello=yes" && goto loop if "%1"=="all" set "v4k=yes" && set "demos=yes" && set "extras=yes" && set "editor=yes" && set "hello=yes" && goto loop
if "%1"=="tcc" set "cc=%1" && goto loop if "%1"=="tcc" set "cc=%1" && goto loop
@ -623,6 +626,10 @@ if "!vis!"=="yes" echo !cc! !other! !import! !args!
!echo! !other! && !cc! !other! !import! !args! || set rc=1 !echo! !other! && !cc! !other! !import! !args! || set rc=1
) )
rem if "!run!"=="yes" (
rem !
rem )
rem PAUSE only if double-clicked from Windows explorer rem PAUSE only if double-clicked from Windows explorer
rem (((echo.%cmdcmdline%)|%WINDIR%\system32\find.exe /I "%~0")>nul)&&pause rem (((echo.%cmdcmdline%)|%WINDIR%\system32\find.exe /I "%~0")>nul)&&pause

View File

@ -10,7 +10,7 @@ int main() {
unsigned comp = compute(vfs_read("shaders/compute-test.glsl")); unsigned comp = compute(vfs_read("shaders/compute-test.glsl"));
texture_t tex = texture_create(TEX_WIDTH, TEX_WIDTH, 4, 0, TEXTURE_LINEAR|TEXTURE_FLOAT); texture_t tex = texture_create(TEX_WIDTH, TEX_WIDTH, 4, 0, TEXTURE_LINEAR|TEXTURE_FLOAT);
shader_bind(comp); shader_bind(comp);
shader_image(tex, 0, 0, 0, READ); shader_image(tex, 0, 0, 0, BUFFER_READ);
struct { struct {
float f; float f;

View File

@ -21,4 +21,4 @@ out vec4 fragColor;
void mainImage( out vec4 fragColor, in vec2 fragCoord ); void mainImage( out vec4 fragColor, in vec2 fragCoord );
void main() { void main() {
mainImage(fragColor, texCoord.xy); mainImage(fragColor, texCoord.xy);
} }

View File

@ -2360,10 +2360,10 @@ int texture_width;
void shader_colormap(const char *name, colormap_t cm); void shader_colormap(const char *name, colormap_t cm);
unsigned shader_get_active(); unsigned shader_get_active();
void shader_destroy(unsigned shader); void shader_destroy(unsigned shader);
enum ACCESS_MODE { enum BUFFER_ACCESS_MODE {
READ, BUFFER_READ,
WRITE, BUFFER_WRITE,
READ_WRITE BUFFER_READ_WRITE
}; };
unsigned compute(const char *cs); unsigned compute(const char *cs);
void compute_dispatch(unsigned wx, unsigned wy, unsigned wz); void compute_dispatch(unsigned wx, unsigned wy, unsigned wz);
@ -2371,7 +2371,7 @@ READ_WRITE
void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access); void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access);
void image_write_barrier(); void image_write_barrier();
void write_barrier(); void write_barrier();
enum USAGE_MODE { enum SSBO_USAGE_MODE {
STATIC_DRAW, STATIC_DRAW,
STATIC_READ, STATIC_READ,
STATIC_COPY, STATIC_COPY,
@ -2381,6 +2381,11 @@ DYNAMIC_COPY,
STREAM_DRAW, STREAM_DRAW,
STREAM_READ, STREAM_READ,
STREAM_COPY STREAM_COPY
};
enum SSBO_ACCESS {
SSBO_READ = BUFFER_READ,
SSBO_WRITE = BUFFER_WRITE,
SSBO_READ_WRITE = BUFFER_READ_WRITE
}; };
unsigned ssbo_create(const void *data, int len, unsigned usage); unsigned ssbo_create(const void *data, int len, unsigned usage);
void ssbo_destroy(unsigned ssbo); void ssbo_destroy(unsigned ssbo);

View File

@ -16490,13 +16490,14 @@ API void shader_colormap(const char *name, colormap_t cm);
API unsigned shader_get_active(); API unsigned shader_get_active();
API void shader_destroy(unsigned shader); API void shader_destroy(unsigned shader);
// compute shaders enum BUFFER_ACCESS_MODE {
enum ACCESS_MODE { BUFFER_READ,
READ, BUFFER_WRITE,
WRITE, BUFFER_READ_WRITE
READ_WRITE
}; };
// compute shaders
/// Loads the compute shader and compiles a GL program. /// Loads the compute shader and compiles a GL program.
/// return: GL program, 0 if failed. /// return: GL program, 0 if failed.
/// cs: shader source code /// cs: shader source code
@ -16542,7 +16543,7 @@ API void write_barrier();
/// `DRAW` favors CPU->GPU operations. /// `DRAW` favors CPU->GPU operations.
/// `READ` favors GPU->CPU operations. /// `READ` favors GPU->CPU operations.
/// `COPY` favors CPU->GPU->CPU operations. /// `COPY` favors CPU->GPU->CPU operations.
enum USAGE_MODE { enum SSBO_USAGE_MODE {
STATIC_DRAW, STATIC_DRAW,
STATIC_READ, STATIC_READ,
STATIC_COPY, STATIC_COPY,
@ -16556,6 +16557,12 @@ enum USAGE_MODE {
STREAM_COPY STREAM_COPY
}; };
enum SSBO_ACCESS {
SSBO_READ = BUFFER_READ,
SSBO_WRITE = BUFFER_WRITE,
SSBO_READ_WRITE = BUFFER_READ_WRITE
};
/// Create Shader Storage Buffer Object /// Create Shader Storage Buffer Object
/// !!! `data` can be NULL /// !!! `data` can be NULL
/// data: optional pointer to data to upload /// data: optional pointer to data to upload
@ -349016,8 +349023,8 @@ void window_hints(unsigned flags) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // osx glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // osx
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // osx, 2:#version150,3:330 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // osx, 2:#version150,3:330
#else #else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //osx glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //osx

View File

@ -335,13 +335,14 @@ API void shader_colormap(const char *name, colormap_t cm);
API unsigned shader_get_active(); API unsigned shader_get_active();
API void shader_destroy(unsigned shader); API void shader_destroy(unsigned shader);
// compute shaders enum BUFFER_ACCESS_MODE {
enum ACCESS_MODE { BUFFER_READ,
READ, BUFFER_WRITE,
WRITE, BUFFER_READ_WRITE
READ_WRITE
}; };
// compute shaders
/// Loads the compute shader and compiles a GL program. /// Loads the compute shader and compiles a GL program.
/// return: GL program, 0 if failed. /// return: GL program, 0 if failed.
/// cs: shader source code /// cs: shader source code
@ -387,7 +388,7 @@ API void write_barrier();
/// `DRAW` favors CPU->GPU operations. /// `DRAW` favors CPU->GPU operations.
/// `READ` favors GPU->CPU operations. /// `READ` favors GPU->CPU operations.
/// `COPY` favors CPU->GPU->CPU operations. /// `COPY` favors CPU->GPU->CPU operations.
enum USAGE_MODE { enum SSBO_USAGE_MODE {
STATIC_DRAW, STATIC_DRAW,
STATIC_READ, STATIC_READ,
STATIC_COPY, STATIC_COPY,
@ -401,6 +402,12 @@ enum USAGE_MODE {
STREAM_COPY STREAM_COPY
}; };
enum SSBO_ACCESS {
SSBO_READ = BUFFER_READ,
SSBO_WRITE = BUFFER_WRITE,
SSBO_READ_WRITE = BUFFER_READ_WRITE
};
/// Create Shader Storage Buffer Object /// Create Shader Storage Buffer Object
/// !!! `data` can be NULL /// !!! `data` can be NULL
/// data: optional pointer to data to upload /// data: optional pointer to data to upload

View File

@ -174,8 +174,8 @@ void window_hints(unsigned flags) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // osx glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // osx
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // osx, 2:#version150,3:330 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // osx, 2:#version150,3:330
#else #else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //osx glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //osx

View File

@ -19932,8 +19932,8 @@ void window_hints(unsigned flags) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // osx glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // osx
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // osx, 2:#version150,3:330 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // osx, 2:#version150,3:330
#else #else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //osx glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //osx

View File

@ -2573,13 +2573,14 @@ API void shader_colormap(const char *name, colormap_t cm);
API unsigned shader_get_active(); API unsigned shader_get_active();
API void shader_destroy(unsigned shader); API void shader_destroy(unsigned shader);
// compute shaders enum BUFFER_ACCESS_MODE {
enum ACCESS_MODE { BUFFER_READ,
READ, BUFFER_WRITE,
WRITE, BUFFER_READ_WRITE
READ_WRITE
}; };
// compute shaders
/// Loads the compute shader and compiles a GL program. /// Loads the compute shader and compiles a GL program.
/// return: GL program, 0 if failed. /// return: GL program, 0 if failed.
/// cs: shader source code /// cs: shader source code
@ -2625,7 +2626,7 @@ API void write_barrier();
/// `DRAW` favors CPU->GPU operations. /// `DRAW` favors CPU->GPU operations.
/// `READ` favors GPU->CPU operations. /// `READ` favors GPU->CPU operations.
/// `COPY` favors CPU->GPU->CPU operations. /// `COPY` favors CPU->GPU->CPU operations.
enum USAGE_MODE { enum SSBO_USAGE_MODE {
STATIC_DRAW, STATIC_DRAW,
STATIC_READ, STATIC_READ,
STATIC_COPY, STATIC_COPY,
@ -2639,6 +2640,12 @@ enum USAGE_MODE {
STREAM_COPY STREAM_COPY
}; };
enum SSBO_ACCESS {
SSBO_READ = BUFFER_READ,
SSBO_WRITE = BUFFER_WRITE,
SSBO_READ_WRITE = BUFFER_READ_WRITE
};
/// Create Shader Storage Buffer Object /// Create Shader Storage Buffer Object
/// !!! `data` can be NULL /// !!! `data` can be NULL
/// data: optional pointer to data to upload /// data: optional pointer to data to upload