1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
3a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * Version:  6.5.1
45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
5a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
7afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a
8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"),
9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation
10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the
12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions:
135e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included
15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software.
165e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
26a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul/**
27a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * \file context.h
28a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * Mesa context and visual-related functions.
29a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul *
30a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * There are three large Mesa data types/classes which are meant to be
31a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * used by device drivers:
32f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg * - struct gl_context: this contains the Mesa rendering state
33032a7ef0a1cb753defc11e97b11ea2e602bae5f2Brian Paul * - struct gl_config:  this describes the color buffer (RGB vs. ci), whether
34032a7ef0a1cb753defc11e97b11ea2e602bae5f2Brian Paul *   or not there's a depth buffer, stencil buffer, etc.
35032a7ef0a1cb753defc11e97b11ea2e602bae5f2Brian Paul * - struct gl_framebuffer:  contains pointers to the depth buffer, stencil
36032a7ef0a1cb753defc11e97b11ea2e602bae5f2Brian Paul *   buffer, accum buffer and alpha buffers.
37a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul *
38a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * These types should be encapsulated by corresponding device driver
39a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * data types.  See xmesa.h and xmesaP.h for an example.
40a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul *
41032a7ef0a1cb753defc11e97b11ea2e602bae5f2Brian Paul * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer
42032a7ef0a1cb753defc11e97b11ea2e602bae5f2Brian Paul * are base classes which the device driver must derive from.
43a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul *
44a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * The following functions create and destroy these data types.
45a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul */
46a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul
47a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul
48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#ifndef CONTEXT_H
49afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CONTEXT_H
50afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
51afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
52ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell#include "imports.h"
535e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen#include "mtypes.h"
54afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5663e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca#ifdef __cplusplus
5763e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonsecaextern "C" {
5863e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca#endif
5963e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca
6063e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca
6127a8432e35669920fa8e985819ba3ef8b258127dBrian Paulstruct _glapi_table;
6227a8432e35669920fa8e985819ba3ef8b258127dBrian Paul
6327a8432e35669920fa8e985819ba3ef8b258127dBrian Paul
64a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul/** \name Visual-related functions */
656dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*@{*/
666dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
67d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsbergextern struct gl_config *
68fcf438e9e03f6e75bca4a49ad372fe7c4b1abbf8Ian Romanick_mesa_create_visual( GLboolean dbFlag,
69b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLboolean stereoFlag,
70b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint redBits,
71b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint greenBits,
72b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint blueBits,
73b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint alphaBits,
74b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint depthBits,
75b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint stencilBits,
76b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint accumRedBits,
77b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint accumGreenBits,
78b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint accumBlueBits,
79b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint accumAlphaBits,
80b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul                     GLint numSamples );
81b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul
82178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paulextern GLboolean
83d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsberg_mesa_initialize_visual( struct gl_config *v,
84178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLboolean dbFlag,
85178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLboolean stereoFlag,
86178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint redBits,
87178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint greenBits,
88178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint blueBits,
89178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint alphaBits,
90178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint depthBits,
91178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint stencilBits,
92178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint accumRedBits,
93178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint accumGreenBits,
94178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint accumBlueBits,
95178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint accumAlphaBits,
96178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul                         GLint numSamples );
97178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul
98b371e0da2b51da7d941de557b62434aaaca5be02Brian Paulextern void
99d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsberg_mesa_destroy_visual( struct gl_config *vis );
100b371e0da2b51da7d941de557b62434aaaca5be02Brian Paul
1016dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*@}*/
102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
103178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paul
104a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul/** \name Context-related functions */
1056dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*@{*/
1066dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
107178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paulextern GLboolean
108f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_initialize_context( struct gl_context *ctx,
1095e4ca1ccc9029fd75bb7676dc128e33d12da9665Brian Paul                          gl_api api,
110d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsberg                          const struct gl_config *visual,
111f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg                          struct gl_context *share_list,
112d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul                          const struct dd_function_table *driverFunctions,
113d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul                          void *driverContext );
114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
115f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergextern struct gl_context *
1166f2f449414e51e3b98f85e3fc916a7f3d42a99d4Brian Paul_mesa_create_context(gl_api api,
1176f2f449414e51e3b98f85e3fc916a7f3d42a99d4Brian Paul                     const struct gl_config *visual,
1186f2f449414e51e3b98f85e3fc916a7f3d42a99d4Brian Paul                     struct gl_context *share_list,
1196f2f449414e51e3b98f85e3fc916a7f3d42a99d4Brian Paul                     const struct dd_function_table *driverFunctions,
1206f2f449414e51e3b98f85e3fc916a7f3d42a99d4Brian Paul                     void *driverContext);
1212ab18d63cb71d988265eeab431e4363081978144Kristian Høgsberg
122178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paulextern void
123f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_free_context_data( struct gl_context *ctx );
1244d053ddae8cc48dd29a75e67290cd09ed995f5c3Brian Paul
125178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paulextern void
126f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_destroy_context( struct gl_context *ctx );
1274d053ddae8cc48dd29a75e67290cd09ed995f5c3Brian Paul
128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
129178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paulextern void
130f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask);
1310498682406d23226b5bc8973e02c7b3a9e0bdeaaBrian Paul
1320498682406d23226b5bc8973e02c7b3a9e0bdeaaBrian Paul
1333f856c6b6b7fa95ef97a8712876de88d7d57932eBrian Paulextern void
134f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height);
1353f856c6b6b7fa95ef97a8712876de88d7d57932eBrian Paul
13629c6c8eb18ace95b9af6dcf34e02c2b8db0ffda8José Fonsecaextern GLboolean
137f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer,
13831aca27c08d6a385c595d34fe4ee06390bf5b0e8Kristian Høgsberg                    struct gl_framebuffer *readBuffer );
1390003778847df6adb792f453df83808fefa560f18Brian Paul
140635ee2df37898fe408be565d189c2fb4dc5f61b1Brian Paulextern GLboolean
141f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare);
1423f02f90f943a996d88abc20f74503afbb56a4c98Brian Paul
143f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergextern struct gl_context *
144b1394fa92aaaf859ce9efc8b5fc194397921320cBrian Paul_mesa_get_current_context(void);
145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1466dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*@}*/
1470498682406d23226b5bc8973e02c7b3a9e0bdeaaBrian Paul
148199b0894b501607bf8d599ef5efc08cd6c08c79dKristian Høgsbergextern void
149f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_init_get_hash(struct gl_context *ctx);
1500498682406d23226b5bc8973e02c7b3a9e0bdeaaBrian Paul
1519a33a11d714c90162d32781ebbd2c1dfab52cfd1Brian Paulextern void
152f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_notifySwapBuffers(struct gl_context *gc);
1539a33a11d714c90162d32781ebbd2c1dfab52cfd1Brian Paul
1549a33a11d714c90162d32781ebbd2c1dfab52cfd1Brian Paul
155fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paulextern struct _glapi_table *
156f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_get_dispatch(struct gl_context *ctx);
157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
159b6e8256899a9a93c665c34e10efcc918f2fcc095Keith Whitwellvoid
160f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_set_mvp_with_dp4( struct gl_context *ctx,
161b6e8256899a9a93c665c34e10efcc918f2fcc095Keith Whitwell                        GLboolean flag );
162b6e8256899a9a93c665c34e10efcc918f2fcc095Keith Whitwell
163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
16456c4226fcc54158eb7fe54eeb13539a979ec155cBrian Paulextern GLboolean
165f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_valid_to_render(struct gl_context *ctx, const char *where);
16656c4226fcc54158eb7fe54eeb13539a979ec155cBrian Paul
16756c4226fcc54158eb7fe54eeb13539a979ec155cBrian Paul
16856c4226fcc54158eb7fe54eeb13539a979ec155cBrian Paul
1696dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/** \name Miscellaneous */
1706dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*@{*/
171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
172178a1c5a25b84bab1d5aae9e14694b531feea3caBrian Paulextern void
173f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_record_error( struct gl_context *ctx, GLenum error );
174d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul
1754837e01bcd3d011a38d75cc9f1eff629c3de6fd6Brian Paul
1764837e01bcd3d011a38d75cc9f1eff629c3de6fd6Brian Paulextern void
177f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_finish(struct gl_context *ctx);
1784837e01bcd3d011a38d75cc9f1eff629c3de6fd6Brian Paul
1794837e01bcd3d011a38d75cc9f1eff629c3de6fd6Brian Paulextern void
180f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_mesa_flush(struct gl_context *ctx);
1814837e01bcd3d011a38d75cc9f1eff629c3de6fd6Brian Paul
1824837e01bcd3d011a38d75cc9f1eff629c3de6fd6Brian Paul
183c40d1dd62dd9bcbb97128e37a75d991a8d3b2d8cKendall Bennettextern void GLAPIENTRY
184fa9df40e8a40824942ea8c6ec17c06c28bea1102Brian Paul_mesa_Finish( void );
185fa9df40e8a40824942ea8c6ec17c06c28bea1102Brian Paul
186c40d1dd62dd9bcbb97128e37a75d991a8d3b2d8cKendall Bennettextern void GLAPIENTRY
187fa9df40e8a40824942ea8c6ec17c06c28bea1102Brian Paul_mesa_Flush( void );
188fa9df40e8a40824942ea8c6ec17c06c28bea1102Brian Paul
1896dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*@}*/
190fa9df40e8a40824942ea8c6ec17c06c28bea1102Brian Paul
19106588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
192a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul/**
193a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * \name Macros for flushing buffered rendering commands before state changes,
194a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul * checking if inside glBegin/glEnd, etc.
195a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul */
19606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/*@{*/
19706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
19806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/**
19906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Flush vertices.
20012f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul *
20112f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul * \param ctx GL context.
20212f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul * \param newstate new state.
20306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul *
20406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
20506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * and calls dd_function_table::FlushVertices if so. Marks
206f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg * __struct gl_contextRec::NewState with \p newstate.
20706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul */
20812f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul#define FLUSH_VERTICES(ctx, newstate)				\
20912f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Pauldo {								\
21012f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul   if (MESA_VERBOSE & VERBOSE_STATE)				\
21112f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul      _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\
21212f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul   if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES)		\
21312f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul      ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES);	\
21412f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul   ctx->NewState |= newstate;					\
21512f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul} while (0)
21606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
21706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/**
21806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Flush current state.
21912f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul *
22012f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul * \param ctx GL context.
22112f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul * \param newstate new state.
22206588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul *
22306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Checks if dd_function_table::NeedFlush is marked to flush current state,
22406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * and calls dd_function_table::FlushVertices if so. Marks
225f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg * __struct gl_contextRec::NewState with \p newstate.
22606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul */
22712f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul#define FLUSH_CURRENT(ctx, newstate)				\
22812f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Pauldo {								\
22912f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul   if (MESA_VERBOSE & VERBOSE_STATE)				\
23012f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul      _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION);	\
23112f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul   if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)		\
23212f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul      ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT);	\
23312f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul   ctx->NewState |= newstate;					\
23412f25eb6d5521ad2dc61eab08331c1ea8d3c67f7Brian Paul} while (0)
23506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
23606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/**
23706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Macro to assert that the API call was made outside the
23806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * glBegin()/glEnd() pair, with return value.
23906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul *
24006588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * \param ctx GL context.
24105720e14ba1072c547fc2388738ed4f70a6630b6Brian Paul * \param retval value to return in case the assertion fails.
24206588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul */
24306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval)		\
24406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Pauldo {									\
24506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {	\
246a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul      _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd");	\
24706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul      return retval;							\
24806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   }									\
24906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul} while (0)
25006588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
25106588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/**
25206588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Macro to assert that the API call was made outside the
25306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * glBegin()/glEnd() pair.
25406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul *
25506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * \param ctx GL context.
25606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul */
25706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul#define ASSERT_OUTSIDE_BEGIN_END(ctx)					\
25806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Pauldo {									\
25906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {	\
260a623e008c651235769c7c50fc55f6e3782e4aacaBrian Paul      _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd");	\
26106588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul      return;								\
26206588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   }									\
26306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul} while (0)
26406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
26506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/**
26606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Macro to assert that the API call was made outside the
26706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * glBegin()/glEnd() pair and flush the vertices.
26806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul *
26906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * \param ctx GL context.
27006588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul */
27106588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx)				\
27206588db3fa2c8292db57b3537bb3ad8811d82f46Brian Pauldo {									\
27306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   ASSERT_OUTSIDE_BEGIN_END(ctx);					\
27406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   FLUSH_VERTICES(ctx, 0);						\
27506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul} while (0)
27606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
27706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/**
27806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * Macro to assert that the API call was made outside the
27906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * glBegin()/glEnd() pair and flush the vertices, with return value.
28006588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul *
28106588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul * \param ctx GL context.
28205720e14ba1072c547fc2388738ed4f70a6630b6Brian Paul * \param retval value to return in case the assertion fails.
28306588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul */
28406588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)	\
28506588db3fa2c8292db57b3537bb3ad8811d82f46Brian Pauldo {									\
28606588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval);			\
28706588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul   FLUSH_VERTICES(ctx, 0);						\
28806588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul} while (0)
28906588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
29006588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul/*@}*/
29106588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
29206588db3fa2c8292db57b3537bb3ad8811d82f46Brian Paul
2933d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen/**
2943d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen * Checks if the context is for Desktop GL (Compatibility or Core)
2953d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen */
2963d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justenstatic inline GLboolean
2973d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen_mesa_is_desktop_gl(const struct gl_context *ctx)
2983d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen{
2993d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen   return ctx->API == API_OPENGL || ctx->API == API_OPENGL_CORE;
3003d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen}
3013d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen
3023d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen
3033d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen/**
3043d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen * Checks if the context is for any GLES version
3053d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen */
3063d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justenstatic inline GLboolean
3073d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen_mesa_is_gles(const struct gl_context *ctx)
3083d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen{
3093d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen   return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
3103d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen}
3113d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen
3123d284dcba6f692ce268c9a2178a30e7a308b2cfcJordan Justen
3132a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick/**
3142a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick * Checks if the context is for GLES 3.x
3152a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick */
3162a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanickstatic inline GLboolean
3172a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick_mesa_is_gles3(const struct gl_context *ctx)
3182a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick{
3192a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick   return ctx->API == API_OPENGLES2 && ctx->Version >= 30;
3202a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick}
3212a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick
3222a1ca4ff73129825a7578b0a5ed1f0ac9476a4c3Ian Romanick
32363e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca#ifdef __cplusplus
32463e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca}
32563e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca#endif
32663e7a4c6e5bf51d8090046ebc5adcb4207448565José Fonseca
32729b4076f9acff96a867760fc885f5eaeb7586977Brian Paul
3284e2de9531e4869edf12536c2cb37d3145ee4065cBrian Paul#endif /* CONTEXT_H */
329