rsx: Reorganize framebuffer setup code

- Fixes some fast paths for framebuffer creation and binding
This commit is contained in:
kd-11 2018-02-02 09:25:30 +03:00
parent 95c6ac699b
commit f20fd217f8
5 changed files with 69 additions and 19 deletions

View file

@ -1414,6 +1414,8 @@ void GLGSRender::do_local_task(bool /*idle*/)
std::lock_guard<std::mutex> lock(queue_guard); std::lock_guard<std::mutex> lock(queue_guard);
if (!work_queue.empty())
{
work_queue.remove_if([](work_item &q) { return q.received; }); work_queue.remove_if([](work_item &q) { return q.received; });
for (work_item& q : work_queue) for (work_item& q : work_queue)
@ -1428,6 +1430,7 @@ void GLGSRender::do_local_task(bool /*idle*/)
lock.unlock(); lock.unlock();
q.cv.notify_one(); q.cv.notify_one();
} }
}
if (m_overlay_cleanup_requests.size()) if (m_overlay_cleanup_requests.size())
{ {

View file

@ -296,6 +296,16 @@ namespace gl
m_id = id; m_id = id;
} }
void fbo::set_extents(size2i extents)
{
m_size = extents;
}
size2i fbo::get_extents() const
{
return m_size;
}
void texture::settings::apply(const texture &texture) const void texture::settings::apply(const texture &texture) const
{ {
save_binding_state save(texture); save_binding_state save(texture);

View file

@ -1921,6 +1921,7 @@ namespace gl
class fbo class fbo
{ {
GLuint m_id = GL_NONE; GLuint m_id = GL_NONE;
size2i m_size;
public: public:
fbo() = default; fbo() = default;
@ -1939,16 +1940,22 @@ namespace gl
class save_binding_state class save_binding_state
{ {
GLint m_last_binding; GLint m_last_binding;
bool reset = true;
public: public:
save_binding_state(const fbo& new_binding) save_binding_state(const fbo& new_binding)
{ {
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_last_binding); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_last_binding);
if (m_last_binding != new_binding.id())
new_binding.bind(); new_binding.bind();
else
reset = false;
} }
~save_binding_state() ~save_binding_state()
{ {
if (reset)
glBindFramebuffer(GL_FRAMEBUFFER, m_last_binding); glBindFramebuffer(GL_FRAMEBUFFER, m_last_binding);
} }
}; };
@ -2093,6 +2100,9 @@ namespace gl
GLuint id() const; GLuint id() const;
void set_id(GLuint id); void set_id(GLuint id);
void set_extents(size2i extents);
size2i get_extents() const;
explicit operator bool() const explicit operator bool() const
{ {
return created(); return created();

View file

@ -223,7 +223,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
if (lg2w > 0 || lg2h > 0) if (lg2w > 0 || lg2h > 0)
{ {
//Something was actually declared for the swizzle context dimensions //Something was actually declared for the swizzle context dimensions
LOG_ERROR(RSX, "Invalid swizzled context depth surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_horizontal, clip_vertical); LOG_WARNING(RSX, "Invalid swizzled context depth surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_horizontal, clip_vertical);
} }
} }
else else
@ -244,7 +244,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
if (lg2w > 0 || lg2h > 0) if (lg2w > 0 || lg2h > 0)
{ {
//Something was actually declared for the swizzle context dimensions //Something was actually declared for the swizzle context dimensions
LOG_ERROR(RSX, "Invalid swizzled context color surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_horizontal, clip_vertical); LOG_WARNING(RSX, "Invalid swizzled context color surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_horizontal, clip_vertical);
} }
} }
else else
@ -284,10 +284,39 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
return; return;
} }
if (draw_fbo)
{
bool really_changed = false;
auto sz = draw_fbo.get_extents();
if (sz.width == clip_horizontal && sz.height == clip_vertical)
{
for (u8 i = 0; i < rsx::limits::color_buffers_count; ++i)
{
if (m_surface_info[i].address != surface_addresses[i])
{
really_changed = true;
break;
}
}
if (!really_changed)
{
if (depth_address == m_depth_surface_info.address)
{
//Nothing has changed, we're still using the same framebuffer
return;
}
}
}
}
m_rtts.prepare_render_target(nullptr, surface_format, depth_format, clip_horizontal, clip_vertical, m_rtts.prepare_render_target(nullptr, surface_format, depth_format, clip_horizontal, clip_vertical,
target, surface_addresses, depth_address); target, surface_addresses, depth_address);
draw_fbo.recreate(); draw_fbo.recreate();
draw_fbo.bind();
draw_fbo.set_extents({ (int)clip_horizontal, (int)clip_vertical });
bool old_format_found = false; bool old_format_found = false;
gl::texture::format old_format; gl::texture::format old_format;
@ -360,8 +389,6 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
if (!framebuffer_status_valid) return; if (!framebuffer_status_valid) return;
check_zcull_status(true, false); check_zcull_status(true, false);
draw_fbo.bind();
set_viewport(); set_viewport();
switch (rsx::method_registers.surface_color_target()) switch (rsx::method_registers.surface_color_target())

View file

@ -2521,7 +2521,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
if (lg2w > 0 || lg2h > 0) if (lg2w > 0 || lg2h > 0)
{ {
//Something was actually declared for the swizzle context dimensions //Something was actually declared for the swizzle context dimensions
LOG_ERROR(RSX, "Invalid swizzled context depth surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_width, clip_height); LOG_WARNING(RSX, "Invalid swizzled context depth surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_width, clip_height);
} }
} }
else else
@ -2542,7 +2542,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
if (lg2w > 0 || lg2h > 0) if (lg2w > 0 || lg2h > 0)
{ {
//Something was actually declared for the swizzle context dimensions //Something was actually declared for the swizzle context dimensions
LOG_ERROR(RSX, "Invalid swizzled context color surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_width, clip_height); LOG_WARNING(RSX, "Invalid swizzled context color surface dims, LG2W=%d, LG2H=%d, clip_w=%d, clip_h=%d", lg2w, lg2h, clip_width, clip_height);
} }
} }
else else
@ -2594,7 +2594,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
{ {
bool really_changed = false; bool really_changed = false;
if (m_draw_fbo->width() == fbo_width && m_draw_fbo->height() == clip_height) if (m_draw_fbo->width() == fbo_width && m_draw_fbo->height() == fbo_height)
{ {
for (u8 i = 0; i < rsx::limits::color_buffers_count; ++i) for (u8 i = 0; i < rsx::limits::color_buffers_count; ++i)
{ {