X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fframebuffer.c;h=42da176784351fbc9f800abbb9d5e94575a25a7f;hb=fd17de21231fb41804299d16f837c07798984411;hp=56558cfcc1edf43de3b7b247f0343edcd009c217;hpb=afe125e0a18ac3886c45c7e6b02b122fb2d327b5;p=mesa.git diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 56558cfcc1e..42da1767843 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -75,7 +75,6 @@ compute_depth_max(struct gl_framebuffer *fb) fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; } - /** * Create and initialize a gl_framebuffer object. * This is intended for creating _window_system_ framebuffers, not generic @@ -84,7 +83,7 @@ compute_depth_max(struct gl_framebuffer *fb) * \sa _mesa_new_framebuffer */ struct gl_framebuffer * -_mesa_create_framebuffer(const GLvisual *visual) +_mesa_create_framebuffer(const struct gl_config *visual) { struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); assert(visual); @@ -103,7 +102,7 @@ _mesa_create_framebuffer(const GLvisual *visual) * \sa _mesa_create_framebuffer */ struct gl_framebuffer * -_mesa_new_framebuffer(GLcontext *ctx, GLuint name) +_mesa_new_framebuffer(struct gl_context *ctx, GLuint name) { struct gl_framebuffer *fb; (void) ctx; @@ -123,7 +122,7 @@ _mesa_new_framebuffer(GLcontext *ctx, GLuint name) */ void _mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, - const GLvisual *visual) + const struct gl_config *visual) { assert(fb); assert(visual); @@ -233,17 +232,13 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) /** * Set *ptr to point to fb, with refcounting and locking. + * This is normally only called from the _mesa_reference_framebuffer() macro + * when there's a real pointer change. */ void -_mesa_reference_framebuffer(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb) +_mesa_reference_framebuffer_(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb) { - assert(ptr); - if (*ptr == fb) { - /* no change */ - return; - } - if (*ptr) { /* unreference old renderbuffer */ GLboolean deleteFlag = GL_FALSE; @@ -282,7 +277,7 @@ _mesa_reference_framebuffer(struct gl_framebuffer **ptr, * without a currently bound rendering context. */ void -_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb, +_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, GLuint width, GLuint height) { GLuint i; @@ -360,7 +355,7 @@ _mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb, * from device drivers (as was done in the past). */ void -_mesa_resizebuffers( GLcontext *ctx ) +_mesa_resizebuffers( struct gl_context *ctx ) { ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); @@ -373,7 +368,7 @@ _mesa_resizebuffers( GLcontext *ctx ) if (ctx->WinSysDrawBuffer) { GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; + struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; assert(buffer->Name == 0); @@ -390,7 +385,7 @@ _mesa_resizebuffers( GLcontext *ctx ) if (ctx->WinSysReadBuffer && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysReadBuffer; + struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; assert(buffer->Name == 0); @@ -430,7 +425,7 @@ _mesa_ResizeBuffersMESA( void ) * window-system framebuffes. */ static void -update_framebuffer_size(GLcontext *ctx, struct gl_framebuffer *fb) +update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) { GLuint minWidth = ~0, minHeight = ~0; GLuint i; @@ -465,7 +460,7 @@ update_framebuffer_size(GLcontext *ctx, struct gl_framebuffer *fb) * \param ctx the GL context. */ void -_mesa_update_draw_buffer_bounds(GLcontext *ctx) +_mesa_update_draw_buffer_bounds(struct gl_context *ctx) { struct gl_framebuffer *buffer = ctx->DrawBuffer; @@ -523,7 +518,8 @@ _mesa_update_draw_buffer_bounds(GLcontext *ctx) * integer Z values. */ void -_mesa_update_framebuffer_visual(struct gl_framebuffer *fb) +_mesa_update_framebuffer_visual(struct gl_context *ctx, + struct gl_framebuffer *fb) { GLuint i; @@ -543,17 +539,31 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb) const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); const gl_format fmt = rb->Format; - - if (baseFormat == GL_RGBA || baseFormat == GL_RGB || - baseFormat == GL_ALPHA) { + + if (_mesa_is_legal_color_format(ctx, baseFormat)) { fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); fb->Visual.rgbBits = fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits; - fb->Visual.floatMode = GL_FALSE; fb->Visual.samples = rb->NumSamples; + fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0; + if (_mesa_get_format_color_encoding(fmt) == GL_SRGB) + fb->Visual.sRGBCapable = ctx->Const.sRGBCapable; + break; + } + } + } + + fb->Visual.floatMode = GL_FALSE; + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer) { + const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + const gl_format fmt = rb->Format; + + if (_mesa_get_format_datatype(fmt) == GL_FLOAT) { + fb->Visual.floatMode = GL_TRUE; break; } } @@ -601,7 +611,7 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb) * \param attIndex indicates the renderbuffer to possibly wrap */ void -_mesa_update_depth_buffer(GLcontext *ctx, +_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, GLuint attIndex) { @@ -612,14 +622,20 @@ _mesa_update_depth_buffer(GLcontext *ctx, depthRb = fb->Attachment[attIndex].Renderbuffer; - if (depthRb && depthRb->_BaseFormat == GL_DEPTH_STENCIL) { + if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ if (!fb->_DepthBuffer || fb->_DepthBuffer->Wrapped != depthRb || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { /* need to update wrapper */ - struct gl_renderbuffer *wrapper - = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); + struct gl_renderbuffer *wrapper; + + if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb); + } + else { + wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); + } _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); ASSERT(fb->_DepthBuffer->Wrapped == depthRb); } @@ -642,7 +658,7 @@ _mesa_update_depth_buffer(GLcontext *ctx, * \param attIndex indicates the renderbuffer to possibly wrap */ void -_mesa_update_stencil_buffer(GLcontext *ctx, +_mesa_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, GLuint attIndex) { @@ -653,7 +669,7 @@ _mesa_update_stencil_buffer(GLcontext *ctx, stencilRb = fb->Attachment[attIndex].Renderbuffer; - if (stencilRb && stencilRb->_BaseFormat == GL_DEPTH_STENCIL) { + if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ if (!fb->_StencilBuffer || fb->_StencilBuffer->Wrapped != stencilRb @@ -723,7 +739,7 @@ _mesa_update_stencil_buffer(GLcontext *ctx, * writing colors. */ static void -update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) +update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb) { GLuint output; @@ -747,7 +763,7 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. */ static void -update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) +update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) { (void) ctx; if (fb->_ColorReadBufferIndex == -1 || @@ -782,7 +798,7 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) * glRenderbufferStorageEXT. */ static void -update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) +update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) { if (fb->Name == 0) { /* This is a window-system framebuffer */ @@ -793,9 +809,6 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, ctx->Color.DrawBuffer, NULL); } - if (fb->ColorReadBuffer != ctx->Pixel.ReadBuffer) { - - } } else { /* This is a user-created framebuffer. @@ -824,7 +837,7 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) * Update state related to the current draw/read framebuffers. */ void -_mesa_update_framebuffer(GLcontext *ctx) +_mesa_update_framebuffer(struct gl_context *ctx) { struct gl_framebuffer *drawFb; struct gl_framebuffer *readFb; @@ -847,7 +860,7 @@ _mesa_update_framebuffer(GLcontext *ctx) * \return GL_TRUE if buffer exists, GL_FALSE otherwise */ GLboolean -_mesa_source_buffer_exists(GLcontext *ctx, GLenum format) +_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) { const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment; @@ -869,17 +882,29 @@ _mesa_source_buffer_exists(GLcontext *ctx, GLenum format) case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: case GL_INTENSITY: + case GL_RG: case GL_RGB: case GL_BGR: case GL_RGBA: case GL_BGRA: case GL_ABGR_EXT: - case GL_COLOR_INDEX: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: if (ctx->ReadBuffer->_ColorReadBuffer == NULL) { return GL_FALSE; } ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 || _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0); break; case GL_DEPTH: @@ -923,7 +948,7 @@ _mesa_source_buffer_exists(GLcontext *ctx, GLenum format) * XXX could do some code merging w/ above function. */ GLboolean -_mesa_dest_buffer_exists(GLcontext *ctx, GLenum format) +_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) { const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; @@ -950,7 +975,16 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format) case GL_RGBA: case GL_BGRA: case GL_ABGR_EXT: - case GL_COLOR_INDEX: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: /* Nothing special since GL_DRAW_BUFFER could be GL_NONE. */ /* Could assert that colorbuffer has RedBits > 0 */ break; @@ -994,7 +1028,7 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format) * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query. */ GLenum -_mesa_get_color_read_format(GLcontext *ctx) +_mesa_get_color_read_format(struct gl_context *ctx) { switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { case MESA_FORMAT_ARGB8888: @@ -1011,7 +1045,7 @@ _mesa_get_color_read_format(GLcontext *ctx) * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query. */ GLenum -_mesa_get_color_read_type(GLcontext *ctx) +_mesa_get_color_read_type(struct gl_context *ctx) { switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { case MESA_FORMAT_ARGB8888: @@ -1040,12 +1074,12 @@ _mesa_print_framebuffer(const struct gl_framebuffer *fb) for (i = 0; i < BUFFER_COUNT; i++) { const struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; if (att->Type == GL_TEXTURE) { - const struct gl_texture_image *texImage; + const struct gl_texture_image *texImage = + _mesa_get_attachment_teximage_const(att); fprintf(stderr, " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n", i, att->Texture->Name, att->TextureLevel, att->CubeMapFace, att->Zoffset, att->Complete); - texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; fprintf(stderr, " Size: %u x %u x %u Format %s\n", texImage->Width, texImage->Height, texImage->Depth, _mesa_get_format_name(texImage->TexFormat));