Files
metal2vulkan/src
Anees Iqbal b8fcc4cd44 Let only sampling decide a texture's binding class
AIR declares each texture argument's access, and reflection reports a write-capable
one as a storage image at `STORAGE_TEXTURE_BINDING_BASE + n`, which is where a
consumer writes its descriptor. The emitter chose the binding class from what the
BODY does instead, and a size query counted as a sampled-image use. So a
`texture2d<float, write>` whose body only calls `get_width()` bound at
`TEXTURE_BINDING_BASE + n`: the consumer wrote its descriptor somewhere the shader
does not read.

Only sampling can decide this -- `OpSampledImage` is what requires `Sampled` 1.
Everything else AIR does to a texture has a form for either class: `read_texture`
is `OpImageRead` on a storage image and `OpImageFetch` on a sampled one, size and
sample-count queries have an opcode each, `get_num_mip_levels` folds to one level
on a storage image, and `is_null_texture` folds to a constant.

The rule took two pieces before, and the gap was between them: `texture_dims`
skips the read and query uses of a texture the body WRITES, and
`storage_texel_read_operands` restored the ones a texel read had otherwise
disqualified. A texture AIR declares write-capable but the body never writes fell
through both. `sampled_binding_required_operands` replaces the pair with the one
question that matters, and `storage_texel_read_operands` is gone.

`air.gather_*` is not in the set, preserving what this classification has always
done: a gathered AND written texture would need one descriptor to be both
`Sampled` 1 and `Sampled` 2, the read-write-with-format case `write_texture_dims`
documents as out of scope, and adding it converts those shaders into a
write-lowering failure instead of resolving anything. I tried it: one corpus
module regressed that way. Whether a gathered storage image reaches a correct
lowering is unaudited and stated as such.

Verified over 2880 corpus sources: bytes identical, reflection identical, failure
count unchanged at 204. The gap needs a texture AIR declares writable that the
body never writes, which no corpus shader does.

New `native_write_declared_texture_binds_as_storage_even_if_the_body_only_queries_it`
checks the module against the binding reflection reports, and is verified as a
detector. `native_kernel_helper_wrapped_write_texture_query_resolves_loaded_image`
was pinning the old behavior with an incidental `OpImageQuerySizeLod` assertion;
its subject is that the query resolves to the wrapped texture, so it now expects
the LOD-less form a storage image takes.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-09-01 00:17:30 +03:00
..
2026-08-20 04:11:23 +03:00
2026-07-22 13:15:24 +03:00
2026-07-22 13:15:24 +03:00