Commit bd2954a9 by Shahbaz Youssefi Committed by Commit Bot

Reland "Cleanup translator option checks"

This reverts commit 9173e017. Reason for revert: This was in a chain of reverts, but is unrelated to the issue. Original change's description: > Revert "Cleanup translator option checks" > > This reverts commit 9710c4e4. > > Reason for revert: > Earlier CL breaks pre-rotation: > https://chromium-review.googlesource.com/c/angle/angle/+/2598584 > > Original change's description: > > 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: Charlie Lao <cclao@google.com> > > Reviewed-by: Jamie Madill <jmadill@chromium.org> > > TBR=syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com > > Change-Id: Ib597a62f3c7078d28f7f5b79d1cc9f8d9e469c31 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: angleproject:3606 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2634047 > Reviewed-by: Tim Van Patten <timvp@google.com> > Commit-Queue: Tim Van Patten <timvp@google.com> TBR=timvp@google.com,syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com Bug: angleproject:3606 Change-Id: I10ecca63a3db6dbc3ddedf5bb7e5319a82a80a30 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633712 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 6c5b766b
......@@ -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)
......
......@@ -543,7 +543,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)
......@@ -810,7 +810,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))
......@@ -923,7 +923,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))
......@@ -933,7 +933,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()))
{
......@@ -977,7 +977,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))
......@@ -988,7 +988,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)
......@@ -1103,7 +1103,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))
......@@ -1112,7 +1112,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
......@@ -1191,7 +1191,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(),
......@@ -1200,7 +1200,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));
......
......@@ -271,7 +271,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;
}
......@@ -292,7 +292,7 @@ TIntermSymbol *SpecConst::getFlipRotation()
TIntermTyped *SpecConst::getMultiplierXForDFdx()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -303,7 +303,7 @@ TIntermTyped *SpecConst::getMultiplierXForDFdx()
TIntermTyped *SpecConst::getMultiplierYForDFdx()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -314,7 +314,7 @@ TIntermTyped *SpecConst::getMultiplierYForDFdx()
TIntermTyped *SpecConst::getMultiplierXForDFdy()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -325,7 +325,7 @@ TIntermTyped *SpecConst::getMultiplierXForDFdy()
TIntermTyped *SpecConst::getMultiplierYForDFdy()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -336,7 +336,7 @@ TIntermTyped *SpecConst::getMultiplierYForDFdy()
TIntermTyped *SpecConst::getFragRotationMatrix()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -346,7 +346,7 @@ TIntermTyped *SpecConst::getFragRotationMatrix()
TIntermTyped *SpecConst::getHalfRenderAreaRotationMatrix()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -356,7 +356,7 @@ TIntermTyped *SpecConst::getHalfRenderAreaRotationMatrix()
TIntermTyped *SpecConst::getFlipXY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -366,7 +366,7 @@ TIntermTyped *SpecConst::getFlipXY()
TIntermTyped *SpecConst::getNegFlipXY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -376,7 +376,7 @@ TIntermTyped *SpecConst::getNegFlipXY()
TIntermTyped *SpecConst::getFlipY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -386,7 +386,7 @@ TIntermTyped *SpecConst::getFlipY()
TIntermTyped *SpecConst::getNegFlipY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -396,7 +396,7 @@ TIntermTyped *SpecConst::getNegFlipY()
TIntermTyped *SpecConst::getFragRotationMultiplyFlipXY()
{
if (!(mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT))
if ((mCompileOptions & SH_USE_SPECIALIZATION_CONSTANT) == 0)
{
return nullptr;
}
......@@ -444,7 +444,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