svga: sync resource content from backing resource before image upload
authorCharmaine Lee <charmainel@vmware.com>
Wed, 7 Jun 2023 20:49:28 +0000 (23:49 +0300)
committerMarge Bot <emma+marge@anholt.net>
Tue, 26 Sep 2023 21:38:01 +0000 (21:38 +0000)
commit25c771a77853141fcc220ae74b30492f8199709c
tree6b662cccedfcda5a701e78e8464ceca04c914ed9
parent83c76cceafb4d375cc9cc2cf043bc32e5577f244
svga: sync resource content from backing resource before image upload

When a backing resource is created for a render target view when the
same resource is currently bound to a shader resource view, the content
update back to the original resource happens when the associated render
target view is unbound. But state update only happens at clear or draw
time. So if TexSubImage happens after BindFrameBuffer and before Draw,
the original texture resource that is mapped to for subimage update
would not have been updated. As a matter of fact at the subsequent state
update at the next draw, the render target views will be updated, the
content from the previous backing resource will be propogated to the
original resource, hence overwriting the changes from the last TexSubImage.

To fix the problem, this patch validates the texture resource, updates
any pending changes from the backing resource before transfer map upload
occurs.

Fixes the rendering issue demonstrated from the fbo_texsubimage_update trace

Reviewed-by: Martin Krastev <krastevm@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25386>
src/gallium/drivers/svga/svga_pipe_draw.c
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_surface.h