nouveau: Add an nv_push struct

This encapsulates the minimum we need for the push macros/functions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:11:58 -06:00 committed by Marge Bot
parent 3964457ba0
commit 60fa24ee09
12 changed files with 104 additions and 96 deletions

View file

@ -122,7 +122,7 @@ mme_tu104_sim_test::submit_push()
void
mme_tu104_sim_test::push_macro(uint32_t id, const std::vector<uint32_t> &macro)
{
nouveau_ws_push_buffer *p = P_SPACE(push, 5 + macro.size());
nv_push *p = P_SPACE(push, 5 + macro.size());
P_MTHD(p, NVC597, LOAD_MME_START_ADDRESS_RAM_POINTER);
P_NVC597_LOAD_MME_START_ADDRESS_RAM_POINTER(p, id);
@ -156,7 +156,7 @@ mme_tu104_sim_test::test_macro(const mme_builder *b,
/* Now run the macro on the GPU */
push_macro(0, macro);
nouveau_ws_push_buffer *p = P_SPACE(push, 1 + MAX2(1, params.size()));
nv_push *p = P_SPACE(push, 1 + MAX2(1, params.size()));
P_1INC(p, NVC597, CALL_MME_MACRO(0));
if (params.empty()) {
@ -1492,7 +1492,7 @@ TEST_F(mme_tu104_sim_test, dwrite_dma)
push_macro(0, macro);
nouveau_ws_push_buffer *p = P_SPACE(push, 10);
nv_push *p = P_SPACE(push, 10);
P_1INC(p, NVC597, CALL_MME_MACRO(0));
P_INLINE_DATA(p, canary5);
@ -1551,7 +1551,7 @@ TEST_F(mme_tu104_sim_test, dram_limit)
push_macro(0, macro);
nouveau_ws_push_buffer *p = P_SPACE(push, 3);
nv_push *p = P_SPACE(push, 3);
P_1INC(p, NVC597, CALL_MME_MACRO(0));
P_INLINE_DATA(p, i);
P_INLINE_DATA(p, chunk_size);
@ -1589,7 +1589,7 @@ TEST_F(mme_tu104_sim_test, dma_read_fifoed)
auto macro = mme_builder_finish_vec(&b);
nouveau_ws_push_buffer *p = P_SPACE(push, 5);
nv_push *p = P_SPACE(push, 5);
P_IMMD(p, NVC597, SET_MME_DATA_FIFO_CONFIG, FIFO_SIZE_SIZE_4KB);
for (uint32_t i = 0; i < 64; i++)
@ -1635,7 +1635,7 @@ TEST_F(mme_tu104_sim_test, scratch_limit)
push_macro(0, macro);
nouveau_ws_push_buffer *p = P_SPACE(push, 3);
nv_push *p = P_SPACE(push, 3);
P_1INC(p, NVC597, CALL_MME_MACRO(0));
P_INLINE_DATA(p, i);
P_INLINE_DATA(p, chunk_size);

View file

@ -21,7 +21,7 @@ nvk_CmdBlitImage2(VkCommandBuffer commandBuffer,
VK_FROM_HANDLE(nvk_image, src, pBlitImageInfo->srcImage);
VK_FROM_HANDLE(nvk_image, dst, pBlitImageInfo->dstImage);
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 16);
struct nv_push *p = P_SPACE(cmd->push, 16);
assert(nvk_get_format(src->vk.format)->supports_2d_blit);
assert(nvk_get_format(dst->vk.format)->supports_2d_blit);

View file

@ -240,7 +240,7 @@ nvk_BeginCommandBuffer(VkCommandBuffer commandBuffer,
nvk_reset_cmd_buffer(&cmd->vk, 0);
/* Start with a nop so we have at least something to submit */
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 2);
struct nv_push *p = P_SPACE(cmd->push, 2);
P_MTHD(p, NV90B5, NOP);
P_NV90B5_NOP(p, 0);

View file

@ -58,7 +58,7 @@ emit_clear_rects(struct nvk_cmd_buffer *cmd,
{
struct nvk_rendering_state *render = &cmd->state.gfx.render;
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, rect_count * 6);
struct nv_push *p = P_SPACE(cmd->push, rect_count * 6);
for (uint32_t r = 0; r < rect_count; r++) {
P_MTHD(p, NV9097, SET_CLEAR_RECT_HORIZONTAL);
@ -115,7 +115,7 @@ nvk_CmdClearAttachments(VkCommandBuffer commandBuffer,
const VkClearRect *pRects)
{
VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 2 + attachmentCount * 4);
struct nv_push *p = P_SPACE(cmd->push, 2 + attachmentCount * 4);
P_IMMD(p, NV9097, SET_CLEAR_SURFACE_CONTROL, {
.respect_stencil_mask = RESPECT_STENCIL_MASK_FALSE,

View file

@ -144,7 +144,7 @@ nouveau_copy_rect(struct nvk_cmd_buffer *cmd, struct nouveau_copy *copy)
{
uint32_t src_bw, dst_bw;
if (copy->remap.comp_size > 0) {
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 2);
struct nv_push *p = P_SPACE(cmd->push, 2);
assert(copy->src.bpp % copy->remap.comp_size == 0);
assert(copy->dst.bpp % copy->remap.comp_size == 0);
@ -192,7 +192,7 @@ nouveau_copy_rect(struct nvk_cmd_buffer *cmd, struct nouveau_copy *copy)
}
for (unsigned z = 0; z < copy->extent_el.depth; z++) {
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 31);
struct nv_push *p = P_SPACE(cmd->push, 31);
P_MTHD(p, NV90B5, OFFSET_IN_UPPER);
P_NV90B5_OFFSET_IN_UPPER(p, src_addr >> 32);
@ -299,7 +299,7 @@ nvk_CmdCopyBuffer2(VkCommandBuffer commandBuffer,
uint64_t size = region->size;
while (size) {
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 10);
struct nv_push *p = P_SPACE(cmd->push, 10);
P_MTHD(p, NV90B5, OFFSET_IN_UPPER);
P_NV90B5_OFFSET_IN_UPPER(p, src_addr >> 32);
@ -547,7 +547,7 @@ nvk_CmdFillBuffer(VkCommandBuffer commandBuffer,
uint32_t pitch = 1 << 19;
uint32_t line = pitch / 4;
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 33);
struct nv_push *p = P_SPACE(cmd->push, 33);
P_IMMD(p, NV902D, SET_OPERATION, V_SRCCOPY);
@ -622,7 +622,7 @@ nvk_CmdUpdateBuffer(VkCommandBuffer commandBuffer,
VkDeviceSize dst_addr = nvk_buffer_address(dst, 0);
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 26 + dataSize / 4);
struct nv_push *p = P_SPACE(cmd->push, 26 + dataSize / 4);
P_IMMD(p, NV902D, SET_OPERATION, V_SRCCOPY);

View file

@ -82,7 +82,7 @@ nvk_CmdDispatch(VkCommandBuffer commandBuffer,
&root_table_map))
return; /* TODO: Error */
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 14 + root_table_size / 4);
struct nv_push *p = P_SPACE(cmd->push, 14 + root_table_size / 4);
P_MTHD(p, NVA0C0, OFFSET_OUT_UPPER);
P_NVA0C0_OFFSET_OUT_UPPER(p, root_table_addr >> 32);

View file

@ -35,7 +35,7 @@ nvk_device_init_context_draw_state(struct nvk_device *dev)
if (pb == NULL)
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
struct nouveau_ws_push_buffer *p = P_SPACE(pb, 0x1000);
struct nv_push *p = P_SPACE(pb, 0x1000);
P_MTHD(p, NV9097, SET_OBJECT);
P_NV9097_SET_OBJECT(p, {
@ -387,7 +387,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
{
VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
struct nvk_rendering_state *render = &cmd->state.gfx.render;
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 23 + pRenderingInfo->colorAttachmentCount * 10);
struct nv_push *p = P_SPACE(cmd->push, 23 + pRenderingInfo->colorAttachmentCount * 10);
memset(render, 0, sizeof(*render));
@ -630,7 +630,7 @@ nvk_flush_vi_state(struct nvk_cmd_buffer *cmd)
const struct vk_dynamic_graphics_state *dyn =
&cmd->vk.dynamic_graphics_state;
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 256);
struct nv_push *p = P_SPACE(cmd->push, 256);
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VI)) {
u_foreach_bit(a, dyn->vi->attributes_valid) {
@ -674,7 +674,7 @@ nvk_flush_ia_state(struct nvk_cmd_buffer *cmd)
/** Nothing to do for MESA_VK_DYNAMIC_IA_PRIMITIVE_TOPOLOGY */
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_IA_PRIMITIVE_RESTART_ENABLE)) {
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 2);
struct nv_push *p = P_SPACE(cmd->push, 2);
P_IMMD(p, NV9097, SET_DA_PRIMITIVE_RESTART,
dyn->ia.primitive_restart_enable);
}
@ -687,7 +687,7 @@ nvk_flush_ts_state(struct nvk_cmd_buffer *cmd)
&cmd->vk.dynamic_graphics_state;
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_TS_PATCH_CONTROL_POINTS)) {
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 2);
struct nv_push *p = P_SPACE(cmd->push, 2);
P_IMMD(p, NV9097, SET_PATCH, dyn->ts.patch_control_points);
}
}
@ -698,7 +698,7 @@ nvk_flush_vp_state(struct nvk_cmd_buffer *cmd)
const struct vk_dynamic_graphics_state *dyn =
&cmd->vk.dynamic_graphics_state;
struct nouveau_ws_push_buffer *p =
struct nv_push *p =
P_SPACE(cmd->push, 14 * dyn->vp.viewport_count + 4 * NVK_MAX_VIEWPORTS);
/* Nothing to do for MESA_VK_DYNAMIC_VP_VIEWPORT_COUNT */
@ -807,7 +807,7 @@ vk_to_nv9097_front_face(VkFrontFace vk_face)
static void
nvk_flush_rs_state(struct nvk_cmd_buffer *cmd)
{
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 23);
struct nv_push *p = P_SPACE(cmd->push, 23);
const struct vk_dynamic_graphics_state *dyn =
&cmd->vk.dynamic_graphics_state;
@ -901,7 +901,7 @@ vk_to_nv9097_stencil_op(VkStencilOp vk_op)
static void
nvk_flush_ds_state(struct nvk_cmd_buffer *cmd)
{
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 35);
struct nv_push *p = P_SPACE(cmd->push, 35);
const struct vk_dynamic_graphics_state *dyn =
&cmd->vk.dynamic_graphics_state;
@ -992,7 +992,7 @@ vk_to_nv9097_logic_op(VkLogicOp vk_op)
static void
nvk_flush_cb_state(struct nvk_cmd_buffer *cmd)
{
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 7);
struct nv_push *p = P_SPACE(cmd->push, 7);
const struct vk_dynamic_graphics_state *dyn =
&cmd->vk.dynamic_graphics_state;
@ -1051,7 +1051,7 @@ nvk_flush_descriptors(struct nvk_cmd_buffer *cmd)
memcpy(root_table_map, &desc->root, sizeof(desc->root));
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 26);
struct nv_push *p = P_SPACE(cmd->push, 26);
P_MTHD(p, NV9097, SET_CONSTANT_BUFFER_SELECTOR_A);
P_NV9097_SET_CONSTANT_BUFFER_SELECTOR_A(p, root_table_size);
@ -1121,7 +1121,7 @@ nvk_CmdBindIndexBuffer(VkCommandBuffer commandBuffer,
VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer);
VK_FROM_HANDLE(nvk_buffer, buffer, _buffer);
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 10);
struct nv_push *p = P_SPACE(cmd->push, 10);
uint64_t addr, range;
if (buffer) {
@ -1156,7 +1156,7 @@ void
nvk_cmd_bind_vertex_buffer(struct nvk_cmd_buffer *cmd, uint32_t vb_idx,
struct nvk_addr_range addr_range)
{
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 6);
struct nv_push *p = P_SPACE(cmd->push, 6);
P_MTHD(p, NV9097, SET_VERTEX_STREAM_A_LOCATION_A(vb_idx));
P_NV9097_SET_VERTEX_STREAM_A_LOCATION_A(p, vb_idx, addr_range.addr >> 32);
@ -1300,7 +1300,7 @@ nvk_CmdDraw(VkCommandBuffer commandBuffer,
.split_mode = SPLIT_MODE_NORMAL_BEGIN_NORMAL_END,
});
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 6);
struct nv_push *p = P_SPACE(cmd->push, 6);
P_1INC(p, NV9097, CALL_MME_MACRO(NVK_MME_DRAW));
P_INLINE_DATA(p, begin);
P_INLINE_DATA(p, vertexCount);
@ -1374,7 +1374,7 @@ nvk_CmdDrawIndexed(VkCommandBuffer commandBuffer,
.split_mode = SPLIT_MODE_NORMAL_BEGIN_NORMAL_END,
});
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 7);
struct nv_push *p = P_SPACE(cmd->push, 7);
P_1INC(p, NV9097, CALL_MME_MACRO(NVK_MME_DRAW_INDEXED));
P_INLINE_DATA(p, begin);
P_INLINE_DATA(p, indexCount);
@ -1443,7 +1443,7 @@ nvk_CmdDrawIndirect(VkCommandBuffer commandBuffer,
.split_mode = SPLIT_MODE_NORMAL_BEGIN_NORMAL_END,
});
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 8);
struct nv_push *p = P_SPACE(cmd->push, 8);
P_IMMD(p, NVC597, SET_MME_DATA_FIFO_CONFIG, FIFO_SIZE_SIZE_4KB);
P_1INC(p, NV9097, CALL_MME_MACRO(NVK_MME_DRAW_INDIRECT));
P_INLINE_DATA(p, begin);
@ -1497,7 +1497,7 @@ nvk_CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer,
.split_mode = SPLIT_MODE_NORMAL_BEGIN_NORMAL_END,
});
struct nouveau_ws_push_buffer *p = P_SPACE(cmd->push, 8);
struct nv_push *p = P_SPACE(cmd->push, 8);
P_IMMD(p, NVC597, SET_MME_DATA_FIFO_CONFIG, FIFO_SIZE_SIZE_4KB);
P_1INC(p, NV9097, CALL_MME_MACRO(NVK_MME_DRAW_INDEXED_INDIRECT));
P_INLINE_DATA(p, begin);

