2 * Mesa 3-D graphics library
5 * Copyright (C) 2010 LunarG Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Chia-I Wu <olv@lunarg.com>
29 #include "state_tracker/st_gl_api.h"
31 #include "pipe/p_context.h"
32 #include "pipe/p_screen.h"
33 #include "util/u_format.h"
34 #include "util/u_pointer.h"
35 #include "util/u_inlines.h"
36 #include "util/u_atomic.h"
37 #include "util/u_surface.h"
39 #include "main/mtypes.h"
40 #include "main/context.h"
41 #include "main/mfeatures.h"
42 #include "main/texobj.h"
43 #include "main/teximage.h"
44 #include "main/texstate.h"
45 #include "main/framebuffer.h"
46 #include "main/fbobject.h"
47 #include "main/renderbuffer.h"
48 #include "main/version.h"
49 #include "st_texture.h"
51 #include "st_context.h"
52 #include "st_format.h"
53 #include "st_cb_fbo.h"
54 #include "st_cb_flush.h"
55 #include "st_manager.h"
58 * Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
59 * Return NULL if the struct gl_framebuffer is a user-created framebuffer.
60 * We'll only return non-null for window system framebuffers.
61 * Note that this function may fail.
63 static INLINE struct st_framebuffer *
64 st_ws_framebuffer(struct gl_framebuffer *fb)
66 /* FBO cannot be casted. See st_new_framebuffer */
67 return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL);
71 * Map an attachment to a buffer index.
73 static INLINE gl_buffer_index
74 attachment_to_buffer_index(enum st_attachment_type statt)
76 gl_buffer_index index;
79 case ST_ATTACHMENT_FRONT_LEFT:
80 index = BUFFER_FRONT_LEFT;
82 case ST_ATTACHMENT_BACK_LEFT:
83 index = BUFFER_BACK_LEFT;
85 case ST_ATTACHMENT_FRONT_RIGHT:
86 index = BUFFER_FRONT_RIGHT;
88 case ST_ATTACHMENT_BACK_RIGHT:
89 index = BUFFER_BACK_RIGHT;
91 case ST_ATTACHMENT_DEPTH_STENCIL:
94 case ST_ATTACHMENT_ACCUM:
97 case ST_ATTACHMENT_SAMPLE:
107 * Map a buffer index to an attachment.
109 static INLINE enum st_attachment_type
110 buffer_index_to_attachment(gl_buffer_index index)
112 enum st_attachment_type statt;
115 case BUFFER_FRONT_LEFT:
116 statt = ST_ATTACHMENT_FRONT_LEFT;
118 case BUFFER_BACK_LEFT:
119 statt = ST_ATTACHMENT_BACK_LEFT;
121 case BUFFER_FRONT_RIGHT:
122 statt = ST_ATTACHMENT_FRONT_RIGHT;
124 case BUFFER_BACK_RIGHT:
125 statt = ST_ATTACHMENT_BACK_RIGHT;
128 statt = ST_ATTACHMENT_DEPTH_STENCIL;
131 statt = ST_ATTACHMENT_ACCUM;
134 statt = ST_ATTACHMENT_INVALID;
142 * Validate a framebuffer to make sure up-to-date pipe_textures are used.
145 st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
147 struct pipe_context *pipe = st->pipe;
148 struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
151 boolean changed = FALSE;
153 if (!p_atomic_read(&stfb->revalidate))
156 /* validate the fb */
157 if (!stfb->iface->validate(stfb->iface, stfb->statts, stfb->num_statts, textures))
160 width = stfb->Base.Width;
161 height = stfb->Base.Height;
163 for (i = 0; i < stfb->num_statts; i++) {
164 struct st_renderbuffer *strb;
165 struct pipe_surface *ps, surf_tmpl;
171 idx = attachment_to_buffer_index(stfb->statts[i]);
172 if (idx >= BUFFER_COUNT) {
173 pipe_resource_reference(&textures[i], NULL);
177 strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer);
179 if (strb->texture == textures[i]) {
180 pipe_resource_reference(&textures[i], NULL);
184 memset(&surf_tmpl, 0, sizeof(surf_tmpl));
185 u_surface_default_template(&surf_tmpl, textures[i],
186 PIPE_BIND_RENDER_TARGET);
187 ps = pipe->create_surface(pipe, textures[i], &surf_tmpl);
189 pipe_surface_reference(&strb->surface, ps);
190 pipe_resource_reference(&strb->texture, ps->texture);
191 /* ownership transfered */
192 pipe_surface_reference(&ps, NULL);
196 strb->Base.Width = strb->surface->width;
197 strb->Base.Height = strb->surface->height;
199 width = strb->Base.Width;
200 height = strb->Base.Height;
203 pipe_resource_reference(&textures[i], NULL);
207 st->dirty.st |= ST_NEW_FRAMEBUFFER;
208 _mesa_resize_framebuffer(st->ctx, &stfb->Base, width, height);
210 assert(stfb->Base.Width == width);
211 assert(stfb->Base.Height == height);
214 p_atomic_set(&stfb->revalidate, FALSE);
218 * Update the attachments to validate by looping the existing renderbuffers.
221 st_framebuffer_update_attachments(struct st_framebuffer *stfb)
225 stfb->num_statts = 0;
226 for (idx = 0; idx < BUFFER_COUNT; idx++) {
227 struct st_renderbuffer *strb;
228 enum st_attachment_type statt;
230 strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer);
231 if (!strb || strb->software)
234 statt = buffer_index_to_attachment(idx);
235 if (statt != ST_ATTACHMENT_INVALID &&
236 st_visual_have_buffers(stfb->iface->visual, 1 << statt))
237 stfb->statts[stfb->num_statts++] = statt;
240 p_atomic_set(&stfb->revalidate, TRUE);
244 * Add a renderbuffer to the framebuffer.
247 st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
250 struct gl_renderbuffer *rb;
251 enum pipe_format format;
258 /* do not distinguish depth/stencil buffers */
259 if (idx == BUFFER_STENCIL)
264 format = stfb->iface->visual->depth_stencil_format;
268 format = stfb->iface->visual->accum_format;
272 format = stfb->iface->visual->color_format;
277 if (format == PIPE_FORMAT_NONE)
280 samples = stfb->iface->visual->samples;
282 samples = st_get_msaa();
284 rb = st_new_renderbuffer_fb(format, samples, sw);
288 if (idx != BUFFER_DEPTH) {
289 _mesa_add_renderbuffer(&stfb->Base, idx, rb);
292 if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0))
293 _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, rb);
294 if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1))
295 _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb);
302 * Intialize a struct gl_config from a visual.
305 st_visual_to_context_mode(const struct st_visual *visual,
306 struct gl_config *mode)
308 memset(mode, 0, sizeof(*mode));
310 if (st_visual_have_buffers(visual, ST_ATTACHMENT_BACK_LEFT_MASK))
311 mode->doubleBufferMode = GL_TRUE;
312 if (st_visual_have_buffers(visual,
313 ST_ATTACHMENT_FRONT_RIGHT_MASK | ST_ATTACHMENT_BACK_RIGHT_MASK))
314 mode->stereoMode = GL_TRUE;
316 if (visual->color_format != PIPE_FORMAT_NONE) {
317 mode->rgbMode = GL_TRUE;
320 util_format_get_component_bits(visual->color_format,
321 UTIL_FORMAT_COLORSPACE_RGB, 0);
323 util_format_get_component_bits(visual->color_format,
324 UTIL_FORMAT_COLORSPACE_RGB, 1);
326 util_format_get_component_bits(visual->color_format,
327 UTIL_FORMAT_COLORSPACE_RGB, 2);
329 util_format_get_component_bits(visual->color_format,
330 UTIL_FORMAT_COLORSPACE_RGB, 3);
332 mode->rgbBits = mode->redBits +
333 mode->greenBits + mode->blueBits + mode->alphaBits;
336 if (visual->depth_stencil_format != PIPE_FORMAT_NONE) {
338 util_format_get_component_bits(visual->depth_stencil_format,
339 UTIL_FORMAT_COLORSPACE_ZS, 0);
341 util_format_get_component_bits(visual->depth_stencil_format,
342 UTIL_FORMAT_COLORSPACE_ZS, 1);
344 mode->haveDepthBuffer = mode->depthBits > 0;
345 mode->haveStencilBuffer = mode->stencilBits > 0;
348 if (visual->accum_format != PIPE_FORMAT_NONE) {
349 mode->haveAccumBuffer = GL_TRUE;
352 util_format_get_component_bits(visual->accum_format,
353 UTIL_FORMAT_COLORSPACE_RGB, 0);
354 mode->accumGreenBits =
355 util_format_get_component_bits(visual->accum_format,
356 UTIL_FORMAT_COLORSPACE_RGB, 1);
357 mode->accumBlueBits =
358 util_format_get_component_bits(visual->accum_format,
359 UTIL_FORMAT_COLORSPACE_RGB, 2);
360 mode->accumAlphaBits =
361 util_format_get_component_bits(visual->accum_format,
362 UTIL_FORMAT_COLORSPACE_RGB, 3);
365 if (visual->samples) {
366 mode->sampleBuffers = 1;
367 mode->samples = visual->samples;
372 * Determine the default draw or read buffer from a visual.
375 st_visual_to_default_buffer(const struct st_visual *visual,
376 GLenum *buffer, GLint *index)
378 enum st_attachment_type statt;
382 statt = visual->render_buffer;
383 /* do nothing if an invalid render buffer is specified */
384 if (statt == ST_ATTACHMENT_INVALID ||
385 !st_visual_have_buffers(visual, 1 << statt))
389 case ST_ATTACHMENT_FRONT_LEFT:
391 idx = BUFFER_FRONT_LEFT;
393 case ST_ATTACHMENT_BACK_LEFT:
395 idx = BUFFER_BACK_LEFT;
397 case ST_ATTACHMENT_FRONT_RIGHT:
398 buf = GL_FRONT_RIGHT;
399 idx = BUFFER_FRONT_RIGHT;
401 case ST_ATTACHMENT_BACK_RIGHT:
403 idx = BUFFER_BACK_RIGHT;
411 if (buf != GL_NONE) {
420 * Create a framebuffer from a manager interface.
422 static struct st_framebuffer *
423 st_framebuffer_create(struct st_framebuffer_iface *stfbi)
425 struct st_framebuffer *stfb;
426 struct gl_config mode;
432 stfb = CALLOC_STRUCT(st_framebuffer);
436 st_visual_to_context_mode(stfbi->visual, &mode);
437 _mesa_initialize_window_framebuffer(&stfb->Base, &mode);
439 /* modify the draw/read buffers of the fb */
440 st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorDrawBuffer[0],
441 &stfb->Base._ColorDrawBufferIndexes[0]);
442 st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorReadBuffer,
443 &stfb->Base._ColorReadBufferIndex);
447 /* add the color buffer */
448 idx = stfb->Base._ColorDrawBufferIndexes[0];
449 if (!st_framebuffer_add_renderbuffer(stfb, idx)) {
454 st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH);
455 st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM);
457 st_framebuffer_update_attachments(stfb);
459 stfb->Base.Initialized = GL_TRUE;
465 * Reference a framebuffer.
468 st_framebuffer_reference(struct st_framebuffer **ptr,
469 struct st_framebuffer *stfb)
471 struct gl_framebuffer *fb = &stfb->Base;
472 _mesa_reference_framebuffer((struct gl_framebuffer **) ptr, fb);
476 st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi,
477 struct st_framebuffer_iface *stfbi)
479 struct st_context *st = (struct st_context *) stctxi;
480 struct st_framebuffer *stfb;
482 /* either draw or read winsys fb */
483 stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer);
484 if (!stfb || stfb->iface != stfbi)
485 stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer);
487 if (stfb && stfb->iface == stfbi) {
488 p_atomic_set(&stfb->revalidate, TRUE);
491 /* This function is probably getting called when we've detected a
492 * change in a window's size but the currently bound context is
493 * not bound to that window.
494 * If the st_framebuffer_iface structure had a pointer to the
495 * corresponding st_framebuffer we'd be able to handle this.
501 st_context_flush(struct st_context_iface *stctxi, unsigned flags,
502 struct pipe_fence_handle **fence)
504 struct st_context *st = (struct st_context *) stctxi;
506 if (flags & ST_FLUSH_FRONT)
507 st_manager_flush_frontbuffer(st);
511 st_context_teximage(struct st_context_iface *stctxi,
512 enum st_texture_type target,
513 int level, enum pipe_format internal_format,
514 struct pipe_resource *tex, boolean mipmap)
516 struct st_context *st = (struct st_context *) stctxi;
517 struct gl_context *ctx = st->ctx;
518 struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
519 struct gl_texture_object *texObj;
520 struct gl_texture_image *texImage;
521 struct st_texture_object *stObj;
522 struct st_texture_image *stImage;
523 GLenum internalFormat;
524 GLuint width, height, depth;
528 target = GL_TEXTURE_1D;
531 target = GL_TEXTURE_2D;
534 target = GL_TEXTURE_3D;
536 case ST_TEXTURE_RECT:
537 target = GL_TEXTURE_RECTANGLE_ARB;
544 texObj = _mesa_select_tex_object(ctx, texUnit, target);
545 _mesa_lock_texture(ctx, texObj);
547 stObj = st_texture_object(texObj);
548 /* switch to surface based */
549 if (!stObj->surface_based) {
550 _mesa_clear_texture_object(ctx, texObj);
551 stObj->surface_based = GL_TRUE;
554 texImage = _mesa_get_tex_image(ctx, texObj, target, level);
555 stImage = st_texture_image(texImage);
560 * XXX When internal_format and tex->format differ, st_finalize_texture
561 * needs to allocate a new texture with internal_format and copy the
562 * texture here into the new one. It will result in surface_copy being
563 * called on surfaces whose formats differ.
565 * To avoid that, internal_format is (wrongly) ignored here. A sane fix
566 * is to use a sampler view.
568 if (!st_sampler_compat_formats(tex->format, internal_format))
569 internal_format = tex->format;
571 if (util_format_get_component_bits(internal_format,
572 UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
573 internalFormat = GL_RGBA;
575 internalFormat = GL_RGB;
577 texFormat = st_ChooseTextureFormat(ctx, internalFormat,
578 GL_BGRA, GL_UNSIGNED_BYTE);
580 _mesa_init_teximage_fields(ctx, target, texImage,
581 tex->width0, tex->height0, 1, 0,
582 internalFormat, texFormat);
585 height = tex->height0;
588 /* grow the image size until we hit level = 0 */
600 _mesa_clear_texture_image(ctx, texImage);
601 width = height = depth = 0;
604 pipe_resource_reference(&stImage->pt, tex);
605 stObj->width0 = width;
606 stObj->height0 = height;
607 stObj->depth0 = depth;
609 _mesa_dirty_texobj(ctx, texObj, GL_TRUE);
610 _mesa_unlock_texture(ctx, texObj);
616 st_context_copy(struct st_context_iface *stctxi,
617 struct st_context_iface *stsrci, unsigned mask)
619 struct st_context *st = (struct st_context *) stctxi;
620 struct st_context *src = (struct st_context *) stsrci;
622 _mesa_copy_context(src->ctx, st->ctx, mask);
626 st_context_share(struct st_context_iface *stctxi,
627 struct st_context_iface *stsrci)
629 struct st_context *st = (struct st_context *) stctxi;
630 struct st_context *src = (struct st_context *) stsrci;
632 return _mesa_share_state(st->ctx, src->ctx);
636 st_context_destroy(struct st_context_iface *stctxi)
638 struct st_context *st = (struct st_context *) stctxi;
639 st_destroy_context(st);
642 static struct st_context_iface *
643 st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
644 const struct st_context_attribs *attribs,
645 struct st_context_iface *shared_stctxi)
647 struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
648 struct st_context *st;
649 struct pipe_context *pipe;
650 struct gl_config mode;
653 if (!(stapi->profile_mask & (1 << attribs->profile)))
656 switch (attribs->profile) {
657 case ST_PROFILE_DEFAULT:
660 case ST_PROFILE_OPENGL_ES1:
663 case ST_PROFILE_OPENGL_ES2:
666 case ST_PROFILE_OPENGL_CORE:
672 pipe = smapi->screen->context_create(smapi->screen, NULL);
676 st_visual_to_context_mode(&attribs->visual, &mode);
677 st = st_create_context(api, pipe, &mode, shared_ctx);
683 /* need to perform version check */
684 if (attribs->major > 1 || attribs->minor > 0) {
685 _mesa_compute_version(st->ctx);
687 /* is the actual version less than the requested version? */
688 if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor <
689 attribs->major * 10 + attribs->minor) {
690 st_destroy_context(st);
695 st->invalidate_on_gl_viewport =
696 smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE);
698 st->iface.destroy = st_context_destroy;
699 st->iface.notify_invalid_framebuffer =
700 st_context_notify_invalid_framebuffer;
701 st->iface.flush = st_context_flush;
702 st->iface.teximage = st_context_teximage;
703 st->iface.copy = st_context_copy;
704 st->iface.share = st_context_share;
705 st->iface.st_context_private = (void *) smapi;
710 static struct st_context_iface *
711 st_api_get_current(struct st_api *stapi)
713 GET_CURRENT_CONTEXT(ctx);
714 struct st_context *st = (ctx) ? ctx->st : NULL;
716 return (st) ? &st->iface : NULL;
719 static struct st_framebuffer *
720 st_framebuffer_reuse_or_create(struct gl_framebuffer *fb,
721 struct st_framebuffer_iface *stfbi)
723 struct st_framebuffer *cur = st_ws_framebuffer(fb), *stfb = NULL;
725 if (cur && cur->iface == stfbi) {
726 /* reuse the current stfb */
727 st_framebuffer_reference(&stfb, cur);
730 /* create a new one */
731 stfb = st_framebuffer_create(stfbi);
738 st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
739 struct st_framebuffer_iface *stdrawi,
740 struct st_framebuffer_iface *streadi)
742 struct st_context *st = (struct st_context *) stctxi;
743 struct st_framebuffer *stdraw, *stread;
746 _glapi_check_multithread();
749 /* reuse or create the draw fb */
750 stdraw = st_framebuffer_reuse_or_create(st->ctx->WinSysDrawBuffer,
752 if (streadi != stdrawi) {
753 /* do the same for the read fb */
754 stread = st_framebuffer_reuse_or_create(st->ctx->WinSysReadBuffer,
759 /* reuse the draw fb for the read fb */
761 st_framebuffer_reference(&stread, stdraw);
764 if (stdraw && stread) {
765 if (stctxi != st_api_get_current(stapi)) {
766 p_atomic_set(&stdraw->revalidate, TRUE);
767 p_atomic_set(&stread->revalidate, TRUE);
769 st_framebuffer_validate(stdraw, st);
770 if (stread != stdraw)
771 st_framebuffer_validate(stread, st);
773 /* modify the draw/read buffers of the context */
775 st_visual_to_default_buffer(stdraw->iface->visual,
776 &st->ctx->Color.DrawBuffer[0], NULL);
779 st_visual_to_default_buffer(stread->iface->visual,
780 &st->ctx->Pixel.ReadBuffer, NULL);
783 ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
786 struct gl_framebuffer *incomplete = _mesa_get_incomplete_framebuffer();
787 ret = _mesa_make_current(st->ctx, incomplete, incomplete);
790 st_framebuffer_reference(&stdraw, NULL);
791 st_framebuffer_reference(&stread, NULL);
794 ret = _mesa_make_current(NULL, NULL, NULL);
801 st_api_get_proc_address(struct st_api *stapi, const char *procname)
803 return (st_proc_t) _glapi_get_proc_address(procname);
807 st_api_destroy(struct st_api *stapi)
812 * Flush the front buffer if the current context renders to the front buffer.
815 st_manager_flush_frontbuffer(struct st_context *st)
817 struct st_framebuffer *stfb = st_ws_framebuffer(st->ctx->DrawBuffer);
818 struct st_renderbuffer *strb = NULL;
821 strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
825 /* never a dummy fb */
827 stfb->iface->flush_front(stfb->iface, ST_ATTACHMENT_FRONT_LEFT);
831 * Return the surface of an EGLImage.
832 * FIXME: I think this should operate on resources, not surfaces
834 struct pipe_surface *
835 st_manager_get_egl_image_surface(struct st_context *st,
836 void *eglimg, unsigned usage)
838 struct st_manager *smapi =
839 (struct st_manager *) st->iface.st_context_private;
840 struct st_egl_image stimg;
841 struct pipe_surface *ps, surf_tmpl;
843 if (!smapi || !smapi->get_egl_image)
846 memset(&stimg, 0, sizeof(stimg));
847 if (!smapi->get_egl_image(smapi, eglimg, &stimg))
850 memset(&surf_tmpl, 0, sizeof(surf_tmpl));
851 surf_tmpl.format = stimg.texture->format;
852 surf_tmpl.usage = usage;
853 surf_tmpl.u.tex.level = stimg.level;
854 surf_tmpl.u.tex.first_layer = stimg.layer;
855 surf_tmpl.u.tex.last_layer = stimg.layer;
856 ps = st->pipe->create_surface(st->pipe, stimg.texture, &surf_tmpl);
857 pipe_resource_reference(&stimg.texture, NULL);
863 * Re-validate the framebuffers.
866 st_manager_validate_framebuffers(struct st_context *st)
868 struct st_framebuffer *stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
869 struct st_framebuffer *stread = st_ws_framebuffer(st->ctx->ReadBuffer);
872 st_framebuffer_validate(stdraw, st);
873 if (stread && stread != stdraw)
874 st_framebuffer_validate(stread, st);
878 * Add a color renderbuffer on demand.
881 st_manager_add_color_renderbuffer(struct st_context *st,
882 struct gl_framebuffer *fb,
885 struct st_framebuffer *stfb = st_ws_framebuffer(fb);
891 if (stfb->Base.Attachment[idx].Renderbuffer)
895 case BUFFER_FRONT_LEFT:
896 case BUFFER_BACK_LEFT:
897 case BUFFER_FRONT_RIGHT:
898 case BUFFER_BACK_RIGHT:
905 if (!st_framebuffer_add_renderbuffer(stfb, idx))
908 st_framebuffer_update_attachments(stfb);
909 st_invalidate_state(st->ctx, _NEW_BUFFERS);
914 static const struct st_api st_gl_api = {
915 "Mesa " MESA_VERSION_STRING,
918 ST_PROFILE_DEFAULT_MASK |
921 ST_PROFILE_OPENGL_ES1_MASK |
924 ST_PROFILE_OPENGL_ES2_MASK |
928 st_api_get_proc_address,
929 st_api_create_context,
935 st_gl_api_create(void)
937 return (struct st_api *) &st_gl_api;