rt: cube array textures and views, with imageCubeArray in the floor

A cube array texture (`MTLTextureTypeCubeArray`) is built: an image cube-compatible with six of
its layers a cube (`arrayLength` times six layers), whose shader view is
`VK_IMAGE_VIEW_TYPE_CUBE_ARRAY`. Metal's casts with a cube array
(`makeTextureView(pixelFormat:textureType:levels:slices:)`) are built in the same form: a cube
array's subrange of whole cubes, its faces as a 2D texture (one face) or a 2D array (any faces),
six of its faces as a cube, a cube as a cube array of one cube, and a multiple of six slices of a
square 2D array as a cube array where its image is cube-compatible. A pass resolves into a
one-sample colour cube array as into a cube (`Plan::resolves`), and a layered pass renders a cube
array's faces across its cubes (the attachment view of its layers, as for a cube).

`imageCubeArray` joins the floor's required features. Every probed device reports it (vulkaninfo
dumps m3-max-48727 to 48731, 48736, 48737 and 61508: the RX 7900 XTX, every 780M, the RTX 2080,
the RTX 3090, the RTX 5080 Laptop, the Iris Xe, lavapipe, the UHD 630's Windows driver,
KosmicKrisp and the RX 550), and Vulkan 1.4 and Roadmap 2022 require it of every device. A device
without it gets the floor's refusal. The runtime-floor profile and its generator state it
(check_device_profiles: 0 findings), and the floor's missing-feature test has its case.

