GNOKII_API gn_error gn_cfg_read_default() { gn_error error = GN_ERR_FAILED; char **config_file_locations = NULL; int num, i; config_file_locations = get_locations(&num); for (i = 0; i < num && error != GN_ERR_NONE; i++) { error = gn_cfg_file_read(config_file_locations[i]); } for (i = 0; i < num; i++) { /* If it couldn't read any config show all filenames tried */ if (error != GN_ERR_NONE) fprintf(stderr, _("Couldn't read %s config file.\n"), config_file_locations[i]); free(config_file_locations[i]); } free(config_file_locations); return error; }
struct int_list *get_ends(char *start, size_t max_len) { return get_locations(start, max_len, '\0'); }
void GLGSRender::read_buffers() { if (!draw_fbo) return; glDisable(GL_STENCIL_TEST); if (g_cfg_rsx_read_color_buffers) { auto color_format = rsx::internals::surface_color_format_to_gl(rsx::method_registers.surface_color()); auto read_color_buffers = [&](int index, int count) { u32 width = rsx::method_registers.surface_clip_width(); u32 height = rsx::method_registers.surface_clip_height(); const std::array<u32, 4> offsets = get_offsets(); const std::array<u32, 4 > locations = get_locations(); const std::array<u32, 4 > pitchs = get_pitchs(); for (int i = index; i < index + count; ++i) { u32 offset = offsets[i]; u32 location = locations[i]; u32 pitch = pitchs[i]; if (!surface_info[i].pitch) continue; rsx::tiled_region color_buffer = get_tiled_address(offset, location & 0xf); u32 texaddr = (u32)((u64)color_buffer.ptr - (u64)vm::base(0)); bool success = m_gl_texture_cache.load_rtt((*std::get<1>(m_rtts.m_bound_render_targets[i])), texaddr, pitch); //Fall back to slower methods if the image could not be fetched from cache. if (!success) { if (!color_buffer.tile) { __glcheck std::get<1>(m_rtts.m_bound_render_targets[i])->copy_from(color_buffer.ptr, color_format.format, color_format.type); } else { u32 range = pitch * height; m_gl_texture_cache.invalidate_range(texaddr, range); std::unique_ptr<u8[]> buffer(new u8[pitch * height]); color_buffer.read(buffer.get(), width, height, pitch); __glcheck std::get<1>(m_rtts.m_bound_render_targets[i])->copy_from(buffer.get(), color_format.format, color_format.type); } } } }; switch (rsx::method_registers.surface_color_target()) { case rsx::surface_target::none: break; case rsx::surface_target::surface_a: read_color_buffers(0, 1); break; case rsx::surface_target::surface_b: read_color_buffers(1, 1); break; case rsx::surface_target::surfaces_a_b: read_color_buffers(0, 2); break; case rsx::surface_target::surfaces_a_b_c: read_color_buffers(0, 3); break; case rsx::surface_target::surfaces_a_b_c_d: read_color_buffers(0, 4); break; } } if (g_cfg_rsx_read_depth_buffer) { //TODO: use pitch u32 pitch = depth_surface_info.pitch; if (!pitch) return; u32 depth_address = rsx::get_address(rsx::method_registers.surface_z_offset(), rsx::method_registers.surface_z_dma()); bool in_cache = m_gl_texture_cache.load_rtt((*std::get<1>(m_rtts.m_bound_depth_stencil)), depth_address, pitch); if (in_cache) return; //Read failed. Fall back to slow s/w path... auto depth_format = rsx::internals::surface_depth_format_to_gl(rsx::method_registers.surface_depth_fmt()); int pixel_size = rsx::internals::get_pixel_size(rsx::method_registers.surface_depth_fmt()); gl::buffer pbo_depth; __glcheck pbo_depth.create(rsx::method_registers.surface_clip_width() * rsx::method_registers.surface_clip_height() * pixel_size); __glcheck pbo_depth.map([&](GLubyte* pixels) { u32 depth_address = rsx::get_address(rsx::method_registers.surface_z_offset(), rsx::method_registers.surface_z_dma()); if (rsx::method_registers.surface_depth_fmt() == rsx::surface_depth_format::z16) { u16 *dst = (u16*)pixels; const be_t<u16>* src = vm::ps3::_ptr<u16>(depth_address); for (int i = 0, end = std::get<1>(m_rtts.m_bound_depth_stencil)->width() * std::get<1>(m_rtts.m_bound_depth_stencil)->height(); i < end; ++i) { dst[i] = src[i]; } } else { u32 *dst = (u32*)pixels; const be_t<u32>* src = vm::ps3::_ptr<u32>(depth_address); for (int i = 0, end = std::get<1>(m_rtts.m_bound_depth_stencil)->width() * std::get<1>(m_rtts.m_bound_depth_stencil)->height(); i < end; ++i) { dst[i] = src[i]; } } }, gl::buffer::access::write); __glcheck std::get<1>(m_rtts.m_bound_depth_stencil)->copy_from(pbo_depth, depth_format.format, depth_format.type); } }