[Mesa-dev] [PATCH v2 3/7] mesa: add support for using API_OPENGL_CORE
Jordan Justen
jordan.l.justen at intel.com
Thu Jul 26 23:43:35 PDT 2012
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
src/mesa/main/api_validate.c | 1 +
src/mesa/main/context.c | 6 ++++--
src/mesa/main/extensions.c | 4 +++-
src/mesa/main/fbobject.c | 14 +++++++-------
src/mesa/main/get.c | 11 +++++++----
src/mesa/main/getstring.c | 1 +
src/mesa/main/texformat.c | 2 +-
src/mesa/main/teximage.c | 2 +-
src/mesa/main/varray.c | 2 +-
src/mesa/main/version.c | 1 +
src/mesa/main/vtxfmt.c | 4 ++--
11 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index ece0a2b..eaf614b 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -128,6 +128,7 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
#if FEATURE_GL
case API_OPENGL:
+ case API_OPENGL_CORE:
{
const struct gl_shader_program *vsProg =
ctx->Shader.CurrentVertexProgram;
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 41550f9..3daff96 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -431,7 +431,7 @@ one_time_init( struct gl_context *ctx )
* when an app is linked to libGLES*, there are not enough dynamic
* entries.
*/
- if (ctx->API == API_OPENGL)
+ if (IS_CTX_DESKTOP_GL(ctx))
_mesa_init_remap_table();
}
@@ -626,7 +626,7 @@ _mesa_init_constants(struct gl_context *ctx)
#endif
/* Shading language version */
- if (ctx->API == API_OPENGL) {
+ if (IS_CTX_DESKTOP_GL(ctx)) {
ctx->Const.GLSLVersion = 120;
_mesa_override_glsl_version(ctx);
}
@@ -962,6 +962,7 @@ _mesa_initialize_context(struct gl_context *ctx,
switch (ctx->API) {
#if FEATURE_GL
case API_OPENGL:
+ case API_OPENGL_CORE:
ctx->Exec = _mesa_create_exec_table();
break;
#endif
@@ -1007,6 +1008,7 @@ _mesa_initialize_context(struct gl_context *ctx,
switch (ctx->API) {
case API_OPENGL:
+ case API_OPENGL_CORE:
#if FEATURE_dlist
ctx->Save = _mesa_create_save_table();
if (!ctx->Save) {
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 0675ce7..fbc1bb7 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -41,7 +41,9 @@
enum {
DISABLE = 0,
- GL = 1 << API_OPENGL,
+ GLL = 1 << API_OPENGL,
+ GLC = 1 << API_OPENGL_CORE,
+ GL = (1 << API_OPENGL) | (1 << API_OPENGL_CORE),
ES1 = 1 << API_OPENGLES,
ES2 = 1 << API_OPENGLES2,
};
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index ece1251..0b426f5 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -164,10 +164,10 @@ get_framebuffer_target(struct gl_context *ctx, GLenum target)
{
switch (target) {
case GL_DRAW_FRAMEBUFFER:
- return ctx->Extensions.EXT_framebuffer_blit && ctx->API == API_OPENGL
+ return ctx->Extensions.EXT_framebuffer_blit && IS_CTX_DESKTOP_GL(ctx)
? ctx->DrawBuffer : NULL;
case GL_READ_FRAMEBUFFER:
- return ctx->Extensions.EXT_framebuffer_blit && ctx->API == API_OPENGL
+ return ctx->Extensions.EXT_framebuffer_blit && IS_CTX_DESKTOP_GL(ctx)
? ctx->ReadBuffer : NULL;
case GL_FRAMEBUFFER_EXT:
return ctx->DrawBuffer;
@@ -221,7 +221,7 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
}
return &fb->Attachment[BUFFER_COLOR0 + i];
case GL_DEPTH_STENCIL_ATTACHMENT:
- if (ctx->API != API_OPENGL)
+ if (!IS_CTX_DESKTOP_GL(ctx))
return NULL;
/* fall-through */
case GL_DEPTH_ATTACHMENT_EXT:
@@ -817,7 +817,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
}
#if FEATURE_GL
- if (ctx->API == API_OPENGL && !ctx->Extensions.ARB_ES2_compatibility) {
+ if (IS_CTX_DESKTOP_GL(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
/* Check that all DrawBuffers are present */
for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) {
if (fb->ColorDrawBuffer[j] != GL_NONE) {
@@ -2289,7 +2289,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The error differs in GL and GLES. */
- err = ctx->API == API_OPENGL ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+ err = IS_CTX_DESKTOP_GL(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
buffer = get_framebuffer_target(ctx, target);
if (!buffer) {
@@ -2309,7 +2309,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
* OES_framebuffer_object spec refers to the EXT_framebuffer_object
* spec.
*/
- if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_framebuffer_object) {
+ if (!IS_CTX_DESKTOP_GL(ctx) || !ctx->Extensions.ARB_framebuffer_object) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
return;
@@ -2357,7 +2357,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
}
else {
assert(att->Type == GL_NONE);
- if (ctx->API == API_OPENGL) {
+ if (IS_CTX_DESKTOP_GL(ctx)) {
*params = 0;
} else {
_mesa_error(ctx, GL_INVALID_ENUM,
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 15de321..844c7be 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -391,6 +391,7 @@ extra_NV_read_buffer_api_gl[] = {
#define API_OPENGL_BIT (1 << API_OPENGL)
#define API_OPENGLES_BIT (1 << API_OPENGLES)
#define API_OPENGLES2_BIT (1 << API_OPENGLES2)
+#define API_OPENGL_CORE_BIT (1 << API_OPENGL_CORE)
/* This is the big table describing all the enums we accept in
* glGet*v(). The table is partitioned into six parts: enums
@@ -405,7 +406,9 @@ extra_NV_read_buffer_api_gl[] = {
static const struct value_desc values[] = {
/* Enums shared between OpenGL, GLES1 and GLES2 */
{ 0, 0, TYPE_API_MASK,
- API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA},
+ API_OPENGL_BIT | API_OPENGLES_BIT |API_OPENGLES2_BIT |
+ API_OPENGL_CORE_BIT,
+ NO_EXTRA},
{ GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers },
{ GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
{ GL_BLEND_SRC, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA },
@@ -534,7 +537,7 @@ static const struct value_desc values[] = {
#if FEATURE_GL || FEATURE_ES1
/* Enums in OpenGL and GLES1 */
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA },
+ { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGL_CORE_BIT, NO_EXTRA },
{ GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
{ GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA },
{ GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA },
@@ -796,7 +799,7 @@ static const struct value_desc values[] = {
#if FEATURE_GL
/* Remaining enums are only in OpenGL */
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA },
+ { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGL_CORE_BIT, NO_EXTRA },
{ GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA },
{ GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA },
{ GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA },
@@ -1887,7 +1890,7 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
}
break;
case EXTRA_API_GL:
- if (ctx->API == API_OPENGL) {
+ if (IS_CTX_DESKTOP_GL(ctx)) {
total++;
enabled++;
}
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 2f445aa..c6f400a 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -41,6 +41,7 @@ shading_language_version(struct gl_context *ctx)
{
switch (ctx->API) {
case API_OPENGL:
+ case API_OPENGL_CORE:
if (!ctx->Extensions.ARB_shader_objects) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetString");
return (const GLubyte *) 0;
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 9189717..6486276 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -895,7 +895,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
}
/* GL_BGRA can be an internal format *only* in OpenGL ES (1.x or 2.0).
*/
- if (ctx->API != API_OPENGL) {
+ if (IS_CTX_GLES(ctx)) {
switch (internalFormat) {
case GL_BGRA:
RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 91df133..fd5e74a 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -130,7 +130,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
/* GL_BGRA can be an internal format *only* in OpenGL ES (1.x or 2.0).
*/
- if (ctx->API != API_OPENGL) {
+ if (IS_CTX_GLES(ctx)) {
switch (internalFormat) {
case GL_BGRA:
return GL_RGBA;
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index efa63b0..df22193 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -92,7 +92,7 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
case GL_DOUBLE:
return DOUBLE_BIT;
case GL_FIXED:
- return ctx->API == API_OPENGL ? FIXED_GL_BIT : FIXED_ES_BIT;
+ return (IS_CTX_DESKTOP_GL(ctx)) ? FIXED_GL_BIT : FIXED_ES_BIT;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return UNSIGNED_INT_2_10_10_10_REV_BIT;
case GL_INT_2_10_10_10_REV:
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index efaaf58..91ef2df 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -315,6 +315,7 @@ _mesa_compute_version(struct gl_context *ctx)
switch (ctx->API) {
case API_OPENGL:
+ case API_OPENGL_CORE:
compute_version(ctx);
break;
case API_OPENGLES:
diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c
index bf7a54c..2146055 100644
--- a/src/mesa/main/vtxfmt.c
+++ b/src/mesa/main/vtxfmt.c
@@ -209,7 +209,7 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
void
_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
{
- if (ctx->API == API_OPENGL)
+ if (IS_CTX_DESKTOP_GL(ctx))
install_vtxfmt( ctx->Exec, vfmt );
}
@@ -221,7 +221,7 @@ _mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
void
_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
{
- if (ctx->API == API_OPENGL)
+ if (IS_CTX_DESKTOP_GL(ctx))
install_vtxfmt( ctx->Save, vfmt );
}
--
1.7.9.5
More information about the mesa-dev
mailing list