vrend: workaround non-conformant sampler view pattern
Works around a rendering artifact in clients that are presumed to be relying on implementation-defined behavior when sampling the alpha channel of imported textures without one. Do the simplest thing and pass the implementation-defined behavior decision to the native host driver.
Signed-off-by: Ryan Neph ryanneph@google.com
This is the particular bug for which this workaround is desired: https://github.com/ValveSoftware/steam-for-linux/issues/10546
On ChromeOS with virgl as the OpenGL driver, host-side triggers a GL_INVALID_OPERATION
upon creating a glTextureView()
as explained in the following log output:
texture view created for EGL-backed texture sampler (format: PIPE_FORMAT_B8G8R8X8_UNORM; view: PIPE_FORMAT_B8G8R8A8_UNORM)
...
[2024-02-28T00:18:18.750352240+00:00 DEBUG rutabaga_gfx::virgl_renderer] ERROR: GL_INVALID_OPERATION in glTextureView(internalformat GL_RGBA8 not compatible with origtexture GL_RGB8)
[2024-02-28T00:18:18.750407276+00:00 DEBUG rutabaga_gfx::virgl_renderer] vrend_check_no_error: context error reported 6 "Composite Threa" Unknown 1282
[2024-02-28T00:18:18.750421562+00:00 DEBUG rutabaga_gfx::virgl_renderer] context 6 failed to dispatch CREATE_OBJECT: 22
[2024-02-28T00:18:18.750432055+00:00 DEBUG rutabaga_gfx::virgl_renderer] vrend_decode_ctx_submit_cmd: context error reported 6 "Composite Threa" Illegal command buffer 394753
[2024-02-28T00:18:18.750443958+00:00 DEBUG devices::virtio::gpu] Some(CmdSubmit3d) -> ErrRutabaga(ComponentError(22))
Merge request reports
Activity
added bugfix label
assigned to @ryanneph
I spent some quality time with the OpenGL 4.6 specification and I've clarified the following points:
- 8.4.4.4 Final Expansion to RGBA (pertaining to
glTexImage*D()
upload andglReadPixels()
download) (page 203)Each group is converted to a group of 4 elements as follows: if a group does not contain an A element, then A is added and set to one for integer components or 1.0 for floating-point components
- 15.2.1 Texture Access (pertaining to texture lookup from fragment shader) (page 490)
- Table 15.1: for "Texture Base Internal Format" ==
RGB
: pre-swizzled lookup produces(Rt, Gt, Bt, 1)
- Table 15.1: for "Texture Base Internal Format" ==
So it sounds like sampling the alpha component from a texture with internalformat
GL_RGB8
is well-defined and returns1.0
.Perhaps the observed sampler view
PIPE_FORMAT_B8G8R8A8_UNORM
on aPIPE_FORMAT_B8G8R8X8_UNORM
resource is Gallium's indication of the client's intention to do this, although it does seem odd. I'm not entirely sure ifVIRGL_CCMD_CREATE_OBJECT
corresponds 1:1 with a client's ownglTextureView()
, or if there is some implicit machinery in Gallium to generate a guest-side call to virgl'spipe_context::create_sampler_view()
.More-so, there may also be a non-default swizzle parameter applied by the client, that flows into vrend in the
VIRGL_CCMD_CREATE_OBJECT
containingVIRGL_OBJECT_SAMPLER_VIEW
that brings us tovrend_create_sampler_view()
where the texture view is created.All that is to say that I'm not sure if this issue is due to client's non-conformant behavior, or if it is just a strange client pattern that virgl mishandles until now. Either way, I think this MR should still be merged, and the client still seems to do some odd things (given that it broke on other platforms as well).
Thanks for the review. I'll move it to the merge queue now.
- 8.4.4.4 Final Expansion to RGBA (pertaining to
assigned to @marge-bot and unassigned @ryanneph
mentioned in commit ryanneph/virglrenderer@7627db82
added 1 commit
- 7627db82 - vrend: workaround non-conformant sampler view pattern
assigned to @ryanneph and unassigned @marge-bot
I couldn't merge this branch: CI failed! See pipeline https://gitlab.freedesktop.org/virgl/virglrenderer/-/pipelines/1120283.
Here is the Gantt chart for the referred pipeline, I hope it helps
(tip: click on the "Pan" button on the top right bar):more info
This message was generated by the ci_post_gantt.py script, which is running on a server at Collabora.
assigned to @marge-bot and unassigned @ryanneph
assigned to @ryanneph and unassigned @marge-bot
I couldn't merge this branch: CI failed! See pipeline https://gitlab.freedesktop.org/virgl/virglrenderer/-/pipelines/1120283.
Here is the Gantt chart for the referred pipeline, I hope it helps
(tip: click on the "Pan" button on the top right bar):more info
This message was generated by the ci_post_gantt.py script, which is running on a server at Collabora.
- Resolved by Ryan Neph
CI appears to be broken while pulling the latest mesa tarball:
+ curl -s -I https://s3.freedesktop.org/artifacts/mesa/mesa/1094474/mesa-x86_64-default-debugoptimized.tar.zst HTTP/2 404 date: Tue, 05 Mar 2024 19:44:28 GMT content-type: application/xml content-length: 229 x-amz-request-id: tx00000c37fee6979fe4004-0065e7761c-71f18c-fdo-opa-dc accept-ranges: bytes x-envoy-upstream-service-time: 2 x-envoy-decorator-operation: rook-ceph-rgw-fdo-opa-dc.rook-ceph.svc.cluster.local:80/* strict-transport-security: max-age=15724800; includeSubDomains access-control-allow-origin: * access-control-allow-methods: GET,HEAD,OPTIONS access-control-allow-headers: DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type access-control-max-age: 1728000 + curl https://s3.freedesktop.org/artifacts/mesa/mesa/1094474/mesa-x86_64-default-debugoptimized.tar.zst -o - + tar -xv --zstd % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 229 100 229 0 0 1280 0 --:--:-- --:--:-- --:--:-- 1286 zstd: /*stdin*\: unsupported format tar: Child returned status 1 tar: Error is not recoverable: exiting now
The request
404
s, while the same artifact was available yesterday when I first ran the pipeline: https://gitlab.freedesktop.org/virgl/virglrenderer/-/pipelines/1119406/@tintou Are we aware of some planned expiration for the mesa pipeline artifacts (e.g. 1 month). This one (https://gitlab.freedesktop.org/mesa/mesa/-/pipelines/1094474) was uploaded almost exactly 1 month ago from yesterday...
Edited by Ryan Neph
assigned to @marge-bot and unassigned @ryanneph
mentioned in commit ryanneph/virglrenderer@d9c002fa