glsl: Move UsesClipDistance from gl_{vertex,geometry}_program into gl_program.
authorPaul Berry <stereotype441@gmail.com>
Wed, 23 Oct 2013 17:59:57 +0000 (10:59 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 25 Oct 2013 05:00:13 +0000 (22:00 -0700)
This will make it easier for back-ends to share code between geometry
shader and vertex shader compilation.  Also, it is renamed to
"UsesClipDistanceOut" to clarify that (a) in geometry shaders, it
refers to the gl_ClipDistance output rather than the gl_ClipDistance
input, and (b) it is irrelevant in fragment shaders.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_vec4_gs.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c

index b48422c5001cbde7a273cd1fd6c8cdbdec2f0971..e00a10431a4156e5b185c72ec9848248bfc8e99f 100644 (file)
@@ -267,7 +267,8 @@ brw_upload_gs_prog(struct brw_context *brw)
    memset(&key, 0, sizeof(key));
 
    key.base.program_string_id = gp->id;
-   brw_setup_vec4_key_clip_info(brw, &key.base, gp->program.UsesClipDistance);
+   brw_setup_vec4_key_clip_info(brw, &key.base,
+                                gp->program.Base.UsesClipDistanceOut);
 
    /* _NEW_LIGHT | _NEW_BUFFERS */
    key.base.clamp_vertex_color = ctx->Light._ClampVertexColor;
index c0ae3edbe0626ab162c8be09480dbd38de63e734..04cf857c98d503561bff3c331571019a070f1737 100644 (file)
@@ -420,7 +420,8 @@ static void brw_upload_vs_prog(struct brw_context *brw)
     * the inputs it asks for, whether they are varying or not.
     */
    key.base.program_string_id = vp->id;
-   brw_setup_vec4_key_clip_info(brw, &key.base, vp->program.UsesClipDistance);
+   brw_setup_vec4_key_clip_info(brw, &key.base,
+                                vp->program.Base.UsesClipDistanceOut);
 
    /* _NEW_POLYGON */
    if (brw->gen < 6) {
index 2c5ea4b5d2aa9b0939434882ec679f04104b90f0..97ed1bd6a14310e873c850420df13b1ee4176a5a 100644 (file)
@@ -1965,6 +1965,12 @@ struct gl_program
 
    GLboolean UsesGather; /**< Does this program use gather4 at all? */
 
+   /**
+    * For vertex and geometry shaders, true if the program uses the
+    * gl_ClipDistance output.  Ignored for fragment shaders.
+    */
+   GLboolean UsesClipDistanceOut;
+
 
    /** Named parameters, constants, etc. from program text */
    struct gl_program_parameter_list *Parameters;
@@ -2009,7 +2015,6 @@ struct gl_vertex_program
 {
    struct gl_program Base;   /**< base class */
    GLboolean IsPositionInvariant;
-   GLboolean UsesClipDistance;
 };
 
 
@@ -2023,7 +2028,6 @@ struct gl_geometry_program
    GLenum InputType;  /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,
                            GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */
    GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
-   GLboolean UsesClipDistance;
    GLboolean UsesEndPrimitive;
 };
 
index d3677c8516b5c9b73cd2e5bf88cb0463d9c78a87..53f0cab7c55f7829440d54836a53b7da7c18dc03 100644 (file)
@@ -1855,10 +1855,8 @@ _mesa_copy_linked_program_data(gl_shader_type type,
                                struct gl_program *dst)
 {
    switch (type) {
-   case MESA_SHADER_VERTEX: {
-      struct gl_vertex_program *dst_vp = (struct gl_vertex_program *) dst;
-      dst_vp->UsesClipDistance = src->Vert.UsesClipDistance;
-   }
+   case MESA_SHADER_VERTEX:
+      dst->UsesClipDistanceOut = src->Vert.UsesClipDistance;
       break;
    case MESA_SHADER_GEOMETRY: {
       struct gl_geometry_program *dst_gp = (struct gl_geometry_program *) dst;
@@ -1866,7 +1864,7 @@ _mesa_copy_linked_program_data(gl_shader_type type,
       dst_gp->VerticesOut = src->Geom.VerticesOut;
       dst_gp->InputType = src->Geom.InputType;
       dst_gp->OutputType = src->Geom.OutputType;
-      dst_gp->UsesClipDistance = src->Geom.UsesClipDistance;
+      dst->UsesClipDistanceOut = src->Geom.UsesClipDistance;
       dst_gp->UsesEndPrimitive = src->Geom.UsesEndPrimitive;
    }
       break;