i965/gs: Precompile geometry shaders.
authorPaul Berry <stereotype441@gmail.com>
Wed, 23 Oct 2013 17:19:39 +0000 (10:19 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 25 Oct 2013 05:00:28 +0000 (22:00 -0700)
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_context.h
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vec4_gs.c
src/mesa/drivers/dri/i965/brw_vec4_gs.h

index 0229cc5b89a33ddb09d7d7d83e8e14df48898aea..39f45c64f87bd919c074602bba1dfaef28354cee 100644 (file)
@@ -1630,6 +1630,12 @@ brw_vertex_program_const(const struct gl_vertex_program *p)
    return (const struct brw_vertex_program *) p;
 }
 
+static INLINE struct brw_geometry_program *
+brw_geometry_program(struct gl_geometry_program *p)
+{
+   return (struct brw_geometry_program *) p;
+}
+
 static INLINE struct brw_fragment_program *
 brw_fragment_program(struct gl_fragment_program *p)
 {
index 5992a1c33b5c55f22e7cd2f2abfdbe322fb34e7b..67084a781441e0d726a27a3fd75fc50ff4d90c4f 100644 (file)
@@ -26,6 +26,7 @@ extern "C" {
 #include "brw_context.h"
 }
 #include "brw_vs.h"
+#include "brw_vec4_gs.h"
 #include "brw_fs.h"
 #include "glsl/ir_optimization.h"
 #include "glsl/glsl_parser_extras.h"
@@ -70,6 +71,9 @@ brw_shader_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    if (brw->precompile && !brw_fs_precompile(ctx, prog))
       return false;
 
+   if (brw->precompile && !brw_gs_precompile(ctx, prog))
+      return false;
+
    if (brw->precompile && !brw_vs_precompile(ctx, prog))
       return false;
 
index e00a10431a4156e5b185c72ec9848248bfc8e99f..b52d646aa00d6e43f7b4218fabfa81c45090d613 100644 (file)
@@ -306,6 +306,40 @@ const struct brw_tracked_state brw_gs_prog = {
 };
 
 
+bool
+brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
+{
+   struct brw_context *brw = brw_context(ctx);
+   struct brw_gs_prog_key key;
+   uint32_t old_prog_offset = brw->gs.base.prog_offset;
+   struct brw_gs_prog_data *old_prog_data = brw->gs.prog_data;
+   bool success;
+
+   if (!prog->_LinkedShaders[MESA_SHADER_GEOMETRY])
+      return true;
+
+   struct gl_geometry_program *gp = (struct gl_geometry_program *)
+      prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
+   struct brw_geometry_program *bgp = brw_geometry_program(gp);
+
+   memset(&key, 0, sizeof(key));
+
+   brw_vec4_setup_prog_key_for_precompile(ctx, &key.base, bgp->id, &gp->Base);
+
+   /* Assume that the set of varyings coming in from the vertex shader exactly
+    * matches what the geometry shader requires.
+    */
+   key.input_varyings = gp->Base.InputsRead;
+
+   success = do_gs_prog(brw, prog, bgp, &key);
+
+   brw->gs.base.prog_offset = old_prog_offset;
+   brw->gs.prog_data = old_prog_data;
+
+   return success;
+}
+
+
 bool
 brw_gs_prog_data_compare(const void *in_a, const void *in_b)
 {
index 8b979ac55b7facbc03e10bd07baf01098102185a..b209d80c96e4fc46491e88a612b1ac855f9b2582 100644 (file)
 extern "C" {
 #endif
 
+struct gl_context;
+struct gl_shader_program;
+
+bool brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
 bool brw_gs_prog_data_compare(const void *a, const void *b);
 void brw_gs_prog_data_free(const void *in_prog_data);