Merge pull request #6279 from hypermoist/fix/mesh-draw-short-of-a-primitive

fix(agc): a mesh draw shorter than one primitive draws nothing
This commit is contained in:
Adrià authored and GitHub committed 2026-10-18 23:57:36 +02:00
commit 07377573f4
2 files changed
+14 -2

No files matched your search

@@ -812,7 +812,7 @@ std::array<std::uint32_t, 4> MeshIndexBufferDescriptor(const Pm4::DrawParameters
MeshArgumentRules MeshArgumentRulesFor(const Context& context, const ShaderRecompiler::MeshConfiguration& mesh, std::uint32_t indexCount) {
const auto inputSize = mesh.inputPrimitive == 1 ? 1u : mesh.inputPrimitive == 2 ? 2u : 3u;
const auto step = mesh.inputPrimitive == 5 || mesh.inputPrimitive == 6 ? 1u : inputSize;
Require(mesh.primitivesPerGroup != 0, "mesh draw contains no complete primitive");
Require(mesh.primitivesPerGroup != 0, "mesh pipeline groups no primitive (zero primitives per group)");
return {indexCount, inputSize, step, mesh.primitivesPerGroup, context.meshLimits.maxMeshWorkGroupCount[0], context.meshLimits.maxMeshWorkGroupCount[1], context.meshLimits.maxMeshWorkGroupTotalCount};
}
@@ -1083,8 +1083,12 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
Require(context.meshShader, "device does not support mesh shaders");
const auto& mesh = *state.stages.mesh;
const auto inputSize = mesh.inputPrimitive == 1 ? 1u : mesh.inputPrimitive == 2 ? 2u : 3u;
Require(draw.indexCount >= inputSize && mesh.primitivesPerGroup != 0, "mesh draw contains no complete primitive");
Require(mesh.primitivesPerGroup != 0, "mesh pipeline groups no primitive (zero primitives per group)");
Require(((state.stages.registerValue >> 19u) & 3u) == 0 || !draw.indexed, "indexed fast-launch draws are unsupported");
if (args == nullptr && draw.indexCount < inputSize) {
inputs.nothing = true;
return inputs;
}
if (args == nullptr) {
const auto step = mesh.inputPrimitive == 5 || mesh.inputPrimitive == 6 ? 1u : inputSize;
const auto primitives = (draw.indexCount - inputSize) / step + 1u;
@@ -386,6 +386,14 @@ int main() {
}
Require(fastLaunchIndexedRefused, "an indexed fast-launch draw was drawn");
for (const bool indexed : {true, false}) {
ClearPixels();
DrawMesh(device, {SmallSubgroup, {indexed ? reinterpret_cast<std::uintptr_t>(Indices.data()) : 0u, 2u, indexed ? 2u : 0u, 1, 0, indexed}, VertexBufferDescriptor(indexed ? Scrambled.data() : Ordered.data(), static_cast<std::uint32_t>(Ordered.size()))});
for (std::uint32_t triangle = 0; triangle < Triangles; ++triangle) {
Require(PixelIs(CellPixel(triangle), Background), std::string(indexed ? "indexed" : "non-indexed") + " triangle-list draw of two vertices drew triangle " + std::to_string(triangle) + ", pixel " + PixelText(CellPixel(triangle)));
}
}
ClearPixels();
auto lineSubgroup = FastLaunchSubgroup;
lineSubgroup.maxPrimitives = 2u;