summaryrefslogtreecommitdiffstats
path: root/src/freedreno
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-01-28 16:24:48 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:02:13 -0700
commit0d81be3959234c3d877efd6ddee5280b01815433 (patch)
treef92a7c7a8ebe38ecaf68e54b3aff0fee31198bf2 /src/freedreno
parent2774a1b97d450c81108c4f8d00c948d8e3427c4f (diff)
turnip: specify initial size in tu_cs_init
We will drop size parameter from tu_cs_begin shortly, such that tu_cs_begin never fails.
Diffstat (limited to 'src/freedreno')
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c2
-rw-r--r--src/freedreno/vulkan/tu_cs.c21
-rw-r--r--src/freedreno/vulkan/tu_cs.h2
-rw-r--r--src/freedreno/vulkan/tu_private.h2
4 files changed, 12 insertions, 15 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index 82a7819966b..0544313bf66 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -736,7 +736,7 @@ tu_create_cmd_buffer(struct tu_device *device,
}
tu_bo_list_init(&cmd_buffer->bo_list);
- tu_cs_init(&cmd_buffer->cs);
+ tu_cs_init(&cmd_buffer->cs, 4096);
*pCommandBuffer = tu_cmd_buffer_to_handle(cmd_buffer);
diff --git a/src/freedreno/vulkan/tu_cs.c b/src/freedreno/vulkan/tu_cs.c
index 108ac707e29..81bf36e9a87 100644
--- a/src/freedreno/vulkan/tu_cs.c
+++ b/src/freedreno/vulkan/tu_cs.c
@@ -27,15 +27,11 @@
* Initialize a command stream.
*/
void
-tu_cs_init(struct tu_cs *cs)
+tu_cs_init(struct tu_cs *cs, uint32_t initial_size)
{
- cs->start = cs->cur = cs->end = NULL;
+ memset(cs, 0, sizeof(*cs));
- cs->entry_count = cs->entry_capacity = 0;
- cs->entries = NULL;
-
- cs->bo_count = cs->bo_capacity = 0;
- cs->bos = NULL;
+ cs->next_bo_size = initial_size;
}
/**
@@ -98,7 +94,7 @@ tu_cs_is_empty(const struct tu_cs *cs)
* be emitted to the new BO.
*/
static VkResult
-tu_cs_add_bo(struct tu_device *dev, struct tu_cs *cs, uint32_t byte_size)
+tu_cs_add_bo(struct tu_device *dev, struct tu_cs *cs, uint32_t size)
{
/* grow cs->bos if needed */
if (cs->bo_count == cs->bo_capacity) {
@@ -116,7 +112,7 @@ tu_cs_add_bo(struct tu_device *dev, struct tu_cs *cs, uint32_t byte_size)
if (!new_bo)
return VK_ERROR_OUT_OF_HOST_MEMORY;
- VkResult result = tu_bo_init_new(dev, new_bo, byte_size);
+ VkResult result = tu_bo_init_new(dev, new_bo, size * sizeof(uint32_t));
if (result != VK_SUCCESS) {
free(new_bo);
return result;
@@ -196,13 +192,12 @@ tu_cs_begin(struct tu_device *dev, struct tu_cs *cs, uint32_t reserve_size)
assert(tu_cs_is_empty(cs));
if (tu_cs_get_space(cs) < reserve_size) {
- uint32_t new_size = MAX2(16384, reserve_size * sizeof(uint32_t));
- if (cs->bo_count)
- new_size = MAX2(new_size, cs->bos[cs->bo_count - 1]->size * 2);
-
+ uint32_t new_size = MAX2(cs->next_bo_size, reserve_size);
VkResult result = tu_cs_add_bo(dev, cs, new_size);
if (result != VK_SUCCESS)
return result;
+
+ cs->next_bo_size = new_size * 2;
}
assert(tu_cs_get_space(cs) >= reserve_size);
diff --git a/src/freedreno/vulkan/tu_cs.h b/src/freedreno/vulkan/tu_cs.h
index a26b01b0ca2..4c184dac8f9 100644
--- a/src/freedreno/vulkan/tu_cs.h
+++ b/src/freedreno/vulkan/tu_cs.h
@@ -28,7 +28,7 @@
#include "registers/adreno_pm4.xml.h"
void
-tu_cs_init(struct tu_cs *cs);
+tu_cs_init(struct tu_cs *cs, uint32_t initial_size);
void
tu_cs_finish(struct tu_device *dev, struct tu_cs *cs);
VkResult
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 3107b052881..cd724ea1b9d 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -786,6 +786,8 @@ struct tu_cs
/* for tu_cs_reserve_space_assert */
uint32_t *reserved_end;
+ uint32_t next_bo_size;
+
struct tu_cs_entry *entries;
uint32_t entry_count;
uint32_t entry_capacity;