Module: Mesa Branch: main Commit: 85fd85f950692ce00d01dd066798e80243d0f2c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=85fd85f950692ce00d01dd066798e80243d0f2c5
Author: Faith Ekstrand <faith.ekstr...@collabora.com> Date: Thu Nov 30 23:34:38 2023 -0600 nvk: Use the copy engine for NVK_DEBUG=zero_memory Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26441> --- src/nouveau/vulkan/nvk_device_memory.c | 72 +++++++++++++++------------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/src/nouveau/vulkan/nvk_device_memory.c b/src/nouveau/vulkan/nvk_device_memory.c index 055a868393b..f13c89b50d3 100644 --- a/src/nouveau/vulkan/nvk_device_memory.c +++ b/src/nouveau/vulkan/nvk_device_memory.c @@ -17,7 +17,7 @@ #include <sys/mman.h> #include "nvtypes.h" -#include "nvk_cl902d.h" +#include "nvk_cl90b5.h" /* Supports opaque fd only */ const VkExternalMemoryProperties nvk_opaque_fd_mem_props = { @@ -53,46 +53,36 @@ zero_vram(struct nvk_device *dev, struct nouveau_ws_bo *bo) uint64_t addr = bo->offset; - /* can't go higher for whatever reason */ - uint32_t pitch = 1 << 19; - - P_IMMD(p, NV902D, SET_OPERATION, V_SRCCOPY); - - P_MTHD(p, NV902D, SET_DST_FORMAT); - P_NV902D_SET_DST_FORMAT(p, V_A8B8G8R8); - P_NV902D_SET_DST_MEMORY_LAYOUT(p, V_PITCH); - - P_MTHD(p, NV902D, SET_DST_PITCH); - P_NV902D_SET_DST_PITCH(p, pitch); - - P_MTHD(p, NV902D, SET_DST_OFFSET_UPPER); - P_NV902D_SET_DST_OFFSET_UPPER(p, addr >> 32); - P_NV902D_SET_DST_OFFSET_LOWER(p, addr & 0xffffffff); - - P_MTHD(p, NV902D, SET_RENDER_SOLID_PRIM_COLOR_FORMAT); - P_NV902D_SET_RENDER_SOLID_PRIM_COLOR_FORMAT(p, V_A8B8G8R8); - P_NV902D_SET_RENDER_SOLID_PRIM_COLOR(p, 0); - - uint32_t height = bo->size / pitch; - uint32_t extra = bo->size % pitch; - - if (height > 0) { - P_IMMD(p, NV902D, RENDER_SOLID_PRIM_MODE, V_RECTS); - - P_MTHD(p, NV902D, RENDER_SOLID_PRIM_POINT_SET_X(0)); - P_NV902D_RENDER_SOLID_PRIM_POINT_SET_X(p, 0, 0); - P_NV902D_RENDER_SOLID_PRIM_POINT_Y(p, 0, 0); - P_NV902D_RENDER_SOLID_PRIM_POINT_SET_X(p, 1, pitch / 4); - P_NV902D_RENDER_SOLID_PRIM_POINT_Y(p, 1, height); - } - - P_IMMD(p, NV902D, RENDER_SOLID_PRIM_MODE, V_RECTS); - - P_MTHD(p, NV902D, RENDER_SOLID_PRIM_POINT_SET_X(0)); - P_NV902D_RENDER_SOLID_PRIM_POINT_SET_X(p, 0, 0); - P_NV902D_RENDER_SOLID_PRIM_POINT_Y(p, 0, height); - P_NV902D_RENDER_SOLID_PRIM_POINT_SET_X(p, 1, extra / 4); - P_NV902D_RENDER_SOLID_PRIM_POINT_Y(p, 1, height); + assert((bo->size % 4096) == 0); + assert((bo->size / 4096) < (1 << 15)); + + P_MTHD(p, NV90B5, OFFSET_OUT_UPPER); + P_NV90B5_OFFSET_OUT_UPPER(p, addr >> 32); + P_NV90B5_OFFSET_OUT_LOWER(p, addr & 0xffffffff); + P_NV90B5_PITCH_IN(p, 4096); + P_NV90B5_PITCH_OUT(p, 4096); + P_NV90B5_LINE_LENGTH_IN(p, (4096 / 16)); + P_NV90B5_LINE_COUNT(p, bo->size / 4096); + + P_IMMD(p, NV90B5, SET_REMAP_CONST_A, 0); + P_IMMD(p, NV90B5, SET_REMAP_COMPONENTS, { + .dst_x = DST_X_CONST_A, + .dst_y = DST_Y_CONST_A, + .dst_z = DST_Z_CONST_A, + .dst_w = DST_W_CONST_A, + .component_size = COMPONENT_SIZE_FOUR, + .num_src_components = NUM_SRC_COMPONENTS_FOUR, + .num_dst_components = NUM_DST_COMPONENTS_FOUR, + }); + + P_IMMD(p, NV90B5, LAUNCH_DMA, { + .data_transfer_type = DATA_TRANSFER_TYPE_NON_PIPELINED, + .multi_line_enable = MULTI_LINE_ENABLE_TRUE, + .flush_enable = FLUSH_ENABLE_TRUE, + .src_memory_layout = SRC_MEMORY_LAYOUT_PITCH, + .dst_memory_layout = DST_MEMORY_LAYOUT_PITCH, + .remap_enable = REMAP_ENABLE_TRUE, + }); return nvk_queue_submit_simple(&dev->queue, nv_push_dw_count(&push), push_data, 1, &bo);