Retract every descriptor the translator invented and nothing read
Two passes synthesize a resource with no Metal argument behind it, purely so an AIR value has a legal SPIR-V type. `air.get_read_sampler()` gets an `OpTypeSampler` because AIR threads a sampler pointer into the sampler-less `texture.read(coord)`; `air.get_null_texture_*()` gets an `OpTypeImage` because a function-constant-gated optional attachment still has to yield a handle. Either value can end up consumed by nothing -- a phi that folds away, an `air.is_null_texture` that becomes a constant -- and the descriptor then demands a resource the shader never reads, which reflection cannot report because no Metal argument corresponds to it. `cae8971` retracted the sampler. The rule was written over one named variable, so the identical null-texture case kept shipping. It is now stated once, over `Ctx::placeholder_descriptor_vars`: a third synthesized placeholder is covered by registering it rather than by copying the pass. The four sites that create a synthesized descriptor -- read sampler, null image, implicit imageblock plane, custom fragment imageblock plane -- had four copies of the same create-variable / decorate / add-to-interface block. They now share `Ctx::descriptor_variable`, and the two placeholder callers go through `Ctx::placeholder_descriptor`, which is what registers them for retraction. Choosing the binding stays with each caller, since the ABI band is what actually differs between them. Measured over 2880 corpus sources: module-declared bindings reflection omits went 4 -> 1, and exactly 3 modules changed bytes -- each dropping one OpTypeImage, one OpTypePointer, one OpVariable, its two descriptor decorations, and the unconsumed OpLoad. spirv-val passes on all three. The remaining 1 is a placeholder image the module genuinely reads, which needs reporting rather than retracting. New authored fixture in `tests/reflection_covers_declared_bindings.rs`: a kernel that asks `air.is_null_texture` about a placeholder and does nothing else with it. Verified as a detector -- it fails at the parent commit, where the module declares a texture binding reflection does not report. `native_get_null_texture_models_unmodeled_placeholder` asserted that binding exists. Its shader only stored the handle into an alloca nothing reads, which is now the retraction case, so it moves to a kernel that queries the placeholder's width -- a placeholder something DOES read keeps its descriptor -- and its band claim is now checked against every Binding decoration rather than a substring. Reflection output is byte-identical on all 2880 sources, so no REFLECTION_VERSION bump: this removes a binding reflection never reported. Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test -p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
This commit is contained in:
1 parent
42a7998514
commit
eaaf85abb0
6 files changed
+178
-75
No files matched your search
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- A descriptor the translator synthesizes only to type an AIR value is retracted whenever nothing
|
||||
consumes that value. This already covered `air.get_read_sampler()`; it now covers
|
||||
`air.get_null_texture_*()` too, so a shader that merely asks whether an optional attachment is
|
||||
bound no longer demands a texture descriptor it never reads. The rule is stated once, over the
|
||||
set of synthesized placeholders, rather than per variable.
|
||||
|
||||
### Added
|
||||
|
||||
- Reflection schema v32: `ShaderReflection::bindings` reports each resource exactly once. A fragment
|
||||
|
||||
@@ -835,20 +835,22 @@ attributes #3 = { convergent nounwind memory(argmem: write) }
|
||||
|
||||
#[test]
|
||||
fn native_get_null_texture_models_unmodeled_placeholder() {
|
||||
// `air.get_null_texture_2d()` yields a synthesized image in the texture descriptor band. Even a
|
||||
// kernel that only stores the opaque handle must remain valid, and the translator-owned resource
|
||||
// must not escape into sampler/color-input bindings.
|
||||
// `air.get_null_texture_2d()` yields a synthesized image in the texture descriptor band. A
|
||||
// kernel that reads through the placeholder keeps that descriptor, and the translator-owned
|
||||
// resource must not escape into sampler/color-input bindings. The opposite case -- a
|
||||
// placeholder nothing consumes, whose descriptor is retracted -- is
|
||||
// `tests/reflection_covers_declared_bindings.rs`.
|
||||
let ll = r#"
|
||||
define void @k(ptr addrspace(1) %out) {
|
||||
entry:
|
||||
%slot = alloca ptr addrspace(1), align 8
|
||||
%tex = call ptr addrspace(1) @air.get_null_texture_2d()
|
||||
store ptr addrspace(1) %tex, ptr %slot, align 8
|
||||
store i32 0, ptr addrspace(1) %out, align 4
|
||||
%width = call i32 @air.get_width_texture_2d(ptr addrspace(1) %tex, i32 0)
|
||||
store i32 %width, ptr addrspace(1) %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr addrspace(1) @air.get_null_texture_2d()
|
||||
declare i32 @air.get_width_texture_2d(ptr addrspace(1), i32)
|
||||
|
||||
!air.kernel = !{!0}
|
||||
!0 = !{ptr @k, !1, !2}
|
||||
@@ -866,6 +868,25 @@ declare ptr addrspace(1) @air.get_null_texture_2d()
|
||||
let asm = disassemble(&spv).expect("disassemble");
|
||||
assert!(asm.contains("OpFunction"), "{asm}");
|
||||
assert!(asm.contains("Binding 32"), "{asm}");
|
||||
for line in asm.lines() {
|
||||
let Some(binding) = line
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.split_first()
|
||||
.and_then(|(head, rest)| (*head == "OpDecorate").then_some(rest))
|
||||
.and_then(|rest| match rest {
|
||||
[_, "Binding", value] => value.parse::<u32>().ok(),
|
||||
_ => None,
|
||||
})
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
assert!(
|
||||
!crate::reflect::SAMPLER_BINDING_RANGE.contains(binding)
|
||||
&& !crate::reflect::COLOR_INPUT_BINDING_RANGE.contains(binding),
|
||||
"the translator-owned placeholder must stay in the texture band; got:\n{asm}"
|
||||
);
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(tmp);
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -369,6 +369,10 @@ struct Ctx {
|
||||
/// lazily-created default sampler variable id, for `air.get_read_sampler()` (a sampler-less
|
||||
/// `texture.read` still passes a sampler operand AIR-side; we synthesize one valid sampler).
|
||||
default_sampler_var: Option<Word>,
|
||||
/// Descriptor variables the translator invented to give an AIR value a legal SPIR-V type, with
|
||||
/// no Metal argument behind them. Retracted when unconsumed; see
|
||||
/// [`stage_input::drop_unconsumed_placeholder_descriptor_loads`].
|
||||
placeholder_descriptor_vars: HashSet<Word>,
|
||||
/// Loaded sampler value ids with an exact static or pipeline-provided state.
|
||||
sampler_states: HashMap<Word, StaticSamplerState>,
|
||||
/// Direct loads of runtime sampler bindings that were given pipeline state.
|
||||
@@ -459,6 +463,7 @@ impl Ctx {
|
||||
specialized_runtime_sampler_values: HashSet::new(),
|
||||
ambiguous_sampler_states: HashSet::new(),
|
||||
default_null_image_vars: HashMap::new(),
|
||||
placeholder_descriptor_vars: HashSet::new(),
|
||||
implicit_imageblock_vars: HashMap::new(),
|
||||
fragment_imageblock_vars: HashMap::new(),
|
||||
uses_fragment_imageblock: false,
|
||||
@@ -2662,9 +2667,10 @@ pub(crate) fn transform_with_options_and_sidecar(
|
||||
// sealing synthesized before global liveness runs.
|
||||
decorate_ptr_access_chain_base_strides(&mut ctx);
|
||||
ctx.module.types_global_values.append(&mut ctx.new_globals);
|
||||
// `air.get_read_sampler()` needed a real sampler descriptor to type its result; if nothing ever
|
||||
// consumed that value, retract the synthesis before liveness runs so the descriptor goes too.
|
||||
stage_input::drop_unconsumed_default_sampler_loads(&mut ctx);
|
||||
// `air.get_read_sampler()` and `air.get_null_texture_*()` each needed a real descriptor to type
|
||||
// their result; where nothing ever consumed that value, retract the synthesis before liveness
|
||||
// runs so the descriptor goes too.
|
||||
stage_input::drop_unconsumed_placeholder_descriptor_loads(&mut ctx);
|
||||
// The closures above are the last of this boundary's instruction changes, and any of them can
|
||||
// delete a variable's last use. Re-establish global liveness against the finished bodies before
|
||||
// the collection that would otherwise root a stranded variable at its own interface entry.
|
||||
|
||||
@@ -30,6 +30,40 @@ impl Ctx {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create one module-scope `UniformConstant` descriptor variable pointing at `pointee_ty`,
|
||||
/// decorate it at `binding` in the descriptor layout's set, and put it on the entry interface.
|
||||
///
|
||||
/// Every descriptor the passes synthesize goes through here, so the four of them cannot drift
|
||||
/// apart on how a resource variable is created, bound, and reached from the entry point.
|
||||
/// Choosing the binding stays with each caller, because the ABI band a synthesized descriptor
|
||||
/// belongs to is what distinguishes them.
|
||||
pub(in crate::passes) fn descriptor_variable(
|
||||
&mut self,
|
||||
pointee_ty: Word,
|
||||
binding: u32,
|
||||
) -> Word {
|
||||
let set = self.descriptor_layout.set;
|
||||
let pointer_ty = self.ty_ptr(StorageClass::UniformConstant, pointee_ty);
|
||||
let var = self.module.fresh_id();
|
||||
self.new_globals.push(Instruction::new(
|
||||
Op::Variable,
|
||||
Some(pointer_ty),
|
||||
Some(var),
|
||||
vec![Operand::StorageClass(StorageClass::UniformConstant)],
|
||||
));
|
||||
decorate_binding(&mut self.module, var, set, binding);
|
||||
self.interface_buffer_var(var);
|
||||
var
|
||||
}
|
||||
|
||||
/// Record a descriptor the translator invented purely to give an AIR value a legal SPIR-V type,
|
||||
/// with no Metal argument behind it. See [`drop_unconsumed_placeholder_descriptor_loads`].
|
||||
fn placeholder_descriptor(&mut self, pointee_ty: Word, binding: u32) -> Word {
|
||||
let var = self.descriptor_variable(pointee_ty, binding);
|
||||
self.placeholder_descriptor_vars.insert(var);
|
||||
var
|
||||
}
|
||||
|
||||
/// Lazily create a default sampler resource variable for `air.get_read_sampler()`. Metal's
|
||||
/// `texture.read(coord)` is sampler-less, but AIR still threads a sampler pointer (from
|
||||
/// `air.get_read_sampler`) into the read intrinsic, where our `lower_read` ignores it. To keep the
|
||||
@@ -44,16 +78,7 @@ impl Ctx {
|
||||
let binding = allocate_static_sampler_binding(&self.module, layout)
|
||||
.ok_or_else(|| "no free sampler binding for synthesized read sampler".to_string())?;
|
||||
let sty = self.ty_sampler();
|
||||
let pptr = self.ty_ptr(StorageClass::UniformConstant, sty);
|
||||
let var = self.module.fresh_id();
|
||||
self.new_globals.push(Instruction::new(
|
||||
Op::Variable,
|
||||
Some(pptr),
|
||||
Some(var),
|
||||
vec![Operand::StorageClass(StorageClass::UniformConstant)],
|
||||
));
|
||||
decorate_binding(&mut self.module, var, layout.set, binding);
|
||||
self.interface_buffer_var(var);
|
||||
let var = self.placeholder_descriptor(sty, binding);
|
||||
self.default_sampler_var = Some(var);
|
||||
Ok(var)
|
||||
}
|
||||
@@ -76,16 +101,7 @@ impl Ctx {
|
||||
let binding = allocate_default_texture_binding(&self.module, layout)
|
||||
.ok_or_else(|| "no free texture binding for synthesized null image".to_string())?;
|
||||
let img_ty = self.ty_image(dim, arrayed, ImageComp::Float);
|
||||
let pptr = self.ty_ptr(StorageClass::UniformConstant, img_ty);
|
||||
let var = self.module.fresh_id();
|
||||
self.new_globals.push(Instruction::new(
|
||||
Op::Variable,
|
||||
Some(pptr),
|
||||
Some(var),
|
||||
vec![Operand::StorageClass(StorageClass::UniformConstant)],
|
||||
));
|
||||
decorate_binding(&mut self.module, var, layout.set, binding);
|
||||
self.interface_buffer_var(var);
|
||||
let var = self.placeholder_descriptor(img_ty, binding);
|
||||
self.default_null_image_vars.insert((dim, arrayed), var);
|
||||
Ok(var)
|
||||
}
|
||||
@@ -123,16 +139,7 @@ impl Ctx {
|
||||
)
|
||||
})?;
|
||||
let image_ty = self.ty_storage_image(Dim::Dim2D, true, format, comp);
|
||||
let pointer_ty = self.ty_ptr(StorageClass::UniformConstant, image_ty);
|
||||
let var = self.module.fresh_id();
|
||||
self.new_globals.push(Instruction::new(
|
||||
Op::Variable,
|
||||
Some(pointer_ty),
|
||||
Some(var),
|
||||
vec![Operand::StorageClass(StorageClass::UniformConstant)],
|
||||
));
|
||||
decorate_binding(&mut self.module, var, layout.set, binding);
|
||||
self.interface_buffer_var(var);
|
||||
let var = self.descriptor_variable(image_ty, binding);
|
||||
self.implicit_imageblock_vars
|
||||
.insert((attachment, data_rate), (var, image_ty, format));
|
||||
Ok((var, image_ty))
|
||||
@@ -168,25 +175,15 @@ impl Ctx {
|
||||
vec![Operand::Capability(capability)],
|
||||
));
|
||||
}
|
||||
let image_ty =
|
||||
self.ty_storage_image(Dim::Dim2D, false, format.image_format, format.component);
|
||||
let pointer_ty = self.ty_ptr(StorageClass::UniformConstant, image_ty);
|
||||
let var = self.module.fresh_id();
|
||||
self.new_globals.push(Instruction::new(
|
||||
Op::Variable,
|
||||
Some(pointer_ty),
|
||||
Some(var),
|
||||
vec![Operand::StorageClass(StorageClass::UniformConstant)],
|
||||
));
|
||||
let layout = self.descriptor_layout;
|
||||
let binding = layout.fragment_imageblock_binding(master_member)
|
||||
let binding = self.descriptor_layout.fragment_imageblock_binding(master_member)
|
||||
.ok_or_else(|| {
|
||||
format!(
|
||||
"fragment imageblock master member {master_member} exceeds the descriptor ABI band"
|
||||
)
|
||||
})?;
|
||||
decorate_binding(&mut self.module, var, layout.set, binding);
|
||||
self.interface_buffer_var(var);
|
||||
let image_ty =
|
||||
self.ty_storage_image(Dim::Dim2D, false, format.image_format, format.component);
|
||||
let var = self.descriptor_variable(image_ty, binding);
|
||||
self.fragment_imageblock_vars
|
||||
.insert(master_member, (var, image_ty));
|
||||
Ok((var, image_ty))
|
||||
@@ -368,30 +365,39 @@ fn decorate_layout_recursive(ctx: &mut Ctx, ty: Word, defs: &HashMap<Word, Instr
|
||||
}
|
||||
}
|
||||
|
||||
/// Retire the synthesized default read sampler when nothing consumed the value it was created to
|
||||
/// Retire a descriptor the translator invented when nothing consumed the value it was created to
|
||||
/// type.
|
||||
///
|
||||
/// `Ctx::default_read_sampler` materializes one `OpTypeSampler` descriptor so that
|
||||
/// `air.get_read_sampler()` has a well-typed result: Metal's `texture.read(coord)` is sampler-less,
|
||||
/// AIR threads a sampler pointer into the read intrinsic anyway, and `lower_read` discards it. When
|
||||
/// every load of that variable feeds nothing, the descriptor is a demand on the consumer for a
|
||||
/// sampler the shader never samples with — and reflection cannot report it, because no Metal
|
||||
/// argument corresponds to it, so a consumer building its layout from `ShaderReflection` omits the
|
||||
/// binding the module declares.
|
||||
/// Two passes synthesize a resource with no Metal argument behind it, purely so an AIR value has a
|
||||
/// legal SPIR-V type. `Ctx::default_read_sampler` materializes an `OpTypeSampler` because AIR
|
||||
/// threads a sampler pointer into `texture.read(coord)`, which in Metal is sampler-less, and
|
||||
/// `lower_read` discards it. `Ctx::default_null_image_of` materializes an `OpTypeImage` for
|
||||
/// `air.get_null_texture_*()`, whose result a phi may merge away or `air.is_null_texture` may fold
|
||||
/// to a constant. When every load of such a variable feeds nothing, the descriptor is a demand on
|
||||
/// the consumer for a resource the shader never uses — and reflection cannot report it, because no
|
||||
/// Metal argument corresponds to it, so a consumer building its layout from `ShaderReflection`
|
||||
/// omits a binding the module declares.
|
||||
///
|
||||
/// This is not general dead-code elimination, which this pipeline deliberately does not do: it
|
||||
/// retracts one descriptor the translator itself synthesized, and only where the synthesis turned
|
||||
/// out to be unnecessary. A load whose result IS consumed keeps the sampler. Dropping the loads is
|
||||
/// enough — `drop_unreferenced_global_variables` then removes the variable, its decorations, and its
|
||||
/// entry-point interface entry.
|
||||
pub(in crate::passes) fn drop_unconsumed_default_sampler_loads(ctx: &mut Ctx) {
|
||||
let Some(sampler) = ctx.default_sampler_var else {
|
||||
/// retracts descriptors the translator itself synthesized, and only where the synthesis turned out
|
||||
/// to be unnecessary. A load whose result IS consumed keeps its descriptor. Dropping the loads is
|
||||
/// enough — `drop_unreferenced_global_variables` then removes each variable, its decorations, and
|
||||
/// its entry-point interface entry.
|
||||
///
|
||||
/// The rule is stated over `Ctx::placeholder_descriptor_vars` rather than over one named variable,
|
||||
/// so a third synthesized placeholder is covered by registering it, not by copying this pass.
|
||||
pub(in crate::passes) fn drop_unconsumed_placeholder_descriptor_loads(ctx: &mut Ctx) {
|
||||
if ctx.placeholder_descriptor_vars.is_empty() {
|
||||
return;
|
||||
};
|
||||
}
|
||||
let referenced = crate::passes::module_cleanup::function_referenced_ids(&ctx.module);
|
||||
let placeholders = std::mem::take(&mut ctx.placeholder_descriptor_vars);
|
||||
let unconsumed_load = |instruction: &Instruction| {
|
||||
instruction.class.opcode == Op::Load
|
||||
&& instruction.operands.first() == Some(&Operand::IdRef(sampler))
|
||||
&& matches!(
|
||||
instruction.operands.first(),
|
||||
Some(Operand::IdRef(variable)) if placeholders.contains(variable)
|
||||
)
|
||||
&& instruction
|
||||
.result_id
|
||||
.is_some_and(|id| !referenced.contains(&id))
|
||||
@@ -403,6 +409,7 @@ pub(in crate::passes) fn drop_unconsumed_default_sampler_loads(ctx: &mut Ctx) {
|
||||
.retain(|instruction| !unconsumed_load(instruction));
|
||||
}
|
||||
}
|
||||
ctx.placeholder_descriptor_vars = placeholders;
|
||||
}
|
||||
|
||||
pub(in crate::passes) fn layout_ty_size_align(
|
||||
|
||||
@@ -24,7 +24,8 @@ use layout::*;
|
||||
// Layout size/align helpers are reused by the lower pass to decorate OpPtrAccessChain base
|
||||
// pointer types with ArrayStride (a sibling-module of interface cannot reach `layout` directly).
|
||||
pub(in crate::passes) use layout::{
|
||||
decorate_block_struct, drop_unconsumed_default_sampler_loads, layout_ty_size_align, round_up,
|
||||
decorate_block_struct, drop_unconsumed_placeholder_descriptor_loads, layout_ty_size_align,
|
||||
round_up,
|
||||
};
|
||||
|
||||
mod air_layout;
|
||||
|
||||
@@ -10,14 +10,16 @@
|
||||
//! the shader never touches, and dropping the binding would silently renumber a consumer's
|
||||
//! expectations. Only the other direction is a defect, and that is what this file checks.
|
||||
//!
|
||||
//! The first case below is where the direction went wrong. `air.get_read_sampler()` exists because
|
||||
//! AIR threads a sampler pointer into `texture.read(coord)`, which in Metal is sampler-less; the
|
||||
//! interface pass materialized a real `OpTypeSampler` descriptor so the value would be typed, and
|
||||
//! `lower_read` then discarded the value. No Metal argument corresponds to that sampler, so
|
||||
//! Two of the cases below are where the direction went wrong, and they are the same defect twice.
|
||||
//! `air.get_read_sampler()` exists because AIR threads a sampler pointer into `texture.read(coord)`,
|
||||
//! which in Metal is sampler-less; `air.get_null_texture_*()` exists because a function-constant
|
||||
//! gated optional attachment still has to yield a texture handle. The interface pass materialized a
|
||||
//! real `OpTypeSampler` / `OpTypeImage` descriptor so each value would be typed, and the consumer of
|
||||
//! that value then turned out to be nothing at all. No Metal argument corresponds to either, so
|
||||
//! reflection had nothing to report — while the module demanded the binding anyway.
|
||||
|
||||
use metal2vulkan::passes::{Stage, TransformOptions};
|
||||
use metal2vulkan::reflect::{ShaderReflection, SAMPLER_BINDING_RANGE};
|
||||
use metal2vulkan::reflect::{ShaderReflection, SAMPLER_BINDING_RANGE, TEXTURE_BINDING_RANGE};
|
||||
use metal2vulkan::translate_sanitized_native_reflected;
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -170,6 +172,64 @@ fn a_sampler_less_texture_read_needs_no_sampler_descriptor() {
|
||||
assert_eq!(declared.len(), 2, "one sampled and one write texture");
|
||||
}
|
||||
|
||||
/// A kernel that asks whether a placeholder texture is bound, and does nothing else with it.
|
||||
///
|
||||
/// `air.get_null_texture_2d()` is what a function-constant-gated optional attachment resolves to
|
||||
/// once the constants are folded off. `air.is_null_texture` on that handle folds to a constant, so
|
||||
/// the image the interface pass materialized to type the handle ends up with no consumer -- and a
|
||||
/// descriptor with no consumer is a demand on the pipeline layout for a texture the shader never
|
||||
/// reads. `native_get_null_texture_models_unmodeled_placeholder` is the other half: a placeholder
|
||||
/// something DOES read keeps its descriptor.
|
||||
const UNCONSUMED_NULL_TEXTURE: &str = r#"target triple = "spirv-unknown-vulkan1.2"
|
||||
|
||||
define void @probe_optional_attachment(ptr addrspace(1) %out) {
|
||||
entry:
|
||||
%tex = call ptr addrspace(1) @air.get_null_texture_2d()
|
||||
%isnull = call i1 @air.is_null_texture_2d(ptr addrspace(1) %tex)
|
||||
%flag = zext i1 %isnull to i32
|
||||
store i32 %flag, ptr addrspace(1) %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr addrspace(1) @air.get_null_texture_2d()
|
||||
declare i1 @air.is_null_texture_2d(ptr addrspace(1))
|
||||
|
||||
!air.kernel = !{!0}
|
||||
!0 = !{ptr @probe_optional_attachment, !1, !2}
|
||||
!1 = !{}
|
||||
!2 = !{!3}
|
||||
!3 = !{i32 0, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 0, i32 1, !"air.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"}
|
||||
"#;
|
||||
|
||||
#[test]
|
||||
fn a_placeholder_texture_nothing_reads_needs_no_texture_descriptor() {
|
||||
let (spirv, reflection) = translate_sanitized_native_reflected(
|
||||
UNCONSUMED_NULL_TEXTURE,
|
||||
Stage::Kernel,
|
||||
&scratch("unconsumed_null_texture"),
|
||||
TransformOptions::default(),
|
||||
)
|
||||
.expect("the optional-attachment probe translates");
|
||||
|
||||
let declared =
|
||||
assert_reflection_covers_declarations("the optional-attachment probe", &spirv, &reflection);
|
||||
let textures = declared
|
||||
.iter()
|
||||
.filter(|(_, binding)| TEXTURE_BINDING_RANGE.contains(*binding))
|
||||
.collect::<Vec<_>>();
|
||||
assert!(
|
||||
textures.is_empty(),
|
||||
"the kernel only asks whether the placeholder is bound and never reads it, so it must not \
|
||||
demand a texture descriptor; it declares {textures:?}"
|
||||
);
|
||||
let text = metal2vulkan::disassemble(&spirv).expect("disassemble");
|
||||
assert!(
|
||||
!text.contains("OpTypeImage"),
|
||||
"no image is bound, so no image type should survive:\n{text}"
|
||||
);
|
||||
assert_eq!(declared.len(), 1, "the one output buffer");
|
||||
}
|
||||
|
||||
/// A fragment shader that reads its render target back through the implicit imageblock.
|
||||
///
|
||||
/// `air.load.implicit_imageblock.*` is detected from the module body, not from the stage, and the
|
||||
|
||||
Reference in new issue
Block a user