vulkan/cmd_buffer: add record_state to the common command buffer.

This pulls the record state out of the cmd queue into the command
buffer. It can be used here by other drivers.

v2: add some get/set api: not set only sets the first error.

v3 (Jason Ekstrand):
 - Rename set_record_result to set_error
 - Automatically log the set error
 - Add a new vk_command_bufer_has_error() helper
 - Split out vk_cmd_queue changes into their own commit

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16918>
This commit is contained in:
Jason Ekstrand 2022-08-31 15:13:05 -05:00 committed by Marge Bot
parent 7d9df64b07
commit 541be28099
2 changed files with 29 additions and 0 deletions

View file

@ -39,6 +39,7 @@ vk_command_buffer_init(struct vk_command_buffer *command_buffer,
command_buffer->pool = pool;
command_buffer->level = level;
vk_dynamic_graphics_state_init(&command_buffer->dynamic_graphics_state);
command_buffer->record_result = VK_SUCCESS;
vk_cmd_queue_init(&command_buffer->cmd_queue, &pool->alloc);
util_dynarray_init(&command_buffer->labels, NULL);
command_buffer->region_begin = true;
@ -52,6 +53,7 @@ void
vk_command_buffer_reset(struct vk_command_buffer *command_buffer)
{
vk_dynamic_graphics_state_clear(&command_buffer->dynamic_graphics_state);
command_buffer->record_result = VK_SUCCESS;
vk_command_buffer_reset_render_pass(command_buffer);
vk_cmd_queue_reset(&command_buffer->cmd_queue);
util_dynarray_clear(&command_buffer->labels);

View file

@ -26,6 +26,7 @@
#include "vk_cmd_queue.h"
#include "vk_graphics_state.h"
#include "vk_log.h"
#include "vk_object.h"
#include "util/list.h"
#include "util/u_dynarray.h"
@ -68,6 +69,9 @@ struct vk_command_buffer {
struct vk_dynamic_graphics_state dynamic_graphics_state;
/** Command buffer recording error state. */
VkResult record_result;
/** Link in vk_command_pool::command_buffers if pool != NULL */
struct list_head pool_link;
@ -150,6 +154,29 @@ vk_command_buffer_reset(struct vk_command_buffer *command_buffer);
void
vk_command_buffer_finish(struct vk_command_buffer *command_buffer);
static inline VkResult
__vk_command_buffer_set_error(struct vk_command_buffer *command_buffer,
VkResult error, const char *file, int line)
{
assert(error != VK_SUCCESS);
error = __vk_errorf(command_buffer, error, file, line, NULL);
if (command_buffer->record_result == VK_SUCCESS)
command_buffer->record_result = error;
return error;
}
#define vk_command_buffer_set_error(command_buffer, error) \
__vk_command_buffer_set_error(command_buffer, error, __FILE__, __LINE__)
static inline VkResult
vk_command_buffer_get_record_result(struct vk_command_buffer *command_buffer)
{
return command_buffer->record_result;
}
#define vk_command_buffer_has_error(command_buffer) \
unlikely((command_buffer)->record_result != VK_SUCCESS)
#ifdef __cplusplus
}
#endif