Commit a48f95ab by Le Quyen Committed by Commit Bot

Move Vulkan GlslangWrapper code to a shared location.

Metal backend will reuse Vulkan's GlslangWrapper code. The Metal backend will use this code to translate glsl to spirv then cross compile to Metal Shading Language using spirv-cross. So the source code of GlslangWrapper should be moved outside vulkan folder. Bug: angleproject:2634 Change-Id: I208062daf0d77756c9d32cfdab925b7dfdf83e05 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1858042Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d4affcdd
...@@ -582,6 +582,18 @@ angle_source_set("libANGLE_headers") { ...@@ -582,6 +582,18 @@ angle_source_set("libANGLE_headers") {
] ]
} }
angle_source_set("angle_glslang_wrapper") {
sources = [
"src/libANGLE/renderer/glslang_wrapper_utils.cpp",
"src/libANGLE/renderer/glslang_wrapper_utils.h",
]
deps = [
":libANGLE_headers",
"${angle_glslang_dir}:glslang_default_resource_limits_sources",
"${angle_glslang_dir}:glslang_sources",
]
}
angle_source_set("libANGLE_base") { angle_source_set("libANGLE_base") {
sources = libangle_sources sources = libangle_sources
......
...@@ -794,6 +794,27 @@ std::string StripLastArrayIndex(const std::string &name) ...@@ -794,6 +794,27 @@ std::string StripLastArrayIndex(const std::string &name)
return name; return name;
} }
bool SamplerNameContainsNonZeroArrayElement(const std::string &name)
{
constexpr char kZERO_ELEMENT[] = "[0]";
size_t start = 0;
while (true)
{
start = name.find(kZERO_ELEMENT[0], start);
if (start == std::string::npos)
{
break;
}
if (name.compare(start, strlen(kZERO_ELEMENT), kZERO_ELEMENT) != 0)
{
return true;
}
start++;
}
return false;
}
const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var, const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var,
const std::string &fullName, const std::string &fullName,
GLuint *fieldIndexOut) GLuint *fieldIndexOut)
......
...@@ -63,6 +63,8 @@ std::string ParseResourceName(const std::string &name, std::vector<unsigned int> ...@@ -63,6 +63,8 @@ std::string ParseResourceName(const std::string &name, std::vector<unsigned int>
// Strips only the last array index from a resource name. // Strips only the last array index from a resource name.
std::string StripLastArrayIndex(const std::string &name); std::string StripLastArrayIndex(const std::string &name);
bool SamplerNameContainsNonZeroArrayElement(const std::string &name);
// Find the child field which matches 'fullName' == var.name + "." + field.name. // Find the child field which matches 'fullName' == var.name + "." + field.name.
// Return nullptr if not found. // Return nullptr if not found.
const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var, const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var,
......
...@@ -56,7 +56,7 @@ void TOutputVulkanGLSL::writeLayoutQualifier(TIntermTyped *variable) ...@@ -56,7 +56,7 @@ void TOutputVulkanGLSL::writeLayoutQualifier(TIntermTyped *variable)
TInfoSinkBase &out = objSink(); TInfoSinkBase &out = objSink();
// This isn't super clean, but it gets the job done. // This isn't super clean, but it gets the job done.
// See corresponding code in GlslangWrapper.cpp. // See corresponding code in glslang_wrapper_utils.cpp.
TIntermSymbol *symbol = variable->getAsSymbolNode(); TIntermSymbol *symbol = variable->getAsSymbolNode();
ASSERT(symbol); ASSERT(symbol);
......
// //
// Copyright 2016 The ANGLE Project Authors. All rights reserved. // Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// GlslangWrapper: Wrapper for Vulkan's glslang compiler. // Wrapper for Khronos glslang compiler.
// //
#include "libANGLE/renderer/vulkan/GlslangWrapper.h" #include "libANGLE/renderer/glslang_wrapper_utils.h"
// glslang has issues with some specific warnings. // glslang has issues with some specific warnings.
ANGLE_DISABLE_EXTRA_SEMI_WARNING ANGLE_DISABLE_EXTRA_SEMI_WARNING
...@@ -28,8 +28,16 @@ ANGLE_REENABLE_EXTRA_SEMI_WARNING ...@@ -28,8 +28,16 @@ ANGLE_REENABLE_EXTRA_SEMI_WARNING
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/ProgramLinkedResources.h" #include "libANGLE/ProgramLinkedResources.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h" #define ANGLE_GLSLANG_CHECK(CALLBACK, TEST, ERR) \
do \
{ \
if (ANGLE_UNLIKELY(!(TEST))) \
{ \
return CALLBACK(ERR); \
} \
\
} while (0)
namespace rx namespace rx
{ {
...@@ -454,7 +462,8 @@ std::string GenerateTransformFeedbackVaryingOutput(const gl::TransformFeedbackVa ...@@ -454,7 +462,8 @@ std::string GenerateTransformFeedbackVaryingOutput(const gl::TransformFeedbackVa
return result.str(); return result.str();
} }
void GenerateTransformFeedbackOutputs(const gl::ProgramState &programState, void GenerateTransformFeedbackOutputs(const GlslangSourceOptions &options,
const gl::ProgramState &programState,
IntermediateShaderSource *vertexShader) IntermediateShaderSource *vertexShader)
{ {
const std::vector<gl::TransformFeedbackVarying> &varyings = const std::vector<gl::TransformFeedbackVarying> &varyings =
...@@ -464,14 +473,14 @@ void GenerateTransformFeedbackOutputs(const gl::ProgramState &programState, ...@@ -464,14 +473,14 @@ void GenerateTransformFeedbackOutputs(const gl::ProgramState &programState,
programState.getTransformFeedbackBufferMode() == GL_INTERLEAVED_ATTRIBS; programState.getTransformFeedbackBufferMode() == GL_INTERLEAVED_ATTRIBS;
const size_t bufferCount = isInterleaved ? 1 : varyings.size(); const size_t bufferCount = isInterleaved ? 1 : varyings.size();
const std::string xfbSet = Str(kUniformsAndXfbDescriptorSetIndex); const std::string xfbSet = Str(options.uniformsAndXfbDescriptorSetIndex);
std::vector<std::string> xfbIndices(bufferCount); std::vector<std::string> xfbIndices(bufferCount);
std::string xfbDecl; std::string xfbDecl;
for (uint32_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex) for (uint32_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex)
{ {
const std::string xfbBinding = Str(kXfbBindingIndexStart + bufferIndex); const std::string xfbBinding = Str(options.xfbBindingIndexStart + bufferIndex);
xfbIndices[bufferIndex] = Str(bufferIndex); xfbIndices[bufferIndex] = Str(bufferIndex);
xfbDecl += "layout(set = " + xfbSet + ", binding = " + xfbBinding + ") buffer xfbBuffer" + xfbDecl += "layout(set = " + xfbSet + ", binding = " + xfbBinding + ") buffer xfbBuffer" +
...@@ -648,11 +657,13 @@ void AssignVaryingLocations(const gl::ProgramState &programState, ...@@ -648,11 +657,13 @@ void AssignVaryingLocations(const gl::ProgramState &programState,
inStageSource->insertQualifierSpecifier(kVaryingName, "in"); inStageSource->insertQualifierSpecifier(kVaryingName, "in");
} }
void AssignUniformBindings(gl::ShaderMap<IntermediateShaderSource> *shaderSources) void AssignUniformBindings(const GlslangSourceOptions &options,
gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{ {
// Bind the default uniforms for vertex and fragment shaders. // Bind the default uniforms for vertex and fragment shaders.
// See corresponding code in OutputVulkanGLSL.cpp. // See corresponding code in OutputVulkanGLSL.cpp.
const std::string uniformsDescriptorSet = "set = " + Str(kUniformsAndXfbDescriptorSetIndex); const std::string uniformsDescriptorSet =
"set = " + Str(options.uniformsAndXfbDescriptorSetIndex);
constexpr char kDefaultUniformsBlockName[] = "defaultUniforms"; constexpr char kDefaultUniformsBlockName[] = "defaultUniforms";
uint32_t bindingIndex = 0; uint32_t bindingIndex = 0;
...@@ -669,7 +680,7 @@ void AssignUniformBindings(gl::ShaderMap<IntermediateShaderSource> *shaderSource ...@@ -669,7 +680,7 @@ void AssignUniformBindings(gl::ShaderMap<IntermediateShaderSource> *shaderSource
// Substitute layout and qualifier strings for the driver uniforms block. // Substitute layout and qualifier strings for the driver uniforms block.
const std::string driverBlockLayoutString = const std::string driverBlockLayoutString =
"set = " + Str(kDriverUniformsDescriptorSetIndex) + ", binding = 0"; "set = " + Str(options.driverUniformsDescriptorSetIndex) + ", binding = 0";
constexpr char kDriverBlockName[] = "ANGLEUniformBlock"; constexpr char kDriverBlockName[] = "ANGLEUniformBlock";
for (IntermediateShaderSource &shaderSource : *shaderSources) for (IntermediateShaderSource &shaderSource : *shaderSources)
...@@ -705,12 +716,14 @@ void AssignResourceBinding(gl::ShaderBitSet activeShaders, ...@@ -705,12 +716,14 @@ void AssignResourceBinding(gl::ShaderBitSet activeShaders,
} }
} }
uint32_t AssignInterfaceBlockBindings(const std::vector<gl::InterfaceBlock> &blocks, uint32_t AssignInterfaceBlockBindings(const GlslangSourceOptions &options,
const std::vector<gl::InterfaceBlock> &blocks,
const char *qualifier, const char *qualifier,
uint32_t bindingStart, uint32_t bindingStart,
gl::ShaderMap<IntermediateShaderSource> *shaderSources) gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{ {
const std::string resourcesDescriptorSet = "set = " + Str(kShaderResourceDescriptorSetIndex); const std::string resourcesDescriptorSet =
"set = " + Str(options.shaderResourceDescriptorSetIndex);
uint32_t bindingIndex = bindingStart; uint32_t bindingIndex = bindingStart;
for (const gl::InterfaceBlock &block : blocks) for (const gl::InterfaceBlock &block : blocks)
...@@ -728,7 +741,8 @@ uint32_t AssignInterfaceBlockBindings(const std::vector<gl::InterfaceBlock> &blo ...@@ -728,7 +741,8 @@ uint32_t AssignInterfaceBlockBindings(const std::vector<gl::InterfaceBlock> &blo
return bindingIndex; return bindingIndex;
} }
uint32_t AssignAtomicCounterBufferBindings(const std::vector<gl::AtomicCounterBuffer> &buffers, uint32_t AssignAtomicCounterBufferBindings(const GlslangSourceOptions &options,
const std::vector<gl::AtomicCounterBuffer> &buffers,
const char *qualifier, const char *qualifier,
uint32_t bindingStart, uint32_t bindingStart,
gl::ShaderMap<IntermediateShaderSource> *shaderSources) gl::ShaderMap<IntermediateShaderSource> *shaderSources)
...@@ -739,8 +753,8 @@ uint32_t AssignAtomicCounterBufferBindings(const std::vector<gl::AtomicCounterBu ...@@ -739,8 +753,8 @@ uint32_t AssignAtomicCounterBufferBindings(const std::vector<gl::AtomicCounterBu
} }
constexpr char kAtomicCounterBlockName[] = "ANGLEAtomicCounters"; constexpr char kAtomicCounterBlockName[] = "ANGLEAtomicCounters";
const std::string bindingString = const std::string bindingString = "set = " + Str(options.shaderResourceDescriptorSetIndex) +
"set = " + Str(kShaderResourceDescriptorSetIndex) + ", binding = " + Str(bindingStart); ", binding = " + Str(bindingStart);
for (const gl::ShaderType shaderType : gl::AllShaderTypes()) for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
...@@ -756,12 +770,14 @@ uint32_t AssignAtomicCounterBufferBindings(const std::vector<gl::AtomicCounterBu ...@@ -756,12 +770,14 @@ uint32_t AssignAtomicCounterBufferBindings(const std::vector<gl::AtomicCounterBu
return bindingStart + 1; return bindingStart + 1;
} }
uint32_t AssignImageBindings(const std::vector<gl::LinkedUniform> &uniforms, uint32_t AssignImageBindings(const GlslangSourceOptions &options,
const std::vector<gl::LinkedUniform> &uniforms,
const gl::RangeUI &imageUniformRange, const gl::RangeUI &imageUniformRange,
uint32_t bindingStart, uint32_t bindingStart,
gl::ShaderMap<IntermediateShaderSource> *shaderSources) gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{ {
const std::string resourcesDescriptorSet = "set = " + Str(kShaderResourceDescriptorSetIndex); const std::string resourcesDescriptorSet =
"set = " + Str(options.shaderResourceDescriptorSetIndex);
uint32_t bindingIndex = bindingStart; uint32_t bindingIndex = bindingStart;
for (unsigned int uniformIndex : imageUniformRange) for (unsigned int uniformIndex : imageUniformRange)
...@@ -783,34 +799,37 @@ uint32_t AssignImageBindings(const std::vector<gl::LinkedUniform> &uniforms, ...@@ -783,34 +799,37 @@ uint32_t AssignImageBindings(const std::vector<gl::LinkedUniform> &uniforms,
return bindingIndex; return bindingIndex;
} }
void AssignNonTextureBindings(const gl::ProgramState &programState, void AssignNonTextureBindings(const GlslangSourceOptions &options,
const gl::ProgramState &programState,
gl::ShaderMap<IntermediateShaderSource> *shaderSources) gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{ {
uint32_t bindingStart = 0; uint32_t bindingStart = 0;
const std::vector<gl::InterfaceBlock> &uniformBlocks = programState.getUniformBlocks(); const std::vector<gl::InterfaceBlock> &uniformBlocks = programState.getUniformBlocks();
bindingStart = bindingStart = AssignInterfaceBlockBindings(options, uniformBlocks, kUniformQualifier,
AssignInterfaceBlockBindings(uniformBlocks, kUniformQualifier, bindingStart, shaderSources); bindingStart, shaderSources);
const std::vector<gl::InterfaceBlock> &storageBlocks = programState.getShaderStorageBlocks(); const std::vector<gl::InterfaceBlock> &storageBlocks = programState.getShaderStorageBlocks();
bindingStart = bindingStart = AssignInterfaceBlockBindings(options, storageBlocks, kSSBOQualifier,
AssignInterfaceBlockBindings(storageBlocks, kSSBOQualifier, bindingStart, shaderSources); bindingStart, shaderSources);
const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers = const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers =
programState.getAtomicCounterBuffers(); programState.getAtomicCounterBuffers();
bindingStart = AssignAtomicCounterBufferBindings(atomicCounterBuffers, kSSBOQualifier, bindingStart = AssignAtomicCounterBufferBindings(options, atomicCounterBuffers, kSSBOQualifier,
bindingStart, shaderSources); bindingStart, shaderSources);
const std::vector<gl::LinkedUniform> &uniforms = programState.getUniforms(); const std::vector<gl::LinkedUniform> &uniforms = programState.getUniforms();
const gl::RangeUI &imageUniformRange = programState.getImageUniformRange(); const gl::RangeUI &imageUniformRange = programState.getImageUniformRange();
bindingStart = AssignImageBindings(uniforms, imageUniformRange, bindingStart, shaderSources); bindingStart =
AssignImageBindings(options, uniforms, imageUniformRange, bindingStart, shaderSources);
} }
void AssignTextureBindings(bool useOldRewriteStructSamplers, void AssignTextureBindings(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
const gl::ProgramState &programState, const gl::ProgramState &programState,
gl::ShaderMap<IntermediateShaderSource> *shaderSources) gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{ {
const std::string texturesDescriptorSet = "set = " + Str(kTextureDescriptorSetIndex); const std::string texturesDescriptorSet = "set = " + Str(options.textureDescriptorSetIndex);
// Assign textures to a descriptor set and binding. // Assign textures to a descriptor set and binding.
uint32_t bindingIndex = 0; uint32_t bindingIndex = 0;
...@@ -821,7 +840,7 @@ void AssignTextureBindings(bool useOldRewriteStructSamplers, ...@@ -821,7 +840,7 @@ void AssignTextureBindings(bool useOldRewriteStructSamplers,
const gl::LinkedUniform &samplerUniform = uniforms[uniformIndex]; const gl::LinkedUniform &samplerUniform = uniforms[uniformIndex];
if (!useOldRewriteStructSamplers && if (!useOldRewriteStructSamplers &&
vk::SamplerNameContainsNonZeroArrayElement(samplerUniform.name)) gl::SamplerNameContainsNonZeroArrayElement(samplerUniform.name))
{ {
continue; continue;
} }
...@@ -832,7 +851,7 @@ void AssignTextureBindings(bool useOldRewriteStructSamplers, ...@@ -832,7 +851,7 @@ void AssignTextureBindings(bool useOldRewriteStructSamplers,
// Samplers in structs are extracted and renamed. // Samplers in structs are extracted and renamed.
const std::string samplerName = useOldRewriteStructSamplers const std::string samplerName = useOldRewriteStructSamplers
? GetMappedSamplerNameOld(samplerUniform.name) ? GetMappedSamplerNameOld(samplerUniform.name)
: vk::GetMappedSamplerName(samplerUniform.name); : GlslangGetMappedSamplerName(samplerUniform.name);
AssignResourceBinding(samplerUniform.activeShaders(), samplerName, bindingString, AssignResourceBinding(samplerUniform.activeShaders(), samplerName, bindingString,
kUniformQualifier, kUnusedUniformSubstitution, shaderSources); kUniformQualifier, kUnusedUniformSubstitution, shaderSources);
...@@ -891,7 +910,7 @@ void CleanupUnusedEntities(bool useOldRewriteStructSamplers, ...@@ -891,7 +910,7 @@ void CleanupUnusedEntities(bool useOldRewriteStructSamplers,
std::string uniformName = unusedUniform.isSampler std::string uniformName = unusedUniform.isSampler
? useOldRewriteStructSamplers ? useOldRewriteStructSamplers
? GetMappedSamplerNameOld(unusedUniform.name) ? GetMappedSamplerNameOld(unusedUniform.name)
: vk::GetMappedSamplerName(unusedUniform.name) : GlslangGetMappedSamplerName(unusedUniform.name)
: unusedUniform.name; : unusedUniform.name;
for (IntermediateShaderSource &shaderSource : *shaderSources) for (IntermediateShaderSource &shaderSource : *shaderSources)
...@@ -907,27 +926,126 @@ constexpr gl::ShaderMap<EShLanguage> kShLanguageMap = { ...@@ -907,27 +926,126 @@ constexpr gl::ShaderMap<EShLanguage> kShLanguageMap = {
{gl::ShaderType::Fragment, EShLangFragment}, {gl::ShaderType::Fragment, EShLangFragment},
{gl::ShaderType::Compute, EShLangCompute}, {gl::ShaderType::Compute, EShLangCompute},
}; };
angle::Result GetShaderSpirvCode(GlslangErrorCallback callback,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
{
// Enable SPIR-V and Vulkan rules when parsing GLSL
EShMessages messages = static_cast<EShMessages>(EShMsgSpvRules | EShMsgVulkanRules);
TBuiltInResource builtInResources(glslang::DefaultTBuiltInResource);
GetBuiltInResourcesFromCaps(glCaps, &builtInResources);
glslang::TShader vertexShader(EShLangVertex);
glslang::TShader fragmentShader(EShLangFragment);
glslang::TShader geometryShader(EShLangGeometry);
glslang::TShader computeShader(EShLangCompute);
gl::ShaderMap<glslang::TShader *> shaders = {
{gl::ShaderType::Vertex, &vertexShader},
{gl::ShaderType::Fragment, &fragmentShader},
{gl::ShaderType::Geometry, &geometryShader},
{gl::ShaderType::Compute, &computeShader},
};
glslang::TProgram program;
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (shaderSources[shaderType].empty())
{
continue;
}
const char *shaderString = shaderSources[shaderType].c_str();
int shaderLength = static_cast<int>(shaderSources[shaderType].size());
glslang::TShader *shader = shaders[shaderType];
shader->setStringsWithLengths(&shaderString, &shaderLength, 1);
shader->setEntryPoint("main");
bool result = shader->parse(&builtInResources, 450, ECoreProfile, false, false, messages);
if (!result)
{
ERR() << "Internal error parsing Vulkan shader corresponding to " << shaderType << ":\n"
<< shader->getInfoLog() << "\n"
<< shader->getInfoDebugLog() << "\n";
ANGLE_GLSLANG_CHECK(callback, false, GlslangError::InvalidShader);
}
program.addShader(shader);
}
bool linkResult = program.link(messages);
if (!linkResult)
{
ERR() << "Internal error linking Vulkan shaders:\n" << program.getInfoLog() << "\n";
ANGLE_GLSLANG_CHECK(callback, false, GlslangError::InvalidShader);
}
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (shaderSources[shaderType].empty())
{
continue;
}
glslang::TIntermediate *intermediate = program.getIntermediate(kShLanguageMap[shaderType]);
glslang::GlslangToSpv(*intermediate, (*shaderCodeOut)[shaderType]);
}
return angle::Result::Continue;
}
} // anonymous namespace } // anonymous namespace
// static void GlslangInitialize()
void GlslangWrapper::Initialize()
{ {
int result = ShInitialize(); int result = ShInitialize();
ASSERT(result != 0); ASSERT(result != 0);
} }
// static void GlslangRelease()
void GlslangWrapper::Release()
{ {
int result = ShFinalize(); int result = ShFinalize();
ASSERT(result != 0); ASSERT(result != 0);
} }
// static std::string GlslangGetMappedSamplerName(const std::string &originalName)
void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers, {
const gl::ProgramState &programState, std::string samplerName = originalName;
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut) // Samplers in structs are extracted.
std::replace(samplerName.begin(), samplerName.end(), '.', '_');
// Remove array elements
auto out = samplerName.begin();
for (auto in = samplerName.begin(); in != samplerName.end(); in++)
{
if (*in == '[')
{
while (*in != ']')
{
in++;
ASSERT(in != samplerName.end());
}
}
else
{
*out++ = *in;
}
}
samplerName.erase(out, samplerName.end());
return samplerName;
}
void GlslangGetShaderSource(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut)
{ {
gl::ShaderMap<IntermediateShaderSource> intermediateSources; gl::ShaderMap<IntermediateShaderSource> intermediateSources;
...@@ -966,9 +1084,9 @@ void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers, ...@@ -966,9 +1084,9 @@ void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers,
AssignOutputLocations(programState, fragmentSource); AssignOutputLocations(programState, fragmentSource);
AssignVaryingLocations(programState, resources, vertexSource, fragmentSource); AssignVaryingLocations(programState, resources, vertexSource, fragmentSource);
} }
AssignUniformBindings(&intermediateSources); AssignUniformBindings(options, &intermediateSources);
AssignTextureBindings(useOldRewriteStructSamplers, programState, &intermediateSources); AssignTextureBindings(options, useOldRewriteStructSamplers, programState, &intermediateSources);
AssignNonTextureBindings(programState, &intermediateSources); AssignNonTextureBindings(options, programState, &intermediateSources);
for (const auto shaderType : gl::kAllGraphicsShaderTypes) for (const auto shaderType : gl::kAllGraphicsShaderTypes)
{ {
...@@ -986,7 +1104,7 @@ void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers, ...@@ -986,7 +1104,7 @@ void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers,
} }
else else
{ {
GenerateTransformFeedbackOutputs(programState, vertexSource); GenerateTransformFeedbackOutputs(options, programState, vertexSource);
} }
} }
...@@ -996,12 +1114,11 @@ void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers, ...@@ -996,12 +1114,11 @@ void GlslangWrapper::GetShaderSource(bool useOldRewriteStructSamplers,
} }
} }
// static angle::Result GlslangGetShaderSpirvCode(GlslangErrorCallback callback,
angle::Result GlslangWrapper::GetShaderCode(vk::Context *context, const gl::Caps &glCaps,
const gl::Caps &glCaps, bool enableLineRasterEmulation,
bool enableLineRasterEmulation, const gl::ShaderMap<std::string> &shaderSources,
const gl::ShaderMap<std::string> &shaderSources, gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
{ {
if (enableLineRasterEmulation) if (enableLineRasterEmulation)
{ {
...@@ -1010,100 +1127,28 @@ angle::Result GlslangWrapper::GetShaderCode(vk::Context *context, ...@@ -1010,100 +1127,28 @@ angle::Result GlslangWrapper::GetShaderCode(vk::Context *context,
gl::ShaderMap<std::string> patchedSources = shaderSources; gl::ShaderMap<std::string> patchedSources = shaderSources;
// #defines must come after the #version directive. // #defines must come after the #version directive.
ANGLE_VK_CHECK(context, ANGLE_GLSLANG_CHECK(callback,
angle::ReplaceSubstring(&patchedSources[gl::ShaderType::Vertex], angle::ReplaceSubstring(&patchedSources[gl::ShaderType::Vertex],
kVersionDefine, kLineRasterDefine), kVersionDefine, kLineRasterDefine),
VK_ERROR_INVALID_SHADER_NV); GlslangError::InvalidShader);
ANGLE_VK_CHECK(context, ANGLE_GLSLANG_CHECK(callback,
angle::ReplaceSubstring(&patchedSources[gl::ShaderType::Fragment], angle::ReplaceSubstring(&patchedSources[gl::ShaderType::Fragment],
kVersionDefine, kLineRasterDefine), kVersionDefine, kLineRasterDefine),
VK_ERROR_INVALID_SHADER_NV); GlslangError::InvalidShader);
if (!shaderSources[gl::ShaderType::Geometry].empty()) if (!shaderSources[gl::ShaderType::Geometry].empty())
{ {
ANGLE_VK_CHECK(context, ANGLE_GLSLANG_CHECK(callback,
angle::ReplaceSubstring(&patchedSources[gl::ShaderType::Geometry], angle::ReplaceSubstring(&patchedSources[gl::ShaderType::Geometry],
kVersionDefine, kLineRasterDefine), kVersionDefine, kLineRasterDefine),
VK_ERROR_INVALID_SHADER_NV); GlslangError::InvalidShader);
} }
return GetShaderCodeImpl(context, glCaps, patchedSources, shaderCodeOut); return GetShaderSpirvCode(callback, glCaps, patchedSources, shaderCodeOut);
} }
else else
{ {
return GetShaderCodeImpl(context, glCaps, shaderSources, shaderCodeOut); return GetShaderSpirvCode(callback, glCaps, shaderSources, shaderCodeOut);
} }
} }
// static
angle::Result GlslangWrapper::GetShaderCodeImpl(vk::Context *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
{
// Enable SPIR-V and Vulkan rules when parsing GLSL
EShMessages messages = static_cast<EShMessages>(EShMsgSpvRules | EShMsgVulkanRules);
TBuiltInResource builtInResources(glslang::DefaultTBuiltInResource);
GetBuiltInResourcesFromCaps(glCaps, &builtInResources);
glslang::TShader vertexShader(EShLangVertex);
glslang::TShader fragmentShader(EShLangFragment);
glslang::TShader geometryShader(EShLangGeometry);
glslang::TShader computeShader(EShLangCompute);
gl::ShaderMap<glslang::TShader *> shaders = {
{gl::ShaderType::Vertex, &vertexShader},
{gl::ShaderType::Fragment, &fragmentShader},
{gl::ShaderType::Geometry, &geometryShader},
{gl::ShaderType::Compute, &computeShader},
};
glslang::TProgram program;
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (shaderSources[shaderType].empty())
{
continue;
}
const char *shaderString = shaderSources[shaderType].c_str();
int shaderLength = static_cast<int>(shaderSources[shaderType].size());
glslang::TShader *shader = shaders[shaderType];
shader->setStringsWithLengths(&shaderString, &shaderLength, 1);
shader->setEntryPoint("main");
bool result = shader->parse(&builtInResources, 450, ECoreProfile, false, false, messages);
if (!result)
{
ERR() << "Internal error parsing Vulkan shader corresponding to " << shaderType << ":\n"
<< shader->getInfoLog() << "\n"
<< shader->getInfoDebugLog() << "\n";
ANGLE_VK_CHECK(context, false, VK_ERROR_INVALID_SHADER_NV);
}
program.addShader(shader);
}
bool linkResult = program.link(messages);
if (!linkResult)
{
ERR() << "Internal error linking Vulkan shaders:\n" << program.getInfoLog() << "\n";
ANGLE_VK_CHECK(context, false, VK_ERROR_INVALID_SHADER_NV);
}
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (shaderSources[shaderType].empty())
{
continue;
}
glslang::TIntermediate *intermediate = program.getIntermediate(kShLanguageMap[shaderType]);
glslang::GlslangToSpv(*intermediate, (*shaderCodeOut)[shaderType]);
}
return angle::Result::Continue;
}
} // namespace rx } // namespace rx
//
// Copyright 2019 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.
//
// Wrapper for Khronos glslang compiler. This file is used by Vulkan and Metal backends.
//
#ifndef LIBANGLE_RENDERER_GLSLANG_WRAPPER_UTILS_H_
#define LIBANGLE_RENDERER_GLSLANG_WRAPPER_UTILS_H_
#include <functional>
#include "libANGLE/renderer/ProgramImpl.h"
namespace rx
{
enum class GlslangError
{
InvalidShader,
};
struct GlslangSourceOptions
{
// Uniforms set index:
uint32_t uniformsAndXfbDescriptorSetIndex = 0;
// Textures set index:
uint32_t textureDescriptorSetIndex = 1;
// Other shader resources set index:
uint32_t shaderResourceDescriptorSetIndex = 2;
// ANGLE driver uniforms set index:
uint32_t driverUniformsDescriptorSetIndex = 3;
// Binding index start for transform feedback buffers:
uint32_t xfbBindingIndexStart = 16;
};
using GlslangErrorCallback = std::function<angle::Result(GlslangError)>;
void GlslangInitialize();
void GlslangRelease();
// Get the mapped sampler name after the soure is transformed by GlslangGetShaderSource()
std::string GlslangGetMappedSamplerName(const std::string &originalName);
// Transform the source to include actual binding points for various shader
// resources (textures, buffers, xfb, etc)
void GlslangGetShaderSource(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut);
angle::Result GlslangGetShaderSpirvCode(GlslangErrorCallback callback,
const gl::Caps &glCaps,
bool enableLineRasterEmulation,
const gl::ShaderMap<std::string> &shaderSources,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodesOut);
} // namespace rx
#endif // LIBANGLE_RENDERER_GLSLANG_WRAPPER_UTILS_H_
...@@ -39,8 +39,8 @@ _vulkan_backend_sources = [ ...@@ -39,8 +39,8 @@ _vulkan_backend_sources = [
"FenceNVVk.h", "FenceNVVk.h",
"FramebufferVk.cpp", "FramebufferVk.cpp",
"FramebufferVk.h", "FramebufferVk.h",
"GlslangWrapper.cpp", "GlslangWrapperVk.cpp",
"GlslangWrapper.h", "GlslangWrapperVk.h",
"ImageVk.cpp", "ImageVk.cpp",
"ImageVk.h", "ImageVk.h",
"MemoryObjectVk.cpp", "MemoryObjectVk.cpp",
...@@ -263,12 +263,11 @@ angle_source_set("angle_vulkan_backend") { ...@@ -263,12 +263,11 @@ angle_source_set("angle_vulkan_backend") {
libs = [] libs = []
deps = [ deps = [
":angle_vulkan", ":angle_vulkan",
"$angle_glslang_dir:glslang_default_resource_limits_sources",
"$angle_glslang_dir:glslang_sources",
"$angle_root:angle_image_util", "$angle_root:angle_image_util",
"$angle_spirv_tools_dir:spvtools_val", "$angle_spirv_tools_dir:spvtools_val",
] ]
public_deps = [ public_deps = [
"$angle_root:angle_glslang_wrapper",
"$angle_root:libANGLE_headers", "$angle_root:libANGLE_headers",
"$angle_root/third_party/vulkan-headers/src:vulkan_headers", "$angle_root/third_party/vulkan-headers/src:vulkan_headers",
] ]
......
//
// 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.
//
// GlslangWrapperVk: Wrapper for Vulkan's glslang compiler.
//
#include "libANGLE/renderer/vulkan/GlslangWrapperVk.h"
#include "libANGLE/renderer/glslang_wrapper_utils.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
namespace rx
{
namespace
{
angle::Result ErrorHandler(vk::Context *context, GlslangError)
{
ANGLE_VK_CHECK(context, false, VK_ERROR_INVALID_SHADER_NV);
return angle::Result::Stop;
}
GlslangSourceOptions CreateSourceOptions()
{
GlslangSourceOptions options;
options.uniformsAndXfbDescriptorSetIndex = kUniformsAndXfbDescriptorSetIndex;
options.textureDescriptorSetIndex = kTextureDescriptorSetIndex;
options.shaderResourceDescriptorSetIndex = kShaderResourceDescriptorSetIndex;
options.driverUniformsDescriptorSetIndex = kDriverUniformsDescriptorSetIndex;
options.xfbBindingIndexStart = kXfbBindingIndexStart;
return options;
}
} // namespace
// static
void GlslangWrapperVk::GetShaderSource(bool useOldRewriteStructSamplers,
const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut)
{
GlslangGetShaderSource(CreateSourceOptions(), useOldRewriteStructSamplers, programState,
resources, shaderSourcesOut);
}
// static
angle::Result GlslangWrapperVk::GetShaderCode(vk::Context *context,
const gl::Caps &glCaps,
bool enableLineRasterEmulation,
const gl::ShaderMap<std::string> &shaderSources,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
{
return GlslangGetShaderSpirvCode(
[context](GlslangError error) { return ErrorHandler(context, error); }, glCaps,
enableLineRasterEmulation, shaderSources, shaderCodeOut);
}
} // namespace rx
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// GlslangWrapper: Wrapper for Vulkan's glslang compiler. // GlslangWrapperVk: Wrapper for Vulkan's glslang compiler.
// //
#ifndef LIBANGLE_RENDERER_VULKAN_GLSLANG_WRAPPER_H_ #ifndef LIBANGLE_RENDERER_VULKAN_GLSLANG_WRAPPER_H_
...@@ -16,12 +16,9 @@ namespace rx ...@@ -16,12 +16,9 @@ namespace rx
{ {
// This class currently holds no state. If we want to hold state we would need to solve the // This class currently holds no state. If we want to hold state we would need to solve the
// potential race conditions with multiple threads. // potential race conditions with multiple threads.
class GlslangWrapper class GlslangWrapperVk
{ {
public: public:
static void Initialize();
static void Release();
static void GetShaderSource(bool useOldRewriteStructSamplers, static void GetShaderSource(bool useOldRewriteStructSamplers,
const gl::ProgramState &programState, const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources, const gl::ProgramLinkedResources &resources,
...@@ -32,12 +29,6 @@ class GlslangWrapper ...@@ -32,12 +29,6 @@ class GlslangWrapper
bool enableLineRasterEmulation, bool enableLineRasterEmulation,
const gl::ShaderMap<std::string> &shaderSources, const gl::ShaderMap<std::string> &shaderSources,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodesOut); gl::ShaderMap<std::vector<uint32_t>> *shaderCodesOut);
private:
static angle::Result GetShaderCodeImpl(vk::Context *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodesOut);
}; };
} // namespace rx } // namespace rx
......
...@@ -10,11 +10,13 @@ ...@@ -10,11 +10,13 @@
#include "libANGLE/renderer/vulkan/ProgramVk.h" #include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/utilities.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/ProgramLinkedResources.h" #include "libANGLE/ProgramLinkedResources.h"
#include "libANGLE/renderer/glslang_wrapper_utils.h"
#include "libANGLE/renderer/renderer_utils.h" #include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/vulkan/BufferVk.h" #include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/GlslangWrapper.h" #include "libANGLE/renderer/vulkan/GlslangWrapperVk.h"
#include "libANGLE/renderer/vulkan/TextureVk.h" #include "libANGLE/renderer/vulkan/TextureVk.h"
namespace rx namespace rx
...@@ -271,7 +273,7 @@ void AddTextureDescriptorSetDesc(const gl::ProgramState &programState, ...@@ -271,7 +273,7 @@ void AddTextureDescriptorSetDesc(const gl::ProgramState &programState,
// 2D arrays are split into multiple 1D arrays when generating // 2D arrays are split into multiple 1D arrays when generating
// LinkedUniforms. Since they are flattened into one array, ignore the // LinkedUniforms. Since they are flattened into one array, ignore the
// nonzero elements and expand the array to the total array size. // nonzero elements and expand the array to the total array size.
if (vk::SamplerNameContainsNonZeroArrayElement(samplerUniform.name)) if (gl::SamplerNameContainsNonZeroArrayElement(samplerUniform.name))
{ {
continue; continue;
} }
...@@ -369,7 +371,7 @@ angle::Result ProgramVk::ShaderInfo::initShaders(ContextVk *contextVk, ...@@ -369,7 +371,7 @@ angle::Result ProgramVk::ShaderInfo::initShaders(ContextVk *contextVk,
ASSERT(!valid()); ASSERT(!valid());
gl::ShaderMap<std::vector<uint32_t>> shaderCodes; gl::ShaderMap<std::vector<uint32_t>> shaderCodes;
ANGLE_TRY(GlslangWrapper::GetShaderCode( ANGLE_TRY(GlslangWrapperVk::GetShaderCode(
contextVk, contextVk->getCaps(), enableLineRasterEmulation, shaderSources, &shaderCodes)); contextVk, contextVk->getCaps(), enableLineRasterEmulation, shaderSources, &shaderCodes));
for (const gl::ShaderType shaderType : gl::AllShaderTypes()) for (const gl::ShaderType shaderType : gl::AllShaderTypes())
...@@ -564,8 +566,8 @@ std::unique_ptr<LinkEvent> ProgramVk::link(const gl::Context *context, ...@@ -564,8 +566,8 @@ std::unique_ptr<LinkEvent> ProgramVk::link(const gl::Context *context,
// assignment done in that function. // assignment done in that function.
linkResources(resources); linkResources(resources);
GlslangWrapper::GetShaderSource(contextVk->useOldRewriteStructSamplers(), mState, resources, GlslangWrapperVk::GetShaderSource(contextVk->useOldRewriteStructSamplers(), mState, resources,
&mShaderSources); &mShaderSources);
reset(contextVk); reset(contextVk);
...@@ -1616,7 +1618,7 @@ angle::Result ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk) ...@@ -1616,7 +1618,7 @@ angle::Result ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk)
uint32_t uniformIndex = mState.getUniformIndexFromSamplerIndex(textureIndex); uint32_t uniformIndex = mState.getUniformIndexFromSamplerIndex(textureIndex);
const gl::LinkedUniform &samplerUniform = mState.getUniforms()[uniformIndex]; const gl::LinkedUniform &samplerUniform = mState.getUniforms()[uniformIndex];
std::string mappedSamplerName = vk::GetMappedSamplerName(samplerUniform.name); std::string mappedSamplerName = GlslangGetMappedSamplerName(samplerUniform.name);
if (useOldRewriteStructSamplers || if (useOldRewriteStructSamplers ||
mappedSamplerNameToBindingIndex.emplace(mappedSamplerName, currentBindingIndex).second) mappedSamplerNameToBindingIndex.emplace(mappedSamplerName, currentBindingIndex).second)
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/renderer/driver_utils.h" #include "libANGLE/renderer/driver_utils.h"
#include "libANGLE/renderer/glslang_wrapper_utils.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/CompilerVk.h" #include "libANGLE/renderer/vulkan/CompilerVk.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h" #include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h" #include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/GlslangWrapper.h"
#include "libANGLE/renderer/vulkan/ProgramVk.h" #include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/VertexArrayVk.h" #include "libANGLE/renderer/vulkan/VertexArrayVk.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h" #include "libANGLE/renderer/vulkan/vk_caps_utils.h"
...@@ -566,7 +566,7 @@ void RendererVk::onDestroy(vk::Context *context) ...@@ -566,7 +566,7 @@ void RendererVk::onDestroy(vk::Context *context)
mPipelineCache.destroy(mDevice); mPipelineCache.destroy(mDevice);
GlslangWrapper::Release(); GlslangRelease();
if (mDevice) if (mDevice)
{ {
...@@ -885,7 +885,7 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -885,7 +885,7 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
// Store the physical device memory properties so we can find the right memory pools. // Store the physical device memory properties so we can find the right memory pools.
mMemoryProperties.init(mPhysicalDevice); mMemoryProperties.init(mPhysicalDevice);
GlslangWrapper::Initialize(); GlslangInitialize();
// Initialize the format table. // Initialize the format table.
mFormatTable.initialize(this, &mNativeTextureCaps, &mNativeCaps.compressedTextureFormats); mFormatTable.initialize(this, &mNativeTextureCaps, &mNativeCaps.compressedTextureFormats);
......
...@@ -14,14 +14,14 @@ complete. They are templated with markers that are filled in later at link time. ...@@ -14,14 +14,14 @@ complete. They are templated with markers that are filled in later at link time.
1. **Link-Time Translation**: During a call to `glLinkProgram` the Vulkan back-end can know the 1. **Link-Time Translation**: During a call to `glLinkProgram` the Vulkan back-end can know the
necessary locations and properties to write to connect the shader stage interfaces. We get the necessary locations and properties to write to connect the shader stage interfaces. We get the
completed shader source using ANGLE's [GlslangWrapper][GlslangWrapper.cpp] helper class. We still completed shader source using ANGLE's [GlslangWrapperVk][GlslangWrapperVk.cpp] helper class. We still
cannot generate `VkShaderModules` since some ANGLE features like [OpenGL line cannot generate `VkShaderModules` since some ANGLE features like [OpenGL line
rasterization](OpenGLLineSegmentRasterization.md) emulation depend on draw-time information. rasterization](OpenGLLineSegmentRasterization.md) emulation depend on draw-time information.
1. **Draw-time SPIR-V Generation**: Once the application records a draw call we use Khronos' 1. **Draw-time SPIR-V Generation**: Once the application records a draw call we use Khronos'
[glslang][glslang] to convert the Vulkan-compatible GLSL into SPIR-V with the correct draw-time [glslang][glslang] to convert the Vulkan-compatible GLSL into SPIR-V with the correct draw-time
defines. The SPIR-V is then compiled into `VkShaderModules`. For details please see defines. The SPIR-V is then compiled into `VkShaderModules`. For details please see
[GlslangWrapper.cpp][GlslangWrapper.cpp]. The `VkShaderModules` are then used by `VkPipelines`. Note [GlslangWrapperVk.cpp][GlslangWrapperVk.cpp]. The `VkShaderModules` are then used by `VkPipelines`. Note
that we currently don't use [SPIRV-Tools][SPIRV-Tools] to perform any SPIR-V optimization. This that we currently don't use [SPIRV-Tools][SPIRV-Tools] to perform any SPIR-V optimization. This
could be something to improve on in the future. could be something to improve on in the future.
...@@ -32,7 +32,7 @@ participant App ...@@ -32,7 +32,7 @@ participant App
participant "ANGLE Front-end" participant "ANGLE Front-end"
participant "Vulkan Back-end" participant "Vulkan Back-end"
participant "ANGLE Translator" participant "ANGLE Translator"
participant "GlslangWrapper" participant "GlslangWrapperVk"
participant "Glslang" participant "Glslang"
App->"ANGLE Front-end": glCompileShader (VS) App->"ANGLE Front-end": glCompileShader (VS)
...@@ -51,8 +51,8 @@ App->"ANGLE Front-end": glLinkProgram ...@@ -51,8 +51,8 @@ App->"ANGLE Front-end": glLinkProgram
Note right of "Vulkan Back-end": ProgramVk inits uniforms,\nlayouts, and descriptors. Note right of "Vulkan Back-end": ProgramVk inits uniforms,\nlayouts, and descriptors.
"Vulkan Back-end"->GlslangWrapper: GlslangWrapper::GetShaderSource "Vulkan Back-end"->GlslangWrapperVk: GlslangWrapperVk::GetShaderSource
GlslangWrapper- ->"Vulkan Back-end": return filled-in sources GlslangWrapperVk- ->"Vulkan Back-end": return filled-in sources
Note right of "Vulkan Back-end": Source is templated with\ndefines to be resolved at\ndraw time. Note right of "Vulkan Back-end": Source is templated with\ndefines to be resolved at\ndraw time.
...@@ -63,8 +63,8 @@ Note right of App: App execution continues... ...@@ -63,8 +63,8 @@ Note right of App: App execution continues...
App->"ANGLE Front-end": glDrawArrays (any draw) App->"ANGLE Front-end": glDrawArrays (any draw)
"ANGLE Front-end"->"Vulkan Back-end": ContextVk::drawArrays "ANGLE Front-end"->"Vulkan Back-end": ContextVk::drawArrays
"Vulkan Back-end"->GlslangWrapper: GlslangWrapper::GetShaderCode (with defines) "Vulkan Back-end"->GlslangWrapperVk: GlslangWrapperVk::GetShaderCode (with defines)
GlslangWrapper->Glslang: GlslangToSpv GlslangWrapperVk->Glslang: GlslangToSpv
Glslang- ->"Vulkan Back-end": Return SPIR-V Glslang- ->"Vulkan Back-end": Return SPIR-V
Note right of "Vulkan Back-end": We init VkShaderModules\nand VkPipeline then\nrecord the draw. Note right of "Vulkan Back-end": We init VkShaderModules\nand VkPipeline then\nrecord the draw.
...@@ -76,7 +76,7 @@ Note right of "Vulkan Back-end": We init VkShaderModules\nand VkPipeline then\nr ...@@ -76,7 +76,7 @@ Note right of "Vulkan Back-end": We init VkShaderModules\nand VkPipeline then\nr
[GL_KHR_vulkan_glsl]: https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_vulkan_glsl.txt [GL_KHR_vulkan_glsl]: https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_vulkan_glsl.txt
[glslang]: https://github.com/KhronosGroup/glslang [glslang]: https://github.com/KhronosGroup/glslang
[GlslangWrapper.cpp]: https://chromium.googlesource.com/angle/angle/+/refs/heads/master/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp [GlslangWrapperVk.cpp]: https://chromium.googlesource.com/angle/angle/+/refs/heads/master/src/libANGLE/renderer/vulkan/GlslangWrapperVk.cpp
[SPIRV-Tools]: https://github.com/KhronosGroup/SPIRV-Tools [SPIRV-Tools]: https://github.com/KhronosGroup/SPIRV-Tools
[translator]: https://chromium.googlesource.com/angle/angle/+/refs/heads/master/src/compiler/translator/ [translator]: https://chromium.googlesource.com/angle/angle/+/refs/heads/master/src/compiler/translator/
[TranslatorVulkan.cpp]: https://chromium.googlesource.com/angle/angle/+/refs/heads/master/src/compiler/translator/TranslatorVulkan.cpp [TranslatorVulkan.cpp]: https://chromium.googlesource.com/angle/angle/+/refs/heads/master/src/compiler/translator/TranslatorVulkan.cpp
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
participant "ANGLE Front-end" participant "ANGLE Front-end"
participant "Vulkan Back-end" participant "Vulkan Back-end"
participant "ANGLE Translator" participant "ANGLE Translator"
participant "GlslangWrapper" participant "GlslangWrapperVk"
participant "Glslang" participant "Glslang"
App->"ANGLE Front-end": glCompileShader (VS) App->"ANGLE Front-end": glCompileShader (VS)
...@@ -21,8 +21,8 @@ App->"ANGLE Front-end": glLinkProgram ...@@ -21,8 +21,8 @@ App->"ANGLE Front-end": glLinkProgram
Note right of "Vulkan Back-end": ProgramVk inits uniforms,\nlayouts, and descriptors. Note right of "Vulkan Back-end": ProgramVk inits uniforms,\nlayouts, and descriptors.
"Vulkan Back-end"->GlslangWrapper: GlslangWrapper::GetShaderSource "Vulkan Back-end"->GlslangWrapperVk: GlslangWrapperVk::GetShaderSource
GlslangWrapper-->"Vulkan Back-end": return filled-in sources GlslangWrapperVk-->"Vulkan Back-end": return filled-in sources
Note right of "Vulkan Back-end": Source is templated with\ndefines to be resolved at\ndraw time. Note right of "Vulkan Back-end": Source is templated with\ndefines to be resolved at\ndraw time.
...@@ -33,11 +33,11 @@ Note right of App: App execution continues... ...@@ -33,11 +33,11 @@ Note right of App: App execution continues...
App->"ANGLE Front-end": glDrawArrays (any draw) App->"ANGLE Front-end": glDrawArrays (any draw)
"ANGLE Front-end"->"Vulkan Back-end": ContextVk::drawArrays "ANGLE Front-end"->"Vulkan Back-end": ContextVk::drawArrays
"Vulkan Back-end"->GlslangWrapper: GlslangWrapper::GetShaderCode (with defines) "Vulkan Back-end"->GlslangWrapperVk: GlslangWrapperVk::GetShaderCode (with defines)
GlslangWrapper->Glslang: GlslangToSpv GlslangWrapperVk->Glslang: GlslangToSpv
Glslang-->"Vulkan Back-end": Return SPIR-V Glslang-->"Vulkan Back-end": Return SPIR-V
Note right of "Vulkan Back-end": We init VkShaderModules\nand VkPipeline then\nrecord the draw. Note right of "Vulkan Back-end": We init VkShaderModules\nand VkPipeline then\nrecord the draw.
"Vulkan Back-end"-->"ANGLE Front-end": return success "Vulkan Back-end"-->"ANGLE Front-end": return success
]]></source><desc></desc><defs><marker viewBox="0 0 5 5" markerWidth="5" markerHeight="5" orient="auto" refX="5" refY="2.5" id="markerArrowBlock"><path d="M 0 0 L 5 2.5 L 0 5 z"></path></marker><marker viewBox="0 0 9.6 16" markerWidth="4" markerHeight="16" orient="auto" refX="9.6" refY="8" id="markerArrowOpen"><path d="M 9.6,8 1.92,16 0,13.7 5.76,8 0,2.286 1.92,0 9.6,8 z"></path></marker></defs><g class="title"></g><g class="actor"><rect x="10" y="20" width="47.59375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="21" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="20">App</tspan></text></g><g class="actor"><rect x="10" y="1170.359375" width="47.59375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="21" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="20">App</tspan></text></g><line x1="33.796875" x2="33.796875" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="237.0390625" y="20" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="248.0390625" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="247.0390625">ANGLE Front-end</tspan></text></g><g class="actor"><rect x="237.0390625" y="1170.359375" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="248.0390625" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="247.0390625">ANGLE Front-end</tspan></text></g><line x1="313.515625" x2="313.515625" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="462.9765625" y="20" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="473.9765625" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="472.9765625">Vulkan Back-end</tspan></text></g><g class="actor"><rect x="462.9765625" y="1170.359375" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="473.9765625" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="472.9765625">Vulkan Back-end</tspan></text></g><line x1="539.453125" x2="539.453125" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="728.3984375" y="20" width="161.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="739.3984375" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="738.3984375">ANGLE Translator</tspan></text></g><g class="actor"><rect x="728.3984375" y="1170.359375" width="161.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="739.3984375" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="738.3984375">ANGLE Translator</tspan></text></g><line x1="809.375" x2="809.375" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="910.3515625" y="20" width="143.359375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="920.3515625" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="920.3515625">GlslangWrapper</tspan></text></g><g class="actor"><rect x="910.3515625" y="1170.359375" width="143.359375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="920.3515625" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="920.3515625">GlslangWrapper</tspan></text></g><line x1="982.03125" x2="982.03125" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="1073.7109375" y="20" width="81.78125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="1083.7109375" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="1083.7109375">Glslang</tspan></text></g><g class="actor"><rect x="1073.7109375" y="1170.359375" width="81.78125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="1083.7109375" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="1083.7109375">Glslang</tspan></text></g><line x1="1114.6015625" x2="1114.6015625" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="signal"><text x="85.6875" y="89.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="85.6875">glCompileShader (VS)</tspan></text><line x1="33.796875" x2="313.515625" y1="98" y2="98" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="351.609375" y="128.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="351.609375">ShaderVk::compile</tspan></text><line x1="313.515625" x2="539.453125" y1="137" y2="137" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="625.9296875" y="167.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="625.9296875">sh::Compile</tspan></text><line x1="539.453125" x2="809.375" y1="176" y2="176" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="433.890625" y="206.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="433.890625">return Vulkan-compatible GLSL</tspan></text><line x1="809.375" x2="313.515625" y1="215" y2="215" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="333.515625" y="235" width="185.9375" height="67.390625" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="338.515625" y="255" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="338.515625">Source is templated</tspan><tspan dy="1.2em" x="338.515625">with markers to be</tspan><tspan dy="1.2em" x="338.515625">filled at link time.</tspan></text></g><g class="note"><rect x="53.796875" y="322.390625" width="212.328125" height="29" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="58.796875" y="342.390625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="58.796875">Same for FS, GS, etc...</tspan></text></g><g class="signal"><text x="81.2890625" y="381.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="81.2890625">glCreateProgram (...)</tspan></text><line x1="33.796875" x2="313.515625" y1="390.390625" y2="390.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="85.6875" y="420.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="85.6875">glAttachShader (...)</tspan></text><line x1="33.796875" x2="313.515625" y1="429.390625" y2="429.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="116.375" y="459.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="116.375">glLinkProgram</tspan></text><line x1="33.796875" x2="313.515625" y1="468.390625" y2="468.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="360.40625" y="498.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="360.40625">ProgramVk::link</tspan></text><line x1="313.515625" x2="539.453125" y1="507.390625" y2="507.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="559.453125" y="527.390625" width="229.921875" height="48.1875" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="564.453125" y="547.390625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="564.453125">ProgramVk inits uniforms,</tspan><tspan dy="1.2em" x="564.453125">layouts, and descriptors.</tspan></text></g><g class="signal"><text x="624.2890625" y="606.078125" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="624.2890625">GlslangWrapper::GetShaderSource</tspan></text><line x1="539.453125" x2="982.03125" y1="614.578125" y2="614.578125" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="655.1796875" y="645.078125" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="655.1796875">return filled-in sources</tspan></text><line x1="982.03125" x2="539.453125" y1="653.578125" y2="653.578125" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="559.453125" y="673.578125" width="229.921875" height="67.390625" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="564.453125" y="693.578125" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="564.453125">Source is templated with</tspan><tspan dy="1.2em" x="564.453125">defines to be resolved at</tspan><tspan dy="1.2em" x="564.453125">draw time.</tspan></text></g><g class="signal"><text x="364.90625" y="771.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="364.90625">return success</tspan></text><line x1="539.453125" x2="313.515625" y1="779.96875" y2="779.96875" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="53.796875" y="799.96875" width="239.71875" height="29" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="59.796875" y="819.96875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="58.796875">App execution continues...</tspan></text></g><g class="signal"><text x="72.4921875" y="859.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="72.4921875">glDrawArrays (any draw)</tspan></text><line x1="33.796875" x2="313.515625" y1="867.96875" y2="867.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="334.1171875" y="898.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="334.1171875">ContextVk::drawArrays</tspan></text><line x1="313.515625" x2="539.453125" y1="906.96875" y2="906.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="567.2109375" y="937.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="567.2109375">GlslangWrapper::GetShaderCode (with defines)</tspan></text><line x1="539.453125" x2="982.03125" y1="945.96875" y2="945.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="995.43359375" y="976.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="995.43359375">GlslangToSpv</tspan></text><line x1="982.03125" x2="1114.6015625" y1="984.96875" y2="984.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="769.24609375" y="1015.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="769.24609375">Return SPIR-V</tspan></text><line x1="1114.6015625" x2="539.453125" y1="1023.96875" y2="1023.96875" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="559.453125" y="1043.96875" width="212.328125" height="67.390625" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="564.453125" y="1063.96875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="564.453125">We init VkShaderModules</tspan><tspan dy="1.2em" x="564.453125">and VkPipeline then</tspan><tspan dy="1.2em" x="564.453125">record the draw.</tspan></text></g><g class="signal"><text x="364.90625" y="1141.859375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="364.90625">return success</tspan></text><line x1="539.453125" x2="313.515625" y1="1150.359375" y2="1150.359375" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g></svg> ]]></source><desc></desc><defs><marker viewBox="0 0 5 5" markerWidth="5" markerHeight="5" orient="auto" refX="5" refY="2.5" id="markerArrowBlock"><path d="M 0 0 L 5 2.5 L 0 5 z"></path></marker><marker viewBox="0 0 9.6 16" markerWidth="4" markerHeight="16" orient="auto" refX="9.6" refY="8" id="markerArrowOpen"><path d="M 9.6,8 1.92,16 0,13.7 5.76,8 0,2.286 1.92,0 9.6,8 z"></path></marker></defs><g class="title"></g><g class="actor"><rect x="10" y="20" width="47.59375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="21" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="20">App</tspan></text></g><g class="actor"><rect x="10" y="1170.359375" width="47.59375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="21" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="20">App</tspan></text></g><line x1="33.796875" x2="33.796875" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="237.0390625" y="20" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="248.0390625" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="247.0390625">ANGLE Front-end</tspan></text></g><g class="actor"><rect x="237.0390625" y="1170.359375" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="248.0390625" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="247.0390625">ANGLE Front-end</tspan></text></g><line x1="313.515625" x2="313.515625" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="462.9765625" y="20" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="473.9765625" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="472.9765625">Vulkan Back-end</tspan></text></g><g class="actor"><rect x="462.9765625" y="1170.359375" width="152.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="473.9765625" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="472.9765625">Vulkan Back-end</tspan></text></g><line x1="539.453125" x2="539.453125" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="728.3984375" y="20" width="161.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="739.3984375" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="738.3984375">ANGLE Translator</tspan></text></g><g class="actor"><rect x="728.3984375" y="1170.359375" width="161.953125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="739.3984375" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="738.3984375">ANGLE Translator</tspan></text></g><line x1="809.375" x2="809.375" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="910.3515625" y="20" width="143.359375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="920.3515625" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="920.3515625">GlslangWrapperVk</tspan></text></g><g class="actor"><rect x="910.3515625" y="1170.359375" width="143.359375" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="920.3515625" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="920.3515625">GlslangWrapperVk</tspan></text></g><line x1="982.03125" x2="982.03125" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="actor"><rect x="1073.7109375" y="20" width="81.78125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="1083.7109375" y="45" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="1083.7109375">Glslang</tspan></text></g><g class="actor"><rect x="1073.7109375" y="1170.359375" width="81.78125" height="39" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="1083.7109375" y="1195.359375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="1083.7109375">Glslang</tspan></text></g><line x1="1114.6015625" x2="1114.6015625" y1="59" y2="1170.359375" stroke="#000000" fill="none" style="stroke-width: 2;"></line><g class="signal"><text x="85.6875" y="89.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="85.6875">glCompileShader (VS)</tspan></text><line x1="33.796875" x2="313.515625" y1="98" y2="98" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="351.609375" y="128.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="351.609375">ShaderVk::compile</tspan></text><line x1="313.515625" x2="539.453125" y1="137" y2="137" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="625.9296875" y="167.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="625.9296875">sh::Compile</tspan></text><line x1="539.453125" x2="809.375" y1="176" y2="176" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="433.890625" y="206.5" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="433.890625">return Vulkan-compatible GLSL</tspan></text><line x1="809.375" x2="313.515625" y1="215" y2="215" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="333.515625" y="235" width="185.9375" height="67.390625" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="338.515625" y="255" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="338.515625">Source is templated</tspan><tspan dy="1.2em" x="338.515625">with markers to be</tspan><tspan dy="1.2em" x="338.515625">filled at link time.</tspan></text></g><g class="note"><rect x="53.796875" y="322.390625" width="212.328125" height="29" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="58.796875" y="342.390625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="58.796875">Same for FS, GS, etc...</tspan></text></g><g class="signal"><text x="81.2890625" y="381.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="81.2890625">glCreateProgram (...)</tspan></text><line x1="33.796875" x2="313.515625" y1="390.390625" y2="390.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="85.6875" y="420.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="85.6875">glAttachShader (...)</tspan></text><line x1="33.796875" x2="313.515625" y1="429.390625" y2="429.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="116.375" y="459.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="116.375">glLinkProgram</tspan></text><line x1="33.796875" x2="313.515625" y1="468.390625" y2="468.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="360.40625" y="498.890625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="360.40625">ProgramVk::link</tspan></text><line x1="313.515625" x2="539.453125" y1="507.390625" y2="507.390625" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="559.453125" y="527.390625" width="229.921875" height="48.1875" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="564.453125" y="547.390625" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="564.453125">ProgramVk inits uniforms,</tspan><tspan dy="1.2em" x="564.453125">layouts, and descriptors.</tspan></text></g><g class="signal"><text x="624.2890625" y="606.078125" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="624.2890625">GlslangWrapperVk::GetShaderSource</tspan></text><line x1="539.453125" x2="982.03125" y1="614.578125" y2="614.578125" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="655.1796875" y="645.078125" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="655.1796875">return filled-in sources</tspan></text><line x1="982.03125" x2="539.453125" y1="653.578125" y2="653.578125" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="559.453125" y="673.578125" width="229.921875" height="67.390625" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="564.453125" y="693.578125" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="564.453125">Source is templated with</tspan><tspan dy="1.2em" x="564.453125">defines to be resolved at</tspan><tspan dy="1.2em" x="564.453125">draw time.</tspan></text></g><g class="signal"><text x="364.90625" y="771.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="364.90625">return success</tspan></text><line x1="539.453125" x2="313.515625" y1="779.96875" y2="779.96875" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="53.796875" y="799.96875" width="239.71875" height="29" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="59.796875" y="819.96875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="58.796875">App execution continues...</tspan></text></g><g class="signal"><text x="72.4921875" y="859.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="72.4921875">glDrawArrays (any draw)</tspan></text><line x1="33.796875" x2="313.515625" y1="867.96875" y2="867.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="334.1171875" y="898.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="334.1171875">ContextVk::drawArrays</tspan></text><line x1="313.515625" x2="539.453125" y1="906.96875" y2="906.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="567.2109375" y="937.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="567.2109375">GlslangWrapperVk::GetShaderCode (with defines)</tspan></text><line x1="539.453125" x2="982.03125" y1="945.96875" y2="945.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="995.43359375" y="976.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="995.43359375">GlslangToSpv</tspan></text><line x1="982.03125" x2="1114.6015625" y1="984.96875" y2="984.96875" stroke="#000000" fill="none" style="stroke-width: 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="signal"><text x="769.24609375" y="1015.46875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="769.24609375">Return SPIR-V</tspan></text><line x1="1114.6015625" x2="539.453125" y1="1023.96875" y2="1023.96875" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g><g class="note"><rect x="559.453125" y="1043.96875" width="212.328125" height="67.390625" stroke="#000000" fill="#ffffff" style="stroke-width: 2;"></rect><text x="564.453125" y="1063.96875" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="564.453125">We init VkShaderModules</tspan><tspan dy="1.2em" x="564.453125">and VkPipeline then</tspan><tspan dy="1.2em" x="564.453125">record the draw.</tspan></text></g><g class="signal"><text x="364.90625" y="1141.859375" style="font-size: 16px; font-family: &quot;Andale Mono&quot;, monospace;"><tspan x="364.90625">return success</tspan></text><line x1="539.453125" x2="313.515625" y1="1150.359375" y2="1150.359375" stroke="#000000" fill="none" style="stroke-width: 2; stroke-dasharray: 6, 2; marker-end: url(&quot;#markerArrowBlock&quot;);"></line></g></svg>
\ No newline at end of file \ No newline at end of file
...@@ -552,57 +552,6 @@ void GarbageObject::destroy(VkDevice device) ...@@ -552,57 +552,6 @@ void GarbageObject::destroy(VkDevice device)
} }
} }
bool SamplerNameContainsNonZeroArrayElement(const std::string &name)
{
constexpr char kZERO_ELEMENT[] = "[0]";
size_t start = 0;
while (true)
{
start = name.find(kZERO_ELEMENT[0], start);
if (start == std::string::npos)
{
break;
}
if (name.compare(start, strlen(kZERO_ELEMENT), kZERO_ELEMENT) != 0)
{
return true;
}
start++;
}
return false;
}
std::string GetMappedSamplerName(const std::string &originalName)
{
std::string samplerName = originalName;
// Samplers in structs are extracted.
std::replace(samplerName.begin(), samplerName.end(), '.', '_');
// Remove array elements
auto out = samplerName.begin();
for (auto in = samplerName.begin(); in != samplerName.end(); in++)
{
if (*in == '[')
{
while (*in != ']')
{
in++;
ASSERT(in != samplerName.end());
}
}
else
{
*out++ = *in;
}
}
samplerName.erase(out, samplerName.end());
return samplerName;
}
} // namespace vk } // namespace vk
// VK_EXT_debug_utils // VK_EXT_debug_utils
......
...@@ -599,8 +599,6 @@ class Recycler final : angle::NonCopyable ...@@ -599,8 +599,6 @@ class Recycler final : angle::NonCopyable
std::vector<T> mObjectFreeList; std::vector<T> mObjectFreeList;
}; };
bool SamplerNameContainsNonZeroArrayElement(const std::string &name);
std::string GetMappedSamplerName(const std::string &originalName);
} // namespace vk } // namespace vk
// List of function pointers for used extensions. // List of function pointers for used extensions.
......
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