Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
Start implementing stubs for CmdRenderPasses
Browse files Browse the repository at this point in the history
  • Loading branch information
abergmeier committed Nov 27, 2019
1 parent d081dde commit 3f2bdbe
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 60 deletions.
91 changes: 77 additions & 14 deletions src/broadcom/vulkan/v3d_cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
#define VC5_CL_H

#include <stdint.h>
#include "v3dvk_bo.h"

#include "broadcom/cle/v3d_packet_helpers.h"


struct v3dvk_bo;
struct v3d_job;
struct v3d_cl;

Expand All @@ -42,19 +45,6 @@ struct v3d_cl_reloc {
uint32_t offset;
};

/**
* Reference to a BO with its associated offset, used in the pack process.
*/
static inline struct v3d_cl_reloc
cl_address(struct v3dvk_bo *bo, uint32_t offset)
{
struct v3d_cl_reloc reloc = {
.bo = bo,
.offset = offset,
};
return reloc;
}

static inline void cl_pack_emit_reloc(struct v3d_cl *cl, const struct v3d_cl_reloc *);

#define __gen_user_data struct v3d_cl
Expand All @@ -71,6 +61,79 @@ struct v3d_cl {
uint32_t size;
};


static inline uint32_t cl_offset(struct v3d_cl *cl)
{
return (char *)cl->next - (char *)cl->base;
}

static inline void
cl_advance(struct v3d_cl_out **cl, uint32_t n)
{
(*cl) = (struct v3d_cl_out *)((char *)(*cl) + n);
}

static inline struct v3d_cl_out *
cl_start(struct v3d_cl *cl)
{
return cl->next;
}

static inline void
cl_end(struct v3d_cl *cl, struct v3d_cl_out *next)
{
cl->next = next;
assert(cl_offset(cl) <= cl->size);
}

/**
* Reference to a BO with its associated offset, used in the pack process.
*/
static inline struct v3d_cl_reloc
cl_address(struct v3dvk_bo *bo, uint32_t offset)
{
struct v3d_cl_reloc reloc = {
.bo = bo,
.offset = offset,
};
return reloc;
}

void v3d_cl_ensure_space_with_branch(struct v3d_cl *cl, uint32_t size);

#define cl_packet_header(packet) V3DX(packet ## _header)
#define cl_packet_length(packet) V3DX(packet ## _length)
#define cl_packet_pack(packet) V3DX(packet ## _pack)
#define cl_packet_struct(packet) V3DX(packet)

/* Macro for setting up an emit of a CL struct. A temporary unpacked struct
* is created, which you get to set fields in of the form:
*
* cl_emit(bcl, FLAT_SHADE_FLAGS, flags) {
* .flags.flat_shade_flags = 1 << 2,
* }
*
* or default values only can be emitted with just:
*
* cl_emit(bcl, FLAT_SHADE_FLAGS, flags);
*
* The trick here is that we make a for loop that will execute the body
* (either the block or the ';' after the macro invocation) exactly once.
*/
#define cl_emit(cl, packet, name) \
for (struct cl_packet_struct(packet) name = { \
cl_packet_header(packet) \
}, \
*_loop_terminate = &name; \
__builtin_expect(_loop_terminate != NULL, 1); \
({ \
struct v3d_cl_out *cl_out = cl_start(cl); \
cl_packet_pack(packet)(cl, (uint8_t *)cl_out, &name); \
cl_advance(&cl_out, cl_packet_length(packet)); \
cl_end(cl, cl_out); \
_loop_terminate = NULL; \
}))

void v3d_job_add_bo(struct v3d_job *job, struct v3dvk_bo *bo);

/**
Expand Down
46 changes: 0 additions & 46 deletions src/broadcom/vulkan/v3dvk_cl.h

This file was deleted.

68 changes: 68 additions & 0 deletions src/broadcom/vulkan/v3dvk_cmd_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* IN THE SOFTWARE.
*/

