Bug 106480 - A2B10G10R10_SNORM vertex attribute doesn't work.
Summary: A2B10G10R10_SNORM vertex attribute doesn't work.
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/radeon (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Reported: 2018-05-11 22:30 UTC by maister
Modified: 2018-05-14 17:40 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

Pipelines (7.40 KB, application/json)
2018-05-11 22:30 UTC, maister
RenderDoc Capture (2.91 MB, application/octet-stream)
2018-05-11 22:31 UTC, maister
renderdoc screenshot of non-reproduction (422.98 KB, image/png)
2018-05-12 00:10 UTC, Bas Nieuwenhuizen

Note You need to log in before you can comment on or make changes to this bug.
Description maister 2018-05-11 22:30:22 UTC
Created attachment 139506 [details]

I've tried to make a vertex shader which uses this vertex format, but it does not work on RADV.

It is almost as if the format becomes SNORM for RGB, but UNORM for A.

To replay the pipeline creation:
git clone git://github.com/Themaister/Fossilize
cd Fossilize
git submodule update --init
mkdir build
cd build
cmake ..
make -j16
./cli/fossilize-replay /tmp/pipelines.json --filter-graphics 0

The ISA generated in VK_AMD_shader_info is:
.cli/fossilize-disasm /tmp/pipelines.json --target amd --graphics-pipeline 0 --stage vert

	s_load_dwordx4 s[8:11], s[2:3], 0x0                 ; C00A0201 00000000
	s_load_dwordx4 s[0:3], s[2:3], 0x10                 ; C00A0001 00000010
	v_add_u32_e32 v0, vcc, s4, v0                       ; 32000004
	v_mov_b32_e32 v6, 1.0                               ; 7E0C02F2
	v_mov_b32_e32 v7, 0                                 ; 7E0E0280
	s_waitcnt lgkmcnt(0)                                ; BF8C007F
	buffer_load_format_xy v[4:5], v0, s[8:11], 0 idxen  ; E0042000 80020400
	buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 idxen ; E00C2000 80000000
	s_waitcnt vmcnt(1)                                  ; BF8C0F71
	exp pos0 v4, v5, v7, v6 done                        ; C40008CF 06070504
	s_waitcnt vmcnt(0)                                  ; BF8C0F70
	exp param0 v0, v1, v2, v3                           ; C400020F 03020100
	s_endpgm                                            ; BF810000
Comment 1 maister 2018-05-11 22:31:46 UTC
Created attachment 139507 [details]
RenderDoc Capture

The color for each component should be 1.0 for one corner, and interpolate towards 0.0 in the other corners, but A is ~0.8 where it should be 0.0, and ~0.6 where it should be 1.0. This seems very similar to SNORM being treated as UNORM.
Comment 2 maister 2018-05-11 22:37:29 UTC
If you're using RenderDoc to inspect the vertex buffer input, you need the very latest as there was a bug with A2BGR10_SNORM.

The vertex buffer input is (1.0, -1.0, -1.0, -1.0), (-1.0, 1.0, -1.0, -1.0) and so on, for each component, frag shader does vColor * 0.5 + 0.5, so expected output should land in [0, 1] range for each component.
Comment 3 Bas Nieuwenhuizen 2018-05-12 00:10:46 UTC
Created attachment 139509 [details]
renderdoc screenshot of non-reproduction

Not sure I can reproduce. If I go to the corner A is a proper 1.0 here (and 0.0 in the other corners).
Comment 4 Roland Scheidegger 2018-05-12 00:37:23 UTC
radeonsi has workarounds for all signed r10g10b10a2 formats for everything before Vega (except Stoney Ridge), with the code explicitly saying the A2 is read as unsigned by the hw.
At a quick glance I don't see any such workarounds for radv, but I have zero idea about that driver.
Comment 5 maister 2018-05-12 09:53:34 UTC
Yes, I should clarify that this is RX470, so Polaris.
Comment 6 Bas Nieuwenhuizen 2018-05-12 11:05:11 UTC
That would explain, I tested on vega.
Comment 7 maister 2018-05-12 18:08:04 UTC
FWIW, this also affects UNIFORM_TEXEL_BUFFER.
Comment 8 Bas Nieuwenhuizen 2018-05-12 20:48:38 UTC
Yes, We'll likely "fix" that by not claiming support for R10G10B10A2 SNORM/SINT formats anymore since support is not required, and a fixup is not possible without significantly impacting perofrmance for apps that don't use it.

VK_FORMAT_A2B10G10R10_SNORM_PACK32 and VK_FORMAT_A2B10G10R10_SINT_PACK32 are not required formats according to the vulkan spec, so we can reasonably disable those.
Comment 9 Bas Nieuwenhuizen 2018-05-12 22:00:06 UTC
This bug should be fixed by

Comment 10 maister 2018-05-12 22:31:45 UTC
That would match AMDVLK, it exposes A2BGR10_SNORM for vertex, but not UNIFORM_TEXEL_BUFFER.
Comment 11 maister 2018-05-13 10:00:08 UTC
The patches seem to have fixed the issue for me :)
Comment 12 Bas Nieuwenhuizen 2018-05-14 17:40:33 UTC
The fixes are in master now.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.