* These must be the last fields of the struct (see
* brw_wm_prog_data_compare()).
*/
- const float *param[MAX_UNIFORMS * 4]; /* should be: BRW_MAX_CURBE */
- const float *pull_param[MAX_UNIFORMS * 4];
+ const float **param;
+ const float **pull_param;
};
/**
typedef bool (*cache_aux_compare_func)(const void *a, const void *b,
int aux_size, const void *key);
+typedef void (*cache_aux_free_func)(const void *aux);
struct brw_cache {
struct brw_context *brw;
* outside of the prog_data). If NULL, a plain memcmp is done.
*/
cache_aux_compare_func aux_compare[BRW_MAX_CACHE];
+ /** Optional functions for freeing other pointers attached to a prog_data. */
+ cache_aux_free_func aux_free[BRW_MAX_CACHE];
};
cache->aux_compare[BRW_VS_PROG] = brw_vs_prog_data_compare;
cache->aux_compare[BRW_WM_PROG] = brw_wm_prog_data_compare;
+ cache->aux_free[BRW_WM_PROG] = brw_wm_prog_data_free;
}
static void
for (i = 0; i < cache->size; i++) {
for (c = cache->items[i]; c; c = next) {
next = c->next;
+ if (cache->aux_free[c->cache_id]) {
+ const void *item_aux = c->key + c->key_size;
+ cache->aux_free[c->cache_id](item_aux);
+ }
free((void *)c->key);
free(c);
}
return true;
}
+void
+brw_wm_prog_data_free(const void *in_prog_data)
+{
+ const struct brw_wm_prog_data *prog_data = in_prog_data;
+
+ ralloc_free((void *)prog_data->param);
+ ralloc_free((void *)prog_data->pull_param);
+}
+
/**
* All Mesa program -> GPU code generation goes through this function.
* Depending on the instructions used (i.e. flow control instructions)
struct intel_context *intel = &brw->intel;
struct brw_wm_compile *c;
const GLuint *program;
+ struct gl_shader *fs = NULL;
GLuint program_size;
+ if (prog)
+ fs = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
+
c = brw->wm.compile_data;
if (c == NULL) {
brw->wm.compile_data = rzalloc(NULL, struct brw_wm_compile);
c->vreg = vreg;
c->refs = refs;
}
+
+ /* Allocate the references to the uniforms that will end up in the
+ * prog_data associated with the compiled program, and which will be freed
+ * by the state cache.
+ */
+ if (fs) {
+ int param_count = fs->num_uniform_components;
+ /* The backend also sometimes adds params for texture size. */
+ param_count += 2 * BRW_MAX_TEX_UNIT;
+
+ c->prog_data.param = rzalloc_array(c, const float *, param_count);
+ c->prog_data.pull_param = rzalloc_array(c, const float *, param_count);
+ } else {
+ /* brw_wm_pass0.c will also add references to 0.0 and 1.0 which are
+ * uploaded as push parameters.
+ */
+ int param_count = (fp->program.Base.Parameters->NumParameters + 2) * 4;
+ c->prog_data.param = rzalloc_array(c, const float *, param_count);
+ /* The old backend never does pull constants. */
+ c->prog_data.pull_param = NULL;
+ }
+
memcpy(&c->key, key, sizeof(*key));
c->fp = fp;