diff --git a/rpcs3/Emu/RSX/GL/glutils/program.cpp b/rpcs3/Emu/RSX/GL/glutils/program.cpp index 97c46abbb9..e68e4b5132 100644 --- a/rpcs3/Emu/RSX/GL/glutils/program.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/program.cpp @@ -220,7 +220,7 @@ namespace gl return (found->second >= 0); } - auto result = glGetUniformLocation(m_program.id(), name.c_str()); + auto result = glGetUniformLocation(m_program->id(), name.c_str()); locations[name] = result; if (location) @@ -247,7 +247,7 @@ namespace gl } } - auto result = glGetUniformLocation(m_program.id(), name.c_str()); + auto result = glGetUniformLocation(m_program->id(), name.c_str()); if (result < 0) { diff --git a/rpcs3/Emu/RSX/GL/glutils/program.h b/rpcs3/Emu/RSX/GL/glutils/program.h index 5caca0ed98..90dcf6bf1d 100644 --- a/rpcs3/Emu/RSX/GL/glutils/program.h +++ b/rpcs3/Emu/RSX/GL/glutils/program.h @@ -55,7 +55,7 @@ namespace gl const std::string& get_source() const { return source; } - fence get_compile_fence_sync() const { return m_compiled_fence; } + const fence& get_compile_fence_sync() const { return m_compiled_fence; } bool created() const { return m_id != GL_NONE; } @@ -106,29 +106,34 @@ namespace gl class uniforms_t { - program& m_program; + program* m_program = nullptr; std::unordered_map locations; public: uniforms_t(program* program) - : m_program(*program) + : m_program(program) {} + uniforms_t(uniforms_t&&) noexcept = default; + uniforms_t& operator = (uniforms_t&&) noexcept = default; + void clear() { locations.clear(); } bool has_location(const std::string& name, int* location = nullptr); GLint location(const std::string& name); - uniform_t operator[](GLint location) { return{ m_program, location }; } + uniform_t operator[](GLint location) { return{ *m_program, location }; } - uniform_t operator[](const std::string& name) { return{ m_program, location(name) }; } + uniform_t operator[](const std::string& name) { return{ *m_program, location(name) }; } } uniforms{ this }; public: program() = default; + program(const program&) = delete; + program& operator = (const program&) = delete; ~program() { @@ -138,6 +143,13 @@ namespace gl } } + void swap(program&& other) noexcept + { + std::swap(m_id, other.m_id); + std::swap(m_fence, other.m_fence); + std::swap(uniforms, other.uniforms); + } + program& recreate() { remove(); diff --git a/rpcs3/Emu/RSX/GL/glutils/ring_buffer.cpp b/rpcs3/Emu/RSX/GL/glutils/ring_buffer.cpp index 146136e4b4..ac0cc48afe 100644 --- a/rpcs3/Emu/RSX/GL/glutils/ring_buffer.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/ring_buffer.cpp @@ -283,10 +283,10 @@ namespace gl const auto range = utils::address_range32::start_length(start, length); m_barriers.erase(std::remove_if(m_barriers.begin(), m_barriers.end(), [&range](auto& barrier_) { - if (barrier_.range.overlaps(range)) + if (barrier_->range.overlaps(range)) { - barrier_.signal.server_wait_sync(); - barrier_.signal.destroy(); + barrier_->signal.server_wait_sync(); + barrier_->signal.destroy(); return true; } @@ -301,9 +301,9 @@ namespace gl return; } - barrier barrier_; - barrier_.range = utils::address_range32::start_length(start, length); - barrier_.signal.create(); - m_barriers.emplace_back(barrier_); + auto barrier_ = std::make_unique(); + barrier_->range = utils::address_range32::start_length(start, length); + barrier_->signal.create(); + m_barriers.emplace_back(std::move(barrier_)); } } diff --git a/rpcs3/Emu/RSX/GL/glutils/ring_buffer.h b/rpcs3/Emu/RSX/GL/glutils/ring_buffer.h index 37ba0e4bdf..fc9de2aa41 100644 --- a/rpcs3/Emu/RSX/GL/glutils/ring_buffer.h +++ b/rpcs3/Emu/RSX/GL/glutils/ring_buffer.h @@ -92,7 +92,7 @@ namespace gl }; buffer m_storage; - std::vector m_barriers; + std::vector> m_barriers; u64 m_alloc_pointer = 0; void pop_barrier(u32 start, u32 length); diff --git a/rpcs3/Emu/RSX/GL/glutils/sync.hpp b/rpcs3/Emu/RSX/GL/glutils/sync.hpp index 4a39bb6171..cab7d9ae66 100644 --- a/rpcs3/Emu/RSX/GL/glutils/sync.hpp +++ b/rpcs3/Emu/RSX/GL/glutils/sync.hpp @@ -15,6 +15,12 @@ namespace gl fence() = default; ~fence() = default; + fence(const fence&) = delete; + fence& operator = (const fence&) = delete; + + fence(fence&&) noexcept = default; + fence& operator = (fence&&) noexcept = default; + void create() { m_value = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);