Validation: an argument-buffer texture buffer binds as a used texture, so the authored compile census compiles it
The authored compile census failed one case, 2631f2da (the public fragment case reading abt_frag_texel_buffer's texture_buffer member), on every profile with "argument-buffer texture 2 is a texture buffer, which no heap array holds" (census job m3-max-63908 atd274b0b474). Sinceed4f8976a5retired texture_buffer_member, the case is no longer refused by a requirement; a run draws it through the runtime (runs_render_through_runtime), which makes texture buffers, and the Metal oracle's observation of it is committed. Only the census still reached the executor's own bind state: case_compile builds its request's bind shape with graphics::render_shape -> bind_state -> argument_buffers::used_texture (argument_buffers.rs:279-283), which refused a texture buffer untyped. The member is now what Metal's useResource makes resident: a used texture of Metal's TextureBuffer type and its pixel format (resources::texture_facts, which bound_texture now uses for image textures), with its resource id. The translator already plans such a used resource: bind::heap's members make no heap member of a texture buffer (heap.rs:931-934), and under the identity domains the census compiles for (DevicePolicy::default, the runtime's) a texture-buffer member is a set-1 texel-buffer element (817463704e). The executor's own context still refuses a case holding one, typed, before it binds (own_context_refuses_members), since its resident-table heap holds no such member; its docs now say why there rather than in used_texture. No version moves: ENGINE_EXECUTOR_ABI's rule exempts a change no recorded row can observe. The runtime route builds no bind state, the own context refuses the case before binding, and the census never caches a failed cell, so no recorded row or cached cell held this shape. The case's census cells change from failed to what the compile gives when main blesses. Tests: argument_buffer_members_are_written_into_their_owner asserts the texture buffer member's used texture (type, format, token, resource id) and that compute_shape plans it (it asserted the refusal before); the_census_compiles_a_texture_buffer_an_argument_buffer_holds compiles every committed case holding one through compile_case on lavapipe under the identity domains, expecting one compiled cell each (the failed cell before).
This commit is contained in:
1 parent
5ccd158e6d
commit
49eebb4d7f
5 files changed
+109
-28
No files matched your search
@@ -1925,7 +1925,8 @@ fn prepare_on_device(input: &DeviceInput) -> Result<(PreparedCase, CompileWorker
|
||||
|
||||
/// Whether the executor's own context refuses a case whose argument buffers hold `members`: a
|
||||
/// texture buffer among them, which a run through the runtime makes over a buffer of its bytes
|
||||
/// (`platform::runtime_textures`) and the binder's planned heap holds no member of
|
||||
/// (`platform::runtime_textures`) and the binder's planned heap holds no member of (the
|
||||
/// translator's `bind::heap`), so a handle loaded from its field would miss
|
||||
/// ([`argument_buffers::used_texture`]).
|
||||
pub fn own_context_refuses_members<'a>(
|
||||
mut members: impl Iterator<Item = &'a LiteralTexture>,
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
//! - a texture is its `gpuResourceID` in the owner and a used resource of class `Texture` with
|
||||
//! that resource id ([`used_texture`]): a heap member, which the plan writes into every heap
|
||||
//! array whose class holds it and enters in each stage's handle table, so a handle loaded from
|
||||
//! the field finds its element;
|
||||
//! the field finds its element; a texture buffer is one of Metal's `TextureBuffer` type, which
|
||||
//! the plan's heap holds no member of, so only a run through the runtime draws it;
|
||||
//! - a sampler is its `gpuResourceID` in the owner and an argument sampler of the bind state with
|
||||
//! that id ([`embed_samplers`], [`sampler_ids`]): the plan writes it into each sampler array
|
||||
//! and enters it in each stage's sampler table, so a sampler loaded from the field finds its
|
||||
@@ -25,7 +26,7 @@ use super::resources;
|
||||
use super::BufferAddress;
|
||||
use crate::case::ArgumentBufferSamplerResource;
|
||||
use crate::literal::{LiteralArgumentBufferBuffer, LiteralArgumentBufferTexture, LiteralTexture};
|
||||
use metal2vulkan::bind::{ArgumentSampler, BoundTexture, ResourceClass, UsedResource};
|
||||
use metal2vulkan::bind::{ArgumentSampler, ResourceClass, UsedResource};
|
||||
use metal2vulkan::metal::{RenderStages, ResourceUsage};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -266,21 +267,19 @@ pub fn used_buffer(
|
||||
}
|
||||
|
||||
/// The used resource of the argument-buffer texture `texture` whose consumer token is `token`
|
||||
/// ([`texture_tokens`]): a `Texture` of the facts a bound texture of it has
|
||||
/// ([`resources::bound_texture`]), whose resource id is [`resource_id`] of its token, resident
|
||||
/// for reading and writing in `stages` as the Metal oracle's `useResource` makes it. A texture
|
||||
/// buffer is refused: the binder's planned heap makes no texture buffer a member, so a handle
|
||||
/// naming one would miss.
|
||||
/// ([`texture_tokens`]): a `Texture` of its facts ([`resources::texture_facts`]), a texture
|
||||
/// buffer's of Metal's `TextureBuffer` type, whose resource id is [`resource_id`] of its token,
|
||||
/// resident for reading and writing in `stages` as the Metal oracle's `useResource` makes it.
|
||||
/// The binder's planned heap makes no texture buffer a member (the translator's `bind::heap`), so
|
||||
/// the executor's own context refuses a case that holds one
|
||||
/// ([`own_context_refuses_members`](super::own_context_refuses_members)); a run through the
|
||||
/// runtime draws it, and the authored compile census compiles its pipeline for this bind shape.
|
||||
pub fn used_texture(
|
||||
token: u32,
|
||||
texture: &LiteralTexture,
|
||||
stages: RenderStages,
|
||||
) -> Result<UsedResource, String> {
|
||||
let BoundTexture::Texture { facts, .. } = resources::bound_texture(texture)? else {
|
||||
return Err(format!(
|
||||
"argument-buffer texture {token} is a texture buffer, which no heap array holds"
|
||||
));
|
||||
};
|
||||
let facts = resources::texture_facts(texture)?;
|
||||
let mut used = UsedResource::new(ResourceClass::Texture(facts), token);
|
||||
used.usage = ResourceUsage::READ | ResourceUsage::WRITE;
|
||||
used.stages = stages;
|
||||
|
||||
@@ -153,14 +153,12 @@ pub fn texel_buffer_length(texture: &LiteralTexture) -> Result<u64, String> {
|
||||
}
|
||||
|
||||
/// What the binder sees bound for an authored texture: a texture buffer's view (offset 0, its
|
||||
/// width in texels), or an image texture's facts (Metal's `arrayLength` counts cubes for a cube
|
||||
/// array, its levels, shader read and write usage, and `isSparse` for a sparse texture).
|
||||
/// width in texels), or an image texture's facts ([`texture_facts`]).
|
||||
pub fn bound_texture(texture: &LiteralTexture) -> Result<BoundTexture, String> {
|
||||
let pixel_format = pixel_format(texture.format);
|
||||
if texture.texture_type == TextureType::Buffer {
|
||||
let length = texel_buffer_length(texture)?;
|
||||
return Ok(BoundTexture::Buffer {
|
||||
pixel_format,
|
||||
pixel_format: pixel_format(texture.format),
|
||||
offset: 0,
|
||||
length,
|
||||
bytes_per_row: length,
|
||||
@@ -169,10 +167,29 @@ pub fn bound_texture(texture: &LiteralTexture) -> Result<BoundTexture, String> {
|
||||
parts: 1,
|
||||
});
|
||||
}
|
||||
let layout = texture.layout()?;
|
||||
let mut facts = TextureFacts::new(self::texture_type(texture.texture_type), pixel_format);
|
||||
facts.sample_count = layout.sample_count;
|
||||
Ok(BoundTexture::Texture {
|
||||
facts: texture_facts(texture)?,
|
||||
resource_id: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The facts of an authored texture, as the binder sees an image texture bound and a used
|
||||
/// resource (`useResource`) names any texture: its type, its pixel format, and shader read and
|
||||
/// write usage; an image texture's sample count, Metal's `arrayLength` (which counts cubes for a
|
||||
/// cube array), its levels, and `isSparse` for a sparse texture. A texture buffer is one sample,
|
||||
/// level and slice of Metal's `TextureBuffer` type, its width checked ([`texel_buffer_length`]).
|
||||
pub fn texture_facts(texture: &LiteralTexture) -> Result<TextureFacts, String> {
|
||||
let mut facts = TextureFacts::new(
|
||||
self::texture_type(texture.texture_type),
|
||||
pixel_format(texture.format),
|
||||
);
|
||||
facts.usage = metal::TextureUsage::SHADER_READ | metal::TextureUsage::SHADER_WRITE;
|
||||
if texture.texture_type == TextureType::Buffer {
|
||||
texel_buffer_length(texture)?;
|
||||
return Ok(facts);
|
||||
}
|
||||
let layout = texture.layout()?;
|
||||
facts.sample_count = layout.sample_count;
|
||||
facts.array_length = match texture.texture_type {
|
||||
TextureType::D1Array | TextureType::D2Array | TextureType::D2MultisampleArray => {
|
||||
layout.array_layers
|
||||
@@ -182,10 +199,7 @@ pub fn bound_texture(texture: &LiteralTexture) -> Result<BoundTexture, String> {
|
||||
};
|
||||
facts.sparse = texture.sparse.is_some();
|
||||
facts.mipmap_level_count = texture.mip_levels;
|
||||
Ok(BoundTexture::Texture {
|
||||
facts,
|
||||
resource_id: None,
|
||||
})
|
||||
Ok(facts)
|
||||
}
|
||||
|
||||
/// The `MTLSamplerDescriptor` the Metal oracle creates for `sampler`: the defaults, with the
|
||||
|
||||
+21
-4
@@ -68,8 +68,8 @@ fn gap(case: &AuthoredCase, expected: &str) {
|
||||
/// writing like the oracle's `useResource`; the owner is created holding the buffer's address and
|
||||
/// each texture's resource id at their fields; a texture's region is an output; and an owner that
|
||||
/// is not bound, a key authored twice, a field named twice, and overlapping fields are refused. A
|
||||
/// texture buffer maps, as a run through the runtime makes it, and the executor's own bind state
|
||||
/// refuses it.
|
||||
/// texture buffer maps, as a run through the runtime makes it, and binds as a used texture of
|
||||
/// Metal's `TextureBuffer` type, in the shape the authored compile census compiles for.
|
||||
#[test]
|
||||
fn argument_buffer_members_are_written_into_their_owner() {
|
||||
let mut case = kernel_case();
|
||||
@@ -218,8 +218,25 @@ fn argument_buffer_members_are_written_into_their_owner() {
|
||||
texel.argument_buffer_textures[&(0, 16)].texture_type,
|
||||
TextureType::Buffer
|
||||
);
|
||||
let refused = bind_state(&texel, &addresses, &embedded, BufferRanges::default()).unwrap_err();
|
||||
assert!(refused.contains("texture buffer"), "{refused}");
|
||||
let state = bind_state(&texel, &addresses, &embedded, BufferRanges::default()).unwrap();
|
||||
let ResourceClass::Texture(facts) = state.used_resources[1].class else {
|
||||
panic!("{:?}", state.used_resources);
|
||||
};
|
||||
assert_eq!(
|
||||
(facts.texture_type, facts.pixel_format),
|
||||
(MetalType::TextureBuffer, PixelFormat::RGBA8Unorm)
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
state.used_resources[1].token,
|
||||
state.used_resources[1].resource_id
|
||||
),
|
||||
(1, Some(resource_id(1)))
|
||||
);
|
||||
assert_eq!(
|
||||
compute_shape(&texel, true, BufferRanges::default()).unwrap(),
|
||||
state.shape()
|
||||
);
|
||||
}
|
||||
|
||||
/// End to end without a device: `argument_buffer_read` of the owned `handles` fixture on
|
||||
|
||||
@@ -357,3 +357,53 @@ fn the_census_compiles_the_mesh_pipelines_no_candidate_draws() {
|
||||
assert_eq!(cells[0].compiles, 1, "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A case whose argument buffer holds a texture buffer, which a run draws through the runtime,
|
||||
/// compiles in the census under the identity domains (the runtime's): the member is a used
|
||||
/// texture of Metal's `TextureBuffer` type in the bind shape the census compiles for
|
||||
/// (`argument_buffers::used_texture`), where the census failed the case. Each committed case that
|
||||
/// holds one, on lavapipe, whose profile holds a texel-buffer heap array.
|
||||
#[test]
|
||||
fn the_census_compiles_a_texture_buffer_an_argument_buffer_holds() {
|
||||
use metal2vulkan_validation::authored_compile::compile_case;
|
||||
use metal2vulkan_validation::case::TextureType;
|
||||
if !llvm_as_available() {
|
||||
return;
|
||||
}
|
||||
let worker = {
|
||||
let program = bin_exe!("corpus-triage");
|
||||
let _ = Command::new(&program).arg("--help").output();
|
||||
CompileWorker::program(program)
|
||||
};
|
||||
let lavapipe = metal2vulkan_validation::worker::compile::WorkerDevice::new(
|
||||
metal2vulkan_validation::engine::load_description("lavapipe").unwrap(),
|
||||
metal2vulkan::device::DevicePolicy::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let holding = CorpusStore::new(metal2vulkan_validation::source::corpus_root())
|
||||
.read_all_cases()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|case| {
|
||||
case.argument_buffer_textures
|
||||
.iter()
|
||||
.any(|member| member.texture_type == TextureType::Buffer)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert!(
|
||||
!holding.is_empty(),
|
||||
"no committed case holds a texture buffer member"
|
||||
);
|
||||
for held in &holding {
|
||||
let (scratch, case) = corpus_with_templates(&held.name);
|
||||
let cells = compile_case(scratch.path(), &worker, &case, &[&lavapipe]);
|
||||
assert_eq!(cells.len(), 1, "{}", case.name);
|
||||
assert_eq!(
|
||||
cells[0].outcome,
|
||||
Ok(CellOutcome::Compiled),
|
||||
"{}: {cells:?}",
|
||||
case.name
|
||||
);
|
||||
assert_eq!(cells[0].compiles, 1, "{}", case.name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user