vrend, formats: Check whether the host supports mixed color attachments

To avoid that the guest sends mixed color attachments when this is not
supported test this and add an according caps flag.

Related: #88 (a full fix needs a mesa side patch to make use of the
         flag sent)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Gert Wollny 6 years ago committed by Dave Airlie
parent 11ed01f69d
commit c4db1be860
  1. 1
      src/virgl_hw.h
  2. 29
      src/vrend_formats.c
  3. 3
      src/vrend_renderer.c
  4. 2
      src/vrend_renderer.h

@ -239,6 +239,7 @@ enum virgl_formats {
#define VIRGL_CAP_SRGB_WRITE_CONTROL (1 << 15)
#define VIRGL_CAP_QBO (1 << 16)
#define VIRGL_CAP_TRANSFER (1 << 17)
#define VIRGL_CAP_FBO_MIXED_COLOR_FORMATS (1 << 18)
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
* but are fixed, no other should be passed to virgl either.

@ -501,6 +501,35 @@ void vrend_check_texture_storage(struct vrend_format_table *table)
}
}
bool vrend_check_fremabuffer_mixed_color_attachements()
{
GLuint tex_id[2];
GLuint fb_id;
bool retval = false;
glGenTextures(2, tex_id);
glGenFramebuffers(1, &fb_id);
glBindTexture(GL_TEXTURE_2D, tex_id[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindFramebuffer(GL_FRAMEBUFFER, fb_id);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex_id[0], 0);
glBindTexture(GL_TEXTURE_2D, tex_id[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 32, 32, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, tex_id[1], 0);
retval = glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
glDeleteFramebuffers(1, &fb_id);
glDeleteTextures(2, tex_id);
return retval;
}
unsigned vrend_renderer_query_multisample_caps(unsigned max_samples, struct virgl_caps_v2 *caps)
{
GLuint tex;

@ -8588,6 +8588,9 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c
caps->v2.capability_bits |= VIRGL_CAP_QBO;
caps->v2.capability_bits |= VIRGL_CAP_TRANSFER;
if (vrend_check_fremabuffer_mixed_color_attachements())
caps->v2.capability_bits |= VIRGL_CAP_FBO_MIXED_COLOR_FORMATS;
}
void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,

@ -112,6 +112,8 @@ struct vrend_if_cbs {
int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags);
void vrend_insert_format(struct vrend_format_table *entry, uint32_t bindings);
bool vrend_check_fremabuffer_mixed_color_attachements(void);
void vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entry, uint32_t bindings, uint8_t swizzle[4]);
const struct vrend_format_table *vrend_get_format_table_entry(enum virgl_formats format);
int vrend_create_shader(struct vrend_context *ctx,

Loading…
Cancel
Save