diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c index 338577d..dd3c626 100644 --- a/src/vrend_blitter.c +++ b/src/vrend_blitter.c @@ -55,6 +55,7 @@ struct vrend_blitter_ctx { virgl_gl_context gl_context; bool initialised; bool use_gles; + int framebuffer_srgb_enabled; GLuint vaoid; @@ -460,6 +461,10 @@ static void vrend_renderer_init_blit_ctx(struct vrend_blitter_ctx *blit_ctx) blit_ctx->vertices[i][0][3] = 1; /*v.w*/ glBindVertexArray(blit_ctx->vaoid); glBindBuffer(GL_ARRAY_BUFFER, blit_ctx->vbo_id); + + if (!blit_ctx->use_gles) + glEnable(GL_FRAMEBUFFER_SRGB); + blit_ctx->framebuffer_srgb_enabled = true; } static inline GLenum convert_mag_filter(unsigned int filter) @@ -686,7 +691,8 @@ static void calc_dst_deltas_from_src(const struct pipe_blit_info *info, void vrend_renderer_blit_gl(UNUSED struct vrend_context *ctx, struct vrend_resource *src_res, struct vrend_resource *dst_res, - const struct pipe_blit_info *info) + const struct pipe_blit_info *info, + bool has_texture_srgb_decode) { struct vrend_blitter_ctx *blit_ctx = &vrend_blit_ctx; GLuint buffers; @@ -787,6 +793,9 @@ void vrend_renderer_blit_gl(UNUSED struct vrend_context *ctx, to_gl_swizzle(src_entry->swizzle[3])); } + /* Just make sure that no stale state disabled decoding */ + if (has_texture_srgb_decode && util_format_is_srgb(src_res->base.format)) + glTexParameteri(src_res->target, GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -833,4 +842,4 @@ void vrend_renderer_blit_gl(UNUSED struct vrend_context *ctx, GL_TEXTURE_2D, 0, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); -} +} \ No newline at end of file diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index bbc6f15..894eee8 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -7129,7 +7129,8 @@ static void vrend_renderer_blit_int(struct vrend_context *ctx, use_gl = true; if (use_gl) { - vrend_renderer_blit_gl(ctx, src_res, dst_res, info); + vrend_renderer_blit_gl(ctx, src_res, dst_res, info, + has_feature(feat_texture_srgb_decode)); vrend_clicbs->make_current(0, ctx->sub->gl_context); return; } @@ -7248,6 +7249,13 @@ static void vrend_renderer_blit_int(struct vrend_context *ctx, vrend_fb_bind_texture(dst_res, 0, info->dst.level, info->dst.box.z + i); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ctx->sub->blit_fb_ids[1]); + if (!vrend_state.use_gles) { + if (util_format_is_srgb(dst_res->base.format)) + glEnable(GL_FRAMEBUFFER_SRGB); + else + glDisable(GL_FRAMEBUFFER_SRGB); + } + glBindFramebuffer(GL_READ_FRAMEBUFFER, intermediate_fbo); glBlitFramebuffer(info->src.box.x, diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 93185c1..4cdcf66 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -391,7 +391,8 @@ boolean format_is_copy_compatible(enum pipe_format src, enum pipe_format dst); void vrend_renderer_blit_gl(struct vrend_context *ctx, struct vrend_resource *src_res, struct vrend_resource *dst_res, - const struct pipe_blit_info *info); + const struct pipe_blit_info *info, + bool has_texture_srgb_decode); void vrend_renderer_reset(void); int vrend_renderer_get_poll_fd(void);