bool file_utils::is_older_than(const char *pSrcFilename, const char *pDstFilename) { VOGL_NOTE_UNUSED(pSrcFilename); VOGL_NOTE_UNUSED(pDstFilename); vogl_error_printf("Unimplemented\n"); return false; }
bool file_utils::is_older_than(const char *pSrcFilename, const char *pDstFilename) { VOGL_NOTE_UNUSED(pSrcFilename); VOGL_NOTE_UNUSED(pDstFilename); console::debug("%s: Unimplemented\n", VOGL_FUNCTION_INFO_CSTR); return false; }
//---------------------------------------------------------------------------------------------------------------------- // vogl_direct_gl_func_epilog - This function is called immediately after EVERY single GL/GLX function call we make. //---------------------------------------------------------------------------------------------------------------------- static void vogl_direct_gl_func_epilog(gl_entrypoint_id_t entrypoint_id, void *pUser_data, void **ppStack_data) { VOGL_NOTE_UNUSED(entrypoint_id); VOGL_NOTE_UNUSED(pUser_data); VOGL_NOTE_UNUSED(ppStack_data); vogl_printf("* GLEPILOG %s\n", g_vogl_entrypoint_descs[entrypoint_id].m_pName); }
bool vogl_vao_state::snapshot(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 handle, GLenum target) { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(target); VOGL_NOTE_UNUSED(remapper); VOGL_CHECK_GL_ERROR; clear(); VOGL_ASSERT(handle <= cUINT32_MAX); m_snapshot_handle = static_cast<GLuint>(handle); // TODO: Core profile support m_has_been_bound = handle ? (GL_ENTRYPOINT(glIsVertexArray)(static_cast<GLuint>(handle)) != 0) : true; if (m_has_been_bound) { vogl_scoped_binding_state orig_binding(GL_VERTEX_ARRAY); GL_ENTRYPOINT(glBindVertexArray)(m_snapshot_handle); VOGL_CHECK_GL_ERROR; m_element_array_binding = vogl_get_gl_integer(GL_ELEMENT_ARRAY_BUFFER_BINDING); m_vertex_attribs.resize(context_info.get_max_vertex_attribs()); for (uint32_t i = 0; i < context_info.get_max_vertex_attribs(); i++) { vogl_vertex_attrib_desc &desc = m_vertex_attribs[i]; desc.m_array_binding = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING); desc.m_enabled = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED) != 0; desc.m_size = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_SIZE); desc.m_type = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_TYPE); desc.m_normalized = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED) != 0; desc.m_stride = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_STRIDE); desc.m_integer = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_INTEGER) != 0; desc.m_divisor = vogl_get_vertex_attrib_uint(i, GL_VERTEX_ATTRIB_ARRAY_DIVISOR); GLvoid *ptr = NULL; GL_ENTRYPOINT(glGetVertexAttribPointerv)(i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr); desc.m_pointer = reinterpret_cast<vogl_trace_ptr_value>(ptr); VOGL_CHECK_GL_ERROR; } } m_is_valid = true; return true; }
// TODO: Requires GL >= 3.2 or extension GL_ARB_sync bool vogl_sync_state::snapshot(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 handle, GLenum target) { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(context_info); VOGL_NOTE_UNUSED(target); VOGL_NOTE_UNUSED(remapper); VOGL_CHECK_GL_ERROR; clear(); m_snapshot_handle = handle; GLsync sync = vogl_handle_to_sync(handle); bool any_gl_errors = false; #define GET_INT(pname) \ do \ { \ GLint val = 0; \ GLsizei len = 0; \ GL_ENTRYPOINT(glGetSynciv)(sync, pname, sizeof(val), &len, &val); \ if (vogl_check_gl_error()) \ any_gl_errors = true; \ m_params.insert(pname, 0, &val, sizeof(val)); \ } while (0) GET_INT(GL_OBJECT_TYPE); GET_INT(GL_SYNC_STATUS); GET_INT(GL_SYNC_CONDITION); GET_INT(GL_SYNC_FLAGS); #undef GET_INT if (any_gl_errors) { clear(); vogl_error_printf("%s: GL error while enumerating sync %" PRIu64 "'s' params\n", VOGL_METHOD_NAME, (uint64_t)handle); return false; } VOGL_ASSERT(m_params.get_value<GLenum>(GL_OBJECT_TYPE) == GL_SYNC_FENCE); VOGL_ASSERT(m_params.get_value<GLenum>(GL_SYNC_CONDITION) == GL_SYNC_GPU_COMMANDS_COMPLETE); VOGL_ASSERT(m_params.get_value<uint>(GL_SYNC_FLAGS) == 0); m_is_valid = true; return true; }
semaphore::semaphore(uint32 initialCount, uint32 maximumCount, const char *pName) { VOGL_NOTE_UNUSED(maximumCount); VOGL_NOTE_UNUSED(pName); VOGL_ASSERT(maximumCount >= initialCount); VOGL_ASSERT(maximumCount >= 1); if (sem_init(&m_sem, 0, initialCount)) { VOGL_FAIL("semaphore: sem_init() failed"); } }
void blah::foobar(int x, const char *y, double z) { VOGL_NOTE_UNUSED(x); VOGL_NOTE_UNUSED(y); VOGL_NOTE_UNUSED(z); btrace_dump(); const char *calling_module = btrace_get_calling_module(); const char *current_module = btrace_get_current_module(); printf("\nbtrace_get_calling_module returns: %s\n", calling_module ? calling_module : "??"); printf("\nbtrace_get_current_module returns: %s\n", current_module ? current_module : "??"); }
bool vogl_framebuffer_attachment::snapshot(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLenum attachment, GLenum type) { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(remapper); VOGL_NOTE_UNUSED(context_info); clear(); m_attachment = attachment; m_type = type; #define DO_QUERY(e) \ do \ { \ int val = 0; \ GL_ENTRYPOINT(glGetFramebufferAttachmentParameteriv)(GL_FRAMEBUFFER, attachment, e, &val); \ VOGL_CHECK_GL_ERROR; \ m_params.insert(e, val); \ } while (0) // TODO: Is this query really valid on default framebuffer FBO's? DO_QUERY(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); static const GLenum s_common_queries[] = { GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING }; for (uint32_t i = 0; i < VOGL_ARRAY_SIZE(s_common_queries); i++) { DO_QUERY(s_common_queries[i]); } if (m_type == GL_TEXTURE) { DO_QUERY(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL); DO_QUERY(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); DO_QUERY(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER); // only need to query LAYERED if GS supported if (context_info.supports_extension("GL_ARB_geometry_shader4")) DO_QUERY(GL_FRAMEBUFFER_ATTACHMENT_LAYERED); } #undef DO_QUERY return true; }
bool vogl_matrix_state::restore_matrix_stack(const vogl_context_info &context_info, GLenum matrix, uint32_t index) const { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(context_info); const matrix_vec *pVec = m_matrices.find_value(matrix_key(matrix, index)); if ((!pVec) || (pVec->size() < 1)) return false; GL_ENTRYPOINT(glMatrixMode)(matrix); if (vogl_check_gl_error()) return false; // deepest .. current // 0 1 2 for (uint32_t i = 0; i < pVec->size(); i++) { if (i) { GL_ENTRYPOINT(glPushMatrix)(); if (vogl_check_gl_error()) return false; } GL_ENTRYPOINT(glLoadMatrixd)((*pVec)[i].get_ptr()); if (vogl_check_gl_error()) return false; } return true; }
bool vogl_renderbuffer_desc::snapshot(const vogl_context_info &context_info) { VOGL_FUNC_TRACER VOGL_ASSERT(context_info.get_version() >= VOGL_GL_VERSION_3_0); VOGL_NOTE_UNUSED(context_info); VOGL_CHECK_GL_ERROR; #define GET_STATE(e, x) \ do \ { \ GL_ENTRYPOINT(glGetRenderbufferParameteriv)(GL_RENDERBUFFER, e, reinterpret_cast<int *>(&x)); \ VOGL_CHECK_GL_ERROR; \ } while (0) GET_STATE(GL_RENDERBUFFER_WIDTH, m_width); GET_STATE(GL_RENDERBUFFER_HEIGHT, m_height); GET_STATE(GL_RENDERBUFFER_SAMPLES, m_samples); GET_STATE(GL_RENDERBUFFER_INTERNAL_FORMAT, m_internal_format); GET_STATE(GL_RENDERBUFFER_RED_SIZE, m_red_size); GET_STATE(GL_RENDERBUFFER_GREEN_SIZE, m_green_size); GET_STATE(GL_RENDERBUFFER_BLUE_SIZE, m_blue_size); GET_STATE(GL_RENDERBUFFER_ALPHA_SIZE, m_alpha_size); GET_STATE(GL_RENDERBUFFER_DEPTH_SIZE, m_depth_size); GET_STATE(GL_RENDERBUFFER_STENCIL_SIZE, m_stencil_size); #undef GET_STATE return true; }
mutex::mutex(unsigned int spin_count, bool recursive) { VOGL_NOTE_UNUSED(spin_count); pthread_mutexattr_t mta; int status = pthread_mutexattr_init(&mta); if (status) { dynamic_string msg(cVarArg, "%s: pthread_mutexattr_init() failed with status %i", VOGL_METHOD_NAME, status); vogl_fail(msg.get_ptr(), __FILE__, __LINE__); } status = pthread_mutexattr_settype(&mta, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); if (status) { dynamic_string msg(cVarArg, "%s: pthread_mutexattr_settype() failed with status %i", VOGL_METHOD_NAME, status); vogl_fail(msg.get_ptr(), __FILE__, __LINE__); } status = pthread_mutex_init(&m_mutex, &mta); if (status) { dynamic_string msg(cVarArg, "%s: pthread_mutex_init() failed with status %i", VOGL_METHOD_NAME, status); vogl_fail(msg.get_ptr(), __FILE__, __LINE__); } #ifdef VOGL_BUILD_DEBUG m_lock_count = 0; #endif }
bool vogl_vao_state::serialize(json_node &node, vogl_blob_manager &blob_manager) const { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(blob_manager); if (!m_is_valid) return false; node.add_key_value("handle", m_snapshot_handle); node.add_key_value("has_been_bound", m_has_been_bound); node.add_key_value("element_array_binding", m_element_array_binding); json_node &vertex_attribs_array = node.add_array("vertex_attribs"); for (uint32_t i = 0; i < m_vertex_attribs.size(); i++) { const vogl_vertex_attrib_desc &desc = m_vertex_attribs[i]; json_node &attribs_obj = vertex_attribs_array.add_object(); attribs_obj.add_key_value("pointer", desc.m_pointer); attribs_obj.add_key_value("array_binding", desc.m_array_binding); attribs_obj.add_key_value("size", desc.m_size); attribs_obj.add_key_value("type", get_gl_enums().find_gl_name(desc.m_type)); attribs_obj.add_key_value("stride", desc.m_stride); attribs_obj.add_key_value("integer", desc.m_integer); attribs_obj.add_key_value("divisor", desc.m_divisor); attribs_obj.add_key_value("enabled", desc.m_enabled); attribs_obj.add_key_value("normalized", desc.m_normalized); } return true; }
bool vogl_material_state::restore(const vogl_context_info &context_info) const { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(context_info); if (!m_valid) { VOGL_ASSERT_ALWAYS; return false; } VOGL_CHECK_GL_ERROR; #define SET_FLOAT(side, pname) set_material_parameter(side, pname) for (uint s = 0; s < cTotalSides; s++) { SET_FLOAT(s, GL_AMBIENT); SET_FLOAT(s, GL_DIFFUSE); SET_FLOAT(s, GL_SPECULAR); SET_FLOAT(s, GL_EMISSION); SET_FLOAT(s, GL_SHININESS); SET_FLOAT(s, GL_COLOR_INDEXES); } #undef GET_FLOAT return !vogl_check_gl_error(); }
bool file_utils::is_drive_separator(char c) { #if defined(PLATFORM_WINDOWS) return (c == ':'); #else VOGL_NOTE_UNUSED(c); return false; #endif }
bool file_utils::create_directories_from_full_path(const dynamic_string &fullpath) { bool got_unc = false; VOGL_NOTE_UNUSED(got_unc); dynamic_string cur_path; const int l = fullpath.get_len(); int n = 0; while (n < l) { const char c = fullpath.get_ptr()[n]; const bool sep = is_path_separator(c); const bool back_sep = is_path_separator(cur_path.back()); const bool is_last_char = (n == (l - 1)); if (((sep) && (!back_sep)) || (is_last_char)) { if ((is_last_char) && (!sep)) cur_path.append_char(c); bool valid = !cur_path.is_empty(); #if defined(PLATFORM_WINDOWS) // reject obvious stuff (drives, beginning of UNC paths): // c:\b\cool // \\machine\blah // \cool\blah if ((cur_path.get_len() == 2) && (cur_path[1] == ':')) valid = false; else if ((cur_path.get_len() >= 2) && (cur_path[0] == '\\') && (cur_path[1] == '\\')) { if (!got_unc) valid = false; got_unc = true; } else if (cur_path == "\\") valid = false; #endif if (cur_path == "/") valid = false; if (valid) { create_directory(cur_path.get_ptr()); } } cur_path.append_char(c); n++; } return true; }
static void check(const char *pFile_line) { VOGL_ASSERT(g_heap_initialized); VOGL_NOTE_UNUSED(pFile_line); #if VOGL_MALLOC_DEBUGGING lock_heap(); Rmalloc_test(pFile_line); unlock_heap(); #endif }
int main(int argc, char *argv[]) { VOGL_NOTE_UNUSED(argc); VOGL_NOTE_UNUSED(argv); printf("libbacktrace_test: hello world!\n\n"); foo_static(); printf("\n"); // Update btrace with our gl info. btrace_get_glinfo().version_str = "version string here"; btrace_get_glinfo().glsl_version_str = "glsl version 4 billion"; btrace_get_glinfo().vendor_str = "vendor"; btrace_get_glinfo().renderer_str = "renderer_str"; vogl::json_document cur_doc; btrace_get_machine_info(cur_doc.get_root()); cur_doc.print(true, 0, 0); }
static void free_block(void *p, const char *pFile_line) { VOGL_ASSERT(g_heap_initialized); VOGL_NOTE_UNUSED(pFile_line); #if VOGL_MALLOC_DEBUGGING lock_heap(); Rfree(p, pFile_line); unlock_heap(); #else free(p); #endif }
void plat_virtual_free(void* free_addr, size_t size) { VOGL_NOTE_UNUSED(size); if (VirtualFree(free_addr, 0, MEM_RELEASE) == FALSE) { VOGL_VERIFY(!"Failed to deallocate a system page. A debug session is needed."); char buf[256]; sprintf(buf, "VirtualFree failed. TODO: Better messaging!"); fwrite(buf, strlen(buf), 1, stderr); abort(); } }
static void print_stats(const char *pFile_line) { VOGL_ASSERT(g_pHeap); #if VOGL_MALLOC_DEBUGGING lock_heap(); Rmalloc_stat(pFile_line); unlock_heap(); #else VOGL_NOTE_UNUSED(pFile_line); #endif }
static void free_block(void *p, const char *pFile_line) { VOGL_ASSERT(g_pHeap); lock_heap(); #if VOGL_MALLOC_DEBUGGING Rfree(p, pFile_line); #else VOGL_NOTE_UNUSED(pFile_line); stbm_free(NULL, g_pHeap, p); #endif unlock_heap(); }
static void *sys_alloc(void *user_context, size_t size_requested, size_t *size_provided) { VOGL_NOTE_UNUSED(user_context); if (!g_page_size) { g_page_size = static_cast<size_t>(plat_get_virtual_page_size()); if (!g_page_size) g_page_size = 65536; } size_requested = (size_requested + g_page_size - 1) & (~(g_page_size - 1)); return plat_virtual_alloc(size_requested, PLAT_READ | PLAT_WRITE, size_provided); }
static void *realloc_block(void *p, size_t size, const char *pFile_line) { VOGL_ASSERT(g_heap_initialized); VOGL_NOTE_UNUSED(pFile_line); #if VOGL_MALLOC_DEBUGGING lock_heap(); void *q = Rrealloc(p, size, pFile_line); unlock_heap(); #else void *q = realloc(p, size); #endif return q; }
static size_t msize_block(void *p, const char *pFile_line) { VOGL_ASSERT(g_heap_initialized); VOGL_NOTE_UNUSED(pFile_line); #if VOGL_MALLOC_DEBUGGING lock_heap(); size_t n = Rmalloc_usable_size(p, pFile_line); unlock_heap(); #else size_t n = malloc_usable_size(p); #endif return n; }
static void *realloc_block(void *p, size_t size, const char *pFile_line) { VOGL_ASSERT(g_pHeap); lock_heap(); #if VOGL_MALLOC_DEBUGGING void *q = Rrealloc(p, size, pFile_line); #else VOGL_NOTE_UNUSED(pFile_line); void *q = stbm_realloc(NULL, g_pHeap, p, size, 0); #endif unlock_heap(); return q; }
static size_t msize_block(void *p, const char *pFile_line) { VOGL_ASSERT(g_pHeap); lock_heap(); #if VOGL_MALLOC_DEBUGGING size_t n = Rmalloc_usable_size(p, pFile_line); #else VOGL_NOTE_UNUSED(pFile_line); size_t n = stbm_get_allocation_size(p); #endif unlock_heap(); return n; }
bool vogl_vao_state::deserialize(const json_node &node, const vogl_blob_manager &blob_manager) { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(blob_manager); clear(); m_snapshot_handle = node.value_as_uint32("handle"); m_has_been_bound = node.value_as_bool("has_been_bound", true); m_element_array_binding = node.value_as_uint32("element_array_binding"); const json_node *pVertex_attribs_array = node.find_child_array("vertex_attribs"); if (!pVertex_attribs_array) return false; m_vertex_attribs.resize(pVertex_attribs_array->size()); for (uint32_t i = 0; i < pVertex_attribs_array->size(); i++) { vogl_vertex_attrib_desc &desc = m_vertex_attribs[i]; const json_node *pAttribs_obj = pVertex_attribs_array->get_value_as_object(i); if (!pAttribs_obj) return false; desc.m_pointer = static_cast<vogl_trace_ptr_value>(pAttribs_obj->value_as_uint64("pointer")); // Fallback for old traces if ((!i) && (pAttribs_obj->has_key("element_array_binding"))) m_element_array_binding = pAttribs_obj->value_as_uint32("element_array_binding"); desc.m_array_binding = pAttribs_obj->value_as_uint32("array_binding"); desc.m_size = pAttribs_obj->value_as_int("size"); desc.m_type = vogl_get_json_value_as_enum(*pAttribs_obj, "type"); desc.m_stride = pAttribs_obj->value_as_int("stride"); desc.m_integer = pAttribs_obj->value_as_bool("integer"); desc.m_divisor = pAttribs_obj->value_as_uint32("divisor"); desc.m_enabled = pAttribs_obj->value_as_bool("enabled"); desc.m_normalized = pAttribs_obj->value_as_bool("normalized"); } m_is_valid = true; return true; }
bool vogl_material_state::snapshot(const vogl_context_info &context_info) { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(context_info); clear(); VOGL_CHECK_GL_ERROR; bool any_gl_errors = false; #define GET_FLOAT(side, pname) \ do \ { \ float values[4] = { 0, 0, 0, 0 }; \ GL_ENTRYPOINT(glGetMaterialfv)(get_face(side), pname, values); \ if (vogl_check_gl_error()) \ any_gl_errors = true; \ m_params[side].insert(pname, 0, values, sizeof(values[0])); \ } while (0) for (uint s = 0; s < cTotalSides; s++) { GET_FLOAT(s, GL_AMBIENT); GET_FLOAT(s, GL_DIFFUSE); GET_FLOAT(s, GL_SPECULAR); GET_FLOAT(s, GL_EMISSION); GET_FLOAT(s, GL_SHININESS); GET_FLOAT(s, GL_COLOR_INDEXES); } #undef GET_FLOAT if (any_gl_errors) { clear(); vogl_error_printf("%s: GL error while enumerating material params\n", VOGL_METHOD_NAME); return false; } m_valid = true; return true; }
static void *malloc_block(size_t size, const char *pFile_line) { // If you hit this assert, it's most likely because vogl_core_init() // (which calls vogl_init_heap) hasn't been called. VOGL_ASSERT(g_pHeap); lock_heap(); #if VOGL_MALLOC_DEBUGGING void *p = Rmalloc(size, pFile_line); #else VOGL_NOTE_UNUSED(pFile_line); void *p = stbm_alloc(NULL, g_pHeap, size, 0); #endif unlock_heap(); return p; }
bool vogl_renderbuffer_desc::restore(const vogl_context_info &context_info) const { VOGL_FUNC_TRACER VOGL_NOTE_UNUSED(context_info); if (!m_width) return false; VOGL_ASSERT(context_info.get_version() >= VOGL_GL_VERSION_3_0); VOGL_CHECK_GL_ERROR; GL_ENTRYPOINT(glRenderbufferStorageMultisample)(GL_RENDERBUFFER, m_samples, m_internal_format, m_width, m_height); bool prev_gl_error = vogl_check_gl_error(); VOGL_ASSERT(!prev_gl_error); return !prev_gl_error; }