Skip to content

Commit

Permalink
Merge pull request #2227 from elizagamedev/exv/essl1-uint-bool-hack
Browse files Browse the repository at this point in the history
Workaround for generating bool uniforms in ESSL1
  • Loading branch information
HansKristian-Work authored Nov 16, 2023
2 parents 4818f7e + bf05920 commit 42aac91
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15051,7 +15051,12 @@ string CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const Bitset
{
auto &execution = get_entry_point();

if (flags.get(DecorationRelaxedPrecision))
if (type.basetype == SPIRType::UInt && is_legacy_es())
{
// HACK: This is a bool. See comment in type_to_glsl().
qual += "lowp ";
}
else if (flags.get(DecorationRelaxedPrecision))
{
bool implied_fmediump = type.basetype == SPIRType::Float &&
options.fragment.default_float_precision == Options::Mediump &&
Expand Down Expand Up @@ -15585,7 +15590,11 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id)
if (type.basetype == SPIRType::UInt && is_legacy())
{
if (options.es)
SPIRV_CROSS_THROW("Unsigned integers are not supported on legacy ESSL.");
// HACK: spirv-cross changes bools into uints and generates code which compares them to
// zero. Input code will have already been validated as not to have contained any uints,
// so any remaining uints must in fact be bools. However, simply returning "bool" here
// will result in invalid code. Instead, return an int.
return backend.basic_int_type;
else
require_extension_internal("GL_EXT_gpu_shader4");
}
Expand Down

0 comments on commit 42aac91

Please sign in to comment.