Repository navigation
feat(agc): implement 8 and 8_8 srgb image loads through unorm views - #866
Conversation
573137d to
f0edd07
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Measured on the HW oracle (gfx1035, image_load ... dmask:0xf unorm, linear 256x1 T#, all 256 codes of 8_SRGB and 8_8_SRGB).
-
The decode isn't the correctly rounded f32 EOTF on hardware. The hardware returns the EOTF rounded to nearest-even at 8 significant bits (bf16 precision, low 16 bits always zero): 0 mismatches against
bf16_rne(eotf(c))across all 256 codes (136 against truncation).SrgbToLinear(SpirvImageEmitter.cpp:330) differs in 254 of 256 codes, e.g.:code HW PR table 1 0x399f00000x399f22b4128 0x3e5d00000x3e5d0a89254 0x3f7e00000x3f7db8deFix: build the table as the EOTF rounded to nearest-even to the top 16 bits, and make
Linear()inImageSrgbLoad.cpp:112the same so the test pins the hardware values. -
TechnicalDebt.md:194says the console's rounding is "not documented or measured": it now is, on gfx1035 (RDNA2), not on the PS5's gfx1013. Please say that, and note that devices that sample R8_SRGB/R8G8_SRGB natively return full f32 precision, so they don't match the hardware either. -
@boykopovar: this adds a per-image specialization field (
ResourceSpecialization::Image::srgbDecode,ResourceMaterializer.cpp:170) and a new reason to pad bindless table entries with zeros (ResourceMaterializer.cpp:390). #639 replaces resource specialization with runtime descriptors: do you want this in now, or should it wait for #639 and be done there?
NVIDIA 610.62 cannot sample R8G8_SRGB, and lavapipe can sample neither it nor R8_SRGB, so an 8_8 sRGB T# made an image the device does not support: creating it crashes the NVIDIA driver and lavapipe loads zeros. The device's format support is read once. An 8 or 8_8 sRGB texture the device cannot sample is created and viewed as R8_UNORM or R8G8_UNORM, and SpirvTarget::srgbDecodeFormats makes the materializer mark the image, so image loads map every channel through a 256-entry table of the sRGB EOTF rounded to nearest even at bf16 precision, which is what RDNA2 (gfx1035) returns; both channels of 8_8 are sRGB, and DST_SEL 0 and 1 map to themselves. Samples and gathers of such an image throw, and its bindless table entries are unmapped like converted formats. APS5_SRGB_SHADER_DECODE=1 takes this path on every device. Shader disk cache entries and keys carry the mark: cache format version 7.
f0edd07 to
9185271
Compare
|
Thanks for measuring all 256 codes of both formats on gfx1035, that's exactly what the table was missing. I've pushed 9185271. The table is now the sRGB EOTF rounded to nearest even at bf16 precision, which matches every one of your 256 measured codes. One small correction on native decode, though. On this RTX 3080, native R8_SRGB loads also come back with the low 16 bits zero: they equal the bf16 values in 227 of 256 codes and are one bf16 step off in the other 29, so they aren't full f32 either. That's why the TechnicalDebt line says native decode "need not match gfx1035" instead of calling it full f32. I couldn't check R8G8_SRGB, because no device here samples it natively. The branch is also rebased on current main, with shader cache DetailsNVIDIA GeForce RTX 3080 Laptop GPU (driver 610.62), native R8_SRGB view,
Neither this NVIDIA driver nor lavapipe reports |
adriadam10
left a comment
There was a problem hiding this comment.
Re-checked 9185271 merged onto current main: the table matches the HW oracle (gfx1035) bit for bit on all 256 codes of 8_SRGB and 8_8_SRGB. ctest is green on RADV, and the PR's tests pass on CI's lavapipe. Changing one table entry makes agc_driver_image_srgb_load fail on both. The per-image srgbDecode field follows the existing conversionFormat pattern, so per boykopovar's note that changes on main don't get in #639's way, I'm merging this.
What
GFX10
8_SRGBand8_8_SRGBmap to optional Vulkan formats: NVIDIA 610.62 lacks R8G8_SRGB and crashes creating such a texture; lavapipe lacks R8_SRGB too and loads zeros.SrgbDecodeFormatsmarks per device which of the two lackSAMPLED_IMAGE; their textures and views use R8_UNORM or R8G8_UNORM, andSpirvTarget::srgbDecodeFormatstakes the mark to shaders, the disk cache (FormatVersion7) and serialized requests (version 9).gfx10_format_table.py).APS5_SRGB_SHADER_DECODE=1forces the path.FormatVersion.Tested
main0d3c1ee: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 387/387 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_image_srgb_load: every code of 8_8_SRGB and 8_SRGB in four swizzle and dmask cases, uploaded or written by UNORMimage_stores, bit-exact against the bf16-rounded EOTF, plus two refusals; fails onmain(NVIDIA crash, lavapipe zeros) and with an f32 table.agc_driver_graphics,agc_shader_disk_cacheandagc_shader_memorycover the mapping, key and serialization (no build onmain).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)