Skip to content

Commit

Permalink
fix opengl error when screenshotting with msaa off (#1795)
Browse files Browse the repository at this point in the history
  • Loading branch information
water111 authored Aug 24, 2022
1 parent be654b9 commit d7af0f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion decompiler/types2/ForwardProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,8 @@ void types2_for_add(types2::Type& type_out,
TP_Type::make_from_ts(coerce_to_reg_type(filtered_results.front().result_type));
return;
} else {
ASSERT(false);
types2_from_ambiguous_deref(output_instr, type_out, filtered_results, extras.tags_locked);
return;
}
}

Expand Down
10 changes: 7 additions & 3 deletions game/graphics/opengl_renderer/OpenGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,18 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) {

if (settings.save_screenshot) {
Fbo* screenshot_src;
int read_buffer;

// can't screenshot from a multisampled buffer directly -
if (m_fbo_state.resources.resolve_buffer.valid) {
screenshot_src = &m_fbo_state.resources.resolve_buffer;
read_buffer = GL_COLOR_ATTACHMENT0;
} else {
screenshot_src = m_fbo_state.render_fbo;
read_buffer = GL_FRONT;
}
finish_screenshot(settings.screenshot_path, screenshot_src->width, screenshot_src->height, 0, 0,
screenshot_src->fbo_id);
screenshot_src->fbo_id, read_buffer);
}
if (settings.gpu_sync) {
glFinish();
Expand Down Expand Up @@ -709,13 +712,14 @@ void OpenGLRenderer::finish_screenshot(const std::string& output_name,
int height,
int x,
int y,
GLuint fbo) {
GLuint fbo,
int read_buffer) {
std::vector<u32> buffer(width * height);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
GLint oldbuf;
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &oldbuf);
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glReadBuffer(read_buffer);
glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data());
// flip upside down in place
for (int h = 0; h < height / 2; h++) {
Expand Down
8 changes: 7 additions & 1 deletion game/graphics/opengl_renderer/OpenGLRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ class OpenGLRenderer {
void do_pcrtc_effects(float alp, SharedRenderState* render_state, ScopedProfilerNode& prof);
void init_bucket_renderers();
void draw_renderer_selection_window();
void finish_screenshot(const std::string& output_name, int px, int py, int x, int y, GLuint fbo);
void finish_screenshot(const std::string& output_name,
int px,
int py,
int x,
int y,
GLuint fbo,
int read_buffer);
template <typename T, class... Args>
T* init_bucket_renderer(const std::string& name,
BucketCategory cat,
Expand Down

0 comments on commit d7af0f0

Please sign in to comment.