diff options
author | Bas Nieuwenhuizen <[email protected]> | 2019-01-15 22:18:15 +0100 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-03-11 10:01:41 -0700 |
commit | ac2a845abf4edf3419acc1dec5601cbe2ea7782b (patch) | |
tree | 3777b0fd5c03b68e30f3068532029d1eeea75eb0 /src/freedreno/vulkan/tu_cmd_buffer.c | |
parent | 2e684cb80000f5e615524f538358e0321d18e3e8 (diff) |
turnip: Add emit functions in a header.
This adds a radv-style check_space functions + emit functions.
Also puts them in a header as a bunch of inlines, so
(1) we can use them from meta code.
(2) they are inline for performance as these are common and small.
Did not put them in tu_private.h as a bunch of inlines only
clutters up that huge headerfile.
Precise error propagation for memory allocation failures is still
todo.
Diffstat (limited to 'src/freedreno/vulkan/tu_cmd_buffer.c')
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index df72d4a7b31..41bd82e3cfc 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -29,6 +29,8 @@ #include "vk_format.h" #include "adreno_pm4.xml.h" +#include "tu_cs.h" + void tu_bo_list_init(struct tu_bo_list *list) { @@ -200,29 +202,20 @@ 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) +VkResult +tu_cs_check_space(struct tu_device *dev, + struct tu_cmd_stream *stream, + size_t size) { - *stream->cur++ = CP_TYPE7_PKT | cnt | - (_odd_parity_bit(cnt) << 15) | - ((opcode & 0x7f) << 16) | - ((_odd_parity_bit(opcode) << 23)); -} + if (stream->end - stream->cur >= size) + return VK_SUCCESS; + VkResult result = tu_cmd_stream_end(stream); + if (result != VK_SUCCESS) + return result; + return tu_cmd_stream_begin(dev, stream, size); +} const struct tu_dynamic_state default_dynamic_state = { .viewport = @@ -553,11 +546,12 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer, &cmd_buffer->cs, 4096); /* Put some stuff in so we do not have empty command buffers. */ - OUT_PKT7(&cmd_buffer->cs, CP_NOP, 4); - *cmd_buffer->cs.cur++ = 0; - *cmd_buffer->cs.cur++ = 0; - *cmd_buffer->cs.cur++ = 0; - *cmd_buffer->cs.cur++ = 0; + tu_cs_emit_pkt7(&cmd_buffer->cs, CP_NOP, 4); + tu_cs_emit(&cmd_buffer->cs, 0); + tu_cs_emit(&cmd_buffer->cs, 0); + tu_cs_emit(&cmd_buffer->cs, 0); + tu_cs_emit(&cmd_buffer->cs, 0); + return result; } |