[Mesa-dev] [PATCH 1/4] anv: Add helpers for converting access flags to pipe bits
Nanley Chery
nanleychery at gmail.com
Thu Mar 30 18:35:04 UTC 2017
On Tue, Mar 14, 2017 at 07:55:50AM -0700, Jason Ekstrand wrote:
> ---
> src/intel/vulkan/anv_private.h | 59 ++++++++++++++++++++++++++++++++++++++
> src/intel/vulkan/genX_cmd_buffer.c | 48 ++-----------------------------
> 2 files changed, 62 insertions(+), 45 deletions(-)
>
This patch is
Reviewed-by: Nanley Chery <nanley.g.chery at intel.com>
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index b11adfd..a0eefe3 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -1156,6 +1156,65 @@ enum anv_pipe_bits {
> ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT | \
> ANV_PIPE_INSTRUCTION_CACHE_INVALIDATE_BIT)
>
> +static inline enum anv_pipe_bits
> +anv_pipe_flush_bits_for_access_flags(VkAccessFlags flags)
> +{
> + enum anv_pipe_bits pipe_bits = 0;
> +
> + unsigned b;
> + for_each_bit(b, flags) {
> + switch ((VkAccessFlagBits)(1 << b)) {
> + case VK_ACCESS_SHADER_WRITE_BIT:
> + pipe_bits |= ANV_PIPE_DATA_CACHE_FLUSH_BIT;
> + break;
> + case VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT:
> + pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
> + break;
> + case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT:
> + pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
> + break;
> + case VK_ACCESS_TRANSFER_WRITE_BIT:
> + pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
> + pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
> + break;
> + default:
> + break; /* Nothing to do */
> + }
> + }
> +
> + return pipe_bits;
> +}
> +
> +static inline enum anv_pipe_bits
> +anv_pipe_invalidate_bits_for_access_flags(VkAccessFlags flags)
> +{
> + enum anv_pipe_bits pipe_bits = 0;
> +
> + unsigned b;
> + for_each_bit(b, flags) {
> + switch ((VkAccessFlagBits)(1 << b)) {
> + case VK_ACCESS_INDIRECT_COMMAND_READ_BIT:
> + case VK_ACCESS_INDEX_READ_BIT:
> + case VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT:
> + pipe_bits |= ANV_PIPE_VF_CACHE_INVALIDATE_BIT;
> + break;
> + case VK_ACCESS_UNIFORM_READ_BIT:
> + pipe_bits |= ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT;
> + pipe_bits |= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
> + break;
> + case VK_ACCESS_SHADER_READ_BIT:
> + case VK_ACCESS_INPUT_ATTACHMENT_READ_BIT:
> + case VK_ACCESS_TRANSFER_READ_BIT:
> + pipe_bits |= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
> + break;
> + default:
> + break; /* Nothing to do */
> + }
> + }
> +
> + return pipe_bits;
> +}
> +
> struct anv_vertex_binding {
> struct anv_buffer * buffer;
> VkDeviceSize offset;
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
> index a12bd67..acb59d5 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -920,7 +920,6 @@ void genX(CmdPipelineBarrier)(
> const VkImageMemoryBarrier* pImageMemoryBarriers)
> {
> ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
> - uint32_t b;
>
> /* XXX: Right now, we're really dumb and just flush whatever categories
> * the app asks for. One of these days we may make this a bit better
> @@ -951,50 +950,9 @@ void genX(CmdPipelineBarrier)(
> }
> }
>
> - enum anv_pipe_bits pipe_bits = 0;
> -
> - for_each_bit(b, src_flags) {
> - switch ((VkAccessFlagBits)(1 << b)) {
> - case VK_ACCESS_SHADER_WRITE_BIT:
> - pipe_bits |= ANV_PIPE_DATA_CACHE_FLUSH_BIT;
> - break;
> - case VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT:
> - pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
> - break;
> - case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT:
> - pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
> - break;
> - case VK_ACCESS_TRANSFER_WRITE_BIT:
> - pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
> - pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
> - break;
> - default:
> - break; /* Nothing to do */
> - }
> - }
> -
> - for_each_bit(b, dst_flags) {
> - switch ((VkAccessFlagBits)(1 << b)) {
> - case VK_ACCESS_INDIRECT_COMMAND_READ_BIT:
> - case VK_ACCESS_INDEX_READ_BIT:
> - case VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT:
> - pipe_bits |= ANV_PIPE_VF_CACHE_INVALIDATE_BIT;
> - break;
> - case VK_ACCESS_UNIFORM_READ_BIT:
> - pipe_bits |= ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT;
> - pipe_bits |= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
> - break;
> - case VK_ACCESS_SHADER_READ_BIT:
> - case VK_ACCESS_INPUT_ATTACHMENT_READ_BIT:
> - case VK_ACCESS_TRANSFER_READ_BIT:
> - pipe_bits |= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
> - break;
> - default:
> - break; /* Nothing to do */
> - }
> - }
> -
> - cmd_buffer->state.pending_pipe_bits |= pipe_bits;
> + cmd_buffer->state.pending_pipe_bits |=
> + anv_pipe_flush_bits_for_access_flags(src_flags) |
> + anv_pipe_invalidate_bits_for_access_flags(dst_flags);
> }
>
> static void
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list