diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 07f5d73..bd23e1b 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.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. diff --git a/src/vrend_formats.c b/src/vrend_formats.c index d9aee7e..61410e6 100644 --- a/src/vrend_formats.c +++ b/src/vrend_formats.c @@ -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; diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 55a7f1b..5611ab9 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -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, diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 9aabe83..51a4c3a 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -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,