Commit 9710c4e4 by Shahbaz Youssefi Committed by Commit Bot

Cleanup translator option checks

Use comparison with 0 for explicit conversion to bool. Bug: angleproject:3606 Change-Id: Ie0a76d7df829227c1376894535813b54e13491b4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2631689 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent cea86910
......@@ -177,7 +177,7 @@ void ResetExtensionBehavior(const ShBuiltInResources &resources,
}
if (resources.ARB_texture_rectangle)
{
if (compileOptions & SH_DISABLE_ARB_TEXTURE_RECTANGLE)
if ((compileOptions & SH_DISABLE_ARB_TEXTURE_RECTANGLE) != 0)
{
// Remove ARB_texture_rectangle so it can't be enabled by extension directives.
extBehavior.erase(TExtension::ARB_texture_rectangle);
......
......@@ -372,7 +372,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType,
new AtomicCounterFunctionHLSL((compileOptions & SH_FORCE_ATOMIC_VALUE_RESOLUTION) != 0);
unsigned int firstUniformRegister =
((compileOptions & SH_SKIP_D3D_CONSTANT_REGISTER_ZERO) != 0) ? 1u : 0u;
(compileOptions & SH_SKIP_D3D_CONSTANT_REGISTER_ZERO) != 0 ? 1u : 0u;
mResourcesHLSL = new ResourcesHLSL(mStructureHLSL, outputType, uniforms, firstUniformRegister);
if (mOutputType == SH_HLSL_3_0_OUTPUT)
......@@ -3204,7 +3204,7 @@ void OutputHLSL::outputTriplet(TInfoSinkBase &out,
void OutputHLSL::outputLineDirective(TInfoSinkBase &out, int line)
{
if ((mCompileOptions & SH_LINE_DIRECTIVES) && (line > 0))
if ((mCompileOptions & SH_LINE_DIRECTIVES) != 0 && line > 0)
{
out << "\n";
out << "#line " << line;
......
......@@ -2651,7 +2651,7 @@ TIntermDeclaration *TParseContext::parseSingleDeclaration(
const ImmutableString &identifier)
{
TType *type = new TType(publicType);
if ((mCompileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) &&
if ((mCompileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) != 0 &&
mDirectiveHandler.pragma().stdgl.invariantAll)
{
TQualifier qualifier = type->getQualifier();
......
......@@ -21,7 +21,7 @@ TranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec)
void TranslatorESSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
ShCompileOptions compileOptions)
{
if (compileOptions & SH_EMULATE_ATAN2_FLOAT_FUNCTION)
if ((compileOptions & SH_EMULATE_ATAN2_FLOAT_FUNCTION) != 0)
{
InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(emu);
}
......
......@@ -25,17 +25,17 @@ TranslatorGLSL::TranslatorGLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutpu
void TranslatorGLSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
ShCompileOptions compileOptions)
{
if (compileOptions & SH_EMULATE_ABS_INT_FUNCTION)
if ((compileOptions & SH_EMULATE_ABS_INT_FUNCTION) != 0)
{
InitBuiltInAbsFunctionEmulatorForGLSLWorkarounds(emu, getShaderType());
}
if (compileOptions & SH_EMULATE_ISNAN_FLOAT_FUNCTION)
if ((compileOptions & SH_EMULATE_ISNAN_FLOAT_FUNCTION) != 0)
{
InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(emu, getShaderVersion());
}
if (compileOptions & SH_EMULATE_ATAN2_FLOAT_FUNCTION)
if ((compileOptions & SH_EMULATE_ATAN2_FLOAT_FUNCTION) != 0)
{
InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(emu);
}
......@@ -234,7 +234,7 @@ bool TranslatorGLSL::shouldFlattenPragmaStdglInvariantAll()
bool TranslatorGLSL::shouldCollectVariables(ShCompileOptions compileOptions)
{
return (compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) ||
return (compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) != 0 ||
TCompiler::shouldCollectVariables(compileOptions);
}
......
......@@ -225,7 +225,7 @@ bool TranslatorMetal::translate(TIntermBlock *root,
// Initialize unused varying outputs to avoid spirv-cross dead-code removing them in later
// stage. Only do this if SH_INIT_OUTPUT_VARIABLES is not specified.
if ((getShaderType() == GL_VERTEX_SHADER || getShaderType() == GL_GEOMETRY_SHADER_EXT) &&
!(compileOptions & SH_INIT_OUTPUT_VARIABLES))
(compileOptions & SH_INIT_OUTPUT_VARIABLES) == 0)
{
InitVariableList list;
for (const sh::ShaderVariable &var : mOutputVaryings)
......
......@@ -542,7 +542,7 @@ ANGLE_NO_DISCARD bool InsertFragCoordCorrection(TCompiler *compiler,
}
TIntermTyped *fragRotation = nullptr;
if (compileOptions & SH_ADD_PRE_ROTATION)
if ((compileOptions & SH_ADD_PRE_ROTATION) != 0)
{
fragRotation = specConst->getFragRotationMatrix();
if (!fragRotation)
......@@ -784,7 +784,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
bool rewriteStructSamplersResult;
int removedUniformsCount;
if (compileOptions & SH_USE_OLD_REWRITE_STRUCT_SAMPLERS)
if ((compileOptions & SH_USE_OLD_REWRITE_STRUCT_SAMPLERS) != 0)
{
rewriteStructSamplersResult =
RewriteStructSamplersOld(this, root, &getSymbolTable(), &removedUniformsCount);
......@@ -812,7 +812,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
// Rewrite samplerCubes as sampler2DArrays. This must be done after rewriting struct samplers
// as it doesn't expect that.
if (compileOptions & SH_EMULATE_SEAMFUL_CUBE_MAP_SAMPLING)
if ((compileOptions & SH_EMULATE_SEAMFUL_CUBE_MAP_SAMPLING) != 0)
{
if (!RewriteCubeMapSamplersAs2DArray(this, root, &getSymbolTable(),
getShaderType() == GL_FRAGMENT_SHADER))
......@@ -925,7 +925,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
if (gl::ShaderTypeSupportsTransformFeedback(packedShaderType))
{
if (compileOptions & SH_ADD_VULKAN_XFB_EXTENSION_SUPPORT_CODE)
if ((compileOptions & SH_ADD_VULKAN_XFB_EXTENSION_SUPPORT_CODE) != 0)
{
// Add support code for transform feedback extension.
if (!AddXfbExtensionSupport(this, root, &getSymbolTable(), driverUniforms))
......@@ -935,7 +935,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
}
// Append a macro for transform feedback substitution prior to modifying depth.
if (compileOptions & SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE)
if ((compileOptions & SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE) != 0)
{
if (!AppendTransformFeedbackOutputToMain(this, root, &getSymbolTable()))
{
......@@ -979,7 +979,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
}
}
if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION)
if ((compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION) != 0)
{
if (!AddBresenhamEmulationFS(this, compileOptions, sink, root, &getSymbolTable(),
specConst, driverUniforms, usesFragCoord))
......@@ -990,7 +990,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
bool hasGLFragColor = false;
bool hasGLFragData = false;
bool usePreRotation = compileOptions & SH_ADD_PRE_ROTATION;
bool usePreRotation = (compileOptions & SH_ADD_PRE_ROTATION) != 0;
bool hasGLSampleMask = false;
for (const ShaderVariable &outputVar : mOutputVariables)
......@@ -1105,7 +1105,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
case gl::ShaderType::Vertex:
{
if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION)
if ((compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION) != 0)
{
if (!AddBresenhamEmulationVS(this, root, &getSymbolTable(), specConst,
driverUniforms))
......@@ -1114,7 +1114,7 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
}
}
if (compileOptions & SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE)
if ((compileOptions & SH_ADD_VULKAN_XFB_EMULATION_SUPPORT_CODE) != 0)
{
// Add support code for transform feedback emulation. Only applies to vertex shader
// as tessellation and geometry shader transform feedback capture require
......@@ -1193,7 +1193,7 @@ bool TranslatorVulkan::translate(TIntermBlock *root,
if (!emulatePrecisionIfNeeded(root, sink, &precisionEmulation, SH_GLSL_VULKAN_OUTPUT))
return false;
bool enablePrecision = ((compileOptions & SH_IGNORE_PRECISION_QUALIFIERS) == 0);
bool enablePrecision = (compileOptions & SH_IGNORE_PRECISION_QUALIFIERS) == 0;
TOutputVulkanGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(),
getNameMap(), &getSymbolTable(), getShaderType(),
......@@ -1202,7 +1202,7 @@ bool TranslatorVulkan::translate(TIntermBlock *root,
SpecConst specConst(&getSymbolTable(), compileOptions);
if (compileOptions & SH_USE_SPECIALIZATION_CONSTANT)
if ((compileOptions & SH_USE_SPECIALIZATION_CONSTANT) != 0)
{
DriverUniform driverUniforms;
if (!translateImpl(root, compileOptions, perfDiagnostics, &specConst, &driverUniforms,
......
......@@ -163,7 +163,7 @@ bool DeclareAndInitBuiltinsForInstancedMultiview(TCompiler *compiler,
// The AST transformation which adds the expression to select the viewport index should
// be done only for the GLSL and ESSL output.
const bool selectView = (compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u;
const bool selectView = (compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0;
// Assert that if the view is selected in the vertex shader, then the output is
// either GLSL or ESSL.
ASSERT(!selectView || IsOutputGLSL(shaderOutput) || IsOutputESSL(shaderOutput));
......
......@@ -270,7 +270,7 @@ void SpecConst::outputLayoutString(TInfoSinkBase &sink) const
TIntermSymbol *SpecConst::getLineRasterEmulation()
{
if (!(mCompileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION))
if ((mCompileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION) == 0)
{
return nullptr;
}
......@@ -291,7 +291,7 @@ TIntermSymbol *SpecConst::getFlipRotation()
TIntermTyped *SpecConst::getMultiplierXForDFdx()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -302,7 +302,7 @@ TIntermTyped *SpecConst::getMultiplierXForDFdx()
TIntermTyped *SpecConst::getMultiplierYForDFdx()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -313,7 +313,7 @@ TIntermTyped *SpecConst::getMultiplierYForDFdx()
TIntermTyped *SpecConst::getMultiplierXForDFdy()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -324,7 +324,7 @@ TIntermTyped *SpecConst::getMultiplierXForDFdy()
TIntermTyped *SpecConst::getMultiplierYForDFdy()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -335,7 +335,7 @@ TIntermTyped *SpecConst::getMultiplierYForDFdy()
TIntermTyped *SpecConst::getFragRotationMatrix()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -345,7 +345,7 @@ TIntermTyped *SpecConst::getFragRotationMatrix()
TIntermTyped *SpecConst::getHalfRenderAreaRotationMatrix()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -355,7 +355,7 @@ TIntermTyped *SpecConst::getHalfRenderAreaRotationMatrix()
TIntermTyped *SpecConst::getFlipXY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -365,7 +365,7 @@ TIntermTyped *SpecConst::getFlipXY()
TIntermTyped *SpecConst::getNegFlipXY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -375,7 +375,7 @@ TIntermTyped *SpecConst::getNegFlipXY()
TIntermTyped *SpecConst::getFlipY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -385,7 +385,7 @@ TIntermTyped *SpecConst::getFlipY()
TIntermTyped *SpecConst::getNegFlipY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -395,7 +395,7 @@ TIntermTyped *SpecConst::getNegFlipY()
TIntermTyped *SpecConst::getFragRotationMultiplyFlipXY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -443,7 +443,7 @@ TIntermSymbol *SpecConst::getDrawableHeight()
TIntermBinary *SpecConst::getHalfRenderArea()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment