From 886cee1f96b41b786f9699d57d0048151b3f8c8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Thu, 14 Feb 2019 10:12:49 +0200 Subject: [PATCH] anv: anv: refactor error handling in anv_shader_bin_write_to_blob() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v2: blob manages error state internally, just return true if errors did not occur (Jason) CID: 1442546 Signed-off-by: Tapani Pälli Reviewed-by: Eric Engestrom Reviewed-by: Jason Ekstrand --- src/intel/vulkan/anv_pipeline_cache.c | 54 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/intel/vulkan/anv_pipeline_cache.c b/src/intel/vulkan/anv_pipeline_cache.c index 911427b..5c6dc58 100644 --- a/src/intel/vulkan/anv_pipeline_cache.c +++ b/src/intel/vulkan/anv_pipeline_cache.c @@ -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 * -- 2.7.4