#include <assert.h>
#include <string.h>
-#include "compiler/blob.h"
#include "compiler/nir/nir.h"
+#include "util/blob.h"
#include "util/build_id.h"
#include "util/disk_cache.h"
#include "util/mesa-sha1.h"
uint32_t prog_key_size,
cache_key cache_key)
{
- gl_shader_stage stage = ish->nir->info.stage;
-
/* Create a copy of the program key with program_string_id zeroed out.
* It's essentially random data which we don't want to include in our
* hashing and comparisons. We'll set a proper value on a cache hit.
*/
union brw_any_prog_key prog_key;
memcpy(&prog_key, orig_prog_key, prog_key_size);
- brw_prog_key_set_id(&prog_key, stage, 0);
+ prog_key.base.program_string_id = 0;
uint8_t data[sizeof(prog_key) + sizeof(ish->nir_sha1)];
uint32_t data_size = prog_key_size + sizeof(ish->nir_sha1);
* 3. Number of entries in the system value array
* 4. System value array
* 5. Legacy param array (only used for compute workgroup ID)
+ * 6. Binding table
*/
blob_write_bytes(&blob, shader->prog_data, brw_prog_data_size(stage));
blob_write_bytes(&blob, shader->map, shader->prog_data->program_size);
- blob_write_bytes(&blob, &shader->num_system_values, sizeof(unsigned));
+ blob_write_uint32(&blob, shader->num_system_values);
blob_write_bytes(&blob, shader->system_values,
shader->num_system_values * sizeof(enum brw_param_builtin));
+ blob_write_uint32(&blob, shader->kernel_input_size);
blob_write_bytes(&blob, prog_data->param,
prog_data->nr_params * sizeof(uint32_t));
+ blob_write_bytes(&blob, &shader->bt, sizeof(shader->bt));
disk_cache_put(cache, cache_key, blob.data, blob.size, NULL);
blob_finish(&blob);
#endif
}
+static const enum iris_program_cache_id cache_id_for_stage[] = {
+ [MESA_SHADER_VERTEX] = IRIS_CACHE_VS,
+ [MESA_SHADER_TESS_CTRL] = IRIS_CACHE_TCS,
+ [MESA_SHADER_TESS_EVAL] = IRIS_CACHE_TES,
+ [MESA_SHADER_GEOMETRY] = IRIS_CACHE_GS,
+ [MESA_SHADER_FRAGMENT] = IRIS_CACHE_FS,
+ [MESA_SHADER_COMPUTE] = IRIS_CACHE_CS,
+};
+
/**
* Search for a compiled shader in the disk cache. If found, upload it
* to the in-memory program cache so we can use it.
struct brw_stage_prog_data *prog_data = ralloc_size(NULL, prog_data_size);
const void *assembly;
uint32_t num_system_values;
+ uint32_t kernel_input_size;
uint32_t *system_values = NULL;
uint32_t *so_decls = NULL;
num_system_values * sizeof(enum brw_param_builtin));
}
+ kernel_input_size = blob_read_uint32(&blob);
+
prog_data->param = NULL;
prog_data->pull_param = NULL;
assert(prog_data->nr_pull_params == 0);
prog_data->nr_params * sizeof(uint32_t));
}
+ struct iris_binding_table bt;
+ blob_copy_bytes(&blob, &bt, sizeof(bt));
+
if (stage == MESA_SHADER_VERTEX ||
stage == MESA_SHADER_TESS_EVAL ||
stage == MESA_SHADER_GEOMETRY) {
struct brw_vue_prog_data *vue_prog_data = (void *) prog_data;
- so_decls = ice->vtbl.create_so_decl_list(&ish->stream_output,
+ so_decls = screen->vtbl.create_so_decl_list(&ish->stream_output,
&vue_prog_data->vue_map);
}
* needed, the constant buffer 0 will be needed, so account for it.
*/
unsigned num_cbufs = ish->nir->info.num_ubos;
- if (num_cbufs || num_system_values || ish->nir->num_uniforms)
+
+ if (num_cbufs || ish->nir->num_uniforms)
num_cbufs++;
+ if (num_system_values)
+ num_cbufs++;
+
+ assert(stage < ARRAY_SIZE(cache_id_for_stage));
+ enum iris_program_cache_id cache_id = cache_id_for_stage[stage];
+
/* Upload our newly read shader to the in-memory program cache and
* return it to the caller.
*/
- return iris_upload_shader(ice, stage, key_size, prog_key, assembly,
- prog_data, so_decls, system_values,
- num_system_values, num_cbufs);
+ struct iris_compiled_shader *shader =
+ iris_upload_shader(ice, cache_id, key_size, prog_key, assembly,
+ prog_data, so_decls, system_values,
+ num_system_values, kernel_input_size, num_cbufs, &bt);
+
+ free(buffer);
+
+ return shader;
#else
return NULL;
#endif