Commit 8b80e852 by Tim Van Patten Committed by Commit Bot

Remove debug info from SPIR-V

When dcheck_always_on=false, the SPIR-V transformer will strip all debug information to reduce the SPIR-V binary size. Running T-Rex shows about 27% reduction in the SPIR-V binary size. Bug: angleproject:4680 Test: CQ Change-Id: Id9d0189cdc9c12fa5a1741cf62ef549a533cdf93 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2267358 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent b291ad09
......@@ -907,6 +907,7 @@ class SpirvTransformer final : angle::NonCopyable
public:
SpirvTransformer(const std::vector<uint32_t> &spirvBlobIn,
bool removeEarlyFragmentTestsOptimization,
bool removeDebugInfo,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderType shaderType,
SpirvBlob *spirvBlobOut)
......@@ -919,6 +920,7 @@ class SpirvTransformer final : angle::NonCopyable
gl::ShaderBitSet allStages;
allStages.set();
mRemoveEarlyFragmentTestsOptimization = removeEarlyFragmentTestsOptimization;
mRemoveDebugInfo = removeDebugInfo;
mBuiltinVariableInfo.activeStages = allStages;
}
......@@ -969,6 +971,7 @@ class SpirvTransformer final : angle::NonCopyable
bool mHasTransformFeedbackOutput;
bool mRemoveEarlyFragmentTestsOptimization;
bool mRemoveDebugInfo;
// Input shader variable info map:
const ShaderInterfaceVariableInfoMap &mVariableInfoMap;
......@@ -1154,6 +1157,21 @@ void SpirvTransformer::transformInstruction()
// Look at global declaration opcodes.
switch (opCode)
{
case spv::OpSourceContinued:
case spv::OpSource:
case spv::OpSourceExtension:
case spv::OpName:
case spv::OpMemberName:
case spv::OpString:
case spv::OpLine:
case spv::OpNoLine:
case spv::OpModuleProcessed:
if (mRemoveDebugInfo)
{
// Strip debug info to reduce binary size.
transformed = true;
}
break;
case spv::OpCapability:
transformed = transformCapability(instruction, wordCount);
break;
......@@ -1866,6 +1884,7 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
angle::Result GlslangTransformSpirvCode(const GlslangErrorCallback &callback,
const gl::ShaderType shaderType,
bool removeEarlyFragmentTestsOptimization,
bool removeDebugInfo,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const SpirvBlob &initialSpirvBlob,
SpirvBlob *spirvBlobOut)
......@@ -1877,7 +1896,7 @@ angle::Result GlslangTransformSpirvCode(const GlslangErrorCallback &callback,
// Transform the SPIR-V code by assigning location/set/binding values.
SpirvTransformer transformer(initialSpirvBlob, removeEarlyFragmentTestsOptimization,
variableInfoMap, shaderType, spirvBlobOut);
removeDebugInfo, variableInfoMap, shaderType, spirvBlobOut);
ANGLE_GLSLANG_CHECK(callback, transformer.transform(), GlslangError::InvalidSpirv);
ASSERT(ValidateSpirv(*spirvBlobOut));
......
......@@ -118,6 +118,7 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
angle::Result GlslangTransformSpirvCode(const GlslangErrorCallback &callback,
const gl::ShaderType shaderType,
bool removeEarlyFragmentTestsOptimization,
bool removeDebugInfo,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const SpirvBlob &initialSpirvBlob,
SpirvBlob *spirvBlobOut);
......
......@@ -256,7 +256,7 @@ angle::Result GlslangGetShaderSpirvCode(ErrorHandler *context,
// do not have ability to add back in at initProgram time.
angle::Result status = GlslangTransformSpirvCode(
[context](GlslangError error) { return HandleError(context, error); }, shaderType,
false, variableInfoMap[shaderType], initialSpirvBlobs[shaderType],
false, false, variableInfoMap[shaderType], initialSpirvBlobs[shaderType],
&(*shaderCodeOut)[shaderType]);
if (status != angle::Result::Continue)
{
......
......@@ -91,8 +91,11 @@ angle::Result GlslangWrapperVk::TransformSpirV(
const SpirvBlob &initialSpirvBlob,
SpirvBlob *shaderCodeOut)
{
const bool removeDebugInfo = !context->getRenderer()->getEnableValidationLayers();
return GlslangTransformSpirvCode(
[context](GlslangError error) { return ErrorHandler(context, error); }, shaderType,
removeEarlyFragmentTestsOptimization, variableInfoMap, initialSpirvBlob, shaderCodeOut);
removeEarlyFragmentTestsOptimization, removeDebugInfo, variableInfoMap, initialSpirvBlob,
shaderCodeOut);
}
} // namespace rx
......@@ -258,6 +258,8 @@ class RendererVk : angle::NonCopyable
vk::BufferHelper &getNullBuffer() { return mTheNullBuffer; }
bool getEnableValidationLayers() const { return mEnableValidationLayers; }
private:
angle::Result initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex);
void ensureCapsInitialized() const;
......
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