summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/intel/vulkan/anv_blorp.c16
-rw-r--r--src/intel/vulkan/anv_descriptor_set.c7
-rw-r--r--src/intel/vulkan/anv_image.c4
-rw-r--r--src/intel/vulkan/anv_private.h12
4 files changed, 28 insertions, 11 deletions
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index d79c5e0e8c6..05790d268cb 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -722,11 +722,17 @@ void anv_CmdFillBuffer(
struct blorp_batch batch;
blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0);
- if (fillSize == VK_WHOLE_SIZE) {
- fillSize = dst_buffer->size - dstOffset;
- /* Make sure fillSize is a multiple of 4 */
- fillSize &= ~3ull;
- }
+ fillSize = anv_buffer_get_range(dst_buffer, dstOffset, fillSize);
+
+ /* From the Vulkan spec:
+ *
+ * "size is the number of bytes to fill, and must be either a multiple
+ * of 4, or VK_WHOLE_SIZE to fill the range from offset to the end of
+ * the buffer. If VK_WHOLE_SIZE is used and the remaining size of the
+ * buffer is not a multiple of 4, then the nearest smaller multiple is
+ * used."
+ */
+ fillSize &= ~3ull;
/* First, we compute the biggest format that can be used with the
* given offsets and size.
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 1e8991ba43b..2a37d7d34ca 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -672,10 +672,9 @@ anv_descriptor_set_write_buffer(struct anv_descriptor_set *set,
/* For buffers with dynamic offsets, we use the full possible range in the
* surface state and do the actual range-checking in the shader.
*/
- if (bind_layout->dynamic_offset_index >= 0 || range == VK_WHOLE_SIZE)
- bview->range = buffer->size - offset;
- else
- bview->range = range;
+ if (bind_layout->dynamic_offset_index >= 0)
+ range = VK_WHOLE_SIZE;
+ bview->range = anv_buffer_get_range(buffer, offset, range);
/* If we're writing descriptors through a push command, we need to allocate
* the surface state from the command buffer. Otherwise it will be
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index b28d135bff9..5f17351e66a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -837,8 +837,8 @@ anv_CreateBufferView(VkDevice _device,
const uint32_t format_bs = isl_format_get_layout(view->format)->bpb / 8;
view->bo = buffer->bo;
view->offset = buffer->offset + pCreateInfo->offset;
- view->range = pCreateInfo->range == VK_WHOLE_SIZE ?
- buffer->size - pCreateInfo->offset : pCreateInfo->range;
+ view->range = anv_buffer_get_range(buffer, pCreateInfo->offset,
+ pCreateInfo->range);
view->range = align_down_npot_u32(view->range, format_bs);
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 38554166570..5fb0c264f6f 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1082,6 +1082,18 @@ struct anv_buffer {
VkDeviceSize offset;
};
+static inline uint64_t
+anv_buffer_get_range(struct anv_buffer *buffer, uint64_t offset, uint64_t range)
+{
+ assert(offset <= buffer->size);
+ if (range == VK_WHOLE_SIZE) {
+ return buffer->size - offset;
+ } else {
+ assert(range <= buffer->size);
+ return range;
+ }
+}
+
enum anv_cmd_dirty_bits {
ANV_CMD_DIRTY_DYNAMIC_VIEWPORT = 1 << 0, /* VK_DYNAMIC_STATE_VIEWPORT */
ANV_CMD_DIRTY_DYNAMIC_SCISSOR = 1 << 1, /* VK_DYNAMIC_STATE_SCISSOR */