summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-10-23 10:19:39 -0700
committerPaul Berry <[email protected]>2013-10-24 22:00:28 -0700
commit85db1326a2f0413a0f55e416791c64732b0af88a (patch)
tree64ee6f190b5bafe72f9ddb9f294a161bc8f4f83e /src/mesa
parente0f34301b29ecf3fb7118b2e05872510c104a49b (diff)
i965/gs: Precompile geometry shaders.
Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h6
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_gs.c34
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_gs.h4
4 files changed, 48 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 0229cc5b89a..39f45c64f87 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -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)
{
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 5992a1c33b5..67084a78144 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs.c b/src/mesa/drivers/dri/i965/brw_vec4_gs.c
index e00a10431a4..b52d646aa00 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs.c
@@ -307,6 +307,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)
{
const struct brw_gs_prog_data *a = in_a;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs.h b/src/mesa/drivers/dri/i965/brw_vec4_gs.h
index 8b979ac55b7..b209d80c96e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs.h
@@ -30,6 +30,10 @@
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);