1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Mesa 3-D graphics library 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Version: 7.1 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the "Software"), 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to deal in the Software without restriction, including without limitation 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and/or sell copies of the Software, and to permit persons to whom the 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software is furnished to do so, subject to the following conditions: 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be included 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * in all copies or substantial portions of the Software. 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_EXT/ARB_framebuffer_object extensions 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Authors: 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Brian Paul 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "buffers.h" 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "context.h" 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "enums.h" 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "fbobject.h" 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "formats.h" 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "framebuffer.h" 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "glformats.h" 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "hash.h" 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "macros.h" 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "mfeatures.h" 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "mtypes.h" 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "renderbuffer.h" 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "state.h" 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "teximage.h" 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "texobj.h" 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Set this to 1 to debug/log glBlitFramebuffer() calls */ 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define DEBUG_BLIT 0 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Notes: 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * None of the GL_EXT_framebuffer_object functions are compiled into 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * display lists. 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * When glGenRender/FramebuffersEXT() is called we insert pointers to 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * these placeholder objects into the hash table. 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Later, when the object ID is first bound, we replace the placeholder 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * with the real frame/renderbuffer. 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct gl_framebuffer DummyFramebuffer; 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct gl_renderbuffer DummyRenderbuffer; 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* We bind this framebuffer when applications pass a NULL 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * drawable/surface in make current. */ 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct gl_framebuffer IncompleteFramebuffer; 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdelete_dummy_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* no op */ 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdelete_dummy_framebuffer(struct gl_framebuffer *fb) 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* no op */ 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_init_fbobjects(struct gl_context *ctx) 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org DummyFramebuffer.Delete = delete_dummy_framebuffer; 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org DummyRenderbuffer.Delete = delete_dummy_renderbuffer; 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org IncompleteFramebuffer.Delete = delete_dummy_framebuffer; 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gl_framebuffer * 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_get_incomplete_framebuffer(void) 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &IncompleteFramebuffer; 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper routine for getting a gl_renderbuffer. 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gl_renderbuffer * 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb; 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (id == 0) 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = (struct gl_renderbuffer *) 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashLookup(ctx->Shared->RenderBuffers, id); 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return rb; 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper routine for getting a gl_framebuffer. 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gl_framebuffer * 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb; 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (id == 0) 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb = (struct gl_framebuffer *) 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashLookup(ctx->Shared->FrameBuffers, id); 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return fb; 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Mark the given framebuffer as invalid. This will force the 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * test for framebuffer completeness to be done before the framebuffer 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * is used. 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orginvalidate_framebuffer(struct gl_framebuffer *fb) 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = 0; /* "indeterminate" */ 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Return the gl_framebuffer object which corresponds to the given 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * framebuffer target, such as GL_DRAW_FRAMEBUFFER. 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Check support for GL_EXT_framebuffer_blit to determine if certain 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * targets are legal. 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \return gl_framebuffer pointer or NULL if target is illegal 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct gl_framebuffer * 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgget_framebuffer_target(struct gl_context *ctx, GLenum target) 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (target) { 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DRAW_FRAMEBUFFER: 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Extensions.EXT_framebuffer_blit && _mesa_is_desktop_gl(ctx) 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? ctx->DrawBuffer : NULL; 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_READ_FRAMEBUFFER: 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Extensions.EXT_framebuffer_blit && _mesa_is_desktop_gl(ctx) 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? ctx->ReadBuffer : NULL; 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_EXT: 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->DrawBuffer; 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * gl_renderbuffer_attachment object. 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This function is only used for user-created FB objects, not the 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * default / window-system FB object. 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the depth buffer attachment point. 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gl_renderbuffer_attachment * 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum attachment) 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(_mesa_is_user_fbo(fb)); 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (attachment) { 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT0_EXT: 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT1_EXT: 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT2_EXT: 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT3_EXT: 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT4_EXT: 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT5_EXT: 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT6_EXT: 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT7_EXT: 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT8_EXT: 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT9_EXT: 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT10_EXT: 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT11_EXT: 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT12_EXT: 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT13_EXT: 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT14_EXT: 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT15_EXT: 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Only OpenGL ES 1.x forbids color attachments other than 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_COLOR_ATTACHMENT0. For all other APIs the limit set by the 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * hardware is used. 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i = attachment - GL_COLOR_ATTACHMENT0_EXT; 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i >= ctx->Const.MaxColorAttachments 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (i > 0 && ctx->API == API_OPENGLES)) { 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_COLOR0 + i]; 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_STENCIL_ATTACHMENT: 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!_mesa_is_desktop_gl(ctx)) 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* fall-through */ 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_ATTACHMENT_EXT: 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_DEPTH]; 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_ATTACHMENT_EXT: 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_STENCIL]; 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * As above, but only used for getting attachments of the default / 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * window-system framebuffer (not user-created framebuffer objects). 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct gl_renderbuffer_attachment * 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum attachment) 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(_mesa_is_winsys_fbo(fb)); 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (attachment) { 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRONT_LEFT: 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_FRONT_LEFT]; 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRONT_RIGHT: 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_FRONT_RIGHT]; 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_BACK_LEFT: 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_BACK_LEFT]; 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_BACK_RIGHT: 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_BACK_RIGHT]; 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_AUX0: 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->Visual.numAuxBuffers == 1) { 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_AUX0]; 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Page 336 (page 352 of the PDF) of the OpenGL 3.0 spec says: 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If the default framebuffer is bound to target, then attachment must 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * be one of FRONT LEFT, FRONT RIGHT, BACK LEFT, BACK RIGHT, or AUXi, 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * identifying a color buffer; DEPTH, identifying the depth buffer; or 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * STENCIL, identifying the stencil buffer." 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Revision #34 of the ARB_framebuffer_object spec has essentially the same 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * language. However, revision #33 of the ARB_framebuffer_object spec 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * says: 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If the default framebuffer is bound to <target>, then <attachment> 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * must be one of FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, AUXi, 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * DEPTH_BUFFER, or STENCIL_BUFFER, identifying a color buffer, the 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * depth buffer, or the stencil buffer, and <pname> may be 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE or 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FRAMEBUFFER_ATTACHMENT_OBJECT_NAME." 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The enum values for DEPTH_BUFFER and STENCIL_BUFFER have been removed 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * from glext.h, so shipping apps should not use those values. 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note that neither EXT_framebuffer_object nor OES_framebuffer_object 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * support queries of the window system FBO. 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH: 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_DEPTH]; 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL: 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[BUFFER_STENCIL]; 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Remove any texture or renderbuffer attached to the given attachment 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * point. Update reference counts, etc. 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_remove_attachment(struct gl_context *ctx, 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att) 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_TEXTURE) { 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(att->Texture); 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Driver.FinishRenderTexture) { 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tell driver that we're done rendering to this texture. */ 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.FinishRenderTexture(ctx, att); 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(!att->Texture); 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(!att->Texture); 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(!att->Renderbuffer); 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Type = GL_NONE; 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_TRUE; 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Bind a texture object to an attachment point. 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The previous binding, if any, will be removed first. 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_set_texture_attachment(struct gl_context *ctx, 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb, 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att, 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_texture_object *texObj, 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum texTarget, GLuint level, GLuint zoffset) 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Texture == texObj) { 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* re-attaching same texture */ 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(att->Type == GL_TEXTURE); 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Driver.FinishRenderTexture) 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.FinishRenderTexture(ctx, att); 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* new attachment */ 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Driver.FinishRenderTexture && att->Texture) 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.FinishRenderTexture(ctx, att); 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_remove_attachment(ctx, att); 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Type = GL_TEXTURE; 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(!att->Texture); 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_texobj(&att->Texture, texObj); 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* always update these fields */ 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->TextureLevel = level; 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->CubeMapFace = _mesa_tex_target_to_face(texTarget); 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Zoffset = zoffset; 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_get_attachment_teximage(att)) { 358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.RenderTexture(ctx, fb, att); 359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org invalidate_framebuffer(fb); 362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Bind a renderbuffer to an attachment point. 367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The previous binding, if any, will be removed first. 368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_set_renderbuffer_attachment(struct gl_context *ctx, 371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att, 372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb) 373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* XXX check if re-doing same attachment, exit early */ 375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_remove_attachment(ctx, att); 376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Type = GL_RENDERBUFFER_EXT; 377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Texture = NULL; /* just to be safe */ 378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_renderbuffer(&att->Renderbuffer, rb); 380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Fallback for ctx->Driver.FramebufferRenderbuffer() 385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Attach a renderbuffer object to a framebuffer object. 386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_framebuffer_renderbuffer(struct gl_context *ctx, 389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb, 390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum attachment, struct gl_renderbuffer *rb) 391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att; 393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_LOCK_MUTEX(fb->Mutex); 395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = _mesa_get_attachment(ctx, fb, attachment); 397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(att); 398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb) { 399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_set_renderbuffer_attachment(ctx, att, rb); 400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* do stencil attachment here (depth already done above) */ 402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT); 403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att); 404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_set_renderbuffer_attachment(ctx, att, rb); 405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->AttachedAnytime = GL_TRUE; 407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_remove_attachment(ctx, att); 410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org invalidate_framebuffer(fb); 413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_UNLOCK_MUTEX(fb->Mutex); 415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Fallback for ctx->Driver.ValidateFramebuffer() 420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Check if the renderbuffer's formats are supported by the software 421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * renderer. 422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Drivers should probably override this. 423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) 426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org gl_buffer_index buf; 428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (buf = 0; buf < BUFFER_COUNT; buf++) { 429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer *rb = fb->Attachment[buf].Renderbuffer; 430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb) { 431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (rb->_BaseFormat) { 432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA: 433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA: 434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE: 435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY: 436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RED: 437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG: 438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; 439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (rb->Format) { 443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* XXX This list is likely incomplete. */ 444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case MESA_FORMAT_RGB9_E5_FLOAT: 445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; 446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default:; 448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* render buffer format is supported by software rendering */ 449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For debug only. 458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgatt_incomplete(const char *msg) 461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (MESA_DEBUG_FLAGS & DEBUG_INCOMPLETE_FBO) { 463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_debug(NULL, "attachment incomplete: %s\n", msg); 464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For debug only. 470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgfbo_incomplete(const char *msg, int index) 473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (MESA_DEBUG_FLAGS & DEBUG_INCOMPLETE_FBO) { 475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); 476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Is the given base format a legal format for a color renderbuffer? 482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLboolean 484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) 485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (baseFormat) { 487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB: 488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA: 489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_TRUE; 490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE: 491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA: 492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY: 493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA: 494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Extensions.ARB_framebuffer_object; 495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RED: 496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG: 497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Extensions.ARB_texture_rg; 498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_FALSE; 500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Is the given base format a legal format for a depth/stencil renderbuffer? 506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLboolean 508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgis_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat) 509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (baseFormat) { 511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_COMPONENT: 512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_STENCIL_EXT: 513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_TRUE; 514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_FALSE; 516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Test if an attachment point is complete and update its Complete field. 522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \param format if GL_COLOR, this is a color attachment point, 523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * if GL_DEPTH, this is a depth component attachment point, 524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * if GL_STENCIL, this is a stencil component attachment point. 525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtest_attachment_completeness(const struct gl_context *ctx, GLenum format, 528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att) 529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); 531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* assume complete */ 533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_TRUE; 534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Look for reasons why the attachment might be incomplete */ 536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_TEXTURE) { 537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_texture_object *texObj = att->Texture; 538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_texture_image *texImage; 539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum baseFormat; 540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!texObj) { 542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("no texobj"); 543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texImage = texObj->Image[att->CubeMapFace][att->TextureLevel]; 548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!texImage) { 549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("no teximage"); 550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texImage->Width < 1 || texImage->Height < 1) { 554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("teximage width/height=0"); 555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("texobj = %u\n", texObj->Name); 556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("level = %d\n", att->TextureLevel); 557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) { 561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("bad z offset"); 562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 564f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 565f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 566f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org baseFormat = _mesa_get_format_base_format(texImage->TexFormat); 567f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 568f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (format == GL_COLOR) { 569f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!_mesa_is_legal_color_format(ctx, baseFormat)) { 570f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("bad format"); 571f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 572f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 573f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 574f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_format_compressed(texImage->TexFormat)) { 575f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("compressed internalformat"); 576f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 577f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 578f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 579f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 580f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (format == GL_DEPTH) { 581f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (baseFormat == GL_DEPTH_COMPONENT) { 582f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 583f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 584f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (ctx->Extensions.EXT_packed_depth_stencil && 585f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_depth_texture && 586f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org baseFormat == GL_DEPTH_STENCIL_EXT) { 587f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 588f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 589f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 590f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 591f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("bad depth format"); 592f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 593f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 594f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 595f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 596f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(format == GL_STENCIL); 597f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Extensions.EXT_packed_depth_stencil && 598f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_depth_texture && 599f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org baseFormat == GL_DEPTH_STENCIL_EXT) { 600f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 601f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 602f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 603f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* no such thing as stencil-only textures */ 604f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("illegal stencil texture"); 605f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 606f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 607f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 608f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 609f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 610f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_RENDERBUFFER_EXT) { 611f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLenum baseFormat = 612f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_get_format_base_format(att->Renderbuffer->Format); 613f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 614f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(att->Renderbuffer); 615f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!att->Renderbuffer->InternalFormat || 616f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Renderbuffer->Width < 1 || 617f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Renderbuffer->Height < 1) { 618f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("0x0 renderbuffer"); 619f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 620f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 621f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 622f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (format == GL_COLOR) { 623f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!_mesa_is_legal_color_format(ctx, baseFormat)) { 624f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("bad renderbuffer color format"); 625f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 626f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 627f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 628f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 629f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (format == GL_DEPTH) { 630f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (baseFormat == GL_DEPTH_COMPONENT) { 631f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 632f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 633f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (ctx->Extensions.EXT_packed_depth_stencil && 634f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org baseFormat == GL_DEPTH_STENCIL_EXT) { 635f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 636f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 637f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 638f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("bad renderbuffer depth format"); 639f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 640f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 641f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 642f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 643f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 644f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(format == GL_STENCIL); 645f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (baseFormat == GL_STENCIL_INDEX) { 646f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 647f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 648f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (ctx->Extensions.EXT_packed_depth_stencil && 649f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org baseFormat == GL_DEPTH_STENCIL_EXT) { 650f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* OK */ 651f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 652f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 653f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Complete = GL_FALSE; 654f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att_incomplete("bad renderbuffer stencil format"); 655f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 656f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 657f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 658f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 659f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 660f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(att->Type == GL_NONE); 661f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* complete */ 662f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 663f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 664f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 665f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 666f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 667f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 668f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Test if the given framebuffer object is complete and update its 669f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Status field with the results. 670f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Calls the ctx->Driver.ValidateFramebuffer() function to allow the 671f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * driver to make hardware-specific validation/completeness checks. 672f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Also update the framebuffer's Width and Height fields if the 673f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * framebuffer is complete. 674f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 675f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 676f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_test_framebuffer_completeness(struct gl_context *ctx, 677f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb) 678f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 679f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint numImages; 680f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum intFormat = GL_NONE; /* color buffers' internal format */ 681f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0; 682f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint numSamples = -1; 683f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 684f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint j; 685f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 686f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(_mesa_is_user_fbo(fb)); 687f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 688f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* we're changing framebuffer fields here */ 689f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 690f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 691f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org numImages = 0; 692f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->Width = 0; 693f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->Height = 0; 694f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 695f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Start at -2 to more easily loop over all attachment points. 696f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * -2: depth buffer 697f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * -1: stencil buffer 698f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * >=0: color buffer 699f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 700f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { 701f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att; 702f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum f; 703f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org gl_format attFormat; 704f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 705f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 706f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * XXX for ARB_fbo, only check color buffers that are named by 707f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_READ_BUFFER and GL_DRAW_BUFFERi. 708f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 709f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 710f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check for attachment completeness 711f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 712f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i == -2) { 713f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = &fb->Attachment[BUFFER_DEPTH]; 714f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test_attachment_completeness(ctx, GL_DEPTH, att); 715f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!att->Complete) { 716f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; 717f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("depth attachment incomplete", -1); 718f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 719f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 720f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 721f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (i == -1) { 722f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = &fb->Attachment[BUFFER_STENCIL]; 723f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test_attachment_completeness(ctx, GL_STENCIL, att); 724f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!att->Complete) { 725f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; 726f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("stencil attachment incomplete", -1); 727f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 728f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 729f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 730f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 731f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = &fb->Attachment[BUFFER_COLOR0 + i]; 732f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test_attachment_completeness(ctx, GL_COLOR, att); 733f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!att->Complete) { 734f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; 735f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("color attachment incomplete", i); 736f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 737f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 738f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 739f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 740f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* get width, height, format of the renderbuffer/texture 741f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 742f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_TEXTURE) { 743f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_texture_image *texImg = 744f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_get_attachment_teximage(att); 745f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org minWidth = MIN2(minWidth, texImg->Width); 746f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org maxWidth = MAX2(maxWidth, texImg->Width); 747f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org minHeight = MIN2(minHeight, texImg->Height); 748f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org maxHeight = MAX2(maxHeight, texImg->Height); 749f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org f = texImg->_BaseFormat; 750f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org attFormat = texImg->TexFormat; 751f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org numImages++; 752f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!_mesa_is_legal_color_format(ctx, f) && 753f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org !is_legal_depth_format(ctx, f)) { 754f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; 755f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("texture attachment incomplete", -1); 756f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 757f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 758f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 759f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_RENDERBUFFER_EXT) { 760f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org minWidth = MIN2(minWidth, att->Renderbuffer->Width); 761f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org maxWidth = MAX2(minWidth, att->Renderbuffer->Width); 762f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org minHeight = MIN2(minHeight, att->Renderbuffer->Height); 763f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org maxHeight = MAX2(minHeight, att->Renderbuffer->Height); 764f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org f = att->Renderbuffer->InternalFormat; 765f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org attFormat = att->Renderbuffer->Format; 766f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org numImages++; 767f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 768f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 769f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att->Type == GL_NONE); 770f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org continue; 771f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 772f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 773f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Renderbuffer && numSamples < 0) { 774f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* first buffer */ 775f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org numSamples = att->Renderbuffer->NumSamples; 776f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 777f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 778f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if integer color */ 779f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_IntegerColor = _mesa_is_format_integer_color(attFormat); 780f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 781f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Error-check width, height, format, samples 782f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 783f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (numImages == 1) { 784f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* save format, num samples */ 785f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i >= 0) { 786f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intFormat = f; 787f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 788f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 789f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 790f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!ctx->Extensions.ARB_framebuffer_object) { 791f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check that width, height, format are same */ 792f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (minWidth != maxWidth || minHeight != maxHeight) { 793f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; 794f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("width or height mismatch", -1); 795f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 796f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 797f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check that all color buffers are the same format */ 798f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (intFormat != GL_NONE && f != intFormat) { 799f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; 800f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("format mismatch", -1); 801f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 802f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 803f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 804f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Renderbuffer && 805f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Renderbuffer->NumSamples != numSamples) { 806f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; 807f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("inconsistant number of samples", i); 808f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 809f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 810f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 811f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 812f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Check that the format is valid. (MESA_FORMAT_NONE means unsupported) 813f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 814f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_RENDERBUFFER && 815f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Renderbuffer->Format == MESA_FORMAT_NONE) { 816f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; 817f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("unsupported renderbuffer format", i); 818f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 819f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 820f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 821f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 822f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if FEATURE_GL 823f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) { 824f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Check that all DrawBuffers are present */ 825f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { 826f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->ColorDrawBuffer[j] != GL_NONE) { 827f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer_attachment *att 828f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org = _mesa_get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); 829f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att); 830f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_NONE) { 831f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; 832f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("missing drawbuffer", j); 833f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 834f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 835f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 836f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 837f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 838f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Check that the ReadBuffer is present */ 839f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->ColorReadBuffer != GL_NONE) { 840f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer_attachment *att 841f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org = _mesa_get_attachment(ctx, fb, fb->ColorReadBuffer); 842f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att); 843f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_NONE) { 844f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; 845f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("missing readbuffer", -1); 846f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 847f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 848f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 849f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 850f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#else 851f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (void) j; 852f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 853f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 854f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (numImages == 0) { 855f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT; 856f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("no attachments", -1); 857f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 858f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 859f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 860f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Provisionally set status = COMPLETE ... */ 861f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; 862f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 863f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* ... but the driver may say the FB is incomplete. 864f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED 865f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * if anything. 866f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 867f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Driver.ValidateFramebuffer) { 868f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.ValidateFramebuffer(ctx, fb); 869f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { 870f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fbo_incomplete("driver marked FBO as incomplete", -1); 871f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 872f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 873f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 874f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) { 875f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 876f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note that if ARB_framebuffer_object is supported and the attached 877f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * renderbuffers/textures are different sizes, the framebuffer 878f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * width/height will be set to the smallest width/height. 879f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 880f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->Width = minWidth; 881f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->Height = minHeight; 882f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 883f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* finally, update the visual info for the framebuffer */ 884f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_update_framebuffer_visual(ctx, fb); 885f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 886f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 887f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 888f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 889f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLboolean GLAPIENTRY 890f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_IsRenderbufferEXT(GLuint renderbuffer) 891f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 892f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 893f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 894f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (renderbuffer) { 895f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); 896f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb != NULL && rb != &DummyRenderbuffer) 897f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_TRUE; 898f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 899f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_FALSE; 900f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 901f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 902f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 903f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 904f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) 905f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 906f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *newRb; 907f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 908f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 909f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 910f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 911f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target != GL_RENDERBUFFER_EXT) { 912f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)"); 913f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 914f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 915f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 916f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* No need to flush here since the render buffer binding has no 917f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * effect on rendering state. 918f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 919f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 920f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (renderbuffer) { 921f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer); 922f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (newRb == &DummyRenderbuffer) { 923f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* ID was reserved, but no real renderbuffer object made yet */ 924f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newRb = NULL; 925f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 926f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (!newRb && ctx->Extensions.ARB_framebuffer_object) { 927f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* All RB IDs must be Gen'd */ 928f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)"); 929f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 930f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 931f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 932f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!newRb) { 933f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* create new renderbuffer object */ 934f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); 935f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!newRb) { 936f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); 937f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 938f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 939f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(newRb->AllocStorage); 940f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); 941f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newRb->RefCount = 1; /* referenced by hash table */ 942f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 943f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 944f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 945f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newRb = NULL; 946f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 947f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 948f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(newRb != &DummyRenderbuffer); 949f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 950f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); 951f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 952f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 953f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 954f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 955f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * If the given renderbuffer is anywhere attached to the framebuffer, detach 956f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the renderbuffer. 957f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This is used when a renderbuffer object is deleted. 958f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The spec calls for unbinding. 959f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 960f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 961f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdetach_renderbuffer(struct gl_context *ctx, 962f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb, 963f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb) 964f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 965f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 966f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < BUFFER_COUNT; i++) { 967f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->Attachment[i].Renderbuffer == rb) { 968f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_remove_attachment(ctx, &fb->Attachment[i]); 969f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 970f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 971f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org invalidate_framebuffer(fb); 972f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 973f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 974f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 975f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 976f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) 977f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 978f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 979f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 980f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 981f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 982f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 983f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 984f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < n; i++) { 985f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (renderbuffers[i] > 0) { 986f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb; 987f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); 988f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb) { 989f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if deleting currently bound renderbuffer object */ 990f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb == ctx->CurrentRenderbuffer) { 991f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* bind default */ 992f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(rb->RefCount >= 2); 993f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); 994f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 995f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 996f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_user_fbo(ctx->DrawBuffer)) { 997f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org detach_renderbuffer(ctx, ctx->DrawBuffer, rb); 998f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 999f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_user_fbo(ctx->ReadBuffer) 1000f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && ctx->ReadBuffer != ctx->DrawBuffer) { 1001f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org detach_renderbuffer(ctx, ctx->ReadBuffer, rb); 1002f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1003f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1004f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Remove from hash table immediately, to free the ID. 1005f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * But the object will not be freed until it's no longer 1006f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * referenced anywhere else. 1007f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1008f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); 1009f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1010f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb != &DummyRenderbuffer) { 1011f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* no longer referenced by hash table */ 1012f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_renderbuffer(&rb, NULL); 1013f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1014f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1015f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1016f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1017f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1018f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1019f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1020f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1021f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) 1022f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1023f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1024f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint first; 1025f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 1026f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1027f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1028f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1029f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (n < 0) { 1030f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); 1031f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1032f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1033f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1034f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!renderbuffers) 1035f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1036f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1037f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); 1038f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1039f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < n; i++) { 1040f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint name = first + i; 1041f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org renderbuffers[i] = name; 1042f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* insert dummy placeholder into hash table */ 1043f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_LOCK_MUTEX(ctx->Shared->Mutex); 1044f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); 1045f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); 1046f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1047f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1048f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1049f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1050f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1051f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Given an internal format token for a render buffer, return the 1052f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, 1053f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL_EXT, GL_ALPHA, GL_LUMINANCE, 1054f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_LUMINANCE_ALPHA, GL_INTENSITY, etc). 1055f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 1056f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This is similar to _mesa_base_tex_format() but the set of valid 1057f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * internal formats is different. 1058f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 1059f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note that even if a format is determined to be legal here, validation 1060f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the FBO may fail if the format is not supported by the driver/GPU. 1061f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 1062f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \param internalFormat as passed to glRenderbufferStorage() 1063f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \return the base internal format, or 0 if internalFormat is illegal 1064f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1065f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLenum 1066f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) 1067f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1068f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 1069f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Notes: some formats such as alpha, luminance, etc. were added 1070f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * with GL_ARB_framebuffer_object. 1071f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1072f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (internalFormat) { 1073f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA: 1074f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA4: 1075f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA8: 1076f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA12: 1077f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA16: 1078f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object 1079f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_ALPHA : 0; 1080f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE: 1081f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE4: 1082f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE8: 1083f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE12: 1084f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16: 1085f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object 1086f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_LUMINANCE : 0; 1087f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA: 1088f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE4_ALPHA4: 1089f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE6_ALPHA2: 1090f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE8_ALPHA8: 1091f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE12_ALPHA4: 1092f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE12_ALPHA12: 1093f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16_ALPHA16: 1094f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object 1095f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_LUMINANCE_ALPHA : 0; 1096f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY: 1097f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY4: 1098f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY8: 1099f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY12: 1100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY16: 1101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object 1102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_INTENSITY : 0; 1103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB8: 1104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGB; 1105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB: 1106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R3_G3_B2: 1107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB4: 1108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB5: 1109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB10: 1110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB12: 1111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB16: 1112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) ? GL_RGB : 0; 1113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB8_EXT: 1114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx) ? GL_RGB : 0; 1115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA4: 1116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB5_A1: 1117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA8: 1118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGBA; 1119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA: 1120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA2: 1121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA12: 1122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA16: 1123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) ? GL_RGBA : 0; 1124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB10_A2: 1125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB8_ALPHA8_EXT: 1126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx) ? GL_RGBA : 0; 1127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_INDEX: 1128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_INDEX1_EXT: 1129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_INDEX4_EXT: 1130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_INDEX16_EXT: 1131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* There are extensions for GL_STENCIL_INDEX1 and GL_STENCIL_INDEX4 in 1132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OpenGL ES, but Mesa does not currently support them. 1133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) ? GL_STENCIL_INDEX : 0; 1135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_INDEX8_EXT: 1136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_STENCIL_INDEX; 1137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_COMPONENT: 1138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_COMPONENT32: 1139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) ? GL_DEPTH_COMPONENT : 0; 1140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_COMPONENT16: 1141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_COMPONENT24: 1142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_DEPTH_COMPONENT; 1143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_STENCIL_EXT: 1144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) 1145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && ctx->Extensions.EXT_packed_depth_stencil 1146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_DEPTH_STENCIL_EXT : 0; 1147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH24_STENCIL8_EXT: 1148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Extensions.EXT_packed_depth_stencil 1149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_DEPTH_STENCIL_EXT : 0; 1150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_COMPONENT32F: 1151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && ctx->Extensions.ARB_depth_buffer_float) 1153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_DEPTH_COMPONENT : 0; 1154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH32F_STENCIL8: 1155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && ctx->Extensions.ARB_depth_buffer_float) 1157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_DEPTH_STENCIL : 0; 1158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RED: 1159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R16: 1160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rg 1161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RED : 0; 1162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R8: 1163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API != API_OPENGLES && ctx->Extensions.ARB_texture_rg 1164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RED : 0; 1165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG: 1166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG16: 1167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_rg 1168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RG : 0; 1169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG8: 1170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API != API_OPENGLES && ctx->Extensions.ARB_texture_rg 1171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RG : 0; 1172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* signed normalized texture formats */ 1173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R8_SNORM: 1174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) 1176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RED : 0; 1177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RED_SNORM: 1178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R16_SNORM: 1179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm 1180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RED : 0; 1181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG8_SNORM: 1182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) 1184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RG : 0; 1185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG_SNORM: 1186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG16_SNORM: 1187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm 1188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RG : 0; 1189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB8_SNORM: 1190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) 1192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGB : 0; 1193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB_SNORM: 1194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB16_SNORM: 1195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm 1196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGB : 0; 1197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA8_SNORM: 1198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) 1200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGBA : 0; 1201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA_SNORM: 1202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA16_SNORM: 1203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm 1204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGBA : 0; 1205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA_SNORM: 1206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA8_SNORM: 1207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA16_SNORM: 1208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_snorm && 1210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; 1211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_SNORM: 1212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE8_SNORM: 1213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16_SNORM: 1214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_snorm && 1216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; 1217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA_SNORM: 1218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE8_ALPHA8_SNORM: 1219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16_ALPHA16_SNORM: 1220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_snorm && 1222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; 1223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY_SNORM: 1224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY8_SNORM: 1225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY16_SNORM: 1226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_snorm && 1228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; 1229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R16F: 1230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R32F: 1231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && 1233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_rg && 1234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_float) ? GL_RED : 0; 1235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG16F: 1236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG32F: 1237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (ctx->API == API_OPENGL && 1239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_rg && 1240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_float) ? GL_RG : 0; 1241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB16F: 1242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB32F: 1243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_float) 1244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || _mesa_is_gles3(ctx) 1245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGB : 0; 1246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA16F: 1247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA32F: 1248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_float) 1249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || _mesa_is_gles3(ctx) 1250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGBA : 0; 1251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA16F_ARB: 1252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA32F_ARB: 1253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_float && 1255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; 1256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16F_ARB: 1257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE32F_ARB: 1258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_float && 1260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; 1261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA16F_ARB: 1262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA32F_ARB: 1263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_float && 1265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; 1266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY16F_ARB: 1267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY32F_ARB: 1268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_float && 1270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; 1271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB9_E5: 1272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (_mesa_is_desktop_gl(ctx) 1273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && ctx->Extensions.EXT_texture_shared_exponent) 1274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || _mesa_is_gles3(ctx) ? GL_RGB : 0; 1275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R11F_G11F_B10F: 1276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_packed_float) 1277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || _mesa_is_gles3(ctx) ? GL_RGB : 0; 1278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA8UI_EXT: 1280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA16UI_EXT: 1281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA32UI_EXT: 1282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA8I_EXT: 1283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA16I_EXT: 1284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA32I_EXT: 1285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (_mesa_is_desktop_gl(ctx) && 1287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer) ? GL_RGBA : 0; 1288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB8UI_EXT: 1290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB16UI_EXT: 1291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB32UI_EXT: 1292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB8I_EXT: 1293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB16I_EXT: 1294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB32I_EXT: 1295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (_mesa_is_desktop_gl(ctx) && 1297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer) ? GL_RGB : 0; 1298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R8UI: 1300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R8I: 1301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R16UI: 1302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R16I: 1303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R32UI: 1304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_R32I: 1305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (_mesa_is_desktop_gl(ctx) && 1307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_rg && 1308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer) ? GL_RED : 0; 1309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG8UI: 1311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG8I: 1312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG16UI: 1313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG16I: 1314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG32UI: 1315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG32I: 1316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->Version >= 30 1317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || (_mesa_is_desktop_gl(ctx) && 1318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_rg && 1319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer) ? GL_RG : 0; 1320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY8I_EXT: 1322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY8UI_EXT: 1323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY16I_EXT: 1324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY16UI_EXT: 1325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY32I_EXT: 1326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY32UI_EXT: 1327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer && 1329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; 1330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE8I_EXT: 1332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE8UI_EXT: 1333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16I_EXT: 1334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE16UI_EXT: 1335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE32I_EXT: 1336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE32UI_EXT: 1337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer && 1339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; 1340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA8I_EXT: 1342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA8UI_EXT: 1343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA16I_EXT: 1344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA16UI_EXT: 1345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA32I_EXT: 1346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA32UI_EXT: 1347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer && 1349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; 1350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA8I_EXT: 1352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA8UI_EXT: 1353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA16I_EXT: 1354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA16UI_EXT: 1355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA32I_EXT: 1356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA32UI_EXT: 1357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return ctx->API == API_OPENGL && 1358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.EXT_texture_integer && 1359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; 1360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB10_A2UI: 1362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (_mesa_is_desktop_gl(ctx) && 1363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Extensions.ARB_texture_rgb10_a2ui) 1364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || _mesa_is_gles3(ctx) ? GL_RGBA : 0; 1365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB565: 1367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_is_gles(ctx) || ctx->Extensions.ARB_ES2_compatibility 1368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_RGB : 0; 1369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 1370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 1371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Invalidate a renderbuffer attachment. Called from _mesa_HashWalk(). 1377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orginvalidate_rb(GLuint key, void *data, void *userData) 1380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb = (struct gl_framebuffer *) data; 1382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData; 1383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* If this is a user-created FBO */ 1385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_user_fbo(fb)) { 1386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 1387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < BUFFER_COUNT; i++) { 1388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att = fb->Attachment + i; 1389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_RENDERBUFFER && 1390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Renderbuffer == rb) { 1391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Mark fb status as indeterminate to force re-validation */ 1392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->_Status = 0; 1393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** sentinal value, see below */ 1401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define NO_SAMPLES 1000 1402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper function used by _mesa_RenderbufferStorageEXT() and 1406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * _mesa_RenderbufferStorageMultisample(). 1407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT(). 1408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgrenderbuffer_storage(GLenum target, GLenum internalFormat, 1411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLsizei width, GLsizei height, GLsizei samples) 1412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const char *func = samples == NO_SAMPLES ? 1414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glRenderbufferStorage" : "RenderbufferStorageMultisample"; 1415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb; 1416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum baseFormat; 1417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target != GL_RENDERBUFFER_EXT) { 1422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); 1423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org baseFormat = _mesa_base_fbo_format(ctx, internalFormat); 1427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (baseFormat == 0) { 1428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); 1429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (width < 0 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { 1433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); 1434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (height < 0 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { 1438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); 1439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (samples == NO_SAMPLES) { 1443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* NumSamples == 0 indicates non-multisampling */ 1444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org samples = 0; 1445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (samples > (GLsizei) ctx->Const.MaxSamples) { 1447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* note: driver may choose to use more samples than what's requested */ 1448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); 1449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = ctx->CurrentRenderbuffer; 1453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!rb) { 1454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); 1455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 1459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb->InternalFormat == internalFormat && 1461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->Width == (GLuint) width && 1462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->Height == (GLuint) height && 1463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->NumSamples == samples) { 1464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* no change in allocation needed */ 1465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* These MUST get set by the AllocStorage func */ 1469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->Format = MESA_FORMAT_NONE; 1470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->NumSamples = samples; 1471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Now allocate the storage */ 1473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(rb->AllocStorage); 1474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { 1475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* No error - check/set fields now */ 1476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */ 1477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(rb->Width == (GLuint) width); 1478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(rb->Height == (GLuint) height); 1479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->InternalFormat = internalFormat; 1480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->_BaseFormat = baseFormat; 1481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(rb->_BaseFormat != 0); 1482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 1484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Probably ran out of memory - clear the fields */ 1485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->Width = 0; 1486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->Height = 0; 1487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->Format = MESA_FORMAT_NONE; 1488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->InternalFormat = GL_NONE; 1489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->_BaseFormat = GL_NONE; 1490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb->NumSamples = 0; 1491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Invalidate the framebuffers the renderbuffer is attached in. */ 1494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb->AttachedAnytime) { 1495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb); 1496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if FEATURE_OES_EGL_image 1501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) 1503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb; 1505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!ctx->Extensions.OES_EGL_image) { 1509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 1510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glEGLImageTargetRenderbufferStorageOES(unsupported)"); 1511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target != GL_RENDERBUFFER) { 1515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 1516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "EGLImageTargetRenderbufferStorageOES"); 1517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = ctx->CurrentRenderbuffer; 1521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!rb) { 1522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 1523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "EGLImageTargetRenderbufferStorageOES"); 1524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 1528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); 1530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 1532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper function for _mesa_GetRenderbufferParameterivEXT() and 1536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * _mesa_GetFramebufferAttachmentParameterivEXT() 1537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * We have to be careful to respect the base format. For example, if a 1538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * renderbuffer/texture was created with internalFormat=GL_RGB but the 1539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE 1540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * we need to return zero. 1541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLint 1543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgget_component_bits(GLenum pname, GLenum baseFormat, gl_format format) 1544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_base_format_has_channel(baseFormat, pname)) 1546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_get_format_bits(format, pname); 1547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else 1548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 1549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, 1555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLsizei width, GLsizei height) 1556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* GL_ARB_fbo says calling this function is equivalent to calling 1558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * glRenderbufferStorageMultisample() with samples=0. We pass in 1559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a token value here just for error reporting purposes. 1560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); 1562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1564f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1565f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1566f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, 1567f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum internalFormat, 1568f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLsizei width, GLsizei height) 1569f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1570f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org renderbuffer_storage(target, internalFormat, width, height, samples); 1571f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1572f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1573f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1574f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1575f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OpenGL ES version of glRenderBufferStorage. 1576f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1577f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1578f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, 1579f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLsizei width, GLsizei height) 1580f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1581f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (internalFormat) { 1582f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB565: 1583f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ 1584f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* choose a closest format */ 1585f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org internalFormat = GL_RGB5; 1586f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1587f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 1588f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1589f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1590f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1591f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org renderbuffer_storage(target, internalFormat, width, height, 0); 1592f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1593f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1594f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1595f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1596f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) 1597f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1598f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb; 1599f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1600f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1601f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1602f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1603f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target != GL_RENDERBUFFER_EXT) { 1604f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 1605f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetRenderbufferParameterivEXT(target)"); 1606f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1607f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1608f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1609f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = ctx->CurrentRenderbuffer; 1610f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!rb) { 1611f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 1612f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetRenderbufferParameterivEXT"); 1613f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1614f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1615f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1616f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* No need to flush here since we're just quering state which is 1617f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * not effected by rendering. 1618f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1619f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1620f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (pname) { 1621f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_WIDTH_EXT: 1622f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = rb->Width; 1623f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1624f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_HEIGHT_EXT: 1625f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = rb->Height; 1626f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1627f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: 1628f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = rb->InternalFormat; 1629f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1630f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_RED_SIZE_EXT: 1631f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_GREEN_SIZE_EXT: 1632f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_BLUE_SIZE_EXT: 1633f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_ALPHA_SIZE_EXT: 1634f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_DEPTH_SIZE_EXT: 1635f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_STENCIL_SIZE_EXT: 1636f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = get_component_bits(pname, rb->_BaseFormat, rb->Format); 1637f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1638f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RENDERBUFFER_SAMPLES: 1639f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_framebuffer_object) 1640f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || _mesa_is_gles3(ctx)) { 1641f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = rb->NumSamples; 1642f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1643f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1644f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* fallthrough */ 1645f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 1646f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 1647f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetRenderbufferParameterivEXT(target)"); 1648f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1649f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1650f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1651f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1652f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1653f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLboolean GLAPIENTRY 1654f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_IsFramebufferEXT(GLuint framebuffer) 1655f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1656f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1657f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); 1658f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (framebuffer) { 1659f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *rb = _mesa_lookup_framebuffer(ctx, framebuffer); 1660f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (rb != NULL && rb != &DummyFramebuffer) 1661f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_TRUE; 1662f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1663f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_FALSE; 1664f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1665f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1666f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1667f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1668f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Check if any of the attachments of the given framebuffer are textures 1669f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * (render to texture). Call ctx->Driver.RenderTexture() for such 1670f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * attachments. 1671f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1672f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1673f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgcheck_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) 1674f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1675f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 1676f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(ctx->Driver.RenderTexture); 1677f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1678f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(fb)) 1679f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; /* can't render to texture with winsys framebuffers */ 1680f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1681f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < BUFFER_COUNT; i++) { 1682f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att = fb->Attachment + i; 1683f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Texture && _mesa_get_attachment_teximage(att)) { 1684f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.RenderTexture(ctx, fb, att); 1685f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1686f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1687f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1688f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1689f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1690f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1691f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Examine all the framebuffer's attachments to see if any are textures. 1692f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * If so, call ctx->Driver.FinishRenderTexture() for each texture to 1693f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * notify the device driver that the texture image may have changed. 1694f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1695f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1696f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgcheck_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) 1697f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1698f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(fb)) 1699f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; /* can't render to texture with winsys framebuffers */ 1700f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1701f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Driver.FinishRenderTexture) { 1702f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 1703f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < BUFFER_COUNT; i++) { 1704f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att = fb->Attachment + i; 1705f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Texture && att->Renderbuffer) { 1706f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.FinishRenderTexture(ctx, att); 1707f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1708f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1709f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1710f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1711f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1712f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1713f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1714f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) 1715f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1716f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *newDrawFb, *newReadFb; 1717f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *oldDrawFb, *oldReadFb; 1718f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean bindReadBuf, bindDrawBuf; 1719f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1720f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1721f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef DEBUG 1722f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Extensions.ARB_framebuffer_object) { 1723f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(ctx->Extensions.EXT_framebuffer_object); 1724f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(ctx->Extensions.EXT_framebuffer_blit); 1725f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1726f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 1727f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1728f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1729f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1730f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!ctx->Extensions.EXT_framebuffer_object) { 1731f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 1732f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBindFramebufferEXT(unsupported)"); 1733f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1734f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1735f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1736f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (target) { 1737f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if FEATURE_EXT_framebuffer_blit 1738f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DRAW_FRAMEBUFFER_EXT: 1739f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!ctx->Extensions.EXT_framebuffer_blit) { 1740f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); 1741f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1742f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1743f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindDrawBuf = GL_TRUE; 1744f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindReadBuf = GL_FALSE; 1745f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1746f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_READ_FRAMEBUFFER_EXT: 1747f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!ctx->Extensions.EXT_framebuffer_blit) { 1748f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); 1749f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1750f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1751f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindDrawBuf = GL_FALSE; 1752f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindReadBuf = GL_TRUE; 1753f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1754f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 1755f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_EXT: 1756f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindDrawBuf = GL_TRUE; 1757f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindReadBuf = GL_TRUE; 1758f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1759f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 1760f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); 1761f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1762f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1763f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1764f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (framebuffer) { 1765f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Binding a user-created framebuffer object */ 1766f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer); 1767f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (newDrawFb == &DummyFramebuffer) { 1768f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* ID was reserved, but no real framebuffer object made yet */ 1769f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newDrawFb = NULL; 1770f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1771f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) { 1772f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* All FBO IDs must be Gen'd */ 1773f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)"); 1774f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1775f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1776f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1777f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!newDrawFb) { 1778f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* create new framebuffer object */ 1779f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); 1780f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!newDrawFb) { 1781f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); 1782f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1783f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1784f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); 1785f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1786f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newReadFb = newDrawFb; 1787f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1788f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 1789f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Binding the window system framebuffer (which was originally set 1790f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * with MakeCurrent). 1791f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1792f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newDrawFb = ctx->WinSysDrawBuffer; 1793f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org newReadFb = ctx->WinSysReadBuffer; 1794f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1795f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1796f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(newDrawFb); 1797f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(newDrawFb != &DummyFramebuffer); 1798f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1799f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* save pointers to current/old framebuffers */ 1800f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org oldDrawFb = ctx->DrawBuffer; 1801f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org oldReadFb = ctx->ReadBuffer; 1802f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1803f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if really changing bindings */ 1804f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (oldDrawFb == newDrawFb) 1805f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindDrawBuf = GL_FALSE; 1806f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (oldReadFb == newReadFb) 1807f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bindReadBuf = GL_FALSE; 1808f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1809f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 1810f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OK, now bind the new Draw/Read framebuffers, if they're changing. 1811f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 1812f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * We also check if we're beginning and/or ending render-to-texture. 1813f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * When a framebuffer with texture attachments is unbound, call 1814f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ctx->Driver.FinishRenderTexture(). 1815f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * When a framebuffer with texture attachments is bound, call 1816f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ctx->Driver.RenderTexture(). 1817f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 1818f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note that if the ReadBuffer has texture attachments we don't consider 1819f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * that a render-to-texture case. 1820f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1821f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (bindReadBuf) { 1822f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 1823f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1824f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if old readbuffer was render-to-texture */ 1825f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org check_end_texture_render(ctx, oldReadFb); 1826f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1827f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb); 1828f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1829f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1830f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (bindDrawBuf) { 1831f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 1832f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1833f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if old framebuffer had any texture attachments */ 1834f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (oldDrawFb) 1835f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org check_end_texture_render(ctx, oldDrawFb); 1836f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1837f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if newly bound framebuffer has any texture attachments */ 1838f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org check_begin_texture_render(ctx, newDrawFb); 1839f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1840f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb); 1841f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1842f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1843f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) { 1844f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb); 1845f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1846f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1847f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1848f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1849f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1850f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) 1851f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1852f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 1853f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1854f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1855f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1856f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 1857f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1858f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < n; i++) { 1859f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (framebuffers[i] > 0) { 1860f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb; 1861f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); 1862f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb) { 1863f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); 1864f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1865f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check if deleting currently bound framebuffer object */ 1866f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Extensions.EXT_framebuffer_blit) { 1867f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* separate draw/read binding points */ 1868f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb == ctx->DrawBuffer) { 1869f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* bind default */ 1870f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(fb->RefCount >= 2); 1871f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); 1872f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1873f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb == ctx->ReadBuffer) { 1874f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* bind default */ 1875f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(fb->RefCount >= 2); 1876f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); 1877f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1878f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1879f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 1880f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* only one binding point for read/draw buffers */ 1881f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { 1882f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* bind default */ 1883f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(fb->RefCount >= 2); 1884f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1885f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1886f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1887f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1888f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* remove from hash table immediately, to free the ID */ 1889f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); 1890f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1891f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb != &DummyFramebuffer) { 1892f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* But the object will not be freed until it's no longer 1893f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * bound in any context. 1894f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1895f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_framebuffer(&fb, NULL); 1896f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1897f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1898f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1899f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1900f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1901f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1902f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1903f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 1904f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers) 1905f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1906f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1907f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint first; 1908f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 1909f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1910f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 1911f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1912f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (n < 0) { 1913f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)"); 1914f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1915f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1916f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1917f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!framebuffers) 1918f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1919f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1920f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); 1921f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1922f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < n; i++) { 1923f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint name = first + i; 1924f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org framebuffers[i] = name; 1925f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* insert dummy placeholder into hash table */ 1926f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_LOCK_MUTEX(ctx->Shared->Mutex); 1927f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer); 1928f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); 1929f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1930f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1931f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1932f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1933f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1934f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLenum GLAPIENTRY 1935f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_CheckFramebufferStatusEXT(GLenum target) 1936f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1937f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *buffer; 1938f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 1939f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1940f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); 1941f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1942f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org buffer = get_framebuffer_target(ctx, target); 1943f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!buffer) { 1944f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); 1945f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 1946f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1947f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1948f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(buffer)) { 1949f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The window system / default framebuffer is always complete */ 1950f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_FRAMEBUFFER_COMPLETE_EXT; 1951f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1952f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1953f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* No need to flush here */ 1954f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1955f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) { 1956f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_test_framebuffer_completeness(ctx, buffer); 1957f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1958f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1959f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return buffer->_Status; 1960f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1961f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1962f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1963f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1964f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Replicate the src attachment point. Used by framebuffer_texture() when 1965f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the same texture is attached at GL_DEPTH_ATTACHMENT and 1966f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_STENCIL_ATTACHMENT. 1967f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1968f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1969f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgreuse_framebuffer_texture_attachment(struct gl_framebuffer *fb, 1970f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org gl_buffer_index dst, 1971f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org gl_buffer_index src) 1972f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1973f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *dst_att = &fb->Attachment[dst]; 1974f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *src_att = &fb->Attachment[src]; 1975f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1976f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(src_att->Texture != NULL); 1977f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(src_att->Renderbuffer != NULL); 1978f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1979f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_texobj(&dst_att->Texture, src_att->Texture); 1980f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_reference_renderbuffer(&dst_att->Renderbuffer, src_att->Renderbuffer); 1981f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst_att->Type = src_att->Type; 1982f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst_att->Complete = src_att->Complete; 1983f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst_att->TextureLevel = src_att->TextureLevel; 1984f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst_att->Zoffset = src_att->Zoffset; 1985f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1986f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1987f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1988f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 1989f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Common code called by glFramebufferTexture1D/2D/3DEXT() and 1990f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * glFramebufferTextureLayerEXT(). 1991f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note: glFramebufferTextureLayerEXT() has no textarget parameter so we'll 1992f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * get textarget=0 in that case. 1993f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1994f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1995f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgframebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, 1996f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum attachment, GLenum textarget, GLuint texture, 1997f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint level, GLint zoffset) 1998f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1999f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att; 2000f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_texture_object *texObj = NULL; 2001f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb; 2002f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum maxLevelsTarget; 2003f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2004f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 2005f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2006f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb = get_framebuffer_target(ctx, target); 2007f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!fb) { 2008f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2009f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(target=0x%x)", caller, target); 2010f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2011f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2012f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2013f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check framebuffer binding */ 2014f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(fb)) { 2015f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2016f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT", caller); 2017f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2018f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2019f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2020f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The textarget, level, and zoffset parameters are only validated if 2021f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * texture is non-zero. 2022f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2023f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texture) { 2024f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean err = GL_TRUE; 2025f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2026f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texObj = _mesa_lookup_texture(ctx, texture); 2027f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texObj != NULL) { 2028f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (textarget == 0) { 2029f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* If textarget == 0 it means we're being called by 2030f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * glFramebufferTextureLayer() and textarget is not used. 2031f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The only legal texture types for that function are 3D and 2032f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 1D/2D arrays textures. 2033f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2034f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org err = (texObj->Target != GL_TEXTURE_3D) && 2035f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) && 2036f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT); 2037f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2038f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2039f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Make sure textarget is consistent with the texture's type */ 2040f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org err = (texObj->Target == GL_TEXTURE_CUBE_MAP) 2041f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? !_mesa_is_cube_face(textarget) 2042f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org : (texObj->Target != textarget); 2043f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2044f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2045f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2046f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* can't render to a non-existant texture */ 2047f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2048f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(non existant texture)", 2049f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org caller); 2050f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2051f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2052f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2053f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (err) { 2054f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2055f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(texture target mismatch)", 2056f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org caller); 2057f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2058f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2059f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2060f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texObj->Target == GL_TEXTURE_3D) { 2061f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); 2062f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (zoffset < 0 || zoffset >= maxSize) { 2063f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, 2064f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(zoffset)", caller); 2065f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2066f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2067f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2068f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) || 2069f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT)) { 2070f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (zoffset < 0 || zoffset >= ctx->Const.MaxArrayTextureLayers) { 2071f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, 2072f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(layer)", caller); 2073f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2074f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2075f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2076f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2077f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org maxLevelsTarget = textarget ? textarget : texObj->Target; 2078f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((level < 0) || 2079f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) { 2080f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, 2081f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(level)", caller); 2082f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2083f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2084f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2085f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2086f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = _mesa_get_attachment(ctx, fb, attachment); 2087f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att == NULL) { 2088f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2089f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture%sEXT(attachment)", caller); 2090f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2091f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2092f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2093f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 2094f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2095f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_LOCK_MUTEX(fb->Mutex); 2096f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texObj) { 2097f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_DEPTH_ATTACHMENT && 2098f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texObj == fb->Attachment[BUFFER_STENCIL].Texture && 2099f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level == fb->Attachment[BUFFER_STENCIL].TextureLevel && 2100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_tex_target_to_face(textarget) == 2101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->Attachment[BUFFER_STENCIL].CubeMapFace && 2102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) { 2103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The texture object is already attached to the stencil attachment 2104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * point. Don't create a new renderbuffer; just reuse the stencil 2105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * attachment's. This is required to prevent a GL error in 2106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL). 2107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH, 2109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org BUFFER_STENCIL); 2110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else if (attachment == GL_STENCIL_ATTACHMENT && 2111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texObj == fb->Attachment[BUFFER_DEPTH].Texture && 2112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level == fb->Attachment[BUFFER_DEPTH].TextureLevel && 2113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_tex_target_to_face(textarget) == 2114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb->Attachment[BUFFER_DEPTH].CubeMapFace && 2115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) { 2116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* As above, but with depth and stencil transposed. */ 2117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL, 2118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org BUFFER_DEPTH); 2119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else { 2120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, 2121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level, zoffset); 2122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 2123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Above we created a new renderbuffer and attached it to the 2124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * depth attachment point. Now attach it to the stencil attachment 2125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * point too. 2126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att == &fb->Attachment[BUFFER_DEPTH]); 2128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL, 2129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org BUFFER_DEPTH); 2130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Set the render-to-texture flag. We'll check this flag in 2134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * glTexImage() and friends to determine if we need to revalidate 2135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * any FBOs that might be rendering into this texture. 2136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This flag never gets cleared since it's non-trivial to determine 2137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * when all FBOs might be done rendering to this texture. That's OK 2138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * though since it's uncommon to render to a texture then repeatedly 2139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * call glTexImage() to change images in the texture. 2140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texObj->_RenderToTexture = GL_TRUE; 2142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_remove_attachment(ctx, att); 2145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 2146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att == &fb->Attachment[BUFFER_DEPTH]); 2147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]); 2148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org invalidate_framebuffer(fb); 2152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _glthread_UNLOCK_MUTEX(fb->Mutex); 2154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, 2160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum textarget, GLuint texture, GLint level) 2161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texture != 0) { 2165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean error; 2166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (textarget) { 2168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_1D: 2169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = GL_FALSE; 2170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_1D_ARRAY: 2172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = !ctx->Extensions.EXT_texture_array; 2173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 2175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = GL_TRUE; 2176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (error) { 2179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture1DEXT(textarget=%s)", 2181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_lookup_enum_by_nr(textarget)); 2182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, 2187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level, 0); 2188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, 2193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum textarget, GLuint texture, GLint level) 2194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texture != 0) { 2198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean error; 2199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (textarget) { 2201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_2D: 2202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = GL_FALSE; 2203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_RECTANGLE: 2205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = _mesa_is_gles(ctx) 2206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || !ctx->Extensions.NV_texture_rectangle; 2207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP_POSITIVE_X: 2209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 2210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 2211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 2212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 2213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 2214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = !ctx->Extensions.ARB_texture_cube_map; 2215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_2D_ARRAY: 2217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = (_mesa_is_gles(ctx) && ctx->Version < 30) 2218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || !ctx->Extensions.EXT_texture_array; 2219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 2221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = GL_TRUE; 2222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (error) { 2225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture2DEXT(textarget=%s)", 2227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_lookup_enum_by_nr(textarget)); 2228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, 2233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level, 0); 2234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, 2239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum textarget, GLuint texture, 2240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint level, GLint zoffset) 2241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { 2245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTexture3DEXT(textarget)"); 2247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, 2251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level, zoffset); 2252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, 2257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint texture, GLint level, GLint layer) 2258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org framebuffer_texture(ctx, "Layer", target, attachment, 0, texture, 2262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org level, layer); 2263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, 2268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum renderbufferTarget, 2269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint renderbuffer) 2270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer_attachment *att; 2272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb; 2273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *rb; 2274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 2277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb = get_framebuffer_target(ctx, target); 2279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!fb) { 2280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(target)"); 2281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (renderbufferTarget != GL_RENDERBUFFER_EXT) { 2285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferRenderbufferEXT(renderbufferTarget)"); 2287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(fb)) { 2291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Can't attach new renderbuffers to a window system framebuffer */ 2292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT"); 2293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = _mesa_get_attachment(ctx, fb, attachment); 2297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att == NULL) { 2298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferRenderbufferEXT(invalid attachment %s)", 2300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_lookup_enum_by_nr(attachment)); 2301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (renderbuffer) { 2305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); 2306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!rb) { 2307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferRenderbufferEXT(non-existant" 2309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " renderbuffer %u)", renderbuffer); 2310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (rb == &DummyRenderbuffer) { 2313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* This is what NVIDIA does */ 2314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, 2315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferRenderbufferEXT(renderbuffer %u)", 2316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org renderbuffer); 2317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* remove renderbuffer attachment */ 2322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb = NULL; 2323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && 2326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org rb && rb->Format != MESA_FORMAT_NONE) { 2327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* make sure the renderbuffer is a depth/stencil format */ 2328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); 2329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (baseFormat != GL_DEPTH_STENCIL) { 2330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferRenderbufferEXT(renderbuffer" 2332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " is not DEPTH_STENCIL format)"); 2333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 2339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(ctx->Driver.FramebufferRenderbuffer); 2341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb); 2342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Some subsequent GL commands may depend on the framebuffer's visual 2344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * after the binding is updated. Update visual info now. 2345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_update_framebuffer_visual(ctx, fb); 2347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, 2352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum pname, GLint *params) 2353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer_attachment *att; 2355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *buffer; 2356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum err; 2357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 2360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The error differs in GL and GLES. */ 2362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM; 2363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org buffer = get_framebuffer_target(ctx, target); 2365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!buffer) { 2366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(target)"); 2368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(buffer)) { 2372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec 2373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * says: 2374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If the framebuffer currently bound to target is zero, then 2376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * INVALID_OPERATION is generated." 2377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The EXT_framebuffer_object spec has the same wording, and the 2379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OES_framebuffer_object spec refers to the EXT_framebuffer_object 2380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * spec. 2381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) { 2383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameteriv(bound FBO = 0)"); 2385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* the default / window-system FBO */ 2388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = _mesa_get_fb0_attachment(ctx, buffer, attachment); 2389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* user-created framebuffer FBO */ 2392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = _mesa_get_attachment(ctx, buffer, attachment); 2393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att == NULL) { 2396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(attachment)"); 2398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 2402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* the depth and stencil attachments must point to the same buffer */ 2403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer_attachment *depthAtt, *stencilAtt; 2404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org depthAtt = _mesa_get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT); 2405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org stencilAtt = _mesa_get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT); 2406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) { 2407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL" 2409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " attachments differ)"); 2410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* No need to flush here */ 2415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (pname) { 2417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: 2418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = _mesa_is_winsys_fbo(buffer) 2419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ? GL_FRAMEBUFFER_DEFAULT : att->Type; 2420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: 2422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_RENDERBUFFER_EXT) { 2423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = att->Renderbuffer->Name; 2424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_TEXTURE) { 2426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = att->Texture->Name; 2427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(att->Type == GL_NONE); 2430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) { 2431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = 0; 2432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else { 2433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: 2438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_TEXTURE) { 2439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = att->TextureLevel; 2440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_NONE) { 2442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, err, 2443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(pname)"); 2444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: 2450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Type == GL_TEXTURE) { 2451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { 2452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; 2453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = 0; 2456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_NONE) { 2459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, err, 2460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(pname)"); 2461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: 2467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->API == API_OPENGLES) { 2468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else if (att->Type == GL_NONE) { 2470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, err, 2471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(pname)"); 2472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else if (att->Type == GL_TEXTURE) { 2473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { 2474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = att->Zoffset; 2475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = 0; 2478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 2485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) 2486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && !_mesa_is_gles3(ctx)) { 2487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_NONE) { 2490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, err, 2491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(pname)"); 2492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Extensions.EXT_framebuffer_sRGB) { 2495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); 2496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* According to ARB_framebuffer_sRGB, we should return LINEAR 2499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * if the sRGB conversion is unsupported. */ 2500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = GL_LINEAR; 2501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 2505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((ctx->API != API_OPENGL || !ctx->Extensions.ARB_framebuffer_object) 2506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && ctx->API != API_OPENGL_CORE 2507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && !_mesa_is_gles3(ctx)) { 2508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_NONE) { 2511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, err, 2512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(pname)"); 2513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org gl_format format = att->Renderbuffer->Format; 2516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (format == MESA_FORMAT_S8) { 2517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* special cases */ 2518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = GL_INDEX; 2519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) { 2521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* depends on the attachment parameter */ 2522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (attachment == GL_STENCIL_ATTACHMENT) { 2523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = GL_INDEX; 2524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = GL_FLOAT; 2527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = _mesa_get_format_datatype(format); 2531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: 2535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 2536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 2537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 2538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 2539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 2540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) 2541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && !_mesa_is_gles3(ctx)) { 2542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Type == GL_NONE) { 2545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, err, 2546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameterivEXT(pname)"); 2547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Texture) { 2549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_texture_image *texImage = 2550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target, 2551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->TextureLevel); 2552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texImage) { 2553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = get_component_bits(pname, texImage->_BaseFormat, 2554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texImage->TexFormat); 2555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = 0; 2558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (att->Renderbuffer) { 2561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat, 2562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Renderbuffer->Format); 2563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2564f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2565f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:" 2566f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " invalid FBO attachment structure"); 2567f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2568f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2569f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 2570f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_pname_enum; 2571f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2572f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2573f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2574f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2575f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orginvalid_pname_enum: 2576f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, 2577f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGetFramebufferAttachmentParameteriv(pname)"); 2578f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2579f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2580f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2581f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2582f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2583f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_GenerateMipmapEXT(GLenum target) 2584f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2585f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_texture_image *srcImage; 2586f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_texture_object *texObj; 2587f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean error; 2588f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2589f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2590f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2591f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 2592f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 2593f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2594f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (target) { 2595f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_1D: 2596f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = _mesa_is_gles(ctx); 2597f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2598f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_2D: 2599f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = GL_FALSE; 2600f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2601f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_3D: 2602f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = ctx->API == API_OPENGLES; 2603f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2604f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_CUBE_MAP: 2605f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = !ctx->Extensions.ARB_texture_cube_map; 2606f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2607f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_1D_ARRAY: 2608f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = _mesa_is_gles(ctx) || !ctx->Extensions.EXT_texture_array; 2609f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2610f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_TEXTURE_2D_ARRAY: 2611f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = (_mesa_is_gles(ctx) && ctx->Version < 30) 2612f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org || !ctx->Extensions.EXT_texture_array; 2613f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 2614f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 2615f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org error = GL_TRUE; 2616f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2617f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2618f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (error) { 2619f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)", 2620f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_lookup_enum_by_nr(target)); 2621f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2622f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2623f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2624f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texObj = _mesa_get_current_tex_object(ctx, target); 2625f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2626f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texObj->BaseLevel >= texObj->MaxLevel) { 2627f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* nothing to do */ 2628f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2629f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2630f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2631f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (texObj->Target == GL_TEXTURE_CUBE_MAP && 2632f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org !_mesa_cube_complete(texObj)) { 2633f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2634f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGenerateMipmap(incomplete cube map)"); 2635f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2636f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2637f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2638f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_lock_texture(ctx, texObj); 2639f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2640f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcImage = _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel); 2641f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!srcImage) { 2642f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_unlock_texture(ctx, texObj); 2643f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2644f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGenerateMipmap(zero size base image)"); 2645f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2646f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2647f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2648f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_enum_format_integer(srcImage->InternalFormat) || 2649f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_is_depthstencil_format(srcImage->InternalFormat) || 2650f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_is_stencil_format(srcImage->InternalFormat)) { 2651f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_unlock_texture(ctx, texObj); 2652f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2653f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glGenerateMipmap(invalid internal format)"); 2654f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2655f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2656f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2657f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target == GL_TEXTURE_CUBE_MAP) { 2658f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint face; 2659f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (face = 0; face < 6; face++) 2660f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.GenerateMipmap(ctx, 2661f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, 2662f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texObj); 2663f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2664f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2665f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.GenerateMipmap(ctx, target, texObj); 2666f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2667f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_unlock_texture(ctx, texObj); 2668f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2669f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2670f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2671f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if FEATURE_EXT_framebuffer_blit 2672f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2673f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic const struct gl_renderbuffer_attachment * 2674f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgfind_attachment(const struct gl_framebuffer *fb, 2675f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer *rb) 2676f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2677f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 2678f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < Elements(fb->Attachment); i++) { 2679f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (fb->Attachment[i].Renderbuffer == rb) 2680f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &fb->Attachment[i]; 2681f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2682f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 2683f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2684f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2685f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2686f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 2687f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper function for checking if the datatypes of color buffers are 2688f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * compatible for glBlitFramebuffer. From the 3.1 spec, page 198: 2689f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2690f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT 2691f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and any of the following conditions hold: 2692f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - The read buffer contains fixed-point or floating-point values and any 2693f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * draw buffer contains neither fixed-point nor floating-point values. 2694f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - The read buffer contains unsigned integer values and any draw buffer 2695f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * does not contain unsigned integer values. 2696f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - The read buffer contains signed integer values and any draw buffer 2697f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * does not contain signed integer values." 2698f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2699f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLboolean 2700f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgcompatible_color_datatypes(gl_format srcFormat, gl_format dstFormat) 2701f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2702f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum srcType = _mesa_get_format_datatype(srcFormat); 2703f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum dstType = _mesa_get_format_datatype(dstFormat); 2704f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2705f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (srcType != GL_INT && srcType != GL_UNSIGNED_INT) { 2706f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(srcType == GL_UNSIGNED_NORMALIZED || 2707f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcType == GL_SIGNED_NORMALIZED || 2708f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcType == GL_FLOAT); 2709f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Boil any of those types down to GL_FLOAT */ 2710f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcType = GL_FLOAT; 2711f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2712f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2713f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (dstType != GL_INT && dstType != GL_UNSIGNED_INT) { 2714f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(dstType == GL_UNSIGNED_NORMALIZED || 2715f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dstType == GL_SIGNED_NORMALIZED || 2716f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dstType == GL_FLOAT); 2717f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Boil any of those types down to GL_FLOAT */ 2718f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dstType = GL_FLOAT; 2719f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2720f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2721f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return srcType == dstType; 2722f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2723f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2724f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2725f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 2726f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Return the equivalent non-generic internal format. 2727f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This is useful for comparing whether two internal formats are semantically 2728f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * equivalent. 2729f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2730f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLenum 2731f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgget_nongeneric_internalformat(GLenum format) 2732f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2733f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (format) { 2734f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* GL 1.1 formats. */ 2735f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case 4: 2736f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA: 2737f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGBA8; 2738f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2739f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case 3: 2740f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB: 2741f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGB8; 2742f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2743f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case 2: 2744f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA: 2745f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_LUMINANCE8_ALPHA8; 2746f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2747f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case 1: 2748f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE: 2749f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_LUMINANCE8; 2750f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2751f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA: 2752f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_ALPHA8; 2753f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2754f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY: 2755f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_INTENSITY8; 2756f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2757f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* GL_ARB_texture_rg */ 2758f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RED: 2759f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_R8; 2760f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2761f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG: 2762f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RG8; 2763f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2764f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* GL_EXT_texture_sRGB */ 2765f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB: 2766f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_SRGB8; 2767f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2768f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB_ALPHA: 2769f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_SRGB8_ALPHA8; 2770f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2771f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SLUMINANCE: 2772f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_SLUMINANCE8; 2773f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2774f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SLUMINANCE_ALPHA: 2775f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_SLUMINANCE8_ALPHA8; 2776f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2777f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* GL_EXT_texture_snorm */ 2778f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGBA_SNORM: 2779f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGBA8_SNORM; 2780f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2781f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RGB_SNORM: 2782f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGB8_SNORM; 2783f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2784f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RG_SNORM: 2785f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RG8_SNORM; 2786f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2787f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_RED_SNORM: 2788f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_R8_SNORM; 2789f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2790f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_ALPHA_SNORM: 2791f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_LUMINANCE8_ALPHA8_SNORM; 2792f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2793f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_LUMINANCE_SNORM: 2794f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_LUMINANCE8_SNORM; 2795f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2796f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ALPHA_SNORM: 2797f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_ALPHA8_SNORM; 2798f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2799f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_INTENSITY_SNORM: 2800f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_INTENSITY8_SNORM; 2801f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2802f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 2803f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return format; 2804f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2805f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2806f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2807f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2808f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLenum 2809f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgget_linear_internalformat(GLenum format) 2810f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2811f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (format) { 2812f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB: 2813f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGB; 2814f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2815f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB_ALPHA: 2816f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGBA; 2817f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2818f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB8: 2819f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGB8; 2820f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2821f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SRGB8_ALPHA8: 2822f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_RGBA8; 2823f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2824f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SLUMINANCE: 2825f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_LUMINANCE8; 2826f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2827f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_SLUMINANCE_ALPHA: 2828f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_LUMINANCE8_ALPHA8; 2829f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2830f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 2831f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return format; 2832f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2833f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2834f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2835f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2836f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLboolean 2837f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgcompatible_resolve_formats(const struct gl_renderbuffer *colorReadRb, 2838f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer *colorDrawRb) 2839f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2840f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum readFormat, drawFormat; 2841f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2842f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The simple case where we know the backing Mesa formats are the same. 2843f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2844f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_get_srgb_format_linear(colorReadRb->Format) == 2845f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_get_srgb_format_linear(colorDrawRb->Format)) { 2846f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_TRUE; 2847f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2848f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2849f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The Mesa formats are different, so we must check whether the internal 2850f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * formats are compatible. 2851f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2852f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Under some circumstances, the user may request e.g. two GL_RGBA8 2853f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * textures and get two entirely different Mesa formats like RGBA8888 and 2854f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ARGB8888. Drivers behaving like that should be able to cope with 2855f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * non-matching formats by themselves, because it's not the user's fault. 2856f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2857f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Blits between linear and sRGB formats are also allowed. 2858f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2859f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFormat = get_nongeneric_internalformat(colorReadRb->InternalFormat); 2860f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFormat = get_nongeneric_internalformat(colorDrawRb->InternalFormat); 2861f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFormat = get_linear_internalformat(readFormat); 2862f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFormat = get_linear_internalformat(drawFormat); 2863f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2864f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (readFormat == drawFormat) { 2865f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_TRUE; 2866f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2867f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2868f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return GL_FALSE; 2869f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 2870f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2871f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2872f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 2873f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Blit rectangular region, optionally from one framebuffer to another. 2874f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2875f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note, if the src buffer is multisampled and the dest is not, this is 2876f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * when the samples must be resolved to a single color. 2877f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2878f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 2879f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 2880f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 2881f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLbitfield mask, GLenum filter) 2882f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 2883f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT | 2884f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GL_DEPTH_BUFFER_BIT | 2885f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GL_STENCIL_BUFFER_BIT); 2886f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_framebuffer *readFb, *drawFb; 2887f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer *colorReadRb, *colorDrawRb; 2888f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 2889f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2890f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 2891f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FLUSH_VERTICES(ctx, _NEW_BUFFERS); 2892f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2893f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (MESA_VERBOSE & VERBOSE_API) 2894f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_debug(ctx, 2895f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n", 2896f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcX0, srcY0, srcX1, srcY1, 2897f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dstX0, dstY0, dstX1, dstY1, 2898f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org mask, _mesa_lookup_enum_by_nr(filter)); 2899f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2900f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->NewState) { 2901f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_update_state(ctx); 2902f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2903f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2904f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFb = ctx->ReadBuffer; 2905f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFb = ctx->DrawBuffer; 2906f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2907f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!readFb || !drawFb) { 2908f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* This will normally never happen but someday we may want to 2909f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * support MakeCurrent() with no drawables. 2910f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2911f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2912f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2913f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2914f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* check for complete framebuffers */ 2915f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || 2916f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { 2917f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, 2918f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(incomplete draw/read buffers)"); 2919f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2920f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2921f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2922f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (filter != GL_NEAREST && filter != GL_LINEAR) { 2923f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(filter)"); 2924f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2925f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2926f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2927f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (mask & ~legalMaskBits) { 2928f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)"); 2929f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2930f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2931f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2932f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* depth/stencil must be blitted with nearest filtering */ 2933f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) 2934f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org && filter != GL_NEAREST) { 2935f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2936f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)"); 2937f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2938f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2939f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2940f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* get color read/draw renderbuffers */ 2941f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (mask & GL_COLOR_BUFFER_BIT) { 2942f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorReadRb = readFb->_ColorReadBuffer; 2943f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorDrawRb = drawFb->_ColorDrawBuffers[0]; 2944f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2945f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* From the EXT_framebuffer_object spec: 2946f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2947f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If a buffer is specified in <mask> and does not exist in both 2948f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the read and draw framebuffers, the corresponding bit is silently 2949f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ignored." 2950f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2951f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((colorReadRb == NULL) || (colorDrawRb == NULL)) { 2952f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorReadRb = colorDrawRb = NULL; 2953f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org mask &= ~GL_COLOR_BUFFER_BIT; 2954f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2955f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (!compatible_color_datatypes(colorReadRb->Format, 2956f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorDrawRb->Format)) { 2957f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2958f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(color buffer datatypes mismatch)"); 2959f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2960f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2961f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2962f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 2963f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorReadRb = colorDrawRb = NULL; 2964f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2965f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2966f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (mask & GL_STENCIL_BUFFER_BIT) { 2967f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *readRb = 2968f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFb->Attachment[BUFFER_STENCIL].Renderbuffer; 2969f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *drawRb = 2970f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFb->Attachment[BUFFER_STENCIL].Renderbuffer; 2971f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2972f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* From the EXT_framebuffer_object spec: 2973f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 2974f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If a buffer is specified in <mask> and does not exist in both 2975f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the read and draw framebuffers, the corresponding bit is silently 2976f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ignored." 2977f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2978f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((readRb == NULL) || (drawRb == NULL)) { 2979f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org mask &= ~GL_STENCIL_BUFFER_BIT; 2980f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2981f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != 2982f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) { 2983f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* There is no need to check the stencil datatype here, because 2984f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * there is only one: GL_UNSIGNED_INT. 2985f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 2986f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 2987f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(stencil buffer size mismatch)"); 2988f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 2989f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2990f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 2991f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2992f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (mask & GL_DEPTH_BUFFER_BIT) { 2993f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *readRb = 2994f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFb->Attachment[BUFFER_DEPTH].Renderbuffer; 2995f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_renderbuffer *drawRb = 2996f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFb->Attachment[BUFFER_DEPTH].Renderbuffer; 2997f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2998f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* From the EXT_framebuffer_object spec: 2999f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3000f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If a buffer is specified in <mask> and does not exist in both 3001f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the read and draw framebuffers, the corresponding bit is silently 3002f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ignored." 3003f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 3004f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((readRb == NULL) || (drawRb == NULL)) { 3005f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org mask &= ~GL_DEPTH_BUFFER_BIT; 3006f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3007f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if ((_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != 3008f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) || 3009f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (_mesa_get_format_datatype(readRb->Format) != 3010f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_get_format_datatype(drawRb->Format))) { 3011f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3012f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(depth buffer format mismatch)"); 3013f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3014f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3015f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3016f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3017f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (readFb->Visual.samples > 0 && 3018f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFb->Visual.samples > 0 && 3019f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFb->Visual.samples != drawFb->Visual.samples) { 3020f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3021f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(mismatched samples)"); 3022f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3023f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3024f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3025f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* extra checks for multisample copies... */ 3026f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (readFb->Visual.samples > 0 || drawFb->Visual.samples > 0) { 3027f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* src and dest region sizes must be the same */ 3028f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (abs(srcX1 - srcX0) != abs(dstX1 - dstX0) || 3029f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org abs(srcY1 - srcY0) != abs(dstY1 - dstY0)) { 3030f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3031f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(bad src/dst multisample region sizes)"); 3032f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3033f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3034f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3035f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* color formats must match */ 3036f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (colorReadRb && 3037f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorDrawRb && 3038f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org !compatible_resolve_formats(colorReadRb, colorDrawRb)) { 3039f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3040f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(bad src/dst multisample pixel formats)"); 3041f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3042f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3043f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3044f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3045f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (filter == GL_LINEAR && (mask & GL_COLOR_BUFFER_BIT)) { 3046f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 3.1 spec, page 199: 3047f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Calling BlitFramebuffer will result in an INVALID_OPERATION error 3048f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * if filter is LINEAR and read buffer contains integer data." 3049f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 3050f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum type = _mesa_get_format_datatype(colorReadRb->Format); 3051f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (type == GL_INT || type == GL_UNSIGNED_INT) { 3052f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3053f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glBlitFramebufferEXT(integer color type)"); 3054f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3055f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3056f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3057f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3058f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!ctx->Extensions.EXT_framebuffer_blit) { 3059f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT"); 3060f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3061f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3062f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3063f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Debug code */ 3064f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (DEBUG_BLIT) { 3065f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," 3066f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " 0x%x, 0x%x)\n", 3067f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcX0, srcY0, srcX1, srcY1, 3068f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dstX0, dstY0, dstX1, dstY1, 3069f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org mask, filter); 3070f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (colorReadRb) { 3071f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_renderbuffer_attachment *att; 3072f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3073f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = find_attachment(readFb, colorReadRb); 3074f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf(" Src FBO %u RB %u (%dx%d) ", 3075f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org readFb->Name, colorReadRb->Name, 3076f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorReadRb->Width, colorReadRb->Height); 3077f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att && att->Texture) { 3078f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("Tex %u tgt 0x%x level %u face %u", 3079f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Texture->Name, 3080f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Texture->Target, 3081f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->TextureLevel, 3082f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->CubeMapFace); 3083f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3084f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("\n"); 3085f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3086f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att = find_attachment(drawFb, colorDrawRb); 3087f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf(" Dst FBO %u RB %u (%dx%d) ", 3088f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org drawFb->Name, colorDrawRb->Name, 3089f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org colorDrawRb->Width, colorDrawRb->Height); 3090f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (att && att->Texture) { 3091f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("Tex %u tgt 0x%x level %u face %u", 3092f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Texture->Name, 3093f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->Texture->Target, 3094f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->TextureLevel, 3095f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org att->CubeMapFace); 3096f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3097f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("\n"); 3098f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3099f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!mask) { 3102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT(ctx->Driver.BlitFramebuffer); 3106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ctx->Driver.BlitFramebuffer(ctx, 3107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org srcX0, srcY0, srcX1, srcY1, 3108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dstX0, dstY0, dstX1, dstY1, 3109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org mask, filter); 3110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 3111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* FEATURE_EXT_framebuffer_blit */ 3112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if FEATURE_ARB_geometry_shader4 3115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 3116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, 3117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint texture, GLint level) 3118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 3119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 3120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTextureARB " 3122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "not implemented!"); 3123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 3124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 3127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, 3128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint texture, GLint level, GLenum face) 3129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 3130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 3131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glFramebufferTextureFaceARB " 3133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "not implemented!"); 3134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 3135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* FEATURE_ARB_geometry_shader4 */ 3136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 3138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orginvalidate_framebuffer_storage(GLenum target, GLsizei numAttachments, 3139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLenum *attachments, GLint x, GLint y, 3140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLsizei width, GLsizei height, const char *name) 3141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 3142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int i; 3143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_framebuffer *fb; 3144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_CURRENT_CONTEXT(ctx); 3145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_OUTSIDE_BEGIN_END(ctx); 3147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fb = get_framebuffer_target(ctx, target); 3149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!fb) { 3150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", name); 3151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (numAttachments < 0) { 3155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_VALUE, 3156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "%s(numAttachments < 0)", name); 3157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The GL_ARB_invalidate_subdata spec says: 3161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If an attachment is specified that does not exist in the 3163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * framebuffer bound to <target>, it is ignored." 3164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * It also says: 3166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "If <attachments> contains COLOR_ATTACHMENTm and m is greater than 3168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * or equal to the value of MAX_COLOR_ATTACHMENTS, then the error 3169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * INVALID_OPERATION is generated." 3170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * No mention is made of GL_AUXi being out of range. Therefore, we allow 3172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * any enum that can be allowed by the API (OpenGL ES 3.0 has a different 3173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * set of retrictions). 3174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 3175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < numAttachments; i++) { 3176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (_mesa_is_winsys_fbo(fb)) { 3177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (attachments[i]) { 3178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_ACCUM: 3179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_AUX0: 3180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_AUX1: 3181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_AUX2: 3182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_AUX3: 3183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Accumulation buffers and auxilary buffers were removed in 3184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OpenGL 3.1, and they never existed in OpenGL ES. 3185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 3186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->API != API_OPENGL) 3187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_enum; 3188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 3189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR: 3190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH: 3191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL: 3192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 3193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_BACK_LEFT: 3194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_BACK_RIGHT: 3195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRONT_LEFT: 3196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRONT_RIGHT: 3197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!_mesa_is_desktop_gl(ctx)) 3198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_enum; 3199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 3200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 3201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_enum; 3202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else { 3204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (attachments[i]) { 3205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_DEPTH_ATTACHMENT: 3206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_STENCIL_ATTACHMENT: 3207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 3208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT0: 3209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT1: 3210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT2: 3211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT3: 3212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT4: 3213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT5: 3214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT6: 3215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT7: 3216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT8: 3217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT9: 3218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT10: 3219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT11: 3220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT12: 3221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT13: 3222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT14: 3223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_COLOR_ATTACHMENT15: { 3224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const int k = attachments[i] - GL_COLOR_ATTACHMENT0; 3225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (k >= ctx->Const.MaxColorAttachments) { 3226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_OPERATION, 3227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "%s(attachment >= max. color attachments)", name); 3228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 3232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org goto invalid_enum; 3233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 3236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* We don't actually do anything for this yet. Just return after 3238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * validating the parameters and generating the required errors. 3239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 3240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orginvalid_enum: 3243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_error(ctx, GL_INVALID_ENUM, "%s(attachment)", name); 3244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 3245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 3246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 3248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, 3249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLenum *attachments, GLint x, GLint y, 3250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLsizei width, GLsizei height) 3251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 3252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org invalidate_framebuffer_storage(target, numAttachments, attachments, 3253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org x, y, width, height, 3254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glInvalidateSubFramebuffer"); 3255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 3256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid GLAPIENTRY 3258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, 3259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLenum *attachments) 3260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 3261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The GL_ARB_invalidate_subdata spec says: 3262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "The command 3264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * void InvalidateFramebuffer(enum target, 3266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * sizei numAttachments, 3267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * const enum *attachments); 3268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * is equivalent to the command InvalidateSubFramebuffer with <x>, <y>, 3270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * <width>, <height> equal to 0, 0, <MAX_VIEWPORT_DIMS[0]>, 3271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * <MAX_VIEWPORT_DIMS[1]> respectively." 3272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 3273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org invalidate_framebuffer_storage(target, numAttachments, attachments, 3274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0, 0, MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT, 3275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "glInvalidateFramebuffer"); 3276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 3277