View file

@ -19,7 +19,7 @@ zero_vram(struct nvk_device *dev, struct nouveau_ws_bo *bo)
if (push == NULL)
return vk_error(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY);
struct nouveau_ws_push_buffer *p = P_SPACE(push, 4096);
struct nv_push *p = P_SPACE(push, 4096);
nouveau_ws_push_ref(push, bo, NOUVEAU_WS_BO_WR);
uint64_t addr = bo->offset;

View file

@ -23,7 +23,7 @@ static void
emit_pipeline_vp_state(struct nvk_graphics_pipeline *pipeline,
const struct vk_viewport_state *vp)
{
struct nouveau_ws_push_buffer *p = P_SPACE(&pipeline->push, 0);
struct nv_push *p = P_SPACE(&pipeline->push, 0);
P_IMMD(p, NV9097, SET_VIEWPORT_Z_CLIP, vp->depth_clip_negative_one_to_one ?
RANGE_NEGATIVE_W_TO_POSITIVE_W :
@ -59,7 +59,7 @@ static void
emit_pipeline_rs_state(struct nvk_graphics_pipeline *pipeline,
const struct vk_rasterization_state *rs)
{
struct nouveau_ws_push_buffer *p = P_SPACE(&pipeline->push, 0);
struct nv_push *p = P_SPACE(&pipeline->push, 0);
/* TODO: Depth clip/clamp? */
P_IMMD(p, NV9097, SET_VIEWPORT_CLIP_CONTROL, {
@ -91,7 +91,7 @@ static void
emit_pipeline_ms_state(struct nvk_graphics_pipeline *pipeline,
const struct vk_multisample_state *ms)
{
struct nouveau_ws_push_buffer *p = P_SPACE(&pipeline->push, 0);
struct nv_push *p = P_SPACE(&pipeline->push, 0);
P_IMMD(p, NV9097, SET_ANTI_ALIAS, ffs(ms->rasterization_samples) - 1);
P_IMMD(p, NV9097, SET_ANTI_ALIAS_ENABLE, ms->sample_shading_enable);
@ -157,7 +157,7 @@ static void
emit_pipeline_cb_state(struct nvk_graphics_pipeline *pipeline,
const struct vk_color_blend_state *cb)
{
struct nouveau_ws_push_buffer *p = P_SPACE(&pipeline->push, 0);
struct nv_push *p = P_SPACE(&pipeline->push, 0);
P_IMMD(p, NV9097, SET_BLEND_STATE_PER_TARGET, ENABLE_TRUE);
@ -246,7 +246,7 @@ nvk_graphics_pipeline_create(struct nvk_device *device,
nouveau_ws_push_init_cpu(&pipeline->push, &pipeline->push_data,
sizeof(pipeline->push_data));
struct nouveau_ws_push_buffer *p = P_SPACE(&pipeline->push, 0);
struct nv_push *p = P_SPACE(&pipeline->push, 0);
struct nvk_shader *last_geom = NULL;
for (gl_shader_stage stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {

View file

@ -109,7 +109,7 @@ nvk_queue_state_update(struct nvk_device *dev,
struct nouveau_ws_push *pb = nouveau_ws_push_new(dev->pdev->dev, 256);
if (pb == NULL)
return vk_error(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY);
struct nouveau_ws_push_buffer *p = P_SPACE(pb, 256);
struct nv_push *p = P_SPACE(pb, 256);
if (qs->images.bo) {
nouveau_ws_push_ref(pb, qs->images.bo, NOUVEAU_WS_BO_RD);
@ -241,7 +241,7 @@ nvk_queue_submit(struct vk_queue *vkqueue, struct vk_queue_submit *submission)
if (!queue->empty_push) {
queue->empty_push = nouveau_ws_push_new(device->pdev->dev, 4096);
struct nouveau_ws_push_buffer *p = P_SPACE(queue->empty_push, 2);
struct nv_push *p = P_SPACE(queue->empty_push, 2);
P_MTHD(p, NV90B5, NOP);
P_NV90B5_NOP(p, 0);

View file

@ -42,10 +42,7 @@ nouveau_ws_push_new(struct nouveau_ws_device *dev, uint64_t size)
struct nouveau_ws_push_buffer push_buf;
push_buf.bo = bo;
push_buf.map = map;
push_buf.orig_map = map;
push_buf.end = map;
push_buf.last_size = NULL;
nv_push_init(&push_buf.push, map, 0);
util_dynarray_init(&push->bos, NULL);
util_dynarray_init(&push->pushs, NULL);
@ -68,10 +65,7 @@ nouveau_ws_push_init_cpu(struct nouveau_ws_push *push,
{
struct nouveau_ws_push_buffer push_buf;
push_buf.bo = NULL;
push_buf.map = data;
push_buf.orig_map = data;
push_buf.end = data + size_bytes;
push_buf.last_size = NULL;
nv_push_init(&push_buf.push, data, size_bytes / sizeof(uint32_t));
util_dynarray_init(&push->bos, NULL);
util_dynarray_init(&push->pushs, NULL);
@ -82,7 +76,7 @@ void
nouveau_ws_push_destroy(struct nouveau_ws_push *push)
{
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
nouveau_ws_bo_unmap(buf->bo, buf->orig_map);
nouveau_ws_bo_unmap(buf->bo, buf->push.orig_map);
nouveau_ws_bo_destroy(buf->bo);
}
@ -90,18 +84,18 @@ nouveau_ws_push_destroy(struct nouveau_ws_push *push)
util_dynarray_fini(&push->pushs);
}
struct nouveau_ws_push_buffer *
struct nv_push *
nouveau_ws_push_space(struct nouveau_ws_push *push,
uint32_t count)
{
struct nouveau_ws_push_buffer *buf = _nouveau_ws_push_top(push);
if (!count)
return buf;
return &buf->push;
if (buf->map + count < buf->orig_map + (buf->bo->size / 4)) {
buf->end = buf->map + count;
return buf;
if (buf->push.map + count < buf->push.orig_map + (buf->bo->size / 4)) {
buf->push.end = buf->push.map + count;
return &buf->push;
}
uint32_t flags = NOUVEAU_WS_BO_GART | NOUVEAU_WS_BO_MAP;
@ -119,13 +113,10 @@ nouveau_ws_push_space(struct nouveau_ws_push *push,
struct nouveau_ws_push_buffer push_buf;
push_buf.bo = bo;
push_buf.map = map;
push_buf.orig_map = map;
push_buf.end = map + count;
push_buf.last_size = NULL;
nv_push_init(&push_buf.push, map, count);
util_dynarray_append(&push->pushs, struct nouveau_ws_push_buffer, push_buf);
return _nouveau_ws_push_top(push);
return &_nouveau_ws_push_top(push)->push;
fail_map:
nouveau_ws_bo_destroy(bo);
@ -137,10 +128,10 @@ nouveau_ws_push_append(struct nouveau_ws_push *push,
const struct nouveau_ws_push *other)
{
struct nouveau_ws_push_buffer *other_buf = _nouveau_ws_push_top(other);
size_t count = other_buf->map - other_buf->orig_map;
size_t count = nv_push_dw_count(&other_buf->push);
struct nouveau_ws_push_buffer *push_buf = P_SPACE(push, count);
if (!push_buf)
struct nv_push *p = P_SPACE(push, count);
if (!p)
return -ENOMEM;
/* We only use this for CPU pushes. */
@ -149,11 +140,9 @@ nouveau_ws_push_append(struct nouveau_ws_push *push,
/* We don't support BO refs for now */
assert(other->bos.size == 0);
assert(push_buf->map + count <= push_buf->end);
memcpy(push_buf->map, other_buf->orig_map, count * sizeof(*push_buf->map));
push_buf->map += count;
push_buf->last_size = NULL;
memcpy(p->map, other_buf->push.orig_map, count * sizeof(*p->map));
p->map += count;
p->last_size = NULL;
return 0;
}
@ -163,16 +152,16 @@ nouveau_ws_push_valid(struct nouveau_ws_push *push) {
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
struct nouveau_ws_push_buffer *buf = _nouveau_ws_push_top(push);
uint32_t *cur = buf->orig_map;
uint32_t *cur = buf->push.orig_map;
/* submitting empty push buffers is probably a bug */
assert(buf->map != buf->orig_map);
assert(buf->push.map != buf->push.orig_map);
/* make sure we don't overrun the bo */
assert(buf->map <= buf->end);
assert(buf->push.map <= buf->push.end);
/* parse all the headers to see if we get to buf->map */
while (cur < buf->map) {
while (cur < buf->push.map) {
uint32_t hdr = *cur;
uint32_t mthd = hdr >> 29;
@ -193,7 +182,7 @@ nouveau_ws_push_valid(struct nouveau_ws_push *push) {
}
cur++;
assert(cur <= buf->map);
assert(cur <= buf->push.map);
}
}
}
@ -202,9 +191,9 @@ static void
nouveau_ws_push_dump(struct nouveau_ws_push *push, struct nouveau_ws_context *ctx)
{
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
uint32_t *cur = buf->orig_map;
uint32_t *cur = buf->push.orig_map;
while (cur < buf->map) {
while (cur < buf->push.map) {
uint32_t hdr = *cur;
uint32_t type = hdr >> 29;
uint32_t inc;
@ -214,7 +203,7 @@ nouveau_ws_push_dump(struct nouveau_ws_push *push, struct nouveau_ws_context *ct
uint32_t value = 0;
bool is_immd = false;
printf("[0x%08" PRIxPTR "] HDR %x subch %i", cur - buf->orig_map, hdr, subchan);
printf("[0x%08" PRIxPTR "] HDR %x subch %i", cur - buf->push.orig_map, hdr, subchan);
cur++;
switch (type) {
@ -351,7 +340,7 @@ nouveau_ws_push_submit(
/* Can't submit a CPU push */
assert(buf->bo);
if (buf->map == buf->orig_map)
if (buf->push.map == buf->push.orig_map)
continue;
req_bo[i].handle = buf->bo->handle;
@ -360,7 +349,7 @@ nouveau_ws_push_submit(
req_push[i].bo_index = i;
req_push[i].offset = 0;
req_push[i].length = (buf->map - buf->orig_map) * 4;
req_push[i].length = nv_push_dw_count(&buf->push) * 4;
i++;
}
@ -445,12 +434,12 @@ void nouveau_ws_push_reset(struct nouveau_ws_push *push)
bool first = true;
util_dynarray_foreach(&push->pushs, struct nouveau_ws_push_buffer, buf) {
if (first) {
buf->map = buf->orig_map;
buf->push.map = buf->push.orig_map;
first = false;
continue;
}
nouveau_ws_bo_unmap(buf->bo, buf->orig_map);
nouveau_ws_bo_unmap(buf->bo, buf->push.orig_map);
nouveau_ws_bo_destroy(buf->bo);
}

View file

@ -18,15 +18,35 @@ struct nouveau_ws_push_bo {
enum nouveau_ws_bo_map_flags flags;
};
struct nouveau_ws_push_buffer {
struct nouveau_ws_bo *bo;
struct nv_push {
uint32_t *orig_map;
uint32_t *map;
uint32_t *end;
uint32_t *last_size;
};
static inline void
nv_push_init(struct nv_push *push, uint32_t *start, size_t dw_count)
{
push->orig_map = start;
push->map = start;
push->end = start + dw_count;
push->last_size = NULL;
}
static inline size_t
nv_push_dw_count(struct nv_push *push)
{
assert(push->orig_map <= push->map);
assert(push->map <= push->end);
return push->map - push->orig_map;
}
struct nouveau_ws_push_buffer {
struct nouveau_ws_bo *bo;
struct nv_push push;
};
struct nouveau_ws_push {
/* struct nouveau_ws_push_bo */
struct util_dynarray bos;
@ -43,7 +63,7 @@ void nouveau_ws_push_init_cpu(struct nouveau_ws_push *push,
void nouveau_ws_push_destroy(struct nouveau_ws_push *);
int nouveau_ws_push_append(struct nouveau_ws_push *,
const struct nouveau_ws_push *);
struct nouveau_ws_push_buffer *
struct nv_push *
nouveau_ws_push_space(struct nouveau_ws_push *, uint32_t size);
int nouveau_ws_push_submit(struct nouveau_ws_push *, struct nouveau_ws_device *, struct nouveau_ws_context *);
void nouveau_ws_push_ref(struct nouveau_ws_push *, struct nouveau_ws_bo *, enum nouveau_ws_bo_map_flags);
@ -82,7 +102,7 @@ NVC0_FIFO_PKHDR_SQ(int subc, int mthd, unsigned size)
}
static inline void
__push_verify(struct nouveau_ws_push_buffer *push)
__push_verify(struct nv_push *push)
{
if (!push->last_size)
return;
@ -99,8 +119,7 @@ __push_verify(struct nouveau_ws_push_buffer *push)
}
static inline void
__push_mthd_size(struct nouveau_ws_push_buffer *push,
int subc, uint32_t mthd, unsigned size)
__push_mthd_size(struct nv_push *push, int subc, uint32_t mthd, unsigned size)
{
__push_verify(push);
@ -110,7 +129,7 @@ __push_mthd_size(struct nouveau_ws_push_buffer *push,
}
static inline void
__push_mthd(struct nouveau_ws_push_buffer *push, int subc, uint32_t mthd)
__push_mthd(struct nv_push *push, int subc, uint32_t mthd)
{
__push_mthd_size(push, subc, mthd, 0);
}
@ -125,7 +144,7 @@ NVC0_FIFO_PKHDR_IL(int subc, int mthd, uint16_t data)
}
static inline void
__push_immd(struct nouveau_ws_push_buffer *push, int subc, uint32_t mthd, uint32_t val)
__push_immd(struct nv_push *push, int subc, uint32_t mthd, uint32_t val)
{
__push_verify(push);
push->last_size = push->map;
@ -151,7 +170,7 @@ NVC0_FIFO_PKHDR_1I(int subc, int mthd, unsigned size)
}
static inline void
__push_1inc(struct nouveau_ws_push_buffer *push, int subc, uint32_t mthd)
__push_1inc(struct nv_push *push, int subc, uint32_t mthd)
{
__push_verify(push);
push->last_size = push->map;
@ -168,7 +187,7 @@ NVC0_FIFO_PKHDR_0I(int subc, int mthd, unsigned size)
}
static inline void
__push_0inc(struct nouveau_ws_push_buffer *push, int subc, uint32_t mthd)
__push_0inc(struct nv_push *push, int subc, uint32_t mthd)
{
__push_verify(push);
push->last_size = push->map;
@ -179,7 +198,7 @@ __push_0inc(struct nouveau_ws_push_buffer *push, int subc, uint32_t mthd)
#define P_0INC(push, class, mthd) __push_0inc(push, SUBC_##class, class##_##mthd)
static inline bool
nvk_push_update_count(struct nouveau_ws_push_buffer *push, uint16_t count)
nvk_push_update_count(struct nv_push *push, uint16_t count)
{
uint32_t last_hdr_val = *push->last_size;
@ -202,7 +221,7 @@ nvk_push_update_count(struct nouveau_ws_push_buffer *push, uint16_t count)
}
static inline void
P_INLINE_DATA(struct nouveau_ws_push_buffer *push, uint32_t value)
P_INLINE_DATA(struct nv_push *push, uint32_t value)
{
if (nvk_push_update_count(push, 1)) {
/* push new value */
@ -212,7 +231,7 @@ P_INLINE_DATA(struct nouveau_ws_push_buffer *push, uint32_t value)
}
static inline void
P_INLINE_FLOAT(struct nouveau_ws_push_buffer *push, float value)
P_INLINE_FLOAT(struct nv_push *push, float value)
{
if (nvk_push_update_count(push, 1)) {
/* push new value */
@ -222,7 +241,7 @@ P_INLINE_FLOAT(struct nouveau_ws_push_buffer *push, float value)
}
static inline void
P_INLINE_ARRAY(struct nouveau_ws_push_buffer *push, const uint32_t *data, int num_dw)
P_INLINE_ARRAY(struct nv_push *push, const uint32_t *data, int num_dw)
{
if (nvk_push_update_count(push, num_dw)) {
/* push new value */
@ -233,7 +252,7 @@ P_INLINE_ARRAY(struct nouveau_ws_push_buffer *push, const uint32_t *data, int nu
/* internally used by generated inlines. */
static inline void
nvk_push_val(struct nouveau_ws_push_buffer *push, uint32_t idx, uint32_t val)
nvk_push_val(struct nv_push *push, uint32_t idx, uint32_t val)
{
UNUSED uint32_t last_hdr_val = *push->last_size;
UNUSED bool is_0inc = (last_hdr_val & 0xe0000000) == 0x60000000;
@ -257,7 +276,7 @@ nvk_push_val(struct nouveau_ws_push_buffer *push, uint32_t idx, uint32_t val)
P_INLINE_DATA(push, val);
}
static inline struct nouveau_ws_push_buffer *
static inline struct nv_push *
P_SPACE(struct nouveau_ws_push *push, uint32_t size)
{
return nouveau_ws_push_space(push, size);