Temp commit. Auth3D Object HRC breakdown

This commit is contained in:
korenkonder
2022-12-10 03:14:07 +03:00
parent a15befd8fb
commit c96c52d4d3
198 changed files with 26200 additions and 14772 deletions
+82 -65
View File
@@ -7,7 +7,7 @@
gl_state_struct gl_state;
inline void gl_state_active_bind_texture_2d(int32_t index, GLuint texture) {
void gl_state_active_bind_texture_2d(int32_t index, GLuint texture) {
if (gl_state.texture_binding_2d[index] != texture) {
if (gl_state.active_texture_index != index) {
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
@@ -19,7 +19,7 @@ inline void gl_state_active_bind_texture_2d(int32_t index, GLuint texture) {
}
}
inline void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture) {
void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture) {
if (gl_state.texture_binding_cube_map[index] != texture) {
if (gl_state.active_texture_index != index) {
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
@@ -31,7 +31,7 @@ inline void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture)
}
}
inline void gl_state_active_texture(size_t index) {
void gl_state_active_texture(size_t index) {
if (gl_state.active_texture_index != index) {
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
gl_state.active_texture = (GLenum)(GL_TEXTURE0 + index);
@@ -39,7 +39,7 @@ inline void gl_state_active_texture(size_t index) {
}
}
inline void gl_state_bind_framebuffer(GLuint framebuffer) {
void gl_state_bind_framebuffer(GLuint framebuffer) {
if (gl_state.read_framebuffer_binding != framebuffer
|| gl_state.draw_framebuffer_binding != framebuffer) {
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
@@ -48,49 +48,46 @@ inline void gl_state_bind_framebuffer(GLuint framebuffer) {
}
}
inline void gl_state_bind_read_framebuffer(GLuint framebuffer) {
void gl_state_bind_read_framebuffer(GLuint framebuffer) {
if (gl_state.read_framebuffer_binding != framebuffer) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
gl_state.read_framebuffer_binding = framebuffer;
}
}
inline void gl_state_bind_draw_framebuffer(GLuint framebuffer) {
void gl_state_bind_draw_framebuffer(GLuint framebuffer) {
if (gl_state.draw_framebuffer_binding != framebuffer) {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
gl_state.draw_framebuffer_binding = framebuffer;
}
}
inline void gl_state_bind_vertex_array(GLuint array) {
if (gl_state.vertex_array_binding != array) {
void gl_state_bind_vertex_array(GLuint array, bool force) {
if (gl_state.vertex_array_binding != array || force) {
glBindVertexArray(array);
gl_state.vertex_array_binding = array;
}
}
inline void gl_state_bind_array_buffer(GLuint buffer) {
if (gl_state.array_buffer_binding != buffer) {
void gl_state_bind_array_buffer(GLuint buffer, bool force) {
if (gl_state.array_buffer_binding != buffer || force) {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
gl_state.array_buffer_binding = buffer;
}
}
inline void gl_state_bind_element_array_buffer(GLuint buffer) {
if (gl_state.element_array_buffer_binding != buffer) {
void gl_state_bind_element_array_buffer(GLuint buffer, bool force) {
if (gl_state.element_array_buffer_binding != buffer || force) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
gl_state.element_array_buffer_binding = buffer;
}
}
inline void gl_state_bind_uniform_buffer(GLuint buffer) {
if (gl_state.uniform_buffer_binding[gl_state.uniform_buffer_index] != buffer) {
glBindBuffer(GL_UNIFORM_BUFFER, buffer);
gl_state.uniform_buffer_binding[gl_state.uniform_buffer_index] = buffer;
}
void gl_state_bind_uniform_buffer(GLuint buffer, bool force) {
gl_state_bind_uniform_buffer_base(gl_state.uniform_buffer_index, buffer);
}
inline void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer) {
void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer, bool force) {
if (gl_state.uniform_buffer_binding[index] != buffer) {
glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer);
gl_state.uniform_buffer_binding[index] = buffer;
@@ -100,8 +97,8 @@ inline void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer) {
}
}
inline void gl_state_bind_uniform_buffer_range(GLuint index,
GLuint buffer, GLintptr offset, GLsizeiptr size) {
void gl_state_bind_uniform_buffer_range(GLuint index,
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force) {
if (gl_state.uniform_buffer_binding[index] != buffer
|| gl_state.uniform_buffer_offset[index] != offset
|| gl_state.uniform_buffer_size[index] != size) {
@@ -113,14 +110,11 @@ inline void gl_state_bind_uniform_buffer_range(GLuint index,
}
}
inline void gl_state_bind_shader_storage_buffer(GLuint buffer) {
if (gl_state.shader_storage_buffer_binding[gl_state.shader_storage_buffer_index] != buffer) {
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer);
gl_state.shader_storage_buffer_binding[gl_state.shader_storage_buffer_index] = buffer;
}
void gl_state_bind_shader_storage_buffer(GLuint buffer, bool force) {
gl_state_bind_shader_storage_buffer_base(gl_state.shader_storage_buffer_index, buffer);
}
inline void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer) {
void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer, bool force) {
if (gl_state.shader_storage_buffer_binding[index] != buffer) {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, buffer);
gl_state.shader_storage_buffer_binding[index] = buffer;
@@ -130,8 +124,8 @@ inline void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer
}
}
inline void gl_state_bind_shader_storage_buffer_range(GLuint index,
GLuint buffer, GLintptr offset, GLsizeiptr size) {
void gl_state_bind_shader_storage_buffer_range(GLuint index,
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force) {
if (gl_state.shader_storage_buffer_binding[index] != buffer
|| gl_state.shader_storage_buffer_offset[index] != offset
|| gl_state.shader_storage_buffer_size[index] != size) {
@@ -143,133 +137,147 @@ inline void gl_state_bind_shader_storage_buffer_range(GLuint index,
}
}
inline void gl_state_bind_texture_2d(GLuint texture) {
void gl_state_bind_texture_2d(GLuint texture) {
if (gl_state.texture_binding_2d[gl_state.active_texture_index] != texture) {
glBindTexture(GL_TEXTURE_2D, texture);
gl_state.texture_binding_2d[gl_state.active_texture_index] = texture;
}
}
inline void gl_state_bind_texture_cube_map(GLuint texture) {
void gl_state_bind_texture_cube_map(GLuint texture) {
if (gl_state.texture_binding_cube_map[gl_state.active_texture_index] != texture) {
glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
gl_state.texture_binding_cube_map[gl_state.active_texture_index] = texture;
}
}
inline void gl_state_bind_sampler(int32_t index, GLuint sampler) {
void gl_state_bind_sampler(int32_t index, GLuint sampler) {
if (gl_state.sampler_binding[index] != sampler) {
glBindSampler(index, sampler);
gl_state.sampler_binding[index] = sampler;
}
}
inline bool gl_state_check_uniform_buffer_binding() {
bool gl_state_check_uniform_buffer_binding() {
return gl_state.uniform_buffer_binding[gl_state.uniform_buffer_index] != 0;
}
inline bool gl_state_check_uniform_buffer_binding_base(size_t index) {
bool gl_state_check_uniform_buffer_binding_base(size_t index) {
return gl_state.uniform_buffer_binding[index] != 0;
}
inline bool gl_state_check_shader_storage_buffer_binding() {
bool gl_state_check_shader_storage_buffer_binding() {
return gl_state.shader_storage_buffer_binding[gl_state.shader_storage_buffer_index] != 0;
}
inline bool gl_state_check_shader_storage_buffer_binding_base(size_t index) {
bool gl_state_check_shader_storage_buffer_binding_base(size_t index) {
return gl_state.shader_storage_buffer_binding[index] != 0;
}
inline bool gl_state_check_texture_binding_2d(size_t index) {
bool gl_state_check_texture_binding_2d(size_t index) {
return gl_state.texture_binding_2d[index] != 0;
}
inline bool gl_state_check_texture_binding_cube_map(size_t index) {
bool gl_state_check_texture_binding_cube_map(size_t index) {
return gl_state.texture_binding_cube_map[index] != 0;
}
inline bool gl_state_check_sampler_binding(int32_t index, GLuint sampler) {
bool gl_state_check_sampler_binding(int32_t index, GLuint sampler) {
return gl_state.sampler_binding[index] != 0;
}
inline void gl_state_disable_blend() {
void gl_state_disable_blend() {
if (gl_state.blend) {
glDisable(GL_BLEND);
gl_state.blend = GL_FALSE;
}
}
inline void gl_state_disable_cull_face() {
void gl_state_disable_cull_face() {
if (gl_state.cull_face) {
glDisable(GL_CULL_FACE);
gl_state.cull_face = GL_FALSE;
}
}
inline void gl_state_disable_depth_test() {
void gl_state_disable_depth_test() {
if (gl_state.depth_test) {
glDisable(GL_DEPTH_TEST);
gl_state.depth_test = GL_FALSE;
}
}
inline void gl_state_disable_primitive_restart() {
if (!gl_state.primitive_restart) {
void gl_state_disable_multisample() {
if (gl_state.multisample) {
glDisable(GL_MULTISAMPLE);
gl_state.multisample = GL_FALSE;
}
}
void gl_state_disable_primitive_restart() {
if (gl_state.primitive_restart) {
glDisable(GL_PRIMITIVE_RESTART);
gl_state.primitive_restart = GL_FALSE;
}
}
inline void gl_state_disable_scissor_test() {
void gl_state_disable_scissor_test() {
if (gl_state.scissor_test) {
glDisable(GL_SCISSOR_TEST);
gl_state.scissor_test = GL_FALSE;
}
}
inline void gl_state_disable_stencil_test() {
void gl_state_disable_stencil_test() {
if (gl_state.stencil_test) {
glDisable(GL_STENCIL_TEST);
gl_state.stencil_test = GL_FALSE;
}
}
inline void gl_state_enable_blend() {
void gl_state_enable_blend() {
if (!gl_state.blend) {
glEnable(GL_BLEND);
gl_state.blend = GL_TRUE;
}
}
inline void gl_state_enable_cull_face() {
void gl_state_enable_cull_face() {
if (!gl_state.cull_face) {
glEnable(GL_CULL_FACE);
gl_state.cull_face = GL_TRUE;
}
}
inline void gl_state_enable_depth_test() {
void gl_state_enable_depth_test() {
if (!gl_state.depth_test) {
glEnable(GL_DEPTH_TEST);
gl_state.depth_test = GL_TRUE;
}
}
inline void gl_state_enable_primitive_restart() {
void gl_state_enable_multisample() {
if (!gl_state.multisample) {
glEnable(GL_MULTISAMPLE);
gl_state.multisample = GL_TRUE;
}
}
void gl_state_enable_primitive_restart() {
if (!gl_state.primitive_restart) {
glEnable(GL_PRIMITIVE_RESTART);
gl_state.primitive_restart = GL_TRUE;
}
}
inline void gl_state_enable_scissor_test() {
void gl_state_enable_scissor_test() {
if (!gl_state.scissor_test) {
glEnable(GL_SCISSOR_TEST);
gl_state.scissor_test = GL_TRUE;
}
}
inline void gl_state_enable_stencil_test() {
void gl_state_enable_stencil_test() {
if (!gl_state.stencil_test) {
glEnable(GL_STENCIL_TEST);
gl_state.stencil_test = GL_TRUE;
@@ -328,7 +336,9 @@ void gl_state_get() {
glGetBooleanv(GL_DEPTH_TEST, &gl_state.depth_test);
glGetIntegerv(GL_DEPTH_FUNC, (GLint*)&gl_state.depth_func);
glGetBooleanv(GL_DEPTH_WRITEMASK, &gl_state.depth_mask);
glGetBooleanv(GL_MULTISAMPLE, &gl_state.multisample);
glGetBooleanv(GL_PRIMITIVE_RESTART, &gl_state.primitive_restart);
glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX, (GLint*)&gl_state.primitive_restart_index);
glGetBooleanv(GL_SCISSOR_TEST, &gl_state.scissor_test);
glGetBooleanv(GL_STENCIL_TEST, &gl_state.stencil_test);
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint*)&gl_state.stencil_mask);
@@ -338,17 +348,17 @@ void gl_state_get() {
gl_state.polygon_back_face_mode = GL_FILL;
}
inline void gl_state_get_all_gl_errors() {
void gl_state_get_all_gl_errors() {
GLenum error;
while (error = glGetError())
printf("GL Error: 0x%04X\n", error);
printf_debug("GL Error: 0x%04X\n", error);
}
inline GLuint gl_state_get_program() {
GLuint gl_state_get_program() {
return gl_state.program;
}
inline void gl_state_set_blend_func(GLenum src, GLenum dst) {
void gl_state_set_blend_func(GLenum src, GLenum dst) {
if (gl_state.blend_src_rgb != src || gl_state.blend_dst_rgb != dst
|| gl_state.blend_src_alpha != GL_ONE || gl_state.blend_dst_alpha != GL_ONE_MINUS_SRC_ALPHA) {
glBlendFuncSeparate(src, dst, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -359,7 +369,7 @@ inline void gl_state_set_blend_func(GLenum src, GLenum dst) {
}
}
inline void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
GLenum src_alpha, GLenum dst_alpha) {
if (gl_state.blend_src_rgb != src_rgb || gl_state.blend_dst_rgb != dst_rgb
|| gl_state.blend_src_alpha != src_alpha || gl_state.blend_dst_alpha != dst_alpha) {
@@ -371,7 +381,7 @@ inline void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
}
}
inline void gl_state_set_blend_equation(GLenum mode) {
void gl_state_set_blend_equation(GLenum mode) {
if (gl_state.blend_mode_rgb != mode || gl_state.blend_mode_alpha != mode) {
glBlendEquationSeparate(mode, mode);
gl_state.blend_mode_rgb = mode;
@@ -379,7 +389,7 @@ inline void gl_state_set_blend_equation(GLenum mode) {
}
}
inline void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_alpha) {
void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_alpha) {
if (gl_state.blend_mode_rgb != mode_rgb || gl_state.blend_mode_alpha != mode_alpha) {
glBlendEquationSeparate(mode_rgb, mode_alpha);
gl_state.blend_mode_rgb = mode_rgb;
@@ -387,7 +397,7 @@ inline void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_al
}
}
inline void gl_state_set_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
void gl_state_set_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
if (gl_state.color_mask[0] != red || gl_state.color_mask[1] != green
|| gl_state.color_mask[2] != blue || gl_state.color_mask[3] != alpha) {
glColorMask(red, green, blue, alpha);
@@ -398,28 +408,28 @@ inline void gl_state_set_color_mask(GLboolean red, GLboolean green, GLboolean bl
}
}
inline void gl_state_set_cull_face_mode(GLenum mode) {
void gl_state_set_cull_face_mode(GLenum mode) {
if (gl_state.cull_face_mode != mode) {
glCullFace(mode);
gl_state.cull_face_mode = mode;
}
}
inline void gl_state_set_depth_func(GLenum func) {
void gl_state_set_depth_func(GLenum func) {
if (gl_state.depth_func != func) {
glDepthFunc(func);
gl_state.depth_func = func;
}
}
inline void gl_state_set_depth_mask(GLboolean flag) {
void gl_state_set_depth_mask(GLboolean flag) {
if (gl_state.depth_mask != flag) {
glDepthMask(flag);
gl_state.depth_mask = flag;
}
}
inline void gl_state_set_polygon_mode(GLenum face, GLenum mode) {
void gl_state_set_polygon_mode(GLenum face, GLenum mode) {
switch (face) {
case GL_FRONT:
if (gl_state.polygon_front_face_mode != mode) {
@@ -451,14 +461,21 @@ inline void gl_state_set_polygon_mode(GLenum face, GLenum mode) {
}
}
inline void gl_state_set_stencil_mask(GLuint mask) {
void gl_state_set_primitive_restart_index(GLuint index) {
if (gl_state.primitive_restart_index != index) {
glPrimitiveRestartIndex(index);
gl_state.primitive_restart_index = index;
}
}
void gl_state_set_stencil_mask(GLuint mask) {
if (gl_state.stencil_mask != mask) {
glStencilMask(mask);
gl_state.stencil_mask = mask;
}
}
inline void gl_state_use_program(GLuint program) {
void gl_state_use_program(GLuint program) {
if (gl_state.program != program) {
glUseProgram(program);
gl_state.program = program;