nvk: Return VkResult from nvk_cmd_buffer_upload_alloc
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
committed by
Marge Bot
parent
903c000055
commit
9bc97bc208
@@ -151,8 +151,8 @@ nvk_cmd_buffer_resize_upload_buf(struct nvk_cmd_buffer *cmd,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd, unsigned size,
|
||||
VkResult
|
||||
nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd, uint32_t size,
|
||||
uint64_t *addr, void **ptr)
|
||||
{
|
||||
assert(size % 4 == 0);
|
||||
@@ -160,15 +160,15 @@ nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd, unsigned size,
|
||||
/* Align to the scalar cache line size if it results in this allocation
|
||||
* being placed in less of them.
|
||||
*/
|
||||
unsigned offset = cmd->upload.offset;
|
||||
unsigned line_size = 256;//for compute dispatches
|
||||
unsigned gap = align(offset, line_size) - offset;
|
||||
uint32_t offset = cmd->upload.offset;
|
||||
uint32_t line_size = 256;//for compute dispatches
|
||||
uint32_t gap = align(offset, line_size) - offset;
|
||||
if ((size & ~(line_size - 1)) > gap)
|
||||
offset = align(offset, line_size);
|
||||
|
||||
if (offset + size > cmd->upload.size) {
|
||||
if (!nvk_cmd_buffer_resize_upload_buf(cmd, size))
|
||||
return false;
|
||||
return vk_error(cmd, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,8 @@ nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd, unsigned size,
|
||||
*ptr = cmd->upload.map + offset;
|
||||
|
||||
cmd->upload.offset = offset + size;
|
||||
return true;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
|
||||
@@ -143,8 +143,8 @@ nvk_get_descriptors_state(struct nvk_cmd_buffer *cmd,
|
||||
}
|
||||
};
|
||||
|
||||
bool
|
||||
nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd_buffer, unsigned size,
|
||||
uint64_t *addr, void **ptr);
|
||||
VkResult nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd,
|
||||
uint32_t size,
|
||||
uint64_t *addr, void **ptr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,6 +67,7 @@ nvk_CmdDispatch(VkCommandBuffer commandBuffer,
|
||||
const struct nvk_shader *shader =
|
||||
&pipeline->base.shaders[MESA_SHADER_COMPUTE];
|
||||
struct nvk_descriptor_state *desc = &cmd->state.cs.descriptors;
|
||||
VkResult result;
|
||||
|
||||
desc->root.cs.block_size[0] = shader->cp.block_size[0];
|
||||
desc->root.cs.block_size[1] = shader->cp.block_size[1];
|
||||
@@ -78,9 +79,12 @@ nvk_CmdDispatch(VkCommandBuffer commandBuffer,
|
||||
uint32_t root_table_size = sizeof(desc->root);
|
||||
void *root_table_map;
|
||||
uint64_t root_table_addr;
|
||||
if (!nvk_cmd_buffer_upload_alloc(cmd, root_table_size, &root_table_addr,
|
||||
&root_table_map))
|
||||
return; /* TODO: Error */
|
||||
result = nvk_cmd_buffer_upload_alloc(cmd, root_table_size,
|
||||
&root_table_addr, &root_table_map);
|
||||
if (unlikely(result != VK_SUCCESS)) {
|
||||
vk_command_buffer_set_error(&cmd->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
struct nv_push *p = P_SPACE(cmd->push, 14 + root_table_size / 4);
|
||||
|
||||
@@ -100,8 +104,11 @@ nvk_CmdDispatch(VkCommandBuffer commandBuffer,
|
||||
|
||||
uint32_t *qmd;
|
||||
uint64_t qmd_addr;
|
||||
if (!nvk_cmd_buffer_upload_alloc(cmd, 512, &qmd_addr, (void **)&qmd))
|
||||
return; /* TODO: Error */
|
||||
result = nvk_cmd_buffer_upload_alloc(cmd, 512, &qmd_addr, (void **)&qmd);
|
||||
if (unlikely(result != VK_SUCCESS)) {
|
||||
vk_command_buffer_set_error(&cmd->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(qmd, pipeline->qmd_template, 256);
|
||||
gv100_compute_setup_launch_desc(qmd, groupCountX, groupCountY, groupCountZ);
|
||||
|
||||
@@ -1035,13 +1035,17 @@ static void
|
||||
nvk_flush_descriptors(struct nvk_cmd_buffer *cmd)
|
||||
{
|
||||
const struct nvk_descriptor_state *desc = &cmd->state.gfx.descriptors;
|
||||
VkResult result;
|
||||
|
||||
uint32_t root_table_size = sizeof(desc->root);
|
||||
void *root_table_map;
|
||||
uint64_t root_table_addr;
|
||||
if (!nvk_cmd_buffer_upload_alloc(cmd, root_table_size, &root_table_addr,
|
||||
&root_table_map))
|
||||
return; /* TODO: Error */
|
||||
result = nvk_cmd_buffer_upload_alloc(cmd, root_table_size,
|
||||
&root_table_addr, &root_table_map);
|
||||
if (unlikely(result != VK_SUCCESS)) {
|
||||
vk_command_buffer_set_error(&cmd->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(root_table_map, &desc->root, sizeof(desc->root));
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ nvk_cmd_bind_map_buffer(struct vk_command_buffer *vk_cmd,
|
||||
struct nvk_cmd_buffer *cmd =
|
||||
container_of(vk_cmd, struct nvk_cmd_buffer, vk);
|
||||
VK_FROM_HANDLE(nvk_buffer, buffer, _buffer);
|
||||
VkResult result;
|
||||
|
||||
uint64_t addr;
|
||||
assert(buffer->vk.size < UINT_MAX);
|
||||
if (!nvk_cmd_buffer_upload_alloc(cmd, buffer->vk.size, &addr, map_out))
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
result = nvk_cmd_buffer_upload_alloc(cmd, buffer->vk.size, &addr, map_out);
|
||||
if (unlikely(result != VK_SUCCESS))
|
||||
return result;
|
||||
|
||||
buffer->addr = addr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user