`Gap::CubeArrayTexture` is deleted (the consumer's checkout at 9bb622a2c2: 0 hits); REFUSALS is
regenerated and the API table loses the variant. The runtime README's texture and view lines,
its resolve line and its floor table say what is built.

Tests, each on every device of the cfg's kind: `tests::texture` round-trips a cube array's last
face (its second cube's); `tests::view` casts a cube as a cube array of one cube, reporting
Metal's array length 1; `tests::cube_views` samples a two-cube `RGBA32Float` cube array at its
second cube and a cube view of its first six faces through the owned fixture
`unk_cube_grad_lod`, every lane reading its face's slice, with `imageCubeArray` enabled; and
`tests::layered` renders a cube array's slices 4 to 9, across both its cubes (the cube-array
layered case, as the layered change landed first).

The conformance ledger's cube array rows and the runtime-floor contexts' opened chains follow in
the next commits.
This commit is contained in:
Anees Iqbal committed 2026-11-21 00:19:34 -08:00
1 parent b71567aca4
commit 7cd1103a44
15 files changed
+295 -123

No files matched your search

@@ -10,10 +10,10 @@
//! | `texture-view-casts-2d-as-2d-array` | a 2D texture | a 2D array of levels 1 and 2, its one slice |
//! | `texture-view-casts-2d-array-as-cube` | a 2D array of eight slices | a cube of levels 1 and 2, slices 1 to 6 |
//!
//! These are the casts of Apple's table (`makeTextureView(pixelFormat:textureType:levels:slices:)`)
//! that metal2vulkan-runtime builds of another type than the parent's: those a cube or a 2D texture
//! makes with nothing new at its make, and a square 2D array's cube of six slices, whose image rt
//! makes cube-compatible; a cube array, and a view as one, is a gap of its own there.
//! These are casts of Apple's table (`makeTextureView(pixelFormat:textureType:levels:slices:)`) of
//! another type than the parent's: those a cube or a 2D texture makes with nothing new at its make,
//! and a square 2D array's cube of six slices, whose image metal2vulkan-runtime makes
//! cube-compatible. No case here casts a cube array or views a texture as one.
//!
//! Every parent is `RGBA16Float`, 8 by 8 texels at level 0, of three levels, `Private`, of
//! render-target and shader-read usage; a cube's slices are its faces, as Metal counts a view's
+21 -19
View File
@@ -1180,10 +1180,10 @@ made, with no lock, and never rewritten for layouts.
sample counts it is `Limit::TextureSize` or `Limit::TextureSamples`.
- Refused as Metal refuses each descriptor (`Refusal::TextureZeroExtent`,
`TextureExtentForType`, `TextureCubeNotSquare`, `TextureArrayLength`, `TextureLevelCount`,
`TextureSampleCount`, `TextureSwizzleWithWrites`). Texture buffers (`Gap::TextureBuffer`),
cube array textures (`Gap::CubeArrayTexture`: their view needs Vulkan's `imageCubeArray`, which
the floor does not require, and no replay stream makes one) and Memoryless storage
(`Gap::MemorylessTexture`) are not built.
`TextureSampleCount`, `TextureSwizzleWithWrites`). Texture buffers (`Gap::TextureBuffer`)
and Memoryless storage (`Gap::MemorylessTexture`) are not built. A cube array texture's image
is cube-compatible with six layers a cube, and its view is a cube array view (`imageCubeArray`,
in the floor).
- `Texture::gpu_resource_id` is its index (0 without one) and the translator's `TextureWord` of
its format and swizzle (`docs/RESOURCE-ID.md`), so the guest computes the ID itself.
- `Texture::replace_region` and `Texture::get_bytes` take a Shared or Managed texture
@@ -1344,10 +1344,11 @@ made, with no lock, and never rewritten for layouts.
`replace_region` and `get_bytes` through it reach the parent's levels and slices under it, and a
view of a Managed texture names the parent's bytes of them; its hazards are its parent's. Built:
the parent's own pixel format, over every slice in the parent's type, a slice subrange of a 1D
or 2D array, a 2D texture as a 2D array of its one slice, one slice of a 2D array as a 2D
texture, and a cube's faces as a 2D texture (one face) or a 2D array (any faces), each over any
level subrange; a view of a view is a view of the first parent. A view as a cube array is
`Gap::CubeArrayTexture`, as a cube array texture is. Refused, as Metal's validation
or 2D array or of a cube array's cubes, a 2D texture as a 2D array of its one slice, one slice
of a 2D array as a 2D texture, a cube's or a cube array's faces as a 2D texture (one face) or a
2D array (any faces), six of a cube array's faces as a cube, and a cube as a cube array of one
cube, each over any level subrange; a view of a view is a view of the first parent. Refused, as
Metal's validation
stops them: an empty range of levels or slices, or one past the parent's
(`Refusal::TextureViewRange`), a slice count the view's type does not take
(`Refusal::TextureViewSlices`), and another pixel format of a texture made without
@@ -1468,9 +1469,9 @@ made, with no lock, and never rewritten for layouts.
another texture type than the casts built above, some of a 2D multisample array's slices, and a
cube view of a 2D array whose image is not cube-compatible (`TextureViewKind::CubeOfArray`): a
square 2D array of six slices or more is made cube-compatible where the device's image format
query takes the flag for its format and usage, and its cube views of six slices are built; a
non-square array's image is not. A view as a cube array stays `Gap::CubeArrayTexture`, as its
view needs `imageCubeArray`, which the floor does not require. A view of a pixel format Metal does not
query takes the flag for its format and usage, and its cube views of six slices and cube array
views of a multiple of six are built; a non-square array's image is not. A view of a pixel
format Metal does not
view the texture as is `Refusal::TextureViewFormat`.
- A swizzle reaches a texture's sampled element alone, as Apple defines it for reads and
samples. A swizzled texture, or a view made with a swizzle or of a swizzled texture, has a
@@ -3030,14 +3031,14 @@ or does not check is rebuilt from the generations' names, with young counted ful
`independentResolve` and `independentResolveNone` allow. The resolve texture takes the
attachment's pixel format and one sample, and its level the attachment level's width and
height. Metal resolves into a texture of any usage, and so does the runtime into a one-sample
colour texture, 2D, a 2D array or a cube, whose image is optimal: such a texture takes the
attachment usage on every device where its format renders, whatever Metal's usage. A resolve
into a texture made without `RenderTarget` usage whose image has no attachment usage is a known
gap (`RenderPassKind::ResolveUsage`): a depth or stencil texture, a colour texture of another
type or of a format the device's optimal image does not render, and a texture over a buffer in
place, whose linear image takes no attachment usage for a resolve alone. Refused as Metal
refuses it: a resolving action with no resolve texture (`Refusal::ResolveTexture`, also where an
encoder sets it later) and an integer format's resolve (`Refusal::ResolveFormat`).
colour texture, 2D, a 2D array, a cube or a cube array, whose image is optimal: such a texture
takes the attachment usage on every device where its format renders, whatever Metal's usage. A
resolve into a texture made without `RenderTarget` usage whose image has no attachment usage is a
known gap (`RenderPassKind::ResolveUsage`): a depth or stencil texture, a colour texture of
another type or of a format the device's optimal image does not render, and a texture over a
buffer in place, whose linear image takes no attachment usage for a resolve alone. Refused as
Metal refuses it: a resolving action with no resolve texture (`Refusal::ResolveTexture`, also
where an encoder sets it later) and an integer format's resolve (`Refusal::ResolveFormat`).
`Metrics::resolves` counts the attachments passes resolved.
- A depth attachment is loaded, cleared and stored as a color attachment is, its clear depth a
`float`: an optimal image in its real layout, of the Vulkan format the translator's format table
@@ -3632,6 +3633,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
| `logicOp` | `VkPhysicalDeviceFeatures` | a render pipeline's logic operation (private render state), the device's own; without it the fragment function would compute it, which needs fragment interlock or raster-order attachment access |
| `bresenhamLines` | `VkPhysicalDeviceLineRasterizationFeaturesEXT` | a line drawn by Metal's rule, the pixels whose diamond it exits (`VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT`), where Vulkan's default rule is the device's own: the rectangle of the line's width on a device whose `strictLines` is set (lavapipe, NVIDIA's driver); Vulkan 1.4 requires it |
| `fullDrawIndexUint32` | `VkPhysicalDeviceFeatures` | an indexed draw's 32-bit indices past `2^24 - 1`; Vulkan 1.4 and Roadmap 2022 require it |
| `imageCubeArray` | `VkPhysicalDeviceFeatures` | a cube array texture and a view as one, a cube array image view; Vulkan 1.4 and Roadmap 2022 require it |
| `depthBiasClamp` | `VkPhysicalDeviceFeatures` | a depth bias's clamp (`set_depth_bias`), the device's own; Vulkan 1.4 and Roadmap 2022 require it |
| `drawIndirectFirstInstance` | `VkPhysicalDeviceFeatures` | an indirect draw's base instance, which the GPU reads from Metal's arguments; Vulkan 1.4 requires it |
| `depthClamp` | `VkPhysicalDeviceFeatures` | the depth clip mode `Clamp` (`set_depth_clip_mode`), a pipeline's depth clamp, the device's own; Vulkan 1.4 and Roadmap 2022 require it |
+19 -25
View File
@@ -1020,11 +1020,6 @@ pub enum Gap {
/// guest render functions declare one in an argument buffer, validation's
/// texture_buffer_member).
TextureBuffer,
/// A cube array texture (`MTLTextureTypeCubeArray`), and so a view of one: its image view
/// needs Vulkan's `imageCubeArray`, which the floor does not require.
///
/// Basis: ours (no replay stream makes a cube array texture or view; built when one does).
CubeArrayTexture,
/// A texture of a pixel format the runtime makes no image of on this device for the
/// descriptor's usage: the device's format query lacks the format or one of the usages, or
/// the format's texels need a conversion in the shader that the translator's identity domains
@@ -1535,26 +1530,26 @@ pub enum RenderPassKind {
Resolve,
/// A resolve into a texture made without `RenderTarget` usage (and not of Metal's unknown
/// usage) whose image has no attachment usage: a depth or stencil texture; a colour texture of
/// a type but 2D, a 2D array or a cube, or whose format the device's optimal image does not
/// render, by its format features or its image format query at the texture's extent; or a
/// texture over a buffer whose linear image lies in place, which takes no attachment usage for
/// a resolve alone, so it stays in place and is never copied to gain one. Metal resolves into a
/// texture of any usage: probe `resolve_texture_usage.m` in the conformance crate (an Apple M3
/// Max, macOS 27.0.1, job m3-max-59768) resolved a 4-sample `BGRA8Unorm_sRGB` attachment into a
/// texture of `ShaderRead` usage and of `ShaderRead | ShaderWrite` usage, plain and under
/// Metal's validation layer, each reading the texels of a `RenderTarget` one. Vulkan resolves
/// only into a view with the attachment usage
/// a type but 2D, a 2D array, a cube or a cube array, or whose format the device's optimal
/// image does not render, by its format features or its image format query at the texture's
/// extent; or a texture over a buffer whose linear image lies in place, which takes no
/// attachment usage for a resolve alone, so it stays in place and is never copied to gain one.
/// Metal resolves into a texture of any usage: probe `resolve_texture_usage.m` in the
/// conformance crate (an Apple M3 Max, macOS 27.0.1, job m3-max-59768) resolved a 4-sample
/// `BGRA8Unorm_sRGB` attachment into a texture of `ShaderRead` usage and of `ShaderRead |
/// ShaderWrite` usage, plain and under Metal's validation layer, each reading the texels of a
/// `RenderTarget` one. Vulkan resolves only into a view with the attachment usage
/// (VUID-VkRenderingInfo-colorAttachmentCount-09476), so every one-sample colour texture of an
/// optimal image, 2D, a 2D array or a cube, takes that usage on every device where its format
/// renders, whatever Metal's usage. It grows memory on RADV: of optimal `RGBA8Unorm`,
/// `BGRA8Unorm_sRGB`, `RGBA16Float`, `R32Float` and `RG11B10Float` images of 256 x 256 and 1920
/// x 1080, one level and a full chain, with `ShaderRead` and `ShaderRead | ShaderWrite` usage,
/// adding the attachment usage grows the size of 18 of 36 on the Radeon 780M (every 1920 x 1080
/// one; `RGBA8Unorm` of one level from 8,847,360 to 8,896,512 bytes, 1.0056 times) and 14 of 36
/// on the RX 550 (8,847,360 to 8,882,200), alignments equal, and none on the Iris Xe, the RTX
/// 3090, llvmpipe or KosmicKrisp (jobs m3-max-59774, m3-max-59775 and m3-max-59776). No depth
/// format was measured, so a depth or stencil texture takes no attachment usage for a resolve
/// alone.
/// optimal image, 2D, a 2D array, a cube or a cube array, takes that usage on every device
/// where its format renders, whatever Metal's usage. It grows memory on RADV: of optimal
/// `RGBA8Unorm`, `BGRA8Unorm_sRGB`, `RGBA16Float`, `R32Float` and `RG11B10Float` images of 256
/// x 256 and 1920 x 1080, one level and a full chain, with `ShaderRead` and `ShaderRead |
/// ShaderWrite` usage, adding the attachment usage grows the size of 18 of 36 on the Radeon
/// 780M (every 1920 x 1080 one; `RGBA8Unorm` of one level from 8,847,360 to 8,896,512 bytes,
/// 1.0056 times) and 14 of 36 on the RX 550 (8,847,360 to 8,882,200), alignments equal, and
/// none on the Iris Xe, the RTX 3090, llvmpipe or KosmicKrisp (jobs m3-max-59774, m3-max-59775
/// and m3-max-59776). No depth format was measured, so a depth or stencil texture takes no
/// attachment usage for a resolve alone.
ResolveUsage,
/// A depth or stencil resolve the device's resolve modes do not offer
/// (`VkPhysicalDeviceDepthStencilResolveProperties`): a depth attachment's `Min` or `Max`
@@ -2308,7 +2303,6 @@ impl fmt::Display for Gap {
"a grid of {threads_per_grid:?} threads in threadgroups of {threads_per_threadgroup:?} ends in partial threadgroups, which this kernel's variant does not run"
),
Gap::MemorylessTexture => f.write_str("Memoryless textures are not built"),
Gap::CubeArrayTexture => f.write_str("cube array textures are not built"),
Gap::CubicSampler => f.write_str("cubic sampler filters are not built"),
Gap::LodClamps => f.write_str(
"a sampler state's bind-time LOD clamps that read otherwise than its own are not built",
+4
View File
@@ -436,6 +436,10 @@ pub(crate) const REQUIRED: &[Feature] = &[
// An indexed draw's 32-bit indices past `2^24 - 1`, which Metal draws. Vulkan 1.4 and
// Roadmap 2022 require it of every device.
feature!(core.full_draw_index_uint32 => FullDrawIndexUint32),
// A cube array texture (`MTLTextureTypeCubeArray`) and a view as one, whose image view is
// `VK_IMAGE_VIEW_TYPE_CUBE_ARRAY`, sampled and read by the translator's shaders. Vulkan 1.4 and
// Roadmap 2022 require it of every device.
feature!(core.image_cube_array => ImageCubeArray),
// A depth bias's clamp (`setDepthBias:slopeScale:clamp:`), the device's own, set as dynamic
// state. Vulkan 1.4 and Roadmap 2022 require it of every device.
feature!(core.depth_bias_clamp),
@@ -12,7 +12,13 @@
//! level counts, have the memory requirements with the flag that they have without it, wherever
//! the device makes both.
//!
//! `llvm-as` assembles the fixture; without it the sampling test skips visibly.
//! A cube array texture (`imageCubeArray`, in the floor) is sampled as one, and Metal's cast of its
//! first six faces as a cube is a cube view of its image: the owned fixture `unk_cube_grad_lod`
//! samples the cube view and the array's second cube at two directions on each face, and over a
//! cube array of two cubes whose slice `s` holds `s` in every texel, each lane reads its face from
//! the view and six past it from the array.
//!
//! `llvm-as` assembles the fixtures; without it the sampling tests skip visibly.
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
mod on_device {
@@ -24,6 +30,7 @@ mod on_device {
TextureType, TextureUsage, TextureViewKind,
};
use ash::vk;
use metal2vulkan::device::VkFeature;
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
/// The array's side, and its slices.
@@ -34,15 +41,15 @@ mod on_device {
/// The constexpr sampler's index the test gives `tvc_cube`.
const CONSTEXPR: u32 = 1;
/// The fixture's library, or None where `llvm-as` is missing.
fn library() -> Option<Library> {
match llvm_assemble(&engine_dir().join("tvc_samples.ll")) {
/// The engine fixture `file`'s library, or None where `llvm-as` is missing.
fn library(file: &str) -> Option<Library> {
match llvm_assemble(&engine_dir().join(file)) {
Ok(bitcode) => Some(Library::from_air(&bitcode).expect("the library")),
Err(AssembleError::Missing(why)) => {
eprintln!("SKIPPED: {why}");
None
}
Err(error) => panic!("tvc_samples.ll: {error:?}"),
Err(error) => panic!("{file}: {error:?}"),
}
}
@@ -58,7 +65,7 @@ mod on_device {
#[test]
fn every_device_samples_a_cube_view_of_six_slices_of_a_2d_array_as_its_faces() {
let Some(library) = library() else {
let Some(library) = library("tvc_samples.ll") else {
return;
};
each_device("cube view of a 2D array", |name, _, device| {
@@ -204,6 +211,152 @@ mod on_device {
});
}
/// The two directions `unk_cube_grad_lod` samples on each face, `in[face]` and `in[6 + face]`
/// (faces +x, -x, +y, -y, +z, -z), each with the face's axis its major one.
const DIRECTIONS: [[f32; 3]; 12] = [
[1.0, 0.0, 0.0],
[-1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, -1.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 0.0, -1.0],
[1.0, 0.25, -0.5],
[-1.0, -0.5, 0.25],
[0.25, 1.0, -0.5],
[-0.5, -1.0, 0.25],
[0.25, -0.5, 1.0],
[-0.5, 0.25, -1.0],
];
#[test]
fn every_device_samples_a_cube_array_and_a_cube_view_of_its_first_cube() {
let Some(library) = library("unk_cube_grad_lod.ll") else {
return;
};
each_device("cube array", |name, _, device| {
let enabled = &device.core().translator.profile().enabled().features;
assert!(
enabled.contains(&VkFeature::ImageCubeArray),
"{name}: imageCubeArray, which the floor requires"
);
let function = library.function("unk_cube_grad_lod").expect("the kernel");
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
FunctionDescriptor::new(function),
));
let _samplers = (device.grant_indices(IndexClass::Sampler, CONSTEXPR, 1))
.unwrap_or_else(|error| panic!("{name}: {error}"));
let _textures = (device.grant_indices(IndexClass::Texture, 1, 2))
.unwrap_or_else(|error| panic!("{name}: {error}"));
let state = (device.new_compute_pipeline_state(&descriptor, |samplers| {
assert!(
matches!(samplers, [NumberedSampler::Constexpr(_)]),
"{name}: {samplers:?}"
);
Ok(vec![CONSTEXPR])
}))
.unwrap_or_else(|error| panic!("{name}: {error}"));
let mut d = TextureDescriptor::new(
TextureType::CubeArray,
PixelFormat::RGBA32Float,
SIDE,
SIDE,
);
d.array_length = 2;
d.usage = TextureUsage::SHADER_READ;
d.storage_mode = StorageMode::Shared;
let cubes = (device.new_texture(&d, Some(1)))
.unwrap_or_else(|error| panic!("{name}: the cube array: {error}"));
let region = Region {
origin: [0; 3],
size: [SIDE, SIDE, 1],
};
let row = u64::from(SIDE * 16);
for slice in 0..12 {
let texels: Vec<f32> = (0..SIDE * SIDE)
.flat_map(|_| [slice as f32, 0.0, 0.0, 1.0])
.collect();
let bytes = floats(&texels);
(cubes.replace_region(
region,
0,
slice,
crate::HostBytes::from(&bytes[..]),
row,
row * u64::from(SIDE),
))
.unwrap_or_else(|error| panic!("{name}: slice {slice}: {error}"));
}
let cube = (cubes.new_texture_view(
PixelFormat::RGBA32Float,
TextureType::Cube,
0..1,
0..6,
Some(2),
))
.unwrap_or_else(|error| panic!("{name}: the cube view: {error}"));
assert_eq!(
(
cubes.descriptor().array_length,
cube.descriptor().texture_type
),
(2, TextureType::Cube),
"{name}: the descriptors"
);
// The directions, then the six gradient axes, then the gradient's magnitude: 0, so
// every lane samples level 0.
let mut input: Vec<f32> = (DIRECTIONS.iter())
.flat_map(|&[x, y, z]| [x, y, z, 0.0])
.collect();
for axis in 0..6 {
let mut g = [0.0; 4];
g[axis / 2] = if axis % 2 == 0 { 1.0 } else { -1.0 };
input.extend(g);
}
input.extend([0.0; 4]);
const LANES: usize = 72;
let mut buffers = Buffers::new(&device);
let at = buffers.of(&device, &floats(&input));
let out = buffers.of(&device, &vec![0; LANES * 16]);
let queue = device.new_command_queue(1).expect("a queue");
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder =
(command_buffer.compute_command_encoder(DispatchType::Serial)).expect("an encoder");
encoder
.set_compute_pipeline_state(&state)
.expect("the state");
encoder.set_texture(Some(&cube), 0).expect("the cube view");
encoder
.set_texture(Some(&cubes), 1)
.expect("the cube array");
encoder.set_buffer(Some(&at), 0, 0).expect("in");
encoder.set_buffer(Some(&out), 0, 1).expect("out");
(encoder.dispatch_threadgroups([3, 1, 1], [24, 1, 1]))
.unwrap_or_else(|error| panic!("{name}: {error}"));
encoder.end_encoding();
command_buffer.commit().expect("a commit");
finished(name, &command_buffer);
assert_eq!(command_buffer.error(), None, "{name}");
let contents = out.contents().expect("a Shared buffer");
// SAFETY: the dispatch that wrote the buffer completed, and its writes reach the host.
let samples =
unsafe { std::slice::from_raw_parts(contents.as_ptr().cast::<[f32; 4]>(), LANES) };
for (lane, sample) in samples.iter().enumerate() {
let face = (lane % 6) as f32;
assert_eq!(
*sample,
[face, 6.0 + face, face, 6.0 + face],
"{name}: lane {lane}: the view's face, then the second cube's"
);
}
drop((cube, cubes, command_buffer));
println!(
"{name}: imageCubeArray enabled; {LANES} lanes sampled a cube array of two \
{SIDE} x {SIDE} cubes at its second cube and a cube view of its first, each \
the face's slice"
);
});
}
/// Each format kind's image: its name, format, usage and the formats a mutable one lists.
type Kind = (
&'static str,
@@ -63,6 +63,7 @@ fn at_the_floor() -> Queried {
features.core.alpha_to_one = vk::TRUE;
features.core.logic_op = vk::TRUE;
features.core.full_draw_index_uint32 = vk::TRUE;
features.core.image_cube_array = vk::TRUE;
features.core.depth_bias_clamp = vk::TRUE;
features.core.draw_indirect_first_instance = vk::TRUE;
features.core.depth_clamp = vk::TRUE;
@@ -373,7 +374,7 @@ fn each_missing_feature_is_named() {
const CORE: &str = "VkPhysicalDeviceFeatures";
const ROBUSTNESS2: &str = "VkPhysicalDeviceRobustness2FeaturesEXT";
type Clear = fn(&mut Features);
let cases: [(Clear, Missing); 56] = [
let cases: [(Clear, Missing); 57] = [
(
|f| f.vulkan12.buffer_device_address = vk::FALSE,
feature(V12, "bufferDeviceAddress"),
@@ -569,6 +570,10 @@ fn each_missing_feature_is_named() {
|f| f.core.full_draw_index_uint32 = vk::FALSE,
feature(CORE, "fullDrawIndexUint32"),
),
(
|f| f.core.image_cube_array = vk::FALSE,
feature(CORE, "imageCubeArray"),
),
(
|f| f.core.depth_bias_clamp = vk::FALSE,
feature(CORE, "depthBiasClamp"),
@@ -3,7 +3,8 @@
//! `[[render_target_array_index]]` `i` renders slice `slice + i` of a layered pass, an index at or
//! past the pass's length renders its first slice, the pass's clear covers every layer, a pass of
//! one layer renders its slice whatever index the vertex function writes, and the fragment
//! function reads the index as written, in each. A vertex function whose index may differ among a
//! function reads the index as written, in each, over a 2D array, a cube and a cube array (its
//! faces counted across its cubes). A vertex function whose index may differ among a
//! primitive's vertices is refused at creation, naming `LayeredRendering`.
//!
//! `rt6_layered_vertex` (engine `rt6_layered`) draws the fullscreen triangle once per instance,
@@ -49,7 +50,7 @@ mod on_device {
expect: &'static [u32],
}
const PASSES: [Layered; 4] = [
const PASSES: [Layered; 5] = [
// Slices 1 to 3 of four: instance 0 renders layer 1 (slice 2), instance 1 layer 0
// (slice 1), and instance 2's index 5, past the length, layer 0 too, over instance 1;
// layer 2 (slice 3) keeps the clear, slice 0 its prior.
@@ -72,6 +73,31 @@ mod on_device {
layers: &[5, 2],
expect: &[CLEAR, CLEAR, word(1, 2), CLEAR, CLEAR, word(0, 5)],
},
// Six faces of a cube array of two cubes, slices 4 to 9, across both cubes: index 5
// renders slice 9 (the second cube's face 3), index 0 slice 4 (the first cube's face 4);
// slices 5 to 8 keep the clear, the four outside the pass their prior.
Layered {
what: "a cube array's slices 4 to 9",
texture_type: TextureType::CubeArray,
slices: 12,
slice: 4,
length: 6,
layers: &[5, 0],
expect: &[
PRIOR,
PRIOR,
PRIOR,
PRIOR,
word(1, 0),
CLEAR,
CLEAR,
CLEAR,
CLEAR,
word(0, 5),
PRIOR,
PRIOR,
],
},
// Passes of one layer, of Metal's default length 0 and of length 1: index 3 renders the
// attachment's slice, and the fragment reads 3.
Layered {
@@ -97,8 +123,10 @@ mod on_device {
/// A Shared render target of `R32Uint`, `SIDE` a side, every slice primed to [`PRIOR`].
fn target(device: &Device, texture_type: TextureType, slices: u32) -> Texture {
let mut d = TextureDescriptor::new(texture_type, PixelFormat::R32Uint, SIDE, SIDE);
if texture_type == TextureType::Type2DArray {
d.array_length = slices;
match texture_type {
TextureType::Type2DArray => d.array_length = slices,
TextureType::CubeArray => d.array_length = slices / 6,
_ => {}
}
d.usage = TextureUsage::RENDER_TARGET;
d.storage_mode = StorageMode::Shared;
@@ -485,7 +485,8 @@ mod on_device {
}
.run(&name, &volume, 3);
// A slice of an array, and a cube's last face.
// A slice of an array, a cube's last face, and a cube array's last face (its second
// cube's), the cube array dropped at once.
let mut d = descriptor(TextureType::Type2DArray, PixelFormat::R8Unorm, [4, 4, 1]);
d.array_length = 3;
let array = make(&d, Some(4098));
@@ -507,6 +508,9 @@ mod on_device {
let d = descriptor(TextureType::Cube, PixelFormat::R8Unorm, [4, 4, 1]);
let cube = make(&d, Some(4099));
trip(5).run(&name, &cube, 5);
let mut d = descriptor(TextureType::CubeArray, PixelFormat::R8Unorm, [4, 4, 1]);
d.array_length = 2;
trip(11).run(&name, &make(&d, Some(4103)), 8);
// A 32-bit float depth texture: its bytes come out, and none go in.
let d = descriptor(TextureType::Type2D, PixelFormat::Depth32Float, [8, 8, 1]);
@@ -552,17 +556,6 @@ mod on_device {
Err(error) => panic!("{name}: BC1: {error}"),
}
// A cube array texture is not built: its view would need `imageCubeArray`.
let mut cubes = descriptor(TextureType::CubeArray, PixelFormat::RGBA8Unorm, [4, 4, 1]);
cubes.array_length = 2;
assert!(
matches!(
device.new_texture(&cubes, Some(4103)),
Err(Error::Unsupported(Gap::CubeArrayTexture))
),
"{name}: a cube array texture"
);
// A Private texture's bytes are the GPU's alone.
let mut d = descriptor(TextureType::Type2D, PixelFormat::RGBA8Unorm, [4, 4, 1]);
d.storage_mode = StorageMode::Private;
+6 -11
View File
@@ -154,11 +154,11 @@ mod on_device {
/// Metal's casts of a cube over the same image (Apple's
/// `makeTextureView(pixelFormat:textureType:levels:slices:)`), each over a level and face
/// range inside the cube: a 2D array of some faces, of every level and face, and a 2D texture
/// of one face. Each reports Metal's type, extent, levels and array length, and a blit copy
/// out of its level 0 and slice 0 reads the cube's level and face under them. A view costs no
/// submission, block or copied byte. A view as a cube array is `Gap::CubeArrayTexture`, as a
/// cube array texture is.
/// range inside the cube: a 2D array of some faces, of every level and face, a 2D texture of
/// one face, and a cube array of its one cube. Each reports Metal's type, extent, levels and
/// array length (a cube array's is its count of cubes), and a blit copy out of its level 0 and
/// slice 0 reads the cube's level and face under them. A view costs no submission, block or
/// copied byte.
#[test]
fn every_device_views_a_cube_s_faces_as_metal_casts_them() {
each_device("texture_views_of_cubes", |name, _, device| {
@@ -176,6 +176,7 @@ mod on_device {
("faces", Type2DArray, 1..2, 2..5, [4, 1, 3], [1, 2]),
("every-face", Type2DArray, 0..2, 0..6, [8, 2, 6], [0, 0]),
("face", Type2D, 1..2, 4..5, [4, 1, 1], [1, 4]),
("as-a-cube-array", CubeArray, 0..1, 0..6, [8, 1, 1], [0, 0]),
];
let counters = device.counters();
for (at, (case, texture_type, levels, faces, reports, under)) in (4100..).zip(cases) {
@@ -215,12 +216,6 @@ mod on_device {
"{name}: {case}: the bytes"
);
}
let as_array =
cube.new_texture_view(PixelFormat::RGBA8Unorm, CubeArray, 0..1, 0..6, Some(4110));
assert!(
matches!(as_array, Err(Error::Unsupported(Gap::CubeArrayTexture))),
"{name}: a cube array view of a cube"
);
});
}
+32 -32
View File
@@ -86,8 +86,7 @@ pub enum StorageMode {
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TextureDescriptor {
/// `textureType`. `TextureBuffer` is refused, [`Gap::TextureBuffer`], and `CubeArray`,
/// [`Gap::CubeArrayTexture`].
/// `textureType`. `TextureBuffer` is refused, [`Gap::TextureBuffer`].
pub texture_type: TextureType,
/// `pixelFormat`.
pub pixel_format: PixelFormat,
@@ -947,8 +946,7 @@ impl Device {
/// [`Refusal::TextureLevelCount`], [`Refusal::TextureSampleCount`],
/// [`Refusal::TextureSwizzleWithWrites`]); [`Refusal::TextureIndex`];
/// [`Refusal::IndicesNotGranted`] for an index not granted; [`Limit::TextureSize`] and [`Limit::TextureSamples`] past the device's;
/// [`Gap::TextureFormat`], [`Gap::TextureBuffer`], [`Gap::CubeArrayTexture`] and
/// [`Gap::MemorylessTexture`];
/// [`Gap::TextureFormat`], [`Gap::TextureBuffer`] and [`Gap::MemorylessTexture`];
/// [`Limit::MemoryAllocations`] where its memory would take the device past its count;
/// [`Error::Vulkan`] where the image or its memory cannot be made; [`Error::Quiesced`].
pub fn new_texture(
@@ -1635,13 +1633,13 @@ struct Plan {
/// multisample, which `VUID-VkImageCreateInfo-samples-02257` bars. A cube's own image is
/// cube-compatible through its shape's flags.
cube: bool,
/// The optimal image takes the colour attachment usage beside `usage`, so that a pass
/// resolves into it as Metal resolves into a texture of any usage
/// ([`RenderPassKind::ResolveUsage`]): a one-sample colour texture, 2D, a 2D array or a cube,
/// made without `RenderTarget` usage, where the format's features hold the attachment and the
/// device's image format query makes the image with it at the texture's extent ([`plan`]).
/// A linear image in place over a buffer, of `linear_usage`, takes no attachment usage for a
/// resolve alone, so it stays in place.
/// The optimal image takes the colour attachment usage beside `usage`, so that a pass resolves
/// into it as Metal resolves into a texture of any usage ([`RenderPassKind::ResolveUsage`]): a
/// one-sample colour texture, 2D, a 2D array, a cube or a cube array, made without
/// `RenderTarget` usage, where the format's features hold the attachment and the device's image
/// format query makes the image with it at the texture's extent ([`plan`]). A linear image in
/// place over a buffer, of `linear_usage`, takes no attachment usage for a resolve alone, so it
/// stays in place.
resolves: bool,
}
@@ -2083,9 +2081,6 @@ fn checked(d: &TextureDescriptor) -> Result<(Shape, TextureUsage), Error> {
if d.storage_mode == StorageMode::Memoryless {
return Err(Error::Unsupported(Gap::MemorylessTexture));
}
if d.texture_type == TextureType::CubeArray {
return Err(Error::Unsupported(Gap::CubeArrayTexture));
}
let usage = match d.usage.is_empty() {
true => {
TextureUsage::SHADER_READ
@@ -2243,7 +2238,10 @@ fn plan(
.contains(vk::ImageUsageFlags::COLOR_ATTACHMENT)
&& matches!(
d.texture_type,
TextureType::Type2D | TextureType::Type2DArray | TextureType::Cube
TextureType::Type2D
| TextureType::Type2DArray
| TextureType::Cube
| TextureType::CubeArray
);
let resolve_usage = match resolves {
true => vk::ImageUsageFlags::COLOR_ATTACHMENT,
@@ -3531,12 +3529,13 @@ impl Texture {
/// and writes through either reach the same bytes, as Metal's do.
///
/// Built: the texture's own pixel format or another its image lists, over every slice in the
/// texture's own type, a slice subrange of a 1D or 2D array, a 2D texture as a 2D array of its
/// one slice, one slice of a 2D array as a 2D texture, a cube's faces as a 2D texture (one
/// face) or a 2D array (any faces), and six slices of a square 2D array as a cube, its image
/// made cube-compatible where the device's format query takes the flag, each over any level
/// subrange. A view as a cube array is
/// [`Gap::CubeArrayTexture`], as a cube array texture is. A texture's image lists the formats Metal views
/// texture's own type, a slice subrange of a 1D or 2D array or of a cube array's cubes, a 2D
/// texture as a 2D array of its one slice, one slice of a 2D array as a 2D texture, a cube's or
/// a cube array's faces as a 2D texture (one face) or a 2D array (any faces), six of a cube
/// array's faces as a cube, a cube as a cube array of one cube, and six slices of a square 2D
/// array as a cube, or a multiple of six as a cube array, its image made cube-compatible where
/// the device's format query takes the flag, each over any level subrange. A texture's image
/// lists the formats Metal views
/// it as that the device holds in a viewed form of the image format's compatibility class: its
/// sRGB sibling whatever its usage, and with `PixelFormatView` usage, or an empty usage
/// (Metal's `MTLTextureUsageUnknown`, which the runtime takes as every usage), every
@@ -3660,20 +3659,21 @@ impl Texture {
}
// Metal's casts (Apple's `makeTextureView(pixelFormat:textureType:levels:slices:)`): 1D to
// 1D, 2D to 2D or a 2D array, a 2D array, a cube or a cube array to any of those four, and
// 3D to 3D. Vulkan views a cube's image, which is cube-compatible, as a 2D texture or a 2D
// array of its layers, and any image as a 2D array of one layer, with no query, so each is
// one form on every device. A cube array is not built, nor a view as one.
// 3D to 3D. Vulkan views a cube's or a cube array's image, which is cube-compatible, as a
// 2D texture, a 2D array of its layers, a cube of six of them or a cube array of a multiple
// of six (`imageCubeArray`, in the floor), and any image as a 2D array of one layer, with
// no query, so each is one form on every device.
match (p.texture_type, texture_type) {
(_, T::CubeArray) => return Err(Error::Unsupported(Gap::CubeArrayTexture)),
(from, to) if from == to => {
if !every_slice && !matches!(to, T::Type1DArray | T::Type2DArray) {
let subrange = matches!(to, T::Type1DArray | T::Type2DArray | T::CubeArray);
if !every_slice && !subrange {
return gap(TextureViewKind::Slices);
}
}
(T::Type2D, T::Type2DArray) | (T::Type2DArray, T::Type2D) => {}
(T::Cube, T::Type2D | T::Type2DArray) => {}
(T::Type2DArray, T::Cube) if inner.image.cube => {}
(T::Type2DArray, T::Cube) => return gap(TextureViewKind::CubeOfArray),
(T::Cube | T::CubeArray, T::Type2D | T::Type2DArray | T::Cube | T::CubeArray) => {}
(T::Type2DArray, T::Cube | T::CubeArray) if inner.image.cube => {}
(T::Type2DArray, T::Cube | T::CubeArray) => return gap(TextureViewKind::CubeOfArray),
_ => return gap(TextureViewKind::TextureType),
}
let mut d = *p;
@@ -4393,9 +4393,9 @@ pub(crate) trait TextureObject {
///
/// Err: [`Gap::RenderPass`] of [`RenderPassKind::ResolveUsage`] for a texture whose image has
/// none: a depth or stencil texture made without `RenderTarget` usage, a colour texture of a
/// type but 2D, a 2D array or a cube or whose format the device's optimal image does not
/// render, and a texture over a buffer whose linear image lies in place; as [`attachment`]
/// for the rest.
/// type but 2D, a 2D array, a cube or a cube array or whose format the device's optimal image
/// does not render, and a texture over a buffer whose linear image lies in place; as
/// [`attachment`] for the rest.
///
/// [`attachment`]: TextureObject::attachment
fn resolve_attachment(&self, level: u32, slice: u32, layers: u32) -> Result<Attachment, Error> {
@@ -1139,6 +1139,7 @@
"alphaToOne": true,
"logicOp": true,
"fullDrawIndexUint32": true,
"imageCubeArray": true,
"depthBiasClamp": true,
"drawIndirectFirstInstance": true,
"depthClamp": true,
@@ -1212,7 +1212,7 @@ pub fn runs_through_runtime(authored: &AuthoredCase, case: &ComputeCase) -> bool
/// Whether the runtime makes `texture` as the Metal oracle makes it: no sparse mapping (a sparse
/// texture stays on the executor's own context), of a type the runtime builds, so neither a
/// texture buffer (`Gap::TextureBuffer`) nor a cube array (`Gap::CubeArrayTexture`). A 32-bit
/// texture buffer (`Gap::TextureBuffer`) nor a cube array. A 32-bit
/// float depth, whose bytes the runtime takes no upload of (`Gap::FloatDepthUpload`), is filled
/// by a draw, as a guest fills one (`platform::runtime_depth`), and a multisampled texture, which
/// neither Metal nor the runtime uploads, by a draw per slice that writes it sample by sample
@@ -9170,7 +9170,6 @@ variant metal2vulkan-runtime::ExportHandle::OpaqueFd OpaqueFd
variant metal2vulkan-runtime::ExportHandle::OpaqueWin32 OpaqueWin32
variant metal2vulkan-runtime::Gap::BicubicTexels BicubicTexels { slot: u32, pixel_format: PixelFormat }
variant metal2vulkan-runtime::Gap::BufferCopyAlignment BufferCopyAlignment { pixel_format: PixelFormat, offset: u64, bytes_per_row: u64, bytes_per_image: u64 }
variant metal2vulkan-runtime::Gap::CubeArrayTexture CubeArrayTexture
variant metal2vulkan-runtime::Gap::CubicSampler CubicSampler
variant metal2vulkan-runtime::Gap::D3d11SurfaceBuffer D3d11SurfaceBuffer
variant metal2vulkan-runtime::Gap::Draw Draw { kind: DrawKind }
Can't render this file because it is too large.
+2 -4
View File
@@ -34,7 +34,7 @@ Columns:
| Devices below the runtime's floor | 8 | 8 | 0 | 0 | 0 | 0 | 0 |
| The runtime's `Refusal` | 76 | 76 | 0 | 0 | 0 | 0 | 0 |
| The runtime's `Limit` | 17 | 17 | 0 | 0 | 0 | 0 | 0 |
| The runtime's `Gap` | 31 | 31 | 0 | 0 | 0 | 0 | 0 |
| The runtime's `Gap` | 30 | 30 | 0 | 0 | 0 | 0 | 0 |
## Totals by basis
@@ -48,7 +48,7 @@ Columns:
| Devices below the runtime's floor | 0 | 0 | 0 | 8 | 0 | 0 | 0 | 0 |
| The runtime's `Refusal` | 21 | 20 | 0 | 0 | 35 | 0 | 0 | 0 |
| The runtime's `Limit` | 0 | 0 | 0 | 13 | 4 | 0 | 0 | 0 |
| The runtime's `Gap` | 0 | 0 | 0 | 2 | 29 | 0 | 0 | 0 |
| The runtime's `Gap` | 0 | 0 | 0 | 2 | 28 | 0 | 0 | 0 |
## 1. Translator and front-end refusals (`Unsupported`: a `Feature` and its `Needs`)
@@ -368,7 +368,6 @@ Columns:
| `IndirectPrivateArena` | `dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:` of a kernel whose private memory lives in the runtime's... | every device (a public call's own check of its arguments) | `ours`: no replay stream dispatches such a kernel indirectly | 1: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)` | `-` |
| `MemorylessTexture` | A texture of `Memoryless` storage, which only render passes use | every device (a public call's own check of its arguments) | `ours`: render passes are not built | 1: `crates/metal2vulkan-runtime/src/texture.rs (checked)` | `-` |
| `TextureBuffer` | A texture buffer (`MTLTextureTypeTextureBuffer`) | every device (a public call's own check of its arguments) | `ours`: no texel-buffer array; no replay stream or live session has used one; harvested guest render functions declare one in an argument buffer, validation's texture_buffer_member | 2: `crates/metal2vulkan-runtime/src/texture.rs (shape, 2 sites)` | `-` |
| `CubeArrayTexture` | A cube array texture (`MTLTextureTypeCubeArray`), and so a view of one | every device (a public call's own check of its arguments) | `ours`: no replay stream makes a cube array texture or view; built when one does | 2: `crates/metal2vulkan-runtime/src/texture.rs (checked)`, `crates/metal2vulkan-runtime/src/texture.rs (view)` | `-` |
| `TextureFormat` | A texture of a pixel format the runtime makes no image of on this device for the descriptor's usage | every device (a public call's own check of its arguments) | `ours`: the device's format query, or the identity domains' shaders read every texture through its view alone | 3: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`, `crates/metal2vulkan-runtime/src/texture.rs (form)` (+1) | `-` |
| `MipmapFilter` | `BlitCommandEncoder::generate_mipmaps` of a texture whose image the device's blits do not filter | every device (a public call's own check of its arguments) | `ours`: the device's format query; the levels are the device's blit chain alone | 1: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)` | `-` |
| `CubicSampler` | A sampler state whose minification or magnification filter is cubic (`Device::new_sampler_state`) | every device (a public call's own check of its arguments) | `ours`: the translator's identity domains do not filter bicubically, and Vulkan's cubic filter is not Metal's | 1: `crates/metal2vulkan-runtime/src/sampler.rs (new_sampler_state)` | `-` |
@@ -654,7 +653,6 @@ Each refusal's sites, with the function that builds it.
- `rt:Gap::IndirectPrivateArena`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`
- `rt:Gap::MemorylessTexture`: `crates/metal2vulkan-runtime/src/texture.rs (checked)`
- `rt:Gap::TextureBuffer`: `crates/metal2vulkan-runtime/src/texture.rs (shape, 2 sites)`
- `rt:Gap::CubeArrayTexture`: `crates/metal2vulkan-runtime/src/texture.rs (checked)`; `crates/metal2vulkan-runtime/src/texture.rs (view)`
- `rt:Gap::TextureFormat`: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`; `crates/metal2vulkan-runtime/src/texture.rs (form)`; `crates/metal2vulkan-runtime/src/texture.rs (plan)`
- `rt:Gap::MipmapFilter`: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)`
- `rt:Gap::CubicSampler`: `crates/metal2vulkan-runtime/src/sampler.rs (new_sampler_state)`
@@ -115,9 +115,9 @@ RUNTIME_FLOOR = {
"shaderStorageImageExtendedFormats", "samplerAnisotropy",
"shaderImageGatherExtended", "shaderInt16", "independentBlend",
"fragmentStoresAndAtomics", "alphaToOne", "logicOp", "fullDrawIndexUint32",
"depthBiasClamp", "drawIndirectFirstInstance", "depthClamp", "shaderClipDistance",
"tessellationShader", "shaderTessellationAndGeometryPointSize", "largePoints",
"dualSrcBlend", "sampleRateShading", "vertexPipelineStoresAndAtomics")},
"imageCubeArray", "depthBiasClamp", "drawIndirectFirstInstance", "depthClamp",
"shaderClipDistance", "tessellationShader", "shaderTessellationAndGeometryPointSize",
"largePoints", "dualSrcBlend", "sampleRateShading", "vertexPipelineStoresAndAtomics")},
"VkPhysicalDeviceVulkan11Features": {member: True for member in (
"storageBuffer16BitAccess", "multiview", "shaderDrawParameters")},
"VkPhysicalDeviceVulkan12Features": {member: True for member in (