mesa: add stencil_func() helper