nvk,nvkmd: Move push dumping to NVKMD
Reviewed-by: Mel Henning <mhenning@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36995>
This commit is contained in:
committed by
Marge Bot
parent
7a50d7004b
commit
38108b2c4b
@@ -1198,47 +1198,6 @@ nvk_cmd_buffer_get_cbuf_descriptor_addr(struct nvk_cmd_buffer *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvk_cmd_buffer_dump(struct nvk_cmd_buffer *cmd, FILE *fp)
|
||||
{
|
||||
struct nvk_device *dev = nvk_cmd_buffer_device(cmd);
|
||||
const struct nvk_physical_device *pdev = nvk_device_physical(dev);
|
||||
|
||||
util_dynarray_foreach(&cmd->pushes, struct nvk_cmd_push, p) {
|
||||
if (p->map) {
|
||||
struct nv_push push = {
|
||||
.start = (uint32_t *)p->map,
|
||||
.end = (uint32_t *)((char *)p->map + p->range),
|
||||
};
|
||||
vk_push_print(fp, &push, &pdev->info);
|
||||
} else {
|
||||
const uint64_t addr = p->addr;
|
||||
fprintf(fp, "<%u B of INDIRECT DATA at 0x%" PRIx64 ">\n",
|
||||
p->range, addr);
|
||||
|
||||
uint64_t mem_offset = 0;
|
||||
struct nvkmd_mem *mem =
|
||||
nvkmd_dev_lookup_mem_by_va(dev->nvkmd, addr, &mem_offset);
|
||||
if (mem != NULL) {
|
||||
void *map;
|
||||
VkResult map_result = nvkmd_mem_map(mem, &dev->vk.base,
|
||||
NVKMD_MEM_MAP_RD, NULL,
|
||||
&map);
|
||||
if (map_result == VK_SUCCESS) {
|
||||
struct nv_push push = {
|
||||
.start = mem->map + mem_offset,
|
||||
.end = mem->map + mem_offset + p->range,
|
||||
};
|
||||
vk_push_print(fp, &push, &pdev->info);
|
||||
nvkmd_mem_unmap(mem, 0);
|
||||
}
|
||||
|
||||
nvkmd_mem_unref(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
nvk_CmdPushDescriptorSetWithTemplate2KHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
|
||||
@@ -391,8 +391,6 @@ void nvk_cmd_dispatch_shader(struct nvk_cmd_buffer *cmd,
|
||||
void nvk_meta_resolve_rendering(struct nvk_cmd_buffer *cmd,
|
||||
const VkRenderingInfo *pRenderingInfo);
|
||||
|
||||
void nvk_cmd_buffer_dump(struct nvk_cmd_buffer *cmd, FILE *fp);
|
||||
|
||||
void nvk_linear_render_copy(struct nvk_cmd_buffer *cmd,
|
||||
const struct nvk_image_view *iview,
|
||||
VkRect2D copy_rect,
|
||||
|
||||
@@ -210,11 +210,8 @@ nvk_queue_submit_exec(struct nvk_queue *queue,
|
||||
struct vk_queue_submit *submit)
|
||||
{
|
||||
struct nvk_device *dev = nvk_queue_device(queue);
|
||||
const struct nvk_physical_device *pdev = nvk_device_physical(dev);
|
||||
VkResult result;
|
||||
|
||||
const bool sync = pdev->debug_flags & NVK_DEBUG_PUSH_SYNC;
|
||||
|
||||
if (submit->command_buffer_count > 0) {
|
||||
result = nvk_queue_state_update(queue, &queue->state);
|
||||
if (result != VK_SUCCESS)
|
||||
@@ -277,23 +274,7 @@ nvk_queue_submit_exec(struct nvk_queue *queue,
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
if (sync) {
|
||||
result = nvkmd_ctx_sync(queue->exec_ctx, &queue->vk.base);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
if ((sync && result != VK_SUCCESS) ||
|
||||
(pdev->debug_flags & NVK_DEBUG_PUSH_DUMP)) {
|
||||
for (unsigned i = 0; i < submit->command_buffer_count; i++) {
|
||||
struct nvk_cmd_buffer *cmd =
|
||||
container_of(submit->command_buffers[i], struct nvk_cmd_buffer, vk);
|
||||
|
||||
nvk_cmd_buffer_dump(cmd, stderr);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -327,8 +308,6 @@ static VkResult
|
||||
nvk_queue_push(struct nvk_queue *queue, const struct nv_push *push)
|
||||
{
|
||||
struct nvk_device *dev = nvk_queue_device(queue);
|
||||
const struct nvk_physical_device *pdev = nvk_device_physical(dev);
|
||||
VkResult result;
|
||||
|
||||
if (vk_queue_is_lost(&queue->vk))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
@@ -336,18 +315,8 @@ nvk_queue_push(struct nvk_queue *queue, const struct nv_push *push)
|
||||
if (nv_push_dw_count(push) == 0)
|
||||
return VK_SUCCESS;
|
||||
|
||||
const bool sync = pdev->debug_flags & NVK_DEBUG_PUSH_SYNC;
|
||||
|
||||
result = nvk_mem_stream_push(dev, &queue->push_stream, queue->exec_ctx,
|
||||
push->start, nv_push_dw_count(push), NULL);
|
||||
if (result == VK_SUCCESS && sync)
|
||||
result = nvkmd_ctx_sync(queue->exec_ctx, &queue->vk.base);
|
||||
|
||||
if ((sync && result != VK_SUCCESS) ||
|
||||
(pdev->debug_flags & NVK_DEBUG_PUSH_DUMP))
|
||||
vk_push_print(stderr, push, &pdev->info);
|
||||
|
||||
return result;
|
||||
return nvk_mem_stream_push(dev, &queue->push_stream, queue->exec_ctx,
|
||||
push->start, nv_push_dw_count(push), NULL);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "nvkmd.h"
|
||||
#include "nouveau/nvkmd_nouveau.h"
|
||||
#include "nv_push.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@@ -257,6 +258,68 @@ nvkmd_va_unbind(struct nvkmd_va *va,
|
||||
return va->ops->unbind(va, log_obj, va_offset_B, range_B);
|
||||
}
|
||||
|
||||
static void
|
||||
nvkmd_ctx_exec_dump(struct nvkmd_dev *dev, struct vk_object_base *log_obj,
|
||||
FILE *fp, const struct nvkmd_ctx_exec *exec)
|
||||
{
|
||||
uint64_t mem_offset_B = 0;
|
||||
struct nvkmd_mem *mem =
|
||||
nvkmd_dev_lookup_mem_by_va(dev, exec->addr, &mem_offset_B);
|
||||
if (mem == NULL) {
|
||||
fprintf(fp, "<%u B of DATA at UNKNOWN ADDRESS 0x%" PRIx64 ">\n",
|
||||
exec->size_B, exec->addr);
|
||||
return;
|
||||
}
|
||||
|
||||
void *map;
|
||||
VkResult map_result = nvkmd_mem_map(mem, log_obj,
|
||||
NVKMD_MEM_MAP_RD, NULL, &map);
|
||||
if (map_result != VK_SUCCESS) {
|
||||
fprintf(fp, "<%u B of DATA at UNMAPPABLE ADDRESS 0x%" PRIx64 ">\n",
|
||||
exec->size_B, exec->addr);
|
||||
goto fail_lookup;
|
||||
}
|
||||
|
||||
assert(mem_offset_B < mem->size_B);
|
||||
uint32_t dump_size_B = MIN2(exec->size_B, mem->size_B - mem_offset_B);
|
||||
|
||||
struct nv_push push = {
|
||||
.start = mem->map + mem_offset_B,
|
||||
.end = mem->map + mem_offset_B + dump_size_B,
|
||||
};
|
||||
vk_push_print(fp, &push, &dev->pdev->dev_info);
|
||||
|
||||
if (dump_size_B < exec->size_B) {
|
||||
fprintf(fp, "<%u B of DATA at UNKNOWN ADDRESS 0x%" PRIx64 ">\n",
|
||||
exec->size_B - dump_size_B, exec->addr + dump_size_B);
|
||||
}
|
||||
|
||||
nvkmd_mem_unmap(mem, 0);
|
||||
fail_lookup:
|
||||
nvkmd_mem_unref(mem);
|
||||
}
|
||||
|
||||
VkResult MUST_CHECK
|
||||
nvkmd_ctx_exec(struct nvkmd_ctx *ctx,
|
||||
struct vk_object_base *log_obj,
|
||||
uint32_t exec_count,
|
||||
const struct nvkmd_ctx_exec *execs)
|
||||
{
|
||||
const bool sync = ctx->dev->pdev->debug_flags & NVK_DEBUG_PUSH_SYNC;
|
||||
|
||||
VkResult result = ctx->ops->exec(ctx, log_obj, exec_count, execs);
|
||||
if (result == VK_SUCCESS && sync)
|
||||
result = ctx->ops->sync(ctx, log_obj);
|
||||
|
||||
if ((sync && result != VK_SUCCESS) ||
|
||||
(ctx->dev->pdev->debug_flags & NVK_DEBUG_PUSH_DUMP)) {
|
||||
for (uint32_t i = 0; i < exec_count; i++)
|
||||
nvkmd_ctx_exec_dump(ctx->dev, log_obj, stderr, &execs[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VkResult MUST_CHECK
|
||||
nvkmd_ctx_bind(struct nvkmd_ctx *ctx,
|
||||
struct vk_object_base *log_obj,
|
||||
|
||||
@@ -546,14 +546,11 @@ nvkmd_ctx_wait(struct nvkmd_ctx *ctx,
|
||||
return ctx->ops->wait(ctx, log_obj, wait_count, waits);
|
||||
}
|
||||
|
||||
static inline VkResult MUST_CHECK
|
||||
VkResult MUST_CHECK
|
||||
nvkmd_ctx_exec(struct nvkmd_ctx *ctx,
|
||||
struct vk_object_base *log_obj,
|
||||
uint32_t exec_count,
|
||||
const struct nvkmd_ctx_exec *execs)
|
||||
{
|
||||
return ctx->ops->exec(ctx, log_obj, exec_count, execs);
|
||||
}
|
||||
const struct nvkmd_ctx_exec *execs);
|
||||
|
||||
VkResult MUST_CHECK
|
||||
nvkmd_ctx_bind(struct nvkmd_ctx *ctx,
|
||||
|
||||
Reference in New Issue
Block a user