mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Replaces `std::shared_pointer` with `stx::atomic_ptr` and `stx::shared_ptr`. Notes to programmers: * This pr kills the use of `dynamic_cast`, `std::dynamic_pointer_cast` and `std::weak_ptr` on IDM objects, possible replacement is to save the object ID on the base object, then use idm::check/get_unlocked to the destination type via the saved ID which may be null. Null pointer check is how you can tell type mismatch (as dynamic cast) or object destruction (as weak_ptr locking). * Double-inheritance on IDM objects should be used with care, `stx::shared_ptr` does not support constant-evaluated pointer offsetting to parent/child type. * `idm::check/get_unlocked` can now be used anywhere. Misc fixes: * Fixes some segfaults with RPCN with interaction with IDM. * Fix deadlocks in access violation handler due locking recursion. * Fixes race condition in process exit-spawn on memory containers read. * Fix bug that theoretically can prevent RPCS3 from booting - fix `id_manager::typeinfo` comparison to compare members instead of `memcmp` which can fail spuriously on padding bytes. * Ensure all IDM inherited types of base, either has `id_base` or `id_type` defined locally, this allows to make getters such as `idm::get_unlocked<lv2_socket, lv2_socket_raw>()` which were broken before. (requires save-states invalidation) * Removes broken operator[] overload of `stx::shared_ptr` and `stx::single_ptr` for non-array types.
128 lines
3.6 KiB
C++
128 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include "Emu/system_config_types.h"
|
|
#include "util/types.hpp"
|
|
#include "../Common/simple_array.hpp"
|
|
#include "../Overlays/overlays.h"
|
|
#include "GLTexture.h"
|
|
|
|
#include "glutils/fbo.h"
|
|
#include "glutils/program.h"
|
|
#include "glutils/vao.hpp"
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace gl
|
|
{
|
|
struct overlay_pass
|
|
{
|
|
std::string fs_src;
|
|
std::string vs_src;
|
|
|
|
gl::glsl::program program_handle;
|
|
gl::glsl::shader vs;
|
|
gl::glsl::shader fs;
|
|
|
|
gl::fbo fbo;
|
|
gl::sampler_state m_sampler;
|
|
|
|
gl::vao m_vao;
|
|
gl::buffer m_vertex_data_buffer;
|
|
|
|
bool compiled = false;
|
|
|
|
u32 num_drawable_elements = 4;
|
|
GLenum primitives = GL_TRIANGLE_STRIP;
|
|
gl::filter m_input_filter = gl::filter::nearest;
|
|
|
|
u32 m_write_aspect_mask = gl::image_aspect::color | gl::image_aspect::depth;
|
|
bool enable_depth_writes = false;
|
|
bool enable_stencil_writes = false;
|
|
|
|
virtual ~overlay_pass() = default;
|
|
|
|
void create();
|
|
void destroy();
|
|
|
|
virtual void on_load() {}
|
|
virtual void on_unload() {}
|
|
|
|
virtual void bind_resources() {}
|
|
virtual void cleanup_resources() {}
|
|
|
|
template <typename T>
|
|
void upload_vertex_data(T* data, u32 elements_count)
|
|
{
|
|
m_vertex_data_buffer.data(elements_count * sizeof(T), data);
|
|
}
|
|
|
|
virtual void emit_geometry();
|
|
|
|
void run(gl::command_context& cmd, const areau& region, GLuint target_texture, GLuint image_aspect_bits, bool enable_blending = false);
|
|
};
|
|
|
|
struct ui_overlay_renderer final : public overlay_pass
|
|
{
|
|
u32 num_elements = 0;
|
|
std::vector<std::unique_ptr<gl::texture>> resources;
|
|
std::unordered_map<u64, std::pair<u32, std::unique_ptr<gl::texture>>> temp_image_cache;
|
|
std::unordered_map<u64, std::unique_ptr<gl::texture_view>> temp_view_cache;
|
|
std::unordered_map<u64, std::unique_ptr<gl::texture>> font_cache;
|
|
std::unordered_map<u64, std::unique_ptr<gl::texture_view>> view_cache;
|
|
rsx::overlays::primitive_type m_current_primitive_type = rsx::overlays::primitive_type::quad_list;
|
|
|
|
ui_overlay_renderer();
|
|
|
|
gl::texture_view* load_simple_image(rsx::overlays::image_info* desc, bool temp_resource, u32 owner_uid);
|
|
|
|
void create();
|
|
void destroy();
|
|
|
|
void remove_temp_resources(u64 key);
|
|
|
|
gl::texture_view* find_font(rsx::overlays::font* font);
|
|
|
|
gl::texture_view* find_temp_image(rsx::overlays::image_info* desc, u32 owner_uid);
|
|
|
|
void set_primitive_type(rsx::overlays::primitive_type type);
|
|
|
|
void emit_geometry() override;
|
|
|
|
void run(gl::command_context& cmd, const areau& viewport, GLuint target, rsx::overlays::overlay& ui);
|
|
};
|
|
|
|
struct video_out_calibration_pass final : public overlay_pass
|
|
{
|
|
video_out_calibration_pass();
|
|
|
|
void run(gl::command_context& cmd, const areau& viewport, const rsx::simple_array<GLuint>& source, f32 gamma, bool limited_rgb, stereo_render_mode_options stereo_mode, gl::filter input_filter);
|
|
};
|
|
|
|
struct rp_ssbo_to_generic_texture final : public overlay_pass
|
|
{
|
|
rp_ssbo_to_generic_texture();
|
|
void run(gl::command_context& cmd, const buffer* src, texture* dst, const u32 src_offset, const coordu& dst_region, const pixel_buffer_layout& layout);
|
|
void run(gl::command_context& cmd, const buffer* src, const texture_view* dst, const u32 src_offset, const coordu& dst_region, const pixel_buffer_layout& layout);
|
|
};
|
|
|
|
// TODO: Replace with a proper manager
|
|
extern std::unordered_map<u32, std::unique_ptr<gl::overlay_pass>> g_overlay_passes;
|
|
|
|
template<class T>
|
|
T* get_overlay_pass()
|
|
{
|
|
u32 index = stx::typeindex<id_manager::typeinfo, T>();
|
|
auto &e = g_overlay_passes[index];
|
|
|
|
if (!e)
|
|
{
|
|
e = std::make_unique<T>();
|
|
e->create();
|
|
}
|
|
|
|
return static_cast<T*>(e.get());
|
|
}
|
|
|
|
void destroy_overlay_passes();
|
|
}
|