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"
38 #include "main/mtypes.h"
39 #include "main/context.h"
40 #include "main/texobj.h"
41 #include "main/teximage.h"
42 #include "main/texstate.h"
43 #include "main/texfetch.h"
44 #include "main/framebuffer.h"
45 #include "main/fbobject.h"
46 #include "main/renderbuffer.h"
47 #include "main/version.h"
48 #include "st_texture.h"
50 #include "st_context.h"
51 #include "st_format.h"
52 #include "st_cb_fbo.h"
53 #include "st_cb_flush.h"
54 #include "st_manager.h"
57 * Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
58 * Return NULL if the struct gl_framebuffer is a user-created framebuffer.
59 * We'll only return non-null for window system framebuffers.
60 * Note that this function may fail.
62 static INLINE
struct st_framebuffer
*
63 st_ws_framebuffer(struct gl_framebuffer
*fb
)
65 /* FBO cannot be casted. See st_new_framebuffer */
66 return (struct st_framebuffer
*) ((fb
&& !fb
->Name
) ? fb
: NULL
);
70 * Map an attachment to a buffer index.
72 static INLINE gl_buffer_index
73 attachment_to_buffer_index(enum st_attachment_type statt
)
75 gl_buffer_index index
;
78 case ST_ATTACHMENT_FRONT_LEFT
:
79 index
= BUFFER_FRONT_LEFT
;
81 case ST_ATTACHMENT_BACK_LEFT
:
82 index
= BUFFER_BACK_LEFT
;
84 case ST_ATTACHMENT_FRONT_RIGHT
:
85 index
= BUFFER_FRONT_RIGHT
;
87 case ST_ATTACHMENT_BACK_RIGHT
:
88 index
= BUFFER_BACK_RIGHT
;
90 case ST_ATTACHMENT_DEPTH_STENCIL
:
93 case ST_ATTACHMENT_ACCUM
:
96 case ST_ATTACHMENT_SAMPLE
:
106 * Map a buffer index to an attachment.
108 static INLINE
enum st_attachment_type
109 buffer_index_to_attachment(gl_buffer_index index
)
111 enum st_attachment_type statt
;
114 case BUFFER_FRONT_LEFT
:
115 statt
= ST_ATTACHMENT_FRONT_LEFT
;
117 case BUFFER_BACK_LEFT
:
118 statt
= ST_ATTACHMENT_BACK_LEFT
;
120 case BUFFER_FRONT_RIGHT
:
121 statt
= ST_ATTACHMENT_FRONT_RIGHT
;
123 case BUFFER_BACK_RIGHT
:
124 statt
= ST_ATTACHMENT_BACK_RIGHT
;
127 statt
= ST_ATTACHMENT_DEPTH_STENCIL
;
130 statt
= ST_ATTACHMENT_ACCUM
;
133 statt
= ST_ATTACHMENT_INVALID
;
141 * Validate a framebuffer to make sure up-to-date pipe_textures are used.
144 st_framebuffer_validate(struct st_framebuffer
*stfb
, struct st_context
*st
)
146 struct pipe_screen
*screen
= st
->pipe
->screen
;
147 struct pipe_resource
*textures
[ST_ATTACHMENT_COUNT
];
150 boolean changed
= FALSE
;
152 if (!p_atomic_read(&stfb
->revalidate
))
155 /* validate the fb */
156 if (!stfb
->iface
->validate(stfb
->iface
, stfb
->statts
, stfb
->num_statts
, textures
))
159 width
= stfb
->Base
.Width
;
160 height
= stfb
->Base
.Height
;
162 for (i
= 0; i
< stfb
->num_statts
; i
++) {
163 struct st_renderbuffer
*strb
;
164 struct pipe_surface
*ps
;
170 idx
= attachment_to_buffer_index(stfb
->statts
[i
]);
171 if (idx
>= BUFFER_COUNT
) {
172 pipe_resource_reference(&textures
[i
], NULL
);
176 strb
= st_renderbuffer(stfb
->Base
.Attachment
[idx
].Renderbuffer
);
178 if (strb
->texture
== textures
[i
]) {
179 pipe_resource_reference(&textures
[i
], NULL
);
183 ps
= screen
->get_tex_surface(screen
, textures
[i
], 0, 0, 0,
184 PIPE_BIND_RENDER_TARGET
);
186 pipe_surface_reference(&strb
->surface
, ps
);
187 pipe_resource_reference(&strb
->texture
, ps
->texture
);
188 /* ownership transfered */
189 pipe_surface_reference(&ps
, NULL
);
193 strb
->Base
.Width
= strb
->surface
->width
;
194 strb
->Base
.Height
= strb
->surface
->height
;
196 width
= strb
->Base
.Width
;
197 height
= strb
->Base
.Height
;
200 pipe_resource_reference(&textures
[i
], NULL
);
204 st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
205 _mesa_resize_framebuffer(st
->ctx
, &stfb
->Base
, width
, height
);
207 assert(stfb
->Base
.Width
== width
);
208 assert(stfb
->Base
.Height
== height
);
211 p_atomic_set(&stfb
->revalidate
, FALSE
);
215 * Update the attachments to validate by looping the existing renderbuffers.
218 st_framebuffer_update_attachments(struct st_framebuffer
*stfb
)
222 stfb
->num_statts
= 0;
223 for (idx
= 0; idx
< BUFFER_COUNT
; idx
++) {
224 struct st_renderbuffer
*strb
;
225 enum st_attachment_type statt
;
227 strb
= st_renderbuffer(stfb
->Base
.Attachment
[idx
].Renderbuffer
);
228 if (!strb
|| strb
->software
)
231 statt
= buffer_index_to_attachment(idx
);
232 if (statt
!= ST_ATTACHMENT_INVALID
&&
233 st_visual_have_buffers(stfb
->iface
->visual
, 1 << statt
))
234 stfb
->statts
[stfb
->num_statts
++] = statt
;
237 p_atomic_set(&stfb
->revalidate
, TRUE
);
241 * Add a renderbuffer to the framebuffer.
244 st_framebuffer_add_renderbuffer(struct st_framebuffer
*stfb
,
247 struct gl_renderbuffer
*rb
;
248 enum pipe_format format
;
255 /* do not distinguish depth/stencil buffers */
256 if (idx
== BUFFER_STENCIL
)
261 format
= stfb
->iface
->visual
->depth_stencil_format
;
265 format
= stfb
->iface
->visual
->accum_format
;
269 format
= stfb
->iface
->visual
->color_format
;
274 if (format
== PIPE_FORMAT_NONE
)
277 samples
= stfb
->iface
->visual
->samples
;
279 samples
= st_get_msaa();
281 rb
= st_new_renderbuffer_fb(format
, samples
, sw
);
285 if (idx
!= BUFFER_DEPTH
) {
286 _mesa_add_renderbuffer(&stfb
->Base
, idx
, rb
);
289 if (util_format_get_component_bits(format
, UTIL_FORMAT_COLORSPACE_ZS
, 0))
290 _mesa_add_renderbuffer(&stfb
->Base
, BUFFER_DEPTH
, rb
);
291 if (util_format_get_component_bits(format
, UTIL_FORMAT_COLORSPACE_ZS
, 1))
292 _mesa_add_renderbuffer(&stfb
->Base
, BUFFER_STENCIL
, rb
);
299 * Intialize a struct gl_config from a visual.
302 st_visual_to_context_mode(const struct st_visual
*visual
,
303 struct gl_config
*mode
)
305 memset(mode
, 0, sizeof(*mode
));
307 if (st_visual_have_buffers(visual
, ST_ATTACHMENT_BACK_LEFT_MASK
))
308 mode
->doubleBufferMode
= GL_TRUE
;
309 if (st_visual_have_buffers(visual
,
310 ST_ATTACHMENT_FRONT_RIGHT_MASK
| ST_ATTACHMENT_BACK_RIGHT_MASK
))
311 mode
->stereoMode
= GL_TRUE
;
313 if (visual
->color_format
!= PIPE_FORMAT_NONE
) {
314 mode
->rgbMode
= GL_TRUE
;
317 util_format_get_component_bits(visual
->color_format
,
318 UTIL_FORMAT_COLORSPACE_RGB
, 0);
320 util_format_get_component_bits(visual
->color_format
,
321 UTIL_FORMAT_COLORSPACE_RGB
, 1);
323 util_format_get_component_bits(visual
->color_format
,
324 UTIL_FORMAT_COLORSPACE_RGB
, 2);
326 util_format_get_component_bits(visual
->color_format
,
327 UTIL_FORMAT_COLORSPACE_RGB
, 3);
329 mode
->rgbBits
= mode
->redBits
+
330 mode
->greenBits
+ mode
->blueBits
+ mode
->alphaBits
;
333 if (visual
->depth_stencil_format
!= PIPE_FORMAT_NONE
) {
335 util_format_get_component_bits(visual
->depth_stencil_format
,
336 UTIL_FORMAT_COLORSPACE_ZS
, 0);
338 util_format_get_component_bits(visual
->depth_stencil_format
,
339 UTIL_FORMAT_COLORSPACE_ZS
, 1);
341 mode
->haveDepthBuffer
= mode
->depthBits
> 0;
342 mode
->haveStencilBuffer
= mode
->stencilBits
> 0;
345 if (visual
->accum_format
!= PIPE_FORMAT_NONE
) {
346 mode
->haveAccumBuffer
= GL_TRUE
;
349 util_format_get_component_bits(visual
->accum_format
,
350 UTIL_FORMAT_COLORSPACE_RGB
, 0);
351 mode
->accumGreenBits
=
352 util_format_get_component_bits(visual
->accum_format
,
353 UTIL_FORMAT_COLORSPACE_RGB
, 1);
354 mode
->accumBlueBits
=
355 util_format_get_component_bits(visual
->accum_format
,
356 UTIL_FORMAT_COLORSPACE_RGB
, 2);
357 mode
->accumAlphaBits
=
358 util_format_get_component_bits(visual
->accum_format
,
359 UTIL_FORMAT_COLORSPACE_RGB
, 3);
362 if (visual
->samples
) {
363 mode
->sampleBuffers
= 1;
364 mode
->samples
= visual
->samples
;
369 * Determine the default draw or read buffer from a visual.
372 st_visual_to_default_buffer(const struct st_visual
*visual
,
373 GLenum
*buffer
, GLint
*index
)
375 enum st_attachment_type statt
;
379 statt
= visual
->render_buffer
;
380 /* do nothing if an invalid render buffer is specified */
381 if (statt
== ST_ATTACHMENT_INVALID
||
382 !st_visual_have_buffers(visual
, 1 << statt
))
386 case ST_ATTACHMENT_FRONT_LEFT
:
388 idx
= BUFFER_FRONT_LEFT
;
390 case ST_ATTACHMENT_BACK_LEFT
:
392 idx
= BUFFER_BACK_LEFT
;
394 case ST_ATTACHMENT_FRONT_RIGHT
:
395 buf
= GL_FRONT_RIGHT
;
396 idx
= BUFFER_FRONT_RIGHT
;
398 case ST_ATTACHMENT_BACK_RIGHT
:
400 idx
= BUFFER_BACK_RIGHT
;
408 if (buf
!= GL_NONE
) {
417 * Create a framebuffer from a manager interface.
419 static struct st_framebuffer
*
420 st_framebuffer_create(struct st_framebuffer_iface
*stfbi
)
422 struct st_framebuffer
*stfb
;
423 struct gl_config mode
;
426 stfb
= CALLOC_STRUCT(st_framebuffer
);
430 /* for FBO-only context */
432 struct gl_framebuffer
*base
= _mesa_get_incomplete_framebuffer();
439 st_visual_to_context_mode(stfbi
->visual
, &mode
);
440 _mesa_initialize_window_framebuffer(&stfb
->Base
, &mode
);
442 /* modify the draw/read buffers of the fb */
443 st_visual_to_default_buffer(stfbi
->visual
, &stfb
->Base
.ColorDrawBuffer
[0],
444 &stfb
->Base
._ColorDrawBufferIndexes
[0]);
445 st_visual_to_default_buffer(stfbi
->visual
, &stfb
->Base
.ColorReadBuffer
,
446 &stfb
->Base
._ColorReadBufferIndex
);
450 /* add the color buffer */
451 idx
= stfb
->Base
._ColorDrawBufferIndexes
[0];
452 if (!st_framebuffer_add_renderbuffer(stfb
, idx
)) {
457 st_framebuffer_add_renderbuffer(stfb
, BUFFER_DEPTH
);
458 st_framebuffer_add_renderbuffer(stfb
, BUFFER_ACCUM
);
460 st_framebuffer_update_attachments(stfb
);
462 stfb
->Base
.Initialized
= GL_TRUE
;
468 * Reference a framebuffer.
471 st_framebuffer_reference(struct st_framebuffer
**ptr
,
472 struct st_framebuffer
*stfb
)
474 struct gl_framebuffer
*fb
= &stfb
->Base
;
475 _mesa_reference_framebuffer((struct gl_framebuffer
**) ptr
, fb
);
479 st_context_notify_invalid_framebuffer(struct st_context_iface
*stctxi
,
480 struct st_framebuffer_iface
*stfbi
)
482 struct st_context
*st
= (struct st_context
*) stctxi
;
483 struct st_framebuffer
*stfb
;
485 /* either draw or read winsys fb */
486 stfb
= st_ws_framebuffer(st
->ctx
->WinSysDrawBuffer
);
487 if (!stfb
|| stfb
->iface
!= stfbi
)
488 stfb
= st_ws_framebuffer(st
->ctx
->WinSysReadBuffer
);
490 if (stfb
&& stfb
->iface
== stfbi
) {
491 p_atomic_set(&stfb
->revalidate
, TRUE
);
494 /* This function is probably getting called when we've detected a
495 * change in a window's size but the currently bound context is
496 * not bound to that window.
497 * If the st_framebuffer_iface structure had a pointer to the
498 * corresponding st_framebuffer we'd be able to handle this.
504 st_context_flush(struct st_context_iface
*stctxi
, unsigned flags
,
505 struct pipe_fence_handle
**fence
)
507 struct st_context
*st
= (struct st_context
*) stctxi
;
508 st_flush(st
, flags
, fence
);
509 if (flags
& PIPE_FLUSH_RENDER_CACHE
)
510 st_manager_flush_frontbuffer(st
);
514 st_context_teximage(struct st_context_iface
*stctxi
, enum st_texture_type target
,
515 int level
, enum pipe_format internal_format
,
516 struct pipe_resource
*tex
, boolean mipmap
)
518 struct st_context
*st
= (struct st_context
*) stctxi
;
519 struct gl_context
*ctx
= st
->ctx
;
520 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
521 struct gl_texture_object
*texObj
;
522 struct gl_texture_image
*texImage
;
523 struct st_texture_object
*stObj
;
524 struct st_texture_image
*stImage
;
525 GLenum internalFormat
;
526 GLuint width
, height
, depth
;
530 target
= GL_TEXTURE_1D
;
533 target
= GL_TEXTURE_2D
;
536 target
= GL_TEXTURE_3D
;
538 case ST_TEXTURE_RECT
:
539 target
= GL_TEXTURE_RECTANGLE_ARB
;
546 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
547 _mesa_lock_texture(ctx
, texObj
);
549 stObj
= st_texture_object(texObj
);
550 /* switch to surface based */
551 if (!stObj
->surface_based
) {
552 _mesa_clear_texture_object(ctx
, texObj
);
553 stObj
->surface_based
= GL_TRUE
;
556 texImage
= _mesa_get_tex_image(ctx
, texObj
, target
, level
);
557 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
;
576 _mesa_init_teximage_fields(ctx
, target
, texImage
,
577 tex
->width0
, tex
->height0
, 1, 0, internalFormat
);
578 texImage
->TexFormat
= st_ChooseTextureFormat(ctx
, internalFormat
,
579 GL_RGBA
, GL_UNSIGNED_BYTE
);
580 _mesa_set_fetch_functions(texImage
, 2);
583 height
= tex
->height0
;
586 /* grow the image size until we hit level = 0 */
598 _mesa_clear_texture_image(ctx
, texImage
);
599 width
= height
= depth
= 0;
602 pipe_resource_reference(&stImage
->pt
, tex
);
603 stObj
->width0
= width
;
604 stObj
->height0
= height
;
605 stObj
->depth0
= depth
;
607 _mesa_dirty_texobj(ctx
, texObj
, GL_TRUE
);
608 _mesa_unlock_texture(ctx
, texObj
);
614 st_context_destroy(struct st_context_iface
*stctxi
)
616 struct st_context
*st
= (struct st_context
*) stctxi
;
617 st_destroy_context(st
);
620 static struct st_context_iface
*
621 st_api_create_context(struct st_api
*stapi
, struct st_manager
*smapi
,
622 const struct st_context_attribs
*attribs
,
623 struct st_context_iface
*shared_stctxi
)
625 struct st_context
*shared_ctx
= (struct st_context
*) shared_stctxi
;
626 struct st_context
*st
;
627 struct pipe_context
*pipe
;
628 struct gl_config mode
;
631 if (!(stapi
->profile_mask
& (1 << attribs
->profile
)))
634 switch (attribs
->profile
) {
635 case ST_PROFILE_DEFAULT
:
638 case ST_PROFILE_OPENGL_ES1
:
641 case ST_PROFILE_OPENGL_ES2
:
644 case ST_PROFILE_OPENGL_CORE
:
650 pipe
= smapi
->screen
->context_create(smapi
->screen
, NULL
);
654 st_visual_to_context_mode(&attribs
->visual
, &mode
);
655 st
= st_create_context(api
, pipe
, &mode
, shared_ctx
);
661 /* need to perform version check */
662 if (attribs
->major
> 1 || attribs
->minor
> 0) {
663 _mesa_compute_version(st
->ctx
);
665 if (st
->ctx
->VersionMajor
< attribs
->major
||
666 st
->ctx
->VersionMajor
< attribs
->minor
) {
667 st_destroy_context(st
);
672 st
->invalidate_on_gl_viewport
=
673 smapi
->get_param(smapi
, ST_MANAGER_BROKEN_INVALIDATE
);
675 st
->iface
.destroy
= st_context_destroy
;
676 st
->iface
.notify_invalid_framebuffer
=
677 st_context_notify_invalid_framebuffer
;
678 st
->iface
.flush
= st_context_flush
;
679 st
->iface
.teximage
= st_context_teximage
;
680 st
->iface
.copy
= NULL
;
681 st
->iface
.st_context_private
= (void *) smapi
;
687 st_api_make_current(struct st_api
*stapi
, struct st_context_iface
*stctxi
,
688 struct st_framebuffer_iface
*stdrawi
,
689 struct st_framebuffer_iface
*streadi
)
691 struct st_context
*st
= (struct st_context
*) stctxi
;
692 struct st_framebuffer
*stdraw
, *stread
, *stfb
;
695 _glapi_check_multithread();
698 /* reuse/create the draw fb */
699 stfb
= st_ws_framebuffer(st
->ctx
->WinSysDrawBuffer
);
700 if (stfb
&& stfb
->iface
== stdrawi
) {
702 st_framebuffer_reference(&stdraw
, stfb
);
705 stdraw
= st_framebuffer_create(stdrawi
);
708 /* reuse/create the read fb */
709 stfb
= st_ws_framebuffer(st
->ctx
->WinSysReadBuffer
);
710 if (!stfb
|| stfb
->iface
!= streadi
)
712 if (stfb
&& stfb
->iface
== streadi
) {
714 st_framebuffer_reference(&stread
, stfb
);
717 stread
= st_framebuffer_create(streadi
);
720 if (stdraw
&& stread
) {
721 st_framebuffer_validate(stdraw
, st
);
722 if (stread
!= stdraw
)
723 st_framebuffer_validate(stread
, st
);
725 /* modify the draw/read buffers of the context */
727 st_visual_to_default_buffer(stdraw
->iface
->visual
,
728 &st
->ctx
->Color
.DrawBuffer
[0], NULL
);
731 st_visual_to_default_buffer(stread
->iface
->visual
,
732 &st
->ctx
->Pixel
.ReadBuffer
, NULL
);
735 ret
= _mesa_make_current(st
->ctx
, &stdraw
->Base
, &stread
->Base
);
741 st_framebuffer_reference(&stdraw
, NULL
);
742 st_framebuffer_reference(&stread
, NULL
);
745 ret
= _mesa_make_current(NULL
, NULL
, NULL
);
751 static struct st_context_iface
*
752 st_api_get_current(struct st_api
*stapi
)
754 GET_CURRENT_CONTEXT(ctx
);
755 struct st_context
*st
= (ctx
) ? ctx
->st
: NULL
;
757 return (st
) ? &st
->iface
: NULL
;
761 st_api_get_proc_address(struct st_api
*stapi
, const char *procname
)
763 return (st_proc_t
) _glapi_get_proc_address(procname
);
767 st_api_destroy(struct st_api
*stapi
)
772 * Flush the front buffer if the current context renders to the front buffer.
775 st_manager_flush_frontbuffer(struct st_context
*st
)
777 struct st_framebuffer
*stfb
= st_ws_framebuffer(st
->ctx
->DrawBuffer
);
778 struct st_renderbuffer
*strb
= NULL
;
781 strb
= st_renderbuffer(stfb
->Base
.Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
785 /* never a dummy fb */
787 stfb
->iface
->flush_front(stfb
->iface
, ST_ATTACHMENT_FRONT_LEFT
);
791 * Return the surface of an EGLImage.
793 struct pipe_surface
*
794 st_manager_get_egl_image_surface(struct st_context
*st
,
795 void *eglimg
, unsigned usage
)
797 struct st_manager
*smapi
=
798 (struct st_manager
*) st
->iface
.st_context_private
;
799 struct st_egl_image stimg
;
800 struct pipe_surface
*ps
;
802 if (!smapi
|| !smapi
->get_egl_image
)
805 memset(&stimg
, 0, sizeof(stimg
));
806 if (!smapi
->get_egl_image(smapi
, eglimg
, &stimg
))
809 ps
= smapi
->screen
->get_tex_surface(smapi
->screen
,
810 stimg
.texture
, stimg
.face
, stimg
.level
, stimg
.zslice
, usage
);
811 pipe_resource_reference(&stimg
.texture
, NULL
);
817 * Re-validate the framebuffers.
820 st_manager_validate_framebuffers(struct st_context
*st
)
822 struct st_framebuffer
*stdraw
= st_ws_framebuffer(st
->ctx
->DrawBuffer
);
823 struct st_framebuffer
*stread
= st_ws_framebuffer(st
->ctx
->ReadBuffer
);
826 st_framebuffer_validate(stdraw
, st
);
827 if (stread
&& stread
!= stdraw
)
828 st_framebuffer_validate(stread
, st
);
832 * Add a color renderbuffer on demand.
835 st_manager_add_color_renderbuffer(struct st_context
*st
, struct gl_framebuffer
*fb
,
838 struct st_framebuffer
*stfb
= st_ws_framebuffer(fb
);
844 if (stfb
->Base
.Attachment
[idx
].Renderbuffer
)
848 case BUFFER_FRONT_LEFT
:
849 case BUFFER_BACK_LEFT
:
850 case BUFFER_FRONT_RIGHT
:
851 case BUFFER_BACK_RIGHT
:
858 if (!st_framebuffer_add_renderbuffer(stfb
, idx
))
861 st_framebuffer_update_attachments(stfb
);
862 st_invalidate_state(st
->ctx
, _NEW_BUFFERS
);
867 static const struct st_api st_gl_api
= {
870 ST_PROFILE_DEFAULT_MASK
|
873 ST_PROFILE_OPENGL_ES1_MASK
|
876 ST_PROFILE_OPENGL_ES2_MASK
|
880 st_api_get_proc_address
,
881 st_api_create_context
,
887 st_gl_api_create(void)
889 return (struct st_api
*) &st_gl_api
;