mesa: move variable declaration out of loop to fix MSVC build