google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.75k stars 1.88k forks source link

DFG LUT uses widely unsupported RGB16F #875

Closed cleak closed 5 years ago

cleak commented 5 years ago

Describe the bug DFG lookup tables use RGB16F which is widely unsupported. This is generally fine for OpenGL, but Vulkan will refuse to create such textures. When running material_sandbox with Vulkan, this will trigger an assertion failure like:

FEngine (64 bits) created at 00000145CFDC6080 (threading is enabled)
FEngine resolved backend: Vulkan
Selected physical device 'GeForce GTX 1060' from 2 physical devices. (vendor 0x0x10de, device 0x0x1c20, api 0x0x40105f, driver 0x0x68c44000)
class utils::PostconditionPanic
in filament::Texture *filament::Texture::Builder::build(filament::Engine &):93
in file ..\..\filament\src\Texture.cpp
reason: Texture format 262184 not supported on this platform

To Reproduce Run material sandbox like:

samples\material_sandbox.exe --api=vulkan ..\..\assets\models\monkey\monkey.obj

Expected behavior material_sandbox should run.

Desktop (please complete the following information):

Additional context It looks like this is a recent problem resulting from #853. Previously DFG used RG16F which has good support.

romainguy commented 5 years ago

Thanks for the report. I must say I am flabbergasted as to why RG16F would be commonly supported but not RGB16F (edit: alignment I suppose, 32 bit vs 48 bit).

romainguy commented 5 years ago

@bejado @prideout It sounds like the TextureReshaper used for Metal would be a good solution here? We'd just have to use RGBA16F I think. If that format isn't widely supported either we'll have to use two DFG LUTs

romainguy commented 5 years ago

Actually is this format truly not supported or is that our driver being paranoid @prideout?

prideout commented 5 years ago

According to gpuinfo.org, only 16% of all implementations support this, so yeah I need to use our reshaping stuff and update the getVkFormat function.

romainguy commented 5 years ago

It's extremely convenient to use an RGB16F texture for the DFG LUT — especially as I keep working on a new sheen parameter for the standard material model — but it opens a few questions:

pixelflinger commented 5 years ago

@romainguy crazy idea, instead of using two RG16F samplers (b/c samplers are a limited resource), why not use a 3D texture? e.g. three R16F layers? or even two RG16F ones -- this way we don't pay the price when the 3d channel is not used (compared to RGBA16F). Now, granted, filament doesn't support 3D textures yet, but we really should and it wouldn't be too hard to add.

Another option would be to use a mip level -- it would have a lower resolution, but does it really matter?