Hash :
e7ce481f
Author :
Date :
2023-11-01T22:44:22
Consolidate parallel compilation in front-end This cleans up the multiple compilation task implementations in the backends and consolidates them in the front-end. The front-end is then able to do the compilation in an unlocked tail call instead if desired (in a future change). This change is in preparation for having the program link tasks directly wait on the shader compilation tasks. As a result, the "shader resolve" should not be needed to access the shader compilation results; it should be enough to wait for the compilation job. This change therefore moves post-processing of results to the compilation job itself as they did not need to actually be done after compilation is done (merely after translation is done). As a side effect, shader substition and other debug features should now work for the GL backend as they are now done before back-end compilation. Bug: angleproject:8297 Change-Id: Ib9274b1149fadca7545956a864d6635b6cba5c3a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4994655 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ShaderVk.cpp:
// Implements the class methods for ShaderVk.
//
#include "libANGLE/renderer/vulkan/ShaderVk.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
namespace rx
{
ShaderVk::ShaderVk(const gl::ShaderState &state) : ShaderImpl(state) {}
ShaderVk::~ShaderVk() {}
std::shared_ptr<ShaderTranslateTask> ShaderVk::compile(const gl::Context *context,
ShCompileOptions *options)
{
ContextVk *contextVk = vk::GetImpl(context);
if (context->isWebGL())
{
// Only WebGL requires initialization of local variables, others don't.
// Extra initialization in spirv shader may affect performance.
options->initializeUninitializedLocals = true;
// WebGL shaders may contain OOB array accesses which in turn cause undefined behavior,
// which may result in security issues. See https://crbug.com/1189110.
options->clampIndirectArrayBounds = true;
if (mState.getShaderType() != gl::ShaderType::Compute)
{
options->initOutputVariables = true;
}
}
if (contextVk->getFeatures().retainSPIRVDebugInfo.enabled)
{
options->outputDebugInfo = true;
}
// robustBufferAccess on Vulkan doesn't support bound check on shader local variables
// but the GL_EXT_robustness does support.
// Enable the flag clampIndirectArrayBounds to ensure out of bounds local variable writes in
// shaders are protected when the context has GL_EXT_robustness enabled
if (contextVk->getShareGroup()->hasAnyContextWithRobustness())
{
options->clampIndirectArrayBounds = true;
}
if (contextVk->getFeatures().clampPointSize.enabled)
{
options->clampPointSize = true;
}
if (contextVk->getFeatures().emulateAdvancedBlendEquations.enabled)
{
options->addAdvancedBlendEquationsEmulation = true;
}
if (contextVk->emulateSeamfulCubeMapSampling())
{
options->emulateSeamfulCubeMapSampling = true;
}
if (!contextVk->getFeatures().enablePrecisionQualifiers.enabled)
{
options->ignorePrecisionQualifiers = true;
}
if (contextVk->getFeatures().forceFragmentShaderPrecisionHighpToMediump.enabled)
{
options->forceShaderPrecisionHighpToMediump = true;
}
// Let compiler use specialized constant for pre-rotation.
if (!contextVk->getFeatures().preferDriverUniformOverSpecConst.enabled)
{
options->useSpecializationConstant = true;
}
if (contextVk->getFeatures().clampFragDepth.enabled)
{
options->clampFragDepth = true;
}
if (!contextVk->getFeatures().supportsDepthClipControl.enabled)
{
options->addVulkanDepthCorrection = true;
}
if (contextVk->getFeatures().supportsTransformFeedbackExtension.enabled)
{
options->addVulkanXfbExtensionSupportCode = true;
}
else if (mState.getShaderType() == gl::ShaderType::Vertex &&
contextVk->getFeatures().emulateTransformFeedback.enabled)
{
options->addVulkanXfbEmulationSupportCode = true;
}
if (contextVk->getFeatures().roundOutputAfterDithering.enabled)
{
options->roundOutputAfterDithering = true;
}
if (contextVk->getFeatures().appendAliasedMemoryDecorations.enabled)
{
options->aliasedUnlessRestrict = true;
}
if (contextVk->getFeatures().explicitlyCastMediumpFloatTo16Bit.enabled)
{
options->castMediumpFloatTo16Bit = true;
}
if (contextVk->getExtensions().shaderPixelLocalStorageANGLE)
{
options->pls = contextVk->getNativePixelLocalStorageOptions();
}
// The Vulkan backend needs no post-processing of the translated shader.
return std::shared_ptr<ShaderTranslateTask>(new ShaderTranslateTask);
}
std::string ShaderVk::getDebugInfo() const
{
return mState.getCompiledState()->compiledBinary.empty() ? "" : "<binary blob>";
}
} // namespace rx