extern "C" {
bool
-brw_vs_emit(struct brw_vs_compile *c)
+brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c)
{
- struct brw_compile *p = &c->func;
- struct brw_context *brw = p->brw;
- struct intel_context *intel = &brw->intel;
- struct gl_context *ctx = &intel->ctx;
- struct gl_shader_program *prog = ctx->Shader.CurrentVertexProgram;
-
if (!prog)
return false;
vec4_visitor v(c, prog, shader);
if (!v.run()) {
- /* FINISHME: Cleanly fail, test at link time, etc. */
- assert(!"not reached");
+ prog->LinkStatus = GL_FALSE;
+ ralloc_strcat(&prog->InfoLog, v.fail_msg);
return false;
}
#include "../glsl/ralloc.h"
-static void do_vs_prog( struct brw_context *brw,
- struct brw_vertex_program *vp,
- struct brw_vs_prog_key *key )
+static bool
+do_vs_prog(struct brw_context *brw,
+ struct gl_shader_program *prog,
+ struct brw_vertex_program *vp,
+ struct brw_vs_prog_key *key)
{
struct gl_context *ctx = &brw->intel.ctx;
struct intel_context *intel = &brw->intel;
if (new_vs == -1)
new_vs = getenv("INTEL_NEW_VS") != NULL;
- if (new_vs) {
- if (!brw_vs_emit(&c))
- brw_old_vs_emit(&c);
+ if (new_vs && prog) {
+ if (!brw_vs_emit(prog, &c)) {
+ ralloc_free(mem_ctx);
+ return false;
+ }
} else {
brw_old_vs_emit(&c);
}
&c.prog_data, aux_size,
&brw->vs.prog_offset, &brw->vs.prog_data);
ralloc_free(mem_ctx);
+
+ return true;
}
if (!brw_search_cache(&brw->cache, BRW_VS_PROG,
&key, sizeof(key),
&brw->vs.prog_offset, &brw->vs.prog_data)) {
- do_vs_prog(brw, vp, &key);
+ bool success = do_vs_prog(brw, ctx->Shader.CurrentVertexProgram,
+ vp, &key);
+
+ assert(success);
}
brw->vs.constant_map = ((int8_t *)brw->vs.prog_data +
sizeof(*brw->vs.prog_data));
}
-
/* See brw_vs.c:
*/
const struct brw_tracked_state brw_vs_prog = {
},
.prepare = brw_upload_vs_prog
};
+
+bool
+brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
+{
+ struct brw_context *brw = brw_context(ctx);
+ struct brw_vs_prog_key key;
+ struct gl_vertex_program *vp = prog->VertexProgram;
+ struct brw_vertex_program *bvp = brw_vertex_program(vp);
+ uint32_t old_prog_offset = brw->vs.prog_offset;
+ struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
+ bool success;
+
+ if (!vp)
+ return true;
+
+ memset(&key, 0, sizeof(key));
+
+ key.program_string_id = bvp->id;
+ key.clamp_vertex_color = true;
+
+ success = do_vs_prog(brw, prog, bvp, &key);
+
+ brw->vs.prog_offset = old_prog_offset;
+ brw->vs.prog_data = old_prog_data;
+
+ return success;
+}