thatcosmonaut / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
3 stars 3 forks source link

Shader format versioning #198

Closed TheSpydog closed 3 weeks ago

TheSpydog commented 3 weeks ago

Right now there's no way for the client or backend to distinguish between DXBC compatible with D3D11 versus DXBC compatible with D3D12. The simplest solution would be to split the DXBC shader format enum into two -- SM5_0 and SM5_1.

However, this begs the question, should other shader formats have some sort of versioning system too? For instance, there are many shader models supported by DXIL, many of which may not be supported on all D3D12 drivers. There's no way to tell the GPU API "this DXIL I'm using relies on the latest and greatest features, so do a driver compatibility check first". Same with SPIR-V and Metal.

Probably the only sane way to deal with this is to have a single supported version / shader model, and document it. We're not exposing extremely low-level features, mesh shaders, or raytracing, which is what more recent shader versions tend to deal with anyway.

flibitijibibo commented 3 weeks ago

I thought the same thing - we can maybe do a Uint32 and use versioning from the respective formats - I think SPIR-V has a version constant in the header, not sure about Metal or DXBC/DXIL.

flibitijibibo commented 3 weeks ago

Working on this in shadercross now.

flibitijibibo commented 3 weeks ago

ShaderCross now supports compiling to DXIL - personally, I'm in favor of removing the DXBC support in D3D12 because...

The only real downside is that shadercross has to include libdxcompiler/libdxil, but people technically had to do that with d3dcompiler anyway...

Akaricchi commented 3 weeks ago

If d3d12 support requires me to to ship dxcompiler and whatever other library, I think I'll just pass on it. I'm happy to have Vulkan, and d3d11 for legacy intel iGPUs i guess.

spirv2dxil

Did you mean dxil-spirv?

flibitijibibo commented 3 weeks ago

Yeah, I think I smooshed dxil-spirv and spirv2nir, which is totally unrelated but I managed to mix it up anyway!

flibitijibibo commented 3 weeks ago

Follow-up for DXIL: https://github.com/thatcosmonaut/SDL/issues/200

Any necessary versioning can be done with SDL_Properties after this is implemented.