#include <assert.h>
#include "common/v3d_macros.h"
#include <cle/v3d_packet_v42_pack.h>
#include "common.h"
#include "v3dvk_buffer.h"
#include "v3dvk_cmd_buffer.h"
Expand Down Expand Up @@ -400,3 +403,68 @@ v3dvk_cmd_buffer_execbuf(struct v3dvk_device *device,
#endif
return result;
}

void
v3dvk_CmdBeginRenderPass(VkCommandBuffer commandBuffer,
const VkRenderPassBeginInfo *pRenderPassBegin,
VkSubpassContents contents)
{
V3DVK_FROM_HANDLE(v3dvk_cmd_buffer, cmd_buffer, commandBuffer);
V3DVK_FROM_HANDLE(v3dvk_render_pass, pass, pRenderPassBegin->renderPass);
V3DVK_FROM_HANDLE(v3dvk_framebuffer, framebuffer, pRenderPassBegin->framebuffer);
VkResult result;

cmd_buffer->state.pass = pass;
cmd_buffer->state.subpass = pass->subpasses;
cmd_buffer->state.framebuffer = framebuffer;
#if 0
result = tu_cmd_state_setup_attachments(cmd_buffer, pRenderPassBegin);
if (result != VK_SUCCESS)
return;

tu_cmd_update_tiling_config(cmd_buffer, &pRenderPassBegin->renderArea);
tu_cmd_prepare_tile_load_ib(cmd_buffer);
tu_cmd_prepare_tile_store_ib(cmd_buffer);
#endif
/* Get space to emit our BCL state, using a branch to jump to a new BO
* if necessary.
*/
v3d_cl_ensure_space_with_branch(&cmd_buffer->bcl, 256 /* XXX */);

cl_emit(&cmd_buffer->bcl, TILE_BINNING_MODE_CFG, config) {
config.width_in_pixels = cmd_buffer->state.framebuffer.width;
config.height_in_pixels = cmd_buffer->state.framebuffer.height;
config.number_of_render_targets =
MAX2(cmd_buffer->state.framebuffer.nr_cbufs, 1);
#if 0
config.multisample_mode_4x = job->msaa;
config.maximum_bpp_of_all_render_targets = job->internal_bpp;
#endif
}

/* draw_cl should contain entries only for this render pass */
assert(!cl_offset(&cmd_buffer->draw_cl));
v3d_init_cl(cmd_buffer->draw_cl);
cmd_buffer->draw_cl_out = cl_start(&cmd_buffer->draw_cl);
}


void
v3dvk_CmdEndRenderPass(VkCommandBuffer commandBuffer)
{
V3DVK_FROM_HANDLE(v3dvk_cmd_buffer, cmd_buffer, commandBuffer);

cl_end(&cmd_buffer->draw_cl, cmd_buffer->draw_cl_out);

v3dvk_cmd_render_tiles(cmd_buffer);

/* discard draw_cs entries now that the tiles are rendered */
v3dvk_cs_discard_entries(&cmd_buffer->draw_cs);

vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
cmd_buffer->state.attachments = NULL;

cmd_buffer->state.pass = NULL;
cmd_buffer->state.subpass = NULL;
cmd_buffer->state.framebuffer = NULL;
}
6 changes: 6 additions & 0 deletions src/broadcom/vulkan/v3dvk_cmd_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <vulkan/vk_icd.h>
#include <vulkan/vulkan.h>
#include "util/list.h"
#include "v3d_cl.h"
#include "v3dvk_job.h"
#include "v3dvk_defines.h"

Expand Down Expand Up @@ -308,6 +309,11 @@ struct v3dvk_cmd_buffer {
VkCommandBufferLevel level;

struct v3dvk_cmd_state state;

// Taken reference from v3d_job.h
struct v3d_cl bcl;
struct v3d_cl rcl;
struct v3d_cl indirect;
};

void
Expand Down

0 comments on commit 3f2bdbe

Please sign in to comment.