From 6b383ca810bb853f11c127d9e1d284dc4dcb0992 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 8 Apr 2024 16:11:04 -0500 Subject: [PATCH] nil: Enforce units via Rust types We add a units generic parameter to Extent4D and Offset4D and then make every helper take and return the right type. The mul and div_* helpers only half-enforce types but it's better than nothing. We leave them non-public so no one outside extent.rs uses them. Reviewed-by: Lina Versace Part-of: --- src/nouveau/nil/cbindgen.toml | 1 - src/nouveau/nil/extent.rs | 255 ++++++++++++++------- src/nouveau/nil/format.rs | 4 +- src/nouveau/nil/image.rs | 46 ++-- src/nouveau/nil/tic.rs | 4 +- src/nouveau/nil/tiling.rs | 35 +-- src/nouveau/vulkan/nvk_cmd_copy.c | 24 +- src/nouveau/vulkan/nvk_cmd_draw.c | 4 +- src/nouveau/vulkan/nvk_descriptor_set.c | 2 +- src/nouveau/vulkan/nvk_image.c | 2 +- src/nouveau/vulkan/nvk_queue_drm_nouveau.c | 12 +- 11 files changed, 238 insertions(+), 151 deletions(-) diff --git a/src/nouveau/nil/cbindgen.toml b/src/nouveau/nil/cbindgen.toml index b9c49b304b858..26c9a402bc9e1 100644 --- a/src/nouveau/nil/cbindgen.toml +++ b/src/nouveau/nil/cbindgen.toml @@ -21,7 +21,6 @@ renaming_overrides_prefixing = true "MAX_LEVELS" = "NIL_MAX_LEVELS" # This is annoying. rename_types doesn't seem to work -"Extent4D" = "nil_extent4d" "Format" = "nil_format" "Image" = "nil_image" "ImageDim" = "nil_image_dim" diff --git a/src/nouveau/nil/extent.rs b/src/nouveau/nil/extent.rs index 5c406b14cb1e6..bef49a701281c 100644 --- a/src/nouveau/nil/extent.rs +++ b/src/nouveau/nil/extent.rs @@ -6,205 +6,284 @@ use crate::image::SampleLayout; use crate::tiling::{gob_height, Tiling, GOB_DEPTH, GOB_WIDTH_B}; use crate::Minify; +pub mod units { + #[derive(Clone, Debug, Copy, PartialEq)] + pub struct Elements {} + + #[derive(Clone, Debug, Copy, PartialEq)] + pub struct Pixels {} + + #[derive(Clone, Debug, Copy, PartialEq)] + pub struct Samples {} + + #[derive(Clone, Debug, Copy, PartialEq)] + pub struct Bytes {} + + #[derive(Clone, Debug, Copy, PartialEq)] + pub struct Tiles {} + + #[derive(Clone, Debug, Copy, PartialEq)] + pub struct GOBs {} +} + #[derive(Clone, Debug, Copy, PartialEq, Default)] #[repr(C)] -pub struct Extent4D { +pub struct Extent4D { pub width: u32, pub height: u32, pub depth: u32, pub array_len: u32, + phantom: std::marker::PhantomData, } -impl Extent4D { +impl Extent4D { pub fn new( width: u32, height: u32, depth: u32, array_len: u32, - ) -> Extent4D { + ) -> Extent4D { Extent4D { width, height, depth, array_len, + phantom: std::marker::PhantomData, } } - pub fn size(&self) -> u32 { - self.width * self.height * self.depth - } - pub fn align(self, alignment: &Self) -> Self { Self { width: self.width.next_multiple_of(alignment.width), height: self.height.next_multiple_of(alignment.height), depth: self.depth.next_multiple_of(alignment.depth), array_len: self.array_len.next_multiple_of(alignment.array_len), + phantom: std::marker::PhantomData, } } - pub fn mul(self, other: Self) -> Self { - Self { + fn mul(self, other: Extent4D) -> Extent4D { + Extent4D { width: self.width * other.width, height: self.height * other.height, depth: self.depth * other.depth, array_len: self.array_len * other.array_len, + phantom: std::marker::PhantomData, } } - pub fn div_ceil(self, other: Self) -> Self { - Self { + fn div_ceil(self, other: Self) -> Extent4D { + Extent4D { width: self.width.div_ceil(other.width), height: self.height.div_ceil(other.height), depth: self.depth.div_ceil(other.depth), array_len: self.array_len.div_ceil(other.array_len), + phantom: std::marker::PhantomData, } } - pub fn px_to_sa(self, sample_layout: SampleLayout) -> Self { + pub fn cast_units(self) -> Extent4D { + Extent4D { + width: self.width, + height: self.height, + depth: self.depth, + array_len: self.array_len, + phantom: std::marker::PhantomData, + } + } +} + +impl Extent4D { + pub fn to_sa( + self, + sample_layout: SampleLayout, + ) -> Extent4D { self.mul(sample_layout.px_extent_sa()) } - #[no_mangle] - pub extern "C" fn nil_extent4d_px_to_el( + pub fn to_el( self, format: Format, sample_layout: SampleLayout, - ) -> Extent4D { - self.px_to_el(format, sample_layout) + ) -> Extent4D { + self.to_sa(sample_layout).div_ceil(format.el_extent_sa()) } - pub fn px_to_el(self, format: Format, sample_layout: SampleLayout) -> Self { - self.px_to_sa(sample_layout).div_ceil(format.el_extent_sa()) + pub fn to_B( + self, + format: Format, + sample_layout: SampleLayout, + ) -> Extent4D { + self.to_el(format, sample_layout).to_B(format) } - pub fn el_to_B(self, format: Format) -> Self { - Self { + pub fn to_tl( + self, + tiling: &Tiling, + format: Format, + sample_layout: SampleLayout, + ) -> Extent4D { + let tl_extent_B = tiling.extent_B(); + self.to_B(format, sample_layout).div_ceil(tl_extent_B) + } +} + +#[no_mangle] +pub extern "C" fn nil_extent4d_px_to_el( + extent_px: Extent4D, + format: Format, + sample_layout: SampleLayout, +) -> Extent4D { + extent_px.to_el(format, sample_layout) +} + +#[no_mangle] +pub extern "C" fn nil_extent4d_px_to_tl( + extent_px: Extent4D, + tiling: &Tiling, + format: Format, + sample_layout: SampleLayout, +) -> Extent4D { + extent_px.to_tl(tiling, format, sample_layout) +} + +impl Extent4D { + pub fn to_px(self, sample_layout: SampleLayout) -> Extent4D { + self.div_ceil(sample_layout.px_extent_sa()) + } +} + +impl Extent4D { + pub fn to_B(self, format: Format) -> Extent4D { + Extent4D { width: self.width * format.el_size_B(), - ..self + ..self.cast_units() } } - pub fn px_to_B(self, format: Format, sample_layout: SampleLayout) -> Self { - self.px_to_el(format, sample_layout) - .el_to_B(format) + + pub fn to_sa(self, format: Format) -> Extent4D { + self.mul(format.el_extent_sa()) + } +} + +impl Extent4D { + pub fn size_B(&self) -> u32 { + self.width * self.height * self.depth } - pub fn B_to_GOB(self, gob_height_is_8: bool) -> Self { - let gob_extent_B = Self { + pub fn to_GOB(self, gob_height_is_8: bool) -> Extent4D { + let gob_extent_B = Extent4D { width: GOB_WIDTH_B, height: gob_height(gob_height_is_8), depth: GOB_DEPTH, array_len: 1, + phantom: std::marker::PhantomData, }; self.div_ceil(gob_extent_B) } - - #[no_mangle] - pub extern "C" fn nil_extent4d_px_to_tl( - self, - tiling: &Tiling, - format: Format, - sample_layout: SampleLayout, - ) -> Self { - self.px_to_tl(tiling, format, sample_layout) - } - - pub fn px_to_tl( - self, - tiling: &Tiling, - format: Format, - sample_layout: SampleLayout, - ) -> Self { - let tl_extent_B = tiling.extent_B(); - self.px_to_B(format, sample_layout).div_ceil(tl_extent_B) - } } #[derive(Clone, Debug, Copy, PartialEq)] #[repr(C)] -pub struct Offset4D { +pub struct Offset4D { pub x: u32, pub y: u32, pub z: u32, pub a: u32, + phantom: std::marker::PhantomData, } -impl Offset4D { - fn div_floor(self, other: Extent4D) -> Self { - Self { +impl Offset4D { + fn div_floor(self, other: Extent4D) -> Offset4D { + Offset4D { x: self.x / other.width, y: self.y / other.height, z: self.z / other.depth, a: self.a / other.array_len, + phantom: std::marker::PhantomData, } } - fn mul(self, other: Extent4D) -> Self { - Self { + fn mul(self, other: Extent4D) -> Offset4D { + Offset4D { x: self.x * other.width, y: self.y * other.height, z: self.z * other.depth, a: self.a * other.array_len, + phantom: std::marker::PhantomData, } } - #[no_mangle] - pub extern "C" fn nil_offset4d_px_to_el( + fn cast_units(self) -> Offset4D { + Offset4D { + x: self.x, + y: self.y, + z: self.z, + a: self.a, + phantom: std::marker::PhantomData, + } + } +} + +impl Offset4D { + pub fn to_el( self, format: Format, sample_layout: SampleLayout, - ) -> Self { - self.px_to_el(format, sample_layout) - } - - pub fn px_to_el(self, format: Format, sample_layout: SampleLayout) -> Self { + ) -> Offset4D { self.mul(sample_layout.px_extent_sa()) .div_floor(format.el_extent_sa()) } - #[no_mangle] - pub extern "C" fn nil_offset4d_px_to_tl( + pub fn to_B( self, - tiling: &Tiling, format: Format, sample_layout: SampleLayout, - ) -> Self { - self.px_to_tl(tiling, format, sample_layout) + ) -> Offset4D { + self.to_el(format, sample_layout).to_B(format) } - pub fn px_to_tl( + pub fn to_tl( self, tiling: &Tiling, format: Format, sample_layout: SampleLayout, - ) -> Self { - self.px_to_B(format, sample_layout) + ) -> Offset4D { + self.to_B(format, sample_layout) .div_floor(tiling.extent_B()) } - - #[no_mangle] - pub extern "C" fn nil_offset4d_px_to_B( - self, - format: Format, - sample_layout: SampleLayout, - ) -> Self { - self.px_to_B(format, sample_layout) - } - - pub fn px_to_B(self, format: Format, sample_layout: SampleLayout) -> Self { - self.px_to_el(format, sample_layout) - .el_to_B(format) - } - - pub fn el_to_B(self, format: Format) -> Self { - let mut offset_B = self; - offset_B.x *= format.el_size_B(); - offset_B - } } -impl Minify for Extent4D { +#[no_mangle] +pub extern "C" fn nil_offset4d_px_to_el( + offset: Offset4D, + format: Format, + sample_layout: SampleLayout, +) -> Offset4D { + offset.to_el(format, sample_layout) +} + +#[no_mangle] +pub extern "C" fn nil_offset4d_px_to_tl( + offset: Offset4D, + tiling: &Tiling, + format: Format, + sample_layout: SampleLayout, +) -> Offset4D { + offset.to_tl(tiling, format, sample_layout) +} + +impl Offset4D { + pub fn to_B(self, format: Format) -> Offset4D { + Offset4D { + x: self.x * format.el_size_B(), + ..self.cast_units() + } + } +} + +impl Minify for Extent4D { fn minify(self, level: u32) -> Self { Self { width: self.width.minify(level), diff --git a/src/nouveau/nil/format.rs b/src/nouveau/nil/format.rs index 323e4a6c23ebf..fefbdb5d46ef7 100644 --- a/src/nouveau/nil/format.rs +++ b/src/nouveau/nil/format.rs @@ -4,7 +4,7 @@ use nil_rs_bindings::*; use nvidia_headers::{cla297, clb097}; -use crate::extent::Extent4D; +use crate::extent::{units, Extent4D}; #[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -45,7 +45,7 @@ impl Format { bits / 8 } - pub(crate) fn el_extent_sa(&self) -> Extent4D { + pub(crate) fn el_extent_sa(&self) -> Extent4D { let desc = self.description(); Extent4D::new(desc.block.width, desc.block.height, desc.block.depth, 1) } diff --git a/src/nouveau/nil/image.rs b/src/nouveau/nil/image.rs index 7d6de3054704b..02f110ea8bf52 100644 --- a/src/nouveau/nil/image.rs +++ b/src/nouveau/nil/image.rs @@ -1,7 +1,7 @@ // Copyright © 2024 Collabora, Ltd. // SPDX-License-Identifier: MIT -use crate::extent::Extent4D; +use crate::extent::{units, Extent4D}; use crate::format::Format; use crate::tiling::Tiling; use crate::Minify; @@ -54,7 +54,7 @@ impl SampleLayout { } } - pub fn px_extent_sa(&self) -> Extent4D { + pub fn px_extent_sa(&self) -> Extent4D { match self { SampleLayout::_1x1 => Extent4D::new(1, 1, 1, 1), SampleLayout::_2x1 => Extent4D::new(2, 1, 1, 1), @@ -66,7 +66,7 @@ impl SampleLayout { } #[no_mangle] - pub extern "C" fn nil_px_extent_sa(self) -> Extent4D { + pub extern "C" fn nil_px_extent_sa(self) -> Extent4D { self.px_extent_sa() } } @@ -76,7 +76,7 @@ impl SampleLayout { pub struct ImageInitInfo { pub dim: ImageDim, pub format: Format, - pub extent_px: Extent4D, + pub extent_px: Extent4D, pub levels: u32, pub samples: u32, pub usage: ImageUsageFlags, @@ -96,7 +96,7 @@ pub struct ImageLevel { pub struct Image { pub dim: ImageDim, pub format: Format, - pub extent_px: Extent4D, + pub extent_px: Extent4D, pub sample_layout: SampleLayout, pub num_levels: u32, pub mip_tail_first_lod: u32, @@ -254,19 +254,20 @@ impl Image { } /// The size in bytes of an extent at a given level. - fn level_extent_B(&self, level: u32) -> Extent4D { - let level_extent_px = self.level_extent_px(level); - let level_extent_el = - level_extent_px.px_to_el(self.format, self.sample_layout); - level_extent_el.el_to_B(self.format) + fn level_extent_B(&self, level: u32) -> Extent4D { + self.level_extent_px(level) + .to_B(self.format, self.sample_layout) } #[no_mangle] - pub extern "C" fn nil_image_level_extent_px(&self, level: u32) -> Extent4D { + pub extern "C" fn nil_image_level_extent_px( + &self, + level: u32, + ) -> Extent4D { self.level_extent_px(level) } - pub fn level_extent_px(&self, level: u32) -> Extent4D { + pub fn level_extent_px(&self, level: u32) -> Extent4D { assert!(level == 0 || self.sample_layout == SampleLayout::_1x1); self.extent_px.minify(level) } @@ -309,13 +310,15 @@ impl Image { } #[no_mangle] - pub extern "C" fn nil_image_level_extent_sa(&self, level: u32) -> Extent4D { + pub extern "C" fn nil_image_level_extent_sa( + &self, + level: u32, + ) -> Extent4D { self.level_extent_sa(level) } - pub fn level_extent_sa(&self, level: u32) -> Extent4D { - let level_extent_px = self.level_extent_px(level); - level_extent_px.px_to_sa(self.sample_layout) + pub fn level_extent_sa(&self, level: u32) -> Extent4D { + self.level_extent_px(level).to_sa(self.sample_layout) } #[no_mangle] @@ -330,7 +333,7 @@ impl Image { if level.tiling.is_tiled { let lvl_tiling_ext_B = level.tiling.extent_B(); - lvl_ext_B.align(&&lvl_tiling_ext_B).size().into() + lvl_ext_B.align(&lvl_tiling_ext_B).size_B().into() } else { assert!(lvl_ext_B.depth == 1); let row_stride = level.row_stride_B * lvl_ext_B.height; @@ -435,7 +438,8 @@ impl Image { image_out.format = uc_format.try_into().unwrap(); image_out.extent_px = lvl_image .extent_px - .px_to_el(lvl_image.format, lvl_image.sample_layout); + .to_el(lvl_image.format, lvl_image.sample_layout) + .cast_units(); image_out } @@ -628,9 +632,9 @@ impl Image { assert!(self.dim == ImageDim::_2D); assert!(self.num_levels == 1); - let extent_in_samples = self.extent_px.px_to_sa(self.sample_layout); + let extent_sa = self.extent_px.to_sa(self.sample_layout); let mut out = self.clone(); - out.extent_px = extent_in_samples; + out.extent_px = extent_sa.cast_units(); out.sample_layout = SampleLayout::_1x1; out } @@ -654,7 +658,7 @@ impl Image { let z_gob = z & ((1 << lvl_tiling.z_log2) - 1); let lvl_extent_tl = - lvl_extent_px.px_to_tl(lvl_tiling, self.format, self.sample_layout); + lvl_extent_px.to_tl(lvl_tiling, self.format, self.sample_layout); let offset_B = u64::from( lvl_extent_tl.width * lvl_extent_tl.height diff --git a/src/nouveau/nil/tic.rs b/src/nouveau/nil/tic.rs index e5350a53f095e..bdab9b315d075 100644 --- a/src/nouveau/nil/tic.rs +++ b/src/nouveau/nil/tic.rs @@ -17,7 +17,7 @@ use nvidia_headers::clc097::PASCAL_A; use paste::paste; use std::ops::Range; -use crate::extent::Extent4D; +use crate::extent::{units, Extent4D}; use crate::format::Format; use crate::image::Image; use crate::image::ImageDim; @@ -211,7 +211,7 @@ fn nil_rs_max_mip_level(image: &Image, view: &View) -> u32 { } } -fn normalize_extent(image: &Image, view: &View) -> Extent4D { +fn normalize_extent(image: &Image, view: &View) -> Extent4D { let mut extent = image.extent_px; match view.view_type { ViewType::_1D diff --git a/src/nouveau/nil/tiling.rs b/src/nouveau/nil/tiling.rs index d4f4571d9bf42..a5198982ce625 100644 --- a/src/nouveau/nil/tiling.rs +++ b/src/nouveau/nil/tiling.rs @@ -1,7 +1,7 @@ // Copyright © 2024 Collabora, Ltd. // SPDX-License-Identifier: MIT -use crate::extent::Extent4D; +use crate::extent::{units, Extent4D}; use crate::format::Format; use crate::image::{ ImageDim, ImageUsageFlags, SampleLayout, IMAGE_USAGE_2D_VIEW_BIT, @@ -38,7 +38,7 @@ impl Tiling { /// Clamps the tiling to less than 2x the given extent in each dimension. /// /// This operation is done by the hardware at each LOD. - pub fn clamp(&self, extent_B: Extent4D) -> Self { + pub fn clamp(&self, extent_B: Extent4D) -> Self { let mut tiling = *self; if !self.is_tiled { @@ -54,7 +54,7 @@ impl Tiling { tiling.x_log2 = 0; } - let extent_GOB = extent_B.B_to_GOB(tiling.gob_height_is_8); + let extent_GOB = extent_B.to_GOB(tiling.gob_height_is_8); let ceil_h = extent_GOB.height.ilog2_ceil() as u8; let ceil_d = extent_GOB.depth.ilog2_ceil() as u8; @@ -74,7 +74,7 @@ impl Tiling { self.size_B() } - pub fn extent_B(&self) -> Extent4D { + pub fn extent_B(&self) -> Extent4D { if self.is_tiled { Extent4D::new( GOB_WIDTH_B << self.x_log2, @@ -89,7 +89,10 @@ impl Tiling { } } -pub fn sparse_block_extent_el(format: Format, dim: ImageDim) -> Extent4D { +pub fn sparse_block_extent_el( + format: Format, + dim: ImageDim, +) -> Extent4D { let bits = format.el_size_B() * 8; // Taken from Vulkan 1.3.279 spec section entitled "Standard Sparse @@ -119,14 +122,17 @@ pub fn sparse_block_extent_px( format: Format, dim: ImageDim, sample_layout: SampleLayout, -) -> Extent4D { +) -> Extent4D { sparse_block_extent_el(format, dim) - .mul(format.el_extent_sa()) - .div_ceil(sample_layout.px_extent_sa()) + .to_sa(format) + .to_px(sample_layout) } -pub fn sparse_block_extent_B(format: Format, dim: ImageDim) -> Extent4D { - sparse_block_extent_el(format, dim).el_to_B(format) +pub fn sparse_block_extent_B( + format: Format, + dim: ImageDim, +) -> Extent4D { + sparse_block_extent_el(format, dim).to_B(format) } #[no_mangle] @@ -134,7 +140,7 @@ pub extern "C" fn nil_sparse_block_extent_px( format: Format, dim: ImageDim, sample_layout: SampleLayout, -) -> Extent4D { +) -> Extent4D { sparse_block_extent_px(format, dim, sample_layout) } @@ -148,7 +154,7 @@ impl Tiling { let gob_height_is_8 = true; let sparse_block_extent_gob = - sparse_block_extent_B.B_to_GOB(gob_height_is_8); + sparse_block_extent_B.to_GOB(gob_height_is_8); Self { is_tiled: true, @@ -160,7 +166,7 @@ impl Tiling { } pub fn choose( - extent_px: Extent4D, + extent_px: Extent4D, format: Format, sample_layout: SampleLayout, usage: ImageUsageFlags, @@ -181,7 +187,6 @@ impl Tiling { tiling.z_log2 = 0; } - let extent_B = extent_px.px_to_B(format, sample_layout); - tiling.clamp(extent_B) + tiling.clamp(extent_px.to_B(format, sample_layout)) } } diff --git a/src/nouveau/vulkan/nvk_cmd_copy.c b/src/nouveau/vulkan/nvk_cmd_copy.c index 3517128957c35..04dc90a93becd 100644 --- a/src/nouveau/vulkan/nvk_cmd_copy.c +++ b/src/nouveau/vulkan/nvk_cmd_copy.c @@ -33,8 +33,8 @@ nvk_cmd_buffer_copy_cls(struct nvk_cmd_buffer *cmd) struct nouveau_copy_buffer { uint64_t base_addr; VkImageType image_type; - struct nil_offset4d offset_el; - struct nil_extent4d extent_el; + struct nil_Offset4D_Elements offset_el; + struct nil_Extent4D_Elements extent_el; uint32_t bpp; uint32_t row_stride; uint32_t array_stride; @@ -48,7 +48,7 @@ struct nouveau_copy { uint8_t comp_size; uint8_t dst[4]; } remap; - struct nil_extent4d extent_el; + struct nil_Extent4D_Elements extent_el; }; static struct nouveau_copy_buffer @@ -65,10 +65,10 @@ nouveau_copy_rect_buffer(struct nvk_buffer *buf, }; } -static struct nil_offset4d +static struct nil_Offset4D_Pixels vk_to_nil_offset(VkOffset3D offset, uint32_t base_array_layer) { - return (struct nil_offset4d) { + return (struct nil_Offset4D_Pixels) { .x = offset.x, .y = offset.y, .z = offset.z, @@ -76,10 +76,10 @@ vk_to_nil_offset(VkOffset3D offset, uint32_t base_array_layer) }; } -static struct nil_extent4d +static struct nil_Extent4D_Pixels vk_to_nil_extent(VkExtent3D extent, uint32_t array_layers) { - return (struct nil_extent4d) { + return (struct nil_Extent4D_Pixels) { .width = extent.width, .height = extent.height, .depth = extent.depth, @@ -93,11 +93,11 @@ nouveau_copy_rect_image(struct nvk_image *img, VkOffset3D offset_px, const VkImageSubresourceLayers *sub_res) { - const struct nil_extent4d lvl_extent4d_px = + const struct nil_Extent4D_Pixels lvl_extent4d_px = nil_image_level_extent_px(&plane->nil, sub_res->mipLevel); offset_px = vk_image_sanitize_offset(&img->vk, offset_px); - const struct nil_offset4d offset4d_px = + const struct nil_Offset4D_Pixels offset4d_px = vk_to_nil_offset(offset_px, sub_res->baseArrayLayer); struct nouveau_copy_buffer buf = { @@ -396,7 +396,7 @@ nvk_CmdCopyBufferToImage2(VkCommandBuffer commandBuffer, vk_image_sanitize_extent(&dst->vk, region->imageExtent); const uint32_t layer_count = vk_image_subresource_layer_count(&dst->vk, ®ion->imageSubresource); - const struct nil_extent4d extent4d_px = + const struct nil_Extent4D_Pixels extent4d_px = vk_to_nil_extent(extent_px, layer_count); const VkImageAspectFlagBits aspects = region->imageSubresource.aspectMask; @@ -503,7 +503,7 @@ nvk_CmdCopyImageToBuffer2(VkCommandBuffer commandBuffer, vk_image_sanitize_extent(&src->vk, region->imageExtent); const uint32_t layer_count = vk_image_subresource_layer_count(&src->vk, ®ion->imageSubresource); - const struct nil_extent4d extent4d_px = + const struct nil_Extent4D_Pixels extent4d_px = vk_to_nil_extent(extent_px, layer_count); const VkImageAspectFlagBits aspects = region->imageSubresource.aspectMask; @@ -614,7 +614,7 @@ nvk_CmdCopyImage2(VkCommandBuffer commandBuffer, vk_image_sanitize_extent(&src->vk, region->extent); const uint32_t layer_count = vk_image_subresource_layer_count(&src->vk, ®ion->srcSubresource); - const struct nil_extent4d extent4d_px = + const struct nil_Extent4D_Pixels extent4d_px = vk_to_nil_extent(extent_px, layer_count); const VkImageAspectFlagBits src_aspects = diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index a3b0c2e7bd055..18d5456fe057a 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -673,7 +673,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, const struct nil_image *nil_image = &image->planes[ip].nil; const struct nil_image_level *level = &nil_image->levels[iview->vk.base_mip_level]; - struct nil_extent4d level_extent_sa = + struct nil_Extent4D_Samples level_extent_sa = nil_image_level_extent_sa(nil_image, iview->vk.base_mip_level); assert(sample_layout == NIL_SAMPLE_LAYOUT_INVALID || @@ -833,7 +833,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, P_IMMD(p, NV9097, SET_ZT_SELECT, 1 /* target_count */); - struct nil_extent4d level_extent_sa = + struct nil_Extent4D_Samples level_extent_sa = nil_image_level_extent_sa(&nil_image, mip_level); /* We use the stride for depth/stencil targets because the Z/S hardware diff --git a/src/nouveau/vulkan/nvk_descriptor_set.c b/src/nouveau/vulkan/nvk_descriptor_set.c index 6879adfff7c5e..5b8851b117ec8 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set.c +++ b/src/nouveau/vulkan/nvk_descriptor_set.c @@ -115,7 +115,7 @@ write_storage_image_view_desc(struct nvk_descriptor_set *set, desc.image_index = view->planes[plane].storage_desc_index; - const struct nil_extent4d px_extent_sa = + const struct nil_Extent4D_Samples px_extent_sa = nil_px_extent_sa(view->planes[plane].sample_layout); desc.sw_log2 = util_logbase2(px_extent_sa.width); desc.sh_log2 = util_logbase2(px_extent_sa.height); diff --git a/src/nouveau/vulkan/nvk_image.c b/src/nouveau/vulkan/nvk_image.c index 133ed699b5319..50eec6be08b54 100644 --- a/src/nouveau/vulkan/nvk_image.c +++ b/src/nouveau/vulkan/nvk_image.c @@ -464,7 +464,7 @@ nvk_fill_sparse_image_fmt_props(VkImageAspectFlags aspects, const enum nil_image_dim dim, const enum nil_sample_layout sample_layout) { - struct nil_extent4d sparse_block_extent_px = + struct nil_Extent4D_Pixels sparse_block_extent_px = nil_sparse_block_extent_px(nil_format(format), dim, sample_layout); assert(sparse_block_extent_px.array_len == 1); diff --git a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c index 63dcb8c169dce..a0087df592a49 100644 --- a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c +++ b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c @@ -163,32 +163,32 @@ push_add_image_plane_bind(struct push_builder *pb, const struct nil_tiling plane_tiling = plane->nil.levels[level].tiling; const uint32_t tile_size_B = nil_tiling_size_B(&plane_tiling); - const struct nil_extent4d bind_extent_px = { + const struct nil_Extent4D_Pixels bind_extent_px = { .width = bind->extent.width, .height = bind->extent.height, .depth = bind->extent.depth, .array_len = 1, }; - const struct nil_offset4d bind_offset_px = { + const struct nil_Offset4D_Pixels bind_offset_px = { .x = bind->offset.x, .y = bind->offset.y, .z = bind->offset.z, .a = layer, }; - const struct nil_extent4d level_extent_px = + const struct nil_Extent4D_Pixels level_extent_px = nil_image_level_extent_px(&plane->nil, level); - const struct nil_extent4d level_extent_tl = + const struct nil_Extent4D_Tiles level_extent_tl = nil_extent4d_px_to_tl(level_extent_px, &plane_tiling, plane->nil.format, plane->nil.sample_layout); /* Convert the extent and offset to tiles */ - struct nil_extent4d bind_extent_tl = + const struct nil_Extent4D_Tiles bind_extent_tl = nil_extent4d_px_to_tl(bind_extent_px, &plane_tiling, plane->nil.format, plane->nil.sample_layout); - struct nil_offset4d bind_offset_tl = + const struct nil_Offset4D_Tiles bind_offset_tl = nil_offset4d_px_to_tl(bind_offset_px, &plane_tiling, plane->nil.format, plane->nil.sample_layout);