X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Freadpix.c;h=e8c28d86162886c39e96a34171d8bd35567f9df8;hb=38ab39f6501f78ea7048e8a16a97fdb075b9d8c7;hp=72aa6a3f31531b4bbf5bcf8d02970b96aa28a9e6;hpb=333663f601a7ed83c2cd7b1dc67cfebdb222de0c;p=mesa.git diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 72aa6a3f315..e8c28d86162 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -106,7 +106,8 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context *ctx, /* For blit-based ReadPixels packing, the clamping is done automatically * unless the type is float. */ if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) && - (type == GL_FLOAT || type == GL_HALF_FLOAT)) { + (type == GL_FLOAT || type == GL_HALF_FLOAT || + type == GL_UNSIGNED_INT_10F_11F_11F_REV)) { transferOps |= IMAGE_CLAMP_BIT; } } @@ -114,7 +115,8 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context *ctx, /* For CPU-based ReadPixels packing, the clamping must always be done * for non-float types, */ if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) || - (type != GL_FLOAT && type != GL_HALF_FLOAT)) { + (type != GL_FLOAT && type != GL_HALF_FLOAT && + type != GL_UNSIGNED_INT_10F_11F_11F_REV)) { transferOps |= IMAGE_CLAMP_BIT; } } @@ -232,7 +234,7 @@ readpixels_memcpy(struct gl_context *ctx, format, type, 0, 0); ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); + &map, &stride, ctx->ReadBuffer->FlipY); if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return GL_TRUE; /* don't bother trying the slow path */ @@ -283,7 +285,7 @@ read_uint_depth_pixels( struct gl_context *ctx, return GL_FALSE; ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); + &map, &stride, fb->FlipY); if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); @@ -341,7 +343,7 @@ read_depth_pixels( struct gl_context *ctx, GL_DEPTH_COMPONENT, type, 0, 0); ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); + &map, &stride, fb->FlipY); if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return; @@ -389,7 +391,7 @@ read_stencil_pixels( struct gl_context *ctx, return; ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); + &map, &stride, fb->FlipY); if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return; @@ -460,7 +462,7 @@ read_rgba_pixels( struct gl_context *ctx, /* Map the source render buffer */ ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &rb_stride); + &map, &rb_stride, fb->FlipY); if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return; @@ -650,7 +652,7 @@ fast_read_depth_stencil_pixels(struct gl_context *ctx, return GL_FALSE; ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); + &map, &stride, fb->FlipY); if (!map) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return GL_TRUE; /* don't bother trying the slow path */ @@ -690,14 +692,14 @@ fast_read_depth_stencil_pixels_separate(struct gl_context *ctx, return GL_FALSE; ctx->Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height, - GL_MAP_READ_BIT, &depthMap, &depthStride); + GL_MAP_READ_BIT, &depthMap, &depthStride, fb->FlipY); if (!depthMap) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return GL_TRUE; /* don't bother trying the slow path */ } ctx->Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height, - GL_MAP_READ_BIT, &stencilMap, &stencilStride); + GL_MAP_READ_BIT, &stencilMap, &stencilStride, fb->FlipY); if (!stencilMap) { ctx->Driver.UnmapRenderbuffer(ctx, depthRb); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); @@ -754,7 +756,7 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx, * If one buffer, only map it once. */ ctx->Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height, - GL_MAP_READ_BIT, &depthMap, &depthStride); + GL_MAP_READ_BIT, &depthMap, &depthStride, fb->FlipY); if (!depthMap) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return; @@ -763,7 +765,7 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx, if (stencilRb != depthRb) { ctx->Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height, GL_MAP_READ_BIT, &stencilMap, - &stencilStride); + &stencilStride, fb->FlipY); if (!stencilMap) { ctx->Driver.UnmapRenderbuffer(ctx, depthRb); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); @@ -901,7 +903,7 @@ _mesa_readpixels(struct gl_context *ctx, static GLenum -read_pixels_es3_error_check(GLenum format, GLenum type, +read_pixels_es3_error_check(struct gl_context *ctx, GLenum format, GLenum type, const struct gl_renderbuffer *rb) { const GLenum internalFormat = rb->InternalFormat; @@ -927,6 +929,16 @@ read_pixels_es3_error_check(GLenum format, GLenum type, return GL_NO_ERROR; if (internalFormat == GL_RGB10_A2UI && type == GL_UNSIGNED_BYTE) return GL_NO_ERROR; + if (type == GL_UNSIGNED_SHORT) { + switch (internalFormat) { + case GL_R16: + case GL_RG16: + case GL_RGB16: + case GL_RGBA16: + if (_mesa_has_EXT_texture_norm16(ctx)) + return GL_NO_ERROR; + } + } break; case GL_BGRA: /* GL_EXT_read_format_bgra */ @@ -1049,7 +1061,7 @@ read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, } } } else { - err = read_pixels_es3_error_check(format, type, rb); + err = read_pixels_es3_error_check(ctx, format, type, rb); } if (err != GL_NO_ERROR) { @@ -1125,6 +1137,14 @@ read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, format, type, &clippedPacking, pixels); } +void GLAPIENTRY +_mesa_ReadnPixelsARB_no_error(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLsizei bufSize, + GLvoid *pixels) +{ + read_pixels(x, y, width, height, format, type, bufSize, pixels, true); +} + void GLAPIENTRY _mesa_ReadnPixelsARB(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, @@ -1133,6 +1153,14 @@ _mesa_ReadnPixelsARB(GLint x, GLint y, GLsizei width, GLsizei height, read_pixels(x, y, width, height, format, type, bufSize, pixels, false); } +void GLAPIENTRY +_mesa_ReadPixels_no_error(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels) +{ + _mesa_ReadnPixelsARB_no_error(x, y, width, height, format, type, INT_MAX, + pixels); +} + void GLAPIENTRY _mesa_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)