Re: [Mesa-dev] [PATCH 2/2] meta: Drop ctx-API checks.

2014-02-27 Thread Eric Anholt
Kenneth Graunke kenn...@whitecape.org writes:

 API is always API_OPENGL_COMPAT (since commit 4e4a537ad55f61a25,
 meta: Push into desktop GL mode when doing meta operations.),
 so most of these checks do nothing.

 We could instead check save-API to only bother setting/restoring
 relevant GL state, but I'm not sure saving a few _mesa_set_enable
 calls is worth the complexity.  My understanding is the point of
 the ctx-API guards was to avoid raising GL errors.

 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/mesa/drivers/common/meta.c  | 139 
 +---
  src/mesa/drivers/common/meta_blit.c |   3 +-
  2 files changed, 50 insertions(+), 92 deletions(-)

 We either ought to do this, or move _mesa_meta_begin's ctx-API override
 to /after/ the state saving.  I'm not sure which we ought to do.

 This simplifies a lot of the core/compat/ES insanity quite a bit, but doing
 the save state/restore state in the real API might be more sensible...

I think I like it this way more.

If we're concerned about state save/restore overhead, then I think some
day we'd want to just avoid all the FF state save/restore in the
GLSL-based paths.

These two are:

Reviewed-by: Eric Anholt e...@anholt.net


pgpkRSD24SsKs.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] meta: Drop ctx-API checks.

2014-02-26 Thread Kenneth Graunke
API is always API_OPENGL_COMPAT (since commit 4e4a537ad55f61a25,
meta: Push into desktop GL mode when doing meta operations.),
so most of these checks do nothing.

We could instead check save-API to only bother setting/restoring
relevant GL state, but I'm not sure saving a few _mesa_set_enable
calls is worth the complexity.  My understanding is the point of
the ctx-API guards was to avoid raising GL errors.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/common/meta.c  | 139 +---
 src/mesa/drivers/common/meta_blit.c |   3 +-
 2 files changed, 50 insertions(+), 92 deletions(-)

We either ought to do this, or move _mesa_meta_begin's ctx-API override
to /after/ the state saving.  I'm not sure which we ought to do.

This simplifies a lot of the core/compat/ES insanity quite a bit, but doing
the save state/restore state in the real API might be more sensible...

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 19600e6..cde34f9 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -188,12 +188,7 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
   return;
}
 
-   /* The version check is a little tricky.  API is set to API_OPENGLES2 even
-* for OpenGL ES 3.0 contexts, and GLSLVersion may be set to 140, for
-* example, in an OpenGL ES 2.0 context.
-*/
-   if ((ctx-API == API_OPENGLES2  ctx-Version  30)
-   || ctx-Const.GLSLVersion  130) {
+   if (ctx-Const.GLSLVersion  130) {
   vs_source =
  attribute vec2 position;\n
  attribute vec4 textureCoords;\n
@@ -464,9 +459,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
  _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE);
}
 
-   if ((state  MESA_META_FOG)
-ctx-API != API_OPENGL_CORE
-ctx-API != API_OPENGLES2) {
+   if (state  MESA_META_FOG) {
   save-Fog = ctx-Fog.Enabled;
   if (ctx-Fog.Enabled)
  _mesa_set_enable(ctx, GL_FOG, GL_FALSE);
@@ -511,10 +504,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
   save-PolygonCull = ctx-Polygon.CullFlag;
   _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
   _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE);
-  if (ctx-API == API_OPENGL_COMPAT) {
- _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE);
- _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE);
-  }
+  _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE);
+  _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE);
   _mesa_set_enable(ctx, GL_CULL_FACE, GL_FALSE);
}
 
@@ -526,21 +517,21 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
if (state  MESA_META_SHADER) {
   int i;
 
-  if (ctx-API == API_OPENGL_COMPAT  ctx-Extensions.ARB_vertex_program) 
{
+  if (ctx-Extensions.ARB_vertex_program) {
  save-VertexProgramEnabled = ctx-VertexProgram.Enabled;
  _mesa_reference_vertprog(ctx, save-VertexProgram,
  ctx-VertexProgram.Current);
  _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
   }
 
-  if (ctx-API == API_OPENGL_COMPAT  
ctx-Extensions.ARB_fragment_program) {
+  if (ctx-Extensions.ARB_fragment_program) {
  save-FragmentProgramEnabled = ctx-FragmentProgram.Enabled;
  _mesa_reference_fragprog(ctx, save-FragmentProgram,
  ctx-FragmentProgram.Current);
  _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE);
   }
 
-  if (ctx-API == API_OPENGL_COMPAT  
ctx-Extensions.ATI_fragment_shader) {
+  if (ctx-Extensions.ATI_fragment_shader) {
  save-ATIFragmentShaderEnabled = ctx-ATIFragmentShader.Enabled;
  _mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI, GL_FALSE);
   }
@@ -570,33 +561,24 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
   save-EnvMode = ctx-Texture.Unit[0].EnvMode;
 
   /* Disable all texture units */
-  if (ctx-API == API_OPENGL_COMPAT || ctx-API == API_OPENGLES) {
- for (u = 0; u  ctx-Const.MaxTextureUnits; u++) {
-save-TexEnabled[u] = ctx-Texture.Unit[u].Enabled;
-save-TexGenEnabled[u] = ctx-Texture.Unit[u].TexGenEnabled;
-if (ctx-Texture.Unit[u].Enabled ||
-ctx-Texture.Unit[u].TexGenEnabled) {
-   _mesa_ActiveTexture(GL_TEXTURE0 + u);
-   _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
-   if (ctx-Extensions.ARB_texture_cube_map)
-  _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
-   if (_mesa_is_gles(ctx) 
-   ctx-Extensions.OES_EGL_image_external)
-  _mesa_set_enable(ctx, GL_TEXTURE_EXTERNAL_OES, GL_FALSE);
-
-   if (ctx-API == API_OPENGL_COMPAT) {
-  _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE);
-  _mesa_set_enable(ctx, GL_TEXTURE_3D,