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;
|
struct blorp_batch batch;
|
||||||
blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0);
|
blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0);
|
||||||
|
|
||||||
if (fillSize == VK_WHOLE_SIZE) {
|
fillSize = anv_buffer_get_range(dst_buffer, dstOffset, fillSize);
|
||||||
fillSize = dst_buffer->size - dstOffset;
|
|
||||||
/* Make sure fillSize is a multiple of 4 */
|
/* 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;
|
fillSize &= ~3ull;
|
||||||
}
|
|
||||||
|
|
||||||
/* First, we compute the biggest format that can be used with the
|
/* First, we compute the biggest format that can be used with the
|
||||||
* given offsets and size.
|
* 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
|
/* For buffers with dynamic offsets, we use the full possible range in the
|
||||||
* surface state and do the actual range-checking in the shader.
|
* surface state and do the actual range-checking in the shader.
|
||||||
*/
|
*/
|
||||||
if (bind_layout->dynamic_offset_index >= 0 || range == VK_WHOLE_SIZE)
|
if (bind_layout->dynamic_offset_index >= 0)
|
||||||
bview->range = buffer->size - offset;
|
range = VK_WHOLE_SIZE;
|
||||||
else
|
bview->range = anv_buffer_get_range(buffer, offset, range);
|
||||||
bview->range = range;
|
|
||||||
|
|
||||||
/* If we're writing descriptors through a push command, we need to allocate
|
/* If we're writing descriptors through a push command, we need to allocate
|
||||||
* the surface state from the command buffer. Otherwise it will be
|
* 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;
|
const uint32_t format_bs = isl_format_get_layout(view->format)->bpb / 8;
|
||||||
view->bo = buffer->bo;
|
view->bo = buffer->bo;
|
||||||
view->offset = buffer->offset + pCreateInfo->offset;
|
view->offset = buffer->offset + pCreateInfo->offset;
|
||||||
view->range = pCreateInfo->range == VK_WHOLE_SIZE ?
|
view->range = anv_buffer_get_range(buffer, pCreateInfo->offset,
|
||||||
buffer->size - pCreateInfo->offset : pCreateInfo->range;
|
pCreateInfo->range);
|
||||||
view->range = align_down_npot_u32(view->range, format_bs);
|
view->range = align_down_npot_u32(view->range, format_bs);
|
||||||
|
|
||||||
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
|
if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
|
||||||
|
@@ -1082,6 +1082,18 @@ struct anv_buffer {
|
|||||||
VkDeviceSize offset;
|
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 {
|
enum anv_cmd_dirty_bits {
|
||||||
ANV_CMD_DIRTY_DYNAMIC_VIEWPORT = 1 << 0, /* VK_DYNAMIC_STATE_VIEWPORT */
|
ANV_CMD_DIRTY_DYNAMIC_VIEWPORT = 1 << 0, /* VK_DYNAMIC_STATE_VIEWPORT */
|
||||||
ANV_CMD_DIRTY_DYNAMIC_SCISSOR = 1 << 1, /* VK_DYNAMIC_STATE_SCISSOR */
|
ANV_CMD_DIRTY_DYNAMIC_SCISSOR = 1 << 1, /* VK_DYNAMIC_STATE_SCISSOR */
|
||||||
|
Reference in New Issue
Block a user