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 GLframebuffer to an st_framebuffer.
58 * Return NULL if the GLframebuffer 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(GLframebuffer
*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 __GLcontextModes from a visual.
302 st_visual_to_context_mode(const struct st_visual
*visual
,
303 __GLcontextModes
*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 __GLcontextModes mode
;
426 stfb
= CALLOC_STRUCT(st_framebuffer
);
430 /* for FBO-only context */
432 GLframebuffer
*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 GLframebuffer
*fb
= &stfb
->Base
;
475 _mesa_reference_framebuffer((GLframebuffer
**) 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
);
489 assert(stfb
&& stfb
->iface
== stfbi
);
491 p_atomic_set(&stfb
->revalidate
, TRUE
);
495 st_context_flush(struct st_context_iface
*stctxi
, unsigned flags
,
496 struct pipe_fence_handle
**fence
)
498 struct st_context
*st
= (struct st_context
*) stctxi
;
499 st_flush(st
, flags
, fence
);
500 if (flags
& PIPE_FLUSH_RENDER_CACHE
)
501 st_manager_flush_frontbuffer(st
);
505 st_context_teximage(struct st_context_iface
*stctxi
, enum st_texture_type target
,
506 int level
, enum pipe_format internal_format
,
507 struct pipe_resource
*tex
, boolean mipmap
)
509 struct st_context
*st
= (struct st_context
*) stctxi
;
510 GLcontext
*ctx
= st
->ctx
;
511 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
512 struct gl_texture_object
*texObj
;
513 struct gl_texture_image
*texImage
;
514 struct st_texture_object
*stObj
;
515 struct st_texture_image
*stImage
;
516 GLenum internalFormat
;
517 GLuint width
, height
, depth
;
521 target
= GL_TEXTURE_1D
;
524 target
= GL_TEXTURE_2D
;
527 target
= GL_TEXTURE_3D
;
529 case ST_TEXTURE_RECT
:
530 target
= GL_TEXTURE_RECTANGLE_ARB
;
537 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
538 _mesa_lock_texture(ctx
, texObj
);
540 stObj
= st_texture_object(texObj
);
541 /* switch to surface based */
542 if (!stObj
->surface_based
) {
543 _mesa_clear_texture_object(ctx
, texObj
);
544 stObj
->surface_based
= GL_TRUE
;
547 texImage
= _mesa_get_tex_image(ctx
, texObj
, target
, level
);
548 stImage
= st_texture_image(texImage
);
551 * XXX When internal_format and tex->format differ, st_finalize_texture
552 * needs to allocate a new texture with internal_format and copy the
553 * texture here into the new one. It will result in surface_copy being
554 * called on surfaces whose formats differ.
556 * To avoid that, internal_format is (wrongly) ignored here. A sane fix
557 * is to use a sampler view.
559 if (!st_sampler_compat_formats(tex
->format
, internal_format
))
560 internal_format
= tex
->format
;
562 if (util_format_get_component_bits(internal_format
,
563 UTIL_FORMAT_COLORSPACE_RGB
, 3) > 0)
564 internalFormat
= GL_RGBA
;
566 internalFormat
= GL_RGB
;
567 _mesa_init_teximage_fields(ctx
, target
, texImage
,
568 tex
->width0
, tex
->height0
, 1, 0, internalFormat
);
569 texImage
->TexFormat
= st_ChooseTextureFormat(ctx
, internalFormat
,
570 GL_RGBA
, GL_UNSIGNED_BYTE
);
571 _mesa_set_fetch_functions(texImage
, 2);
574 height
= tex
->height0
;
577 /* grow the image size until we hit level = 0 */
589 _mesa_clear_texture_image(ctx
, texImage
);
590 width
= height
= depth
= 0;
593 pipe_resource_reference(&stImage
->pt
, tex
);
594 stObj
->width0
= width
;
595 stObj
->height0
= height
;
596 stObj
->depth0
= depth
;
598 _mesa_dirty_texobj(ctx
, texObj
, GL_TRUE
);
599 _mesa_unlock_texture(ctx
, texObj
);
605 st_context_destroy(struct st_context_iface
*stctxi
)
607 struct st_context
*st
= (struct st_context
*) stctxi
;
608 st_destroy_context(st
);
611 static struct st_context_iface
*
612 st_api_create_context(struct st_api
*stapi
, struct st_manager
*smapi
,
613 const struct st_context_attribs
*attribs
,
614 struct st_context_iface
*shared_stctxi
)
616 struct st_context
*shared_ctx
= (struct st_context
*) shared_stctxi
;
617 struct st_context
*st
;
618 struct pipe_context
*pipe
;
619 __GLcontextModes mode
;
622 if (!(stapi
->profile_mask
& (1 << attribs
->profile
)))
625 switch (attribs
->profile
) {
626 case ST_PROFILE_DEFAULT
:
629 case ST_PROFILE_OPENGL_ES1
:
632 case ST_PROFILE_OPENGL_ES2
:
635 case ST_PROFILE_OPENGL_CORE
:
641 pipe
= smapi
->screen
->context_create(smapi
->screen
, NULL
);
645 st_visual_to_context_mode(&attribs
->visual
, &mode
);
646 st
= st_create_context(api
, pipe
, &mode
, shared_ctx
);
652 /* need to perform version check */
653 if (attribs
->major
> 1 || attribs
->minor
> 0) {
654 _mesa_compute_version(st
->ctx
);
656 if (st
->ctx
->VersionMajor
< attribs
->major
||
657 st
->ctx
->VersionMajor
< attribs
->minor
) {
658 st_destroy_context(st
);
663 st
->invalidate_on_gl_viewport
=
664 smapi
->get_param(smapi
, ST_MANAGER_BROKEN_INVALIDATE
);
666 st
->iface
.destroy
= st_context_destroy
;
667 st
->iface
.notify_invalid_framebuffer
=
668 st_context_notify_invalid_framebuffer
;
669 st
->iface
.flush
= st_context_flush
;
670 st
->iface
.teximage
= st_context_teximage
;
671 st
->iface
.copy
= NULL
;
672 st
->iface
.st_context_private
= (void *) smapi
;
678 st_api_make_current(struct st_api
*stapi
, struct st_context_iface
*stctxi
,
679 struct st_framebuffer_iface
*stdrawi
,
680 struct st_framebuffer_iface
*streadi
)
682 struct st_context
*st
= (struct st_context
*) stctxi
;
683 struct st_framebuffer
*stdraw
, *stread
, *stfb
;
686 _glapi_check_multithread();
689 /* reuse/create the draw fb */
690 stfb
= st_ws_framebuffer(st
->ctx
->WinSysDrawBuffer
);
691 if (stfb
&& stfb
->iface
== stdrawi
) {
693 st_framebuffer_reference(&stdraw
, stfb
);
696 stdraw
= st_framebuffer_create(stdrawi
);
699 /* reuse/create the read fb */
700 stfb
= st_ws_framebuffer(st
->ctx
->WinSysReadBuffer
);
701 if (!stfb
|| stfb
->iface
!= streadi
)
703 if (stfb
&& stfb
->iface
== streadi
) {
705 st_framebuffer_reference(&stread
, stfb
);
708 stread
= st_framebuffer_create(streadi
);
711 if (stdraw
&& stread
) {
712 st_framebuffer_validate(stdraw
, st
);
713 if (stread
!= stdraw
)
714 st_framebuffer_validate(stread
, st
);
716 /* modify the draw/read buffers of the context */
718 st_visual_to_default_buffer(stdraw
->iface
->visual
,
719 &st
->ctx
->Color
.DrawBuffer
[0], NULL
);
722 st_visual_to_default_buffer(stread
->iface
->visual
,
723 &st
->ctx
->Pixel
.ReadBuffer
, NULL
);
726 ret
= _mesa_make_current(st
->ctx
, &stdraw
->Base
, &stread
->Base
);
732 st_framebuffer_reference(&stdraw
, NULL
);
733 st_framebuffer_reference(&stread
, NULL
);
736 ret
= _mesa_make_current(NULL
, NULL
, NULL
);
742 static struct st_context_iface
*
743 st_api_get_current(struct st_api
*stapi
)
745 GET_CURRENT_CONTEXT(ctx
);
746 struct st_context
*st
= (ctx
) ? ctx
->st
: NULL
;
748 return (st
) ? &st
->iface
: NULL
;
752 st_api_get_proc_address(struct st_api
*stapi
, const char *procname
)
754 return (st_proc_t
) _glapi_get_proc_address(procname
);
758 st_api_destroy(struct st_api
*stapi
)
763 * Flush the front buffer if the current context renders to the front buffer.
766 st_manager_flush_frontbuffer(struct st_context
*st
)
768 struct st_framebuffer
*stfb
= st_ws_framebuffer(st
->ctx
->DrawBuffer
);
769 struct st_renderbuffer
*strb
= NULL
;
772 strb
= st_renderbuffer(stfb
->Base
.Attachment
[BUFFER_FRONT_LEFT
].Renderbuffer
);
776 /* never a dummy fb */
778 stfb
->iface
->flush_front(stfb
->iface
, ST_ATTACHMENT_FRONT_LEFT
);
782 * Return the surface of an EGLImage.
784 struct pipe_surface
*
785 st_manager_get_egl_image_surface(struct st_context
*st
,
786 void *eglimg
, unsigned usage
)
788 struct st_manager
*smapi
=
789 (struct st_manager
*) st
->iface
.st_context_private
;
790 struct st_egl_image stimg
;
791 struct pipe_surface
*ps
;
793 if (!smapi
|| !smapi
->get_egl_image
)
796 memset(&stimg
, 0, sizeof(stimg
));
797 if (!smapi
->get_egl_image(smapi
, eglimg
, &stimg
))
800 ps
= smapi
->screen
->get_tex_surface(smapi
->screen
,
801 stimg
.texture
, stimg
.face
, stimg
.level
, stimg
.zslice
, usage
);
802 pipe_resource_reference(&stimg
.texture
, NULL
);
808 * Re-validate the framebuffers.
811 st_manager_validate_framebuffers(struct st_context
*st
)
813 struct st_framebuffer
*stdraw
= st_ws_framebuffer(st
->ctx
->DrawBuffer
);
814 struct st_framebuffer
*stread
= st_ws_framebuffer(st
->ctx
->ReadBuffer
);
817 st_framebuffer_validate(stdraw
, st
);
818 if (stread
&& stread
!= stdraw
)
819 st_framebuffer_validate(stread
, st
);
823 * Add a color renderbuffer on demand.
826 st_manager_add_color_renderbuffer(struct st_context
*st
, GLframebuffer
*fb
,
829 struct st_framebuffer
*stfb
= st_ws_framebuffer(fb
);
835 if (stfb
->Base
.Attachment
[idx
].Renderbuffer
)
839 case BUFFER_FRONT_LEFT
:
840 case BUFFER_BACK_LEFT
:
841 case BUFFER_FRONT_RIGHT
:
842 case BUFFER_BACK_RIGHT
:
849 if (!st_framebuffer_add_renderbuffer(stfb
, idx
))
852 st_framebuffer_update_attachments(stfb
);
853 st_invalidate_state(st
->ctx
, _NEW_BUFFERS
);
858 static const struct st_api st_gl_api
= {
861 ST_PROFILE_DEFAULT_MASK
|
864 ST_PROFILE_OPENGL_ES1_MASK
|
867 ST_PROFILE_OPENGL_ES2_MASK
|
871 st_api_get_proc_address
,
872 st_api_create_context
,
878 st_gl_api_create(void)
880 return (struct st_api
*) &st_gl_api
;