add window_msaa and normalise occl query result

main
Dominik Madarász 2024-08-27 12:46:11 +02:00
parent 1e41f28033
commit e5062ef825
8 changed files with 53 additions and 13 deletions

View File

@ -2111,6 +2111,7 @@ enum WINDOW_FLAGS {
void window_loop_exit();
void window_title(const char *title);
void window_color(unsigned color);
char window_msaa();
vec2 window_canvas();
void* window_handle();
char* window_stats();

View File

@ -18787,6 +18787,7 @@ API void window_loop_exit(); // exit from main loop function (emscripten onl
API void window_title(const char *title);
API void window_color(unsigned color);
API char window_msaa();
API vec2 window_canvas();
API void* window_handle();
API char* window_stats();
@ -383224,6 +383225,14 @@ void shadowmatrix_ortho(mat44 shm_proj, float left, float right, float bottom, f
static renderstate_t query_test_rs;
static inline
unsigned query_adjust_samples_msaa(unsigned samples) {
if (window_msaa() > 1) {
return samples / window_msaa();
}
return samples;
}
static inline
void query_test_rs_init() {
do_once {
@ -383271,7 +383280,7 @@ unsigned query_test_point(mat44 proj, mat44 view, vec3 pos, float size) {
glBindVertexArray( 0 );
glUseProgram( oldprog );
return samples_passed;
return query_adjust_samples_msaa(samples_passed);
}
// -----------------------------------------------------------------------------
@ -392045,6 +392054,7 @@ static int w, h, xpos, ypos, paused;
static int fullscreen, xprev, yprev, wprev, hprev;
static uint64_t frame_count;
static double t, dt, fps, hz = 0.00;
static char msaa = 0;
static char title[128] = {0};
static char screenshot_file[DIR_MAX];
static int locked_aspect_ratio = 0;
@ -392154,9 +392164,9 @@ void window_hints(unsigned flags) {
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
// glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
// glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // makes it non-resizable
if(flags & WINDOW_MSAA2) glfwWindowHint(GLFW_SAMPLES, 2); // x2 AA
if(flags & WINDOW_MSAA4) glfwWindowHint(GLFW_SAMPLES, 4); // x4 AA
if(flags & WINDOW_MSAA8) glfwWindowHint(GLFW_SAMPLES, 8); // x8 AA
if(flags & WINDOW_MSAA2) glfwWindowHint(GLFW_SAMPLES, 2), msaa = 2; // x2 AA
if(flags & WINDOW_MSAA4) glfwWindowHint(GLFW_SAMPLES, 4), msaa = 4; // x4 AA
if(flags & WINDOW_MSAA8) glfwWindowHint(GLFW_SAMPLES, 8), msaa = 8; // x8 AA
g->flags = flags;
}
@ -392772,6 +392782,9 @@ void window_color(unsigned color) {
unsigned a = (color >> 24) & 255;
winbgcolor = vec4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
}
char window_msaa() {
return msaa;
}
static int has_icon;
int window_has_icon() {
return has_icon;

View File

@ -1552,6 +1552,14 @@ void shadowmatrix_ortho(mat44 shm_proj, float left, float right, float bottom, f
static renderstate_t query_test_rs;
static inline
unsigned query_adjust_samples_msaa(unsigned samples) {
if (window_msaa() > 1) {
return samples / window_msaa();
}
return samples;
}
static inline
void query_test_rs_init() {
do_once {
@ -1599,7 +1607,7 @@ unsigned query_test_point(mat44 proj, mat44 view, vec3 pos, float size) {
glBindVertexArray( 0 );
glUseProgram( oldprog );
return samples_passed;
return query_adjust_samples_msaa(samples_passed);
}
// -----------------------------------------------------------------------------

View File

@ -112,6 +112,7 @@ static int w, h, xpos, ypos, paused;
static int fullscreen, xprev, yprev, wprev, hprev;
static uint64_t frame_count;
static double t, dt, fps, hz = 0.00;
static char msaa = 0;
static char title[128] = {0};
static char screenshot_file[DIR_MAX];
static int locked_aspect_ratio = 0;
@ -221,9 +222,9 @@ void window_hints(unsigned flags) {
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
// glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
// glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // makes it non-resizable
if(flags & WINDOW_MSAA2) glfwWindowHint(GLFW_SAMPLES, 2); // x2 AA
if(flags & WINDOW_MSAA4) glfwWindowHint(GLFW_SAMPLES, 4); // x4 AA
if(flags & WINDOW_MSAA8) glfwWindowHint(GLFW_SAMPLES, 8); // x8 AA
if(flags & WINDOW_MSAA2) glfwWindowHint(GLFW_SAMPLES, 2), msaa = 2; // x2 AA
if(flags & WINDOW_MSAA4) glfwWindowHint(GLFW_SAMPLES, 4), msaa = 4; // x4 AA
if(flags & WINDOW_MSAA8) glfwWindowHint(GLFW_SAMPLES, 8), msaa = 8; // x8 AA
g->flags = flags;
}
@ -839,6 +840,9 @@ void window_color(unsigned color) {
unsigned a = (color >> 24) & 255;
winbgcolor = vec4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
}
char window_msaa() {
return msaa;
}
static int has_icon;
int window_has_icon() {
return has_icon;

View File

@ -40,6 +40,7 @@ API void window_loop_exit(); // exit from main loop function (emscripten onl
API void window_title(const char *title);
API void window_color(unsigned color);
API char window_msaa();
API vec2 window_canvas();
API void* window_handle();
API char* window_stats();

View File

@ -18351,6 +18351,14 @@ void shadowmatrix_ortho(mat44 shm_proj, float left, float right, float bottom, f
static renderstate_t query_test_rs;
static inline
unsigned query_adjust_samples_msaa(unsigned samples) {
if (window_msaa() > 1) {
return samples / window_msaa();
}
return samples;
}
static inline
void query_test_rs_init() {
do_once {
@ -18398,7 +18406,7 @@ unsigned query_test_point(mat44 proj, mat44 view, vec3 pos, float size) {
glBindVertexArray( 0 );
glUseProgram( oldprog );
return samples_passed;
return query_adjust_samples_msaa(samples_passed);
}
// -----------------------------------------------------------------------------
@ -27172,6 +27180,7 @@ static int w, h, xpos, ypos, paused;
static int fullscreen, xprev, yprev, wprev, hprev;
static uint64_t frame_count;
static double t, dt, fps, hz = 0.00;
static char msaa = 0;
static char title[128] = {0};
static char screenshot_file[DIR_MAX];
static int locked_aspect_ratio = 0;
@ -27281,9 +27290,9 @@ void window_hints(unsigned flags) {
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
// glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
// glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // makes it non-resizable
if(flags & WINDOW_MSAA2) glfwWindowHint(GLFW_SAMPLES, 2); // x2 AA
if(flags & WINDOW_MSAA4) glfwWindowHint(GLFW_SAMPLES, 4); // x4 AA
if(flags & WINDOW_MSAA8) glfwWindowHint(GLFW_SAMPLES, 8); // x8 AA
if(flags & WINDOW_MSAA2) glfwWindowHint(GLFW_SAMPLES, 2), msaa = 2; // x2 AA
if(flags & WINDOW_MSAA4) glfwWindowHint(GLFW_SAMPLES, 4), msaa = 4; // x4 AA
if(flags & WINDOW_MSAA8) glfwWindowHint(GLFW_SAMPLES, 8), msaa = 8; // x8 AA
g->flags = flags;
}
@ -27899,6 +27908,9 @@ void window_color(unsigned color) {
unsigned a = (color >> 24) & 255;
winbgcolor = vec4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
}
char window_msaa() {
return msaa;
}
static int has_icon;
int window_has_icon() {
return has_icon;

View File

@ -4854,6 +4854,7 @@ API void window_loop_exit(); // exit from main loop function (emscripten onl
API void window_title(const char *title);
API void window_color(unsigned color);
API char window_msaa();
API vec2 window_canvas();
API void* window_handle();
API char* window_stats();

View File

@ -4,7 +4,7 @@
cd `dirname $0`
git clone https://github.com/assimp/assimp && cd assimp && git checkout 05115b07
cmake -DCMAKE_BUILD_TYPE=Release -DASSIMP_BUILD_TESTS=OFF .
cmake -DCMAKE_BUILD_TYPE=Release -DASSIMP_BUILD_TESTS=OFF -D_FORTIFY_SOURCE=0 .
make -j 8
cp bin/libassimp.so ../libassimp.so
cp bin/libassimp.so ../libassimp.so.5