mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
nil, nvk: Add plumbing for compression
This lays the groundwork for enabling compression by adding a way to pass in whether the image will be compressed or not from NVK to NIL. Reviewed-by: Mel Henning <mhenning@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38702>
This commit is contained in:
parent
02b4647a1c
commit
21165c7972
5 changed files with 25 additions and 11 deletions
|
|
@ -42,6 +42,7 @@ renaming_overrides_prefixing = true
|
|||
"IMAGE_USAGE_LINEAR_BIT" = "NIL_IMAGE_USAGE_LINEAR_BIT"
|
||||
"IMAGE_USAGE_SPARSE_RESIDENCY_BIT" = "NIL_IMAGE_USAGE_SPARSE_RESIDENCY_BIT"
|
||||
"IMAGE_USAGE_VIDEO_BIT" = "NIL_IMAGE_USAGE_VIDEO_BIT"
|
||||
"IMAGE_USAGE_UNCOMPRESSED_BIT" = "NIL_IMAGE_USAGE_UNCOMPRESSED_BIT"
|
||||
|
||||
[macro_expansion]
|
||||
bitflags = true # We need this for the bitflags crate
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ pub const IMAGE_USAGE_2D_VIEW_BIT: ImageUsageFlags = 1 << 0;
|
|||
pub const IMAGE_USAGE_LINEAR_BIT: ImageUsageFlags = 1 << 1;
|
||||
pub const IMAGE_USAGE_SPARSE_RESIDENCY_BIT: ImageUsageFlags = 1 << 2;
|
||||
pub const IMAGE_USAGE_VIDEO_BIT: ImageUsageFlags = 1 << 3;
|
||||
pub const IMAGE_USAGE_UNCOMPRESSED_BIT: ImageUsageFlags = 1 << 4;
|
||||
|
||||
#[derive(Clone, Debug, Copy, PartialEq, Default)]
|
||||
#[repr(u8)]
|
||||
|
|
@ -181,9 +182,9 @@ pub struct Image {
|
|||
pub array_stride_B: u64,
|
||||
pub align_B: u32,
|
||||
pub size_B: u64,
|
||||
pub compressed: bool,
|
||||
pub tile_mode: u16,
|
||||
pub pte_kind: u8,
|
||||
pub compressed_pte_kind: u8,
|
||||
}
|
||||
|
||||
impl Image {
|
||||
|
|
@ -282,9 +283,9 @@ impl Image {
|
|||
array_stride_B: 0,
|
||||
align_B,
|
||||
size_B,
|
||||
compressed: false,
|
||||
tile_mode: 0,
|
||||
pte_kind: 0,
|
||||
compressed_pte_kind: 0,
|
||||
mip_tail_first_lod: 0,
|
||||
};
|
||||
image.levels[0] = level0;
|
||||
|
|
@ -366,9 +367,9 @@ impl Image {
|
|||
array_stride_B: 0,
|
||||
align_B: 0,
|
||||
size_B: 0,
|
||||
compressed: false,
|
||||
tile_mode: 0,
|
||||
pte_kind: 0,
|
||||
compressed_pte_kind: 0,
|
||||
mip_tail_first_lod: 0,
|
||||
};
|
||||
|
||||
|
|
@ -432,12 +433,12 @@ impl Image {
|
|||
image.align_B = std::cmp::max(image.align_B, 1 << 16);
|
||||
}
|
||||
|
||||
image.pte_kind = Self::choose_pte_kind(
|
||||
dev,
|
||||
info.format,
|
||||
info.samples,
|
||||
image.compressed,
|
||||
);
|
||||
image.pte_kind =
|
||||
Self::choose_pte_kind(dev, info.format, info.samples, false);
|
||||
if (info.usage & IMAGE_USAGE_UNCOMPRESSED_BIT) == 0 {
|
||||
image.compressed_pte_kind =
|
||||
Self::choose_pte_kind(dev, info.format, info.samples, true);
|
||||
}
|
||||
|
||||
if info.modifier != DRM_FORMAT_MOD_INVALID {
|
||||
let bl_mod = BlockLinearModifier::try_from(info.modifier).unwrap();
|
||||
|
|
|
|||
|
|
@ -1190,7 +1190,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
|
|||
P_NV9097_SET_COLOR_TARGET_LAYER(p, i, 0);
|
||||
}
|
||||
|
||||
P_IMMD(p, NV9097, SET_COLOR_COMPRESSION(i), nil_image->compressed);
|
||||
P_IMMD(p, NV9097, SET_COLOR_COMPRESSION(i), image->is_compressed);
|
||||
} else {
|
||||
P_MTHD(p, NV9097, SET_COLOR_TARGET_A(i));
|
||||
P_NV9097_SET_COLOR_TARGET_A(p, i, 0);
|
||||
|
|
@ -1280,7 +1280,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
|
|||
|
||||
P_IMMD(p, NV9097, SET_ZT_LAYER, base_array_layer);
|
||||
|
||||
P_IMMD(p, NV9097, SET_Z_COMPRESSION, nil_image.compressed);
|
||||
P_IMMD(p, NV9097, SET_Z_COMPRESSION, image->is_compressed);
|
||||
|
||||
if (nvk_cmd_buffer_3d_cls(cmd) >= MAXWELL_B) {
|
||||
P_IMMD(p, NVC597, SET_ZT_SPARSE, {
|
||||
|
|
|
|||
|
|
@ -817,6 +817,9 @@ nvk_image_init(struct nvk_device *dev,
|
|||
VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR))
|
||||
usage |= NIL_IMAGE_USAGE_VIDEO_BIT;
|
||||
|
||||
if (!image->can_compress)
|
||||
usage |= NIL_IMAGE_USAGE_UNCOMPRESSED_BIT;
|
||||
|
||||
uint32_t explicit_row_stride_B = 0;
|
||||
|
||||
/* This section is removed by the optimizer for non-ANDROID builds */
|
||||
|
|
|
|||
|
|
@ -103,6 +103,15 @@ struct nvk_image {
|
|||
*/
|
||||
struct nvk_image_plane linear_tiled_shadow;
|
||||
struct nvkmd_mem *linear_tiled_shadow_mem;
|
||||
|
||||
/* This indicates that we would like to compress the image and would prefer
|
||||
* larger pages and a dedicated allocation.
|
||||
*/
|
||||
bool can_compress;
|
||||
/* This indicates that we actually have compressed the image. This is set at
|
||||
* bind time.
|
||||
*/
|
||||
bool is_compressed;
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue