pan/midgard: Use better heuristic for shader termination