therontarigo / nvcachetools

Extract and inspect compiled shaders for Nvidia GPUs from the shader cache
ISC License
25 stars 3 forks source link

Nvidia bin format changed #1

Open danilw opened 4 months ago

danilw commented 4 months ago

nvcachedec does not ecxtract *.nvuc from new Nvidia bin format.

On Nvidia drivers 550:

nvcachedec and everything else still works, but only for OpenGL shaders

For Vulkan shaders:


./nvcachedec nv_bin/*.toc objs

TOC Entry 00000
  zstd compressed
Object: Unknown object type

TOC Entry 00001
  zstd compressed
Object: Unknown object type

TOC Entry 00002
  zstd compressed
Object: Unknown object type

TOC Entry 00003
  zstd compressed
Object: Unknown object type

TOC Entry 00004
  zstd compressed
Object: Unknown object type

TOC Entry 00005
  zstd compressed
Object: Unknown object type

TOC Entry 00006
  zstd compressed
Object: Unknown object type

I added test nv_bin files as attachment - nv_bin.zip

Before, in 2023 I tested last time - nvcachedec was able to work/extract Vulkan files same as OpenGL.

therontarigo commented 4 months ago

Thanks, added the formats in this branch: https://github.com/therontarigo/nvcachetools/tree/driver550 - I'd like to get driver 550 working on my own machine and test the nvuc files with an updated nvdisasm before committing to master.

danilw commented 4 months ago

Thanks for update.

I tested your change - it works:

/nvcachedec nv_bin/*.toc objs

TOC Entry 00000
  zstd compressed
Object: 0x0250 ELF object

TOC Entry 00001
  zstd compressed
Object: NVDA NVVM NVuc binary

TOC Entry 00002
  zstd compressed
Object: NVDA NVVM NVuc binary

TOC Entry 00003
  zstd compressed
Object: NVDA NVVM NVuc binary

TOC Entry 00004
  zstd compressed
Object: NVDA NVVM NVuc binary

TOC Entry 00005
  zstd compressed
Object: NVDA NVVM NVuc binary

TOC Entry 00006
  zstd compressed
Object: NVDA NVVM NVuc binary

Processed 7 entries

Extracting sections from nvuc also works.

Using nvdisasm to read nvuc - also work:

/usr/local/cuda/bin/nvdisasm --binary SM89 objs/object00001.nvuc
cuVN: v1.0 nsec=7 arch=AMPERE chip=AMPERE/GA100 PIXEL driver=00000000 size=000034d0

...

Section UCODE
    .headerflags    @"EF_CUDA_64BIT_ADDRESS EF_CUDA_SM89 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM89)"

....

I updated related to this blog post Decompiling Nvidia shaders, and optimizing, and its github mirror - I added one screenshot from Nvidia 4060 (look black/white image with text) just Shadertoy new shader code - it look little different compare to previous screenshot from Maxwell GPU.

P.S. to test as Vulkan app I used my shadertoy-launcher and its created shader cache.