🐛 Normalize a GL kernel's inputs as a vertex function's
The GL lowering makes each variant's metadata what `metal` writes, but it
read only a vertex or fragment entry point's inputs. A kernel's inputs kept
the generator's bare attribute name after air.location_index and had no
buffer address space. The kernel GL's renderer makes for a tessellated draw
has such an input ("attrib_0" at its argument 0). metal2vulkan refuses that
key, so the device refused the kernel's compute pipeline. The renderer's
buildPipelineState failed, and it drew the draw's vertices in software
(measured: macOS 27.0.1 arm64, a quad patch through a tessellation control
and evaluation shader, m3-max-30129).
For the guest: a GL kernel's inputs now follow the rules a vertex
function's do. The tessellated draw's kernel was still refused with these
rules alone (m3-max-30150): the name sits in its control point input's
field, which the next commit normalizes. gl_tests holds a kernel's inputs
through the rules.
This commit is contained in:
1 parent
42f95955e7
commit
94b38e7034
3 files changed
+54
-12
No files matched your search
@@ -472,8 +472,9 @@ bool normalizeNode(std::string &line, bool input, const std::string &type, const
|
||||
NodeText n;
|
||||
if (!splitNode(line, n))
|
||||
return false;
|
||||
// A vertex input's attribute name, which the generator writes as a bare string after the
|
||||
// location's two operands, is not in the node `metal` writes.
|
||||
// An input's attribute name, which the generator writes as a bare string after the location's
|
||||
// two operands (a vertex function's vertex input, a kernel's input), is not in the node `metal`
|
||||
// writes.
|
||||
bool edited = false;
|
||||
for (size_t i = 0; input && i + 3 < n.ops.size(); i++) {
|
||||
std::string key, bare;
|
||||
@@ -627,7 +628,8 @@ bool RgfxGLNormalizeStageText(std::string &text, const RgfxGLSignature &signatur
|
||||
nodeLine.resize(n + 1, lines.size());
|
||||
nodeLine[n] = i;
|
||||
} else if (entryList == lines.size() &&
|
||||
(starts(line, "!air.vertex = ") || starts(line, "!air.fragment = "))) {
|
||||
(starts(line, "!air.vertex = ") || starts(line, "!air.fragment = ") ||
|
||||
starts(line, "!air.kernel = "))) {
|
||||
entryList = i;
|
||||
} else if (starts(line, "!air.version = ")) {
|
||||
versionList = i;
|
||||
|
||||
@@ -53,8 +53,13 @@
|
||||
* fetch, denormals), the first, and no air.compile.native_double_disable, which `metal` does
|
||||
* not write; llvm.module.flags holds the first flag of each name (the module's own limits,
|
||||
* 4096 buffers, not the builtins' 31);
|
||||
* - a vertex input's attribute name, a bare string after its air.location_index's two
|
||||
* operands, is dropped (the input keeps its air.arg_name, which holds the same name);
|
||||
* - an input's attribute name, a bare string after its air.location_index's two operands, is
|
||||
* dropped (the input keeps its air.arg_name, which holds the same name), in a vertex
|
||||
* function's inputs and a kernel's alike. The kernel the renderer makes for a tessellated
|
||||
* draw has one at its argument 0 ("attrib_0"): metal2vulkan refused that kernel's compute
|
||||
* pipeline ("UnknownKey"), and the renderer drew the draw's vertices in software (measured:
|
||||
* macOS 27.0.1 arm64, a quad patch through a tessellation control and evaluation shader,
|
||||
* m3-max-30129);
|
||||
* - a flat fragment input has no sampling key: `metal` writes [[flat]] as air.flat alone, and
|
||||
* the generator writes air.center before it;
|
||||
* - a buffer input has the air.address_space `metal` writes, its parameter's pointer's, and,
|
||||
@@ -108,12 +113,12 @@ struct RgfxGLSignature {
|
||||
|
||||
/// Makes `text`, a module as LLVM prints it, follow the rules above: the module's (no gld.*
|
||||
/// lists; one version, its language Metal's; its own compile options and module flags, once
|
||||
/// each), and those of the stage metadata of its vertex or fragment entry point where it has one:
|
||||
/// an integer user() varying's air.arg_type_name is the unsigned name, a vertex input has no
|
||||
/// bare attribute name, a flat fragment input no sampling key, and an output or input node
|
||||
/// without air.arg_type_name gets the name `signature` gives its value (an input's by its
|
||||
/// parameter index), and an air.arg_name where it has none. True where it changed `text`; `text`
|
||||
/// is unchanged otherwise.
|
||||
/// each), and those of the stage metadata of its vertex, fragment or kernel entry point where it
|
||||
/// has one: an integer user() varying's air.arg_type_name is the unsigned name, an input has no
|
||||
/// bare attribute name, a flat fragment input no sampling key, a buffer input its address space
|
||||
/// and pointee size, and an output or input node without air.arg_type_name gets the name
|
||||
/// `signature` gives its value (an input's by its parameter index), and an air.arg_name where it
|
||||
/// has none. True where it changed `text`; `text` is unchanged otherwise.
|
||||
bool RgfxGLNormalizeStageText(std::string &text, const RgfxGLSignature &signature);
|
||||
|
||||
/// The GL IR a renderer's pointer holds: the u32 length at `ir`, then that many bytes. Writes the
|
||||
|
||||
@@ -964,7 +964,8 @@ void test_stage_metadata_normalized()
|
||||
CHECK(RgfxGLNormalizeStageText(text, vertex));
|
||||
CHECK(text == kVertexNormalized);
|
||||
|
||||
// No vertex or fragment entry point: a kernel's module, or none at all.
|
||||
// A kernel's module whose one input node has no parameter index, which the input rules leave
|
||||
// as it is.
|
||||
const std::string kernel = "!air.kernel = !{!0}\n!0 = !{void ()* @__main, !1, !2}\n!1 = !{}\n!2 = "
|
||||
"!{!3}\n!3 = !{!\"air.depth\"}\n";
|
||||
text = kernel;
|
||||
@@ -972,6 +973,40 @@ void test_stage_metadata_normalized()
|
||||
// The module's rules hold for a kernel too: the generator's lists go.
|
||||
text = kernel + "!gld.plugin_info = !{!1}\n";
|
||||
CHECK(RgfxGLNormalizeStageText(text, vertex) && text == kernel);
|
||||
// So do the input rules: a kernel's input loses the bare attribute name after its location,
|
||||
// as the generator writes one in the kernel of a tessellated draw ("attrib_0" at its argument
|
||||
// 0, which metal2vulkan refuses), and its buffer gets the address space of its parameter's
|
||||
// pointer. Our own text: the inputs as `metal` writes a stage_in kernel's, the bare name added
|
||||
// and the buffer's address space taken out.
|
||||
{
|
||||
const std::string inputs = "!air.kernel = !{!0}\n"
|
||||
"!0 = !{void (<2 x float>, float addrspace(1)*, i32)* @__main, !1, !2}\n"
|
||||
"!1 = !{}\n"
|
||||
"!2 = !{!3, !4, !5}\n";
|
||||
const std::string thread = "!5 = !{i32 2, !\"air.thread_position_in_grid\", !\"air.arg_type_name\", "
|
||||
"!\"uint\", !\"air.arg_name\", !\"i\"}\n";
|
||||
const std::string generated =
|
||||
inputs +
|
||||
"!3 = !{i32 0, !\"air.stage_in\", !\"air.location_index\", i32 0, i32 1, !\"attrib_0\", "
|
||||
"!\"air.arg_type_name\", !\"float2\", !\"air.arg_name\", !\"attrib_0\"}\n"
|
||||
"!4 = !{i32 1, !\"air.buffer\", !\"air.location_index\", i32 0, i32 1, !\"air.read\", "
|
||||
"!\"air.arg_type_size\", i32 4, !\"air.arg_type_align_size\", i32 4, !\"air.arg_type_name\", "
|
||||
"!\"float\", !\"air.arg_name\", !\"b\"}\n" +
|
||||
thread;
|
||||
const std::string normalized =
|
||||
inputs +
|
||||
"!3 = !{i32 0, !\"air.stage_in\", !\"air.location_index\", i32 0, i32 1, "
|
||||
"!\"air.arg_type_name\", !\"float2\", !\"air.arg_name\", !\"attrib_0\"}\n"
|
||||
"!4 = !{i32 1, !\"air.buffer\", !\"air.location_index\", i32 0, i32 1, !\"air.read\", "
|
||||
"!\"air.address_space\", i32 1, !\"air.arg_type_size\", i32 4, !\"air.arg_type_align_size\", "
|
||||
"i32 4, !\"air.arg_type_name\", !\"float\", !\"air.arg_name\", !\"b\"}\n" +
|
||||
thread;
|
||||
RgfxGLSignature compute;
|
||||
compute.parameters = {"float2", "float", "uint"};
|
||||
text = generated;
|
||||
CHECK(RgfxGLNormalizeStageText(text, compute) && text == normalized);
|
||||
CHECK(!RgfxGLNormalizeStageText(text, compute) && text == normalized);
|
||||
}
|
||||
text = "";
|
||||
CHECK(!RgfxGLNormalizeStageText(text, vertex) && text.empty());
|
||||
// An entry node naming nodes the text lacks.
|
||||
|
||||
Reference in new issue
Block a user