anv: Add a helper for working with VK_WHOLE_SIZE for buffers
Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
This commit is contained in:
@@ -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.
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user