From: Jason Ekstrand Date: Thu, 21 May 2015 22:55:27 +0000 (-0700) Subject: vk: Do relocations in surface states when they are created X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=519fe765e21e43b650ebf2acc9e28725e528a0de;p=mesa.git vk: Do relocations in surface states when they are created Previously, we waited until later and did a pass through the used surfaces and did the relocations then. This lead to doing double-relocations which was causing us to get bogus surface offsets. --- diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 745e5dd7090..3381729680a 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -2466,9 +2466,13 @@ void anv_CmdBindDescriptorSets( anv_cmd_buffer_alloc_surface_state(cmd_buffer, 64, 64); memcpy(state.map, view->surface_state.map, 64); + /* The address goes in dwords 8 and 9 of the SURFACE_STATE */ + *(uint64_t *)(state.map + 8 * 4) = + anv_reloc_list_add(&cmd_buffer->surface_relocs, + state.offset + 8 * 4, + view->bo, view->offset); + bindings->descriptors[s].surfaces[start + b] = state.offset; - bindings->descriptors[s].relocs[start + b].bo = view->bo; - bindings->descriptors[s].relocs[start + b].offset = view->offset; } start = layout->set[firstSet + i].sampler_start[s]; @@ -2553,34 +2557,12 @@ flush_descriptor_sets(struct anv_cmd_buffer *cmd_buffer) if (layers + surface_count > 0) { struct anv_state state; - uint32_t offset; - uint32_t *address; uint32_t size; size = (bias + surface_count) * sizeof(uint32_t); state = anv_cmd_buffer_alloc_surface_state(cmd_buffer, size, 32); memcpy(state.map, bindings->descriptors[s].surfaces, size); - for (uint32_t i = 0; i < layers; i++) { - offset = bindings->descriptors[s].surfaces[i] + 8 * sizeof(int32_t); - address = cmd_buffer->surface_bo.map + offset; - - *address = - anv_reloc_list_add(&cmd_buffer->surface_relocs, offset, - bindings->descriptors[s].relocs[i].bo, - bindings->descriptors[s].relocs[i].offset); - } - - for (uint32_t i = 0; i < surface_count; i++) { - offset = bindings->descriptors[s].surfaces[i] + 8 * sizeof(int32_t); - address = cmd_buffer->surface_bo.map + offset; - - *address = - anv_reloc_list_add(&cmd_buffer->surface_relocs, offset, - bindings->descriptors[s].relocs[bias + i].bo, - bindings->descriptors[s].relocs[bias + i].offset); - } - static const uint32_t binding_table_opcodes[] = { [VK_SHADER_STAGE_VERTEX] = 38, [VK_SHADER_STAGE_TESS_CONTROL] = 39, @@ -3172,9 +3154,13 @@ anv_cmd_buffer_fill_render_targets(struct anv_cmd_buffer *cmd_buffer) anv_cmd_buffer_alloc_surface_state(cmd_buffer, 64, 64); memcpy(state.map, view->surface_state.map, 64); + /* The address goes in dwords 8 and 9 of the SURFACE_STATE */ + *(uint64_t *)(state.map + 8 * 4) = + anv_reloc_list_add(&cmd_buffer->surface_relocs, + state.offset + 8 * 4, + view->bo, view->offset); + bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].surfaces[i] = state.offset; - bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].relocs[i].bo = view->bo; - bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].relocs[i].offset = view->offset; } cmd_buffer->dirty |= ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY; } diff --git a/src/vulkan/meta.c b/src/vulkan/meta.c index cd4fbaf87f3..c4d245614ce 100644 --- a/src/vulkan/meta.c +++ b/src/vulkan/meta.c @@ -185,11 +185,6 @@ anv_cmd_buffer_copy_render_targets(struct anv_cmd_buffer *cmd_buffer, for (uint32_t i = 0; i < fb->color_attachment_count; i++) { bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].surfaces[i] = old_bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].surfaces[i]; - - bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].relocs[i].bo = - old_bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].relocs[i].bo; - bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].relocs[i].offset = - old_bindings->descriptors[VK_SHADER_STAGE_FRAGMENT].relocs[i].offset; } cmd_buffer->dirty |= ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY; diff --git a/src/vulkan/private.h b/src/vulkan/private.h index f15856387d8..e1d306f780e 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -530,10 +530,6 @@ struct anv_bindings { struct { uint32_t surfaces[256]; - struct { - struct anv_bo *bo; - uint32_t offset; - } relocs[256]; struct { uint32_t dwords[4]; } samplers[16]; } descriptors[VK_NUM_SHADER_STAGE]; };