summaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan/tu_cmd_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/freedreno/vulkan/tu_cmd_buffer.c')
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c44
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;
}