panfrost: Ensure we upload at least 1 blend RT
[mesa.git] / src / gallium / drivers / iris / iris_disk_cache.c
index 2b022aff66a432afad528562a68ea752768a071c..325903c9861db1635a0795d72dde2cd27d4d8fdc 100644 (file)
@@ -51,26 +51,21 @@ iris_disk_cache_compute_key(struct disk_cache *cache,
                             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;
 
-   uint32_t data_size = prog_key_size + ish->ir_cache_binary_size;
+   uint8_t data[sizeof(prog_key) + sizeof(ish->nir_sha1)];
+   uint32_t data_size = prog_key_size + sizeof(ish->nir_sha1);
 
-   void *data = malloc(data_size);
-   memcpy(data, &prog_key, prog_key_size);
-   memcpy(data + prog_key_size, ish->ir_cache_binary,
-          ish->ir_cache_binary_size);
+   memcpy(data, ish->nir_sha1, sizeof(ish->nir_sha1));
+   memcpy(data + sizeof(ish->nir_sha1), &prog_key, prog_key_size);
 
    disk_cache_compute_key(cache, data, data_size, cache_key);
-
-   free(data);
 }
 
 /**
@@ -112,6 +107,7 @@ iris_disk_cache_store(struct disk_cache *cache,
     * 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);
@@ -120,6 +116,7 @@ iris_disk_cache_store(struct disk_cache *cache,
                     shader->num_system_values * sizeof(enum brw_param_builtin));
    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);
@@ -192,6 +189,9 @@ iris_disk_cache_retrieve(struct iris_context *ice,
                       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) {
@@ -205,15 +205,24 @@ iris_disk_cache_retrieve(struct iris_context *ice,
     * 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++;
 
    /* 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, stage, key_size, prog_key, assembly,
+                         prog_data, so_decls, system_values,
+                         num_system_values, num_cbufs, &bt);
+
+   free(buffer);
+
+   return shader;
 #else
    return NULL;
 #endif