Skip to content

Commit

Permalink
lowlevel: Add prefix to assert macros
Browse files Browse the repository at this point in the history
  • Loading branch information
caseif committed Jul 9, 2024
1 parent e6e4d0e commit d6361b4
Show file tree
Hide file tree
Showing 38 changed files with 182 additions and 182 deletions.
4 changes: 2 additions & 2 deletions engine/dynamic/render_opengl/src/gl_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ namespace argus {

void set_attrib_pointer(array_handle_t array_obj, buffer_handle_t buffer_obj, binding_index_t binding_index,
GLuint vertex_len, GLuint attr_len, GLuint attr_index, GLuint *attr_offset) {
assert(attr_len <= INT_MAX);
argus_assert(attr_len <= INT_MAX);

if (AGLET_GL_ARB_direct_state_access) {
glEnableVertexArrayAttrib(array_obj, attr_index);
glVertexArrayAttribFormat(array_obj, attr_index, GLint(attr_len), GL_FLOAT, GL_FALSE, *attr_offset);
glVertexArrayAttribBinding(array_obj, attr_index, binding_index);
} else {
auto stride = vertex_len * uint32_t(sizeof(GLfloat));
assert(stride <= INT_MAX);
argus_assert(stride <= INT_MAX);

glBindBuffer(GL_ARRAY_BUFFER, buffer_obj);
glEnableVertexAttribArray(attr_index);
Expand Down
4 changes: 2 additions & 2 deletions engine/dynamic/render_opengl/src/module_render_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->render(event.delta);
break;
Expand All @@ -136,7 +136,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->notify_window_resize(event.resolution);
break;
Expand Down
2 changes: 1 addition & 1 deletion engine/dynamic/render_opengl/src/renderer/bucket_proc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace argus {
}

auto program_it = scene_state.parent_state.linked_programs.find(bucket->material_res.uid);
assert(program_it != scene_state.parent_state.linked_programs.cend());
argus_assert(program_it != scene_state.parent_state.linked_programs.cend());

// the program should have been linked during object processing
auto &program = program_it->second;
Expand Down
16 changes: 8 additions & 8 deletions engine/dynamic/render_opengl/src/renderer/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ namespace argus {
}

void BufferInfo::map_write() {
assert(valid);
assert(allow_mapping);
argus_assert(valid);
argus_assert(allow_mapping);

if (persistent) {
return;
}

assert(mapped == nullptr);
argus_assert(mapped == nullptr);

if (AGLET_GL_ARB_direct_state_access) {
mapped = glMapNamedBuffer(handle, GL_WRITE_ONLY);
Expand All @@ -95,14 +95,14 @@ namespace argus {
}

void BufferInfo::unmap() {
assert(valid);
assert(allow_mapping);
argus_assert(valid);
argus_assert(allow_mapping);

if (persistent) {
return;
}

assert(mapped != nullptr);
argus_assert(mapped != nullptr);

if (AGLET_GL_ARB_direct_state_access) {
glUnmapNamedBuffer(handle);
Expand All @@ -116,8 +116,8 @@ namespace argus {
}

void BufferInfo::write(void *src, size_t len, size_t offset) {
assert(valid);
assert(offset + len <= this->size);
argus_assert(valid);
argus_assert(offset + len <= this->size);

if (mapped != nullptr) {
memcpy(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(mapped) + offset), src, len);
Expand Down
16 changes: 8 additions & 8 deletions engine/dynamic/render_opengl/src/renderer/shader_mgmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace argus {
if (gl_res == GL_FALSE) {
int log_len;
glGetShaderiv(shader_handle, GL_INFO_LOG_LENGTH, &log_len);
assert(log_len >= 0);
argus_assert(log_len >= 0);
char *log = new char[size_t(log_len) + 1];
log[0] = '\0';
glGetShaderInfoLog(shader_handle, log_len, nullptr, log);
Expand Down Expand Up @@ -272,7 +272,7 @@ namespace argus {
if (res == GL_FALSE) {
int log_len;
glGetProgramiv(program_handle, GL_INFO_LOG_LENGTH, &log_len);
assert(log_len >= 0);
argus_assert(log_len >= 0);
char *log = new char[size_t(log_len)];
glGetProgramInfoLog(program_handle, GL_INFO_LOG_LENGTH, nullptr, log);
crash("Failed to link program: %s", log);
Expand All @@ -283,7 +283,7 @@ namespace argus {
GLint attrib_count;

glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &attrib_max_len);
assert(attrib_max_len >= 0);
argus_assert(attrib_max_len >= 0);
glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTES, &attrib_count);

GLsizei attrib_name_len;
Expand All @@ -294,9 +294,9 @@ namespace argus {
for (int i = 0; i < attrib_count; i++) {
glGetActiveAttrib(program_handle, uint32_t(i), attrib_max_len, &attrib_name_len,
&attrib_size, &attrib_type, attrib_name);
assert(attrib_name_len <= attrib_max_len);
argus_assert(attrib_name_len <= attrib_max_len);
GLint attrib_loc = glGetAttribLocation(program_handle, attrib_name);
assert(attrib_loc >= 0);
argus_assert(attrib_loc >= 0);
refl_info.attribute_locations[std::string(attrib_name)] = uint32_t(attrib_loc);
}
}
Expand All @@ -306,7 +306,7 @@ namespace argus {
GLint uniform_count;

glGetProgramiv(program_handle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_max_len);
assert(uniform_max_len >= 0);
argus_assert(uniform_max_len >= 0);
glGetProgramiv(program_handle, GL_ACTIVE_UNIFORMS, &uniform_count);

GLsizei uniform_name_len;
Expand All @@ -315,9 +315,9 @@ namespace argus {
for (int i = 0; i < uniform_count; i++) {
glGetActiveUniformName(program_handle, uint32_t(i), uniform_max_len, &uniform_name_len,
uniform_name);
assert(uniform_name_len <= uniform_max_len);
argus_assert(uniform_name_len <= uniform_max_len);
GLint uniform_loc = glGetUniformLocation(program_handle, uniform_name);
assert(uniform_loc >= 0);
argus_assert(uniform_loc >= 0);
refl_info.uniform_variable_locations[std::string(uniform_name)] = uint32_t(uniform_loc);
}
}
Expand Down
4 changes: 2 additions & 2 deletions engine/dynamic/render_opengl_legacy/src/gl_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ namespace argus {

void set_attrib_pointer(buffer_handle_t buffer_obj, GLuint vertex_len, GLuint attr_len, GLuint attr_index,
GLuint *attr_offset) {
assert(attr_len <= INT_MAX);
argus_assert(attr_len <= INT_MAX);

auto stride = vertex_len * uint32_t(sizeof(GLfloat));
assert(stride <= INT_MAX);
argus_assert(stride <= INT_MAX);

glBindBuffer(GL_ARRAY_BUFFER, buffer_obj);
glEnableVertexAttribArray(attr_index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->render(event.delta);
break;
Expand All @@ -138,7 +138,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->notify_window_resize(event.resolution);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace argus {
}

auto program_it = scene_state.parent_state.linked_programs.find(bucket->material_res.uid);
assert(program_it != scene_state.parent_state.linked_programs.cend());
argus_assert(program_it != scene_state.parent_state.linked_programs.cend());

bool animated = program_it->second.reflection.has_uniform(SHADER_UBO_OBJ, SHADER_UNIFORM_OBJ_UV_STRIDE);

Expand Down
16 changes: 8 additions & 8 deletions engine/dynamic/render_opengl_legacy/src/renderer/shader_mgmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace argus {
if (res == GL_FALSE) {
int log_len;
glGetShaderiv(shader_handle, GL_INFO_LOG_LENGTH, &log_len);
assert(log_len >= 0);
argus_assert(log_len >= 0);
char *log = new char[size_t(log_len) + 1];
log[0] = '\0';
glGetShaderInfoLog(shader_handle, log_len, nullptr, log);
Expand Down Expand Up @@ -227,7 +227,7 @@ namespace argus {
if (res == GL_FALSE) {
int log_len;
glGetProgramiv(program_handle, GL_INFO_LOG_LENGTH, &log_len);
assert(log_len >= 0);
argus_assert(log_len >= 0);
char *log = new char[size_t(log_len)];
glGetProgramInfoLog(program_handle, GL_INFO_LOG_LENGTH, nullptr, log);
crash("Failed to link program: %s", log);
Expand All @@ -237,7 +237,7 @@ namespace argus {
GLint attrib_count;

glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &attrib_max_len);
assert(attrib_max_len >= 0);
argus_assert(attrib_max_len >= 0);
glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTES, &attrib_count);

GLsizei attrib_name_len;
Expand All @@ -248,17 +248,17 @@ namespace argus {
for (int i = 0; i < attrib_count; i++) {
glGetActiveAttrib(program_handle, uint32_t(i), attrib_max_len, &attrib_name_len,
&attrib_size, &attrib_type, attrib_name);
assert(attrib_name_len <= attrib_max_len);
argus_assert(attrib_name_len <= attrib_max_len);
GLint attrib_loc = glGetAttribLocation(program_handle, attrib_name);
assert(attrib_loc >= 0);
argus_assert(attrib_loc >= 0);
refl_info.attribute_locations[std::string(attrib_name)] = uint32_t(attrib_loc);
}

GLint uniform_max_len;
GLint uniform_count;

glGetProgramiv(program_handle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_max_len);
assert(uniform_max_len >= 0);
argus_assert(uniform_max_len >= 0);
glGetProgramiv(program_handle, GL_ACTIVE_UNIFORMS, &uniform_count);

GLsizei uniform_name_len;
Expand All @@ -267,9 +267,9 @@ namespace argus {
for (int i = 0; i < uniform_count; i++) {
glGetActiveUniform(program_handle, uint32_t(i), uniform_max_len, &uniform_name_len,
nullptr, nullptr, uniform_name);
assert(uniform_name_len <= uniform_max_len);
argus_assert(uniform_name_len <= uniform_max_len);
GLint uniform_loc = glGetUniformLocation(program_handle, uniform_name);
assert(uniform_loc >= 0);
argus_assert(uniform_loc >= 0);
refl_info.uniform_variable_locations[std::string(uniform_name)] = uint32_t(uniform_loc);
}

Expand Down
4 changes: 2 additions & 2 deletions engine/dynamic/render_opengles/src/gl_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ namespace argus {
GLuint attr_len, GLuint attr_index, GLuint *attr_offset) {
UNUSED(binding_index);

assert(attr_len <= INT_MAX);
argus_assert(attr_len <= INT_MAX);

auto stride = vertex_len * uint32_t(sizeof(GLfloat));
assert(stride <= INT_MAX);
argus_assert(stride <= INT_MAX);

glBindBuffer(GL_ARRAY_BUFFER, buffer_obj);
glEnableVertexAttribArray(attr_index);
Expand Down
4 changes: 2 additions & 2 deletions engine/dynamic/render_opengles/src/module_render_opengles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->render(event.delta);
break;
Expand All @@ -133,7 +133,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->notify_window_resize(event.resolution);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace argus {
}

auto program_it = scene_state.parent_state.linked_programs.find(bucket->material_res.uid);
assert(program_it != scene_state.parent_state.linked_programs.cend());
argus_assert(program_it != scene_state.parent_state.linked_programs.cend());

// the program should have been linked during object processing
auto &program = program_it->second;
Expand Down
12 changes: 6 additions & 6 deletions engine/dynamic/render_opengles/src/renderer/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ namespace argus {
}

void BufferInfo::map_write() {
assert(valid);
argus_assert(valid);

if (persistent) {
return;
}

assert(mapped == nullptr);
argus_assert(mapped == nullptr);

glBindBuffer(target, handle);
mapped = glMapBufferRange(target, 0, GLsizeiptr(size), GL_MAP_WRITE_BIT);
glBindBuffer(target, 0);
}

void BufferInfo::unmap() {
assert(valid);
argus_assert(valid);

if (persistent) {
return;
}

assert(mapped != nullptr);
argus_assert(mapped != nullptr);

glBindBuffer(target, handle);
glUnmapBuffer(target);
Expand All @@ -87,8 +87,8 @@ namespace argus {
}

void BufferInfo::write(void *src, size_t len, size_t offset) {
assert(valid);
assert(offset + len <= this->size);
argus_assert(valid);
argus_assert(offset + len <= this->size);

if (mapped != nullptr) {
memcpy(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(mapped) + offset), src, len);
Expand Down
10 changes: 5 additions & 5 deletions engine/dynamic/render_opengles/src/renderer/shader_mgmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace argus {
if (gl_res == GL_FALSE) {
GLint log_len;
glGetShaderiv(shader_handle, GL_INFO_LOG_LENGTH, &log_len);
assert(log_len >= 0);
argus_assert(log_len >= 0);
char *log = new char[size_t(log_len + 1)];
glGetShaderInfoLog(shader_handle, log_len, nullptr, log);
std::string stage_str;
Expand Down Expand Up @@ -245,7 +245,7 @@ namespace argus {
if (res == GL_FALSE) {
int log_len;
glGetProgramiv(program_handle, GL_INFO_LOG_LENGTH, &log_len);
assert(log_len >= 0);
argus_assert(log_len >= 0);
char *log = new char[size_t(log_len)];
glGetProgramInfoLog(program_handle, GL_INFO_LOG_LENGTH, nullptr, log);
crash("Failed to link program: %s", log);
Expand All @@ -256,7 +256,7 @@ namespace argus {
GLint uniform_count;

glGetProgramiv(program_handle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_max_len);
assert(uniform_max_len >= 0);
argus_assert(uniform_max_len >= 0);
glGetProgramiv(program_handle, GL_ACTIVE_UNIFORMS, &uniform_count);

GLsizei uniform_name_len;
Expand All @@ -267,9 +267,9 @@ namespace argus {
for (int i = 0; i < uniform_count; i++) {
glGetActiveUniform(program_handle, uint32_t(i), uniform_max_len, &uniform_name_len,
&uniform_size, &uniform_type, uniform_name);
assert(uniform_name_len <= uniform_max_len);
argus_assert(uniform_name_len <= uniform_max_len);
GLint uniform_loc = glGetUniformLocation(program_handle, uniform_name);
assert(uniform_loc >= 0);
argus_assert(uniform_loc >= 0);
refl_info.uniform_variable_locations[std::string(uniform_name)] = uint32_t(uniform_loc);
}
}
Expand Down
4 changes: 2 additions & 2 deletions engine/dynamic/render_vulkan/src/module_render_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());
auto &renderer = it->second;

if (!renderer->m_is_initted) {
Expand All @@ -236,7 +236,7 @@ namespace argus {
}

auto it = g_renderer_map.find(&window);
assert(it != g_renderer_map.end());
argus_assert(it != g_renderer_map.end());

it->second->notify_window_resize(event.resolution);
break;
Expand Down
Loading

0 comments on commit d6361b4

Please sign in to comment.