aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2019-11-15 15:15:53 -0500
committerJonathan Marek <[email protected]>2019-12-05 22:12:29 -0500
commit3ab4f994619920c2a02a9cf861538a82532ab2d3 (patch)
tree0a38815979ff68ac69d14e77d9038642a284ecf9 /src/freedreno
parent1abca2b3c84a42ab64c466bc209db42c41bba5e3 (diff)
turnip: add function to allocate aligned memory in a substream cs
To use with texture states that need alignment (texconst, sampler, border) Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]>
Diffstat (limited to 'src/freedreno')
-rw-r--r--src/freedreno/vulkan/tu_cs.c35
-rw-r--r--src/freedreno/vulkan/tu_cs.h7
-rw-r--r--src/freedreno/vulkan/tu_private.h5
3 files changed, 47 insertions, 0 deletions
diff --git a/src/freedreno/vulkan/tu_cs.c b/src/freedreno/vulkan/tu_cs.c
index 48242f813ad..22c0527db88 100644
--- a/src/freedreno/vulkan/tu_cs.c
+++ b/src/freedreno/vulkan/tu_cs.c
@@ -263,6 +263,41 @@ tu_cs_begin_sub_stream(struct tu_device *dev,
}
/**
+ * Allocate count*size dwords, aligned to size dwords.
+ * \a cs must be in TU_CS_MODE_SUB_STREAM mode.
+ *
+ */
+VkResult
+tu_cs_alloc(struct tu_device *dev,
+ struct tu_cs *cs,
+ uint32_t count,
+ uint32_t size,
+ struct ts_cs_memory *memory)
+{
+ assert(cs->mode == TU_CS_MODE_SUB_STREAM);
+ assert(size && size <= 1024);
+
+ if (!count)
+ return VK_SUCCESS;
+
+ /* TODO: smarter way to deal with alignment? */
+
+ VkResult result = tu_cs_reserve_space(dev, cs, count * size + (size-1));
+ if (result != VK_SUCCESS)
+ return result;
+
+ struct tu_bo *bo = cs->bos[cs->bo_count - 1];
+ size_t offset = align(tu_cs_get_offset(cs), size);
+
+ memory->map = bo->map + offset * sizeof(uint32_t);
+ memory->iova = bo->iova + offset * sizeof(uint32_t);
+
+ cs->start = cs->cur = (uint32_t*) bo->map + offset + count * size;
+
+ return VK_SUCCESS;
+}
+
+/**
* End command packet emission to a sub-stream. \a sub_cs becomes invalid
* after this call.
*
diff --git a/src/freedreno/vulkan/tu_cs.h b/src/freedreno/vulkan/tu_cs.h
index f3e0ade2a36..19fe984b431 100644
--- a/src/freedreno/vulkan/tu_cs.h
+++ b/src/freedreno/vulkan/tu_cs.h
@@ -48,6 +48,13 @@ tu_cs_begin_sub_stream(struct tu_device *dev,
uint32_t size,
struct tu_cs *sub_cs);
+VkResult
+tu_cs_alloc(struct tu_device *dev,
+ struct tu_cs *cs,
+ uint32_t count,
+ uint32_t size,
+ struct ts_cs_memory *memory);
+
struct tu_cs_entry
tu_cs_end_sub_stream(struct tu_cs *cs, struct tu_cs *sub_cs);
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 2532feed14e..4f2b9fefad5 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -508,6 +508,11 @@ struct tu_cs_entry
uint32_t offset;
};
+struct ts_cs_memory {
+ uint32_t *map;
+ uint64_t iova;
+};
+
enum tu_cs_mode
{