[Mesa-dev] [PATCH 51/65] i965: add cache fallback support
Timothy Arceri
timothy.arceri at collabora.com
Fri Apr 29 13:33:50 UTC 2016
---
src/mesa/drivers/dri/i965/brw_shader_cache.c | 43 ++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index d1336d7..625ad3f 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -28,7 +28,10 @@
#include <compiler/glsl/ir_uniform.h>
#include <compiler/glsl/cache.h>
#include <compiler/glsl/blob.h>
+#include <compiler/glsl/program.h>
#include <compiler/nir_types.h>
+#include <program/ir_to_mesa.h>
+#include <program/program.h>
#include "brw_state.h"
#include "brw_wm.h"
@@ -333,9 +336,45 @@ upload_cached_program(struct brw_context *brw)
return;
FAIL:
- /* Fall back and compile from source here. */
prog->program_written_to_cache = false;
- printf("FIXME: May need to fallback to compile from source here...\n");
+ printf("Falling back to compile from source.\n");
+
+ /* Cached program not found. Fall back to linking shaders but first
+ * compile any shaders we didn't compile earlier.
+ */
+ if (brw->vertex_program->Base.nir == NULL) {
+ struct gl_shader_program *prog =
+ brw->ctx._Shader->CurrentProgram[MESA_SHADER_VERTEX];
+ for (unsigned i = 0; i < prog->NumShaders; i++) {
+ _mesa_glsl_compile_shader(&brw->ctx, prog->Shaders[i], false, false,
+ true);
+ }
+ _mesa_glsl_link_shader(&brw->ctx, prog, true);
+
+ struct gl_program *vp =
+ prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+ brw->vertex_program = gl_vertex_program(vp);
+
+ struct gl_program *fp =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+ brw->fragment_program = gl_fragment_program(fp);
+ }
+
+ if (brw->fragment_program->Base.nir == NULL) {
+ struct gl_shader_program *prog =
+ brw->ctx._Shader->_CurrentFragmentProgram;
+
+ for (unsigned i = 0; i < prog->NumShaders; i++) {
+ _mesa_glsl_compile_shader(&brw->ctx, prog->Shaders[i], false, false,
+ true);
+ }
+ _mesa_glsl_link_shader(&brw->ctx, prog, true);
+
+ struct gl_program *fp =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+ brw->fragment_program = gl_fragment_program(fp);
+ }
+
free(buffer);
}
--
2.5.5
More information about the mesa-dev
mailing list