cmd_buffer->state.pending_pipe_bits |= ANV_PIPE_RENDER_TARGET_BUFFER_WRITES;
}
-void anv_CmdFillBuffer(
- VkCommandBuffer commandBuffer,
- VkBuffer dstBuffer,
- VkDeviceSize dstOffset,
- VkDeviceSize fillSize,
- uint32_t data)
+void
+anv_cmd_buffer_fill_area(struct anv_cmd_buffer *cmd_buffer,
+ struct anv_address address,
+ VkDeviceSize size,
+ uint32_t data)
{
- ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
- ANV_FROM_HANDLE(anv_buffer, dst_buffer, dstBuffer);
struct blorp_surf surf;
struct isl_surf isl_surf;
struct blorp_batch batch;
anv_blorp_batch_init(cmd_buffer, &batch, 0);
- fillSize = vk_buffer_range(&dst_buffer->vk, 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.
*/
int bs = 16;
- bs = gcd_pow2_u64(bs, dstOffset);
- bs = gcd_pow2_u64(bs, fillSize);
+ uint64_t offset = address.offset;
+ bs = gcd_pow2_u64(bs, offset);
+ bs = gcd_pow2_u64(bs, size);
enum isl_format isl_format = isl_format_for_size(bs);
union isl_color_value color = {
};
const uint64_t max_fill_size = MAX_SURFACE_DIM * MAX_SURFACE_DIM * bs;
- while (fillSize >= max_fill_size) {
- get_blorp_surf_for_anv_buffer(cmd_buffer->device,
- dst_buffer, dstOffset,
- MAX_SURFACE_DIM, MAX_SURFACE_DIM,
- MAX_SURFACE_DIM * bs, isl_format, true,
- &surf, &isl_surf);
+ while (size >= max_fill_size) {
+ get_blorp_surf_for_anv_address(cmd_buffer->device,
+ (struct anv_address) {
+ .bo = address.bo, .offset = offset,
+ },
+ MAX_SURFACE_DIM, MAX_SURFACE_DIM,
+ MAX_SURFACE_DIM * bs, isl_format, true,
+ &surf, &isl_surf);
blorp_clear(&batch, &surf, isl_format, ISL_SWIZZLE_IDENTITY,
0, 0, 1, 0, 0, MAX_SURFACE_DIM, MAX_SURFACE_DIM,
color, 0 /* color_write_disable */);
- fillSize -= max_fill_size;
- dstOffset += max_fill_size;
+ size -= max_fill_size;
+ offset += max_fill_size;
}
- uint64_t height = fillSize / (MAX_SURFACE_DIM * bs);
+ uint64_t height = size / (MAX_SURFACE_DIM * bs);
assert(height < MAX_SURFACE_DIM);
if (height != 0) {
const uint64_t rect_fill_size = height * MAX_SURFACE_DIM * bs;
- get_blorp_surf_for_anv_buffer(cmd_buffer->device,
- dst_buffer, dstOffset,
- MAX_SURFACE_DIM, height,
- MAX_SURFACE_DIM * bs, isl_format, true,
- &surf, &isl_surf);
+ get_blorp_surf_for_anv_address(cmd_buffer->device,
+ (struct anv_address) {
+ .bo = address.bo, .offset = offset,
+ },
+ MAX_SURFACE_DIM, height,
+ MAX_SURFACE_DIM * bs, isl_format, true,
+ &surf, &isl_surf);
blorp_clear(&batch, &surf, isl_format, ISL_SWIZZLE_IDENTITY,
0, 0, 1, 0, 0, MAX_SURFACE_DIM, height,
color, 0 /* color_write_disable */);
- fillSize -= rect_fill_size;
- dstOffset += rect_fill_size;
+ size -= rect_fill_size;
+ offset += rect_fill_size;
}
- if (fillSize != 0) {
- const uint32_t width = fillSize / bs;
- get_blorp_surf_for_anv_buffer(cmd_buffer->device,
- dst_buffer, dstOffset,
- width, 1,
- width * bs, isl_format, true,
- &surf, &isl_surf);
+ if (size != 0) {
+ const uint32_t width = size / bs;
+ get_blorp_surf_for_anv_address(cmd_buffer->device,
+ (struct anv_address) {
+ .bo = address.bo, .offset = offset,
+ },
+ width, 1,
+ width * bs, isl_format, true,
+ &surf, &isl_surf);
blorp_clear(&batch, &surf, isl_format, ISL_SWIZZLE_IDENTITY,
0, 0, 1, 0, 0, width, 1,
}
anv_blorp_batch_finish(&batch);
+}
+
+void anv_CmdFillBuffer(
+ VkCommandBuffer commandBuffer,
+ VkBuffer dstBuffer,
+ VkDeviceSize dstOffset,
+ VkDeviceSize fillSize,
+ uint32_t data)
+{
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
+ ANV_FROM_HANDLE(anv_buffer, dst_buffer, dstBuffer);
+
+ fillSize = vk_buffer_range(&dst_buffer->vk, 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;
+
+ anv_cmd_buffer_fill_area(cmd_buffer,
+ anv_address_add(dst_buffer->address, dstOffset),
+ fillSize, data);
cmd_buffer->state.pending_pipe_bits |= ANV_PIPE_RENDER_TARGET_BUFFER_WRITES;
}