From 26261847cfcea3562d7eda04d2cdf883eb55d3d3 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Thu, 10 Jan 2019 21:39:14 +0100 Subject: [PATCH] turnip: Fill command buffer --- src/freedreno/vulkan/tu_cmd_buffer.c | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 1407c0cf83b..1cfbf1cb96c 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -28,7 +28,7 @@ #include "tu_private.h" #include "vk_format.h" - +#include "adreno_pm4.xml.h" void tu_bo_list_init(struct tu_bo_list *list) { @@ -200,6 +200,30 @@ tu_cmd_stream_reset(struct tu_device *dev, stream->entry_count = 0; } +static unsigned +_odd_parity_bit(unsigned val) +{ + /* See: http://graphics.stanford.edu/~seander/bithacks.html#ParityParallel + * note that we want odd parity so 0x6996 is inverted. + */ + val ^= val >> 16; + val ^= val >> 8; + val ^= val >> 4; + val &= 0xf; + return (~0x6996 >> val) & 1; +} + +static void +OUT_PKT7(struct tu_cmd_stream *stream, uint8_t opcode, uint16_t cnt) +{ + *stream->cur++ = CP_TYPE7_PKT | cnt | + (_odd_parity_bit(cnt) << 15) | + ((opcode & 0x7f) << 16) | + ((_odd_parity_bit(opcode) << 23)); +} + + + const struct tu_dynamic_state default_dynamic_state = { .viewport = { @@ -525,6 +549,15 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer, cmd_buffer->status = TU_CMD_BUFFER_STATUS_RECORDING; + result = tu_cmd_stream_begin(cmd_buffer->device, + &cmd_buffer->primary_cmd_stream, 4096); + + /* Put some stuff in so we do not have empty command buffers. */ + OUT_PKT7(&cmd_buffer->primary_cmd_stream, CP_NOP, 4); + *cmd_buffer->primary_cmd_stream.cur++ = 0; + *cmd_buffer->primary_cmd_stream.cur++ = 0; + *cmd_buffer->primary_cmd_stream.cur++ = 0; + *cmd_buffer->primary_cmd_stream.cur++ = 0; return result; } @@ -572,6 +605,7 @@ tu_EndCommandBuffer(VkCommandBuffer commandBuffer) { TU_FROM_HANDLE(tu_cmd_buffer, cmd_buffer, commandBuffer); + tu_cmd_stream_end(&cmd_buffer->primary_cmd_stream); cmd_buffer->status = TU_CMD_BUFFER_STATUS_EXECUTABLE; return cmd_buffer->record_result; -- 2.30.2