summaryrefslogtreecommitdiff
path: root/lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-09-02 05:18:14 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-09-02 05:18:14 +0000
commit5f66494d31f735486b8222ecfa0a0c9046e92543 (patch)
treef699ac8d7f6d510c30bded04f96a1209344f6a47 /lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c
parent17a5b543e3479aaa779cc68345c46d437edd05d8 (diff)
Import Mesa 22.1.7
Diffstat (limited to 'lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c')
-rw-r--r--lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c112
1 files changed, 61 insertions, 51 deletions
diff --git a/lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c b/lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c
index 2f79e4e9c..8b2e16127 100644
--- a/lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c
+++ b/lib/mesa/src/broadcom/vulkan/v3dvx_meta_common.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2021 Raspberry Pi
+ * Copyright © 2021 Raspberry Pi Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,11 +25,10 @@
#include "v3dv_meta_common.h"
#include "broadcom/common/v3d_macros.h"
+#include "broadcom/common/v3d_tfu.h"
#include "broadcom/cle/v3dx_pack.h"
#include "broadcom/compiler/v3d_compiler.h"
-#include "vk_format_info.h"
-
struct rcl_clear_info {
const union v3dv_clear_value *clear_value;
struct v3dv_image *image;
@@ -51,12 +50,14 @@ emit_rcl_prologue(struct v3dv_job *job,
if (job->cmd_buffer->state.oom)
return NULL;
+ assert(!tiling->msaa || !tiling->double_buffer);
cl_emit(rcl, TILE_RENDERING_MODE_CFG_COMMON, config) {
config.early_z_disable = true;
config.image_width_pixels = tiling->width;
config.image_height_pixels = tiling->height;
config.number_of_render_targets = 1;
config.multisample_mode_4x = tiling->msaa;
+ config.double_buffer_in_non_ms_mode = tiling->double_buffer;
config.maximum_bpp_of_all_render_targets = tiling->internal_bpp;
config.internal_depth_type = fb->internal_depth_type;
}
@@ -167,7 +168,11 @@ emit_frame_setup(struct v3dv_job *job,
cl_emit(rcl, STORE_TILE_BUFFER_GENERAL, store) {
store.buffer_to_store = NONE;
}
- if (clear_value && i == 0) {
+ /* When using double-buffering, we need to clear both buffers (unless
+ * we only have a single tile to render).
+ */
+ if (clear_value &&
+ (i == 0 || v3dv_do_double_initial_tile_clear(tiling))) {
cl_emit(rcl, CLEAR_TILE_BUFFERS, clear) {
clear.clear_z_stencil_buffer = true;
clear.clear_all_render_targets = true;
@@ -308,7 +313,15 @@ format_needs_rb_swap(struct v3dv_device *device,
VkFormat format)
{
const uint8_t *swizzle = v3dv_get_format_swizzle(device, format);
- return swizzle[0] == PIPE_SWIZZLE_Z;
+ return v3dv_format_swizzle_needs_rb_swap(swizzle);
+}
+
+static inline bool
+format_needs_reverse(struct v3dv_device *device,
+ VkFormat format)
+{
+ const uint8_t *swizzle = v3dv_get_format_swizzle(device, format);
+ return v3dv_format_swizzle_needs_reverse(swizzle);
}
static void
@@ -374,6 +387,7 @@ emit_image_load(struct v3dv_device *device,
* so we need to make sure we respect the format swizzle.
*/
needs_rb_swap = format_needs_rb_swap(device, framebuffer->vk_format);
+ needs_chan_reverse = format_needs_reverse(device, framebuffer->vk_format);
}
load.r_b_swap = needs_rb_swap;
@@ -431,6 +445,7 @@ emit_image_store(struct v3dv_device *device,
} else if (!is_copy_from_buffer && !is_copy_to_buffer &&
(aspect & VK_IMAGE_ASPECT_COLOR_BIT)) {
needs_rb_swap = format_needs_rb_swap(device, framebuffer->vk_format);
+ needs_chan_reverse = format_needs_reverse(device, framebuffer->vk_format);
}
store.r_b_swap = needs_rb_swap;
@@ -815,78 +830,70 @@ v3dX(meta_emit_copy_image_rcl)(struct v3dv_job *job,
void
v3dX(meta_emit_tfu_job)(struct v3dv_cmd_buffer *cmd_buffer,
- struct v3dv_image *dst,
- uint32_t dst_mip_level,
- uint32_t dst_layer,
- struct v3dv_image *src,
- uint32_t src_mip_level,
- uint32_t src_layer,
+ uint32_t dst_bo_handle,
+ uint32_t dst_offset,
+ enum v3d_tiling_mode dst_tiling,
+ uint32_t dst_padded_height_or_stride,
+ uint32_t dst_cpp,
+ uint32_t src_bo_handle,
+ uint32_t src_offset,
+ enum v3d_tiling_mode src_tiling,
+ uint32_t src_padded_height_or_stride,
+ uint32_t src_cpp,
uint32_t width,
uint32_t height,
const struct v3dv_format *format)
{
- const struct v3d_resource_slice *src_slice = &src->slices[src_mip_level];
- const struct v3d_resource_slice *dst_slice = &dst->slices[dst_mip_level];
-
- assert(dst->mem && dst->mem->bo);
- const struct v3dv_bo *dst_bo = dst->mem->bo;
-
- assert(src->mem && src->mem->bo);
- const struct v3dv_bo *src_bo = src->mem->bo;
-
struct drm_v3d_submit_tfu tfu = {
.ios = (height << 16) | width,
.bo_handles = {
- dst_bo->handle,
- src_bo->handle != dst_bo->handle ? src_bo->handle : 0
+ dst_bo_handle,
+ src_bo_handle != dst_bo_handle ? src_bo_handle : 0
},
};
- const uint32_t src_offset =
- src_bo->offset + v3dv_layer_offset(src, src_mip_level, src_layer);
tfu.iia |= src_offset;
- uint32_t icfg;
- if (src_slice->tiling == V3D_TILING_RASTER) {
- icfg = V3D_TFU_ICFG_FORMAT_RASTER;
+ if (src_tiling == V3D_TILING_RASTER) {
+ tfu.icfg = V3D33_TFU_ICFG_FORMAT_RASTER << V3D33_TFU_ICFG_FORMAT_SHIFT;
} else {
- icfg = V3D_TFU_ICFG_FORMAT_LINEARTILE +
- (src_slice->tiling - V3D_TILING_LINEARTILE);
+ tfu.icfg = (V3D33_TFU_ICFG_FORMAT_LINEARTILE +
+ (src_tiling - V3D_TILING_LINEARTILE)) <<
+ V3D33_TFU_ICFG_FORMAT_SHIFT;
}
- tfu.icfg |= icfg << V3D_TFU_ICFG_FORMAT_SHIFT;
+ tfu.icfg |= format->tex_type << V3D33_TFU_ICFG_TTYPE_SHIFT;
- const uint32_t dst_offset =
- dst_bo->offset + v3dv_layer_offset(dst, dst_mip_level, dst_layer);
- tfu.ioa |= dst_offset;
+ tfu.ioa = dst_offset;
- tfu.ioa |= (V3D_TFU_IOA_FORMAT_LINEARTILE +
- (dst_slice->tiling - V3D_TILING_LINEARTILE)) <<
- V3D_TFU_IOA_FORMAT_SHIFT;
- tfu.icfg |= format->tex_type << V3D_TFU_ICFG_TTYPE_SHIFT;
+ tfu.ioa |= (V3D33_TFU_IOA_FORMAT_LINEARTILE +
+ (dst_tiling - V3D_TILING_LINEARTILE)) <<
+ V3D33_TFU_IOA_FORMAT_SHIFT;
- switch (src_slice->tiling) {
+ switch (src_tiling) {
case V3D_TILING_UIF_NO_XOR:
case V3D_TILING_UIF_XOR:
- tfu.iis |= src_slice->padded_height / (2 * v3d_utile_height(src->cpp));
+ tfu.iis |= src_padded_height_or_stride / (2 * v3d_utile_height(src_cpp));
break;
case V3D_TILING_RASTER:
- tfu.iis |= src_slice->stride / src->cpp;
+ tfu.iis |= src_padded_height_or_stride / src_cpp;
break;
default:
break;
}
+ /* The TFU can handle raster sources but always produces UIF results */
+ assert(dst_tiling != V3D_TILING_RASTER);
+
/* If we're writing level 0 (!IOA_DIMTW), then we need to supply the
* OPAD field for the destination (how many extra UIF blocks beyond
* those necessary to cover the height).
*/
- if (dst_slice->tiling == V3D_TILING_UIF_NO_XOR ||
- dst_slice->tiling == V3D_TILING_UIF_XOR) {
- uint32_t uif_block_h = 2 * v3d_utile_height(dst->cpp);
+ if (dst_tiling == V3D_TILING_UIF_NO_XOR || dst_tiling == V3D_TILING_UIF_XOR) {
+ uint32_t uif_block_h = 2 * v3d_utile_height(dst_cpp);
uint32_t implicit_padded_height = align(height, uif_block_h);
- uint32_t icfg =
- (dst_slice->padded_height - implicit_padded_height) / uif_block_h;
- tfu.icfg |= icfg << V3D_TFU_ICFG_OPAD_SHIFT;
+ uint32_t icfg = (dst_padded_height_or_stride - implicit_padded_height) /
+ uif_block_h;
+ tfu.icfg |= icfg << V3D33_TFU_ICFG_OPAD_SHIFT;
}
v3dv_cmd_buffer_add_tfu_job(cmd_buffer, &tfu);
@@ -1081,6 +1088,9 @@ emit_copy_buffer_to_layer_per_tile_list(struct v3dv_job *job,
uint32_t format = choose_tlb_format(framebuffer, imgrsc->aspectMask,
false, false, true);
+ uint32_t image_layer = layer + (image->vk.image_type != VK_IMAGE_TYPE_3D ?
+ imgrsc->baseArrayLayer : region->imageOffset.z);
+
emit_linear_load(cl, RENDER_TARGET_0, buffer->mem->bo,
buffer_offset, buffer_stride, format);
@@ -1100,13 +1110,13 @@ emit_copy_buffer_to_layer_per_tile_list(struct v3dv_job *job,
if (imgrsc->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) {
emit_image_load(job->device, cl, framebuffer, image,
VK_IMAGE_ASPECT_STENCIL_BIT,
- imgrsc->baseArrayLayer + layer, imgrsc->mipLevel,
+ image_layer, imgrsc->mipLevel,
false, false);
} else {
assert(imgrsc->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT);
emit_image_load(job->device, cl, framebuffer, image,
VK_IMAGE_ASPECT_DEPTH_BIT,
- imgrsc->baseArrayLayer + layer, imgrsc->mipLevel,
+ image_layer, imgrsc->mipLevel,
false, false);
}
}
@@ -1117,20 +1127,20 @@ emit_copy_buffer_to_layer_per_tile_list(struct v3dv_job *job,
/* Store TLB to image */
emit_image_store(job->device, cl, framebuffer, image, imgrsc->aspectMask,
- imgrsc->baseArrayLayer + layer, imgrsc->mipLevel,
+ image_layer, imgrsc->mipLevel,
false, true, false);
if (framebuffer->vk_format == VK_FORMAT_D24_UNORM_S8_UINT) {
if (imgrsc->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) {
emit_image_store(job->device, cl, framebuffer, image,
VK_IMAGE_ASPECT_STENCIL_BIT,
- imgrsc->baseArrayLayer + layer, imgrsc->mipLevel,
+ image_layer, imgrsc->mipLevel,
false, false, false);
} else {
assert(imgrsc->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT);
emit_image_store(job->device, cl, framebuffer, image,
VK_IMAGE_ASPECT_DEPTH_BIT,
- imgrsc->baseArrayLayer + layer, imgrsc->mipLevel,
+ image_layer, imgrsc->mipLevel,
false, false, false);
}
}