One commit of the 247 on development-fast (720ef1ce9a..9f46fdf80d), squashed at the user's request. Translator: - Tessellation on a device without tessellationShader: Metal's tessellator emitted as SPIR-V, a one-workgroup scan placing each patch's triangles in Metal's order, and the post-tessellation function as a plain vertex stage (EmulatedTessellationDraws; SEMANTICS 1739, ARTIFACT_FORMAT 419). - [[primitive_id]] on a device without geometry or tessellation shaders, as a flat varying the vertex function writes; indexed lists, lines and points drawn de-indexed (RuntimeGap::PrimitiveIdIndices). - Fragment functions of more colors than the device draws at once, compiled in color groups (PrecisionNote::ColorAttachmentGroups). - Object functions' threadgroup memory from the render encoder; a kernel's mesh draws from an indirect command buffer; mesh payload sizing. - The Vulkan 1.2 floor profile (vk12-floor) and the gates it needs; Metal 27.0.1 answers as the M3 Max. - Overflow tests in the runtime-built modules by the product's high word (NVIDIA's compiler fails the division form), guarded crate-wide by tests::owned_divisions. Runtime: - Color-group passes replayed per group over twin depth/stencil; snapshot and copy-back cost cuts. - Command buffers finish on the queue waiter that saw them; the waiter holds no device handle, so a program's drop after its wait is the device's last. - Every object an encoder was handed held until its command buffer completes; deallocator order and announcements. - Driver defects recorded and announced: ANV counts a visibility sample once per color output (visibility-count-per-color); MoltenVK fails pending work when memory that held a device-address buffer is freed, so freed memory waits for the work in flight (host-deallocator-delayed). - RenderCommandEncoder::set_object_threadgroup_memory_length; Visibility::counting(). Validation: mesh tooling (object, mesh and ICB-mesh cases on both executors), the authoring census closed, the queue storm judged in Metal's unit, load-robust exits and indirect-census bounds, and the golden hashes, printouts, fixture inventory and authored compile census blessed. Docs: FAST-PATHS.md trimmed to a ledger of what is true now; API.md's catalogue and accepted differences, REFUSALS.md and METAL-COVERAGE.md current. Verified on development-fast before the squash: the full suites on the RTX 5080, RTX 3090, RX 7900 XTX, Radeon 780M, Iris Xe, lavapipe and the M3 (MoltenVK and the Metal oracle), lint in every configuration, rustdoc, doc tests, packaging and public case qualification; the timing and teardown lanes x5 on every venue; the authoring-capability census 16656/16656 with 0 unresolved, the vk12-floor translation census at 6139 translated with the slowest row 794 ms and peak 126 MiB. The tree is development-fast's at 9f46fdf80d.
51 lines
2.2 KiB
Metal
51 lines
2.2 KiB
Metal
// Owned fixture: the functions the metal2vulkan-runtime crate's examples run
|
|
// (runtime/examples/). Written from scratch for them; `scripts/regen-air-fixtures/
|
|
// regen-air-fixtures.sh --dir examples` compiles it. No translator sweep reads this directory.
|
|
#include <metal_stdlib>
|
|
using namespace metal;
|
|
|
|
// compute_dispatch, indirect_command_buffer and adopted_buffer:
|
|
// output[i] = input[i] * scale + i.
|
|
kernel void scale_and_offset(device const float *input [[buffer(0)]],
|
|
device float *output [[buffer(1)]],
|
|
constant float &scale [[buffer(2)]],
|
|
uint index [[thread_position_in_grid]]) {
|
|
output[index] = input[index] * scale + float(index);
|
|
}
|
|
|
|
// render_to_texture: a triangle list whose vertices read their positions and colors from two
|
|
// buffers by vertex ID; each triangle takes one color.
|
|
struct Varyings {
|
|
float4 position [[position]];
|
|
float4 color [[flat]];
|
|
};
|
|
|
|
vertex Varyings colored_vertex(device const float2 *positions [[buffer(0)]],
|
|
device const float4 *colors [[buffer(1)]],
|
|
uint id [[vertex_id]]) {
|
|
Varyings out;
|
|
out.position = float4(positions[id], 0.0, 1.0);
|
|
out.color = colors[id];
|
|
return out;
|
|
}
|
|
|
|
fragment float4 colored_fragment(Varyings in [[stage_in]]) {
|
|
return in.color;
|
|
}
|
|
|
|
// The runtime's made_at_creation lane: each pixel of the triangles sampled from a half texture
|
|
// through a linear filter, at its position over an 8-texel side.
|
|
fragment half4 sampled_fragment(Varyings in [[stage_in]],
|
|
texture2d<half> source [[texture(0)]]) {
|
|
constexpr sampler linear(filter::linear);
|
|
return source.sample(linear, in.position.xy / 8.0);
|
|
}
|
|
|
|
// heap_placement: each texel of `source` with its color channels inverted, into `destination`.
|
|
kernel void invert_texels(texture2d<float, access::read> source [[texture(0)]],
|
|
texture2d<float, access::write> destination [[texture(1)]],
|
|
uint2 position [[thread_position_in_grid]]) {
|
|
float4 texel = source.read(position);
|
|
destination.write(float4(1.0 - texel.rgb, texel.a), position);
|
|
}
|