X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Frenderbuffer.c;h=b0d4c8cca264f8c2967946564af369b2fd9851c9;hb=555f67c3d717a52464b517cd6d9874468ab3bd92;hp=1bb09bfe6a18ff413aa21fef0f8fa7f10f0c721f;hpb=59a5b5a193d5d9c5776aa586b34657b6e315479d;p=mesa.git diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 1bb09bfe6a1..b0d4c8cca26 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 6.5 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * @@ -17,9 +16,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ @@ -38,7 +38,9 @@ void _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) { - _glthread_INIT_MUTEX(rb->Mutex); + GET_CURRENT_CONTEXT(ctx); + + mtx_init(&rb->Mutex, mtx_plain); rb->ClassID = 0; rb->Name = name; @@ -52,7 +54,24 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) rb->Width = 0; rb->Height = 0; - rb->InternalFormat = GL_RGBA; + rb->Depth = 0; + + /* In GL 3, the initial format is GL_RGBA according to Table 6.26 + * on page 302 of the GL 3.3 spec. + * + * In GLES 3, the initial format is GL_RGBA4 according to Table 6.15 + * on page 258 of the GLES 3.0.4 spec. + * + * If the context is current, set the initial format based on the + * specs. If the context is not current, we cannot determine the + * API, so default to GL_RGBA. + */ + if (ctx && _mesa_is_gles3(ctx)) { + rb->InternalFormat = GL_RGBA4; + } else { + rb->InternalFormat = GL_RGBA; + } + rb->Format = MESA_FORMAT_NONE; } @@ -75,11 +94,16 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) /** * Delete a gl_framebuffer. * This is the default function for renderbuffer->Delete(). + * Drivers which subclass gl_renderbuffer should probably implement their + * own delete function. But the driver might also call this function to + * free the object in the end. */ void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) +_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { - /* no-op */ + mtx_destroy(&rb->Mutex); + free(rb->Label); + free(rb); } @@ -147,15 +171,15 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, GLboolean deleteFlag = GL_FALSE; struct gl_renderbuffer *oldRb = *ptr; - _glthread_LOCK_MUTEX(oldRb->Mutex); - ASSERT(oldRb->RefCount > 0); + mtx_lock(&oldRb->Mutex); + assert(oldRb->RefCount > 0); oldRb->RefCount--; - /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ deleteFlag = (oldRb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldRb->Mutex); + mtx_unlock(&oldRb->Mutex); if (deleteFlag) { - oldRb->Delete(oldRb); + GET_CURRENT_CONTEXT(ctx); + oldRb->Delete(ctx, oldRb); } *ptr = NULL; @@ -164,10 +188,9 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, if (rb) { /* reference new renderbuffer */ - _glthread_LOCK_MUTEX(rb->Mutex); + mtx_lock(&rb->Mutex); rb->RefCount++; - /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ - _glthread_UNLOCK_MUTEX(rb->Mutex); + mtx_unlock(&rb->Mutex); *ptr = rb; } }