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