}
-static void
+void
brw_cs_populate_key(struct brw_context *brw, struct brw_cs_prog_key *key)
{
struct gl_context *ctx = &brw->ctx;
brw_cs_populate_key(brw, &key);
- if (!brw_search_cache(&brw->cache, BRW_CACHE_CS_PROG,
- &key, sizeof(key),
- &brw->cs.base.prog_offset,
- &brw->cs.base.prog_data)) {
- bool success = brw_codegen_cs_prog(brw, cp, &key);
- (void) success;
- assert(success);
- }
+ if (brw_search_cache(&brw->cache, BRW_CACHE_CS_PROG,
+ &key, sizeof(key),
+ &brw->cs.base.prog_offset,
+ &brw->cs.base.prog_data))
+ return;
+
+ if (brw_disk_cache_upload_program(brw, MESA_SHADER_COMPUTE))
+ return;
+
+ cp = (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
+ cp->id = key.program_string_id;
+
+ MAYBE_UNUSED bool success = brw_codegen_cs_prog(brw, cp, &key);
+ assert(success);
}
#include "brw_context.h"
#include "brw_program.h"
+#include "brw_cs.h"
#include "brw_gs.h"
#include "brw_state.h"
#include "brw_vs.h"
brw_wm_populate_key(brw, &prog_key.wm);
prog_key.wm.program_string_id = 0;
break;
+ case MESA_SHADER_COMPUTE:
+ brw_cs_populate_key(brw, &prog_key.cs);
+ prog_key.cs.program_string_id = 0;
+ break;
default:
unreachable("Unsupported stage!");
}
cache_id = BRW_CACHE_FS_PROG;
stage_state = &brw->wm.base;
break;
+ case MESA_SHADER_COMPUTE:
+ prog_key.cs.program_string_id = brw_program(prog)->id;
+ cache_id = BRW_CACHE_CS_PROG;
+ stage_state = &brw->cs.base;
+ break;
default:
unreachable("Unsupported stage!");
}
}
void
-brw_disk_cache_write_program(struct brw_context *brw)
+brw_disk_cache_write_render_programs(struct brw_context *brw)
{
struct disk_cache *cache = brw->ctx.Cache;
if (cache == NULL)
MESA_SHADER_FRAGMENT);
}
}
+
+void
+brw_disk_cache_write_compute_program(struct brw_context *brw)
+{
+ struct disk_cache *cache = brw->ctx.Cache;
+ if (cache == NULL)
+ return;
+
+ struct gl_program *prog =
+ brw->ctx._Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (prog && !prog->program_written_to_cache) {
+ struct brw_cs_prog_key cs_key;
+ brw_cs_populate_key(brw, &cs_key);
+ cs_key.program_string_id = 0;
+
+ write_program_data(brw, prog, &cs_key, brw->cs.base.prog_data,
+ brw->cs.base.prog_offset, cache,
+ MESA_SHADER_COMPUTE);
+ }
+}
/* brw_disk_cache.c */
bool brw_disk_cache_upload_program(struct brw_context *brw,
gl_shader_stage stage);
-void brw_disk_cache_write_program(struct brw_context *brw);
+void brw_disk_cache_write_compute_program(struct brw_context *brw);
+void brw_disk_cache_write_render_programs(struct brw_context *brw);
/***********************************************************************
* brw_state.c