Skip to content

nvk: Don't clobber vb0 after repeated blits

M Henning requested to merge mhenning/mesa:blit_fixes into main

If a program does two blits in a row, we internally do a sequence of operations that involves binding vb0.

Previously, the vb0 state after each operation would look something like:

operation cmd->state.gfx.vb0 hardware save->vb0
user user
nvk_meta_begin() user user user
BindVertexBuffers(internal0) internal0 internal0 user
nvk_meta_end() internal0 user
nvk_meta_begin() internal0 user internal0
BindVertexBuffers(internal1) internal1 internal1 internal0
nvk_meta_end() internal1 internal0

That is, CmdBindVertexBuffers() would update cmd->state.gfx.vb0, but nvk_meta_end() would not. This meant that the last operation would bind a driver-internal buffer instead of the original value that the user set.

This change fixes the issue by tracking cmd->state.gfx.vb0 in nvk_cmd_bind_vertex_buffer(), which both CmdBindVertexBuffers() and nvk_meta_end() call into.

After this commit, the state looks like:

operation cmd->state.gfx.vb0 hardware save->vb0
user user
nvk_meta_begin() user user user
BindVertexBuffers(internal0) internal0 internal0 user
nvk_meta_end() user user
nvk_meta_begin() user user user
BindVertexBuffers(internal1) internal1 internal1 user
nvk_meta_end() user user

To test this commit, build gtk4 commit 87b66de1, run:

GSK_RENDERER=vulkan gtk4-demo --run=image_scaling

then select trilinear filtering in the dropdown and check for rendering artifacts.

Fixes: e1c66501 ("nvk: Use vk_meta for CmdClearAttachments")

Edited by M Henning

Merge request reports