rt: texture buffers are buffer views of their buffer's bytes in set 1's two texel-buffer arrays
What: Buffer::new_texture of a texture buffer's descriptor makes one VkBufferView of the bytes
shaders reach (a Managed buffer's device copy where it has one), from the offset, its width's
texels long: no image, no copy, no new push field. Set 1 gains two arrays of 65,536 elements,
binding 5 (uniform texel buffers, the read ones) and binding 6 (storage texel buffers, the written
ones), at the same index class as textures; a texture buffer's index is the same element of both,
and placing a texture or a texture buffer over the other's index nulls the other's elements. The
translator's identity domains classify a texture_buffer slot or argument-buffer member as a texel
buffer of that array (no TexelBufferRange fact, no swizzle under identity), so a pipeline that
declares one is no longer Unsupported{IdentityDomains}. SEMANTICS_VERSION 2258.
Metal's own refusals are typed: an offset off Device::minimum_texture_buffer_alignment
(minimumTextureBufferAlignmentForPixelFormat:, the device's texel-buffer offset alignment, the
larger of the uniform and storage ones, a single texel's size where the device says it suffices)
is Refusal::TextureBufferAlignment; a bytesPerRow below the row or texels past the buffer is
Refusal::BufferTextureLayout; a descriptor of more than one row, level, slice or sample, and a
swizzle with writes, as Metal refuses them. Device::new_texture (and every other make) of a texture
buffer's descriptor is Refusal::TextureBufferNotOverBuffer: the consumer places the bytes as it
places every buffer. Gap::TextureBuffer goes; a swizzled texture buffer (Gap::TextureBufferSwizzle),
a view of one, and a blit copy of one are recorded gaps. A format needs both texel-buffer usages in
its buffer features (Gap::TextureFormat otherwise): the view's buffer has both usages, and without
maintenance5 its usage is the buffer's.
The floor requires the six texel-buffer descriptor-indexing features (update-after-bind, dynamic
and non-uniform indexing, uniform and storage) and raises the limits the two arrays count against:
uniform texel buffers against the sampled-image limits, storage texel buffers against the
storage-image limits, both against maxPerStageUpdateAfterBindResources and the pools: sampled and
storage per stage and per set 131,072 (196,608 sampled with attachment reads' second elements),
resources 262,152 (327,688), pools 274,144 (339,680). Every recorded device fits: the 8 device dumps'
least are llvmpipe's 1,015,808 sampled/storage/resources and the UHD 630's 1,048,576 pools; all 12
devices there report the six features.
Why: six harvested guest functions declare a texture buffer, and a pipeline that declared one was
refused at creation.
Checked by: tests::texture_buffers (lavapipe: R32Uint read at a buffer offset and written, out of
bounds read zero and dropped, atomics through read_write, every refusal), engine_identity's
a_texture_buffer_is_the_texel_buffer_element_its_resource_id_names (L3 on lavapipe and moltenvk-m3),
the floor tests, the signatures table and REFUSALS.md regenerated; the lane's compile job reports
the runs.
This commit is contained in:
1 parent
838b6f0260
commit
817463704e
24 files changed
+1493
-264
No files matched your search
@@ -1090,11 +1090,15 @@ the Direct3D 11 texture's payload until it is freed.
|
||||
## Set 1 and index grants
|
||||
|
||||
Shaders reach textures and samplers by index (`docs/RESOURCE-ID.md`). Every pipeline takes set 1,
|
||||
one descriptor set the device makes at creation, of five arrays whose element `i` is the object
|
||||
one descriptor set the device makes at creation, of seven arrays whose element `i` is the object
|
||||
whose `gpuResourceID` holds index `i`: 65,536 sampled textures (binding 0), 65,536 storage
|
||||
textures (binding 1), and 4,000 samplers of each use, plain, depth comparison and integer texture
|
||||
(bindings 2, 3 and 4). A texture's index is the same element of both texture arrays: one with a
|
||||
storage view takes both, any other the sampled one alone, and its storage element stays null. Every binding is partially bound, updated after bind and
|
||||
textures (binding 1), 4,000 samplers of each use, plain, depth comparison and integer texture
|
||||
(bindings 2, 3 and 4), and 65,536 uniform and 65,536 storage texel buffers, the texture buffers
|
||||
(bindings 5 and 6). A texture's index is the same element of both texture arrays: one with a
|
||||
storage view takes both, any other the sampled one alone, and its storage element stays null. A
|
||||
texture buffer's index is the same element of both texel-buffer arrays: the uniform one where
|
||||
shaders read it, the storage one where they write it, the other null; its texture elements stay
|
||||
null, as a texture's texel-buffer elements do. Every binding is partially bound, updated after bind and
|
||||
updated while unused elements are pending, so an object's element is written once, as it is
|
||||
made, with no lock, and never rewritten for layouts.
|
||||
|
||||
@@ -1110,7 +1114,7 @@ made, with no lock, and never rewritten for layouts.
|
||||
so a bad ID there reads the element at `index & 0xFFFF`, never one outside the arrays. A slot's
|
||||
index is the runtime's own push, unmasked, and no argument buffer's ID reaches the feedback
|
||||
elements.
|
||||
- Every element no object owns is defined. A texture element is a null descriptor
|
||||
- Every element no object owns is defined. A texture or texel-buffer element is a null descriptor
|
||||
(`nullDescriptor`): it reads zeros, sizes 0 and drops writes, as Metal's nil texture does. A
|
||||
sampler element is its array's default sampler, nearest and clamped to the edge; the
|
||||
comparison array's compares with `NEVER`, so a comparison through it answers 0, as Metal's
|
||||
@@ -1220,12 +1224,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`)
|
||||
and Memoryless storage (`Gap::MemorylessTexture`) are not built. A texture buffer is refused at
|
||||
both makes, `Device::new_texture` and `Buffer::new_texture`, and a pipeline whose function
|
||||
declares a `texture_buffer` is refused at creation (`Unsupported{IdentityDomains}`): a consumer
|
||||
that tells a guest texture buffers are supported (an alignment, a format's buffer usage) hands it
|
||||
nil for each one it makes. A cube array texture's image
|
||||
`TextureSampleCount`, `TextureSwizzleWithWrites`). Memoryless storage
|
||||
(`Gap::MemorylessTexture`) is not built. A texture buffer's descriptor is
|
||||
`Refusal::TextureBufferNotOverBuffer` at every make but `Buffer::new_texture`, which makes texture
|
||||
buffers (below). 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
|
||||
@@ -1302,6 +1304,31 @@ made, with no lock, and never rewritten for layouts.
|
||||
the buffer's bytes, with no submission; a dispatch's use of the texture is a use of the buffer in the
|
||||
hazard sets, and a write to it reaches the host as a write to a Shared buffer does. The texture
|
||||
holds the buffer.
|
||||
- A texture buffer (`MTLTextureTypeTextureBuffer`) is made over a buffer alone:
|
||||
`Buffer::new_texture` of its descriptor is one `VkBufferView` of the bytes shaders reach from
|
||||
`offset`, its width's texels long, with no image and no copy. Metal's
|
||||
`newTextureWithDescriptor:` of a texture buffer's descriptor allocates the bytes itself; here it
|
||||
is `Refusal::TextureBufferNotOverBuffer`, and the consumer places a buffer of the texels' bytes,
|
||||
as it places every buffer, and makes the texture buffer over it. `offset` is a multiple of
|
||||
`Device::minimum_texture_buffer_alignment(pixel_format)`, `minimumTextureBufferAlignmentForPixelFormat:`
|
||||
(`Refusal::TextureBufferAlignment` otherwise): the device's texel-buffer offset alignment for
|
||||
the format's texel, the larger of the uniform and the storage texel buffer's (Vulkan 1.3's
|
||||
`…TexelBufferOffsetAlignmentBytes`, or the texel's bytes where the device's
|
||||
`…TexelBufferOffsetSingleTexelAlignment` says one texel suffices), at most 256, so it divides
|
||||
the multiple of 256 every buffer starts at. Metal documents the alignment for the row's bytes
|
||||
too; a texture buffer's one row reads no other, so any `bytes_per_row` that covers the row is
|
||||
taken (`Refusal::BufferTextureLayout` below it, or for texels past the buffer). The format is one
|
||||
the device holds directly, of one colour texel an element, whose buffer features hold both the
|
||||
uniform and the storage texel buffer (`Gap::TextureFormat` otherwise): the view is of a buffer
|
||||
of both usages, so its format takes both. A width past `maxTexelBufferElements` is
|
||||
`Limit::TextureSize`. Its view is the element of the uniform texel-buffer array at its index
|
||||
where shaders read it, and of the storage one where they write it and the format's storage
|
||||
texel buffers write without a format (else it has no storage element, as a texture has none:
|
||||
`Gap::StorageElement` at the draw or dispatch that writes it at a slot). Its texels are the
|
||||
buffer's bytes: the host, a blit or a shader writing the buffer writes them, `replace_region`
|
||||
and `get_bytes` write and read them there, and its uses are uses of the buffer in the hazard
|
||||
sets. Its storage mode is the buffer's. The view goes once the texture buffer is gone and its
|
||||
elements are null.
|
||||
- Where the device's linear image does not take the texture (another pitch, an offset off the
|
||||
image's alignment, a format or usage the linear tiling lacks, a spilled block), the texture is
|
||||
an optimal image of its own, and the device copies the bytes shaders reach into it and back,
|
||||
@@ -4048,6 +4075,12 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
|
||||
| `shaderStorageImageArrayDynamicIndexing` | `VkPhysicalDeviceFeatures` | indexing the read-write texture array by a `gpuResourceID` |
|
||||
| `shaderSampledImageArrayNonUniformIndexing` | `VkPhysicalDeviceVulkan12Features` | a `gpuResourceID` that differs between threads |
|
||||
| `shaderStorageImageArrayNonUniformIndexing` | `VkPhysicalDeviceVulkan12Features` | a `gpuResourceID` that differs between threads |
|
||||
| `descriptorBindingUniformTexelBufferUpdateAfterBind` | `VkPhysicalDeviceVulkan12Features` | the read texture-buffer array |
|
||||
| `descriptorBindingStorageTexelBufferUpdateAfterBind` | `VkPhysicalDeviceVulkan12Features` | the written texture-buffer array |
|
||||
| `shaderUniformTexelBufferArrayDynamicIndexing` | `VkPhysicalDeviceVulkan12Features` | indexing the read texture-buffer array by a `gpuResourceID` |
|
||||
| `shaderStorageTexelBufferArrayDynamicIndexing` | `VkPhysicalDeviceVulkan12Features` | indexing the written texture-buffer array by a `gpuResourceID` |
|
||||
| `shaderUniformTexelBufferArrayNonUniformIndexing` | `VkPhysicalDeviceVulkan12Features` | a texture buffer's `gpuResourceID` that differs between threads |
|
||||
| `shaderStorageTexelBufferArrayNonUniformIndexing` | `VkPhysicalDeviceVulkan12Features` | a texture buffer's `gpuResourceID` that differs between threads |
|
||||
| `shaderStorageImageWriteWithoutFormat` | `VkPhysicalDeviceFeatures` | writes to array elements of any pixel format |
|
||||
| `nullDescriptor` | `VkPhysicalDeviceRobustness2FeaturesEXT` | every texture element no texture owns: a nil, freed or unowned index reads zeros, sizes 0 and drops writes, as Metal's nil texture does. The robust buffer access beside it stays off |
|
||||
| `samplerAnisotropy` | `VkPhysicalDeviceFeatures` | a sampler state's `maxAnisotropy`, which the device's own filter takes |
|
||||
@@ -4193,9 +4226,11 @@ pipeline states). So `Device::extensions` names the extension only with its feat
|
||||
### Limits
|
||||
|
||||
The descriptor limits are what the runtime's fixed arrays need: 65,536 sampled textures, 65,536
|
||||
storage textures and three arrays of 4,000 samplers, one per use (plain, depth comparison,
|
||||
integer texture). Vulkan requires at least 500,000 of each texture limit and of the two resource
|
||||
totals on a device that supports `descriptorIndexing`, as every lab device does. 4,000 is Vulkan's minimum `maxSamplerAllocationCount`. The compute limits let a threadgroup take
|
||||
storage textures, 65,536 read and 65,536 written texture buffers, and three arrays of 4,000
|
||||
samplers, one per use (plain, depth comparison, integer texture). A read texture buffer (a uniform
|
||||
texel buffer) counts against the sampled-image limits and a written one (a storage texel buffer)
|
||||
against the storage-image limits. Vulkan requires at least 500,000 of each texture limit and of
|
||||
the two resource totals on a device that supports `descriptorIndexing`, as every lab device does. 4,000 is Vulkan's minimum `maxSamplerAllocationCount`. The compute limits let a threadgroup take
|
||||
Metal's 1,024 threads in any shape up to 1,024 by 1,024 by 64. `maxColorAttachments` holds
|
||||
Metal's eight color attachments on every device; Vulkan 1.3 requires 4 of it, and Vulkan 1.4 8.
|
||||
`maxFragmentOutputAttachments` holds a fragment function's output to each of them; Vulkan 1.3 and
|
||||
@@ -4205,15 +4240,15 @@ A Boolean limit's minimum is 1,
|
||||
|
||||
| Limit | Minimum | Used for |
|
||||
|---|---|---|
|
||||
| `maxPerStageDescriptorUpdateAfterBindSampledImages` | `65536` | the sampled-texture array |
|
||||
| `maxDescriptorSetUpdateAfterBindSampledImages` | `65536` | the sampled-texture array |
|
||||
| `maxPerStageDescriptorUpdateAfterBindStorageImages` | `65536` | the storage-texture array |
|
||||
| `maxDescriptorSetUpdateAfterBindStorageImages` | `65536` | the storage-texture array |
|
||||
| `maxPerStageDescriptorUpdateAfterBindSampledImages` | `131072` | the sampled-texture and read texture-buffer arrays |
|
||||
| `maxDescriptorSetUpdateAfterBindSampledImages` | `131072` | the sampled-texture and read texture-buffer arrays |
|
||||
| `maxPerStageDescriptorUpdateAfterBindStorageImages` | `131072` | the storage-texture and written texture-buffer arrays |
|
||||
| `maxDescriptorSetUpdateAfterBindStorageImages` | `131072` | the storage-texture and written texture-buffer arrays |
|
||||
| `maxPerStageDescriptorUpdateAfterBindSamplers` | `12000` | the three sampler arrays |
|
||||
| `maxDescriptorSetUpdateAfterBindSamplers` | `12000` | the three sampler arrays |
|
||||
| `maxSamplerAllocationCount` | `4000` | Vulkan's minimum: live samplers |
|
||||
| `maxPerStageUpdateAfterBindResources` | `131072` | both texture arrays in one stage; a fragment stage needs its `maxColorAttachments` more |
|
||||
| `maxUpdateAfterBindDescriptorsInAllPools` | `143072` | all five arrays |
|
||||
| `maxPerStageUpdateAfterBindResources` | `262144` | the four texture and texture-buffer arrays in one stage; a fragment stage needs its `maxColorAttachments` more |
|
||||
| `maxUpdateAfterBindDescriptorsInAllPools` | `274144` | all seven arrays |
|
||||
| `maxPushConstantsSize` | `256` | per-command values: a compute kernel's dispatch region and 24 buffer addresses below its tail, anything larger in a block whose address is pushed; a render pipeline's vertex and fragment functions' values in the same 256 bytes, dense by link, anything larger in a block whose address is pushed |
|
||||
| `maxComputeWorkGroupInvocations` | `1024` | Metal's most threads per threadgroup |
|
||||
| `maxComputeWorkGroupSize[0]` | `1024` | a threadgroup's width |
|
||||
@@ -4315,8 +4350,8 @@ blocks), and only that call makes a sparse buffer. Elsewhere the call refuses.
|
||||
|
||||
A draw that reads, through a texture, an attachment its own pass renders (Metal's read of a
|
||||
render target) is built where the device's descriptor limits hold the sampled-texture array's
|
||||
second elements beside the floor's arrays: 131,072 sampled textures where the limits above name
|
||||
65,536 (`maxPerStageDescriptorUpdateAfterBindSampledImages`,
|
||||
second elements beside the floor's arrays: 65,536 sampled images more than the limits above name
|
||||
(`maxPerStageDescriptorUpdateAfterBindSampledImages`,
|
||||
`maxDescriptorSetUpdateAfterBindSampledImages`, `maxPerStageUpdateAfterBindResources` and
|
||||
`maxUpdateAfterBindDescriptorsInAllPools`); a device without them refuses such a draw
|
||||
(`Gap::Draw` of `DrawKind::AttachmentRead`), and is otherwise the same
|
||||
|
||||
@@ -2,20 +2,21 @@
|
||||
//! at the index a `gpuResourceID` holds (`docs/RESOURCE-ID.md`), and the index grants the consumer
|
||||
//! chooses those indices from.
|
||||
//!
|
||||
//! One descriptor set of the translator's identity domains' five arrays, made at device creation
|
||||
//! One descriptor set of the translator's identity domains' seven arrays, made at device creation
|
||||
//! and never rewritten for layouts: binding 0 the sampled textures and binding 1 the storage
|
||||
//! textures (65,536 each, element `i` of both the texture at index `i`), and bindings 2, 3 and 4
|
||||
//! the samplers of each use, plain, depth comparison and integer texture (4,000 each). Every
|
||||
//! binding is partially bound and updated after bind, also while work that uses the set is
|
||||
//! pending, so writing one element needs no lock: each element has one owner, which writes it
|
||||
//! alone.
|
||||
//! textures (65,536 each, element `i` of both the texture at index `i`), bindings 2, 3 and 4 the
|
||||
//! samplers of each use, plain, depth comparison and integer texture (4,000 each), and bindings 5
|
||||
//! and 6 the texture buffers' uniform and storage texel buffers (65,536 each, element `i` of both
|
||||
//! the texture buffer at index `i`). Every binding is partially bound and updated after bind, also
|
||||
//! while work that uses the set is pending, so writing one element needs no lock: each element has
|
||||
//! one owner, which writes it alone.
|
||||
//!
|
||||
//! Every element no live object owns holds a defined value, so a nil, stale or forged index reads
|
||||
//! zeros or samples plainly on every device, where an element never written would be undefined
|
||||
//! behaviour. A texture element is a null descriptor (`nullDescriptor`): it reads zeros, answers
|
||||
//! 0 to its size and level queries and drops its writes. The Metal Shading Language leaves every
|
||||
//! member function of a null texture undefined (section 6.13.18), so these are the runtime's
|
||||
//! answers, not Metal's. A sampler
|
||||
//! behaviour. A texture or texel-buffer element is a null descriptor (`nullDescriptor`): it reads
|
||||
//! zeros, answers 0 to its size and level queries and drops its writes. The Metal Shading Language
|
||||
//! leaves every member function of a null texture undefined (section 6.13.18), so these are the
|
||||
//! runtime's answers, not Metal's. A sampler
|
||||
//! element is its array's default sampler, nearest and clamped to the edge; the comparison
|
||||
//! array's compares with `NEVER`, so a comparison through it answers 0, as Metal's default
|
||||
//! comparison (`MTLCompareFunctionNever`) does. Vulkan has no null sampler. The device writes
|
||||
@@ -52,10 +53,14 @@ pub(crate) const STORAGE_BINDING: u32 = 1;
|
||||
/// The binding of the first sampler array; the plain, comparison and integer-texture arrays
|
||||
/// follow in that order.
|
||||
pub(crate) const FIRST_SAMPLER_BINDING: u32 = 2;
|
||||
/// The binding of the uniform texel-buffer array: the texture buffers shaders read.
|
||||
pub(crate) const UNIFORM_TEXELS_BINDING: u32 = 5;
|
||||
/// The binding of the storage texel-buffer array: the texture buffers shaders write.
|
||||
pub(crate) const STORAGE_TEXELS_BINDING: u32 = 6;
|
||||
|
||||
/// Set 1's bindings, each its binding, descriptor type and count: the arrays a kernel's layout
|
||||
/// names under the identity domains, which every pipeline's layout takes from this set.
|
||||
pub(crate) const BINDINGS: [(u32, vk::DescriptorType, u32); 5] = [
|
||||
pub(crate) const BINDINGS: [(u32, vk::DescriptorType, u32); 7] = [
|
||||
(SAMPLED_BINDING, vk::DescriptorType::SAMPLED_IMAGE, TEXTURES),
|
||||
(STORAGE_BINDING, vk::DescriptorType::STORAGE_IMAGE, TEXTURES),
|
||||
(FIRST_SAMPLER_BINDING, vk::DescriptorType::SAMPLER, SAMPLERS),
|
||||
@@ -69,6 +74,16 @@ pub(crate) const BINDINGS: [(u32, vk::DescriptorType, u32); 5] = [
|
||||
vk::DescriptorType::SAMPLER,
|
||||
SAMPLERS,
|
||||
),
|
||||
(
|
||||
UNIFORM_TEXELS_BINDING,
|
||||
vk::DescriptorType::UNIFORM_TEXEL_BUFFER,
|
||||
TEXTURES,
|
||||
),
|
||||
(
|
||||
STORAGE_TEXELS_BINDING,
|
||||
vk::DescriptorType::STORAGE_TEXEL_BUFFER,
|
||||
TEXTURES,
|
||||
),
|
||||
];
|
||||
|
||||
/// No Metal counterpart: the class of a texture or sampler index, which sets the range its grants
|
||||
@@ -77,9 +92,11 @@ pub(crate) const BINDINGS: [(u32, vk::DescriptorType, u32); 5] = [
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum IndexClass {
|
||||
/// A texture of any usage shaders reach: 1 to 65,535, one index valid in both the
|
||||
/// sampled-texture and the storage-texture array. A texture shaders write through a storage
|
||||
/// view takes the element of both at its index; any other takes the sampled-texture array's
|
||||
/// alone, and its storage element stays null.
|
||||
/// sampled-texture and the storage-texture array, and in both texel-buffer arrays. A texture
|
||||
/// shaders write through a storage view takes the element of both texture arrays at its
|
||||
/// index; any other takes the sampled-texture array's alone, and its storage element stays
|
||||
/// null. A texture buffer takes the texel-buffer arrays' elements instead: the uniform one
|
||||
/// where shaders read it, the storage one where they write it.
|
||||
Texture,
|
||||
/// A sampler: 1 to 3,999 of each sampler array. A Metal sampler state takes one, and so does
|
||||
/// each constexpr sampler a pipeline state numbers.
|
||||
@@ -325,9 +342,10 @@ impl Arrays {
|
||||
/// [`Arrays::vacate_texture`] writes it: it holds no image, so its layout need only be one
|
||||
/// every device takes for a sampled image, which the feedback layout is not: a device without
|
||||
/// `VK_EXT_attachment_feedback_loop_layout` refuses it
|
||||
/// (`VUID-VkWriteDescriptorSet-descriptorType-04149`). The descriptor-slot gauge rises where no
|
||||
/// object held the index. Its owner word, which [`Arrays::vacate_texture`] and
|
||||
/// [`Arrays::place_shadow`] take.
|
||||
/// (`VUID-VkWriteDescriptorSet-descriptorType-04149`). Where it displaced, it writes both
|
||||
/// texel-buffer elements null too, which a texture buffer there may have held. The
|
||||
/// descriptor-slot gauge rises where no object held the index. Its owner word, which
|
||||
/// [`Arrays::vacate_texture`] and [`Arrays::place_shadow`] take.
|
||||
///
|
||||
/// Err: [`Refusal::IndicesNotGranted`].
|
||||
///
|
||||
@@ -364,10 +382,108 @@ impl Arrays {
|
||||
}),
|
||||
};
|
||||
// SAFETY: the caller's contract; the texture owns the index, and the lock is held.
|
||||
unsafe { self.write_texture(device, index, sampled, storage, second) };
|
||||
unsafe {
|
||||
self.write_texture(device, index, sampled, storage, second);
|
||||
if displaced {
|
||||
self.write_texels(device, index, [vk::BufferView::null(); 2]);
|
||||
}
|
||||
}
|
||||
Ok(owner)
|
||||
}
|
||||
|
||||
/// Places a texture buffer at `index` ([`Grants::place`]) and writes its elements before
|
||||
/// another object can be placed there: the uniform texel-buffer array's with `views[0]` and
|
||||
/// the storage one's with `views[1]`, a null descriptor where a view is null. Where it
|
||||
/// displaced, it writes the index's texture elements null too (the sampled, the storage, and
|
||||
/// the second where the set holds them), which a texture there may have held. The
|
||||
/// descriptor-slot gauge rises where no object held the index. Its owner word, which
|
||||
/// [`Arrays::vacate_texels`] takes.
|
||||
///
|
||||
/// Err: [`Refusal::IndicesNotGranted`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Each view is live and of the device whenever work uses it, and where it displaces, no work
|
||||
/// in flight uses the index's elements (the consumer's duty: Vulkan does not define that
|
||||
/// write).
|
||||
pub(crate) unsafe fn place_texels(
|
||||
&self,
|
||||
device: &ash::Device,
|
||||
counters: &Counters,
|
||||
index: u32,
|
||||
views: [vk::BufferView; 2],
|
||||
) -> Result<Owner, Error> {
|
||||
let mut grants = lock(&self.grants);
|
||||
let Placed { owner, displaced } = grants.place(IndexClass::Texture, index)?;
|
||||
if !displaced {
|
||||
counters.rise(Gauge::DescriptorSlots);
|
||||
}
|
||||
// SAFETY: the caller's contract; the texture buffer owns the index, and the lock is held.
|
||||
unsafe {
|
||||
self.write_texels(device, index, views);
|
||||
if displaced {
|
||||
let null = vk::ImageView::null();
|
||||
let second =
|
||||
(self.seconds).then_some((null, vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL));
|
||||
self.write_texture(device, index, None, Some(null), second);
|
||||
}
|
||||
}
|
||||
Ok(owner)
|
||||
}
|
||||
|
||||
/// The texture buffer of `owner` goes from `index`: where it still owns the index, the index
|
||||
/// is free and its texel-buffer elements are null again, and the descriptor-slot gauge falls.
|
||||
/// A displaced texture buffer's going touches nothing.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// No work in flight reads the texture buffer's elements.
|
||||
pub(crate) unsafe fn vacate_texels(
|
||||
&self,
|
||||
device: &ash::Device,
|
||||
counters: &Counters,
|
||||
(index, owner): (u32, Owner),
|
||||
) {
|
||||
let mut grants = lock(&self.grants);
|
||||
if grants.vacate(IndexClass::Texture, index, owner) {
|
||||
// SAFETY: the caller's contract; the lock is held, so no object is placed there
|
||||
// before its elements are null.
|
||||
unsafe { self.write_texels(device, index, [vk::BufferView::null(); 2]) };
|
||||
counters.fall(Gauge::DescriptorSlots);
|
||||
}
|
||||
}
|
||||
|
||||
/// Writes a texture buffer's elements at `index`: the uniform texel-buffer array's with
|
||||
/// `views[0]` and the storage one's with `views[1]`, a null descriptor where a view is null.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The grants' lock is held by a placement or a vacating of the index, and each view is live
|
||||
/// and of the device whenever work uses it.
|
||||
unsafe fn write_texels(&self, device: &ash::Device, index: u32, views: [vk::BufferView; 2]) {
|
||||
let (uniform, storage) = ([views[0]], [views[1]]);
|
||||
let writes = [
|
||||
texel_write(
|
||||
self.set,
|
||||
UNIFORM_TEXELS_BINDING,
|
||||
vk::DescriptorType::UNIFORM_TEXEL_BUFFER,
|
||||
&uniform,
|
||||
)
|
||||
.dst_array_element(index),
|
||||
texel_write(
|
||||
self.set,
|
||||
STORAGE_TEXELS_BINDING,
|
||||
vk::DescriptorType::STORAGE_TEXEL_BUFFER,
|
||||
&storage,
|
||||
)
|
||||
.dst_array_element(index),
|
||||
];
|
||||
// SAFETY: the caller's contract; the bindings are update-after-bind and
|
||||
// update-unused-while-pending, so elements of other owners may be written meanwhile, and
|
||||
// a null buffer view is a null descriptor under `nullDescriptor`.
|
||||
unsafe { device.update_descriptor_sets(&writes, &[]) };
|
||||
}
|
||||
|
||||
/// Writes the second element of the texture of `owner` at `index` with `view`, its view of its
|
||||
/// image's shadow, in the shadow's home layout, shader-read-only, where the texture still owns
|
||||
/// the index: a draw reads an attachment through it on a device without the attachment
|
||||
@@ -740,6 +856,14 @@ impl Made {
|
||||
ty: vk::DescriptorType::SAMPLER,
|
||||
descriptor_count: SAMPLER_ARRAYS * SAMPLERS,
|
||||
},
|
||||
vk::DescriptorPoolSize {
|
||||
ty: vk::DescriptorType::UNIFORM_TEXEL_BUFFER,
|
||||
descriptor_count: TEXTURES,
|
||||
},
|
||||
vk::DescriptorPoolSize {
|
||||
ty: vk::DescriptorType::STORAGE_TEXEL_BUFFER,
|
||||
descriptor_count: TEXTURES,
|
||||
},
|
||||
];
|
||||
let info = vk::DescriptorPoolCreateInfo::default()
|
||||
.flags(vk::DescriptorPoolCreateFlags::UPDATE_AFTER_BIND)
|
||||
@@ -815,10 +939,10 @@ impl Made {
|
||||
|
||||
/// Runs `f` with set 1's layout, `counts` elements in each binding of [`BINDINGS`].
|
||||
pub(crate) fn with_arrays_layout<R>(
|
||||
counts: [u32; 5],
|
||||
counts: [u32; 7],
|
||||
f: impl FnOnce(&vk::DescriptorSetLayoutCreateInfo) -> R,
|
||||
) -> R {
|
||||
let bindings = std::array::from_fn::<_, 5, _>(|index| {
|
||||
let bindings = std::array::from_fn::<_, 7, _>(|index| {
|
||||
let (binding, ty, _) = BINDINGS[index];
|
||||
vk::DescriptorSetLayoutBinding::default()
|
||||
.binding(binding)
|
||||
@@ -828,7 +952,7 @@ pub(crate) fn with_arrays_layout<R>(
|
||||
});
|
||||
let flags = [vk::DescriptorBindingFlags::PARTIALLY_BOUND
|
||||
| vk::DescriptorBindingFlags::UPDATE_AFTER_BIND
|
||||
| vk::DescriptorBindingFlags::UPDATE_UNUSED_WHILE_PENDING; 5];
|
||||
| vk::DescriptorBindingFlags::UPDATE_UNUSED_WHILE_PENDING; 7];
|
||||
let mut binding_flags =
|
||||
vk::DescriptorSetLayoutBindingFlagsCreateInfo::default().binding_flags(&flags);
|
||||
let info = vk::DescriptorSetLayoutCreateInfo::default()
|
||||
@@ -869,9 +993,9 @@ pub(crate) fn sampled_images(seconds: bool) -> u32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Writes every element of `set` its default: a null descriptor in each texture array, the
|
||||
/// sampled-texture array's `sampled` elements, `plain` in the plain and integer-texture sampler
|
||||
/// arrays and `compare` in the comparison array.
|
||||
/// Writes every element of `set` its default: a null descriptor in each texture and texel-buffer
|
||||
/// array, the sampled-texture array's `sampled` elements, `plain` in the plain and
|
||||
/// integer-texture sampler arrays and `compare` in the comparison array.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
@@ -896,6 +1020,7 @@ unsafe fn fill(
|
||||
let samplers =
|
||||
|sampler| vec![vk::DescriptorImageInfo::default().sampler(sampler); SAMPLERS as usize];
|
||||
let (plains, compares) = (samplers(plain), samplers(compare));
|
||||
let texels = vec![vk::BufferView::null(); TEXTURES as usize];
|
||||
let writes = [
|
||||
write(
|
||||
set,
|
||||
@@ -927,12 +1052,38 @@ unsafe fn fill(
|
||||
vk::DescriptorType::SAMPLER,
|
||||
&plains,
|
||||
),
|
||||
texel_write(
|
||||
set,
|
||||
UNIFORM_TEXELS_BINDING,
|
||||
vk::DescriptorType::UNIFORM_TEXEL_BUFFER,
|
||||
&texels,
|
||||
),
|
||||
texel_write(
|
||||
set,
|
||||
STORAGE_TEXELS_BINDING,
|
||||
vk::DescriptorType::STORAGE_TEXEL_BUFFER,
|
||||
&texels,
|
||||
),
|
||||
];
|
||||
// SAFETY: the caller's contract; a null image view is a null descriptor under
|
||||
// SAFETY: the caller's contract; a null image or buffer view is a null descriptor under
|
||||
// `nullDescriptor`, and each sampler is the device's.
|
||||
unsafe { device.update_descriptor_sets(&writes, &[]) };
|
||||
}
|
||||
|
||||
/// The write of `views` into texel-buffer `binding` of `set`, from its first element.
|
||||
fn texel_write(
|
||||
set: vk::DescriptorSet,
|
||||
binding: u32,
|
||||
ty: vk::DescriptorType,
|
||||
views: &[vk::BufferView],
|
||||
) -> vk::WriteDescriptorSet<'_> {
|
||||
vk::WriteDescriptorSet::default()
|
||||
.dst_set(set)
|
||||
.dst_binding(binding)
|
||||
.descriptor_type(ty)
|
||||
.texel_buffer_view(views)
|
||||
}
|
||||
|
||||
/// The write of `infos` into `binding` of `set`, from its first element.
|
||||
fn write(
|
||||
set: vk::DescriptorSet,
|
||||
|
||||
@@ -196,6 +196,13 @@ impl BlitCommandEncoder {
|
||||
if !source.is_of(core) || !destination.is_of(core) {
|
||||
return Err(Error::Refused(Refusal::OtherDevice));
|
||||
}
|
||||
// A texture buffer's texels are its buffer's bytes, which no image copy reaches.
|
||||
if source.texels() || destination.texels() {
|
||||
return Err(Error::Unsupported(Gap::TextureCopy {
|
||||
source: source.descriptor().pixel_format,
|
||||
destination: destination.descriptor().pixel_format,
|
||||
}));
|
||||
}
|
||||
let same = source.id() == destination.id();
|
||||
let sides = (Side::of(source), Side::of(destination));
|
||||
let Some(copy) = texture_copy(&sides.0, from, size, &sides.1, to, same)? else {
|
||||
@@ -476,6 +483,12 @@ impl BlitCommandEncoder {
|
||||
if !texture.is_of(&self.core) || !buffer.is_of(&self.core) {
|
||||
return Err(Error::Refused(Refusal::OtherDevice));
|
||||
}
|
||||
// A texture buffer's texels are its buffer's bytes, which no image copy reaches.
|
||||
if texture.texels() {
|
||||
return Err(Error::Unsupported(Gap::TextureBytes {
|
||||
pixel_format: texture.descriptor().pixel_format,
|
||||
}));
|
||||
}
|
||||
// A Managed buffer's GPU side is its device copy, where it has one.
|
||||
let base = buffer.device_range().1;
|
||||
let lies = Lies {
|
||||
|
||||
@@ -352,6 +352,8 @@ pub(crate) struct Core {
|
||||
pub(crate) constexprs: Mutex<HashMap<(u32, [u64; 2]), Constexpr>>,
|
||||
/// [`Device::minimum_linear_texture_alignment`]'s answers, one per pixel format asked.
|
||||
pub(crate) linear_alignments: Mutex<HashMap<metal2vulkan::metal::PixelFormat, u64>>,
|
||||
/// What a texture buffer's offset and width take ([`Device::minimum_texture_buffer_alignment`]).
|
||||
pub(crate) texels: crate::texture::TexelLimits,
|
||||
/// The live textures over a buffer in an image of their own (`crate::over`): while there are
|
||||
/// any, the commands track what they write.
|
||||
pub(crate) copied_overs: AtomicUsize,
|
||||
@@ -715,6 +717,19 @@ impl Device {
|
||||
let max_block_len = vulkan11
|
||||
.max_memory_allocation_size
|
||||
.min(vulkan13.max_buffer_size);
|
||||
let texels = crate::texture::TexelLimits {
|
||||
alignments: [
|
||||
(
|
||||
vulkan13.uniform_texel_buffer_offset_alignment_bytes,
|
||||
vulkan13.uniform_texel_buffer_offset_single_texel_alignment == vk::TRUE,
|
||||
),
|
||||
(
|
||||
vulkan13.storage_texel_buffer_offset_alignment_bytes,
|
||||
vulkan13.storage_texel_buffer_offset_single_texel_alignment == vk::TRUE,
|
||||
),
|
||||
],
|
||||
max_elements: limits.max_texel_buffer_elements,
|
||||
};
|
||||
let limits = EncoderLimits {
|
||||
max_group_count: limits.max_compute_work_group_count,
|
||||
max_shared_memory: limits.max_compute_shared_memory_size,
|
||||
@@ -803,6 +818,7 @@ impl Device {
|
||||
samplers: Mutex::new(SamplerTable::new(sampler_cap)),
|
||||
constexprs: Mutex::new(HashMap::new()),
|
||||
linear_alignments: Mutex::new(HashMap::new()),
|
||||
texels,
|
||||
copied_overs: AtomicUsize::new(0),
|
||||
limits,
|
||||
ring: Ring::new(),
|
||||
|
||||
@@ -686,7 +686,9 @@ pub enum Refusal {
|
||||
},
|
||||
/// A texture over a buffer ([`Buffer::new_texture`](crate::Buffer::new_texture)) whose rows
|
||||
/// are not a whole number of texels apart or are closer than a row, whose offset is not a
|
||||
/// whole number of texels, or whose texels run past the buffer.
|
||||
/// whole number of texels, or whose texels run past the buffer; a texture buffer
|
||||
/// (`MTLTextureTypeTextureBuffer`) whose `bytesPerRow` is less than its width's bytes, or
|
||||
/// whose texels run past the buffer.
|
||||
///
|
||||
/// Basis: ours (a linear image and a copy read rows whole texels apart from a texel's start,
|
||||
/// and texels past the buffer would lie in memory it does not hold).
|
||||
@@ -698,6 +700,42 @@ pub enum Refusal {
|
||||
/// The buffer's length.
|
||||
len: u64,
|
||||
},
|
||||
/// A texture buffer (`MTLTextureTypeTextureBuffer`) over a buffer
|
||||
/// ([`Buffer::new_texture`](crate::Buffer::new_texture)) whose offset is not a multiple of the
|
||||
/// device's minimum texture-buffer alignment for its pixel format
|
||||
/// ([`Device::minimum_texture_buffer_alignment`](crate::Device::minimum_texture_buffer_alignment)),
|
||||
/// which may differ from what another device answers for the same format. Plain Metal takes
|
||||
/// an offset off its own alignment, which Metal's validation stops (the conformance crate's
|
||||
/// `buffer-textures-made`: offsets of 4, 8, 20 and 33 bytes of an `R32Uint` texture buffer,
|
||||
/// on an Apple M3 Max); a Vulkan buffer view takes none off the device's.
|
||||
///
|
||||
/// Basis: metal-documented (`MTLDevice.h`: `minimumTextureBufferAlignmentForPixelFormat:`
|
||||
/// "Returns the minimum alignment required for offset and rowBytes when creating a texture
|
||||
/// buffer from a buffer").
|
||||
TextureBufferAlignment {
|
||||
/// The texture buffer's pixel format.
|
||||
pixel_format: PixelFormat,
|
||||
/// Its offset in the buffer.
|
||||
offset: u64,
|
||||
/// The device's minimum texture-buffer alignment for the pixel format.
|
||||
alignment: u64,
|
||||
},
|
||||
/// A texture buffer (`MTLTextureTypeTextureBuffer`) made other than over a buffer:
|
||||
/// [`Device::new_texture`](crate::Device::new_texture),
|
||||
/// [`Device::new_texture_for_views`](crate::Device::new_texture_for_views),
|
||||
/// [`Device::new_heap_texture`](crate::Device::new_heap_texture),
|
||||
/// [`Device::new_heap_texture_for_views`](crate::Device::new_heap_texture_for_views),
|
||||
/// [`Device::heap_texture_size_and_align`](crate::Device::heap_texture_size_and_align),
|
||||
/// [`Device::new_managed_texture`](crate::Device::new_managed_texture) and
|
||||
/// [`Device::new_drawable_texture`](crate::Device::new_drawable_texture) of a texture buffer's
|
||||
/// descriptor. The consumer places a buffer of the texture buffer's bytes, as it places every
|
||||
/// buffer, and makes it over that buffer with
|
||||
/// [`Buffer::new_texture`](crate::Buffer::new_texture), where Metal's
|
||||
/// `newTextureWithDescriptor:` of a texture buffer's descriptor allocates the bytes itself.
|
||||
///
|
||||
/// Basis: ours (a texture buffer's texels are a buffer's bytes, read through a buffer view of
|
||||
/// the buffer; the runtime places no buffer of its own).
|
||||
TextureBufferNotOverBuffer,
|
||||
/// A heap texture whose image does not lie in its heap
|
||||
/// ([`Device::new_heap_texture`](crate::Device::new_heap_texture),
|
||||
/// [`Device::new_heap_texture_for_views`](crate::Device::new_heap_texture_for_views)): past
|
||||
@@ -1072,12 +1110,15 @@ pub enum Gap {
|
||||
///
|
||||
/// Basis: ours (render passes are not built).
|
||||
MemorylessTexture,
|
||||
/// A texture buffer (`MTLTextureTypeTextureBuffer`).
|
||||
/// A texture buffer (`MTLTextureTypeTextureBuffer`) with a swizzle other than each channel's
|
||||
/// own ([`Buffer::new_texture`](crate::Buffer::new_texture)), which Metal applies to its reads.
|
||||
///
|
||||
/// Basis: 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).
|
||||
TextureBuffer,
|
||||
/// Basis: ours (a texel buffer view has no component mapping, and a texture's resource ID
|
||||
/// carries no swizzle to the shader; no recorded stream makes one).
|
||||
TextureBufferSwizzle {
|
||||
/// The texture buffer's pixel format.
|
||||
pixel_format: PixelFormat,
|
||||
},
|
||||
/// 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
|
||||
@@ -1123,9 +1164,11 @@ pub enum Gap {
|
||||
/// texture whose image is no plain copy of Metal's bytes in one aspect: a format of depth and
|
||||
/// stencil both but in a copy of a plane option
|
||||
/// ([`BlitOption`](crate::BlitOption)), or a multisample texture. Also a plane option of a
|
||||
/// format without the aspect it names.
|
||||
/// format without the aspect it names, and a blit copy between a buffer and a texture buffer,
|
||||
/// whose texels are its own buffer's bytes.
|
||||
///
|
||||
/// Basis: ours (no copy between such an image and bytes is built).
|
||||
/// Basis: ours (no copy between such an image and bytes is built, nor a texture buffer's
|
||||
/// copy as a buffer copy; no recorded stream copies a texture buffer).
|
||||
TextureBytes {
|
||||
/// The texture's pixel format.
|
||||
pixel_format: PixelFormat,
|
||||
@@ -1148,7 +1191,8 @@ pub enum Gap {
|
||||
/// usages chose; a 1D texture with one of another type; or regions of two textures in place
|
||||
/// over one buffer whose rows meet shifted both ways, or not shifted, along each axis, so
|
||||
/// that no cut into slabs along one axis copies them as from the source before the copy (a
|
||||
/// destination row across the end of its own source row and the start of the next is one).
|
||||
/// destination row across the end of its own source row and the start of the next is one);
|
||||
/// or a texture buffer, whose texels are its buffer's bytes and no image.
|
||||
///
|
||||
/// Basis: ours (Vulkan 1.3 copies none of these with one command, nor these regions in slabs
|
||||
/// along one axis; each is built when a replay stream makes one).
|
||||
@@ -1159,11 +1203,14 @@ pub enum Gap {
|
||||
destination: PixelFormat,
|
||||
},
|
||||
/// A texture over a buffer ([`Buffer::new_texture`](crate::Buffer::new_texture)) the runtime
|
||||
/// does not make: other than 2D of one level, sample and slice; of a format of other than
|
||||
/// one color texel an element; or whose first texel in the bytes shaders reach is not a whole
|
||||
/// number of texels in, which no copy addresses.
|
||||
/// does not make: other than 2D of one level, sample and slice, or a texture buffer; of a
|
||||
/// format of other than one color texel an element; whose first texel in the bytes shaders
|
||||
/// reach is not a whole number of texels in, which no copy addresses; or a texture buffer whose
|
||||
/// first texel there is not a multiple of the device's texel-buffer offset alignment for its
|
||||
/// format, where the buffer's own place in its memory is not.
|
||||
///
|
||||
/// Basis: ours (the in-place linear image and the copy form take one 2D color image).
|
||||
/// Basis: ours (the in-place linear image and the copy form take one 2D color image, and a
|
||||
/// texture buffer's view the texel-buffer offset alignment of Vulkan 1.3).
|
||||
TextureOverBuffer {
|
||||
/// The texture's pixel format.
|
||||
pixel_format: PixelFormat,
|
||||
@@ -1750,6 +1797,9 @@ pub enum TextureViewKind {
|
||||
CubeOfArray,
|
||||
/// Some of the slices of a texture that is not a 1D or 2D array: a 2D multisample array's.
|
||||
Slices,
|
||||
/// A view of a texture buffer: its texels are its buffer's bytes, read through a buffer view
|
||||
/// that takes no other format, type or swizzle.
|
||||
TextureBuffer,
|
||||
}
|
||||
|
||||
/// A limit a call ran into, with what it was asked.
|
||||
@@ -1823,9 +1873,11 @@ pub enum Limit {
|
||||
count: u32,
|
||||
},
|
||||
/// A texture whose extent or array layers are past what the device makes of its format,
|
||||
/// type, usage and sample count. A cube's layers are six a cube.
|
||||
/// type, usage and sample count. A cube's layers are six a cube. A texture buffer's width past
|
||||
/// the device's texel buffer elements, its extent `[width, 1, 1]` in 1 layer.
|
||||
///
|
||||
/// Basis: device (the image format query's `maxExtent` and `maxArrayLayers`).
|
||||
/// Basis: device (the image format query's `maxExtent` and `maxArrayLayers`, and
|
||||
/// `maxTexelBufferElements`).
|
||||
TextureSize {
|
||||
/// The extent asked for.
|
||||
extent: [u32; 3],
|
||||
@@ -2320,6 +2372,17 @@ impl fmt::Display for Refusal {
|
||||
f,
|
||||
"a texture at offset {offset}, rows {bytes_per_row} bytes apart, does not lie in whole texels inside a buffer of {len} bytes"
|
||||
),
|
||||
Refusal::TextureBufferAlignment {
|
||||
pixel_format,
|
||||
offset,
|
||||
alignment,
|
||||
} => write!(
|
||||
f,
|
||||
"a texture buffer of {pixel_format:?} at offset {offset} is off the device's texture-buffer alignment of {alignment} bytes"
|
||||
),
|
||||
Refusal::TextureBufferNotOverBuffer => f.write_str(
|
||||
"a texture buffer is made over a buffer the consumer places (Buffer::new_texture)",
|
||||
),
|
||||
Refusal::HeapTexturePlace {
|
||||
offset,
|
||||
size,
|
||||
@@ -2478,7 +2541,10 @@ impl fmt::Display for Gap {
|
||||
Gap::LodClamps => f.write_str(
|
||||
"a sampler state's bind-time LOD clamps that read otherwise than its own are not built",
|
||||
),
|
||||
Gap::TextureBuffer => f.write_str("texture buffers are not built"),
|
||||
Gap::TextureBufferSwizzle { pixel_format } => write!(
|
||||
f,
|
||||
"a swizzled texture buffer of {pixel_format:?} is not built"
|
||||
),
|
||||
Gap::TextureFormat { pixel_format } => write!(
|
||||
f,
|
||||
"no texture of {pixel_format:?} is made on this device for the usage"
|
||||
|
||||
@@ -171,9 +171,11 @@ fn shader_extension(name: &CStr) -> Option<VkExtension> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Slots in each texture array, the sampled and the storage: the most textures alive at once,
|
||||
/// each at its index in both. Vulkan's least update-after-bind sampled and storage images, per
|
||||
/// stage and per set, is 500,000 on a device that supports `descriptorIndexing`.
|
||||
/// Slots in each texture array, the sampled and the storage, and in each texel-buffer array, the
|
||||
/// uniform and the storage: the most textures alive at once, each at its index in all four. A
|
||||
/// uniform texel buffer counts as a sampled image and a storage one as a storage image against the
|
||||
/// update-after-bind limits, whose least, per stage and per set, is 500,000 on a device that
|
||||
/// supports `descriptorIndexing`.
|
||||
pub(crate) const TEXTURES: u32 = 65_536;
|
||||
|
||||
/// Slots in each sampler array. 4000 is Vulkan's minimum `maxSamplerAllocationCount`, so every
|
||||
@@ -421,6 +423,14 @@ pub(crate) const REQUIRED: &[Feature] = &[
|
||||
feature!(core.shader_storage_image_array_dynamic_indexing => ShaderStorageImageArrayDynamicIndexing),
|
||||
feature!(vulkan12.shader_sampled_image_array_non_uniform_indexing => ShaderSampledImageArrayNonUniformIndexing),
|
||||
feature!(vulkan12.shader_storage_image_array_non_uniform_indexing => ShaderStorageImageArrayNonUniformIndexing),
|
||||
// One texel-buffer array per use of a texture buffer, read and written, indexed by its
|
||||
// `gpuResourceID` as the texture arrays are. Every recorded device reports the six.
|
||||
feature!(vulkan12.descriptor_binding_uniform_texel_buffer_update_after_bind => DescriptorBindingUniformTexelBufferUpdateAfterBind),
|
||||
feature!(vulkan12.descriptor_binding_storage_texel_buffer_update_after_bind => DescriptorBindingStorageTexelBufferUpdateAfterBind),
|
||||
feature!(vulkan12.shader_uniform_texel_buffer_array_dynamic_indexing => ShaderUniformTexelBufferArrayDynamicIndexing),
|
||||
feature!(vulkan12.shader_storage_texel_buffer_array_dynamic_indexing => ShaderStorageTexelBufferArrayDynamicIndexing),
|
||||
feature!(vulkan12.shader_uniform_texel_buffer_array_non_uniform_indexing => ShaderUniformTexelBufferArrayNonUniformIndexing),
|
||||
feature!(vulkan12.shader_storage_texel_buffer_array_non_uniform_indexing => ShaderStorageTexelBufferArrayNonUniformIndexing),
|
||||
feature!(core.shader_storage_image_write_without_format => ShaderStorageImageWriteWithoutFormat),
|
||||
// A read-write texture of a format Vulkan lists among the storage image extended formats
|
||||
// (`RG16Float`, `RG11B10Float`, `R8Unorm` and the rest), declared with its format where a
|
||||
@@ -1369,17 +1379,18 @@ pub(crate) fn flag_names(flags: vk::MemoryPropertyFlags) -> String {
|
||||
|
||||
/// Whether the device's descriptor limits hold the sampled-texture array's second elements
|
||||
/// (`arrays::sampled_images`) beside the floor's arrays: what the attachment reads take beyond
|
||||
/// [`limits`].
|
||||
/// [`limits`]. A uniform texel buffer counts as a sampled image, and a storage one as a storage
|
||||
/// image.
|
||||
fn second_elements_fit(device: &Queried) -> bool {
|
||||
let limits = &device.limits;
|
||||
let descriptors = &device.vulkan12;
|
||||
let sampled = 2 * TEXTURES;
|
||||
let sampled = 3 * TEXTURES;
|
||||
descriptors.max_per_stage_descriptor_update_after_bind_sampled_images >= sampled
|
||||
&& descriptors.max_descriptor_set_update_after_bind_sampled_images >= sampled
|
||||
&& descriptors.max_per_stage_update_after_bind_resources
|
||||
>= sampled + TEXTURES + limits.max_color_attachments
|
||||
>= sampled + 2 * TEXTURES + limits.max_color_attachments
|
||||
&& descriptors.max_update_after_bind_descriptors_in_all_pools
|
||||
>= sampled + TEXTURES + SAMPLER_ARRAYS * SAMPLERS
|
||||
>= sampled + 2 * TEXTURES + SAMPLER_ARRAYS * SAMPLERS
|
||||
}
|
||||
|
||||
/// Each limit the floor sets: its Vulkan name, the device's value, and the least value the runtime
|
||||
@@ -1387,26 +1398,27 @@ fn second_elements_fit(device: &Queried) -> bool {
|
||||
pub(crate) fn limits(device: &Queried) -> [(&'static str, u32, u32); 18] {
|
||||
let limits = &device.limits;
|
||||
let descriptors = &device.vulkan12;
|
||||
// A uniform texel buffer counts as a sampled image, and a storage one as a storage image.
|
||||
[
|
||||
(
|
||||
"maxPerStageDescriptorUpdateAfterBindSampledImages",
|
||||
descriptors.max_per_stage_descriptor_update_after_bind_sampled_images,
|
||||
TEXTURES,
|
||||
2 * TEXTURES,
|
||||
),
|
||||
(
|
||||
"maxDescriptorSetUpdateAfterBindSampledImages",
|
||||
descriptors.max_descriptor_set_update_after_bind_sampled_images,
|
||||
TEXTURES,
|
||||
2 * TEXTURES,
|
||||
),
|
||||
(
|
||||
"maxPerStageDescriptorUpdateAfterBindStorageImages",
|
||||
descriptors.max_per_stage_descriptor_update_after_bind_storage_images,
|
||||
TEXTURES,
|
||||
2 * TEXTURES,
|
||||
),
|
||||
(
|
||||
"maxDescriptorSetUpdateAfterBindStorageImages",
|
||||
descriptors.max_descriptor_set_update_after_bind_storage_images,
|
||||
TEXTURES,
|
||||
2 * TEXTURES,
|
||||
),
|
||||
(
|
||||
"maxPerStageDescriptorUpdateAfterBindSamplers",
|
||||
@@ -1427,12 +1439,12 @@ pub(crate) fn limits(device: &Queried) -> [(&'static str, u32, u32); 18] {
|
||||
(
|
||||
"maxPerStageUpdateAfterBindResources",
|
||||
descriptors.max_per_stage_update_after_bind_resources,
|
||||
2 * TEXTURES + limits.max_color_attachments,
|
||||
4 * TEXTURES + limits.max_color_attachments,
|
||||
),
|
||||
(
|
||||
"maxUpdateAfterBindDescriptorsInAllPools",
|
||||
descriptors.max_update_after_bind_descriptors_in_all_pools,
|
||||
2 * TEXTURES + SAMPLER_ARRAYS * SAMPLERS,
|
||||
4 * TEXTURES + SAMPLER_ARRAYS * SAMPLERS,
|
||||
),
|
||||
(
|
||||
"maxPushConstantsSize",
|
||||
|
||||
@@ -953,7 +953,12 @@ impl Pool {
|
||||
/// so it is vacated before the program's release returns. Releases keep their order.
|
||||
pub(crate) fn release(&self, core: &Core, object: Free) {
|
||||
let now = matches!(self.noted(), Wait::Progress(0));
|
||||
if now && matches!(object, Free::TextureIndex(..) | Free::SamplerIndex(..)) {
|
||||
if now
|
||||
&& matches!(
|
||||
object,
|
||||
Free::TextureIndex(..) | Free::TexelIndex(..) | Free::SamplerIndex(..)
|
||||
)
|
||||
{
|
||||
return crate::reaper::free(core, object);
|
||||
}
|
||||
let mut state = self.lock();
|
||||
@@ -1686,7 +1691,7 @@ pub(crate) fn run(core: Arc<Core>) {
|
||||
// An index goes here, before the gauge falls, so every released index is vacated once
|
||||
// nothing waits; an object goes to the reaper.
|
||||
match object {
|
||||
Free::TextureIndex(..) | Free::SamplerIndex(..) => {
|
||||
Free::TextureIndex(..) | Free::TexelIndex(..) | Free::SamplerIndex(..) => {
|
||||
crate::reaper::free(&core, object)
|
||||
}
|
||||
_ => core.reaper.give(Job::Free(object)),
|
||||
|
||||
@@ -84,6 +84,10 @@ pub(crate) enum Free {
|
||||
/// A released texture's index and owner word, its second element too where it says so
|
||||
/// (`Arrays::vacate_texture`).
|
||||
TextureIndex((u32, Owner), bool),
|
||||
/// A released texture buffer's index and owner word (`Arrays::vacate_texels`).
|
||||
TexelIndex((u32, Owner)),
|
||||
/// A dropped texture buffer's buffer view; the textures gauge falls with it.
|
||||
TexelView(vk::BufferView),
|
||||
/// A released sampler state's index and owner word (`Arrays::vacate_samplers`).
|
||||
SamplerIndex(u32, Owner),
|
||||
}
|
||||
@@ -250,6 +254,14 @@ pub(crate) fn free(core: &Core, object: Free) {
|
||||
(core.arrays).vacate_texture(device, &core.counters, at, second)
|
||||
},
|
||||
// SAFETY: as above.
|
||||
Free::TexelIndex(at) => unsafe { (core.arrays).vacate_texels(device, &core.counters, at) },
|
||||
Free::TexelView(view) => {
|
||||
// SAFETY: no pending work uses it: every command buffer that used the texture buffer
|
||||
// held it until it retired, and its elements of set 1 are null or another texture's.
|
||||
unsafe { device.destroy_buffer_view(view, None) };
|
||||
core.counters.fall(Gauge::Textures);
|
||||
}
|
||||
// SAFETY: as above.
|
||||
Free::SamplerIndex(index, owner) => unsafe {
|
||||
(core.arrays).vacate_samplers(device, &core.counters, index, owner)
|
||||
},
|
||||
|
||||
@@ -56,6 +56,24 @@ fn at_the_floor() -> Queried {
|
||||
features
|
||||
.vulkan12
|
||||
.shader_storage_image_array_non_uniform_indexing = vk::TRUE;
|
||||
features
|
||||
.vulkan12
|
||||
.descriptor_binding_uniform_texel_buffer_update_after_bind = vk::TRUE;
|
||||
features
|
||||
.vulkan12
|
||||
.descriptor_binding_storage_texel_buffer_update_after_bind = vk::TRUE;
|
||||
features
|
||||
.vulkan12
|
||||
.shader_uniform_texel_buffer_array_dynamic_indexing = vk::TRUE;
|
||||
features
|
||||
.vulkan12
|
||||
.shader_storage_texel_buffer_array_dynamic_indexing = vk::TRUE;
|
||||
features
|
||||
.vulkan12
|
||||
.shader_uniform_texel_buffer_array_non_uniform_indexing = vk::TRUE;
|
||||
features
|
||||
.vulkan12
|
||||
.shader_storage_texel_buffer_array_non_uniform_indexing = vk::TRUE;
|
||||
features.core.shader_storage_image_write_without_format = vk::TRUE;
|
||||
features.core.sampler_anisotropy = vk::TRUE;
|
||||
features.core.shader_storage_image_extended_formats = vk::TRUE;
|
||||
@@ -119,14 +137,14 @@ fn at_the_floor() -> Queried {
|
||||
.timestamp_compute_and_graphics(true)
|
||||
.standard_sample_locations(true),
|
||||
vulkan12: vk::PhysicalDeviceVulkan12Properties::default()
|
||||
.max_per_stage_descriptor_update_after_bind_sampled_images(65_536)
|
||||
.max_descriptor_set_update_after_bind_sampled_images(65_536)
|
||||
.max_per_stage_descriptor_update_after_bind_storage_images(65_536)
|
||||
.max_descriptor_set_update_after_bind_storage_images(65_536)
|
||||
.max_per_stage_descriptor_update_after_bind_sampled_images(2 * 65_536)
|
||||
.max_descriptor_set_update_after_bind_sampled_images(2 * 65_536)
|
||||
.max_per_stage_descriptor_update_after_bind_storage_images(2 * 65_536)
|
||||
.max_descriptor_set_update_after_bind_storage_images(2 * 65_536)
|
||||
.max_per_stage_descriptor_update_after_bind_samplers(3 * 4000)
|
||||
.max_descriptor_set_update_after_bind_samplers(3 * 4000)
|
||||
.max_per_stage_update_after_bind_resources(2 * 65_536 + 8)
|
||||
.max_update_after_bind_descriptors_in_all_pools(2 * 65_536 + 3 * 4000),
|
||||
.max_per_stage_update_after_bind_resources(4 * 65_536 + 8)
|
||||
.max_update_after_bind_descriptors_in_all_pools(4 * 65_536 + 3 * 4000),
|
||||
features,
|
||||
extensions: DEVICE_EXTENSIONS
|
||||
.iter()
|
||||
@@ -458,7 +476,7 @@ fn each_missing_feature_is_named() {
|
||||
const CORE: &str = "VkPhysicalDeviceFeatures";
|
||||
const ROBUSTNESS2: &str = "VkPhysicalDeviceRobustness2FeaturesEXT";
|
||||
type Clear = fn(&mut Features);
|
||||
let cases: [(Clear, Missing); 61] = [
|
||||
let cases: [(Clear, Missing); 67] = [
|
||||
(
|
||||
|f| f.vulkan12.buffer_device_address = vk::FALSE,
|
||||
feature(V12, "bufferDeviceAddress"),
|
||||
@@ -509,6 +527,48 @@ fn each_missing_feature_is_named() {
|
||||
|f| f.vulkan12.shader_storage_image_array_non_uniform_indexing = vk::FALSE,
|
||||
feature(V12, "shaderStorageImageArrayNonUniformIndexing"),
|
||||
),
|
||||
(
|
||||
|f| {
|
||||
f.vulkan12
|
||||
.descriptor_binding_uniform_texel_buffer_update_after_bind = vk::FALSE
|
||||
},
|
||||
feature(V12, "descriptorBindingUniformTexelBufferUpdateAfterBind"),
|
||||
),
|
||||
(
|
||||
|f| {
|
||||
f.vulkan12
|
||||
.descriptor_binding_storage_texel_buffer_update_after_bind = vk::FALSE
|
||||
},
|
||||
feature(V12, "descriptorBindingStorageTexelBufferUpdateAfterBind"),
|
||||
),
|
||||
(
|
||||
|f| {
|
||||
f.vulkan12
|
||||
.shader_uniform_texel_buffer_array_dynamic_indexing = vk::FALSE
|
||||
},
|
||||
feature(V12, "shaderUniformTexelBufferArrayDynamicIndexing"),
|
||||
),
|
||||
(
|
||||
|f| {
|
||||
f.vulkan12
|
||||
.shader_storage_texel_buffer_array_dynamic_indexing = vk::FALSE
|
||||
},
|
||||
feature(V12, "shaderStorageTexelBufferArrayDynamicIndexing"),
|
||||
),
|
||||
(
|
||||
|f| {
|
||||
f.vulkan12
|
||||
.shader_uniform_texel_buffer_array_non_uniform_indexing = vk::FALSE
|
||||
},
|
||||
feature(V12, "shaderUniformTexelBufferArrayNonUniformIndexing"),
|
||||
),
|
||||
(
|
||||
|f| {
|
||||
f.vulkan12
|
||||
.shader_storage_texel_buffer_array_non_uniform_indexing = vk::FALSE
|
||||
},
|
||||
feature(V12, "shaderStorageTexelBufferArrayNonUniformIndexing"),
|
||||
),
|
||||
(
|
||||
|f| f.core.shader_storage_image_write_without_format = vk::FALSE,
|
||||
feature(CORE, "shaderStorageImageWriteWithoutFormat"),
|
||||
@@ -729,34 +789,34 @@ fn each_low_limit_is_named() {
|
||||
(
|
||||
|d| {
|
||||
d.vulkan12
|
||||
.max_per_stage_descriptor_update_after_bind_sampled_images = 65_535
|
||||
.max_per_stage_descriptor_update_after_bind_sampled_images = 2 * 65_536 - 1
|
||||
},
|
||||
"maxPerStageDescriptorUpdateAfterBindSampledImages",
|
||||
65_536,
|
||||
2 * 65_536,
|
||||
),
|
||||
(
|
||||
|d| {
|
||||
d.vulkan12
|
||||
.max_descriptor_set_update_after_bind_sampled_images = 65_535
|
||||
.max_descriptor_set_update_after_bind_sampled_images = 2 * 65_536 - 1
|
||||
},
|
||||
"maxDescriptorSetUpdateAfterBindSampledImages",
|
||||
65_536,
|
||||
2 * 65_536,
|
||||
),
|
||||
(
|
||||
|d| {
|
||||
d.vulkan12
|
||||
.max_per_stage_descriptor_update_after_bind_storage_images = 65_535
|
||||
.max_per_stage_descriptor_update_after_bind_storage_images = 2 * 65_536 - 1
|
||||
},
|
||||
"maxPerStageDescriptorUpdateAfterBindStorageImages",
|
||||
65_536,
|
||||
2 * 65_536,
|
||||
),
|
||||
(
|
||||
|d| {
|
||||
d.vulkan12
|
||||
.max_descriptor_set_update_after_bind_storage_images = 65_535
|
||||
.max_descriptor_set_update_after_bind_storage_images = 2 * 65_536 - 1
|
||||
},
|
||||
"maxDescriptorSetUpdateAfterBindStorageImages",
|
||||
65_536,
|
||||
2 * 65_536,
|
||||
),
|
||||
(
|
||||
|d| {
|
||||
@@ -777,14 +837,14 @@ fn each_low_limit_is_named() {
|
||||
4000,
|
||||
),
|
||||
(
|
||||
|d| d.vulkan12.max_per_stage_update_after_bind_resources = 2 * 65_536 + 7,
|
||||
|d| d.vulkan12.max_per_stage_update_after_bind_resources = 4 * 65_536 + 7,
|
||||
"maxPerStageUpdateAfterBindResources",
|
||||
2 * 65_536 + 8,
|
||||
4 * 65_536 + 8,
|
||||
),
|
||||
(
|
||||
|d| d.vulkan12.max_update_after_bind_descriptors_in_all_pools = 2 * 65_536 + 11_999,
|
||||
|d| d.vulkan12.max_update_after_bind_descriptors_in_all_pools = 4 * 65_536 + 11_999,
|
||||
"maxUpdateAfterBindDescriptorsInAllPools",
|
||||
2 * 65_536 + 12_000,
|
||||
4 * 65_536 + 12_000,
|
||||
),
|
||||
(
|
||||
|d| d.limits.max_push_constants_size = 255,
|
||||
@@ -1534,10 +1594,10 @@ fn the_fault_report_is_enabled_where_listed_and_reported() {
|
||||
fn the_attachment_reads_take_the_feedback_loop_where_reported_and_a_copy_elsewhere() {
|
||||
let roomy = |device: &mut Queried| {
|
||||
let descriptors = &mut device.vulkan12;
|
||||
descriptors.max_per_stage_descriptor_update_after_bind_sampled_images = 2 * 65_536;
|
||||
descriptors.max_descriptor_set_update_after_bind_sampled_images = 2 * 65_536;
|
||||
descriptors.max_per_stage_update_after_bind_resources = 3 * 65_536 + 8;
|
||||
descriptors.max_update_after_bind_descriptors_in_all_pools = 3 * 65_536 + 3 * 4000;
|
||||
descriptors.max_per_stage_descriptor_update_after_bind_sampled_images = 3 * 65_536;
|
||||
descriptors.max_descriptor_set_update_after_bind_sampled_images = 3 * 65_536;
|
||||
descriptors.max_per_stage_update_after_bind_resources = 5 * 65_536 + 8;
|
||||
descriptors.max_update_after_bind_descriptors_in_all_pools = 5 * 65_536 + 3 * 4000;
|
||||
};
|
||||
let looped = |device: &mut Queried| {
|
||||
(device.extensions).extend(
|
||||
|
||||
@@ -102,6 +102,7 @@ mod swizzle;
|
||||
mod take_split;
|
||||
mod texture;
|
||||
mod texture_accesses;
|
||||
mod texture_buffers;
|
||||
mod translate;
|
||||
mod translator_fields;
|
||||
mod upload;
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
//! Texture buffers (`MTLTextureTypeTextureBuffer`), under a device cfg on every device of the cfg's
|
||||
//! kind, each a buffer view of a Shared buffer's bytes ([`crate::Buffer::new_texture`]):
|
||||
//!
|
||||
//! - the owned fixture `ob1_texel_buffer` reads four `R32Uint` texels of one texture buffer, at a
|
||||
//! nonzero offset in its buffer, through the uniform texel-buffer array, and writes four of
|
||||
//! another through the storage array: in bounds it reads the buffer's bytes and writes them,
|
||||
//! and past the width it reads zero and writes nothing, as the Metal Shading Language defines
|
||||
//! (a read out of bounds returns zero, a write out of bounds is ignored); the bytes around both
|
||||
//! keep theirs, and the host reads the written texels through the texture and the buffer alike;
|
||||
//! - an owned kernel adds to an `R32Uint` texture buffer's texels through an atomic and loads them
|
||||
//! again (`access::read_write`), answering the texels the buffer held and leaving the sums there;
|
||||
//! - what Metal refuses (an offset off the device's alignment, a `bytesPerRow` below the row,
|
||||
//! texels past the buffer, a descriptor of more than one row, level, slice or sample, a swizzle
|
||||
//! with writes) and what the runtime does not build (a texture buffer made other than over a
|
||||
//! buffer, a swizzled one, a view of one, a blit copy of one, a format held through a component
|
||||
//! mapping) are each refused typed.
|
||||
//!
|
||||
//! The device's gauges read zero once each test's device is gone (`each_device`), every texture
|
||||
//! buffer's view freed with it. `llvm-as` assembles the functions; without it the tests skip
|
||||
//! visibly.
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::tests::command::on_device::{each_device, finished};
|
||||
use crate::{
|
||||
BlitOption, Buffer, BufferLayout, ComputePipelineDescriptor, ComputePipelineState, Device,
|
||||
DispatchType, Error, FunctionDescriptor, Gap, IndexClass, Library, MemoryClass,
|
||||
PixelFormat, Refusal, Region, StageSource, StorageMode, Texture, TextureDescriptor,
|
||||
TexturePlace, TextureSwizzle, TextureSwizzleChannels, TextureType, TextureUsage,
|
||||
TextureViewKind,
|
||||
};
|
||||
use metal2vulkan_devtools::{engine_dir, llvm_assemble, llvm_assemble_text, AssembleError};
|
||||
|
||||
/// The bytes of the Shared block every buffer of a test lies in.
|
||||
const BLOCK: u64 = 16 << 10;
|
||||
/// The buffer the texture buffers lie over: its place in the block and its length.
|
||||
const DATA: (u64, u64) = (0, 4096);
|
||||
/// What the bytes around a texture buffer hold, before and after.
|
||||
const SENTINEL: u32 = 0x5a5a_5a5a;
|
||||
|
||||
/// `bitcode`'s library, or None where `llvm-as` is missing.
|
||||
fn library(name: &str, bitcode: Result<Vec<u8>, AssembleError>) -> Option<Library> {
|
||||
match bitcode {
|
||||
Ok(bitcode) => Some(Library::from_air(&bitcode).expect("the library")),
|
||||
Err(AssembleError::Missing(why)) => {
|
||||
eprintln!("SKIPPED: {why}");
|
||||
None
|
||||
}
|
||||
Err(error) => panic!("{name}: {error:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// The kernel `name`'s state.
|
||||
fn state(device: &Device, library: &Library, name: &str) -> ComputePipelineState {
|
||||
let function = library.function(name).expect("the kernel");
|
||||
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(
|
||||
FunctionDescriptor::new(function),
|
||||
));
|
||||
(device.new_compute_pipeline_state(&descriptor, |samplers| Ok(vec![0; samplers.len()])))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"))
|
||||
}
|
||||
|
||||
/// A texture buffer's descriptor: `width` texels of `pixel_format`, of `usage`.
|
||||
fn descriptor(pixel_format: PixelFormat, width: u32, usage: TextureUsage) -> TextureDescriptor {
|
||||
let mut d = TextureDescriptor::new(TextureType::TextureBuffer, pixel_format, width, 1);
|
||||
d.usage = usage;
|
||||
d
|
||||
}
|
||||
|
||||
/// The words of a Shared buffer, as the host reads them.
|
||||
fn words(buffer: &Buffer) -> Vec<u32> {
|
||||
let contents = buffer.contents().expect("a Shared buffer");
|
||||
let len = usize::try_from(buffer.length() / 4).expect("a length");
|
||||
// SAFETY: the buffer is alive, Shared, of `len` words, and no work in flight writes it.
|
||||
unsafe { std::slice::from_raw_parts(contents.cast::<u32>().as_ptr(), len) }.to_vec()
|
||||
}
|
||||
|
||||
/// Writes `values` to a Shared buffer's words from word `first`.
|
||||
fn set_words(buffer: &Buffer, first: usize, values: &[u32]) {
|
||||
let contents = buffer.contents().expect("a Shared buffer");
|
||||
let len = usize::try_from(buffer.length() / 4).expect("a length");
|
||||
assert!(first + values.len() <= len, "words past the buffer");
|
||||
// SAFETY: the buffer is alive, Shared, and holds the words; no work in flight reaches it.
|
||||
let words = unsafe { std::slice::from_raw_parts_mut(contents.cast::<u32>().as_ptr(), len) };
|
||||
words[first..first + values.len()].copy_from_slice(values);
|
||||
}
|
||||
|
||||
/// One dispatch of `state` over `threads` threads in one threadgroup, with `textures` and
|
||||
/// `buffers` at their slots, committed and finished.
|
||||
fn dispatch(
|
||||
device: &Device,
|
||||
state: &ComputePipelineState,
|
||||
textures: &[&Texture],
|
||||
buffers: &[&Buffer],
|
||||
threads: u32,
|
||||
) {
|
||||
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");
|
||||
for (slot, texture) in (0..).zip(textures) {
|
||||
encoder.set_texture(Some(texture), slot).expect("a texture");
|
||||
}
|
||||
for (slot, buffer) in (0..).zip(buffers) {
|
||||
encoder.set_buffer(Some(buffer), 0, slot).expect("a buffer");
|
||||
}
|
||||
encoder
|
||||
.dispatch_threadgroups([1, 1, 1], [threads, 1, 1])
|
||||
.expect("the dispatch");
|
||||
encoder.end_encoding();
|
||||
command_buffer.commit().expect("a commit");
|
||||
finished("texture buffers", &command_buffer);
|
||||
assert_eq!(command_buffer.error(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_device_reads_and_writes_texture_buffers_over_a_buffer_s_bytes() {
|
||||
let name = "ob1_texel_buffer.ll";
|
||||
let Some(library) = library(name, llvm_assemble(&engine_dir().join(name))) else {
|
||||
return;
|
||||
};
|
||||
each_device("texture buffers", |name, _, device| {
|
||||
let _grant = (device.grant_indices(IndexClass::Texture, 1, 2))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let block = (device.take_block(MemoryClass::Shared, BLOCK)).expect("a block");
|
||||
let place =
|
||||
|(at, len)| (device.new_buffer(block.id, at, len, Some(0))).expect("a buffer");
|
||||
let data = place(DATA);
|
||||
let idx = place((4096, 64));
|
||||
let out = place((8192, 32));
|
||||
let alignment = (device.minimum_texture_buffer_alignment(PixelFormat::R32Uint))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert!((1..=256).contains(&alignment), "{name}: {alignment}");
|
||||
// The read one at a nonzero multiple of the alignment, the written one at 2048.
|
||||
let (src_at, dst_at) = (4 * alignment, 2048);
|
||||
let words_of = |at: u64| usize::try_from(at / 4).expect("an offset");
|
||||
let (src, dst) = (words_of(src_at), words_of(dst_at));
|
||||
set_words(&data, 0, &[SENTINEL; 1024]);
|
||||
set_words(&data, src, &[11, 22, 33, 44]);
|
||||
set_words(&data, dst, &[0; 4]);
|
||||
let threads: Vec<u32> = (0..8).collect();
|
||||
set_words(&idx, 0, &threads);
|
||||
set_words(&idx, 8, &threads);
|
||||
set_words(&out, 0, &[SENTINEL; 8]);
|
||||
let read = (data.new_texture(
|
||||
&descriptor(PixelFormat::R32Uint, 4, TextureUsage::SHADER_READ),
|
||||
Some(1),
|
||||
src_at,
|
||||
16,
|
||||
))
|
||||
.unwrap_or_else(|error| panic!("{name}: the read texture buffer: {error}"));
|
||||
let written = (data.new_texture(
|
||||
&descriptor(PixelFormat::R32Uint, 4, TextureUsage::SHADER_WRITE),
|
||||
Some(2),
|
||||
dst_at,
|
||||
16,
|
||||
))
|
||||
.unwrap_or_else(|error| panic!("{name}: the written texture buffer: {error}"));
|
||||
assert_eq!(read.descriptor().storage_mode, StorageMode::Shared);
|
||||
assert_eq!(read.gpu_resource_id().index, 1);
|
||||
let kernel = state(&device, &library, "ob1_texel_buffer");
|
||||
dispatch(&device, &kernel, &[&read, &written], &[&idx, &out], 8);
|
||||
// In bounds, the buffer's texels; past the width, zero.
|
||||
assert_eq!(words(&out)[..8], [11, 22, 33, 44, 0, 0, 0, 0], "{name}");
|
||||
let bytes = words(&data);
|
||||
let marked: Vec<u32> = (0..4).map(|t| 0xa000_0000 | t).collect();
|
||||
assert_eq!(bytes[dst..dst + 4], marked, "{name}");
|
||||
// Nothing past either texture buffer's texels was read into them or written.
|
||||
assert_eq!(bytes[dst + 4..dst + 8], [SENTINEL; 4], "{name}");
|
||||
assert_eq!(bytes[src + 4..src + 8], [SENTINEL; 4], "{name}");
|
||||
assert_eq!(bytes[src..src + 4], [11, 22, 33, 44], "{name}");
|
||||
// The host reads the written texels through the texture as in the buffer.
|
||||
let mut texels = [0u8; 16];
|
||||
let region = Region {
|
||||
origin: [0; 3],
|
||||
size: [4, 1, 1],
|
||||
};
|
||||
(written.get_bytes(&mut texels, 16, 0, region, 0, 0))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let first = u32::from_ne_bytes(texels[..4].try_into().expect("a word"));
|
||||
assert_eq!(first, 0xa000_0000, "{name}");
|
||||
println!("{name}: texture buffers read and written at offsets {src_at} and {dst_at}");
|
||||
});
|
||||
}
|
||||
|
||||
/// `tb_atomic(ab, out, t)`: thread `t` adds 3 to texel `t` of `ab`, a `texture_buffer<uint,
|
||||
/// access::read_write>`, writing the texel it held to `out[t]`, then loads the texel to
|
||||
/// `out[8 + t]`.
|
||||
const ATOMIC_KERNEL: &str = r#"target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
|
||||
target triple = "air64_v28-apple-macosx26.0.0"
|
||||
|
||||
define void @tb_atomic(ptr addrspace(1) %ab, ptr addrspace(1) noundef "air-buffer-no-alias" %out, i32 noundef %t) {
|
||||
entry:
|
||||
%old = tail call <4 x i32> @air.atomic_fetch_add_explicit_texture_buffer_1d.u.v4i32(ptr addrspace(1) %ab, i32 %t, <4 x i32> <i32 3, i32 3, i32 3, i32 3>, i32 0, i32 3)
|
||||
%o = extractelement <4 x i32> %old, i64 0
|
||||
%p = getelementptr inbounds i32, ptr addrspace(1) %out, i32 %t
|
||||
store i32 %o, ptr addrspace(1) %p, align 4
|
||||
%now = tail call <4 x i32> @air.atomic_load_explicit_texture_buffer_1d.u.v4i32(ptr addrspace(1) %ab, i32 %t, i32 0, i32 3)
|
||||
%n = extractelement <4 x i32> %now, i64 0
|
||||
%t8 = add i32 %t, 8
|
||||
%q = getelementptr inbounds i32, ptr addrspace(1) %out, i32 %t8
|
||||
store i32 %n, ptr addrspace(1) %q, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare <4 x i32> @air.atomic_fetch_add_explicit_texture_buffer_1d.u.v4i32(ptr addrspace(1), i32, <4 x i32>, i32, i32)
|
||||
declare <4 x i32> @air.atomic_load_explicit_texture_buffer_1d.u.v4i32(ptr addrspace(1), i32, i32, i32)
|
||||
|
||||
!air.kernel = !{!0}
|
||||
!air.version = !{!5}
|
||||
!air.language_version = !{!6}
|
||||
!0 = !{ptr @tb_atomic, !1, !2}
|
||||
!1 = !{}
|
||||
!2 = !{!3, !4, !7}
|
||||
!3 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.arg_type_name", !"texture_buffer<uint, read_write>", !"air.arg_name", !"ab"}
|
||||
!4 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"}
|
||||
!5 = !{i32 2, i32 8, i32 0}
|
||||
!6 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!7 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"}
|
||||
"#;
|
||||
|
||||
#[test]
|
||||
fn every_device_updates_a_texture_buffer_s_texels_by_an_atomic() {
|
||||
let name = "tb_atomic";
|
||||
let Some(library) = library(name, llvm_assemble_text(ATOMIC_KERNEL)) else {
|
||||
return;
|
||||
};
|
||||
each_device("texture buffer atomics", |name, _, device| {
|
||||
let _grant = (device.grant_indices(IndexClass::Texture, 1, 1))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let block = (device.take_block(MemoryClass::Shared, BLOCK)).expect("a block");
|
||||
let place =
|
||||
|(at, len)| (device.new_buffer(block.id, at, len, Some(0))).expect("a buffer");
|
||||
let data = place(DATA);
|
||||
let out = place((8192, 64));
|
||||
set_words(&data, 0, &[10, 20, 30, 40]);
|
||||
let usage = TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE;
|
||||
let texels =
|
||||
(data.new_texture(&descriptor(PixelFormat::R32Uint, 4, usage), Some(1), 0, 16))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let kernel = state(&device, &library, "tb_atomic");
|
||||
dispatch(&device, &kernel, &[&texels], &[&out], 4);
|
||||
let answers = words(&out);
|
||||
assert_eq!(answers[..4], [10, 20, 30, 40], "{name}: the texels held");
|
||||
assert_eq!(
|
||||
answers[8..12],
|
||||
[13, 23, 33, 43],
|
||||
"{name}: the texels loaded"
|
||||
);
|
||||
assert_eq!(
|
||||
words(&data)[..4],
|
||||
[13, 23, 33, 43],
|
||||
"{name}: the buffer's bytes"
|
||||
);
|
||||
println!("{name}: a texture buffer's atomics update its buffer's bytes");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_device_refuses_what_metal_refuses_of_a_texture_buffer_and_what_is_not_built() {
|
||||
each_device("texture buffer refusals", |name, _, device| {
|
||||
let _grant = (device.grant_indices(IndexClass::Texture, 1, 2))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let block = (device.take_block(MemoryClass::Shared, BLOCK)).expect("a block");
|
||||
let data = (device.new_buffer(block.id, DATA.0, DATA.1, Some(0))).expect("a buffer");
|
||||
let read = TextureUsage::SHADER_READ;
|
||||
let d = descriptor(PixelFormat::R32Uint, 4, read);
|
||||
let alignment = (device.minimum_texture_buffer_alignment(PixelFormat::R32Uint))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
let refused = |result: Result<Texture, Error>| match result {
|
||||
Ok(_) => panic!("{name}: made"),
|
||||
Err(error) => error,
|
||||
};
|
||||
// Made other than over a buffer.
|
||||
assert!(matches!(
|
||||
refused(device.new_texture(&d, Some(1))),
|
||||
Error::Refused(Refusal::TextureBufferNotOverBuffer)
|
||||
));
|
||||
// An offset off the alignment, where the device has one above a byte.
|
||||
if alignment > 1 {
|
||||
assert!(matches!(
|
||||
refused(data.new_texture(&d, Some(1), alignment + 1, 16)),
|
||||
Error::Refused(Refusal::TextureBufferAlignment {
|
||||
pixel_format: PixelFormat::R32Uint,
|
||||
alignment: a,
|
||||
..
|
||||
}) if a == alignment
|
||||
));
|
||||
}
|
||||
// A row's bytes below its texels', and texels past the buffer.
|
||||
for (width, bytes_per_row) in [(4, 15), (2048, 8192)] {
|
||||
let d = descriptor(PixelFormat::R32Uint, width, read);
|
||||
assert!(matches!(
|
||||
refused(data.new_texture(&d, Some(1), 0, bytes_per_row)),
|
||||
Error::Refused(Refusal::BufferTextureLayout { .. })
|
||||
));
|
||||
}
|
||||
// More than one row, level, slice or sample.
|
||||
let mut tall = d;
|
||||
tall.height = 2;
|
||||
assert!(matches!(
|
||||
refused(data.new_texture(&tall, Some(1), 0, 16)),
|
||||
Error::Refused(Refusal::TextureExtentForType)
|
||||
));
|
||||
let mut levels = d;
|
||||
levels.mipmap_level_count = 2;
|
||||
assert!(matches!(
|
||||
refused(data.new_texture(&levels, Some(1), 0, 16)),
|
||||
Error::Refused(Refusal::TextureLevelCount { levels: 2, max: 1 })
|
||||
));
|
||||
// A swizzle: refused with writes as Metal refuses it, not built with reads.
|
||||
let mut swizzled = d;
|
||||
swizzled.swizzle = TextureSwizzleChannels {
|
||||
red: TextureSwizzle::Green,
|
||||
..TextureSwizzleChannels::DEFAULT
|
||||
};
|
||||
assert!(matches!(
|
||||
refused(data.new_texture(&swizzled, Some(1), 0, 16)),
|
||||
Error::Unsupported(Gap::TextureBufferSwizzle {
|
||||
pixel_format: PixelFormat::R32Uint
|
||||
})
|
||||
));
|
||||
swizzled.usage = TextureUsage::SHADER_WRITE;
|
||||
assert!(matches!(
|
||||
refused(data.new_texture(&swizzled, Some(1), 0, 16)),
|
||||
Error::Refused(Refusal::TextureSwizzleWithWrites)
|
||||
));
|
||||
// A format held through a component mapping.
|
||||
assert!(matches!(
|
||||
device.minimum_texture_buffer_alignment(PixelFormat::A8Unorm),
|
||||
Err(Error::Unsupported(Gap::TextureFormat {
|
||||
pixel_format: PixelFormat::A8Unorm
|
||||
}))
|
||||
));
|
||||
// A view of one, and a blit copy of one.
|
||||
let texels = (data.new_texture(&d, Some(1), 0, 16))
|
||||
.unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert!(matches!(
|
||||
texels.new_texture_view(
|
||||
PixelFormat::R32Uint,
|
||||
TextureType::TextureBuffer,
|
||||
0..1,
|
||||
0..1,
|
||||
Some(2)
|
||||
),
|
||||
Err(Error::Unsupported(Gap::TextureView {
|
||||
kind: TextureViewKind::TextureBuffer
|
||||
}))
|
||||
));
|
||||
let queue = device.new_command_queue(1).expect("a queue");
|
||||
let command_buffer = queue.command_buffer().expect("a command buffer");
|
||||
let mut blit = command_buffer
|
||||
.blit_command_encoder()
|
||||
.expect("a blit encoder");
|
||||
let place = TexturePlace {
|
||||
slice: 0,
|
||||
level: 0,
|
||||
origin: [0; 3],
|
||||
};
|
||||
assert!(matches!(
|
||||
blit.copy_from_texture(&texels, place, [4, 1, 1], &texels, place),
|
||||
Err(Error::Unsupported(Gap::TextureCopy { .. }))
|
||||
));
|
||||
let layout = BufferLayout {
|
||||
offset: 2048,
|
||||
bytes_per_row: 16,
|
||||
bytes_per_image: 0,
|
||||
};
|
||||
assert!(matches!(
|
||||
blit.copy_from_buffer_with_options(
|
||||
&data,
|
||||
layout,
|
||||
[4, 1, 1],
|
||||
&texels,
|
||||
place,
|
||||
BlitOption::None
|
||||
),
|
||||
Err(Error::Unsupported(Gap::TextureBytes {
|
||||
pixel_format: PixelFormat::R32Uint
|
||||
}))
|
||||
));
|
||||
blit.end_encoding();
|
||||
drop((command_buffer, queue, texels));
|
||||
println!(
|
||||
"{name}: texture buffers refused as Metal refuses them, alignment {alignment}"
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ pub enum StorageMode {
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct TextureDescriptor {
|
||||
/// `textureType`. `TextureBuffer` is refused, [`Gap::TextureBuffer`].
|
||||
/// `textureType`. A `TextureBuffer` is made over a buffer alone ([`Buffer::new_texture`]).
|
||||
pub texture_type: TextureType,
|
||||
/// `pixelFormat`.
|
||||
pub pixel_format: PixelFormat,
|
||||
@@ -210,7 +210,8 @@ pub struct Texture {
|
||||
pub(crate) struct TextureInner {
|
||||
core: Arc<Core>,
|
||||
descriptor: TextureDescriptor,
|
||||
image: Arc<Image>,
|
||||
/// What holds its texels: its image, or a texture buffer's view of its buffer's bytes.
|
||||
body: Body,
|
||||
/// The format of its views: the image's, or a view's own.
|
||||
format: vk::Format,
|
||||
/// Its views' format reads as storage without a format ([`Plan`]'s `storage_reads`).
|
||||
@@ -248,6 +249,24 @@ pub(crate) struct TextureInner {
|
||||
shadow: Option<ShadowView>,
|
||||
}
|
||||
|
||||
/// What holds a texture's texels ([`TextureInner`]'s `body`).
|
||||
enum Body {
|
||||
/// An image: the texture's own, or a view's parent's.
|
||||
Image(Arc<Image>),
|
||||
/// A texture buffer's buffer view of its buffer's bytes ([`Buffer::new_texture`]).
|
||||
Texels(Texels),
|
||||
}
|
||||
|
||||
/// A texture buffer's one buffer view of its buffer's bytes, of the texel-buffer usages the
|
||||
/// buffer has, so it is the element of each texel-buffer array the texture takes at its index:
|
||||
/// the uniform one where shaders read it, the storage one where they write it. The reaper frees
|
||||
/// it once the texture is gone and its elements are null.
|
||||
struct Texels {
|
||||
view: vk::BufferView,
|
||||
/// Whether the uniform element and the storage element hold the view.
|
||||
elements: [bool; 2],
|
||||
}
|
||||
|
||||
/// A texture's view of its image's shadow (`TextureInner::shadow`).
|
||||
struct ShadowView {
|
||||
view_type: vk::ImageViewType,
|
||||
@@ -881,15 +900,25 @@ impl Drop for TextureInner {
|
||||
// An upload holds the image past the texture: the pending one's bound counts it, and
|
||||
// the reaper, off the work lock this drop may run under, has the release looked at
|
||||
// where one not yet submitted holds it (`Work::release`).
|
||||
if Arc::strong_count(&self.image) > 1 {
|
||||
core.work.released(self.image.bytes);
|
||||
let image = Arc::downgrade(&self.image);
|
||||
core.reaper.give(Job::Released(image, self.image.bytes));
|
||||
if let Body::Image(image) = &self.body {
|
||||
if Arc::strong_count(image) > 1 {
|
||||
core.work.released(image.bytes);
|
||||
core.reaper
|
||||
.give(Job::Released(Arc::downgrade(image), image.bytes));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(at) = self.index {
|
||||
let second = self.image.attachment_reads;
|
||||
core.pool.release(core, Free::TextureIndex(at, second));
|
||||
match (self.index, &self.body) {
|
||||
(Some(at), Body::Image(image)) => {
|
||||
let second = image.attachment_reads;
|
||||
core.pool.release(core, Free::TextureIndex(at, second));
|
||||
}
|
||||
(Some(at), Body::Texels(_)) => core.pool.release(core, Free::TexelIndex(at)),
|
||||
(None, _) => {}
|
||||
}
|
||||
// After its elements: the view goes once nothing reaches it through them.
|
||||
if let Body::Texels(texels) = &self.body {
|
||||
core.pool.release(core, Free::TexelView(texels.view));
|
||||
}
|
||||
// Its element is null, or another texture's: its view of the shadow goes before the
|
||||
// shadow, which its image holds.
|
||||
@@ -948,7 +977,8 @@ 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`] and [`Gap::MemorylessTexture`];
|
||||
/// [`Refusal::TextureBufferNotOverBuffer`] for a texture buffer's descriptor;
|
||||
/// [`Gap::TextureFormat`] 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(
|
||||
@@ -1326,7 +1356,7 @@ impl Device {
|
||||
let inner = TextureInner {
|
||||
core: Arc::clone(core),
|
||||
descriptor: d,
|
||||
image,
|
||||
body: Body::Image(image),
|
||||
format: plan.format,
|
||||
storage_reads: plan.storage_reads,
|
||||
views_usage: None,
|
||||
@@ -1547,7 +1577,7 @@ impl Device {
|
||||
let inner = TextureInner {
|
||||
core: Arc::clone(core),
|
||||
descriptor: d,
|
||||
image,
|
||||
body: Body::Image(image),
|
||||
format: plan.format,
|
||||
storage_reads: plan.storage_reads,
|
||||
views_usage: None,
|
||||
@@ -1575,12 +1605,12 @@ impl Device {
|
||||
inner: Arc::new(inner),
|
||||
device: self.clone(),
|
||||
};
|
||||
core.work.home(core, &texture.inner.image)?;
|
||||
core.work.home(core, texture.inner.imaged())?;
|
||||
// Over a Managed buffer's device copy, its buffer keeps what Metal's Managed events owe it
|
||||
// (`crate::over::ManagedOvers`), once the move to its home layout goes ahead of every
|
||||
// later commit, a capture's copy in among them.
|
||||
if let (Some(buffer), Some((_, copy))) = (texture.managed_over(), texture.copied_over()) {
|
||||
let image = Arc::clone(&texture.inner.image);
|
||||
let image = Arc::clone(texture.inner.imaged());
|
||||
(buffer.over_entries()).add(texture.inner.id, image, copy, copy.range);
|
||||
}
|
||||
Ok(texture)
|
||||
@@ -2083,7 +2113,13 @@ fn checked(d: &TextureDescriptor) -> Result<(Shape, TextureUsage), Error> {
|
||||
if d.storage_mode == StorageMode::Memoryless {
|
||||
return Err(Error::Unsupported(Gap::MemorylessTexture));
|
||||
}
|
||||
let usage = match d.usage.is_empty() {
|
||||
Ok((shape, usage_taken(d)))
|
||||
}
|
||||
|
||||
/// The usage a descriptor takes: its own, and every usage for Metal's unknown usage, as Metal
|
||||
/// takes it.
|
||||
fn usage_taken(d: &TextureDescriptor) -> TextureUsage {
|
||||
match d.usage.is_empty() {
|
||||
true => {
|
||||
TextureUsage::SHADER_READ
|
||||
| TextureUsage::SHADER_WRITE
|
||||
@@ -2091,8 +2127,7 @@ fn checked(d: &TextureDescriptor) -> Result<(Shape, TextureUsage), Error> {
|
||||
| TextureUsage::PIXEL_FORMAT_VIEW
|
||||
}
|
||||
false => d.usage,
|
||||
};
|
||||
Ok((shape, usage))
|
||||
}
|
||||
}
|
||||
|
||||
/// The checks a texture's own descriptor takes, Metal's: [`checked`]'s, and a swizzle only of
|
||||
@@ -2133,10 +2168,10 @@ pub(crate) fn combined(
|
||||
/// Checks a descriptor's shape as Metal does.
|
||||
pub(crate) fn shape(d: &TextureDescriptor) -> Result<Shape, Error> {
|
||||
use TextureType as T;
|
||||
let (image_type, flags) =
|
||||
formats::image_type(d.texture_type).ok_or(Error::Unsupported(Gap::TextureBuffer))?;
|
||||
let view_type =
|
||||
formats::image_view_type(d.texture_type).ok_or(Error::Unsupported(Gap::TextureBuffer))?;
|
||||
// A texture buffer has no image: its texels are a buffer's bytes ([`Buffer::new_texture`]).
|
||||
let not_over = || Error::Refused(Refusal::TextureBufferNotOverBuffer);
|
||||
let (image_type, flags) = formats::image_type(d.texture_type).ok_or_else(not_over)?;
|
||||
let view_type = formats::image_view_type(d.texture_type).ok_or_else(not_over)?;
|
||||
let refused = |refusal| Err(Error::Refused(refusal));
|
||||
if d.width == 0 || d.height == 0 || d.depth == 0 {
|
||||
return refused(Refusal::TextureZeroExtent);
|
||||
@@ -3292,7 +3327,8 @@ impl TextureInner {
|
||||
) -> vk::ImageMemoryBarrier2<'static> {
|
||||
use vk::AccessFlags2 as Access;
|
||||
use vk::PipelineStageFlags2 as Stage;
|
||||
self.barrier(placed, self.image.home, self.image.copy_layout(layout))
|
||||
let image = self.imaged();
|
||||
self.barrier(placed, image.home, image.copy_layout(layout))
|
||||
.src_stage_mask(Stage::ALL_COMMANDS)
|
||||
.src_access_mask(Access::MEMORY_WRITE)
|
||||
.dst_stage_mask(Stage::COPY)
|
||||
@@ -3312,7 +3348,8 @@ impl TextureInner {
|
||||
}
|
||||
_ => Access::NONE,
|
||||
};
|
||||
self.barrier(placed, self.image.copy_layout(layout), self.image.home)
|
||||
let image = self.imaged();
|
||||
self.barrier(placed, image.copy_layout(layout), image.home)
|
||||
.src_stage_mask(Stage::COPY)
|
||||
.src_access_mask(written)
|
||||
.dst_stage_mask(Stage::ALL_COMMANDS)
|
||||
@@ -3326,14 +3363,15 @@ impl TextureInner {
|
||||
old: vk::ImageLayout,
|
||||
new: vk::ImageLayout,
|
||||
) -> vk::ImageMemoryBarrier2<'static> {
|
||||
let image = self.imaged();
|
||||
vk::ImageMemoryBarrier2::default()
|
||||
.old_layout(old)
|
||||
.new_layout(new)
|
||||
.src_queue_family_index(vk::QUEUE_FAMILY_IGNORED)
|
||||
.dst_queue_family_index(vk::QUEUE_FAMILY_IGNORED)
|
||||
.image(self.image.image)
|
||||
.image(image.image)
|
||||
.subresource_range(vk::ImageSubresourceRange {
|
||||
aspect_mask: self.image.aspects,
|
||||
aspect_mask: image.aspects,
|
||||
base_mip_level: placed.level,
|
||||
level_count: 1,
|
||||
base_array_layer: placed.layer,
|
||||
@@ -3430,7 +3468,8 @@ impl TextureInner {
|
||||
};
|
||||
let away = [self.away(©.placed, layout, access)];
|
||||
let home = [self.back(©.placed, layout)];
|
||||
let named = self.image.copy_layout(layout);
|
||||
let image = self.imaged();
|
||||
let named = image.copy_layout(layout);
|
||||
let host = [vk::MemoryBarrier2::default()
|
||||
.src_stage_mask(Stage::COPY)
|
||||
.src_access_mask(Access::TRANSFER_WRITE)
|
||||
@@ -3448,16 +3487,12 @@ impl TextureInner {
|
||||
&vk::DependencyInfo::default().image_memory_barriers(&away),
|
||||
);
|
||||
match to_image {
|
||||
true => device.cmd_copy_buffer_to_image(
|
||||
command,
|
||||
buffer,
|
||||
self.image.image,
|
||||
named,
|
||||
&[region],
|
||||
),
|
||||
true => {
|
||||
device.cmd_copy_buffer_to_image(command, buffer, image.image, named, &[region])
|
||||
}
|
||||
false => device.cmd_copy_image_to_buffer(
|
||||
command,
|
||||
self.image.image,
|
||||
image.image,
|
||||
named,
|
||||
buffer,
|
||||
copy_out::regions(©.unit, region).as_slice(),
|
||||
@@ -3471,16 +3506,42 @@ impl TextureInner {
|
||||
}
|
||||
|
||||
impl TextureInner {
|
||||
/// Its image: its own, or a view's parent's; `None` for a texture buffer.
|
||||
fn image(&self) -> Option<&Arc<Image>> {
|
||||
match &self.body {
|
||||
Body::Image(image) => Some(image),
|
||||
Body::Texels(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Its image, on a path a texture buffer never reaches: each call that would take one there
|
||||
/// refuses it first (copies and blits, render pass attachments, views, drawables and the
|
||||
/// copies over buffers, whose texture is never one), and a texture buffer takes no upload.
|
||||
fn imaged(&self) -> &Arc<Image> {
|
||||
self.image()
|
||||
.expect("an image path reached by a texture buffer, which every such call refuses")
|
||||
}
|
||||
|
||||
/// Whether it has a storage element: a storage view of its image, or a texture buffer's view
|
||||
/// in the storage texel-buffer array.
|
||||
fn stores(&self) -> bool {
|
||||
match (&self.view, &self.body) {
|
||||
(Some(view), _) => view.views.storage.is_some(),
|
||||
(None, Body::Image(image)) => image.storage.is_some(),
|
||||
(None, Body::Texels(texels)) => texels.elements[1],
|
||||
}
|
||||
}
|
||||
|
||||
/// For the device tests: whether its image has a storage view, its home general.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn has_storage_view(&self) -> bool {
|
||||
self.image.storage.is_some()
|
||||
self.imaged().storage.is_some()
|
||||
}
|
||||
|
||||
/// For the device tests: its image's usage.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn image_usage(&self) -> vk::ImageUsageFlags {
|
||||
self.image.usage
|
||||
self.imaged().usage
|
||||
}
|
||||
|
||||
/// Where the texture starts in its image: a view's first level and array layer, else the
|
||||
@@ -3505,15 +3566,16 @@ impl TextureInner {
|
||||
new: Option<vk::ImageLayout>,
|
||||
) -> vk::ImageMemoryBarrier2<'static> {
|
||||
let [level, layer] = self.base();
|
||||
let home = self.image.home;
|
||||
let image = self.imaged();
|
||||
let home = image.home;
|
||||
vk::ImageMemoryBarrier2::default()
|
||||
.old_layout(old.unwrap_or(home))
|
||||
.new_layout(new.unwrap_or(home))
|
||||
.src_queue_family_index(vk::QUEUE_FAMILY_IGNORED)
|
||||
.dst_queue_family_index(vk::QUEUE_FAMILY_IGNORED)
|
||||
.image(self.image.image)
|
||||
.image(image.image)
|
||||
.subresource_range(vk::ImageSubresourceRange {
|
||||
aspect_mask: self.image.aspects,
|
||||
aspect_mask: image.aspects,
|
||||
base_mip_level: level + levels.start,
|
||||
level_count: levels.end - levels.start,
|
||||
base_array_layer: layer,
|
||||
@@ -3628,6 +3690,10 @@ impl Texture {
|
||||
use TextureType as T;
|
||||
let inner = &self.inner;
|
||||
let p = &inner.descriptor;
|
||||
let gap = |kind| Err(Error::Unsupported(Gap::TextureView { kind }));
|
||||
if let Body::Texels(_) = inner.body {
|
||||
return gap(TextureViewKind::TextureBuffer);
|
||||
}
|
||||
let level_count = levels.end.saturating_sub(levels.start);
|
||||
let slice_count = slices.end.saturating_sub(slices.start);
|
||||
if level_count == 0
|
||||
@@ -3642,7 +3708,6 @@ impl Texture {
|
||||
slice_count,
|
||||
}));
|
||||
}
|
||||
let gap = |kind| Err(Error::Unsupported(Gap::TextureView { kind }));
|
||||
let refused = || {
|
||||
Err(Error::Refused(Refusal::TextureViewFormat {
|
||||
texture: p.pixel_format,
|
||||
@@ -3686,7 +3751,7 @@ impl Texture {
|
||||
}
|
||||
(T::Type2D, T::Type2DArray) | (T::Type2DArray, T::Type2D) => {}
|
||||
(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) if inner.imaged().cube => {}
|
||||
(T::Type2DArray, T::Cube | T::CubeArray) => return gap(TextureViewKind::CubeOfArray),
|
||||
_ => return gap(TextureViewKind::TextureType),
|
||||
}
|
||||
@@ -3708,7 +3773,7 @@ impl Texture {
|
||||
// makes of a texture's own descriptor alone.
|
||||
let (shape, usage) = checked(&d)?;
|
||||
let mut plan = form(&inner.core, &d, usage)?;
|
||||
let image = &inner.image;
|
||||
let image = inner.imaged();
|
||||
if own_format_only && plan.format != image.format {
|
||||
return refused();
|
||||
}
|
||||
@@ -3740,7 +3805,7 @@ impl Texture {
|
||||
base_array_layer: base[1],
|
||||
layer_count: shape.layers,
|
||||
};
|
||||
let image = inner.image.image;
|
||||
let image = inner.imaged().image;
|
||||
let make = |(components, aspect, role): (_, _, vk::ImageUsageFlags)| {
|
||||
let (view_type, format) = (shape.view_type, plan.format);
|
||||
let usage = views_usage.map(|usage| usage & role);
|
||||
@@ -3783,11 +3848,12 @@ impl Texture {
|
||||
// A failed view's image views go to the reaper as `views` drops, and so do they where the
|
||||
// view is refused its index.
|
||||
made?;
|
||||
let shadow = ShadowView::of(&inner.image, &plan, index, shape.view_type, range);
|
||||
let image = inner.imaged();
|
||||
let shadow = ShadowView::of(image, &plan, index, shape.view_type, range);
|
||||
let index = match index {
|
||||
Some(index) => {
|
||||
let element = (sampled.filter(|_| plan.read)).map(|view| (view, inner.image.home));
|
||||
let looped = sampled.filter(|_| inner.image.looped());
|
||||
let element = (sampled.filter(|_| plan.read)).map(|view| (view, image.home));
|
||||
let looped = sampled.filter(|_| image.looped());
|
||||
// SAFETY: the view's image views are live; the image is in its home layout
|
||||
// whenever work uses it.
|
||||
let owner = unsafe {
|
||||
@@ -3825,7 +3891,7 @@ impl Texture {
|
||||
swizzle: swizzle.unwrap_or(p.swizzle),
|
||||
..d
|
||||
},
|
||||
image: Arc::clone(&inner.image),
|
||||
body: Body::Image(Arc::clone(image)),
|
||||
format: plan.format,
|
||||
storage_reads: plan.storage_reads,
|
||||
views_usage,
|
||||
@@ -3872,8 +3938,9 @@ impl Texture {
|
||||
/// last presented, and waited for the acquire's fence; its swapchain is not destroyed. These
|
||||
/// are Vulkan's rules on a swapchain's image, which the runtime cannot check.
|
||||
pub unsafe fn drawable_acquired(&self) -> Result<(), Error> {
|
||||
let image = &self.inner.image;
|
||||
let drawable = (image.drawable.as_ref()).ok_or(Error::Refused(Refusal::NotDrawable))?;
|
||||
let drawable = (self.inner.image())
|
||||
.and_then(|image| image.drawable.as_ref())
|
||||
.ok_or(Error::Refused(Refusal::NotDrawable))?;
|
||||
let before = {
|
||||
let mut turn = lock(&drawable.turn);
|
||||
let before = *turn;
|
||||
@@ -3890,7 +3957,7 @@ impl Texture {
|
||||
before
|
||||
};
|
||||
let core = &self.inner.core;
|
||||
let homed = core.work.home(core, image);
|
||||
let homed = core.work.home(core, self.inner.imaged());
|
||||
if homed.is_err() {
|
||||
*lock(&drawable.turn) = before;
|
||||
}
|
||||
@@ -3998,7 +4065,7 @@ impl Texture {
|
||||
core.work.upload(
|
||||
core,
|
||||
Some(&stage),
|
||||
[Held::Texture(Arc::clone(&inner.image))],
|
||||
[Held::Texture(Arc::clone(inner.imaged()))],
|
||||
// SAFETY: recording under the work lock, the upload holding the image and the stage.
|
||||
|device, command| unsafe {
|
||||
let region = copy.buffer_image_copy(stage.offset(), 0, 0);
|
||||
@@ -4069,7 +4136,7 @@ impl Texture {
|
||||
core,
|
||||
None,
|
||||
[
|
||||
Held::Texture(Arc::clone(&inner.image)),
|
||||
Held::Texture(Arc::clone(inner.imaged())),
|
||||
Held::Block(Arc::clone(bytes.held().0)),
|
||||
],
|
||||
// SAFETY: recording under the work lock, the upload holding the image and the named
|
||||
@@ -4168,7 +4235,7 @@ impl Texture {
|
||||
core.work.upload(
|
||||
core,
|
||||
Some(&stage),
|
||||
[Held::Texture(Arc::clone(&inner.image))],
|
||||
[Held::Texture(Arc::clone(inner.imaged()))],
|
||||
// SAFETY: as in `replace_region`.
|
||||
|device, command| unsafe {
|
||||
let region = copy.buffer_image_copy(stage.offset(), 0, 0);
|
||||
@@ -4221,9 +4288,16 @@ pub(crate) trait TextureObject {
|
||||
Arc::ptr_eq(&self.object().core, core)
|
||||
}
|
||||
|
||||
/// Its image.
|
||||
/// Its image. A texture buffer has none: every call that reaches this refuses one first
|
||||
/// ([`texels`](Self::texels)).
|
||||
fn image(&self) -> vk::Image {
|
||||
self.object().image.image
|
||||
self.object().imaged().image
|
||||
}
|
||||
|
||||
/// Whether it is a texture buffer, whose texels are its buffer's bytes, read through a buffer
|
||||
/// view: no copy, blit, pass or view of an image reaches it.
|
||||
fn texels(&self) -> bool {
|
||||
matches!(self.object().body, Body::Texels(_))
|
||||
}
|
||||
|
||||
/// Whether it reaches `level` and one of the `layers` layers from `layer` of its image: a view
|
||||
@@ -4240,15 +4314,16 @@ pub(crate) trait TextureObject {
|
||||
/// `attachment_reads`): its image in the feedback layout, or, on a device without the
|
||||
/// attachment feedback loop, its view of its image's shadow.
|
||||
fn attachment_reads(&self) -> bool {
|
||||
let image = &self.object().image;
|
||||
image.attachment_reads && (image.looped() || self.object().shadow.is_some())
|
||||
(self.object().image()).is_some_and(|image| {
|
||||
image.attachment_reads && (image.looped() || self.object().shadow.is_some())
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether a draw reads an attachment of its own pass through it in the feedback layout
|
||||
/// ([`Image`]'s `looped`), where its image has the feedback usage; else through its view of
|
||||
/// the image's shadow.
|
||||
fn looped(&self) -> bool {
|
||||
self.object().image.looped()
|
||||
(self.object().image()).is_some_and(|image| image.looped())
|
||||
}
|
||||
|
||||
/// Its resource id while a draw reads an attachment through it: its second element's, at its
|
||||
@@ -4274,7 +4349,7 @@ pub(crate) trait TextureObject {
|
||||
let (Some(at), Some(index)) = (&self.object().shadow, self.object().index) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(shadow) = self.object().image.shadow()? else {
|
||||
let Some(shadow) = self.object().imaged().shadow()? else {
|
||||
return Ok(None);
|
||||
};
|
||||
let mut view = lock(&at.view);
|
||||
@@ -4304,7 +4379,9 @@ pub(crate) trait TextureObject {
|
||||
|
||||
/// The format its image's shadow is made in, the image's; `None` for an image of no shadow.
|
||||
fn shadow_format(&self) -> Option<vk::Format> {
|
||||
(self.object().image.shadowing.as_ref()).map(|shadowing| shadowing.made.2.format)
|
||||
(self.object().image())
|
||||
.and_then(|image| image.shadowing.as_ref())
|
||||
.map(|shadowing| shadowing.made.2.format)
|
||||
}
|
||||
|
||||
/// What a draw reads of its image through it (`crate::shadow`): with `own_pixel`, the draw's
|
||||
@@ -4343,7 +4420,7 @@ pub(crate) trait TextureObject {
|
||||
None => &self.object().descriptor,
|
||||
};
|
||||
vk::ImageSubresourceRange {
|
||||
aspect_mask: self.object().image.aspects,
|
||||
aspect_mask: self.object().imaged().aspects,
|
||||
base_mip_level: 0,
|
||||
level_count: root.mipmap_level_count,
|
||||
base_array_layer: 0,
|
||||
@@ -4359,7 +4436,7 @@ pub(crate) trait TextureObject {
|
||||
/// The format its image is made in, which a blit of the image filters by: a view in another
|
||||
/// format's differs from [`format`](Self::format).
|
||||
fn image_format(&self) -> vk::Format {
|
||||
self.object().image.format
|
||||
self.object().imaged().format
|
||||
}
|
||||
|
||||
/// A layout change of its levels `levels`, counted from its first, over each of its slices,
|
||||
@@ -4415,7 +4492,7 @@ pub(crate) trait TextureObject {
|
||||
fn resolve_attachment(&self, level: u32, slice: u32, layers: u32) -> Result<Attachment, Error> {
|
||||
let renders =
|
||||
vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT;
|
||||
if !self.object().image.usage.intersects(renders) {
|
||||
if !(self.object().image()).is_some_and(|image| image.usage.intersects(renders)) {
|
||||
return Err(Error::Unsupported(Gap::RenderPass {
|
||||
kind: RenderPassKind::ResolveUsage,
|
||||
}));
|
||||
@@ -4453,7 +4530,8 @@ pub(crate) trait TextureObject {
|
||||
}
|
||||
let [first_level, first_layer] = TextureInner::base(self.object());
|
||||
let (level_in_image, layer) = (first_level + level, first_layer + slice);
|
||||
let image = &self.object().image;
|
||||
// The type's check above refused a texture buffer.
|
||||
let image = self.object().imaged();
|
||||
// A view of another format than the image's renders where the format's features hold an
|
||||
// attachment.
|
||||
let renders =
|
||||
@@ -4535,7 +4613,7 @@ pub(crate) trait TextureObject {
|
||||
/// ([`Image::copy_layout`]): general for a texture over a buffer in place, `layout` for any
|
||||
/// other.
|
||||
fn copy_layout(&self, layout: vk::ImageLayout) -> vk::ImageLayout {
|
||||
self.object().image.copy_layout(layout)
|
||||
self.object().imaged().copy_layout(layout)
|
||||
}
|
||||
|
||||
/// The barrier that moves `placed` from home to the copy layout of the transfer `layout` for
|
||||
@@ -4560,8 +4638,9 @@ pub(crate) trait TextureObject {
|
||||
///
|
||||
/// Err: [`Refusal::NotDrawable`]; [`Refusal::DrawableNotAcquired`].
|
||||
fn present_turn(&self) -> Result<(), Error> {
|
||||
let drawable =
|
||||
(self.object().image.drawable.as_ref()).ok_or(Error::Refused(Refusal::NotDrawable))?;
|
||||
let drawable = (self.object().image())
|
||||
.and_then(|image| image.drawable.as_ref())
|
||||
.ok_or(Error::Refused(Refusal::NotDrawable))?;
|
||||
let mut turn = lock(&drawable.turn);
|
||||
if *turn != Turn::Acquired {
|
||||
return Err(Error::Refused(Refusal::DrawableNotAcquired));
|
||||
@@ -4573,7 +4652,7 @@ pub(crate) trait TextureObject {
|
||||
/// The command buffer that presents the drawable was dropped uncommitted: it is acquired
|
||||
/// again, for another present.
|
||||
fn unpresent(&self) {
|
||||
if let Some(drawable) = &self.object().image.drawable {
|
||||
if let Some(drawable) = (self.object().image()).and_then(|image| image.drawable.as_ref()) {
|
||||
*lock(&drawable.turn) = Turn::Acquired;
|
||||
}
|
||||
}
|
||||
@@ -4581,7 +4660,7 @@ pub(crate) trait TextureObject {
|
||||
/// The command buffer that presents the drawable is committed: the image is the presentation
|
||||
/// engine's once that command buffer has run, in the present layout.
|
||||
fn presented(&self) {
|
||||
if let Some(drawable) = &self.object().image.drawable {
|
||||
if let Some(drawable) = (self.object().image()).and_then(|image| image.drawable.as_ref()) {
|
||||
*lock(&drawable.turn) = Turn::Engine;
|
||||
}
|
||||
}
|
||||
@@ -4590,7 +4669,7 @@ pub(crate) trait TextureObject {
|
||||
/// writes. It delays nothing after it: the present's semaphore wait and its own visibility
|
||||
/// operations order the presentation engine's reads (Vulkan's note on `VkPresentInfoKHR`).
|
||||
fn present_barrier(&self) -> vk::ImageMemoryBarrier2<'static> {
|
||||
let image = &self.object().image;
|
||||
let image = self.object().imaged();
|
||||
vk::ImageMemoryBarrier2::default()
|
||||
.src_stage_mask(vk::PipelineStageFlags2::ALL_COMMANDS)
|
||||
.src_access_mask(vk::AccessFlags2::MEMORY_WRITE)
|
||||
@@ -4642,11 +4721,7 @@ pub(crate) trait TextureObject {
|
||||
let d = &self.object().descriptor;
|
||||
let written = (d.usage.is_empty() || d.usage.contains(TextureUsage::SHADER_WRITE))
|
||||
&& !multisampled(d.texture_type);
|
||||
let storage = match &self.object().view {
|
||||
Some(view) => view.views.storage,
|
||||
None => self.object().image.storage,
|
||||
};
|
||||
(written && storage.is_none()).then_some(d.pixel_format)
|
||||
(written && !self.object().stores()).then_some(d.pixel_format)
|
||||
}
|
||||
|
||||
/// Where it has a storage element the device cannot read without a format, which shaders read
|
||||
@@ -4655,11 +4730,7 @@ pub(crate) trait TextureObject {
|
||||
/// its make). Its pixel format, which [`Gap::StorageElement`] names.
|
||||
fn unread(&self) -> Option<PixelFormat> {
|
||||
let inner = self.object();
|
||||
let storage = match &inner.view {
|
||||
Some(view) => view.views.storage,
|
||||
None => inner.image.storage,
|
||||
};
|
||||
(storage.is_some() && !inner.storage_reads).then_some(inner.descriptor.pixel_format)
|
||||
(inner.stores() && !inner.storage_reads).then_some(inner.descriptor.pixel_format)
|
||||
}
|
||||
|
||||
/// Whether it reads through a swizzle other than each channel's own.
|
||||
@@ -4747,10 +4818,11 @@ pub(crate) trait TextureObject {
|
||||
+ u64::from(d.height - 1) * place.bytes_per_row
|
||||
+ u64::from(d.width) * u64::from(unit.bytes);
|
||||
let whole = named.buffer.span();
|
||||
let image = inner.imaged();
|
||||
let copy = OverCopy {
|
||||
image: inner.image.image,
|
||||
home: inner.image.home,
|
||||
aspects: inner.image.aspects,
|
||||
image: image.image,
|
||||
home: image.home,
|
||||
aspects: image.aspects,
|
||||
buffer,
|
||||
region,
|
||||
unit,
|
||||
@@ -4771,14 +4843,14 @@ pub(crate) trait TextureObject {
|
||||
/// For the device tests: the bytes its image's memory requirements name.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
fn image_size(&self) -> u64 {
|
||||
self.object().image.bytes
|
||||
self.object().imaged().bytes
|
||||
}
|
||||
|
||||
/// For the device tests: the texture block its image is placed in and the offset there;
|
||||
/// `None` for an image of no place.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
fn place(&self) -> Option<(BlockId, u64)> {
|
||||
match &self.object().image.backing {
|
||||
match &self.object().imaged().backing {
|
||||
Backing::Placed(place) => Some((place.block(), place.offset)),
|
||||
_ => None,
|
||||
}
|
||||
@@ -4854,12 +4926,38 @@ impl Buffer {
|
||||
/// buffer's device copy only at Metal's Managed events. Each copy counts in
|
||||
/// [`Metrics::over_copies`](crate::Metrics::over_copies).
|
||||
///
|
||||
/// A texture buffer (`MTLTextureTypeTextureBuffer`) is one Vulkan buffer view of the bytes
|
||||
/// shaders reach, from `offset`, its width's texels long: nothing is copied or allocated, and
|
||||
/// its texels are the buffer's bytes, which the host, a blit or a shader writing the buffer
|
||||
/// writes and a shader reading the texture reads, as Metal's are. The view is the element of
|
||||
/// each texel-buffer array of set 1 its uses take at its index: the uniform one where shaders
|
||||
/// read it, the storage one where they write it and the device's storage texel buffers write
|
||||
/// its format without a format. Its uses take the buffer's id in the encoders' hazard sets.
|
||||
/// Its offset is a multiple of [`Device::minimum_texture_buffer_alignment`], and its
|
||||
/// `bytesPerRow`, which no texel reads past its one row, is at least that row. Its storage
|
||||
/// mode is the buffer's. A view of it ([`Texture::new_texture_view`]) is
|
||||
/// [`Gap::TextureView`] of [`TextureViewKind::TextureBuffer`]; a blit's copy of it, and a
|
||||
/// pass that renders into it, is a gap too, while [`Texture::replace_region`] and
|
||||
/// [`Texture::get_bytes`] write and read its bytes in the buffer.
|
||||
///
|
||||
/// Err: as [`Device::new_texture`]; [`Refusal::BufferTextureLayout`] for rows that are not a
|
||||
/// whole number of texels apart or are closer than a row, an offset that is not a whole
|
||||
/// number of texels, or texels past the buffer; [`Gap::TextureOverBuffer`] for a texture
|
||||
/// other than 2D of one level, sample and slice, or of a format of other than one color texel
|
||||
/// an element, or whose first texel in the bytes shaders reach is not a whole number of
|
||||
/// texels in.
|
||||
/// texels in. Of a texture buffer: what Metal refuses of its descriptor
|
||||
/// ([`Refusal::TextureZeroExtent`], [`Refusal::TextureExtentForType`] for a height or depth
|
||||
/// other than 1, [`Refusal::TextureArrayLength`], [`Refusal::TextureSampleCount`],
|
||||
/// [`Refusal::TextureLevelCount`], [`Refusal::TextureSwizzleWithWrites`]);
|
||||
/// [`Refusal::TextureBufferAlignment`] for an offset off the device's alignment;
|
||||
/// [`Refusal::BufferTextureLayout`] for a `bytesPerRow` below its row or texels past the
|
||||
/// buffer; [`Refusal::TextureIndex`] and [`Refusal::IndicesNotGranted`] as
|
||||
/// [`Device::new_texture`]; [`Limit::TextureSize`] for a width past the device's
|
||||
/// `maxTexelBufferElements`; [`Gap::TextureFormat`] as
|
||||
/// [`Device::minimum_texture_buffer_alignment`]; [`Gap::TextureBufferSwizzle`];
|
||||
/// [`Gap::TextureOverBuffer`] where its first texel in the bytes shaders reach is off the
|
||||
/// alignment, the buffer's own place there being off it; [`Error::Vulkan`] where the view
|
||||
/// cannot be made.
|
||||
pub fn new_texture(
|
||||
&self,
|
||||
descriptor: &TextureDescriptor,
|
||||
@@ -4902,11 +5000,286 @@ impl Buffer {
|
||||
MemoryClass::Private => StorageMode::Private,
|
||||
},
|
||||
};
|
||||
if d.texture_type == TextureType::TextureBuffer {
|
||||
return self
|
||||
.device()
|
||||
.texel_texture(&d, reach, self, offset, bytes_per_row);
|
||||
}
|
||||
let over = Source::Over(self, offset, bytes_per_row);
|
||||
self.device().texture(&d, reach, over)
|
||||
}
|
||||
}
|
||||
|
||||
/// What a texture buffer's offset and width take on the device: Vulkan 1.3's texel-buffer
|
||||
/// alignment properties and `maxTexelBufferElements`, read once at device creation.
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct TexelLimits {
|
||||
/// The uniform and then the storage texel buffer's offset alignment in bytes
|
||||
/// (`uniformTexelBufferOffsetAlignmentBytes`, `storageTexelBufferOffsetAlignmentBytes`), each
|
||||
/// with whether a texel's own size suffices where it is less
|
||||
/// (`…TexelBufferOffsetSingleTexelAlignment`).
|
||||
pub(crate) alignments: [(u64, bool); 2],
|
||||
/// `maxTexelBufferElements`: the most texels a texture buffer holds.
|
||||
pub(crate) max_elements: u32,
|
||||
}
|
||||
|
||||
impl TexelLimits {
|
||||
/// The alignment of a texture buffer's first texel in its `VkBuffer`, for a texel of `texel`
|
||||
/// bytes: for each of the uniform and the storage texel buffer, its alignment in bytes, or
|
||||
/// the texel's bytes where those are less and one texel suffices; the larger of the two, as
|
||||
/// its one view is of a buffer of both usages (`VUID-VkBufferViewCreateInfo-buffer-02750`,
|
||||
/// `-02751`). Vulkan takes a texel of a multiple of three bytes at its component's size; such a
|
||||
/// texel, which no Metal texture-buffer format has, takes the alignment in bytes, a multiple
|
||||
/// of that.
|
||||
pub(crate) fn alignment(&self, texel: u64) -> u64 {
|
||||
let effective = |(bytes, single): (u64, bool)| match single && texel.is_power_of_two() {
|
||||
true => bytes.min(texel),
|
||||
false => bytes,
|
||||
};
|
||||
effective(self.alignments[0]).max(effective(self.alignments[1]))
|
||||
}
|
||||
}
|
||||
|
||||
/// What a texture buffer of a pixel format holds ([`texel_form`]).
|
||||
struct TexelForm {
|
||||
/// Its buffer view's format.
|
||||
format: vk::Format,
|
||||
/// A texel's bytes.
|
||||
bytes: u32,
|
||||
/// The translator's `TextureWord` of the format, with each channel's own swizzle.
|
||||
word: u32,
|
||||
/// The format's storage texel buffers are written through an image declared without a
|
||||
/// format: a texture buffer shaders write has a storage element.
|
||||
writes: bool,
|
||||
/// The format's storage texel buffers are read through an image declared without a format
|
||||
/// ([`TextureInner`]'s `storage_reads`).
|
||||
reads: bool,
|
||||
}
|
||||
|
||||
/// What a texture buffer of `pf` holds on the device of `core`: a format the device holds
|
||||
/// directly, of one color texel an element, whose buffer features hold both the uniform and the
|
||||
/// storage texel buffer, as its one view is of a buffer of both usages and its format takes both
|
||||
/// (`VUID-VkBufferViewCreateInfo-format-08778`, `-08779`).
|
||||
///
|
||||
/// Err: [`Gap::TextureFormat`] for any other.
|
||||
fn texel_form(core: &Core, pf: PixelFormat) -> Result<TexelForm, Error> {
|
||||
let gap = || Error::Unsupported(Gap::TextureFormat { pixel_format: pf });
|
||||
let word = TextureWord::of(pf, TextureSwizzleChannels::DEFAULT)
|
||||
.ok_or_else(gap)?
|
||||
.0;
|
||||
let profile = core.translator.profile();
|
||||
let usage = TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE;
|
||||
let mapping =
|
||||
formats::vk_format(pf, &formats::texture_usages(pf, usage), profile).map_err(|_| gap())?;
|
||||
let block = mapping.format.block().ok_or_else(gap)?;
|
||||
let format: vk::Format = mapping.format.into();
|
||||
let supports = |use_| profile.supports_format(format, use_);
|
||||
let color = block.depth.is_none() && block.stencil.is_none();
|
||||
if mapping.emulation != FormatEmulation::Direct
|
||||
|| !color
|
||||
|| formats::block_extent(pf).is_some()
|
||||
|| !supports(FormatUsage::UniformTexelBuffer)
|
||||
|| !supports(FormatUsage::StorageTexelBuffer)
|
||||
{
|
||||
return Err(gap());
|
||||
}
|
||||
Ok(TexelForm {
|
||||
format,
|
||||
bytes: block.size,
|
||||
word,
|
||||
writes: supports(FormatUsage::StorageTexelBufferWriteWithoutFormat),
|
||||
reads: supports(FormatUsage::StorageTexelBufferReadWithoutFormat),
|
||||
})
|
||||
}
|
||||
|
||||
impl Device {
|
||||
/// `minimumTextureBufferAlignmentForPixelFormat:`: what a texture buffer's offset in its
|
||||
/// buffer is a multiple of ([`Buffer::new_texture`]), the device's texel-buffer offset
|
||||
/// alignment for the format's texel: for each of the uniform and the storage texel buffer,
|
||||
/// Vulkan 1.3's `…TexelBufferOffsetAlignmentBytes`, or the texel's bytes where those are
|
||||
/// less and the device's `…TexelBufferOffsetSingleTexelAlignment` says one texel suffices; the
|
||||
/// larger of the two. The answer differs by device, as Metal's does by GPU, and is never more
|
||||
/// than 256, Vulkan's bound on both, so it divides the multiple of 256 every buffer the
|
||||
/// consumer places by [`Device::heap_buffer_size_and_align`]'s rule starts at. No Vulkan call
|
||||
/// is made. Metal documents the alignment for the offset and the row's bytes; the runtime
|
||||
/// takes any `bytesPerRow` that covers the row, as a texture buffer's one row reads no other.
|
||||
///
|
||||
/// Err: [`Gap::TextureFormat`] for a format the runtime makes no texture buffer of on the
|
||||
/// device: one held through a conversion or a component mapping, compressed, of depth or
|
||||
/// stencil, or whose buffer features lack the uniform or the storage texel buffer.
|
||||
pub fn minimum_texture_buffer_alignment(
|
||||
&self,
|
||||
pixel_format: PixelFormat,
|
||||
) -> Result<u64, Error> {
|
||||
let core = self.core();
|
||||
let form = texel_form(core, pixel_format)?;
|
||||
Ok(core.texels.alignment(u64::from(form.bytes)))
|
||||
}
|
||||
|
||||
/// A texture buffer of `descriptor` over `buffer`'s bytes from `offset`, reached as `reach`
|
||||
/// says, as [`Buffer::new_texture`] makes it: one buffer view of the bytes shaders reach.
|
||||
fn texel_texture(
|
||||
&self,
|
||||
descriptor: &TextureDescriptor,
|
||||
reach: Reach,
|
||||
buffer: &Buffer,
|
||||
offset: u64,
|
||||
bytes_per_row: u64,
|
||||
) -> Result<Texture, Error> {
|
||||
let d = *descriptor;
|
||||
let core = self.core();
|
||||
let refused = |refusal| Err(Error::Refused(refusal));
|
||||
// Metal's texture buffer: a width of texels in one row, level, sample and slice.
|
||||
if d.width == 0 || d.height == 0 || d.depth == 0 {
|
||||
return refused(Refusal::TextureZeroExtent);
|
||||
}
|
||||
if d.height != 1 || d.depth != 1 {
|
||||
return refused(Refusal::TextureExtentForType);
|
||||
}
|
||||
if d.array_length != 1 {
|
||||
return refused(Refusal::TextureArrayLength {
|
||||
array_length: d.array_length,
|
||||
});
|
||||
}
|
||||
if d.sample_count != 1 {
|
||||
return refused(Refusal::TextureSampleCount {
|
||||
sample_count: d.sample_count,
|
||||
});
|
||||
}
|
||||
if d.mipmap_level_count != 1 {
|
||||
return refused(Refusal::TextureLevelCount {
|
||||
levels: d.mipmap_level_count,
|
||||
max: 1,
|
||||
});
|
||||
}
|
||||
let usage = usage_taken(&d);
|
||||
if d.swizzle != TextureSwizzleChannels::DEFAULT {
|
||||
if usage.intersects(TextureUsage::SHADER_WRITE | TextureUsage::RENDER_TARGET) {
|
||||
return refused(Refusal::TextureSwizzleWithWrites);
|
||||
}
|
||||
// Metal applies it to the reads, which no buffer view maps and no resource ID carries.
|
||||
return Err(Error::Unsupported(Gap::TextureBufferSwizzle {
|
||||
pixel_format: d.pixel_format,
|
||||
}));
|
||||
}
|
||||
let index = match reach {
|
||||
Reach::Index(index) if reached(d.pixel_format, usage) != index.is_some() => {
|
||||
return refused(Refusal::TextureIndex { index });
|
||||
}
|
||||
Reach::Index(index) => index,
|
||||
Reach::Views => None,
|
||||
};
|
||||
let form = texel_form(core, d.pixel_format)?;
|
||||
let alignment = core.texels.alignment(u64::from(form.bytes));
|
||||
if !offset.is_multiple_of(alignment) {
|
||||
return refused(Refusal::TextureBufferAlignment {
|
||||
pixel_format: d.pixel_format,
|
||||
offset,
|
||||
alignment,
|
||||
});
|
||||
}
|
||||
let row = u64::from(d.width) * u64::from(form.bytes);
|
||||
let len = buffer.length();
|
||||
if bytes_per_row < row || offset.checked_add(row).is_none_or(|end| end > len) {
|
||||
return refused(Refusal::BufferTextureLayout {
|
||||
offset,
|
||||
bytes_per_row,
|
||||
len,
|
||||
});
|
||||
}
|
||||
let max = core.texels.max_elements;
|
||||
if d.width > max {
|
||||
return Err(Error::Limit(Limit::TextureSize {
|
||||
extent: [d.width, 1, 1],
|
||||
layers: 1,
|
||||
max_extent: [max, 1, 1],
|
||||
max_layers: 1,
|
||||
}));
|
||||
}
|
||||
// The bytes shaders reach: a Managed buffer's device copy, where it has one.
|
||||
let (of, base) = buffer.device_range();
|
||||
if !(base + offset).is_multiple_of(alignment) {
|
||||
return Err(Error::Unsupported(Gap::TextureOverBuffer {
|
||||
pixel_format: d.pixel_format,
|
||||
}));
|
||||
}
|
||||
let info = vk::BufferViewCreateInfo::default()
|
||||
.buffer(of)
|
||||
.format(form.format)
|
||||
.offset(base + offset)
|
||||
.range(row);
|
||||
// SAFETY: the buffer is the device's, of both texel-buffer usages, whose format features
|
||||
// the format holds (`texel_form`); the range lies in its bytes, at the alignment both
|
||||
// usages take, its texels no more than `maxTexelBufferElements`.
|
||||
let view = unsafe { core.device.create_buffer_view(&info, None) }
|
||||
.map_err(Error::vulkan("vkCreateBufferView"))?;
|
||||
core.counters.rise(Gauge::Textures);
|
||||
// The uniform element where shaders read it, the storage one where they write it.
|
||||
let elements = [
|
||||
usage.contains(TextureUsage::SHADER_READ),
|
||||
usage.contains(TextureUsage::SHADER_WRITE) && form.writes,
|
||||
];
|
||||
let index = match index {
|
||||
Some(index) => {
|
||||
let views = elements.map(|held| match held {
|
||||
true => view,
|
||||
false => vk::BufferView::null(),
|
||||
});
|
||||
// SAFETY: the view lives until the reaper frees it, once the texture buffer's
|
||||
// elements are null or another object's.
|
||||
let placed = unsafe {
|
||||
(core.arrays).place_texels(&core.device, &core.counters, index, views)
|
||||
};
|
||||
match placed {
|
||||
Ok(owner) => Some((index, owner)),
|
||||
Err(error) => {
|
||||
// SAFETY: no element holds the view, and nothing else has it.
|
||||
unsafe { core.device.destroy_buffer_view(view, None) };
|
||||
core.counters.fall(Gauge::Textures);
|
||||
return Err(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let named = Named {
|
||||
buffer: Arc::clone(buffer.object()),
|
||||
places: vec![BytesPlace {
|
||||
offset,
|
||||
bytes_per_row,
|
||||
bytes_per_image: 0,
|
||||
}],
|
||||
form: Form::InPlace,
|
||||
};
|
||||
let inner = TextureInner {
|
||||
core: Arc::clone(core),
|
||||
descriptor: d,
|
||||
body: Body::Texels(Texels { view, elements }),
|
||||
format: form.format,
|
||||
storage_reads: form.reads,
|
||||
views_usage: None,
|
||||
unit: Some(CopyUnit {
|
||||
aspect: vk::ImageAspectFlags::COLOR,
|
||||
bytes: form.bytes,
|
||||
block: [1, 1],
|
||||
}),
|
||||
index,
|
||||
word: form.word,
|
||||
id: core.ids.take(),
|
||||
heap: None,
|
||||
named: Some(named),
|
||||
view: None,
|
||||
emulation: FormatEmulation::Direct,
|
||||
attachments: Mutex::new(Vec::new()),
|
||||
shadow: None,
|
||||
};
|
||||
Ok(Texture {
|
||||
inner: Arc::new(inner),
|
||||
device: self.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// A texture over a buffer in an image of its own: the copy between the bytes shaders reach of
|
||||
/// the buffer and its image (`crate::over`).
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -5139,7 +5512,7 @@ impl Device {
|
||||
let inner = TextureInner {
|
||||
core: Arc::clone(core),
|
||||
descriptor: d,
|
||||
image,
|
||||
body: Body::Image(image),
|
||||
format: plan.format,
|
||||
storage_reads: plan.storage_reads,
|
||||
views_usage,
|
||||
@@ -5163,7 +5536,7 @@ impl Device {
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
crate::surface::steps::mark("plane texture");
|
||||
if !general {
|
||||
core.work.home(core, &texture.inner.image)?;
|
||||
core.work.home(core, texture.inner.imaged())?;
|
||||
}
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
crate::surface::steps::mark("plane home");
|
||||
@@ -5174,6 +5547,6 @@ impl Device {
|
||||
impl Texture {
|
||||
/// The texture's image, for an upload to hold.
|
||||
pub(crate) fn held_image(&self) -> Arc<Image> {
|
||||
Arc::clone(&self.inner.image)
|
||||
Arc::clone(self.inner.imaged())
|
||||
}
|
||||
}
|
||||
@@ -1167,6 +1167,12 @@
|
||||
"descriptorBindingStorageImageUpdateAfterBind": true,
|
||||
"shaderSampledImageArrayNonUniformIndexing": true,
|
||||
"shaderStorageImageArrayNonUniformIndexing": true,
|
||||
"descriptorBindingUniformTexelBufferUpdateAfterBind": true,
|
||||
"descriptorBindingStorageTexelBufferUpdateAfterBind": true,
|
||||
"shaderUniformTexelBufferArrayDynamicIndexing": true,
|
||||
"shaderStorageTexelBufferArrayDynamicIndexing": true,
|
||||
"shaderUniformTexelBufferArrayNonUniformIndexing": true,
|
||||
"shaderStorageTexelBufferArrayNonUniformIndexing": true,
|
||||
"samplerMirrorClampToEdge": true,
|
||||
"shaderInt8": true,
|
||||
"storageBuffer8BitAccess": true,
|
||||
@@ -1217,14 +1223,14 @@
|
||||
}
|
||||
},
|
||||
"VkPhysicalDeviceVulkan12Properties": {
|
||||
"maxPerStageDescriptorUpdateAfterBindSampledImages": 65536,
|
||||
"maxDescriptorSetUpdateAfterBindSampledImages": 65536,
|
||||
"maxPerStageDescriptorUpdateAfterBindStorageImages": 65536,
|
||||
"maxDescriptorSetUpdateAfterBindStorageImages": 65536,
|
||||
"maxPerStageDescriptorUpdateAfterBindSampledImages": 131072,
|
||||
"maxDescriptorSetUpdateAfterBindSampledImages": 131072,
|
||||
"maxPerStageDescriptorUpdateAfterBindStorageImages": 131072,
|
||||
"maxDescriptorSetUpdateAfterBindStorageImages": 131072,
|
||||
"maxPerStageDescriptorUpdateAfterBindSamplers": 12000,
|
||||
"maxDescriptorSetUpdateAfterBindSamplers": 12000,
|
||||
"maxPerStageUpdateAfterBindResources": 131080,
|
||||
"maxUpdateAfterBindDescriptorsInAllPools": 143072
|
||||
"maxPerStageUpdateAfterBindResources": 262152,
|
||||
"maxUpdateAfterBindDescriptorsInAllPools": 274144
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -649,7 +649,10 @@ fn a_texture_buffer_is_refused_where_a_2d_texture_is_made() {
|
||||
};
|
||||
let refused = made(rt::TextureType::TextureBuffer);
|
||||
assert!(
|
||||
matches!(refused, Err(rt::Error::Unsupported(rt::Gap::TextureBuffer))),
|
||||
matches!(
|
||||
refused,
|
||||
Err(rt::Error::Refused(rt::Refusal::TextureBufferNotOverBuffer))
|
||||
),
|
||||
"{refused:?}"
|
||||
);
|
||||
made(rt::TextureType::Type2D).unwrap();
|
||||
|
||||
Vendored
+1
-1
@@ -61,7 +61,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2257;
|
||||
pub const SEMANTICS_VERSION: u32 = 2258;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
//! (`Sampled = 2`) whose format is the slot's `StorageImageChoice` (`LowerInputs`). A cube texture
|
||||
//! that is read or written, and every storage cube, is declared as the 2D array the binder views it
|
||||
//! as (layer = face + 6 · cube, `RuntimeFact::ImageViewShape`), because Vulkan fetches no cube by
|
||||
//! face. Texture buffers are texel buffers (`RuntimeFact::TexelBufferRange`).
|
||||
//! face. Texture buffers are texel buffers (`RuntimeFact::TexelBufferRange`; under the identity
|
||||
//! domains, elements of set 1's texel-buffer arrays).
|
||||
//!
|
||||
//! **Operations.** `read` is `OpImageFetch` on a sampled image and `OpImageRead` on a storage
|
||||
//! image; `write` is `OpImageWrite`; `get_*` are `OpImageQuery*`; `fence` is an image memory
|
||||
@@ -2967,10 +2968,12 @@ fn select_read_as(
|
||||
// texel, where a device's block that holds no mapped tile reads the device's value. A texture
|
||||
// buffer's swizzle applies to its reads: Metal returns each channel from the source the bound
|
||||
// texture buffer's swizzle names, out of bounds too. A `ulong` read's swizzle is not measured;
|
||||
// the binder refuses a swizzled texture buffer there.
|
||||
// the binder refuses a swizzled texture buffer there. Under the identity domains the runtime
|
||||
// makes no swizzled texture buffer, so the read takes none.
|
||||
let swizzle = matches!(image, ImageRef::Slot(_))
|
||||
&& shape.dim == ImageDim::Buffer
|
||||
&& !matches!(texel.conv, TexelConv::U64Words { .. });
|
||||
&& !matches!(texel.conv, TexelConv::U64Words { .. })
|
||||
&& !crate::lower::access::identity(cx.profile);
|
||||
// A storage slot bound to a swizzled texture applies the swizzle under its variant, to the
|
||||
// converted texel, out of bounds too, as plain Metal reads it. A `ulong` texel's swizzle, and a
|
||||
// read of fewer lanes, are not measured. So does an extended-range sampled slot of the variant,
|
||||
|
||||
@@ -1306,7 +1306,9 @@ fn declare_slot(
|
||||
if cube_as_array {
|
||||
facts.push(RuntimeFact::ImageViewShape { slot: s.slot });
|
||||
}
|
||||
if shape.dim == ImageDim::Buffer {
|
||||
// Under the identity domains the runtime makes no texture buffer past
|
||||
// `maxTexelBufferElements`: the slot's element is its one view.
|
||||
if shape.dim == ImageDim::Buffer && !crate::lower::access::identity(cx.profile) {
|
||||
facts.push(RuntimeFact::TexelBufferRange { slot: s.slot });
|
||||
}
|
||||
// A texture-buffer slot under its parts variant is an array of its parts, one texel buffer
|
||||
@@ -1767,11 +1769,12 @@ impl SlotPlan {
|
||||
/// atomic's `R32ui` / `R32i` ([`atomic_format`]) or of a `ulong` texture's `Rg32ui`
|
||||
/// ([`ulong_format`]), each the format Metal requires of the bound texture there, whose storage
|
||||
/// element is of that format. A `ulong` slot is an `RG32` unsigned image whose two words the
|
||||
/// shader joins and splits, so its class is the unsigned integer one of its shape. `None` for a
|
||||
/// declaration the identity arrays hold no element of yet: a cube viewed as an array, level views,
|
||||
/// a texture buffer, its parts or rows, planes, an extended-range or RGBX form, a `ulong` slot a
|
||||
/// `ulong` atomic updates (an `R64ui` image), or a storage image with another format or a
|
||||
/// conversion.
|
||||
/// shader joins and splits, so its class is the unsigned integer one of its shape. A texture
|
||||
/// buffer's is a texel buffer's, uniform where the slot reads and storage where it writes, the
|
||||
/// element its resource ID holds in the texel-buffer arrays. `None` for a declaration the identity
|
||||
/// arrays hold no element of yet: a cube viewed as an array, level views, a texture buffer's parts
|
||||
/// or rows, planes, an extended-range or RGBX form, a `ulong` slot a `ulong` atomic updates (an
|
||||
/// `R64ui` image), or a storage image with another format or a conversion.
|
||||
pub(crate) fn identity_class(decl: &ImageDecl) -> Option<ImageHandleClass> {
|
||||
let plain = !decl.cube_as_array
|
||||
&& decl.level_views.is_none()
|
||||
@@ -1787,6 +1790,7 @@ pub(crate) fn identity_class(decl: &ImageDecl) -> Option<ImageHandleClass> {
|
||||
Dim::D2 => SymDim::D2,
|
||||
Dim::D3 => SymDim::D3,
|
||||
Dim::Cube => SymDim::Cube,
|
||||
Dim::Buffer => SymDim::Buffer,
|
||||
_ => return None,
|
||||
};
|
||||
let storage = decl.usage == ImageUsage::Storage;
|
||||
|
||||
@@ -1068,10 +1068,11 @@ fn heap_set(
|
||||
}))
|
||||
}
|
||||
|
||||
/// Each image array of the identity domains' set 1, the sampled-image array (binding 0) and the
|
||||
/// storage-image array (binding 1): one element per index a texture's resource ID may hold, the
|
||||
/// same index in both (`docs/RESOURCE-ID.md`). A power of two, so an argument buffer's texture
|
||||
/// index masked below it (`lower::access::handle`) is an element of both.
|
||||
/// Each texture array of the identity domains' set 1, the sampled-image array (binding 0), the
|
||||
/// storage-image array (binding 1), the uniform texel-buffer array (binding 5) and the storage
|
||||
/// texel-buffer array (binding 6): one element per index a texture's resource ID may hold, the
|
||||
/// same index in each (`docs/RESOURCE-ID.md`). A power of two, so an argument buffer's texture
|
||||
/// index masked below it (`lower::access::handle`) is an element of each.
|
||||
pub(crate) const IDENTITY_TEXTURES: u32 = 65_536;
|
||||
const _: () = assert!(IDENTITY_TEXTURES.is_power_of_two());
|
||||
|
||||
@@ -1082,13 +1083,15 @@ pub(crate) const IDENTITY_SAMPLERS: u32 = 4_000;
|
||||
|
||||
/// Set 1 under the identity domains: the same layout for every pipeline, so the consumer binds one
|
||||
/// set for every command. Binding 0 is the sampled-image array and binding 1 the storage-image
|
||||
/// array, each element the texture whose resource ID holds its index; every heap class the
|
||||
/// pipeline's stages declare is a variable of its descriptor type's binding, as the variables of
|
||||
/// one set and binding may be (Vulkan's "DescriptorSet and Binding Assignment"). Bindings 2, 3 and
|
||||
/// 4 are the sampler arrays of the three uses, each element the device's sampler of that use made
|
||||
/// of the sampler whose resource ID holds its index: plain (2), with depth comparison (3), and for
|
||||
/// an integer texture (4), every filter nearest. Every stage sees every array, partially bound,
|
||||
/// updated after binding and while unused elements are pending: the floor's features.
|
||||
/// array, each element the texture whose resource ID holds its index; bindings 5 and 6 are the
|
||||
/// uniform and storage texel-buffer arrays, each element the texture buffer whose resource ID
|
||||
/// holds its index. Every heap class the pipeline's stages declare is a variable of its descriptor
|
||||
/// type's binding, as the variables of one set and binding may be (Vulkan's "DescriptorSet and
|
||||
/// Binding Assignment"). Bindings 2, 3 and 4 are the sampler arrays of the three uses, each element
|
||||
/// the device's sampler of that use made of the sampler whose resource ID holds its index: plain
|
||||
/// (2), with depth comparison (3), and for an integer texture (4), every filter nearest. Every
|
||||
/// stage sees every array, partially bound, updated after binding and while unused elements are
|
||||
/// pending: the floor's features.
|
||||
fn identity_set(
|
||||
heap: &BTreeMap<HandleClass, HeapDecl>,
|
||||
table: &mut LinkTable,
|
||||
@@ -1097,6 +1100,8 @@ fn identity_set(
|
||||
let binding = match (h.ty, class) {
|
||||
(vk::DescriptorType::SAMPLED_IMAGE, _) => 0,
|
||||
(vk::DescriptorType::STORAGE_IMAGE, _) => 1,
|
||||
(vk::DescriptorType::UNIFORM_TEXEL_BUFFER, _) => 5,
|
||||
(vk::DescriptorType::STORAGE_TEXEL_BUFFER, _) => 6,
|
||||
(
|
||||
vk::DescriptorType::SAMPLER,
|
||||
HandleClass::Sampler {
|
||||
@@ -1146,6 +1151,16 @@ fn identity_set(
|
||||
array(2, vk::DescriptorType::SAMPLER, IDENTITY_SAMPLERS),
|
||||
array(3, vk::DescriptorType::SAMPLER, IDENTITY_SAMPLERS),
|
||||
array(4, vk::DescriptorType::SAMPLER, IDENTITY_SAMPLERS),
|
||||
array(
|
||||
5,
|
||||
vk::DescriptorType::UNIFORM_TEXEL_BUFFER,
|
||||
IDENTITY_TEXTURES,
|
||||
),
|
||||
array(
|
||||
6,
|
||||
vk::DescriptorType::STORAGE_TEXEL_BUFFER,
|
||||
IDENTITY_TEXTURES,
|
||||
),
|
||||
],
|
||||
flags: vk::DescriptorSetLayoutCreateFlags::UPDATE_AFTER_BIND_POOL,
|
||||
})
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
//! the textures there, answers the width and `is_null_texture` by the index (0 for nil), and,
|
||||
//! where the shader checks reads (no `robustImageAccess2`), takes a format's missing alpha out of
|
||||
//! bounds from the word, as `tests/resource_words.tsv` gives it.
|
||||
//! - A kernel's texture buffers (`engine/ob1_texel_buffer`, `engine/texture_ops`' `texel_buffers`,
|
||||
//! and an argument buffer's in `engine/rlm_runtime_limits`' `rlm_member_texture_buffer`) are the
|
||||
//! elements of set 1's texel-buffer arrays at the indices their resource IDs hold, a read one
|
||||
//! the uniform array's and a written one the storage array's, with no fact of the bound texture
|
||||
//! buffer. Each passes L3.
|
||||
//! - A kernel's texture atomic (`ta`, generated: `atomic_fetch_add` on a `texture2d<uint,
|
||||
//! access::read_write>`) declares its slot `R32ui`, a class whose variable is the storage-image
|
||||
//! array's. It passes L3 and, on the CPU interpreter, adds to the texels of the element its
|
||||
@@ -518,6 +523,47 @@ fn a_runtime_sampler_is_the_set_1_element_its_resource_id_names() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A kernel that reads one texture buffer and writes another (`ob1_texel_buffer`, of `uint`
|
||||
/// texels, and `texture_ops`' `texel_buffers`, of `float` ones), and one whose argument buffer
|
||||
/// holds one (`rlm_runtime_limits`' `rlm_member_texture_buffer`), take each from set 1's texel
|
||||
/// buffer arrays at the index its resource ID holds: a read one from the uniform array (binding 5)
|
||||
/// and a written one from the storage array (binding 6), with no fact of the bound texture buffer
|
||||
/// (no `TexelBufferRange`: the runtime's buffer view is the texture buffer, its width its texels).
|
||||
/// A slot's ID is its pushed field. Each passes L3 on each profile.
|
||||
#[test]
|
||||
fn a_texture_buffer_is_the_texel_buffer_element_its_resource_id_names() {
|
||||
let kernels = [
|
||||
("ob1_texel_buffer", "ob1_texel_buffer", vec![5, 6]),
|
||||
("texture_ops", "texel_buffers", vec![5, 6]),
|
||||
("rlm_runtime_limits", "rlm_member_texture_buffer", vec![5]),
|
||||
];
|
||||
for (fixture, entry, bindings) in kernels {
|
||||
let Some(bc) = assemble(fixture) else {
|
||||
return;
|
||||
};
|
||||
for stem in PROFILES {
|
||||
let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}"));
|
||||
let (a, plan, _) =
|
||||
compile_kept(&bc, entry, &p).unwrap_or_else(|e| panic!("{stem} {entry}: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{stem} {entry}: L3: {e}"));
|
||||
assert!(
|
||||
!(plan.facts.iter()).any(|f| matches!(f, RuntimeFact::TexelBufferRange { .. })),
|
||||
"{stem} {entry}: {:?}",
|
||||
plan.facts
|
||||
);
|
||||
let linked =
|
||||
link(&[&a], &LinkInputs::standalone(), &p).unwrap_or_else(|e| panic!("{e}"));
|
||||
let mut used: Vec<u32> = (linked.table.bindings.values())
|
||||
.filter(|(set, _)| *set == 1)
|
||||
.map(|(_, binding)| *binding)
|
||||
.collect();
|
||||
used.sort();
|
||||
used.dedup();
|
||||
assert_eq!(used, bindings, "{stem} {entry}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The words of `sample_up`'s constexpr sampler (`fixtures/public/harness/workloads.ll`).
|
||||
const SAMPLE_UP_WORDS: [u64; 2] = [34_901_797_601_020_489, 0];
|
||||
|
||||
@@ -748,6 +794,8 @@ fn identity_arrays() -> Vec<(u32, vk::DescriptorType, u32)> {
|
||||
(2, vk::DescriptorType::SAMPLER, 4_000),
|
||||
(3, vk::DescriptorType::SAMPLER, 4_000),
|
||||
(4, vk::DescriptorType::SAMPLER, 4_000),
|
||||
(5, vk::DescriptorType::UNIFORM_TEXEL_BUFFER, 65_536),
|
||||
(6, vk::DescriptorType::STORAGE_TEXEL_BUFFER, 65_536),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -6589,6 +6589,7 @@ method metal2vulkan-runtime::Device::import_host_memory pub unsafe fn import_hos
|
||||
method metal2vulkan-runtime::Device::loss pub fn loss(&self) -> Option<DeviceLoss>
|
||||
method metal2vulkan-runtime::Device::memory_types pub fn memory_types(&self) -> floor::MemoryTypes
|
||||
method metal2vulkan-runtime::Device::minimum_linear_texture_alignment pub fn minimum_linear_texture_alignment(&self, pixel_format: PixelFormat) -> Result<u64, Error>
|
||||
method metal2vulkan-runtime::Device::minimum_texture_buffer_alignment pub fn minimum_texture_buffer_alignment(&self, pixel_format: PixelFormat) -> Result<u64, Error>
|
||||
method metal2vulkan-runtime::Device::new pub fn new(physical: &PhysicalDevice, options: DeviceOptions) -> Result<Device, Error>
|
||||
method metal2vulkan-runtime::Device::new_buffer pub fn new_buffer(&self, block: BlockId, offset: u64, length: u64, zero_from: Option<u64>) -> Result<Buffer, Error>
|
||||
method metal2vulkan-runtime::Device::new_command_queue pub fn new_command_queue(&self, max_command_buffer_count: u32) -> Result<CommandQueue, Error>
|
||||
@@ -9276,7 +9277,7 @@ variant metal2vulkan-runtime::Gap::StageSize StageSize { weight: u64, cause: Sta
|
||||
variant metal2vulkan-runtime::Gap::StorageElement StorageElement { slot: Option<u32>, pixel_format: PixelFormat }
|
||||
variant metal2vulkan-runtime::Gap::SurfaceUsage SurfaceUsage { pixel_format: PixelFormat, missing: u32 }
|
||||
variant metal2vulkan-runtime::Gap::SwizzledReadWrite SwizzledReadWrite { slot: u32 }
|
||||
variant metal2vulkan-runtime::Gap::TextureBuffer TextureBuffer
|
||||
variant metal2vulkan-runtime::Gap::TextureBufferSwizzle TextureBufferSwizzle { pixel_format: PixelFormat }
|
||||
variant metal2vulkan-runtime::Gap::TextureBytes TextureBytes { pixel_format: PixelFormat }
|
||||
variant metal2vulkan-runtime::Gap::TextureCopy TextureCopy { source: PixelFormat, destination: PixelFormat }
|
||||
variant metal2vulkan-runtime::Gap::TextureFormat TextureFormat { pixel_format: PixelFormat }
|
||||
@@ -9495,6 +9496,8 @@ variant metal2vulkan-runtime::Refusal::SurfacePlanes SurfacePlanes { planes: usi
|
||||
variant metal2vulkan-runtime::Refusal::TessellationFactorOffset TessellationFactorOffset { offset: u64 }
|
||||
variant metal2vulkan-runtime::Refusal::TextureArgumentIndex TextureArgumentIndex { index: u32 }
|
||||
variant metal2vulkan-runtime::Refusal::TextureArrayLength TextureArrayLength { array_length: u32 }
|
||||
variant metal2vulkan-runtime::Refusal::TextureBufferAlignment TextureBufferAlignment { pixel_format: PixelFormat, offset: u64, alignment: u64 }
|
||||
variant metal2vulkan-runtime::Refusal::TextureBufferNotOverBuffer TextureBufferNotOverBuffer
|
||||
variant metal2vulkan-runtime::Refusal::TextureBytesLayout TextureBytesLayout { bytes_per_row: u64, bytes_per_image: u64, len: u64 }
|
||||
variant metal2vulkan-runtime::Refusal::TextureBytesPrivate TextureBytesPrivate
|
||||
variant metal2vulkan-runtime::Refusal::TextureCopyMismatch TextureCopyMismatch { source: PixelFormat, destination: PixelFormat }
|
||||
@@ -9584,6 +9587,7 @@ variant metal2vulkan-runtime::TextureViewKind::CubeOfArray CubeOfArray
|
||||
variant metal2vulkan-runtime::TextureViewKind::PixelFormat PixelFormat
|
||||
variant metal2vulkan-runtime::TextureViewKind::Slices Slices
|
||||
variant metal2vulkan-runtime::TextureViewKind::SurfacePixelFormat SurfacePixelFormat
|
||||
variant metal2vulkan-runtime::TextureViewKind::TextureBuffer TextureBuffer
|
||||
variant metal2vulkan-runtime::TextureViewKind::TextureType TextureType
|
||||
variant metal2vulkan-runtime::VariantStart::Ahead Ahead
|
||||
variant metal2vulkan-runtime::VariantStart::FirstUse FirstUse
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -10,12 +10,12 @@ Every public item of the macOS 27.2 SDK (Xcode 27.2, 27B52)'s Metal headers, by
|
||||
|
||||
| Status | Items | Of which deprecated |
|
||||
|---|---|---|
|
||||
| implemented | 621 | 29 |
|
||||
| missing | 1090 | 34 |
|
||||
| implemented | 622 | 29 |
|
||||
| missing | 1089 | 34 |
|
||||
| out of scope | 424 | 5 |
|
||||
| all | 2135 | 68 |
|
||||
|
||||
Implemented by the runtime: 265; by the translator's values: 356. Missing by size: S 182, M 205, L 327, XL 376.
|
||||
Implemented by the runtime: 266; by the translator's values: 356. Missing by size: S 181, M 205, L 327, XL 376.
|
||||
|
||||
## Missing, in build order
|
||||
|
||||
@@ -28,7 +28,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app
|
||||
| command queue descriptor | S | 3 | `MTLCommandQueueDescriptor`, `MTLCommandQueueDescriptor.maxCommandBufferCount`, `MTLDevice.newCommandQueueWithDescriptor:` |
|
||||
| compute, blit and resource-state pass descriptors | S | 10 | `MTLBlitPassDescriptor`, `MTLBlitPassDescriptor.blitPassDescriptor`, `MTLCommandBuffer.computeCommandEncoderWithDescriptor:`, ... |
|
||||
| libraries from a file path or URL | S | 2 | `MTLDevice.newLibraryWithFile:error:`, `MTLDevice.newLibraryWithURL:error:` |
|
||||
| device, state and resource queries | S | 73 | `MTLAllocation.allocatedSize`, `MTLBuffer.sparseBufferTier`, `MTLCommandBuffer.device`, ... |
|
||||
| device, state and resource queries | S | 72 | `MTLAllocation.allocatedSize`, `MTLBuffer.sparseBufferTier`, `MTLCommandBuffer.device`, ... |
|
||||
| plain-value constructors (`MTLOriginMake` and the rest) | S | 7 | `MTLOriginMake`, `MTLSizeMake`, `MTLRegionMake1D`, ... |
|
||||
| a buffer made with bytes | S | 1 | `MTLDevice.newBufferWithBytes:length:options:` |
|
||||
| pipeline creation forms (from a function, with a completion handler) | S | 6 | `MTLDevice.newRenderPipelineStateWithDescriptor:options:completionHandler:`, `MTLDevice.newComputePipelineStateWithFunction:error:`, `MTLDevice.newComputePipelineStateWithFunction:options:reflection:error:`, ... |
|
||||
@@ -1447,7 +1447,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app
|
||||
| `MTLDevice.supportsFamily:` | method | missing | S: a query or call metal2vulkan-runtime does not answer |
|
||||
| `MTLDevice.supportsTextureSampleCount:` | method | implemented | `Device::supports_texture_sample_count` (runtime) |
|
||||
| `MTLDevice.minimumLinearTextureAlignmentForPixelFormat:` | method | implemented | `Device::minimum_linear_texture_alignment` (runtime) |
|
||||
| `MTLDevice.minimumTextureBufferAlignmentForPixelFormat:` | method | missing | S: a texture buffer's offset alignment; a texture buffer is refused (`Gap::TextureBuffer`) |
|
||||
| `MTLDevice.minimumTextureBufferAlignmentForPixelFormat:` | method | implemented | `Device::minimum_texture_buffer_alignment` (runtime) |
|
||||
| `MTLDevice.newRenderPipelineStateWithTileDescriptor:options:reflection:error:` | method | missing | L: tile render pipelines; metal2vulkan-runtime makes none |
|
||||
| `MTLDevice.newRenderPipelineStateWithTileDescriptor:options:completionHandler:` | method | missing | L: tile render pipelines; metal2vulkan-runtime makes none |
|
||||
| `MTLDevice.newRenderPipelineStateWithMeshDescriptor:options:reflection:error:` | method | missing | L: mesh render pipelines; metal2vulkan-runtime makes none |
|
||||
@@ -2541,7 +2541,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app
|
||||
| `MTLTextureDescriptor` | class | implemented | `TextureDescriptor` (runtime) |
|
||||
| `MTLTextureDescriptor.texture2DDescriptorWithPixelFormat:width:height:mipmapped:` | class method | missing | S: a query or call metal2vulkan-runtime does not answer |
|
||||
| `MTLTextureDescriptor.textureCubeDescriptorWithPixelFormat:size:mipmapped:` | class method | missing | S: a query or call metal2vulkan-runtime does not answer |
|
||||
| `MTLTextureDescriptor.textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:` | class method | missing | S: a texture buffer's descriptor; a texture buffer is refused (`Gap::TextureBuffer`) |
|
||||
| `MTLTextureDescriptor.textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:` | class method | missing | S: a query or call metal2vulkan-runtime does not answer |
|
||||
| `MTLTextureDescriptor.textureType` | property | implemented | `TextureDescriptor.texture_type` (runtime) |
|
||||
| `MTLTextureDescriptor.pixelFormat` | property | implemented | `TextureDescriptor.pixel_format` (runtime) |
|
||||
| `MTLTextureDescriptor.width` | property | implemented | `TextureDescriptor.width` (runtime) |
|
||||
|
||||
+34
-30
@@ -32,7 +32,7 @@ Columns:
|
||||
| Rate maps the compile layer does not compile | 5 | 5 | 0 | 0 | 4 | 1 | 0 |
|
||||
| The translation deadline | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
|
||||
| Devices below the runtime's floor | 8 | 8 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Refusal` | 80 | 80 | 0 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Refusal` | 82 | 82 | 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 |
|
||||
|
||||
@@ -46,7 +46,7 @@ Columns:
|
||||
| Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
|
||||
| The translation deadline | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
|
||||
| Devices below the runtime's floor | 0 | 0 | 0 | 8 | 0 | 0 | 0 | 0 |
|
||||
| The runtime's `Refusal` | 22 | 24 | 0 | 0 | 34 | 0 | 0 | 0 |
|
||||
| The runtime's `Refusal` | 22 | 25 | 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 | 3 | 28 | 0 | 0 | 0 |
|
||||
|
||||
@@ -288,14 +288,14 @@ Columns:
|
||||
| `BufferOffsetAlignment` | A dispatch whose kernel, or a draw whose vertex or fragment function, reaches a buffer bound where its address, the buffer's `gpuAddress` plus the... | every device (a public call's own check of its arguments) | `metal-documented`: Metal's API validation refuses the bind offset: "must be a multiple of 4 but was set to 2" for a `uint *` argument bound at offset 2, an Apple M3 Max, macOS 27.0.1, `probes/vector_access_placement.m` in the conformance crate | 1: `crates/metal2vulkan-runtime/src/encoder.rs (check_alignment)` | `-` |
|
||||
| `IndicesGranted` | A grant of an index already granted (`Device::grant_indices`) | every device (a public call's own check of its arguments) | `ours`: each index has one grant, so each resource ID names one object | 1: `crates/metal2vulkan-runtime/src/arrays.rs (grant)` | `-` |
|
||||
| `IndicesNotGranted` | A texture, a sampler state or a pipeline state's constexpr sampler at an index no grant of its class holds (`Device::new_texture`,... | every device (a public call's own check of its arguments) | `ours`: an object takes an index the consumer was granted | 1: `crates/metal2vulkan-runtime/src/arrays.rs (place)` | `-` |
|
||||
| `TextureIndex` | A texture shaders reach made without an index, or one they do not reach made with one (`Device::new_texture`) | every device (a public call's own check of its arguments) | `ours`: an index is an element of set 1's texture arrays, which only shaders read | 4: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)`, `crates/metal2vulkan-runtime/src/texture.rs (surface_texture)` (+2) | `-` |
|
||||
| `TextureZeroExtent` | A texture with a width, height or depth of 0 | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "MTLTextureDescriptor has width of zero", and the same for a height of zero | 1: `crates/metal2vulkan-runtime/src/texture.rs (shape)` | `-` |
|
||||
| `TextureExtentForType` | A texture with a height other than 1 of a 1D type, or a depth other than 1 of a type that is not 3D | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "the texture type MTLTextureType1D requires that height is 1", and the same for a 2D texture of depth 2 | 1: `crates/metal2vulkan-runtime/src/texture.rs (shape)` | `-` |
|
||||
| `TextureIndex` | A texture shaders reach made without an index, or one they do not reach made with one (`Device::new_texture`) | every device (a public call's own check of its arguments) | `ours`: an index is an element of set 1's texture arrays, which only shaders read | 5: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)`, `crates/metal2vulkan-runtime/src/texture.rs (surface_texture)` (+3) | `-` |
|
||||
| `TextureZeroExtent` | A texture with a width, height or depth of 0 | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "MTLTextureDescriptor has width of zero", and the same for a height of zero | 2: `crates/metal2vulkan-runtime/src/texture.rs (shape)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureExtentForType` | A texture with a height other than 1 of a 1D type, or a depth other than 1 of a type that is not 3D | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "the texture type MTLTextureType1D requires that height is 1", and the same for a 2D texture of depth 2 | 2: `crates/metal2vulkan-runtime/src/texture.rs (shape)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureCubeNotSquare` | A cube texture whose width and height differ | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "MTLTextureDescriptor width must equal height for cube textures" | 1: `crates/metal2vulkan-runtime/src/texture.rs (shape)` | `-` |
|
||||
| `TextureArrayLength` | A texture with an array length of 0, or other than 1 of a type that is not an array | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "MTLTextureDescriptor has arrayLength of zero", where an array length of 2 is made | 2: `crates/metal2vulkan-runtime/src/texture.rs (shape, 2 sites)` | `-` |
|
||||
| `TextureLevelCount` | A texture with a mipmap level count of 0, more than its full chain's, or more than 1 of a multisample or 1D type | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "requests 5 mipmap levels, but the dimensions (8, 8, 1) can only support a maxiumum of 4 levels", and the same for 0 | 1: `crates/metal2vulkan-runtime/src/texture.rs (shape)` | `-` |
|
||||
| `TextureSampleCount` | A texture with a sample count of 0, or other than 1 of a type that is not multisample | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "has sampleCount set but is using a type that does not allow sampleCount" for 0 and for 2 of a 2D texture | 1: `crates/metal2vulkan-runtime/src/texture.rs (shape)` | `-` |
|
||||
| `TextureSwizzleWithWrites` | A texture with a swizzle other than each channel from itself and shader-write or render-target usage | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "Texture swizzling is not compatable with MTLTextureUsageShaderWrite", where a swizzle of read usage alone is made | 1: `crates/metal2vulkan-runtime/src/texture.rs (own_checks)` | `-` |
|
||||
| `TextureArrayLength` | A texture with an array length of 0, or other than 1 of a type that is not an array | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "MTLTextureDescriptor has arrayLength of zero", where an array length of 2 is made | 3: `crates/metal2vulkan-runtime/src/texture.rs (shape, 2 sites)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureLevelCount` | A texture with a mipmap level count of 0, more than its full chain's, or more than 1 of a multisample or 1D type | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "requests 5 mipmap levels, but the dimensions (8, 8, 1) can only support a maxiumum of 4 levels", and the same for 0 | 2: `crates/metal2vulkan-runtime/src/texture.rs (shape)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureSampleCount` | A texture with a sample count of 0, or other than 1 of a type that is not multisample | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "has sampleCount set but is using a type that does not allow sampleCount" for 0 and for 2 of a 2D texture | 2: `crates/metal2vulkan-runtime/src/texture.rs (shape)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureSwizzleWithWrites` | A texture with a swizzle other than each channel from itself and shader-write or render-target usage | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1: plain Metal asserts "Texture swizzling is not compatable with MTLTextureUsageShaderWrite", where a swizzle of read usage alone is made | 2: `crates/metal2vulkan-runtime/src/texture.rs (own_checks)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureBytesPrivate` | `Texture::replace_region` or `Texture::get_bytes` of a Private or Memoryless texture | every device (a public call's own check of its arguments) | `metal-documented`: Apple's documentation of `MTLStorageModePrivate`: "The resource is accessible only to the GPU." | 1: `crates/metal2vulkan-runtime/src/texture.rs (copy)` | `-` |
|
||||
| `TextureRegion` | `Texture::replace_region`, `Texture::get_bytes` or a blit copy (`BlitCommandEncoder::copy_from_texture`) of a level or slice past the texture's,... | every device (a public call's own check of its arguments) | `ours`: no texel of the texture is there to copy | 1: `crates/metal2vulkan-runtime/src/texture.rs (place)` | `-` |
|
||||
| `TextureBytesLayout` | `Texture::replace_region` or `Texture::get_bytes` with rows closer than a row of the region, images closer than an image of it, or bytes too few... | every device (a public call's own check of its arguments) | `ours`: the call would read or write past the bytes it is given, or one texel's bytes over another's | 1: `crates/metal2vulkan-runtime/src/texture.rs (copy)` | `-` |
|
||||
@@ -307,7 +307,9 @@ Columns:
|
||||
| `MipmapFormat` | `BlitCommandEncoder::generate_mipmaps` of a texture of more than one level whose pixel format is not a colour-renderable, filterable one | every device (a public call's own check of its arguments) | `metal-measured`: Apple's `generateMipmaps(for:)` page: mipmap generation works only for textures with colour-renderable and colour-filterable pixel formats; Metal's API validation stops the others, measured on an Apple M3 Max and an M4 | 1: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)` | `-` |
|
||||
| `TextureCopyMismatch` | `BlitCommandEncoder::copy_from_texture` between textures of two pixel formats, or of two sample counts | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, probe `blit_copy_format_pairs.m` in the conformance crate: Metal's validation layer stops every pair of two formats it was given, sRGB, integer, float, channel order, depth and compressed pairs among them, with `[sourceTexture pixelFormat](...) must equal [destinationTexture pixelFormat](...)`, and a source of four samples into one of one with `[sourceTexture sampleCount](4) must equal [destinationTexture sampleCount](1)` | 1: `crates/metal2vulkan-runtime/src/blit.rs (texture_copy)` | `-` |
|
||||
| `ManagedTextureBytes` | A Managed texture's bytes the device cannot copy in place (`Device::new_managed_texture`) | every device (a public call's own check of its arguments) | `ours`: a buffer-to-image copy reads a place only so laid out, and the consumer's bytes are the place the copy reads | 5: `crates/metal2vulkan-runtime/src/texture.rs (check_places)`, `crates/metal2vulkan-runtime/src/texture.rs (named)` (+2) | `-` |
|
||||
| `BufferTextureLayout` | A texture over a buffer (`Buffer::new_texture`) whose rows are not a whole number of texels apart or are closer than a row, whose offset is not a... | every device (a public call's own check of its arguments) | `ours`: a linear image and a copy read rows whole texels apart from a texel's start, and texels past the buffer would lie in memory it does not hold | 1: `crates/metal2vulkan-runtime/src/texture.rs (check_over)` | `-` |
|
||||
| `BufferTextureLayout` | A texture over a buffer (`Buffer::new_texture`) whose rows are not a whole number of texels apart or are closer than a row, whose offset is not a... | every device (a public call's own check of its arguments) | `ours`: a linear image and a copy read rows whole texels apart from a texel's start, and texels past the buffer would lie in memory it does not hold | 2: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureBufferAlignment` | A texture buffer (`MTLTextureTypeTextureBuffer`) over a buffer (`Buffer::new_texture`) whose offset is not a multiple of the device's minimum... | every device (a public call's own check of its arguments) | `metal-documented`: `MTLDevice.h`: `minimumTextureBufferAlignmentForPixelFormat:` "Returns the minimum alignment required for offset and rowBytes when creating a texture buffer from a buffer" | 1: `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `TextureBufferNotOverBuffer` | A texture buffer (`MTLTextureTypeTextureBuffer`) made other than over a buffer | every device (a public call's own check of its arguments) | `ours`: a texture buffer's texels are a buffer's bytes, read through a buffer view of the buffer; the runtime places no buffer of its own | 1: `crates/metal2vulkan-runtime/src/texture.rs (shape)` | `-` |
|
||||
| `HeapTexturePlace` | A heap texture whose image does not lie in its heap (`Device::new_heap_texture`, `Device::new_heap_texture_for_views`) | every device (a public call's own check of its arguments) | `ours`: an image bound past its heap's range would take memory the heap does not hold, and Vulkan binds an image only at its alignment | 1: `crates/metal2vulkan-runtime/src/texture.rs (make)` | `-` |
|
||||
| `DrawableDescriptor` | A drawable's texture (`Device::new_drawable_texture`) of a descriptor that is not a 2D texture of one level of the swapchain's image extent, or... | every device (a public call's own check of its arguments) | `ours`: the texture is the swapchain's image, which the descriptor states | 1: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)` | `-` |
|
||||
| `DrawableFormat` | A drawable's texture (`Device::new_drawable_texture`) over a swapchain whose image format is not the one the runtime holds the descriptor's pixel... | every device (a public call's own check of its arguments) | `ours`: the texture's views and copies read the image in the format the runtime holds the pixel format in | 1: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)` | `-` |
|
||||
@@ -345,7 +347,7 @@ Columns:
|
||||
| `ThreadgroupThreads` | A dispatch whose threadgroup is within Metal's `maxTotalThreadsPerThreadgroup` for the kernel and past the state's on this device | at the device's limit | `device`: the device's compute work-group and shared-memory limits | 1: `crates/metal2vulkan-runtime/src/encoder.rs (size_checked)` | `-` |
|
||||
| `BytesLength` | `setBytes` data longer than one parameter ring chunk | every device (a public call's own check of its arguments) | `ours`: a ring chunk is 64 KiB | 2: `crates/metal2vulkan-runtime/src/encoder.rs (set_bytes)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (set_bytes)` | `-` |
|
||||
| `IndexRange` | A grant of no indices, or one past its class's range (`Device::grant_indices`, [`IndexClass::range`]) | every device (a public call's own check of its arguments) | `ours`: the descriptor arrays are 65,536 sampled and 65,536 storage textures, one index of both a texture's, and 4,000 samplers of each use, and index 0 is nil | 1: `crates/metal2vulkan-runtime/src/arrays.rs (grant)` | `-` |
|
||||
| `TextureSize` | A texture whose extent or array layers are past what the device makes of its format, type, usage and sample count | at the device's limit | `device`: the image format query's `maxExtent` and `maxArrayLayers` | 1: `crates/metal2vulkan-runtime/src/texture.rs (plan)` | `-` |
|
||||
| `TextureSize` | A texture whose extent or array layers are past what the device makes of its format, type, usage and sample count | at the device's limit | `device`: the image format query's `maxExtent` and `maxArrayLayers`, and `maxTexelBufferElements` | 2: `crates/metal2vulkan-runtime/src/texture.rs (plan)`, `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `DeviceSamplers` | A sampler state whose device samplers would take the device past its `maxSamplerAllocationCount`, less the sampler arrays' two defaults... | at the device's limit | `device`: the device's `maxSamplerAllocationCount` | 1: `crates/metal2vulkan-runtime/src/sampler.rs (take)` | `-` |
|
||||
| `MemoryAllocations` | A `VkDeviceMemory` allocation past the device's `maxMemoryAllocationCount` live ones, refused before the driver is called | at the device's limit | `device`: the device's `maxMemoryAllocationCount` | 1: `crates/metal2vulkan-runtime/src/memory.rs (allocate)` | `-` |
|
||||
| `AllocationNotMapped` | A take that no free range fits made an allocation that the consumer's `BlockMappings::map` did not map | every device (a public call's own check of its arguments) | `ours`: the consumer's hook gave the allocation no place in its own address range | 1: `crates/metal2vulkan-runtime/src/memory.rs (own)` | `-` |
|
||||
@@ -369,15 +371,15 @@ Columns:
|
||||
| `NoStageInRegion` | A dispatch of a kernel that reads the stage-in region (`[[grid_origin]]`, `[[grid_size]]`) on an encoder that never set one... | every device (a public call's own check of its arguments) | `ours`: no replay stream dispatches such a kernel without setting a region | 1: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)` | `-` |
|
||||
| `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)` | `-` |
|
||||
| `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) | `-` |
|
||||
| `TextureBufferSwizzle` | A texture buffer (`MTLTextureTypeTextureBuffer`) with a swizzle other than each channel's own (`Buffer::new_texture`), which Metal applies to its... | every device (a public call's own check of its arguments) | `ours`: a texel buffer view has no component mapping, and a texture's resource ID carries no swizzle to the shader; no recorded stream makes one | 1: `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)` | `-` |
|
||||
| `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 | 4: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`, `crates/metal2vulkan-runtime/src/texture.rs (form)` (+2) | `-` |
|
||||
| `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)` | `-` |
|
||||
| `LodClamps` | A sampler state bound with LOD clamps its samples read otherwise through (`ComputeCommandEncoder::set_sampler_state_with_lod_clamps` and the... | every device (a public call's own check of its arguments) | `ours`: no replay stream binds such clamps: every bind-time clamp the streams make reads as its state's own | 1: `crates/metal2vulkan-runtime/src/sampler.rs (clamps_at_bind)` | `-` |
|
||||
| `TextureBytes` | `Texture::replace_region`, `Texture::get_bytes` or a blit copy between a buffer and a texture (`BlitCommandEncoder::copy_from_buffer`) of a... | every device (a public call's own check of its arguments) | `ours`: no copy between such an image and bytes is built | 4: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-runtime/src/blit.rs (with_option)` (+2) | `-` |
|
||||
| `TextureBytes` | `Texture::replace_region`, `Texture::get_bytes` or a blit copy between a buffer and a texture (`BlitCommandEncoder::copy_from_buffer`) of a... | every device (a public call's own check of its arguments) | `ours`: no copy between such an image and bytes is built, nor a texture buffer's copy as a buffer copy; no recorded stream copies a texture buffer | 5: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy, 2 sites)`, `crates/metal2vulkan-runtime/src/blit.rs (with_option)` (+2) | `-` |
|
||||
| `FloatDepthUpload` | `Texture::replace_region` or `BlitCommandEncoder::copy_from_buffer` into a 32-bit float depth (`Depth32Float`) | every device (a public call's own check of its arguments) | `ours`: no upload of a 32-bit float depth is built | 3: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`, `crates/metal2vulkan-runtime/src/texture.rs (replace_region)` (+1) | `-` |
|
||||
| `TextureCopy` | `BlitCommandEncoder::copy_from_texture` that the floor's `vkCmdCopyImage` does not make | every device (a public call's own check of its arguments) | `ours`: Vulkan 1.3 copies none of these with one command, nor these regions in slabs along one axis; each is built when a replay stream makes one | 1: `crates/metal2vulkan-runtime/src/blit.rs (texture_copy)` | `-` |
|
||||
| `TextureOverBuffer` | A texture over a buffer (`Buffer::new_texture`) the runtime does not make | every device (a public call's own check of its arguments) | `ours`: the in-place linear image and the copy form take one 2D color image | 3: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`, `crates/metal2vulkan-runtime/src/texture.rs (error)` (+1) | `-` |
|
||||
| `TextureCopy` | `BlitCommandEncoder::copy_from_texture` that the floor's `vkCmdCopyImage` does not make | every device (a public call's own check of its arguments) | `ours`: Vulkan 1.3 copies none of these with one command, nor these regions in slabs along one axis; each is built when a replay stream makes one | 2: `crates/metal2vulkan-runtime/src/blit.rs (copy_from_texture)`, `crates/metal2vulkan-runtime/src/blit.rs (texture_copy)` | `-` |
|
||||
| `TextureOverBuffer` | A texture over a buffer (`Buffer::new_texture`) the runtime does not make | every device (a public call's own check of its arguments) | `ours`: the in-place linear image and the copy form take one 2D color image, and a texture buffer's view the texel-buffer offset alignment of Vulkan 1.3 | 4: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`, `crates/metal2vulkan-runtime/src/texture.rs (error)` (+2) | `-` |
|
||||
| `HeapTexture` | A heap texture the runtime does not place (`Device::new_heap_texture`, `Device::new_heap_texture_for_views` and `Device::heap_texture_size_and_align`) | every device (a public call's own check of its arguments) | `ours`: heap textures are built for Private heaps of placeable images | 2: `crates/metal2vulkan-runtime/src/texture.rs (heap_fit)`, `crates/metal2vulkan-runtime/src/texture.rs (heap_source)` | `-` |
|
||||
| `SurfaceUsage` | A surface plane in place (`Device::new_exported_surface`) whose texture's uses ask an image usage its linear tiling lacks (storage, for one) | at the device's limit | `device`: the image format query and the format features of the plane's tiling | 3: `crates/metal2vulkan-runtime/src/d3d11.rs (d3d11_plane)`, `crates/metal2vulkan-runtime/src/surface.rs (plane)` (+1) | `-` |
|
||||
| `D3d11SurfaceBuffer` | The buffer of a surface of Direct3D 11 textures (`Surface::buffer` of `Device::import_d3d11_surface`'s, a Windows host's) | every device (a public call's own check of its arguments) | `ours`: each plane is a Direct3D 11 texture of its own, imported into memory of its own as an optimal image, so no one memory holds the picture's bytes for a buffer | 1: `crates/metal2vulkan-runtime/src/surface.rs (buffer)` | `-` |
|
||||
@@ -587,14 +589,14 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Refusal::BufferOffsetAlignment`: `crates/metal2vulkan-runtime/src/encoder.rs (check_alignment)`
|
||||
- `rt:Refusal::IndicesGranted`: `crates/metal2vulkan-runtime/src/arrays.rs (grant)`
|
||||
- `rt:Refusal::IndicesNotGranted`: `crates/metal2vulkan-runtime/src/arrays.rs (place)`
|
||||
- `rt:Refusal::TextureIndex`: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (surface_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (texture)`; `crates/metal2vulkan-runtime/src/texture.rs (view)`
|
||||
- `rt:Refusal::TextureZeroExtent`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`
|
||||
- `rt:Refusal::TextureExtentForType`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`
|
||||
- `rt:Refusal::TextureIndex`: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (surface_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`; `crates/metal2vulkan-runtime/src/texture.rs (texture)`; `crates/metal2vulkan-runtime/src/texture.rs (view)`
|
||||
- `rt:Refusal::TextureZeroExtent`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureExtentForType`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureCubeNotSquare`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`
|
||||
- `rt:Refusal::TextureArrayLength`: `crates/metal2vulkan-runtime/src/texture.rs (shape, 2 sites)`
|
||||
- `rt:Refusal::TextureLevelCount`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`
|
||||
- `rt:Refusal::TextureSampleCount`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`
|
||||
- `rt:Refusal::TextureSwizzleWithWrites`: `crates/metal2vulkan-runtime/src/texture.rs (own_checks)`
|
||||
- `rt:Refusal::TextureArrayLength`: `crates/metal2vulkan-runtime/src/texture.rs (shape, 2 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureLevelCount`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureSampleCount`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureSwizzleWithWrites`: `crates/metal2vulkan-runtime/src/texture.rs (own_checks)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureBytesPrivate`: `crates/metal2vulkan-runtime/src/texture.rs (copy)`
|
||||
- `rt:Refusal::TextureRegion`: `crates/metal2vulkan-runtime/src/texture.rs (place)`
|
||||
- `rt:Refusal::TextureBytesLayout`: `crates/metal2vulkan-runtime/src/texture.rs (copy)`
|
||||
@@ -606,7 +608,9 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Refusal::MipmapFormat`: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)`
|
||||
- `rt:Refusal::TextureCopyMismatch`: `crates/metal2vulkan-runtime/src/blit.rs (texture_copy)`
|
||||
- `rt:Refusal::ManagedTextureBytes`: `crates/metal2vulkan-runtime/src/texture.rs (check_places)`; `crates/metal2vulkan-runtime/src/texture.rs (named)`; `crates/metal2vulkan-runtime/src/texture.rs (named_host)`; `crates/metal2vulkan-runtime/src/texture.rs (upload_region, 2 sites)`
|
||||
- `rt:Refusal::BufferTextureLayout`: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`
|
||||
- `rt:Refusal::BufferTextureLayout`: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureBufferAlignment`: `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Refusal::TextureBufferNotOverBuffer`: `crates/metal2vulkan-runtime/src/texture.rs (shape)`
|
||||
- `rt:Refusal::HeapTexturePlace`: `crates/metal2vulkan-runtime/src/texture.rs (make)`
|
||||
- `rt:Refusal::DrawableDescriptor`: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)`
|
||||
- `rt:Refusal::DrawableFormat`: `crates/metal2vulkan-runtime/src/texture.rs (new_drawable_texture)`
|
||||
@@ -639,7 +643,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Limit::ThreadgroupThreads`: `crates/metal2vulkan-runtime/src/encoder.rs (size_checked)`
|
||||
- `rt:Limit::BytesLength`: `crates/metal2vulkan-runtime/src/encoder.rs (set_bytes)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_bytes)`
|
||||
- `rt:Limit::IndexRange`: `crates/metal2vulkan-runtime/src/arrays.rs (grant)`
|
||||
- `rt:Limit::TextureSize`: `crates/metal2vulkan-runtime/src/texture.rs (plan)`
|
||||
- `rt:Limit::TextureSize`: `crates/metal2vulkan-runtime/src/texture.rs (plan)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Limit::DeviceSamplers`: `crates/metal2vulkan-runtime/src/sampler.rs (take)`
|
||||
- `rt:Limit::MemoryAllocations`: `crates/metal2vulkan-runtime/src/memory.rs (allocate)`
|
||||
- `rt:Limit::AllocationNotMapped`: `crates/metal2vulkan-runtime/src/memory.rs (own)`
|
||||
@@ -658,15 +662,15 @@ Each refusal's sites, with the function that builds it.
|
||||
- `rt:Gap::NoStageInRegion`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`
|
||||
- `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::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::TextureBufferSwizzle`: `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `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)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_form)`
|
||||
- `rt:Gap::MipmapFilter`: `crates/metal2vulkan-runtime/src/blit.rs (generate_mipmaps)`
|
||||
- `rt:Gap::CubicSampler`: `crates/metal2vulkan-runtime/src/sampler.rs (new_sampler_state)`
|
||||
- `rt:Gap::LodClamps`: `crates/metal2vulkan-runtime/src/sampler.rs (clamps_at_bind)`
|
||||
- `rt:Gap::TextureBytes`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-runtime/src/blit.rs (with_option)`; `crates/metal2vulkan-runtime/src/texture.rs (check_places)`; `crates/metal2vulkan-runtime/src/texture.rs (copy)`
|
||||
- `rt:Gap::TextureBytes`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy, 2 sites)`; `crates/metal2vulkan-runtime/src/blit.rs (with_option)`; `crates/metal2vulkan-runtime/src/texture.rs (check_places)`; `crates/metal2vulkan-runtime/src/texture.rs (copy)`
|
||||
- `rt:Gap::FloatDepthUpload`: `crates/metal2vulkan-runtime/src/blit.rs (buffer_copy)`; `crates/metal2vulkan-runtime/src/texture.rs (replace_region)`; `crates/metal2vulkan-runtime/src/texture.rs (upload_region)`
|
||||
- `rt:Gap::TextureCopy`: `crates/metal2vulkan-runtime/src/blit.rs (texture_copy)`
|
||||
- `rt:Gap::TextureOverBuffer`: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`; `crates/metal2vulkan-runtime/src/texture.rs (error)`; `crates/metal2vulkan-runtime/src/texture.rs (over_texel)`
|
||||
- `rt:Gap::TextureCopy`: `crates/metal2vulkan-runtime/src/blit.rs (copy_from_texture)`; `crates/metal2vulkan-runtime/src/blit.rs (texture_copy)`
|
||||
- `rt:Gap::TextureOverBuffer`: `crates/metal2vulkan-runtime/src/texture.rs (check_over)`; `crates/metal2vulkan-runtime/src/texture.rs (error)`; `crates/metal2vulkan-runtime/src/texture.rs (over_texel)`; `crates/metal2vulkan-runtime/src/texture.rs (texel_texture)`
|
||||
- `rt:Gap::HeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs (heap_fit)`; `crates/metal2vulkan-runtime/src/texture.rs (heap_source)`
|
||||
- `rt:Gap::SurfaceUsage`: `crates/metal2vulkan-runtime/src/d3d11.rs (d3d11_plane)`; `crates/metal2vulkan-runtime/src/surface.rs (plane)`; `crates/metal2vulkan-runtime/src/texture.rs (surface_texture)`
|
||||
- `rt:Gap::D3d11SurfaceBuffer`: `crates/metal2vulkan-runtime/src/surface.rs (buffer)`
|
||||
|
||||
@@ -1111,7 +1111,7 @@ MTLDevice.h MTLDevice method supportsFeatureSet: yes M deprecated feature sets
|
||||
MTLDevice.h MTLDevice method supportsFamily: M a query or call metal2vulkan-runtime does not answer S queries
|
||||
MTLDevice.h MTLDevice method supportsTextureSampleCount: I runtime Device::supports_texture_sample_count
|
||||
MTLDevice.h MTLDevice method minimumLinearTextureAlignmentForPixelFormat: I runtime Device::minimum_linear_texture_alignment
|
||||
MTLDevice.h MTLDevice method minimumTextureBufferAlignmentForPixelFormat: M a texture buffer's offset alignment; a texture buffer is refused (`Gap::TextureBuffer`) S queries
|
||||
MTLDevice.h MTLDevice method minimumTextureBufferAlignmentForPixelFormat: I runtime Device::minimum_texture_buffer_alignment
|
||||
MTLDevice.h MTLDevice method newRenderPipelineStateWithTileDescriptor:options:reflection:error: M tile render pipelines; metal2vulkan-runtime makes none L tile
|
||||
MTLDevice.h MTLDevice method newRenderPipelineStateWithTileDescriptor:options:completionHandler: M tile render pipelines; metal2vulkan-runtime makes none L tile
|
||||
MTLDevice.h MTLDevice method newRenderPipelineStateWithMeshDescriptor:options:reflection:error: M mesh render pipelines; metal2vulkan-runtime makes none L mesh
|
||||
@@ -2030,7 +2030,7 @@ MTLTexture.h MTLSharedTextureHandle property label M labels of samplers, dept
|
||||
MTLTexture.h MTLTextureDescriptor class MTLTextureDescriptor I runtime TextureDescriptor
|
||||
MTLTexture.h MTLTextureDescriptor class method texture2DDescriptorWithPixelFormat:width:height:mipmapped: M a query or call metal2vulkan-runtime does not answer S queries
|
||||
MTLTexture.h MTLTextureDescriptor class method textureCubeDescriptorWithPixelFormat:size:mipmapped: M a query or call metal2vulkan-runtime does not answer S queries
|
||||
MTLTexture.h MTLTextureDescriptor class method textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage: M a texture buffer's descriptor; a texture buffer is refused (`Gap::TextureBuffer`) S queries
|
||||
MTLTexture.h MTLTextureDescriptor class method textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage: M a query or call metal2vulkan-runtime does not answer S queries
|
||||
MTLTexture.h MTLTextureDescriptor property textureType I runtime TextureDescriptor.texture_type
|
||||
MTLTexture.h MTLTextureDescriptor property pixelFormat I runtime TextureDescriptor.pixel_format
|
||||
MTLTexture.h MTLTextureDescriptor property width I runtime TextureDescriptor.width
|
||||
|
||||
|
@@ -127,7 +127,13 @@ RUNTIME_FLOOR = {
|
||||
"descriptorBindingSampledImageUpdateAfterBind",
|
||||
"descriptorBindingStorageImageUpdateAfterBind",
|
||||
"shaderSampledImageArrayNonUniformIndexing",
|
||||
"shaderStorageImageArrayNonUniformIndexing", "samplerMirrorClampToEdge",
|
||||
"shaderStorageImageArrayNonUniformIndexing",
|
||||
"descriptorBindingUniformTexelBufferUpdateAfterBind",
|
||||
"descriptorBindingStorageTexelBufferUpdateAfterBind",
|
||||
"shaderUniformTexelBufferArrayDynamicIndexing",
|
||||
"shaderStorageTexelBufferArrayDynamicIndexing",
|
||||
"shaderUniformTexelBufferArrayNonUniformIndexing",
|
||||
"shaderStorageTexelBufferArrayNonUniformIndexing", "samplerMirrorClampToEdge",
|
||||
"shaderInt8", "storageBuffer8BitAccess", "scalarBlockLayout",
|
||||
"uniformBufferStandardLayout", "vulkanMemoryModel", "vulkanMemoryModelDeviceScope",
|
||||
"shaderSubgroupExtendedTypes", "timelineSemaphore", "hostQueryReset",
|
||||
@@ -153,14 +159,14 @@ RUNTIME_FLOOR = {
|
||||
"maxFragmentOutputAttachments": 8,
|
||||
}},
|
||||
"VkPhysicalDeviceVulkan12Properties": {
|
||||
"maxPerStageDescriptorUpdateAfterBindSampledImages": 65536,
|
||||
"maxDescriptorSetUpdateAfterBindSampledImages": 65536,
|
||||
"maxPerStageDescriptorUpdateAfterBindStorageImages": 65536,
|
||||
"maxDescriptorSetUpdateAfterBindStorageImages": 65536,
|
||||
"maxPerStageDescriptorUpdateAfterBindSampledImages": 131072,
|
||||
"maxDescriptorSetUpdateAfterBindSampledImages": 131072,
|
||||
"maxPerStageDescriptorUpdateAfterBindStorageImages": 131072,
|
||||
"maxDescriptorSetUpdateAfterBindStorageImages": 131072,
|
||||
"maxPerStageDescriptorUpdateAfterBindSamplers": 12000,
|
||||
"maxDescriptorSetUpdateAfterBindSamplers": 12000,
|
||||
"maxPerStageUpdateAfterBindResources": 131080,
|
||||
"maxUpdateAfterBindDescriptorsInAllPools": 143072,
|
||||
"maxPerStageUpdateAfterBindResources": 262152,
|
||||
"maxUpdateAfterBindDescriptorsInAllPools": 274144,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user