fix opengl error when screenshotting with msaa off (#1795)

This commit is contained in:
water111 2022-08-23 20:37:59 -04:00 committed by GitHub
parent be654b9398
commit d7af0f0d30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View file

@ -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;
}
}

View file

@ -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();
@ -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++) {

View file

@ -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,