mesa: replace ctx->VertexProgram._TwoSideEnabled with a helper function
authorMarek Olšák <marek.olsak@amd.com>
Fri, 9 Jun 2017 19:27:18 +0000 (21:27 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/genX_state_upload.c
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/main/state.h
src/mesa/state_tracker/st_atom_rasterizer.c

index 0739306f30bd666d3ebcd4d8c7b27024b7adfc60..d92b5197fdd5e19b8b5faf543c6e8fce03452465 100644 (file)
@@ -34,6 +34,7 @@
 #include "main/mtypes.h"
 #include "main/enums.h"
 #include "main/fbobject.h"
+#include "main/state.h"
 
 #include "intel_batchbuffer.h"
 
@@ -152,8 +153,7 @@ brw_upload_sf_prog(struct brw_context *brw)
    }
 
    /* _NEW_LIGHT | _NEW_PROGRAM */
-   key.do_twoside_color = ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) ||
-                           ctx->VertexProgram._TwoSideEnabled);
+   key.do_twoside_color = _mesa_vertex_program_two_side_enabled(ctx);
 
    /* _NEW_POLYGON */
    if (key.do_twoside_color) {
index 8c6d3ff012e84c5bfaa8b5ed274803756b4a1b2f..b0e423f2f4d3a714b7beda513702c0a7aef6046f 100644 (file)
@@ -31,6 +31,7 @@
 #include "main/context.h"
 #include "main/enums.h"
 #include "main/macros.h"
+#include "main/state.h"
 
 #include "brw_context.h"
 #if GEN_GEN == 6
@@ -1117,7 +1118,7 @@ genX(calculate_attr_overrides)(const struct brw_context *brw,
          genX(get_attr_override)(&attribute,
                                  &brw->vue_map_geom_out,
                                  *urb_entry_read_offset, attr,
-                                 brw->ctx.VertexProgram._TwoSideEnabled,
+                                 _mesa_vertex_program_two_side_enabled(ctx),
                                  &max_source_attr);
       }
 
index 4e7011bb7018bf2cc46f69371f165e5b205f0c5a..e36bb9199642c112c90c34247b9a4589565d5ed0 100644 (file)
@@ -2255,8 +2255,6 @@ struct gl_vertex_program_state
    GLboolean _Enabled;           /**< Enabled and _valid_ user program? */
    GLboolean PointSizeEnabled;   /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
    GLboolean TwoSideEnabled;     /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
-   /** Computed two sided lighting for fixed function/programs. */
-   GLboolean _TwoSideEnabled;
    struct gl_program *Current;  /**< User-bound vertex program */
 
    /** Currently enabled and valid vertex program (including internal
index d1d0c2cd998daa3b740c97a8835fd75ad530af96..0772e6b82a1b8e51f89f5aad7d929abdbdd86070 100644 (file)
@@ -289,22 +289,6 @@ update_frontbit(struct gl_context *ctx)
 }
 
 
-/**
- * Update the ctx->VertexProgram._TwoSideEnabled flag.
- */
-static void
-update_twoside(struct gl_context *ctx)
-{
-   if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] ||
-       ctx->VertexProgram._Enabled) {
-      ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled;
-   } else {
-      ctx->VertexProgram._TwoSideEnabled = (ctx->Light.Enabled &&
-                                           ctx->Light.Model.TwoSide);
-   }
-}
-
-
 /**
  * Compute derived GL state.
  * If __struct gl_contextRec::NewState is non-zero then this function \b must
@@ -376,9 +360,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
    if (new_state & _NEW_LIGHT)
       _mesa_update_lighting( ctx );
 
-   if (new_state & (_NEW_LIGHT | _NEW_PROGRAM))
-      update_twoside( ctx );
-
    if (new_state & _NEW_PIXEL)
       _mesa_update_pixel( ctx );
 
index 7a6cdacf4710b1dda19a7c13106d5ec2a744903c..8817a4776d1c62877c197ea0921b19f0c306f6ed 100644 (file)
@@ -72,4 +72,15 @@ _mesa_need_secondary_color(const struct gl_context *ctx)
    return GL_FALSE;
 }
 
+/** Compute two sided lighting state for fixed function or programs. */
+static inline bool
+_mesa_vertex_program_two_side_enabled(const struct gl_context *ctx)
+{
+   if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] ||
+       ctx->VertexProgram._Enabled)
+      return ctx->VertexProgram.TwoSideEnabled;
+
+   return ctx->Light.Enabled && ctx->Light.Model.TwoSide;
+}
+
 #endif
index 42696b10a364dbf6d46c5f2a1efbaa1fefa5a5c4..6e17562d5aab7a856e0428643f6245b948d50a02 100644 (file)
@@ -32,6 +32,7 @@
  
 #include "main/macros.h"
 #include "main/framebuffer.h"
+#include "main/state.h"
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_debug.h"
@@ -99,7 +100,7 @@ void st_update_rasterizer( struct st_context *st )
                              GL_FIRST_VERTEX_CONVENTION_EXT;
 
    /* _NEW_LIGHT | _NEW_PROGRAM */
-   raster->light_twoside = ctx->VertexProgram._TwoSideEnabled;
+   raster->light_twoside = _mesa_vertex_program_two_side_enabled(ctx);
 
    /*_NEW_LIGHT | _NEW_BUFFERS */
    raster->clamp_vertex_color = !st->clamp_vert_color_in_shader &&