Avoid polyfilling the half2float branch of functions on web and when using ANGLE.
They are still needed when using desktop GL and when using Adreno 3xx devices
This commit is contained in:
parent
bb70f3af74
commit
07c3544697
4 changed files with 31 additions and 11 deletions
|
@ -168,6 +168,10 @@ void ShaderGLES3::_build_variant_code(StringBuilder &builder, uint32_t p_variant
|
||||||
builder.append("#version 300 es\n");
|
builder.append("#version 300 es\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GLES3::Config::get_singleton()->polyfill_half2float) {
|
||||||
|
builder.append("#define USE_HALF2FLOAT\n");
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < specialization_count; i++) {
|
for (int i = 0; i < specialization_count; i++) {
|
||||||
if (p_specialization & (uint64_t(1) << uint64_t(i))) {
|
if (p_specialization & (uint64_t(1) << uint64_t(i))) {
|
||||||
builder.append("#define " + String(specializations[i].name) + "\n");
|
builder.append("#define " + String(specializations[i].name) + "\n");
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
|
|
||||||
// Compatibility renames. These are exposed with the "godot_" prefix
|
// Compatibility renames. These are exposed with the "godot_" prefix
|
||||||
// to work around two distinct Adreno bugs:
|
// to work around two distinct Adreno bugs:
|
||||||
// 1. Some Adreno devices expose ES310 functions in ES300 shaders.
|
// 1. Some Adreno devices expose ES310 functions in ES300 shaders.
|
||||||
// Internally, we must use the "godot_" prefix, but user shaders
|
// Internally, we must use the "godot_" prefix, but user shaders
|
||||||
// will be mapped automatically.
|
// will be mapped automatically.
|
||||||
// 2. Adreno 3XX devices have poor implementations of the other packing
|
// 2. Adreno 3XX devices have poor implementations of the other packing
|
||||||
// functions, so we just use our own everywhere to keep it simple.
|
// functions, so we just use our own there to keep it simple.
|
||||||
|
|
||||||
|
#ifdef USE_HALF2FLOAT
|
||||||
// Floating point pack/unpack functions are part of the GLSL ES 300 specification used by web and mobile.
|
// Floating point pack/unpack functions are part of the GLSL ES 300 specification used by web and mobile.
|
||||||
|
// It appears to be safe to expose these on mobile, but when running through ANGLE this appears to break.
|
||||||
uint float2half(uint f) {
|
uint float2half(uint f) {
|
||||||
uint e = f & uint(0x7f800000);
|
uint e = f & uint(0x7f800000);
|
||||||
if (e <= uint(0x38000000)) {
|
if (e <= uint(0x38000000)) {
|
||||||
|
@ -52,6 +53,17 @@ vec2 godot_unpackSnorm2x16(uint p) {
|
||||||
return clamp((v - 32767.0) * vec2(0.00003051851), vec2(-1.0), vec2(1.0));
|
return clamp((v - 32767.0) * vec2(0.00003051851), vec2(-1.0), vec2(1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define packHalf2x16 godot_packHalf2x16
|
||||||
|
#define unpackHalf2x16 godot_unpackHalf2x16
|
||||||
|
#define packUnorm2x16 godot_packUnorm2x16
|
||||||
|
#define unpackUnorm2x16 godot_unpackUnorm2x16
|
||||||
|
#define packSnorm2x16 godot_packSnorm2x16
|
||||||
|
#define unpackSnorm2x16 godot_unpackSnorm2x16
|
||||||
|
|
||||||
|
#endif // USE_HALF2FLOAT
|
||||||
|
|
||||||
|
// Always expose these as they are ES310 functions and not available in ES300 or GLSL 330.
|
||||||
|
|
||||||
uint godot_packUnorm4x8(vec4 v) {
|
uint godot_packUnorm4x8(vec4 v) {
|
||||||
uvec4 uv = uvec4(round(clamp(v, vec4(0.0), vec4(1.0)) * 255.0));
|
uvec4 uv = uvec4(round(clamp(v, vec4(0.0), vec4(1.0)) * 255.0));
|
||||||
return uv.x | (uv.y << uint(8)) | (uv.z << uint(16)) | (uv.w << uint(24));
|
return uv.x | (uv.y << uint(8)) | (uv.z << uint(16)) | (uv.w << uint(24));
|
||||||
|
@ -75,9 +87,3 @@ vec4 godot_unpackSnorm4x8(uint p) {
|
||||||
#define unpackUnorm4x8 godot_unpackUnorm4x8
|
#define unpackUnorm4x8 godot_unpackUnorm4x8
|
||||||
#define packSnorm4x8 godot_packSnorm4x8
|
#define packSnorm4x8 godot_packSnorm4x8
|
||||||
#define unpackSnorm4x8 godot_unpackSnorm4x8
|
#define unpackSnorm4x8 godot_unpackSnorm4x8
|
||||||
#define packHalf2x16 godot_packHalf2x16
|
|
||||||
#define unpackHalf2x16 godot_unpackHalf2x16
|
|
||||||
#define packUnorm2x16 godot_packUnorm2x16
|
|
||||||
#define unpackUnorm2x16 godot_unpackUnorm2x16
|
|
||||||
#define packSnorm2x16 godot_packSnorm2x16
|
|
||||||
#define unpackSnorm2x16 godot_unpackSnorm2x16
|
|
||||||
|
|
|
@ -231,6 +231,13 @@ Config::Config() {
|
||||||
} else if (rendering_device_name == "PowerVR Rogue GE8320") {
|
} else if (rendering_device_name == "PowerVR Rogue GE8320") {
|
||||||
disable_transform_feedback_shader_cache = true;
|
disable_transform_feedback_shader_cache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3_angle") {
|
||||||
|
polyfill_half2float = false;
|
||||||
|
}
|
||||||
|
#ifdef WEB_ENABLED
|
||||||
|
polyfill_half2float = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {
|
Config::~Config() {
|
||||||
|
|
|
@ -95,13 +95,16 @@ public:
|
||||||
bool multiview_supported = false;
|
bool multiview_supported = false;
|
||||||
bool external_texture_supported = false;
|
bool external_texture_supported = false;
|
||||||
|
|
||||||
// Adreno 3XX compatibility
|
// Adreno 3XX compatibility.
|
||||||
bool disable_particles_workaround = false; // set to 'true' to disable 'GPUParticles'
|
bool disable_particles_workaround = false; // Set to 'true' to disable 'GPUParticles'.
|
||||||
bool flip_xy_workaround = false;
|
bool flip_xy_workaround = false;
|
||||||
|
|
||||||
// PowerVR GE 8320 workaround
|
// PowerVR GE 8320 workaround.
|
||||||
bool disable_transform_feedback_shader_cache = false;
|
bool disable_transform_feedback_shader_cache = false;
|
||||||
|
|
||||||
|
// ANGLE shader workaround.
|
||||||
|
bool polyfill_half2float = true;
|
||||||
|
|
||||||
#ifdef ANDROID_ENABLED
|
#ifdef ANDROID_ENABLED
|
||||||
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC eglFramebufferTextureMultiviewOVR = nullptr;
|
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC eglFramebufferTextureMultiviewOVR = nullptr;
|
||||||
PFNGLTEXSTORAGE3DMULTISAMPLEPROC eglTexStorage3DMultisample = nullptr;
|
PFNGLTEXSTORAGE3DMULTISAMPLEPROC eglTexStorage3DMultisample = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue