int xoffset, int yoffset, int zoffset,
int width, int height, int depth,
GLenum format, GLenum type, const void *pixels,
- bool allocate_storage, bool create_pbo,
+ bool create_pbo,
const struct gl_pixelstore_attrib *packing)
{
struct gl_buffer_object *pbo = NULL;
- GLuint pbo_tex = 0, fbos[2] = { 0, 0 };
- struct gl_framebuffer *readFb;
- struct gl_framebuffer *drawFb;
+ GLuint pbo_tex = 0;
+ struct gl_framebuffer *readFb = NULL;
+ struct gl_framebuffer *drawFb = NULL;
int image_height;
struct gl_texture_image *pbo_tex_image;
GLenum status;
*/
image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight;
+ _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
+ MESA_META_PIXEL_STORE));
+
pbo_tex_image = create_texture_for_pbo(ctx, create_pbo,
GL_PIXEL_UNPACK_BUFFER,
dims, width, height, depth,
format, type, pixels, packing,
&pbo, &pbo_tex);
- if (!pbo_tex_image)
+ if (!pbo_tex_image) {
+ _mesa_meta_end(ctx);
return false;
+ }
- if (allocate_storage)
- ctx->Driver.AllocTextureImageBuffer(ctx, tex_image);
-
- _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
- MESA_META_PIXEL_STORE));
-
- _mesa_CreateFramebuffers(2, fbos);
-
- readFb = _mesa_lookup_framebuffer(ctx, fbos[0]);
- assert(readFb != NULL && readFb->Name == fbos[0]);
+ readFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (readFb == NULL)
+ goto fail;
- drawFb = _mesa_lookup_framebuffer(ctx, fbos[1]);
- assert(drawFb != NULL && drawFb->Name == fbos[1]);
+ drawFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (drawFb == NULL)
+ goto fail;
_mesa_bind_framebuffers(ctx, drawFb, tex_image ? readFb : ctx->ReadBuffer);
if (status != GL_FRAMEBUFFER_COMPLETE)
goto fail;
+ /* Explicitly disable sRGB encoding */
+ ctx->DrawBuffer->Visual.sRGBCapable = false;
+
_mesa_update_state(ctx);
if (_mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
success = true;
fail:
- _mesa_DeleteFramebuffers(2, fbos);
+ _mesa_reference_framebuffer(&readFb, NULL);
+ _mesa_reference_framebuffer(&drawFb, NULL);
_mesa_DeleteTextures(1, &pbo_tex);
_mesa_reference_buffer_object(ctx, &pbo, NULL);
const struct gl_pixelstore_attrib *packing)
{
struct gl_buffer_object *pbo = NULL;
- GLuint pbo_tex = 0, fbos[2] = { 0, 0 };
+ GLuint pbo_tex = 0;
struct gl_framebuffer *readFb;
struct gl_framebuffer *drawFb;
int image_height;
*/
image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight;
+ _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
+ MESA_META_PIXEL_STORE));
+
pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,
dims, width, height, depth,
format, type, pixels, packing,
&pbo, &pbo_tex);
- if (!pbo_tex_image)
- return false;
- _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER |
- MESA_META_PIXEL_STORE));
+ if (!pbo_tex_image) {
+ _mesa_meta_end(ctx);
+ return false;
+ }
/* GL_CLAMP_FRAGMENT_COLOR doesn't affect ReadPixels and GettexImage */
if (ctx->Extensions.ARB_color_buffer_float)
_mesa_ClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
- _mesa_CreateFramebuffers(2, fbos);
-
- readFb = _mesa_lookup_framebuffer(ctx, fbos[0]);
- assert(readFb != NULL && readFb->Name == fbos[0]);
+ readFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (readFb == NULL)
+ goto fail;
- drawFb = _mesa_lookup_framebuffer(ctx, fbos[1]);
- assert(drawFb != NULL && drawFb->Name == fbos[1]);
+ drawFb = ctx->Driver.NewFramebuffer(ctx, 0xDEADBEEF);
+ if (drawFb == NULL)
+ goto fail;
if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
assert(depth == 1);
if (status != GL_FRAMEBUFFER_COMPLETE)
goto fail;
+ /* Explicitly disable sRGB encoding */
+ ctx->DrawBuffer->Visual.sRGBCapable = false;
+
_mesa_update_state(ctx);
if (_mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
success = true;
fail:
- _mesa_DeleteFramebuffers(2, fbos);
+ _mesa_reference_framebuffer(&drawFb, NULL);
+ _mesa_reference_framebuffer(&readFb, NULL);
_mesa_DeleteTextures(1, &pbo_tex);
_mesa_reference_buffer_object(ctx, &pbo, NULL);