anv: anv: refactor error handling in anv_shader_bin_write_to_blob()
authorTapani Pälli <tapani.palli@intel.com>
Thu, 14 Feb 2019 08:12:49 +0000 (10:12 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Wed, 20 Feb 2019 13:39:19 +0000 (15:39 +0200)
v2: blob manages error state internally, just return
    true if errors did not occur (Jason)

CID: 1442546
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_pipeline_cache.c

index 911427b7bf811318a7459fc37881715adef22d99..5c6dc58f24d310e30ec294474f8b16a493a1737c 100644 (file)
@@ -127,44 +127,42 @@ static bool
 anv_shader_bin_write_to_blob(const struct anv_shader_bin *shader,
                              struct blob *blob)
 {
-   bool ok;
+   blob_write_uint32(blob, shader->key->size);
+   blob_write_bytes(blob, shader->key->data, shader->key->size);
 
-   ok = blob_write_uint32(blob, shader->key->size);
-   ok = blob_write_bytes(blob, shader->key->data, shader->key->size);
+   blob_write_uint32(blob, shader->kernel_size);
+   blob_write_bytes(blob, shader->kernel.map, shader->kernel_size);
 
-   ok = blob_write_uint32(blob, shader->kernel_size);
-   ok = blob_write_bytes(blob, shader->kernel.map, shader->kernel_size);
+   blob_write_uint32(blob, shader->constant_data_size);
+   blob_write_bytes(blob, shader->constant_data.map,
+                    shader->constant_data_size);
 
-   ok = blob_write_uint32(blob, shader->constant_data_size);
-   ok = blob_write_bytes(blob, shader->constant_data.map,
-                         shader->constant_data_size);
-
-   ok = blob_write_uint32(blob, shader->prog_data_size);
-   ok = blob_write_bytes(blob, shader->prog_data, shader->prog_data_size);
-   ok = blob_write_bytes(blob, shader->prog_data->param,
-                               shader->prog_data->nr_params *
-                               sizeof(*shader->prog_data->param));
+   blob_write_uint32(blob, shader->prog_data_size);
+   blob_write_bytes(blob, shader->prog_data, shader->prog_data_size);
+   blob_write_bytes(blob, shader->prog_data->param,
+                    shader->prog_data->nr_params *
+                    sizeof(*shader->prog_data->param));
 
    if (shader->xfb_info) {
       uint32_t xfb_info_size =
          nir_xfb_info_size(shader->xfb_info->output_count);
-      ok = blob_write_uint32(blob, xfb_info_size);
-      ok = blob_write_bytes(blob, shader->xfb_info, xfb_info_size);
+      blob_write_uint32(blob, xfb_info_size);
+      blob_write_bytes(blob, shader->xfb_info, xfb_info_size);
    } else {
-      ok = blob_write_uint32(blob, 0);
+      blob_write_uint32(blob, 0);
    }
 
-   ok = blob_write_uint32(blob, shader->bind_map.surface_count);
-   ok = blob_write_uint32(blob, shader->bind_map.sampler_count);
-   ok = blob_write_uint32(blob, shader->bind_map.image_count);
-   ok = blob_write_bytes(blob, shader->bind_map.surface_to_descriptor,
-                               shader->bind_map.surface_count *
-                               sizeof(*shader->bind_map.surface_to_descriptor));
-   ok = blob_write_bytes(blob, shader->bind_map.sampler_to_descriptor,
-                               shader->bind_map.sampler_count *
-                               sizeof(*shader->bind_map.sampler_to_descriptor));
-
-   return ok;
+   blob_write_uint32(blob, shader->bind_map.surface_count);
+   blob_write_uint32(blob, shader->bind_map.sampler_count);
+   blob_write_uint32(blob, shader->bind_map.image_count);
+   blob_write_bytes(blob, shader->bind_map.surface_to_descriptor,
+                    shader->bind_map.surface_count *
+                    sizeof(*shader->bind_map.surface_to_descriptor));
+   blob_write_bytes(blob, shader->bind_map.sampler_to_descriptor,
+                    shader->bind_map.sampler_count *
+                    sizeof(*shader->bind_map.sampler_to_descriptor));
+
+   return !blob->out_of_memory;
 }
 
 static struct anv_shader_bin *