darksylinc / betsy

Betsy GPU compressor
Other
314 stars 18 forks source link

Make the BC3 shaders compatible with GLSL ES version 310 #12

Open nanley opened 2 years ago

nanley commented 2 years ago

This is based on a collection of changes I had to make when I tried to compile these shaders in gles31 apps. Please let me know what you think.

darksylinc commented 2 years ago
  1. Could you do #define const instead? I prefer if const stays, rather than being removed. It's a very useful keyword that improves readability and maintenance
  2. @reduz thoughts? Originally betsy was written to maximize Vulkan compatibility so that it can be ported to Godot (that mostly reduces to declaring #version 450 on top though), but goals have changed a little. AFAIK this PR needs GLES 3.1 (not 3.0) due to the need for Compute Shader support.
nanley commented 1 year ago

Updated const.

WRT to Vulkan compatibility, we shouldn't need to change the version directive right? AFAICT, GL_KHR_vulkan_glsl is compatible with #version 310 es.

One downside I've noticed with the PR's usage of rg32 and rgba16 (https://github.com/darksylinc/betsy/pull/12/commits/c2f0e029a526527c60a7bdf6bffe98652f37f5e3) is that it'd require a Vulkan app to set VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT during image creation. This could have a negative performance impact with some Vulkan drivers. One solution is to update the stitch shader to use rgba16. However, that would impact a number of other shaders outside of the BC3 scope.