mesa ctx->API --> _mesa_is_foo(ctx)

replaces direct API checks with _mesa_is_...() checks

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8340

Signed-off-by: Volodymyr Obohzyn volodymyr.obozhyn@globallogic.com

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>

Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21556>
This commit is contained in:
volodymyr.o
2023-02-27 15:19:30 +02:00
committed by Marge Bot
parent 5e039dbf8e
commit 47e7b49c61
30 changed files with 75 additions and 71 deletions

View File

@@ -95,7 +95,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->ARB_texture_rectangle_enable = true;
/* OpenGL ES 2.0 has different defaults from desktop GL. */
if (ctx->API == API_OPENGLES2) {
if (_mesa_is_gles2(ctx)) {
this->language_version = 100;
this->es_shader = true;
this->ARB_texture_rectangle_enable = false;
@@ -238,7 +238,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
}
}
}
if (ctx->API == API_OPENGLES2 || ctx->Extensions.ARB_ES2_compatibility) {
if (_mesa_is_gles2(ctx) || ctx->Extensions.ARB_ES2_compatibility) {
this->supported_versions[this->num_supported_versions].ver = 100;
this->supported_versions[this->num_supported_versions].gl_ver = 20;
this->supported_versions[this->num_supported_versions].es = true;
@@ -256,7 +256,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->supported_versions[this->num_supported_versions].es = true;
this->num_supported_versions++;
}
if ((ctx->API == API_OPENGLES2 && ctx->Version >= 32) ||
if (_mesa_is_gles32(ctx) ||
ctx->Extensions.ARB_ES3_2_compatibility) {
this->supported_versions[this->num_supported_versions].ver = 320;
this->supported_versions[this->num_supported_versions].gl_ver = 32;

View File

@@ -91,6 +91,7 @@
#include "main/shaderobj.h"
#include "main/enums.h"
#include "main/mtypes.h"
#include "main/context.h"
namespace {
@@ -3928,7 +3929,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
* always require a Vertex shader and hence a Fragment shader.
* - Finally a Compute shader linked with any other stage is a link error.
*/
if (!prog->SeparateShader && ctx->API == API_OPENGLES2 &&
if (!prog->SeparateShader && _mesa_is_gles2(ctx) &&
num_shaders[MESA_SHADER_COMPUTE] == 0) {
if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
linker_error(prog, "program lacks a vertex shader\n");

View File

@@ -54,12 +54,12 @@ class PrintCode(gl_XML.gl_print_base):
if not condition:
continue
if (condition == '_mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2' and
if (condition == '_mesa_is_desktop_gl(ctx) || _mesa_is_gles2(ctx)' and
re.match('VertexAttrib[1-4].*ARB', f.name)):
# These functions should map to an *ES callback for GLES2.
settings_by_condition['_mesa_is_desktop_gl(ctx)'].append(
'SET_{0}(tab, NAME({0}));'.format(f.name))
settings_by_condition['ctx->API == API_OPENGLES2'].append(
settings_by_condition['_mesa_is_gles2(ctx)'].append(
'SET_{0}(tab, NAME_ES({0}));'.format(f.name))
else:
macro = ('NAME_CALLLIST' if f.name[0:8] == 'CallList' else

View File

@@ -306,22 +306,22 @@ def get_api_condition(f):
unconditional_count = 0
if ex.compatibility is not None:
condition_parts.append('ctx->API == API_OPENGL_COMPAT')
condition_parts.append('_mesa_is_desktop_gl_compat(ctx)')
unconditional_count += 1
if ex.core is not None:
condition_parts.append('ctx->API == API_OPENGL_CORE')
condition_parts.append('_mesa_is_desktop_gl_core(ctx)')
unconditional_count += 1
if ex.es1 is not None:
condition_parts.append('ctx->API == API_OPENGLES')
condition_parts.append('_mesa_is_gles1(ctx)')
unconditional_count += 1
if ex.es2 is not None:
if ex.es2 > 20:
condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(ex.es2))
condition_parts.append('(_mesa_is_gles2(ctx) && ctx->Version >= {0})'.format(ex.es2))
else:
condition_parts.append('ctx->API == API_OPENGLES2')
condition_parts.append('_mesa_is_gles2(ctx)')
unconditional_count += 1
# If the function is unconditionally available in all four
@@ -333,16 +333,16 @@ def get_api_condition(f):
else:
if f.desktop:
if f.deprecated:
condition_parts.append('ctx->API == API_OPENGL_COMPAT')
condition_parts.append('_mesa_is_desktop_gl_compat(ctx)')
else:
condition_parts.append('_mesa_is_desktop_gl(ctx)')
if 'es1' in f.api_map:
condition_parts.append('ctx->API == API_OPENGLES')
condition_parts.append('_mesa_is_gles1(ctx)')
if 'es2' in f.api_map:
if f.api_map['es2'] > 2.0:
condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10)))
condition_parts.append('(_mesa_is_gles2(ctx) && ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10)))
else:
condition_parts.append('ctx->API == API_OPENGLES2')
condition_parts.append('_mesa_is_gles2(ctx)')
if not condition_parts:
# This function does not exist in any API.

View File

@@ -206,7 +206,7 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
* the name of the vertex array object."
*/
if (id == 0) {
if (ctx->API == API_OPENGL_COMPAT)
if (_mesa_is_desktop_gl_compat(ctx))
return ctx->Array.DefaultVAO;
return NULL;
@@ -250,7 +250,7 @@ _mesa_lookup_vao_err(struct gl_context *ctx, GLuint id,
* the name of the vertex array object."
*/
if (id == 0) {
if (is_ext_dsa || ctx->API == API_OPENGL_CORE) {
if (is_ext_dsa || _mesa_is_desktop_gl_core(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(zero is not valid vaobj name%s)",
caller,
@@ -936,7 +936,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, bool no_error)
/* Update the valid-to-render state if binding on unbinding default VAO
* if drawing with the default VAO is invalid.
*/
if (ctx->API == API_OPENGL_CORE &&
if (_mesa_is_desktop_gl_core(ctx) &&
(oldObj == ctx->Array.DefaultVAO) != (newObj == ctx->Array.DefaultVAO))
_mesa_update_valid_to_render_state(ctx);
}

View File

@@ -944,8 +944,8 @@ _mesa_PopAttrib(void)
TEST_AND_UPDATE(ctx->Point.PointSprite, attr->Point.PointSprite,
GL_POINT_SPRITE);
if ((ctx->API == API_OPENGL_COMPAT && ctx->Version >= 20)
|| ctx->API == API_OPENGL_CORE)
if ((_mesa_is_desktop_gl_compat(ctx) && ctx->Version >= 20)
|| _mesa_is_desktop_gl_core(ctx))
TEST_AND_CALL1_SEL(Point.SpriteOrigin, PointParameterf, GL_POINT_SPRITE_COORD_ORIGIN);
}

View File

@@ -163,7 +163,7 @@ clear(struct gl_context *ctx, GLbitfield mask, bool no_error)
* existed in OpenGL ES.
*/
if ((mask & GL_ACCUM_BUFFER_BIT) != 0
&& (ctx->API == API_OPENGL_CORE || _mesa_is_gles(ctx))) {
&& (_mesa_is_desktop_gl_core(ctx) || _mesa_is_gles(ctx))) {
_mesa_error( ctx, GL_INVALID_VALUE, "glClear(GL_ACCUM_BUFFER_BIT)");
return;
}

View File

@@ -14094,7 +14094,7 @@ void
_mesa_init_dispatch_save_begin_end(struct gl_context *ctx)
{
struct _glapi_table *tab = ctx->Dispatch.Save;
assert(ctx->API == API_OPENGL_COMPAT);
assert(_mesa_is_desktop_gl_compat(ctx));
#define NAME_AE(x) _mesa_##x
#define NAME_CALLLIST(x) save_##x

View File

@@ -2316,7 +2316,7 @@ _mesa_DrawArraysIndirect(GLenum mode, const GLvoid *indirect)
* DrawElementsIndirect are to source their arguments directly from the
* pointer passed as their <indirect> parameters."
*/
if (ctx->API == API_OPENGL_COMPAT &&
if (_mesa_is_desktop_gl_compat(ctx) &&
!ctx->DrawIndirectBuffer) {
DrawArraysIndirectCommand *cmd = (DrawArraysIndirectCommand *) indirect;
@@ -2351,7 +2351,7 @@ _mesa_DrawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect)
* DrawElementsIndirect are to source their arguments directly from the
* pointer passed as their <indirect> parameters."
*/
if (ctx->API == API_OPENGL_COMPAT &&
if (_mesa_is_desktop_gl_compat(ctx) &&
!ctx->DrawIndirectBuffer) {
/*
* Unlike regular DrawElementsInstancedBaseVertex commands, the indices
@@ -2416,7 +2416,7 @@ _mesa_MultiDrawArraysIndirect(GLenum mode, const GLvoid *indirect,
* DrawElementsIndirect are to source their arguments directly from the
* pointer passed as their <indirect> parameters."
*/
if (ctx->API == API_OPENGL_COMPAT &&
if (_mesa_is_desktop_gl_compat(ctx) &&
!ctx->DrawIndirectBuffer) {
if (!_mesa_is_no_error_enabled(ctx) &&
@@ -2489,7 +2489,7 @@ _mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type,
* DrawElementsIndirect are to source their arguments directly from the
* pointer passed as their <indirect> parameters."
*/
if (ctx->API == API_OPENGL_COMPAT &&
if (_mesa_is_desktop_gl_compat(ctx) &&
!ctx->DrawIndirectBuffer) {
/*
* Unlike regular DrawElementsInstancedBaseVertex commands, the indices

View File

@@ -146,7 +146,7 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx)
return;
}
if (ctx->API == API_OPENGL_COMPAT) {
if (_mesa_is_desktop_gl_compat(ctx)) {
if (!shader->CurrentProgram[MESA_SHADER_FRAGMENT]) {
if (ctx->FragmentProgram.Enabled &&
!_mesa_arb_fragment_program_enabled(ctx))

View File

@@ -162,7 +162,7 @@ _mesa_GetString( GLenum name )
ctx->Extensions.String = _mesa_make_extension_string(ctx);
return (const GLubyte *) ctx->Extensions.String;
case GL_SHADING_LANGUAGE_VERSION:
if (ctx->API == API_OPENGLES)
if (_mesa_is_gles1(ctx))
break;
return shading_language_version(ctx);
case GL_PROGRAM_ERROR_STRING_ARB:

View File

@@ -436,7 +436,7 @@ draw_arrays(GLuint drawid, GLenum mode, GLint first, GLsizei count,
}
unsigned user_buffer_mask =
ctx->API == API_OPENGL_CORE ? 0 : get_user_buffer_mask(ctx);
_mesa_is_desktop_gl_core(ctx) ? 0 : get_user_buffer_mask(ctx);
/* Fast path when nothing needs to be done.
*
@@ -556,7 +556,7 @@ _mesa_marshal_MultiDrawArrays(GLenum mode, const GLint *first,
struct glthread_attrib_binding buffers[VERT_ATTRIB_MAX];
unsigned user_buffer_mask =
ctx->API == API_OPENGL_CORE || draw_count <= 0 ||
_mesa_is_desktop_gl_core(ctx) || draw_count <= 0 ||
ctx->Dispatch.Current == ctx->Dispatch.ContextLost ||
ctx->GLThread.inside_begin_end ? 0 : get_user_buffer_mask(ctx);
@@ -852,7 +852,7 @@ draw_elements(GLuint drawid, GLenum mode, GLsizei count, GLenum type,
struct glthread_vao *vao = ctx->GLThread.CurrentVAO;
unsigned user_buffer_mask =
ctx->API == API_OPENGL_CORE ? 0 : get_user_buffer_mask(ctx);
_mesa_is_desktop_gl_core(ctx) ? 0 : get_user_buffer_mask(ctx);
bool has_user_indices = vao->CurrentElementBufferName == 0 && indices;
/* Fast path when nothing needs to be done.
@@ -1136,7 +1136,7 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
if (draw_count > 0 && is_index_type_valid(type) &&
ctx->Dispatch.Current != ctx->Dispatch.ContextLost &&
!ctx->GLThread.inside_begin_end) {
user_buffer_mask = ctx->API == API_OPENGL_CORE ? 0 : get_user_buffer_mask(ctx);
user_buffer_mask = _mesa_is_desktop_gl_core(ctx) ? 0 : get_user_buffer_mask(ctx);
has_user_indices = vao->CurrentElementBufferName == 0;
}

View File

@@ -113,7 +113,7 @@ _mesa_Hint( GLenum target, GLenum mode )
/* GL_ARB_fragment_shader */
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_fragment_shader)
if (_mesa_is_gles1(ctx) || !ctx->Extensions.ARB_fragment_shader)
goto invalid_target;
if (ctx->Hint.FragmentShaderDerivative == mode)
return;

View File

@@ -877,7 +877,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
GLuint f;
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
assert(ctx->API == API_OPENGL_COMPAT);
assert(_mesa_is_desktop_gl_compat(ctx));
FLUSH_VERTICES(ctx, 0, 0); /* update materials */
FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
@@ -1269,8 +1269,8 @@ _mesa_init_lighting( struct gl_context *ctx )
NULL );
ctx->Light.ColorMaterialEnabled = GL_FALSE;
ctx->Light.ClampVertexColor = ctx->API == API_OPENGL_COMPAT;
ctx->Light._ClampVertexColor = ctx->API == API_OPENGL_COMPAT;
ctx->Light.ClampVertexColor = _mesa_is_desktop_gl_compat(ctx);
ctx->Light._ClampVertexColor = _mesa_is_desktop_gl_compat(ctx);
/* Miscellaneous */
ctx->Light._NeedEyeCoords = GL_FALSE;

View File

@@ -61,7 +61,7 @@ line_width(struct gl_context *ctx, GLfloat width, bool no_error)
* *NOT* removed in a later spec. Therefore, we only disallow this in a
* forward compatible context.
*/
if (!no_error && ctx->API == API_OPENGL_CORE
if (!no_error && _mesa_is_desktop_gl_core(ctx)
&& ((ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
!= 0)
&& width > 1.0F) {

View File

@@ -81,7 +81,7 @@ get_named_matrix_stack(struct gl_context *ctx, GLenum mode, const char* caller)
case GL_MATRIX5_ARB:
case GL_MATRIX6_ARB:
case GL_MATRIX7_ARB:
if (ctx->API == API_OPENGL_COMPAT
if (_mesa_is_desktop_gl_compat(ctx)
&& (ctx->Extensions.ARB_vertex_program ||
ctx->Extensions.ARB_fragment_program)) {
const GLuint m = mode - GL_MATRIX0_ARB;

View File

@@ -242,7 +242,7 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
*
* This restriction is relaxed for OpenGL ES 3.1.
*/
if ((ctx->API == API_OPENGLES2 && ctx->Version == 30) &&
if ((_mesa_is_gles2(ctx) && ctx->Version == 30) &&
_mesa_is_enum_format_integer(internalFormat)
&& samples > 0) {
return GL_INVALID_OPERATION;

View File

@@ -168,8 +168,8 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params)
/* GL_POINT_SPRITE_COORD_ORIGIN was added to point sprites when the
* extension was merged into OpenGL 2.0.
*/
if ((ctx->API == API_OPENGL_COMPAT && ctx->Version >= 20)
|| ctx->API == API_OPENGL_CORE) {
if ((_mesa_is_desktop_gl_compat(ctx) && ctx->Version >= 20)
|| _mesa_is_desktop_gl_core(ctx)) {
GLenum value = (GLenum) params[0];
if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -228,8 +228,8 @@ _mesa_init_point(struct gl_context *ctx)
* In a core context, the state will default to true, and the setters and
* getters are disabled.
*/
ctx->Point.PointSprite = (ctx->API == API_OPENGL_CORE ||
ctx->API == API_OPENGLES2);
ctx->Point.PointSprite = (_mesa_is_desktop_gl_core(ctx) ||
_mesa_is_gles2(ctx));
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
ctx->Point.CoordReplace = 0; /* GL_ARB_point_sprite */

View File

@@ -184,7 +184,7 @@ polygon_mode(struct gl_context *ctx, GLenum face, GLenum mode, bool no_error)
switch (face) {
case GL_FRONT:
if (!no_error && ctx->API == API_OPENGL_CORE) {
if (!no_error && _mesa_is_desktop_gl_core(ctx)) {
_mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
return;
}
@@ -207,7 +207,7 @@ polygon_mode(struct gl_context *ctx, GLenum face, GLenum mode, bool no_error)
_mesa_update_edgeflag_state_vao(ctx);
break;
case GL_BACK:
if (!no_error && ctx->API == API_OPENGL_CORE) {
if (!no_error && _mesa_is_desktop_gl_core(ctx)) {
_mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
return;
}

View File

@@ -94,7 +94,7 @@ _mesa_update_allow_draw_out_of_order(struct gl_context *ctx)
if (!ctx->Const.AllowDrawOutOfOrder)
return;
assert(ctx->API == API_OPENGL_COMPAT);
assert(_mesa_is_desktop_gl_compat(ctx));
/* If all of these are NULL, GLSL is disabled. */
struct gl_program *vs =
@@ -440,7 +440,7 @@ update_program_constants(struct gl_context *ctx)
update_single_program_constants(ctx, ctx->FragmentProgram._Current,
MESA_SHADER_FRAGMENT);
if (ctx->API == API_OPENGL_COMPAT &&
if (_mesa_is_desktop_gl_compat(ctx) &&
ctx->Const.GLSLVersionCompat >= 150) {
new_state |=
update_single_program_constants(ctx, ctx->GeometryProgram._Current,
@@ -510,8 +510,8 @@ _mesa_update_state_locked( struct gl_context *ctx )
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* Handle Core and Compatibility contexts separately. */
if (ctx->API == API_OPENGL_COMPAT ||
ctx->API == API_OPENGLES) {
if (_mesa_is_desktop_gl_compat(ctx) ||
_mesa_is_gles1(ctx)) {
/* Update derived state. */
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
_mesa_update_modelview_project( ctx, new_state );
@@ -680,7 +680,7 @@ set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
* ES 2.0+ or OpenGL core profile, none of these arrays should ever
* be enabled.
*/
if (ctx->API == API_OPENGL_COMPAT)
if (_mesa_is_desktop_gl_compat(ctx))
ctx->VertexProgram._VPModeInputFilter = VERT_BIT_ALL;
else
ctx->VertexProgram._VPModeInputFilter = VERT_BIT_GENERIC_ALL;

View File

@@ -121,7 +121,7 @@ set_combiner_mode(struct gl_context *ctx,
break;
case GL_DOT3_RGB_EXT:
case GL_DOT3_RGBA_EXT:
legal = (ctx->API == API_OPENGL_COMPAT &&
legal = (_mesa_is_desktop_gl_compat(ctx) &&
ctx->Extensions.EXT_texture_env_dot3 &&
pname == GL_COMBINE_RGB);
break;
@@ -132,7 +132,7 @@ set_combiner_mode(struct gl_context *ctx,
case GL_MODULATE_ADD_ATI:
case GL_MODULATE_SIGNED_ADD_ATI:
case GL_MODULATE_SUBTRACT_ATI:
legal = (ctx->API == API_OPENGL_COMPAT &&
legal = (_mesa_is_desktop_gl_compat(ctx) &&
ctx->Extensions.ATI_texture_env_combine3);
break;
default:
@@ -231,12 +231,12 @@ set_combiner_source(struct gl_context *ctx,
legal = (param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits);
break;
case GL_ZERO:
legal = (ctx->API == API_OPENGL_COMPAT &&
legal = (_mesa_is_desktop_gl_compat(ctx) &&
(ctx->Extensions.ATI_texture_env_combine3 ||
ctx->Extensions.NV_texture_env_combine4));
break;
case GL_ONE:
legal = (ctx->API == API_OPENGL_COMPAT &&
legal = (_mesa_is_desktop_gl_compat(ctx) &&
ctx->Extensions.ATI_texture_env_combine3);
break;
default:
@@ -627,7 +627,7 @@ get_texenvi(struct gl_context *ctx,
return texUnit->Combine.SourceRGB[rgb_idx];
}
case GL_SOURCE3_RGB_NV:
if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) {
if (_mesa_is_desktop_gl_compat(ctx) && ctx->Extensions.NV_texture_env_combine4) {
return texUnit->Combine.SourceRGB[3];
}
else {
@@ -641,7 +641,7 @@ get_texenvi(struct gl_context *ctx,
return texUnit->Combine.SourceA[alpha_idx];
}
case GL_SOURCE3_ALPHA_NV:
if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) {
if (_mesa_is_desktop_gl_compat(ctx) && ctx->Extensions.NV_texture_env_combine4) {
return texUnit->Combine.SourceA[3];
}
else {
@@ -655,7 +655,7 @@ get_texenvi(struct gl_context *ctx,
return texUnit->Combine.OperandRGB[op_rgb];
}
case GL_OPERAND3_RGB_NV:
if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) {
if (_mesa_is_desktop_gl_compat(ctx) && ctx->Extensions.NV_texture_env_combine4) {
return texUnit->Combine.OperandRGB[3];
}
else {
@@ -669,7 +669,7 @@ get_texenvi(struct gl_context *ctx,
return texUnit->Combine.OperandA[op_alpha];
}
case GL_OPERAND3_ALPHA_NV:
if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) {
if (_mesa_is_desktop_gl_compat(ctx) && ctx->Extensions.NV_texture_env_combine4) {
return texUnit->Combine.OperandA[3];
}
else {

View File

@@ -55,7 +55,7 @@ get_texgen(struct gl_context *ctx, GLuint texunitIndex, GLenum coord, const char
texUnit = _mesa_get_fixedfunc_tex_unit(ctx, texunitIndex);
if (ctx->API == API_OPENGLES) {
if (_mesa_is_gles1(ctx)) {
return (coord == GL_TEXTURE_GEN_STR_OES)
? &texUnit->GenS : NULL;
}

View File

@@ -1854,7 +1854,7 @@ _mesa_uniform_matrix(GLint location, GLsizei count,
* http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml
*/
if (transpose) {
if (ctx->API == API_OPENGLES2 && ctx->Version < 30) {
if (_mesa_is_gles2(ctx) && ctx->Version < 30) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glUniformMatrix(matrix transpose is not GL_FALSE)");
return;

View File

@@ -92,7 +92,7 @@ _mesa_init_program(struct gl_context *ctx)
ctx->VertexProgram._VaryingInputs = VERT_BIT_ALL;
ctx->VertexProgram.Enabled = GL_FALSE;
ctx->VertexProgram.PointSizeEnabled =
(ctx->API == API_OPENGLES2) ? GL_TRUE : GL_FALSE;
_mesa_is_gles2(ctx) ? GL_TRUE : GL_FALSE;
ctx->VertexProgram.TwoSideEnabled = GL_FALSE;
_mesa_reference_program(ctx, &ctx->VertexProgram.Current,
ctx->Shared->DefaultVertexProgram);

View File

@@ -41,6 +41,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "cso_cache/cso_context.h"
#include "main/context.h"
static GLuint
@@ -221,7 +222,7 @@ st_update_rasterizer(struct st_context *st)
raster->point_quad_rasterization = 1;
raster->point_tri_clip = st->ctx->API == API_OPENGLES2;
raster->point_tri_clip = _mesa_is_gles2(st->ctx);
}
/* ST_NEW_VERTEX_PROGRAM

View File

@@ -154,7 +154,7 @@ st_invalidate_state(struct gl_context *ctx)
/* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT_STATE)) {
ctx->NewDriverState |= ST_NEW_VS_STATE;
if (st->ctx->API == API_OPENGL_COMPAT && ctx->Version >= 32) {
if (_mesa_is_desktop_gl_compat(st->ctx) && ctx->Version >= 32) {
ctx->NewDriverState |= ST_NEW_GS_STATE | ST_NEW_TES_STATE;
}
}
@@ -684,7 +684,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
/* For drivers which cannot do color clamping, it's better to just
* disable ARB_color_buffer_float in the core profile, because
* the clamping is deprecated there anyway. */
if (ctx->API == API_OPENGL_CORE &&
if (_mesa_is_desktop_gl_core(ctx) &&
(st->clamp_frag_color_in_shader || st->clamp_vert_color_in_shader)) {
st->clamp_vert_color_in_shader = GL_FALSE;
st->clamp_frag_color_in_shader = GL_FALSE;

View File

@@ -1262,7 +1262,7 @@ st_precompile_shader_variant(struct st_context *st,
memset(&key, 0, sizeof(key));
if (st->ctx->API == API_OPENGL_COMPAT &&
if (_mesa_is_desktop_gl_compat(st->ctx) &&
st->clamp_vert_color_in_shader &&
(prog->info.outputs_written & (VARYING_SLOT_COL0 |
VARYING_SLOT_COL1 |

View File

@@ -36,6 +36,7 @@
#include "state_tracker/st_context.h"
#include "main/context.h"
#ifdef __cplusplus
@@ -67,8 +68,8 @@ st_invalidate_readpix_cache(struct st_context *st)
static inline bool
st_user_clip_planes_enabled(struct gl_context *ctx)
{
return (ctx->API == API_OPENGL_COMPAT ||
ctx->API == API_OPENGLES) && /* only ES 1.x */
return (_mesa_is_desktop_gl_compat(ctx) ||
_mesa_is_gles1(ctx)) && /* only ES 1.x */
ctx->Transform.ClipPlanesEnabled;
}

View File

@@ -31,6 +31,7 @@
#include "main/api_arrayelt.h"
#include "main/arrayobj.h"
#include "main/varray.h"
#include "main/context.h"
#include "util/u_memory.h"
#include "vbo.h"
#include "vbo_private.h"
@@ -163,7 +164,7 @@ _vbo_CreateContext(struct gl_context *ctx)
STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
vbo_exec_init(ctx);
if (ctx->API == API_OPENGL_COMPAT)
if (_mesa_is_desktop_gl_compat(ctx))
vbo_save_init(ctx);
vbo->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
@@ -184,7 +185,7 @@ _vbo_DestroyContext(struct gl_context *ctx)
if (vbo) {
vbo_exec_destroy(ctx);
if (ctx->API == API_OPENGL_COMPAT)
if (_mesa_is_desktop_gl_compat(ctx))
vbo_save_destroy(ctx);
_mesa_reference_vao(ctx, &vbo->VAO, NULL);
}

View File

@@ -603,10 +603,10 @@ _mesa_Materialfv(GLenum face, GLenum pname, const GLfloat *params)
updateMats = ALL_MATERIAL_BITS;
}
if (ctx->API == API_OPENGL_COMPAT && face == GL_FRONT) {
if (_mesa_is_desktop_gl_compat(ctx) && face == GL_FRONT) {
updateMats &= FRONT_MATERIAL_BITS;
}
else if (ctx->API == API_OPENGL_COMPAT && face == GL_BACK) {
else if (_mesa_is_desktop_gl_compat(ctx) && face == GL_BACK) {
updateMats &= BACK_MATERIAL_BITS;
}
else if (face != GL_FRONT_AND_BACK) {