1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci/**
27bf215546Sopenharmony_ci * \file context.h
28bf215546Sopenharmony_ci * Mesa context and visual-related functions.
29bf215546Sopenharmony_ci *
30bf215546Sopenharmony_ci * There are three large Mesa data types/classes which are meant to be
31bf215546Sopenharmony_ci * used by device drivers:
32bf215546Sopenharmony_ci * - struct gl_context: this contains the Mesa rendering state
33bf215546Sopenharmony_ci * - struct gl_config:  this describes the color buffer (RGB vs. ci), whether
34bf215546Sopenharmony_ci *   or not there's a depth buffer, stencil buffer, etc.
35bf215546Sopenharmony_ci * - struct gl_framebuffer:  contains pointers to the depth buffer, stencil
36bf215546Sopenharmony_ci *   buffer, accum buffer and alpha buffers.
37bf215546Sopenharmony_ci *
38bf215546Sopenharmony_ci * These types should be encapsulated by corresponding device driver
39bf215546Sopenharmony_ci * data types.  See xmesa.h and xmesaP.h for an example.
40bf215546Sopenharmony_ci *
41bf215546Sopenharmony_ci * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer
42bf215546Sopenharmony_ci * are base classes which the device driver must derive from.
43bf215546Sopenharmony_ci *
44bf215546Sopenharmony_ci * The following functions create and destroy these data types.
45bf215546Sopenharmony_ci */
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci#ifndef CONTEXT_H
49bf215546Sopenharmony_ci#define CONTEXT_H
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci#include "errors.h"
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_ci#include "extensions.h"
55bf215546Sopenharmony_ci#include "mtypes.h"
56bf215546Sopenharmony_ci#include "vbo/vbo.h"
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci#ifdef __cplusplus
60bf215546Sopenharmony_ciextern "C" {
61bf215546Sopenharmony_ci#endif
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_cistruct _glapi_table;
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ci/** \name Context-related functions */
68bf215546Sopenharmony_ci/*@{*/
69bf215546Sopenharmony_ci
70bf215546Sopenharmony_ciextern void
71bf215546Sopenharmony_ci_mesa_initialize(const char *extensions_override);
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ciextern GLboolean
74bf215546Sopenharmony_ci_mesa_initialize_context( struct gl_context *ctx,
75bf215546Sopenharmony_ci                          gl_api api,
76bf215546Sopenharmony_ci                          bool no_error,
77bf215546Sopenharmony_ci                          const struct gl_config *visual,
78bf215546Sopenharmony_ci                          struct gl_context *share_list,
79bf215546Sopenharmony_ci                          const struct dd_function_table *driverFunctions);
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ciextern struct _glapi_table *
82bf215546Sopenharmony_ci_mesa_alloc_dispatch_table(bool glthread);
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ciextern void
85bf215546Sopenharmony_ci_mesa_initialize_exec_table(struct gl_context *ctx);
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ciextern void
88bf215546Sopenharmony_ci_mesa_initialize_dispatch_tables(struct gl_context *ctx);
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ciextern struct _glapi_table *
91bf215546Sopenharmony_ci_mesa_new_nop_table(unsigned numEntries, bool glthread);
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_ciextern void
94bf215546Sopenharmony_ci_mesa_free_context_data(struct gl_context *ctx, bool destroy_debug_output);
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ciextern void
97bf215546Sopenharmony_ci_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask);
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ciextern GLboolean
100bf215546Sopenharmony_ci_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer,
101bf215546Sopenharmony_ci                    struct gl_framebuffer *readBuffer );
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ciextern GLboolean
104bf215546Sopenharmony_ci_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare);
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ciextern struct gl_context *
107bf215546Sopenharmony_ci_mesa_get_current_context(void);
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ci/*@}*/
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ciextern void
112bf215546Sopenharmony_ci_mesa_init_constants(struct gl_constants *consts, gl_api api);
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ciextern struct _glapi_table *
115bf215546Sopenharmony_ci_mesa_get_dispatch(struct gl_context *ctx);
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ciextern void
118bf215546Sopenharmony_ci_mesa_set_context_lost_dispatch(struct gl_context *ctx);
119bf215546Sopenharmony_ci
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci/** \name Miscellaneous */
123bf215546Sopenharmony_ci/*@{*/
124bf215546Sopenharmony_ci
125bf215546Sopenharmony_ciextern void
126bf215546Sopenharmony_ci_mesa_flush(struct gl_context *ctx);
127bf215546Sopenharmony_ci
128bf215546Sopenharmony_ci/*@}*/
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci/**
132bf215546Sopenharmony_ci * Are we currently between glBegin and glEnd?
133bf215546Sopenharmony_ci * During execution, not display list compilation.
134bf215546Sopenharmony_ci */
135bf215546Sopenharmony_cistatic inline GLboolean
136bf215546Sopenharmony_ci_mesa_inside_begin_end(const struct gl_context *ctx)
137bf215546Sopenharmony_ci{
138bf215546Sopenharmony_ci   return ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END;
139bf215546Sopenharmony_ci}
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci/**
143bf215546Sopenharmony_ci * Are we currently between glBegin and glEnd in a display list?
144bf215546Sopenharmony_ci */
145bf215546Sopenharmony_cistatic inline GLboolean
146bf215546Sopenharmony_ci_mesa_inside_dlist_begin_end(const struct gl_context *ctx)
147bf215546Sopenharmony_ci{
148bf215546Sopenharmony_ci   return ctx->Driver.CurrentSavePrimitive <= PRIM_MAX;
149bf215546Sopenharmony_ci}
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci
153bf215546Sopenharmony_ci/**
154bf215546Sopenharmony_ci * \name Macros for flushing buffered rendering commands before state changes,
155bf215546Sopenharmony_ci * checking if inside glBegin/glEnd, etc.
156bf215546Sopenharmony_ci */
157bf215546Sopenharmony_ci/*@{*/
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci/**
160bf215546Sopenharmony_ci * Flush vertices.
161bf215546Sopenharmony_ci *
162bf215546Sopenharmony_ci * \param ctx GL context.
163bf215546Sopenharmony_ci * \param newstate new state.
164bf215546Sopenharmony_ci *
165bf215546Sopenharmony_ci * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
166bf215546Sopenharmony_ci * and calls dd_function_table::FlushVertices if so. Marks
167bf215546Sopenharmony_ci * __struct gl_contextRec::NewState with \p newstate.
168bf215546Sopenharmony_ci */
169bf215546Sopenharmony_ci#define FLUSH_VERTICES(ctx, newstate, pop_attrib_mask)          \
170bf215546Sopenharmony_cido {								\
171bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_STATE)				\
172bf215546Sopenharmony_ci      _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __func__);	\
173bf215546Sopenharmony_ci   if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES)		\
174bf215546Sopenharmony_ci      vbo_exec_FlushVertices(ctx, FLUSH_STORED_VERTICES);	\
175bf215546Sopenharmony_ci   ctx->NewState |= newstate;					\
176bf215546Sopenharmony_ci   ctx->PopAttribState |= pop_attrib_mask;                      \
177bf215546Sopenharmony_ci} while (0)
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_ci/**
180bf215546Sopenharmony_ci * Flush current state.
181bf215546Sopenharmony_ci *
182bf215546Sopenharmony_ci * \param ctx GL context.
183bf215546Sopenharmony_ci * \param newstate new state.
184bf215546Sopenharmony_ci *
185bf215546Sopenharmony_ci * Checks if dd_function_table::NeedFlush is marked to flush current state,
186bf215546Sopenharmony_ci * and calls dd_function_table::FlushVertices if so. Marks
187bf215546Sopenharmony_ci * __struct gl_contextRec::NewState with \p newstate.
188bf215546Sopenharmony_ci */
189bf215546Sopenharmony_ci#define FLUSH_CURRENT(ctx, newstate)				\
190bf215546Sopenharmony_cido {								\
191bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_STATE)				\
192bf215546Sopenharmony_ci      _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __func__);	\
193bf215546Sopenharmony_ci   if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)		\
194bf215546Sopenharmony_ci      vbo_exec_FlushVertices(ctx, FLUSH_UPDATE_CURRENT);	\
195bf215546Sopenharmony_ci   ctx->NewState |= newstate;					\
196bf215546Sopenharmony_ci} while (0)
197bf215546Sopenharmony_ci
198bf215546Sopenharmony_ci/**
199bf215546Sopenharmony_ci * Flush vertices.
200bf215546Sopenharmony_ci *
201bf215546Sopenharmony_ci * \param ctx GL context.
202bf215546Sopenharmony_ci *
203bf215546Sopenharmony_ci * Checks if dd_function_table::NeedFlush is marked to flush stored vertices
204bf215546Sopenharmony_ci * or current state and calls dd_function_table::FlushVertices if so.
205bf215546Sopenharmony_ci */
206bf215546Sopenharmony_ci#define FLUSH_FOR_DRAW(ctx)                                     \
207bf215546Sopenharmony_cido {                                                            \
208bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_STATE)                            \
209bf215546Sopenharmony_ci      _mesa_debug(ctx, "FLUSH_FOR_DRAW in %s\n", __func__);     \
210bf215546Sopenharmony_ci   if (ctx->Driver.NeedFlush) {                                 \
211bf215546Sopenharmony_ci      if (ctx->_AllowDrawOutOfOrder) {                          \
212bf215546Sopenharmony_ci          if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)     \
213bf215546Sopenharmony_ci             vbo_exec_FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
214bf215546Sopenharmony_ci      } else {                                                  \
215bf215546Sopenharmony_ci         vbo_exec_FlushVertices(ctx, ctx->Driver.NeedFlush);    \
216bf215546Sopenharmony_ci      }                                                         \
217bf215546Sopenharmony_ci   }                                                            \
218bf215546Sopenharmony_ci} while (0)
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci/**
221bf215546Sopenharmony_ci * Macro to assert that the API call was made outside the
222bf215546Sopenharmony_ci * glBegin()/glEnd() pair, with return value.
223bf215546Sopenharmony_ci *
224bf215546Sopenharmony_ci * \param ctx GL context.
225bf215546Sopenharmony_ci * \param retval value to return in case the assertion fails.
226bf215546Sopenharmony_ci */
227bf215546Sopenharmony_ci#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval)		\
228bf215546Sopenharmony_cido {									\
229bf215546Sopenharmony_ci   if (_mesa_inside_begin_end(ctx)) {					\
230bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd");	\
231bf215546Sopenharmony_ci      return retval;							\
232bf215546Sopenharmony_ci   }									\
233bf215546Sopenharmony_ci} while (0)
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci/**
236bf215546Sopenharmony_ci * Macro to assert that the API call was made outside the
237bf215546Sopenharmony_ci * glBegin()/glEnd() pair.
238bf215546Sopenharmony_ci *
239bf215546Sopenharmony_ci * \param ctx GL context.
240bf215546Sopenharmony_ci */
241bf215546Sopenharmony_ci#define ASSERT_OUTSIDE_BEGIN_END(ctx)					\
242bf215546Sopenharmony_cido {									\
243bf215546Sopenharmony_ci   if (_mesa_inside_begin_end(ctx)) {					\
244bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd");	\
245bf215546Sopenharmony_ci      return;								\
246bf215546Sopenharmony_ci   }									\
247bf215546Sopenharmony_ci} while (0)
248bf215546Sopenharmony_ci
249bf215546Sopenharmony_ci/*@}*/
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci/**
253bf215546Sopenharmony_ci * Checks if the context is for Desktop GL (Compatibility or Core)
254bf215546Sopenharmony_ci */
255bf215546Sopenharmony_cistatic inline bool
256bf215546Sopenharmony_ci_mesa_is_desktop_gl(const struct gl_context *ctx)
257bf215546Sopenharmony_ci{
258bf215546Sopenharmony_ci   return ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGL_CORE;
259bf215546Sopenharmony_ci}
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci
262bf215546Sopenharmony_ci/**
263bf215546Sopenharmony_ci * Checks if the context is for any GLES version
264bf215546Sopenharmony_ci */
265bf215546Sopenharmony_cistatic inline bool
266bf215546Sopenharmony_ci_mesa_is_gles(const struct gl_context *ctx)
267bf215546Sopenharmony_ci{
268bf215546Sopenharmony_ci   return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
269bf215546Sopenharmony_ci}
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci/**
273bf215546Sopenharmony_ci * Checks if the context is for GLES 3.0 or later
274bf215546Sopenharmony_ci */
275bf215546Sopenharmony_cistatic inline bool
276bf215546Sopenharmony_ci_mesa_is_gles3(const struct gl_context *ctx)
277bf215546Sopenharmony_ci{
278bf215546Sopenharmony_ci   return ctx->API == API_OPENGLES2 && ctx->Version >= 30;
279bf215546Sopenharmony_ci}
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_ci
282bf215546Sopenharmony_ci/**
283bf215546Sopenharmony_ci * Checks if the context is for GLES 3.1 or later
284bf215546Sopenharmony_ci */
285bf215546Sopenharmony_cistatic inline bool
286bf215546Sopenharmony_ci_mesa_is_gles31(const struct gl_context *ctx)
287bf215546Sopenharmony_ci{
288bf215546Sopenharmony_ci   return ctx->API == API_OPENGLES2 && ctx->Version >= 31;
289bf215546Sopenharmony_ci}
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci/**
293bf215546Sopenharmony_ci * Checks if the context is for GLES 3.2 or later
294bf215546Sopenharmony_ci */
295bf215546Sopenharmony_cistatic inline bool
296bf215546Sopenharmony_ci_mesa_is_gles32(const struct gl_context *ctx)
297bf215546Sopenharmony_ci{
298bf215546Sopenharmony_ci   return ctx->API == API_OPENGLES2 && ctx->Version >= 32;
299bf215546Sopenharmony_ci}
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_cistatic inline bool
303bf215546Sopenharmony_ci_mesa_is_no_error_enabled(const struct gl_context *ctx)
304bf215546Sopenharmony_ci{
305bf215546Sopenharmony_ci   return ctx->Const.ContextFlags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
306bf215546Sopenharmony_ci}
307bf215546Sopenharmony_ci
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_cistatic inline bool
310bf215546Sopenharmony_ci_mesa_has_integer_textures(const struct gl_context *ctx)
311bf215546Sopenharmony_ci{
312bf215546Sopenharmony_ci   return _mesa_has_EXT_texture_integer(ctx) || _mesa_is_gles3(ctx);
313bf215546Sopenharmony_ci}
314bf215546Sopenharmony_ci
315bf215546Sopenharmony_cistatic inline bool
316bf215546Sopenharmony_ci_mesa_has_half_float_textures(const struct gl_context *ctx)
317bf215546Sopenharmony_ci{
318bf215546Sopenharmony_ci   return _mesa_has_ARB_texture_float(ctx) ||
319bf215546Sopenharmony_ci          _mesa_has_OES_texture_half_float(ctx);
320bf215546Sopenharmony_ci}
321bf215546Sopenharmony_ci
322bf215546Sopenharmony_cistatic inline bool
323bf215546Sopenharmony_ci_mesa_has_float_textures(const struct gl_context *ctx)
324bf215546Sopenharmony_ci{
325bf215546Sopenharmony_ci   return _mesa_has_ARB_texture_float(ctx) ||
326bf215546Sopenharmony_ci          _mesa_has_OES_texture_float(ctx) || _mesa_is_gles3(ctx);
327bf215546Sopenharmony_ci }
328bf215546Sopenharmony_ci
329bf215546Sopenharmony_cistatic inline bool
330bf215546Sopenharmony_ci_mesa_has_texture_rgb10_a2ui(const struct gl_context *ctx)
331bf215546Sopenharmony_ci{
332bf215546Sopenharmony_ci   return _mesa_has_ARB_texture_rgb10_a2ui(ctx) || _mesa_is_gles3(ctx);
333bf215546Sopenharmony_ci}
334bf215546Sopenharmony_ci
335bf215546Sopenharmony_cistatic inline bool
336bf215546Sopenharmony_ci_mesa_has_float_depth_buffer(const struct gl_context *ctx)
337bf215546Sopenharmony_ci{
338bf215546Sopenharmony_ci   return _mesa_has_ARB_depth_buffer_float(ctx) || _mesa_is_gles3(ctx);
339bf215546Sopenharmony_ci}
340bf215546Sopenharmony_ci
341bf215546Sopenharmony_cistatic inline bool
342bf215546Sopenharmony_ci_mesa_has_packed_float(const struct gl_context *ctx)
343bf215546Sopenharmony_ci{
344bf215546Sopenharmony_ci   return _mesa_has_EXT_packed_float(ctx) || _mesa_is_gles3(ctx);
345bf215546Sopenharmony_ci}
346bf215546Sopenharmony_ci
347bf215546Sopenharmony_cistatic inline bool
348bf215546Sopenharmony_ci_mesa_has_rg_textures(const struct gl_context *ctx)
349bf215546Sopenharmony_ci{
350bf215546Sopenharmony_ci   return _mesa_has_ARB_texture_rg(ctx) || _mesa_has_EXT_texture_rg(ctx) ||
351bf215546Sopenharmony_ci          _mesa_is_gles3(ctx);
352bf215546Sopenharmony_ci}
353bf215546Sopenharmony_ci
354bf215546Sopenharmony_cistatic inline bool
355bf215546Sopenharmony_ci_mesa_has_texture_shared_exponent(const struct gl_context *ctx)
356bf215546Sopenharmony_ci{
357bf215546Sopenharmony_ci   return _mesa_has_EXT_texture_shared_exponent(ctx) || _mesa_is_gles3(ctx);
358bf215546Sopenharmony_ci}
359bf215546Sopenharmony_ci
360bf215546Sopenharmony_cistatic inline bool
361bf215546Sopenharmony_ci_mesa_has_texture_type_2_10_10_10_REV(const struct gl_context *ctx)
362bf215546Sopenharmony_ci{
363bf215546Sopenharmony_ci   return _mesa_is_desktop_gl(ctx) ||
364bf215546Sopenharmony_ci          _mesa_has_EXT_texture_type_2_10_10_10_REV(ctx);
365bf215546Sopenharmony_ci}
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_ci/**
368bf215546Sopenharmony_ci * Checks if the context supports geometry shaders.
369bf215546Sopenharmony_ci */
370bf215546Sopenharmony_cistatic inline bool
371bf215546Sopenharmony_ci_mesa_has_geometry_shaders(const struct gl_context *ctx)
372bf215546Sopenharmony_ci{
373bf215546Sopenharmony_ci   return _mesa_has_OES_geometry_shader(ctx) ||
374bf215546Sopenharmony_ci          (_mesa_is_desktop_gl(ctx) && ctx->Version >= 32);
375bf215546Sopenharmony_ci}
376bf215546Sopenharmony_ci
377bf215546Sopenharmony_ci
378bf215546Sopenharmony_ci/**
379bf215546Sopenharmony_ci * Checks if the context supports compute shaders.
380bf215546Sopenharmony_ci */
381bf215546Sopenharmony_cistatic inline bool
382bf215546Sopenharmony_ci_mesa_has_compute_shaders(const struct gl_context *ctx)
383bf215546Sopenharmony_ci{
384bf215546Sopenharmony_ci   return _mesa_has_ARB_compute_shader(ctx) ||
385bf215546Sopenharmony_ci      (ctx->API == API_OPENGLES2 && ctx->Version >= 31);
386bf215546Sopenharmony_ci}
387bf215546Sopenharmony_ci
388bf215546Sopenharmony_ci/**
389bf215546Sopenharmony_ci * Checks if the context supports tessellation.
390bf215546Sopenharmony_ci */
391bf215546Sopenharmony_cistatic inline bool
392bf215546Sopenharmony_ci_mesa_has_tessellation(const struct gl_context *ctx)
393bf215546Sopenharmony_ci{
394bf215546Sopenharmony_ci   /* _mesa_has_EXT_tessellation_shader(ctx) is redundant with the OES
395bf215546Sopenharmony_ci    * check, so don't bother calling it.
396bf215546Sopenharmony_ci    */
397bf215546Sopenharmony_ci   return _mesa_has_OES_tessellation_shader(ctx) ||
398bf215546Sopenharmony_ci          _mesa_has_ARB_tessellation_shader(ctx);
399bf215546Sopenharmony_ci}
400bf215546Sopenharmony_ci
401bf215546Sopenharmony_cistatic inline bool
402bf215546Sopenharmony_ci_mesa_has_texture_cube_map_array(const struct gl_context *ctx)
403bf215546Sopenharmony_ci{
404bf215546Sopenharmony_ci   return _mesa_has_ARB_texture_cube_map_array(ctx) ||
405bf215546Sopenharmony_ci          _mesa_has_OES_texture_cube_map_array(ctx);
406bf215546Sopenharmony_ci}
407bf215546Sopenharmony_ci
408bf215546Sopenharmony_cistatic inline bool
409bf215546Sopenharmony_ci_mesa_has_texture_view(const struct gl_context *ctx)
410bf215546Sopenharmony_ci{
411bf215546Sopenharmony_ci   return _mesa_has_ARB_texture_view(ctx) ||
412bf215546Sopenharmony_ci          _mesa_has_OES_texture_view(ctx);
413bf215546Sopenharmony_ci}
414bf215546Sopenharmony_ci
415bf215546Sopenharmony_cistatic inline bool
416bf215546Sopenharmony_ci_mesa_hw_select_enabled(const struct gl_context *ctx)
417bf215546Sopenharmony_ci{
418bf215546Sopenharmony_ci   return ctx->RenderMode == GL_SELECT &&
419bf215546Sopenharmony_ci      ctx->Const.HardwareAcceleratedSelect;
420bf215546Sopenharmony_ci}
421bf215546Sopenharmony_ci
422bf215546Sopenharmony_ci#ifdef __cplusplus
423bf215546Sopenharmony_ci}
424bf215546Sopenharmony_ci#endif
425bf215546Sopenharmony_ci
426bf215546Sopenharmony_ci
427bf215546Sopenharmony_ci#endif /* CONTEXT_H */
428