Open feliwir opened 3 years ago
OK this will take some time to review, a few comments:
.clang-format
, the final PR must not.Betsy was commissioned for Godot, thus the way the code was structured was to maximize easiness of integration into other projects, which is why the classes have abstracted GL code away. A key aspect we wish to conserve is that integration (aka copy paste into your own project) should be straightforward. As long as this aspect is preserved I'm cool with it. I wanted to go with Vulkan but time was limited and Vulkan initial setup is harder and we were on a tight budget; which is why we went for OpenGL (they both support GLSL anyway, and 95% of the project is GLSL code)
So to answer some questions:
gli::gl GL(gli::gl::PROFILE_GL33);
gli::gl::format const GLFormat = GL.translate(Texture.format(), Texture.swizzles());
gli::dx DX();
gli::dx::format const DXFormat = DX.translate(Texture.format(), Texture.swizzles());
(and so on for Vulkan)
GLI has the advantage that it can also translate to DirectX and Vulkan formats. As you probably know best yourself the KTX format does store the format parameters in OpenGL internal format specifiers. But e.g. DDS does use the internal DirectX format. So e.g. if we wanted to support DDS (which i definetly want to add aswell, since it's still the most common for compressed textures we need to be able to translate to that aswell. Another benefit of GLI is the mentioned Vulkan support, which it can translate to aswell. It looks like that:
Oh I see where it's going. More context:
PixelFormat
maps 1:1 to DXGI_FORMAT and VK_FORMAT, e.g. PFG_RGBA16_FLOAT
is DXGI_FORMAT_R32G32B32_FLOAT
and VK_FORMAT_R16G16B16A16_SFLOAT
. You can find the mappings already in Ogre's database which is where I grabbed from (Vulkan, D3D11). It has a lot more formats than what Betsy needs thoughIf we're going to use GLI to support Pre-DX10 headers then it makes sense (assuming GLI supports pre-DX10 dds). Otherwise, integrating a large library like GLI just for format conversion sounds overkill when it's only a large switch statement per backend.
- Another point i forgot: I compiled the shaders into the binary and did the preprocessing with cmake. So this should reduce the headache of requiring the shaders next to the binary and also reduce startup time, since no shader preprocessing & file io is performed.
OK that sounds very useful! As long as it can be toggled on/off at build time (both for development and for platforms where embedding the files into the exe can prove difficult)
This is more of a meta PR, asking for changes that make sense to you / you'd accept a PR for: