Instancing breaking because of DisableBatching tag

Avatar
  • updated
  • Unity's Fault

Hi,

First, thanks for the awesome plugin! I've been however running into an issue as soon as I render the same type of shape twice using immediate mode with Unity 2020.3.20f1 (maybe this version is not supported?).

I've been investigating using the C# debugger and the frame analyzer. Turns out that DrawMeshInstanced is added into the command buffer but is silently ignored and not visible in the frame analyzer.

Not sure why this happens, however it seems that removing

"DisableBatching" = "True"

from the shader solves my issue.

This is what my code looks like, if it has any importance:

using(Draw.Command(cam)) {
    Draw.LineGeometry = lineGeometry;
    Draw.ThicknessSpace = thicknessSpace;

    ResetCursor();

    while(NextEntry()) {
        Vector3 pos = location.Get(this);
        float radius = size.Get(this);
        Color c = color.Get(this);
        c.a *= m_alphaMultiplier;

        Draw.Color = c;
        Draw.Disc(pos, fw, radius);
    }
}

Same thing for Arc and Lines.

Kind regards,

- Nicolas

Reporting a bug? please specify Unity version:
2020.3.20f1
Reporting a bug? please specify Shapes version:
4.1.1
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator

hm, it seems like GPU instancing is somehow broken or disabled in your project. do you know of any settings that might cause it, or some obscure target platform?

Avatar
nicolas barbotin

Not that I'm aware of; target is Win64. I'm not sure of where Unity hides all of the different settings related to GPU instancing, the only setting I found is "Instancing Variants" which is set to "Strip Unused".

In any case, I've just tested the same project on my home laptop and it works perfectly fine with "DisableBatching"="True". But then again, my home laptop has Unity 2020.3.23f1 instead of 3.20f1, maybe that's the issue.

I'll update to 2020.3.23f1 on my work laptop on Monday and tell you if it fixed it.

Thank you,

- Nicolas

Avatar
nicolas barbotin

Hi Freya,

Sorry for the late reply. This problem keeps happening to me every now and then, however I found a way to work around it: it seems that deleting the "Library/ShaderCache" folder fixes the issue. Not sure what Unity is doing behind the scenes, but what I can say is that it has nothing to do with DisableBatching. Why would Unity silently ignore a draw call?

- Nicolas

Avatar
Freya Holmér creator
  • Unity's Fault

that's really bizarre! I've had multiple people report similar issues, it would be nice if deleting the cache would be the solution! here's hoping :)

glad it worked out!