Files
reims-vgpu/tests/shaders/render_argwrite.metal
T
Anees Iqbal 9939485879 🐛 Declare a render encoder's useResources: to rt as compute's are
What the guest sees changes. Before, a render encoder's useResources: (each
form, with or without stages) never reached metal2vulkan-runtime: the platform
noted its textures and nothing else. So a draw whose vertex or fragment
function wrote a texture beyond its slots (through an argument buffer or a
resource ID) after a declared write of a texture with no storage element ran,
and Vulkan dropped the writes Metal makes. Now each resource it names but nil
is rt's use_resource with the declared usage, as the compute encoder's is (the
two share resource_usage and the declaration's notes, compute::declared). rt
keeps the resource until the command buffer retires and records nothing, and
such a draw is rt's Gap::StorageElement: it draws nothing, is counted under
rt-refused-gap, the process's first on a line of stderr, as the compute
encoder's dispatch is, and the process goes on. Declared textures over a buffer
in an image of their own now take rt's copies around the draws after them, and
a usage no Metal value is (0, or a bit past sample's) is Metal's refusal,
counted under rt-refused-metal, as on the compute side.

The texture notes stay: a tiled texture's take at the commit and a read
through the platform's own index are not retention. rt's keep of its own
buffer or texture until the command buffer retires is inside the platform, as
for every bound resource and the compute encoder's declarations; the guest's
objects go when core drops them, as before, so the order of releases the host
sees is unchanged.

Tests: a_draw_after_a_declared_write_of_a_texture_with_no_storage_element_
is_refused_on_vulkan, over a new fragment function, render_argwrite.metal,
whose metallib build.sh's two steps made on a Mac (metal 32023.922), with the
compute encoder's dispatch of tex_write as the oracle of which textures have
no storage element on the device. render_encoders_on_vulkan now counts a usage
of 8 as Metal's refusal.
2026-11-21 00:36:16 -08:00

13 lines
498 B
Metal

#include <metal_stdlib>
using namespace metal;
// A fragment function that reaches a texture beyond its slots: it writes
// (1, 0, 1, 1) to texel (0, 0) of the texture whose resource ID the argument
// buffer at fragment buffer 0 holds, and returns opaque green.
struct Written {
texture2d<float, access::write> t [[id(0)]];
};
fragment float4 render_argwrite(constant Written &w [[buffer(0)]]) {
w.t.write(float4(1.0, 0.0, 1.0, 1.0), uint2(0, 0));
return float4(0.0, 1.0, 0.0, 1.0);
}