i965/gs: Precompile geometry shaders.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Paul Berry 2013-10-23 10:19:39 -07:00
parent e0f34301b2
commit 85db1326a2
4 changed files with 48 additions and 0 deletions

View 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)
{

View 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;

View 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)
{

View file

@ -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);