Commit 85c076ee by Tim Van Patten Committed by Commit Bot

Vulkan: Make mVariableInfoMap a gl::ShaderMap<>

The ShaderInterfaceVariableInfoMap information is specific to each shader stage, since the locations are determined for each shader stage. This change makes mVariableInfoMap a gl::ShaderMap<> to handle this, which will make it easier to compile separable programs, determine the variable locations, and transform the SPIR-V. Bug: angleproject:3570 Change-Id: I28b71a37efe54bbcfe1dcd445fa03ee71e74f0a6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2062741 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com>
parent abaa3573
......@@ -216,11 +216,11 @@ ShaderInterfaceVariableInfo *AddLocationInfo(ShaderInterfaceVariableInfoMap *inf
ASSERT(info->descriptorSet == ShaderInterfaceVariableInfo::kInvalid);
ASSERT(info->binding == ShaderInterfaceVariableInfo::kInvalid);
ASSERT(info->location[stage] == ShaderInterfaceVariableInfo::kInvalid);
ASSERT(info->component[stage] == ShaderInterfaceVariableInfo::kInvalid);
ASSERT(info->location == ShaderInterfaceVariableInfo::kInvalid);
ASSERT(info->component == ShaderInterfaceVariableInfo::kInvalid);
info->location[stage] = location;
info->component[stage] = component;
info->location = location;
info->component = component;
info->activeStages.set(stage);
return info;
......@@ -457,6 +457,7 @@ void GenerateTransformFeedbackExtensionOutputs(const gl::ProgramState &programSt
}
void AssignAttributeLocations(const gl::ProgramState &programState,
gl::ShaderType stage,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
{
// Assign attribute locations for the vertex shader.
......@@ -465,14 +466,16 @@ void AssignAttributeLocations(const gl::ProgramState &programState,
ASSERT(attribute.active);
AddLocationInfo(variableInfoMapOut, attribute.mappedName, attribute.location,
ShaderInterfaceVariableInfo::kInvalid, gl::ShaderType::Vertex);
ShaderInterfaceVariableInfo::kInvalid, stage);
}
}
void AssignOutputLocations(const gl::ProgramState &programState,
const gl::ShaderType shaderType,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
{
// Assign output locations for the fragment shader.
ASSERT(shaderType == gl::ShaderType::Fragment);
// TODO(syoussefi): Add support for EXT_blend_func_extended. http://anglebug.com/3385
const auto &outputLocations = programState.getOutputLocations();
const auto &outputVariables = programState.getOutputVariables();
......@@ -500,7 +503,7 @@ void AssignOutputLocations(const gl::ProgramState &programState,
}
AddLocationInfo(variableInfoMapOut, outputVar.mappedName, location,
ShaderInterfaceVariableInfo::kInvalid, gl::ShaderType::Fragment);
ShaderInterfaceVariableInfo::kInvalid, shaderType);
}
}
......@@ -509,15 +512,15 @@ void AssignOutputLocations(const gl::ProgramState &programState,
// location 0 to these entries, adding an entry for them here allows us to ASSERT that every
// shader interface variable is processed during the SPIR-V transformation. This is done when
// iterating the ids provided by OpEntryPoint.
AddLocationInfo(variableInfoMapOut, "webgl_FragColor", 0, 0, gl::ShaderType::Fragment);
AddLocationInfo(variableInfoMapOut, "webgl_FragData", 0, 0, gl::ShaderType::Fragment);
AddLocationInfo(variableInfoMapOut, "webgl_FragColor", 0, 0, shaderType);
AddLocationInfo(variableInfoMapOut, "webgl_FragData", 0, 0, shaderType);
}
void AssignVaryingLocations(const GlslangSourceOptions &options,
const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
uint32_t locationsUsedForEmulation = programInterfaceInfo->locationsUsedForXfbExtension;
const gl::ProgramExecutable &glExecutable = programState.getProgramExecutable();
......@@ -530,7 +533,8 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
for (const gl::ShaderType shaderType : glExecutable.getLinkedShaderStages())
{
AddLocationInfo(variableInfoMapOut, sh::vk::kLineRasterEmulationPosition,
AddLocationInfo(&(*variableInfoMapOut)[shaderType],
sh::vk::kLineRasterEmulationPosition,
lineRasterEmulationPositionLocation,
ShaderInterfaceVariableInfo::kInvalid, shaderType);
}
......@@ -567,16 +571,16 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
const std::string &name = varying.isStructField()
? varying.frontVarying.parentStructMappedName
: varying.frontVarying.varying->mappedName;
AddLocationInfo(variableInfoMapOut, name, location, component,
varying.frontVarying.stage);
AddLocationInfo(&(*variableInfoMapOut)[varying.frontVarying.stage], name, location,
component, varying.frontVarying.stage);
}
if (varying.backVarying.varying)
{
const std::string &name = varying.isStructField()
? varying.backVarying.parentStructMappedName
: varying.backVarying.varying->mappedName;
AddLocationInfo(variableInfoMapOut, name, location, component,
varying.backVarying.stage);
AddLocationInfo(&(*variableInfoMapOut)[varying.backVarying.stage], name, location,
component, varying.backVarying.stage);
}
}
......@@ -595,14 +599,15 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
// If name is already in the map, it will automatically have marked all other stages
// inactive.
if (variableInfoMapOut->find(varyingName) != variableInfoMapOut->end())
if ((*variableInfoMapOut)[shaderType].find(varyingName) !=
(*variableInfoMapOut)[shaderType].end())
{
continue;
}
// Otherwise, add an entry for it with all locations inactive.
ShaderInterfaceVariableInfo *info = &(*variableInfoMapOut)[varyingName];
ASSERT(info->location[shaderType] == ShaderInterfaceVariableInfo::kInvalid);
ShaderInterfaceVariableInfo *info = &(*variableInfoMapOut)[shaderType][varyingName];
ASSERT(info->location == ShaderInterfaceVariableInfo::kInvalid);
}
}
}
......@@ -612,6 +617,7 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
uint32_t locationsUsedForXfbExtension,
const gl::ShaderType shaderType,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
{
const std::vector<gl::TransformFeedbackVarying> &tfVaryings =
......@@ -657,7 +663,7 @@ void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramState &programS
ASSERT(xfbVaryingLocation < locationsUsedForXfbExtension);
AddLocationInfo(variableInfoMapOut, xfbVaryingName, xfbVaryingLocation,
ShaderInterfaceVariableInfo::kInvalid, gl::ShaderType::Vertex);
ShaderInterfaceVariableInfo::kInvalid, shaderType);
SetXfbInfo(variableInfoMapOut, xfbVaryingName, bufferIndex, currentOffset,
currentStride);
}
......@@ -707,43 +713,50 @@ void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramState &programS
void AssignUniformBindings(GlslangSourceOptions &options,
const gl::ProgramState &programState,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (programState.getAttachedShader(shaderType) ||
programState.getProgramExecutable().hasLinkedShaderStage(shaderType))
{
AddResourceInfo(variableInfoMapOut, kDefaultUniformNames[shaderType],
AddResourceInfo(&(*variableInfoMapOut)[shaderType], kDefaultUniformNames[shaderType],
programInterfaceInfo->uniformsAndXfbDescriptorSetIndex,
programInterfaceInfo->currentUniformBindingIndex, shaderType);
++programInterfaceInfo->currentUniformBindingIndex;
// Assign binding to the driver uniforms block
AddResourceInfoToAllStages(&(*variableInfoMapOut)[shaderType],
sh::vk::kDriverUniformsBlockName,
programInterfaceInfo->driverUniformsDescriptorSetIndex, 0);
}
}
// Assign binding to the driver uniforms block
AddResourceInfoToAllStages(variableInfoMapOut, sh::vk::kDriverUniformsBlockName,
programInterfaceInfo->driverUniformsDescriptorSetIndex, 0);
}
// TODO: http://anglebug.com/4512: Need to combine descriptor set bindings across
// shader stages.
void AssignInterfaceBlockBindings(GlslangSourceOptions &options,
const gl::ProgramState &programState,
const std::vector<gl::InterfaceBlock> &blocks,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
for (const gl::InterfaceBlock &block : blocks)
{
if (!block.isArray || block.arrayElement == 0)
{
// TODO: http://anglebug.com/4523: All blocks should be active
if (block.activeShaders().any())
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
AddResourceInfoToAllStages(variableInfoMapOut, block.mappedName,
programInterfaceInfo->shaderResourceDescriptorSetIndex,
programInterfaceInfo->currentShaderResourceBindingIndex);
++programInterfaceInfo->currentShaderResourceBindingIndex;
// TODO: http://anglebug.com/4523: All blocks should be active
if (programState.getProgramExecutable().hasLinkedShaderStage(shaderType) &&
block.isActive(shaderType))
{
AddResourceInfo(&(*variableInfoMapOut)[shaderType], block.mappedName,
programInterfaceInfo->shaderResourceDescriptorSetIndex,
programInterfaceInfo->currentShaderResourceBindingIndex,
shaderType);
++programInterfaceInfo->currentShaderResourceBindingIndex;
}
}
}
}
......@@ -752,28 +765,36 @@ void AssignInterfaceBlockBindings(GlslangSourceOptions &options,
// TODO: http://anglebug.com/4512: Need to combine descriptor set bindings across
// shader stages.
void AssignAtomicCounterBufferBindings(GlslangSourceOptions &options,
const gl::ProgramState &programState,
const std::vector<gl::AtomicCounterBuffer> &buffers,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
if (buffers.size() == 0)
{
return;
}
AddResourceInfoToAllStages(variableInfoMapOut, sh::vk::kAtomicCountersBlockName,
programInterfaceInfo->shaderResourceDescriptorSetIndex,
programInterfaceInfo->currentShaderResourceBindingIndex);
++programInterfaceInfo->currentShaderResourceBindingIndex;
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (programState.getProgramExecutable().hasLinkedShaderStage(shaderType))
{
AddResourceInfo(&(*variableInfoMapOut)[shaderType], sh::vk::kAtomicCountersBlockName,
programInterfaceInfo->shaderResourceDescriptorSetIndex,
programInterfaceInfo->currentShaderResourceBindingIndex, shaderType);
++programInterfaceInfo->currentShaderResourceBindingIndex;
}
}
}
// TODO: http://anglebug.com/4512: Need to combine descriptor set bindings across
// shader stages.
void AssignImageBindings(GlslangSourceOptions &options,
const gl::ProgramState &programState,
const std::vector<gl::LinkedUniform> &uniforms,
const gl::RangeUI &imageUniformRange,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
for (unsigned int uniformIndex : imageUniformRange)
{
......@@ -782,10 +803,17 @@ void AssignImageBindings(GlslangSourceOptions &options,
std::string name = imageUniform.mappedName;
if (GetImageNameWithoutIndices(&name))
{
AddResourceInfoToAllStages(variableInfoMapOut, name,
programInterfaceInfo->shaderResourceDescriptorSetIndex,
programInterfaceInfo->currentShaderResourceBindingIndex);
++programInterfaceInfo->currentShaderResourceBindingIndex;
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (programState.getProgramExecutable().hasLinkedShaderStage(shaderType))
{
AddResourceInfo(&(*variableInfoMapOut)[shaderType], name,
programInterfaceInfo->shaderResourceDescriptorSetIndex,
programInterfaceInfo->currentShaderResourceBindingIndex,
shaderType);
++programInterfaceInfo->currentShaderResourceBindingIndex;
}
}
}
}
}
......@@ -793,22 +821,24 @@ void AssignImageBindings(GlslangSourceOptions &options,
void AssignNonTextureBindings(GlslangSourceOptions &options,
const gl::ProgramState &programState,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
const std::vector<gl::InterfaceBlock> &uniformBlocks = programState.getUniformBlocks();
AssignInterfaceBlockBindings(options, uniformBlocks, programInterfaceInfo, variableInfoMapOut);
AssignInterfaceBlockBindings(options, programState, uniformBlocks, programInterfaceInfo,
variableInfoMapOut);
const std::vector<gl::InterfaceBlock> &storageBlocks = programState.getShaderStorageBlocks();
AssignInterfaceBlockBindings(options, storageBlocks, programInterfaceInfo, variableInfoMapOut);
AssignInterfaceBlockBindings(options, programState, storageBlocks, programInterfaceInfo,
variableInfoMapOut);
const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers =
programState.getAtomicCounterBuffers();
AssignAtomicCounterBufferBindings(options, atomicCounterBuffers, programInterfaceInfo,
variableInfoMapOut);
AssignAtomicCounterBufferBindings(options, programState, atomicCounterBuffers,
programInterfaceInfo, variableInfoMapOut);
const std::vector<gl::LinkedUniform> &uniforms = programState.getUniforms();
const gl::RangeUI &imageUniformRange = programState.getImageUniformRange();
AssignImageBindings(options, uniforms, imageUniformRange, programInterfaceInfo,
AssignImageBindings(options, programState, uniforms, imageUniformRange, programInterfaceInfo,
variableInfoMapOut);
}
......@@ -817,7 +847,7 @@ void AssignNonTextureBindings(GlslangSourceOptions &options,
void AssignTextureBindings(GlslangSourceOptions &options,
const gl::ProgramState &programState,
GlslangProgramInterfaceInfo *programInterfaceInfo,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
// Assign textures to a descriptor set and binding.
const std::vector<gl::LinkedUniform> &uniforms = programState.getUniforms();
......@@ -839,13 +869,17 @@ void AssignTextureBindings(GlslangSourceOptions &options,
? GetMappedSamplerNameOld(samplerUniform.name)
: GlslangGetMappedSamplerName(samplerUniform.name);
// TODO: http://anglebug.com/4523: All uniforms should be active
if (samplerUniform.activeShaders().any())
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
AddResourceInfoToAllStages(variableInfoMapOut, samplerName,
programInterfaceInfo->textureDescriptorSetIndex,
programInterfaceInfo->currentTextureBindingIndex);
++programInterfaceInfo->currentTextureBindingIndex;
// TODO: http://anglebug.com/4523: All uniforms should be active
if (programState.getProgramExecutable().hasLinkedShaderStage(shaderType) &&
samplerUniform.isActive(shaderType))
{
AddResourceInfo(&(*variableInfoMapOut)[shaderType], samplerName,
programInterfaceInfo->textureDescriptorSetIndex,
programInterfaceInfo->currentTextureBindingIndex, shaderType);
++programInterfaceInfo->currentTextureBindingIndex;
}
}
}
}
......@@ -1393,7 +1427,7 @@ bool SpirvTransformer::transformDecorate(const uint32_t *instruction, size_t wor
switch (decoration)
{
case spv::DecorationLocation:
newDecorationValue = info->location[mShaderType];
newDecorationValue = info->location;
break;
case spv::DecorationBinding:
newDecorationValue = info->binding;
......@@ -1423,13 +1457,13 @@ bool SpirvTransformer::transformDecorate(const uint32_t *instruction, size_t wor
}
// Add component decoration, if any.
if (info->component[mShaderType] != ShaderInterfaceVariableInfo::kInvalid)
if (info->component != ShaderInterfaceVariableInfo::kInvalid)
{
// Copy the location decoration declaration and modify it to contain the Component
// decoration.
const size_t instOffset = copyInstruction(instruction, wordCount);
(*mSpirvBlobOut)[instOffset + kDecorationIndex] = spv::DecorationComponent;
(*mSpirvBlobOut)[instOffset + kDecorationValueIndex] = info->component[mShaderType];
(*mSpirvBlobOut)[instOffset + kDecorationValueIndex] = info->component;
}
// Add Xfb decorations, if any.
......@@ -1711,11 +1745,7 @@ uint32_t SpirvTransformer::getNewId()
const uint32_t ShaderInterfaceVariableInfo::kInvalid;
ShaderInterfaceVariableInfo::ShaderInterfaceVariableInfo()
{
location.fill(kInvalid);
component.fill(kInvalid);
}
ShaderInterfaceVariableInfo::ShaderInterfaceVariableInfo() {}
void GlslangInitialize()
{
......@@ -1812,7 +1842,7 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
const gl::ProgramLinkedResources &resources,
GlslangProgramInterfaceInfo *programInterfaceInfo,
gl::ShaderMap<std::string> *shaderSourcesOut,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
......@@ -1840,7 +1870,8 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
else if (options.emulateTransformFeedback)
{
GenerateTransformFeedbackEmulationOutputs(
options, programState, programInterfaceInfo, vertexSource, variableInfoMapOut);
options, programState, programInterfaceInfo, vertexSource,
&(*variableInfoMapOut)[gl::ShaderType::Vertex]);
}
}
}
......@@ -1851,14 +1882,16 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
if (programState.getAttachedShader(gl::ShaderType::Fragment) ||
executable.hasLinkedShaderStage(gl::ShaderType::Fragment))
{
AssignOutputLocations(programState, variableInfoMapOut);
AssignOutputLocations(programState, gl::ShaderType::Fragment,
&(*variableInfoMapOut)[gl::ShaderType::Fragment]);
}
// Assign attributes to the vertex shader, if any.
if (programState.getAttachedShader(gl::ShaderType::Vertex) ||
executable.hasLinkedShaderStage(gl::ShaderType::Vertex))
{
AssignAttributeLocations(programState, variableInfoMapOut);
AssignAttributeLocations(programState, gl::ShaderType::Vertex,
&(*variableInfoMapOut)[gl::ShaderType::Vertex]);
}
if (!programState.getAttachedShader(gl::ShaderType::Compute) &&
......@@ -1873,7 +1906,7 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
{
AssignTransformFeedbackExtensionQualifiers(
programState, resources, programInterfaceInfo->locationsUsedForXfbExtension,
variableInfoMapOut);
gl::ShaderType::Vertex, &(*variableInfoMapOut)[gl::ShaderType::Vertex]);
}
}
......@@ -1885,7 +1918,7 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
angle::Result GlslangGetShaderSpirvCode(const GlslangErrorCallback &callback,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const ShaderMapInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<SpirvBlob> *spirvBlobsOut)
{
gl::ShaderMap<SpirvBlob> initialSpirvBlobs;
......@@ -1903,7 +1936,9 @@ angle::Result GlslangGetShaderSpirvCode(const GlslangErrorCallback &callback,
SpirvBlob *spirvBlob = &(*spirvBlobsOut)[shaderType];
SpirvTransformer transformer(initialSpirvBlob, variableInfoMap, shaderType, spirvBlob);
// Transform the SPIR-V code by assigning location/set/binding values.
SpirvTransformer transformer(initialSpirvBlob, variableInfoMap[shaderType], shaderType,
spirvBlob);
ANGLE_GLSLANG_CHECK(callback, transformer.transform(), GlslangError::InvalidSpirv);
ASSERT(ValidateSpirv(*spirvBlob));
......
......@@ -73,8 +73,8 @@ struct ShaderInterfaceVariableInfo
// variables that share the same name, such as a vertex attribute and a fragment output. They
// will share this object since they have the same name, but will find possibly different
// locations in their respective slots.
gl::ShaderMap<uint32_t> location;
gl::ShaderMap<uint32_t> component;
uint32_t location = kInvalid;
uint32_t component = kInvalid;
// The stages this shader interface variable is active.
gl::ShaderBitSet activeStages;
// Used for transform feedback extension to decorate vertex shader output.
......@@ -86,6 +86,7 @@ struct ShaderInterfaceVariableInfo
// TODO: http://anglebug.com/4524: Need a different hash key than a string, since
// that's slow to calculate.
using ShaderInterfaceVariableInfoMap = std::unordered_map<std::string, ShaderInterfaceVariableInfo>;
using ShaderMapInterfaceVariableInfoMap = gl::ShaderMap<ShaderInterfaceVariableInfoMap>;
void GlslangInitialize();
void GlslangRelease();
......@@ -106,12 +107,12 @@ void GlslangGetShaderSource(GlslangSourceOptions &options,
const gl::ProgramLinkedResources &resources,
GlslangProgramInterfaceInfo *programInterfaceInfo,
gl::ShaderMap<std::string> *shaderSourcesOut,
ShaderInterfaceVariableInfoMap *variableInfoMapOut);
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut);
angle::Result GlslangGetShaderSpirvCode(const GlslangErrorCallback &callback,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const ShaderMapInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<SpirvBlob> *spirvBlobsOut);
} // namespace rx
......
......@@ -312,7 +312,7 @@ angle::Result ProgramMtl::linkImpl(const gl::Context *glContext,
// Gather variable info and transform sources.
gl::ShaderMap<std::string> shaderSources;
ShaderInterfaceVariableInfoMap variableInfoMap;
ShaderMapInterfaceVariableInfoMap variableInfoMap;
mtl::GlslangGetShaderSource(mState, resources, &shaderSources, &variableInfoMap);
// Convert GLSL to spirv code
......
......@@ -22,12 +22,12 @@ namespace mtl
void GlslangGetShaderSource(const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut,
ShaderInterfaceVariableInfoMap *variableInfoMapOut);
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut);
angle::Result GlslangGetShaderSpirvCode(ErrorHandler *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const ShaderMapInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut);
} // namespace mtl
} // namespace rx
......
......@@ -50,7 +50,7 @@ GlslangSourceOptions CreateSourceOptions()
void GlslangGetShaderSource(const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
GlslangSourceOptions options = CreateSourceOptions();
GlslangProgramInterfaceInfo programInterfaceInfo;
......@@ -63,7 +63,7 @@ void GlslangGetShaderSource(const gl::ProgramState &programState,
angle::Result GlslangGetShaderSpirvCode(ErrorHandler *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const ShaderMapInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
{
return rx::GlslangGetShaderSpirvCode(
......
......@@ -61,7 +61,7 @@ void GlslangWrapperVk::GetShaderSource(const angle::FeaturesVk &features,
const gl::ProgramLinkedResources &resources,
GlslangProgramInterfaceInfo *programInterfaceInfo,
gl::ShaderMap<std::string> *shaderSourcesOut,
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut)
{
GlslangSourceOptions options = CreateSourceOptions(features);
GlslangGetShaderSource(options, programState, resources, programInterfaceInfo, shaderSourcesOut,
......@@ -69,11 +69,12 @@ void GlslangWrapperVk::GetShaderSource(const angle::FeaturesVk &features,
}
// static
angle::Result GlslangWrapperVk::GetShaderCode(vk::Context *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
angle::Result GlslangWrapperVk::GetShaderCode(
vk::Context *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderMapInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodeOut)
{
return GlslangGetShaderSpirvCode(
[context](GlslangError error) { return ErrorHandler(context, error); }, glCaps,
......
......@@ -35,12 +35,12 @@ class GlslangWrapperVk
const gl::ProgramLinkedResources &resources,
GlslangProgramInterfaceInfo *programInterfaceInfo,
gl::ShaderMap<std::string> *shaderSourcesOut,
ShaderInterfaceVariableInfoMap *variableInfoMapOut);
ShaderMapInterfaceVariableInfoMap *variableInfoMapOut);
static angle::Result GetShaderCode(vk::Context *context,
const gl::Caps &glCaps,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const ShaderMapInterfaceVariableInfoMap &variableInfoMap,
gl::ShaderMap<std::vector<uint32_t>> *shaderCodesOut);
};
} // namespace rx
......
......@@ -63,27 +63,25 @@ std::unique_ptr<rx::LinkEvent> ProgramExecutableVk::load(gl::BinaryInputStream *
{
clearVariableInfoMap();
size_t variableInfoMapSize = stream->readInt<size_t>();
for (size_t i = 0; i < variableInfoMapSize; ++i)
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
const std::string variableName = stream->readString();
ShaderInterfaceVariableInfo *info = &mVariableInfoMap[variableName];
info->descriptorSet = stream->readInt<uint32_t>();
info->binding = stream->readInt<uint32_t>();
size_t variableInfoMapSize = stream->readInt<size_t>();
for (gl::ShaderType shaderType : gl::AllShaderTypes())
for (size_t i = 0; i < variableInfoMapSize; ++i)
{
info->location[shaderType] = stream->readInt<uint32_t>();
info->component[shaderType] = stream->readInt<uint32_t>();
const std::string variableName = stream->readString();
ShaderInterfaceVariableInfo *info = &mVariableInfoMap[shaderType][variableName];
info->descriptorSet = stream->readInt<uint32_t>();
info->binding = stream->readInt<uint32_t>();
info->location = stream->readInt<uint32_t>();
info->component = stream->readInt<uint32_t>();
// PackedEnumBitSet uses uint8_t
info->activeStages = gl::ShaderBitSet(stream->readInt<uint8_t>());
info->xfbBuffer = stream->readInt<uint32_t>();
info->xfbOffset = stream->readInt<uint32_t>();
info->xfbStride = stream->readInt<uint32_t>();
}
// PackedEnumBitSet uses uint8_t
info->activeStages = gl::ShaderBitSet(stream->readInt<uint8_t>());
info->xfbBuffer = stream->readInt<uint32_t>();
info->xfbOffset = stream->readInt<uint32_t>();
info->xfbStride = stream->readInt<uint32_t>();
}
return std::make_unique<LinkEventDone>(angle::Result::Continue);
......@@ -91,30 +89,31 @@ std::unique_ptr<rx::LinkEvent> ProgramExecutableVk::load(gl::BinaryInputStream *
void ProgramExecutableVk::save(gl::BinaryOutputStream *stream)
{
stream->writeInt<size_t>(mVariableInfoMap.size());
for (const auto &it : mVariableInfoMap)
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
stream->writeString(it.first);
stream->writeInt<uint32_t>(it.second.descriptorSet);
stream->writeInt<uint32_t>(it.second.binding);
for (gl::ShaderType shaderType : gl::AllShaderTypes())
stream->writeInt<size_t>(mVariableInfoMap[shaderType].size());
for (const auto &it : mVariableInfoMap[shaderType])
{
stream->writeInt<uint32_t>(it.second.location[shaderType]);
stream->writeInt<uint32_t>(it.second.component[shaderType]);
stream->writeString(it.first);
stream->writeInt<uint32_t>(it.second.descriptorSet);
stream->writeInt<uint32_t>(it.second.binding);
stream->writeInt<uint32_t>(it.second.location);
stream->writeInt<uint32_t>(it.second.component);
// PackedEnumBitSet uses uint8_t
stream->writeInt<uint8_t>(it.second.activeStages.bits());
stream->writeInt<uint32_t>(it.second.xfbBuffer);
stream->writeInt<uint32_t>(it.second.xfbOffset);
stream->writeInt<uint32_t>(it.second.xfbStride);
}
// PackedEnumBitSet uses uint8_t
stream->writeInt<uint8_t>(it.second.activeStages.bits());
stream->writeInt<uint32_t>(it.second.xfbBuffer);
stream->writeInt<uint32_t>(it.second.xfbOffset);
stream->writeInt<uint32_t>(it.second.xfbStride);
}
}
void ProgramExecutableVk::clearVariableInfoMap()
{
mVariableInfoMap.clear();
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
mVariableInfoMap[shaderType].clear();
}
}
uint32_t GetInterfaceBlockArraySize(const std::vector<gl::InterfaceBlock> &blocks,
......@@ -180,6 +179,7 @@ angle::Result ProgramExecutableVk::allocateDescriptorSetAndGetInfo(ContextVk *co
void ProgramExecutableVk::addInterfaceBlockDescriptorSetDesc(
const std::vector<gl::InterfaceBlock> &blocks,
const gl::ShaderType shaderType,
VkDescriptorType descType,
vk::DescriptorSetLayoutDesc *descOut)
{
......@@ -189,21 +189,21 @@ void ProgramExecutableVk::addInterfaceBlockDescriptorSetDesc(
const uint32_t arraySize = GetInterfaceBlockArraySize(blocks, bufferIndex);
bufferIndex += arraySize;
if (!block.activeShaders().any())
if (!block.isActive(shaderType))
{
continue;
}
const std::string blockName = block.mappedName;
const ShaderInterfaceVariableInfo &info = mVariableInfoMap[blockName];
const VkShaderStageFlags &activeStages = gl_vk::GetShaderStageFlags(info.activeStages);
const ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][blockName];
descOut->update(info.binding, descType, arraySize, activeStages);
descOut->update(info.binding, descType, arraySize, gl_vk::kShaderStageMap[shaderType]);
}
}
void ProgramExecutableVk::addAtomicCounterBufferDescriptorSetDesc(
const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers,
const gl::ShaderType shaderType,
vk::DescriptorSetLayoutDesc *descOut)
{
if (atomicCounterBuffers.empty())
......@@ -212,12 +212,17 @@ void ProgramExecutableVk::addAtomicCounterBufferDescriptorSetDesc(
}
std::string blockName(sh::vk::kAtomicCountersBlockName);
const ShaderInterfaceVariableInfo &info = mVariableInfoMap[blockName];
VkShaderStageFlags activeStages = rx::gl_vk::GetShaderStageFlags(info.activeStages);
const ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][blockName];
if (!info.activeStages[shaderType])
{
return;
}
// A single storage buffer array is used for all stages for simplicity.
descOut->update(info.binding, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS, activeStages);
gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS,
gl_vk::kShaderStageMap[shaderType]);
}
void ProgramExecutableVk::addImageDescriptorSetDesc(const gl::ProgramState &programState,
......@@ -232,15 +237,25 @@ void ProgramExecutableVk::addImageDescriptorSetDesc(const gl::ProgramState &prog
uint32_t uniformIndex = programState.getUniformIndexFromImageIndex(imageIndex);
const gl::LinkedUniform &imageUniform = uniforms[uniformIndex];
std::string name = imageUniform.mappedName;
GetImageNameWithoutIndices(&name);
ShaderInterfaceVariableInfo &info = mVariableInfoMap[name];
// The front-end always binds array image units sequentially.
uint32_t arraySize = static_cast<uint32_t>(imageBinding.boundImageUnits.size());
VkShaderStageFlags activeStages = gl_vk::GetShaderStageFlags(info.activeStages);
descOut->update(info.binding, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, arraySize, activeStages);
for (const gl::ShaderType shaderType :
programState.getProgramExecutable().getLinkedShaderStages())
{
if (!imageUniform.isActive(shaderType))
{
continue;
}
std::string name = imageUniform.mappedName;
GetImageNameWithoutIndices(&name);
ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][name];
VkShaderStageFlags activeStages = gl_vk::kShaderStageMap[shaderType];
descOut->update(info.binding, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, arraySize,
activeStages);
}
}
}
......@@ -261,11 +276,9 @@ void ProgramExecutableVk::addTextureDescriptorSetDesc(const gl::ProgramState &pr
const std::string samplerName = useOldRewriteStructSamplers
? GetMappedSamplerNameOld(samplerUniform.name)
: GlslangGetMappedSamplerName(samplerUniform.name);
ShaderInterfaceVariableInfo &info = mVariableInfoMap[samplerName];
// The front-end always binds array sampler units sequentially.
uint32_t arraySize = static_cast<uint32_t>(samplerBinding.boundTextureUnits.size());
VkShaderStageFlags activeStages = gl_vk::GetShaderStageFlags(info.activeStages);
if (!useOldRewriteStructSamplers)
{
......@@ -283,8 +296,20 @@ void ProgramExecutableVk::addTextureDescriptorSetDesc(const gl::ProgramState &pr
}
}
descOut->update(info.binding, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, arraySize,
activeStages);
for (const gl::ShaderType shaderType :
programState.getProgramExecutable().getLinkedShaderStages())
{
if (!samplerUniform.isActive(shaderType))
{
continue;
}
ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][samplerName];
VkShaderStageFlags activeStages = gl_vk::kShaderStageMap[shaderType];
descOut->update(info.binding, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, arraySize,
activeStages);
}
}
}
......@@ -371,7 +396,7 @@ angle::Result ProgramExecutableVk::createPipelineLayout(const gl::Context *glCon
for (const gl::ShaderType shaderType : linkedShaderStages)
{
const std::string uniformBlockName = kDefaultUniformNames[shaderType];
ShaderInterfaceVariableInfo &info = mVariableInfoMap[uniformBlockName];
ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][uniformBlockName];
if (!info.activeStages[shaderType])
{
continue;
......@@ -387,8 +412,9 @@ angle::Result ProgramExecutableVk::createPipelineLayout(const gl::Context *glCon
{
size_t xfbBufferCount = programState.getTransformFeedbackBufferCount();
TransformFeedbackVk *transformFeedbackVk = vk::GetImpl(transformFeedback);
transformFeedbackVk->updateDescriptorSetLayout(contextVk, mVariableInfoMap, xfbBufferCount,
&uniformsAndXfbSetDesc);
transformFeedbackVk->updateDescriptorSetLayout(contextVk,
mVariableInfoMap[gl::ShaderType::Vertex],
xfbBufferCount, &uniformsAndXfbSetDesc);
}
ANGLE_TRY(renderer->getDescriptorSetLayout(
......@@ -398,12 +424,16 @@ angle::Result ProgramExecutableVk::createPipelineLayout(const gl::Context *glCon
// Uniform and storage buffers, atomic counter buffers and images:
vk::DescriptorSetLayoutDesc resourcesSetDesc;
addInterfaceBlockDescriptorSetDesc(programState.getUniformBlocks(),
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &resourcesSetDesc);
addInterfaceBlockDescriptorSetDesc(programState.getShaderStorageBlocks(),
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &resourcesSetDesc);
addAtomicCounterBufferDescriptorSetDesc(programState.getAtomicCounterBuffers(),
&resourcesSetDesc);
for (const gl::ShaderType shaderType : linkedShaderStages)
{
addInterfaceBlockDescriptorSetDesc(programState.getUniformBlocks(), shaderType,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &resourcesSetDesc);
addInterfaceBlockDescriptorSetDesc(programState.getShaderStorageBlocks(), shaderType,
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &resourcesSetDesc);
addAtomicCounterBufferDescriptorSetDesc(programState.getAtomicCounterBuffers(), shaderType,
&resourcesSetDesc);
}
addImageDescriptorSetDesc(programState, &resourcesSetDesc);
ANGLE_TRY(renderer->getDescriptorSetLayout(
......@@ -537,7 +567,7 @@ void ProgramExecutableVk::updateDefaultUniformsDescriptorSet(
programState.getProgramExecutable().getLinkedShaderStages())
{
const std::string uniformBlockName = kDefaultUniformNames[shaderType];
ShaderInterfaceVariableInfo &info = mVariableInfoMap[uniformBlockName];
ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][uniformBlockName];
if (!info.activeStages[shaderType])
{
return;
......@@ -585,6 +615,7 @@ void ProgramExecutableVk::updateDefaultUniformsDescriptorSet(
}
void ProgramExecutableVk::updateBuffersDescriptorSet(ContextVk *contextVk,
const gl::ShaderType shaderType,
vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper,
const std::vector<gl::InterfaceBlock> &blocks,
......@@ -619,7 +650,7 @@ void ProgramExecutableVk::updateBuffersDescriptorSet(ContextVk *contextVk,
isStorageBuffer ? glState.getIndexedShaderStorageBuffer(block.binding)
: glState.getIndexedUniformBuffer(block.binding);
if (!block.activeShaders().any())
if (!block.isActive(shaderType))
{
continue;
}
......@@ -629,7 +660,7 @@ void ProgramExecutableVk::updateBuffersDescriptorSet(ContextVk *contextVk,
continue;
}
ShaderInterfaceVariableInfo info = mVariableInfoMap[block.mappedName];
ShaderInterfaceVariableInfo info = mVariableInfoMap[shaderType][block.mappedName];
uint32_t binding = info.binding;
uint32_t arrayElement = block.isArray ? block.arrayElement : 0;
VkDeviceSize maxBlockSize = isStorageBuffer ? 0 : block.dataSize;
......@@ -665,6 +696,7 @@ void ProgramExecutableVk::updateBuffersDescriptorSet(ContextVk *contextVk,
void ProgramExecutableVk::updateAtomicCounterBuffersDescriptorSet(
const gl::ProgramState &programState,
const gl::ShaderType shaderType,
ContextVk *contextVk,
vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper)
......@@ -681,7 +713,12 @@ void ProgramExecutableVk::updateAtomicCounterBuffersDescriptorSet(
VkDescriptorSet descriptorSet = mDescriptorSets[kShaderResourceDescriptorSetIndex];
std::string blockName(sh::vk::kAtomicCountersBlockName);
const ShaderInterfaceVariableInfo &info = mVariableInfoMap[blockName];
const ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][blockName];
if (!info.activeStages[shaderType])
{
return;
}
gl::AtomicCounterBuffersArray<VkDescriptorBufferInfo> descriptorBufferInfo;
gl::AtomicCounterBuffersArray<VkWriteDescriptorSet> writeDescriptorInfo;
......@@ -751,6 +788,7 @@ void ProgramExecutableVk::updateAtomicCounterBuffersDescriptorSet(
}
angle::Result ProgramExecutableVk::updateImagesDescriptorSet(const gl::ProgramState &programState,
const gl::ShaderType shaderType,
ContextVk *contextVk)
{
const gl::State &glState = contextVk->getState();
......@@ -776,9 +814,15 @@ angle::Result ProgramExecutableVk::updateImagesDescriptorSet(const gl::ProgramSt
const gl::ImageBinding &imageBinding = imageBindings[imageIndex];
uint32_t uniformIndex = programState.getUniformIndexFromImageIndex(imageIndex);
const gl::LinkedUniform &imageUniform = uniforms[uniformIndex];
std::string name = imageUniform.mappedName;
if (!imageUniform.isActive(shaderType))
{
continue;
}
std::string name = imageUniform.mappedName;
GetImageNameWithoutIndices(&name);
ShaderInterfaceVariableInfo &info = mVariableInfoMap[name];
ShaderInterfaceVariableInfo &info = mVariableInfoMap[shaderType][name];
ASSERT(!imageBinding.unreferenced);
......@@ -835,16 +879,29 @@ angle::Result ProgramExecutableVk::updateShaderResourcesDescriptorSet(
vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper)
{
const gl::ProgramExecutable *executable = contextVk->getState().getProgramExecutable();
ASSERT(executable);
ANGLE_TRY(allocateDescriptorSet(contextVk, kShaderResourceDescriptorSetIndex));
updateBuffersDescriptorSet(contextVk, resourceUseList, commandBufferHelper,
programState.getUniformBlocks(), VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
updateBuffersDescriptorSet(contextVk, resourceUseList, commandBufferHelper,
programState.getShaderStorageBlocks(),
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
updateAtomicCounterBuffersDescriptorSet(programState, contextVk, resourceUseList,
commandBufferHelper);
return updateImagesDescriptorSet(programState, contextVk);
for (const gl::ShaderType shaderType : executable->getLinkedShaderStages())
{
updateBuffersDescriptorSet(contextVk, shaderType, resourceUseList, commandBufferHelper,
programState.getUniformBlocks(),
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
updateBuffersDescriptorSet(contextVk, shaderType, resourceUseList, commandBufferHelper,
programState.getShaderStorageBlocks(),
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
updateAtomicCounterBuffersDescriptorSet(programState, shaderType, contextVk,
resourceUseList, commandBufferHelper);
angle::Result status = updateImagesDescriptorSet(programState, shaderType, contextVk);
if (status != angle::Result::Continue)
{
return status;
}
}
return angle::Result::Continue;
}
angle::Result ProgramExecutableVk::updateTransformFeedbackDescriptorSet(
......@@ -995,11 +1052,12 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(const gl::Program
textureVk->getReadImageViewAndRecordUse(contextVk).getHandle();
}
ShaderInterfaceVariableInfoMap &variableInfoMap = mVariableInfoMap[shaderType];
const std::string samplerName =
contextVk->getRenderer()->getFeatures().forceOldRewriteStructSamplers.enabled
? GetMappedSamplerNameOld(samplerUniform.name)
: GlslangGetMappedSamplerName(samplerUniform.name);
ShaderInterfaceVariableInfo &info = mVariableInfoMap[samplerName];
ShaderInterfaceVariableInfo &info = variableInfoMap[samplerName];
VkWriteDescriptorSet &writeInfo = writeDescriptorInfo[writeCount];
......
......@@ -48,7 +48,10 @@ class ProgramExecutableVk
std::unique_ptr<rx::LinkEvent> load(gl::BinaryInputStream *stream);
void clearVariableInfoMap();
ShaderInterfaceVariableInfoMap &getShaderInterfaceVariableInfoMap() { return mVariableInfoMap; }
ShaderMapInterfaceVariableInfoMap &getShaderInterfaceVariableInfoMap()
{
return mVariableInfoMap;
}
const vk::PipelineLayout &getPipelineLayout() const { return mPipelineLayout.get(); }
angle::Result createPipelineLayout(const gl::Context *glContext,
......@@ -77,10 +80,12 @@ class ProgramExecutableVk
uint32_t descriptorSetIndex,
bool *newPoolAllocatedOut);
void addInterfaceBlockDescriptorSetDesc(const std::vector<gl::InterfaceBlock> &blocks,
const gl::ShaderType shaderType,
VkDescriptorType descType,
vk::DescriptorSetLayoutDesc *descOut);
void addAtomicCounterBufferDescriptorSetDesc(
const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers,
const gl::ShaderType shaderType,
vk::DescriptorSetLayoutDesc *descOut);
void addImageDescriptorSetDesc(const gl::ProgramState &programState,
vk::DescriptorSetLayoutDesc *descOut);
......@@ -95,15 +100,18 @@ class ProgramExecutableVk
void updateTransformFeedbackDescriptorSetImpl(const gl::ProgramState &programState,
ContextVk *contextVk);
void updateBuffersDescriptorSet(ContextVk *contextVk,
const gl::ShaderType shaderType,
vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper,
const std::vector<gl::InterfaceBlock> &blocks,
VkDescriptorType descriptorType);
void updateAtomicCounterBuffersDescriptorSet(const gl::ProgramState &programState,
const gl::ShaderType shaderType,
ContextVk *contextVk,
vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper);
angle::Result updateImagesDescriptorSet(const gl::ProgramState &programState,
const gl::ShaderType shaderType,
ContextVk *contextVk);
// This is a special "empty" placeholder buffer for when a shader has no uniforms or doesn't
......@@ -139,7 +147,7 @@ class ProgramExecutableVk
// TODO: http://anglebug.com/4524: Need a different hash key than a string,
// since that's slow to calculate.
ShaderInterfaceVariableInfoMap mVariableInfoMap;
ShaderMapInterfaceVariableInfoMap mVariableInfoMap;
};
} // namespace rx
......
......@@ -168,7 +168,7 @@ ProgramVk::ShaderInfo::~ShaderInfo() = default;
angle::Result ProgramVk::ShaderInfo::initShaders(
ContextVk *contextVk,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap)
const ShaderMapInterfaceVariableInfoMap &variableInfoMap)
{
ASSERT(!valid());
......
......@@ -224,7 +224,7 @@ class ProgramVk : public ProgramImpl
angle::Result initShaders(ContextVk *contextVk,
const gl::ShaderMap<std::string> &shaderSources,
const ShaderInterfaceVariableInfoMap &variableInfoMap);
const ShaderMapInterfaceVariableInfoMap &variableInfoMap);
void release(ContextVk *contextVk);
ANGLE_INLINE bool valid() const { return mIsInitialized; }
......
......@@ -303,10 +303,10 @@ void TransformFeedbackVk::writeDescriptorSet(ContextVk *contextVk,
{
VkDevice device = contextVk->getDevice();
ProgramExecutableVk *executableVk = contextVk->getExecutable();
ShaderInterfaceVariableInfoMap variableInfoMap =
ShaderMapInterfaceVariableInfoMap variableInfoMap =
executableVk->getShaderInterfaceVariableInfoMap();
const std::string bufferName = GetXfbBufferName(0);
ShaderInterfaceVariableInfo &info = variableInfoMap[bufferName];
ShaderInterfaceVariableInfo &info = variableInfoMap[gl::ShaderType::Vertex][bufferName];
VkWriteDescriptorSet writeDescriptorInfo = {};
writeDescriptorInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
......
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