summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2017-03-09 11:49:01 +0100
committerIago Toral Quiroga <[email protected]>2017-03-16 11:40:05 +0100
commitbe52f9693acb6055f62548e838348c584bbd08d7 (patch)
tree88f9d3cd3bd1039d52b137435a5e7f9d2a6264b7
parenta578b06d7bd6d1bb075bc9b8b04af97118bee18f (diff)
anv/blorp: make anv_cmd_buffer_alloc_blorp_binding_table() return a VkResult
Instead of asserting inside the function, and then use use that information to return early from its callers upon failure. v2: - Make sure that clear_color_attachment() and clear_depth_stencil_attachment() get the VkResult as well so they avoid executing the batch if an error happened. (Topi) Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r--src/intel/vulkan/anv_blorp.c59
-rw-r--r--src/intel/vulkan/anv_private.h5
-rw-r--r--src/intel/vulkan/genX_blorp_exec.c8
3 files changed, 46 insertions, 26 deletions
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 4342a0b51d8..1f4fec5f35b 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -912,45 +912,52 @@ void anv_CmdClearDepthStencilImage(
blorp_batch_finish(&batch);
}
-struct anv_state
+VkResult
anv_cmd_buffer_alloc_blorp_binding_table(struct anv_cmd_buffer *cmd_buffer,
uint32_t num_entries,
- uint32_t *state_offset)
+ uint32_t *state_offset,
+ struct anv_state *bt_state)
{
- struct anv_state bt_state =
- anv_cmd_buffer_alloc_binding_table(cmd_buffer, num_entries,
- state_offset);
- if (bt_state.map == NULL) {
+ *bt_state = anv_cmd_buffer_alloc_binding_table(cmd_buffer, num_entries,
+ state_offset);
+ if (bt_state->map == NULL) {
/* We ran out of space. Grab a new binding table block. */
- MAYBE_UNUSED VkResult result =
- anv_cmd_buffer_new_binding_table_block(cmd_buffer);
- assert(result == VK_SUCCESS);
+ VkResult result = anv_cmd_buffer_new_binding_table_block(cmd_buffer);
+ if (result != VK_SUCCESS)
+ return result;
/* Re-emit state base addresses so we get the new surface state base
* address before we start emitting binding tables etc.
*/
anv_cmd_buffer_emit_state_base_address(cmd_buffer);
- bt_state = anv_cmd_buffer_alloc_binding_table(cmd_buffer, num_entries,
- state_offset);
- assert(bt_state.map != NULL);
+ *bt_state = anv_cmd_buffer_alloc_binding_table(cmd_buffer, num_entries,
+ state_offset);
+ assert(bt_state->map != NULL);
}
- return bt_state;
+ return VK_SUCCESS;
}
-static uint32_t
+static VkResult
binding_table_for_surface_state(struct anv_cmd_buffer *cmd_buffer,
- struct anv_state surface_state)
+ struct anv_state surface_state,
+ uint32_t *bt_offset)
{
uint32_t state_offset;
- struct anv_state bt_state =
- anv_cmd_buffer_alloc_blorp_binding_table(cmd_buffer, 1, &state_offset);
+ struct anv_state bt_state;
+
+ VkResult result =
+ anv_cmd_buffer_alloc_blorp_binding_table(cmd_buffer, 1, &state_offset,
+ &bt_state);
+ if (result != VK_SUCCESS)
+ return result;
uint32_t *bt_map = bt_state.map;
bt_map[0] = surface_state.offset + state_offset;
- return bt_state.offset;
+ *bt_offset = bt_state.offset;
+ return VK_SUCCESS;
}
static void
@@ -971,8 +978,12 @@ clear_color_attachment(struct anv_cmd_buffer *cmd_buffer,
struct anv_attachment_state *att_state =
&cmd_buffer->state.attachments[att_idx];
- uint32_t binding_table =
- binding_table_for_surface_state(cmd_buffer, att_state->color_rt_state);
+ uint32_t binding_table;
+ VkResult result =
+ binding_table_for_surface_state(cmd_buffer, att_state->color_rt_state,
+ &binding_table);
+ if (result != VK_SUCCESS)
+ return;
union isl_color_value clear_color =
vk_to_isl_color(attachment->clearValue.color);
@@ -1017,9 +1028,13 @@ clear_depth_stencil_attachment(struct anv_cmd_buffer *cmd_buffer,
VK_IMAGE_TILING_OPTIMAL);
}
- uint32_t binding_table =
+ uint32_t binding_table;
+ VkResult result =
binding_table_for_surface_state(cmd_buffer,
- cmd_buffer->state.null_surface_state);
+ cmd_buffer->state.null_surface_state,
+ &binding_table);
+ if (result != VK_SUCCESS)
+ return;
for (uint32_t r = 0; r < rectCount; ++r) {
const VkOffset2D offset = pRects[r].rect.offset;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index a2da04169be..c92741c78da 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1476,10 +1476,11 @@ void anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer);
const struct anv_image_view *
anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer);
-struct anv_state
+VkResult
anv_cmd_buffer_alloc_blorp_binding_table(struct anv_cmd_buffer *cmd_buffer,
uint32_t num_entries,
- uint32_t *state_offset);
+ uint32_t *state_offset,
+ struct anv_state *bt_state);
void anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer);
diff --git a/src/intel/vulkan/genX_blorp_exec.c b/src/intel/vulkan/genX_blorp_exec.c
index ba834d4c55f..86730e07def 100644
--- a/src/intel/vulkan/genX_blorp_exec.c
+++ b/src/intel/vulkan/genX_blorp_exec.c
@@ -89,9 +89,13 @@ blorp_alloc_binding_table(struct blorp_batch *batch, unsigned num_entries,
struct anv_cmd_buffer *cmd_buffer = batch->driver_batch;
uint32_t state_offset;
- struct anv_state bt_state =
+ struct anv_state bt_state;
+
+ VkResult result =
anv_cmd_buffer_alloc_blorp_binding_table(cmd_buffer, num_entries,
- &state_offset);
+ &state_offset, &bt_state);
+ if (result != VK_SUCCESS)
+ return;
uint32_t *bt_map = bt_state.map;
*bt_offset = bt_state.offset;