formats: rework the logic for identifying which formats can be read back

On OpenGL all textures can be read back using glGetTexture. On GLES
we have to be able to bind the texture to an FBO to use glReadPixels,
and only a few formats are supported as destination formats.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
macos/master
Gert Wollny 3 years ago
parent 30026fd745
commit 11143f2e00
  1. 14
      src/vrend_formats.c

@ -483,6 +483,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
entry = &rg_base_formats[0]; entry = &rg_base_formats[0];
swizzle[0] = swizzle[1] = swizzle[2] = PIPE_SWIZZLE_ZERO; swizzle[0] = swizzle[1] = swizzle[2] = PIPE_SWIZZLE_ZERO;
swizzle[3] = PIPE_SWIZZLE_RED; swizzle[3] = PIPE_SWIZZLE_RED;
break; break;
case VIRGL_FORMAT_A16_UNORM: case VIRGL_FORMAT_A16_UNORM:
entry = &rg_base_formats[2]; entry = &rg_base_formats[2];
@ -523,14 +524,19 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
status = glCheckFramebufferStatus(GL_FRAMEBUFFER); status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
binding = VIRGL_BIND_SAMPLER_VIEW; binding = VIRGL_BIND_SAMPLER_VIEW;
if (status == GL_FRAMEBUFFER_COMPLETE) { if (status == GL_FRAMEBUFFER_COMPLETE)
binding |= is_depth ? VIRGL_BIND_DEPTH_STENCIL : VIRGL_BIND_RENDER_TARGET; binding |= is_depth ? VIRGL_BIND_DEPTH_STENCIL : VIRGL_BIND_RENDER_TARGET;
/* On OpenGL all textures can be read back using glGetTexImage, but on GLES
we have to be able to bind textures to framebuffers, and use glReadPixels
to get the data. And apart from a few formats where support is required
(by the GLES version), we have to query the driver to identify additional
formats that are supported as destination formats by glReadPixels. */
if (is_desktop_gl || if (is_desktop_gl ||
(is_depth && depth_stencil_formats_can_readback(table[i].format)) || (status == GL_FRAMEBUFFER_COMPLETE &&
color_format_can_readback(&table[i], gles_ver)) ((is_depth && depth_stencil_formats_can_readback(table[i].format)) ||
color_format_can_readback(&table[i], gles_ver))))
flags |= VIRGL_TEXTURE_CAN_READBACK; flags |= VIRGL_TEXTURE_CAN_READBACK;
}
glDeleteTextures(1, &tex_id); glDeleteTextures(1, &tex_id);
glDeleteFramebuffers(1, &fb_id); glDeleteFramebuffers(1, &fb_id);

Loading…
Cancel
Save