#include "st_cb_fbo.h"
#include "st_manager.h"
#include "st_scissor.h"
+#include "st_util.h"
#include "util/u_format.h"
-
-static void
-st_adjust_blit_for_msaa_resolve(struct pipe_blit_info *blit)
-{
- /* Even though we do multisample resolves at the time of the blit, OpenGL
- * specification defines them as if they happen at the time of rendering,
- * which means that the type of averaging we do during the resolve should
- * only depend on the source format; the destination format should be
- * ignored. But, specification doesn't seem to be strict about it.
- *
- * It has been observed that mulitisample resolves produce slightly better
- * looking images when averaging is done using destination format. NVIDIA's
- * proprietary OpenGL driver also follows this approach.
- *
- * When multisampling, if the source and destination formats are equal
- * (aside from the color space), we choose to blit in sRGB space to get
- * this higher quality image.
- */
- if (blit->src.resource->nr_samples > 1 &&
- blit->dst.resource->nr_samples <= 1) {
- blit->dst.format = blit->dst.resource->format;
-
- if (util_format_is_srgb(blit->dst.resource->format))
- blit->src.format = util_format_srgb(blit->src.resource->format);
- else
- blit->src.format = util_format_linear(blit->src.resource->format);
- }
-}
-
static void
st_BlitFramebuffer(struct gl_context *ctx,
struct gl_framebuffer *readFB,
if (mask & GL_COLOR_BUFFER_BIT) {
struct gl_renderbuffer_attachment *srcAtt =
&readFB->Attachment[readFB->_ColorReadBufferIndex];
+ GLuint i;
blit.mask = PIPE_MASK_RGBA;
if (srcAtt->Type == GL_TEXTURE) {
struct st_texture_object *srcObj = st_texture_object(srcAtt->Texture);
- GLuint i;
if (!srcObj || !srcObj->pt) {
return;
}
- for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) {
- struct st_renderbuffer *dstRb =
- st_renderbuffer(drawFB->_ColorDrawBuffers[i]);
-
- if (dstRb) {
- struct pipe_surface *dstSurf = dstRb->surface;
-
- if (dstSurf) {
- blit.dst.resource = dstSurf->texture;
- blit.dst.level = dstSurf->u.tex.level;
- blit.dst.box.z = dstSurf->u.tex.first_layer;
- blit.dst.format = util_format_linear(dstSurf->format);
+ blit.src.resource = srcObj->pt;
+ blit.src.level = srcAtt->TextureLevel;
+ blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace;
+ blit.src.format = srcObj->pt->format;
- blit.src.resource = srcObj->pt;
- blit.src.level = srcAtt->TextureLevel;
- blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace;
- blit.src.format = util_format_linear(srcObj->pt->format);
-
- st_adjust_blit_for_msaa_resolve(&blit);
-
- st->pipe->blit(st->pipe, &blit);
- dstRb->defined = true; /* front buffer tracking */
- }
- }
- }
+ if (!ctx->Color.sRGBEnabled)
+ blit.src.format = util_format_linear(blit.src.format);
}
else {
struct st_renderbuffer *srcRb =
st_renderbuffer(readFB->_ColorReadBuffer);
struct pipe_surface *srcSurf;
- GLuint i;
- if (!srcRb || !srcRb->surface) {
+ if (!srcRb)
+ return;
+
+ st_update_renderbuffer_surface(st, srcRb);
+
+ if (!srcRb->surface)
return;
- }
srcSurf = srcRb->surface;
- for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) {
- struct st_renderbuffer *dstRb =
- st_renderbuffer(drawFB->_ColorDrawBuffers[i]);
+ blit.src.resource = srcSurf->texture;
+ blit.src.level = srcSurf->u.tex.level;
+ blit.src.box.z = srcSurf->u.tex.first_layer;
+ blit.src.format = srcSurf->format;
+ }
+
+ for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) {
+ struct st_renderbuffer *dstRb =
+ st_renderbuffer(drawFB->_ColorDrawBuffers[i]);
- if (dstRb) {
- struct pipe_surface *dstSurf = dstRb->surface;
+ if (dstRb) {
+ struct pipe_surface *dstSurf;
- if (dstSurf) {
- blit.dst.resource = dstSurf->texture;
- blit.dst.level = dstSurf->u.tex.level;
- blit.dst.box.z = dstSurf->u.tex.first_layer;
- blit.dst.format = util_format_linear(dstSurf->format);
+ st_update_renderbuffer_surface(st, dstRb);
- blit.src.resource = srcSurf->texture;
- blit.src.level = srcSurf->u.tex.level;
- blit.src.box.z = srcSurf->u.tex.first_layer;
- blit.src.format = util_format_linear(srcSurf->format);
+ dstSurf = dstRb->surface;
- st_adjust_blit_for_msaa_resolve(&blit);
+ if (dstSurf) {
+ blit.dst.resource = dstSurf->texture;
+ blit.dst.level = dstSurf->u.tex.level;
+ blit.dst.box.z = dstSurf->u.tex.first_layer;
+ blit.dst.format = dstSurf->format;
- st->pipe->blit(st->pipe, &blit);
- dstRb->defined = true; /* front buffer tracking */
- }
+ st->pipe->blit(st->pipe, &blit);
+ dstRb->defined = true; /* front buffer tracking */
}
}
}