Repository navigation
Read a color style's image once in the shaders, so SDL GPU's first frame no longer stalls (#301) - #343
Merged
Conversation
…ame no longer stalls (#301) SDL GPU can't index its images, so each image read in a shader is a case for every image a draw binds. getSDFColor read its image in each color type's branch: 17 reads, each 16 cases, up to three times a shader. lavapipe compiles that the first time it draws, and on Windows a first frame took about 16 s. getSDFColor now works out the image and where to read it for each type, then reads it in one place: one size query, one sample, and one row of four texels for the interpolated triangle and box. The drawing is the same on every backend, byte for byte. - The Direct3D 12 and SDL GPU tests draw every color type and compare it with Vulkan's drawing. - CI runs the whole-app tests on SDL GPU over lavapipe on Windows again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #301. SDL GPU took 20 to 40 s per whole-app test on Windows' lavapipe, about 1 s on Linux's. The CI step timed out, so it was dropped.
What was slow
SDL_BeginGPURenderPass. That is where lavapipe compiles the shaders, the first time it draws with them.switchwith a case for each of the 16 images a draw binds.getSDFColorread its image in each color type's branch: 17 reads in all.The fix
getSDFColor(sdf_color.slang, shared by every backend) now does it in two steps:FetchImageRow), for the interpolated triangle and box. The fourth texel is clamped to the image's width, so the triangle doesn't read past it.Results
gui_gpu_tests --graphics=sdlgpupasses in about 4 minutes on this machine. That machine runs the Direct3D 12 suite about as fast as the CI runner (51 s against 48 s).Tests
ColorTypesApp(gpu_draw_app.h) draws a shape of every color type. Six of them had no pixel test before:EveryColorTypeDrawsAsOnVulkancompares its frame with Vulkan's. It runs in:gui_d3d12_testsgui_sdlgpu_tests, for each driverExpectSameAsOnVulkan, is now shared with the existing draw test.gui_vulkan_tests,gui_d3d12_testsandgui_sdlgpu_testsgui_gpu_testson Vulkan, Direct3D 12 and SDL GPUgui_core_testsLeft