#include "libANGLE/renderer/vulkan/ProgramExecutableVk.h"
#include "common/string_utils.h"
#include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/ProgramPipelineVk.h"
#include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/TextureVk.h"
#include "libANGLE/renderer/vulkan/TransformFeedbackVk.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
#include "libANGLE/renderer/vulkan/vk_utils.h"
namespace rx
{
namespace
{
static constexpr size_t kMaxLocalPipelineCacheSize = …;
bool ValidateTransformedSpirV(vk::Context *context,
const gl::ShaderBitSet &linkedShaderStages,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
const gl::ShaderMap<angle::spirv::Blob> &spirvBlobs)
{ … }
uint32_t GetInterfaceBlockArraySize(const std::vector<gl::InterfaceBlock> &blocks,
uint32_t bufferIndex)
{ … }
void SetupDefaultPipelineState(const vk::Context *context,
const gl::ProgramExecutable &glExecutable,
gl::PrimitiveMode mode,
vk::PipelineRobustness pipelineRobustness,
vk::PipelineProtectedAccess pipelineProtectedAccess,
vk::GraphicsPipelineSubset subset,
vk::GraphicsPipelineDesc *graphicsPipelineDescOut)
{ … }
void GetPipelineCacheData(ContextVk *contextVk,
const vk::PipelineCache &pipelineCache,
angle::MemoryBuffer *cacheDataOut)
{ … }
vk::SpecializationConstants MakeSpecConsts(ProgramTransformOptions transformOptions,
const vk::GraphicsPipelineDesc &desc)
{ … }
template <typename T>
void UpdateDefaultUniformBlock(GLsizei count,
uint32_t arrayIndex,
int componentCount,
const T *v,
const sh::BlockMemberInfo &layoutInfo,
angle::MemoryBuffer *uniformData)
{ … }
template <typename T>
void ReadFromDefaultUniformBlock(int componentCount,
uint32_t arrayIndex,
T *dst,
const sh::BlockMemberInfo &layoutInfo,
const angle::MemoryBuffer *uniformData)
{ … }
template <typename T>
void SetUniformImpl(const gl::ProgramExecutable *executable,
GLint location,
GLsizei count,
const T *v,
GLenum entryPointType,
DefaultUniformBlockMap *defaultUniformBlocks,
gl::ShaderBitSet *defaultUniformBlocksDirty)
{ … }
template <int cols, int rows>
void SetUniformMatrixfv(const gl::ProgramExecutable *executable,
GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value,
DefaultUniformBlockMap *defaultUniformBlocks,
gl::ShaderBitSet *defaultUniformBlocksDirty)
{ … }
vk::GraphicsPipelineSubset GetWarmUpSubset(const angle::FeaturesVk &features)
{ … }
}
class ProgramExecutableVk::WarmUpTaskCommon : public vk::Context, public LinkSubTask
{ … };
class ProgramExecutableVk::WarmUpComputeTask : public WarmUpTaskCommon
{ … };
SharedRenderPass;
class ProgramExecutableVk::WarmUpGraphicsTask : public WarmUpTaskCommon
{ … };
DefaultUniformBlockVk::DefaultUniformBlockVk() = default;
DefaultUniformBlockVk::~DefaultUniformBlockVk() = default;
ShaderInfo::ShaderInfo() { … }
ShaderInfo::~ShaderInfo() = default;
angle::Result ShaderInfo::initShaders(vk::Context *context,
const gl::ShaderBitSet &linkedShaderStages,
const gl::ShaderMap<const angle::spirv::Blob *> &spirvBlobs,
const ShaderInterfaceVariableInfoMap &variableInfoMap,
bool isGLES1)
{ … }
void ShaderInfo::initShaderFromProgram(gl::ShaderType shaderType,
const ShaderInfo &programShaderInfo)
{ … }
void ShaderInfo::clear()
{ … }
void ShaderInfo::load(gl::BinaryInputStream *stream)
{ … }
void ShaderInfo::save(gl::BinaryOutputStream *stream)
{ … }
ProgramInfo::ProgramInfo() { … }
ProgramInfo::~ProgramInfo() = default;
angle::Result ProgramInfo::initProgram(vk::Context *context,
gl::ShaderType shaderType,
bool isLastPreFragmentStage,
bool isTransformFeedbackProgram,
const ShaderInfo &shaderInfo,
ProgramTransformOptions optionBits,
const ShaderInterfaceVariableInfoMap &variableInfoMap)
{ … }
void ProgramInfo::release(ContextVk *contextVk)
{ … }
ProgramExecutableVk::ProgramExecutableVk(const gl::ProgramExecutable *executable)
: … { … }
ProgramExecutableVk::~ProgramExecutableVk()
{ … }
void ProgramExecutableVk::destroy(const gl::Context *context)
{ … }
void ProgramExecutableVk::resetLayout(ContextVk *contextVk)
{ … }
void ProgramExecutableVk::reset(ContextVk *contextVk)
{ … }
angle::Result ProgramExecutableVk::initializePipelineCache(vk::Context *context,
bool compressed,
const std::vector<uint8_t> &pipelineData)
{ … }
angle::Result ProgramExecutableVk::ensurePipelineCacheInitialized(vk::Context *context)
{ … }
angle::Result ProgramExecutableVk::load(ContextVk *contextVk,
bool isSeparable,
gl::BinaryInputStream *stream,
egl::CacheGetResult *resultOut)
{ … }
void ProgramExecutableVk::save(ContextVk *contextVk,
bool isSeparable,
gl::BinaryOutputStream *stream)
{ … }
void ProgramExecutableVk::clearVariableInfoMap()
{ … }
angle::Result ProgramExecutableVk::getPipelineCacheWarmUpTasks(
vk::Renderer *renderer,
vk::PipelineRobustness pipelineRobustness,
vk::PipelineProtectedAccess pipelineProtectedAccess,
std::vector<std::shared_ptr<LinkSubTask>> *postLinkSubTasksOut)
{ … }
angle::Result ProgramExecutableVk::prepareForWarmUpPipelineCache(
vk::Context *context,
vk::PipelineRobustness pipelineRobustness,
vk::PipelineProtectedAccess pipelineProtectedAccess,
vk::GraphicsPipelineSubset subset,
bool *isComputeOut,
angle::FixedVector<bool, 2> *surfaceRotationVariationsOut,
vk::GraphicsPipelineDesc **graphicsPipelineDescOut,
vk::RenderPass *renderPassOut)
{ … }
angle::Result ProgramExecutableVk::warmUpComputePipelineCache(
vk::Context *context,
vk::PipelineRobustness pipelineRobustness,
vk::PipelineProtectedAccess pipelineProtectedAccess)
{ … }
angle::Result ProgramExecutableVk::warmUpGraphicsPipelineCache(
vk::Context *context,
vk::PipelineRobustness pipelineRobustness,
vk::PipelineProtectedAccess pipelineProtectedAccess,
vk::GraphicsPipelineSubset subset,
const bool isSurfaceRotated,
const vk::GraphicsPipelineDesc &graphicsPipelineDesc,
const vk::RenderPass &renderPass,
vk::PipelineHelper *placeholderPipelineHelper)
{ … }
void ProgramExecutableVk::waitForPostLinkTasksImpl(ContextVk *contextVk)
{ … }
void ProgramExecutableVk::waitForGraphicsPostLinkTasks(
ContextVk *contextVk,
const vk::GraphicsPipelineDesc ¤tGraphicsPipelineDesc)
{ … }
angle::Result ProgramExecutableVk::mergePipelineCacheToRenderer(vk::Context *context) const
{ … }
void ProgramExecutableVk::addInterfaceBlockDescriptorSetDesc(
const std::vector<gl::InterfaceBlock> &blocks,
gl::ShaderBitSet shaderTypes,
VkDescriptorType descType,
vk::DescriptorSetLayoutDesc *descOut)
{ … }
void ProgramExecutableVk::addAtomicCounterBufferDescriptorSetDesc(
const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers,
vk::DescriptorSetLayoutDesc *descOut)
{ … }
void ProgramExecutableVk::addImageDescriptorSetDesc(vk::DescriptorSetLayoutDesc *descOut)
{ … }
void ProgramExecutableVk::addInputAttachmentDescriptorSetDesc(vk::DescriptorSetLayoutDesc *descOut)
{ … }
angle::Result ProgramExecutableVk::addTextureDescriptorSetDesc(
vk::Context *context,
const gl::ActiveTextureArray<TextureVk *> *activeTextures,
vk::DescriptorSetLayoutDesc *descOut)
{ … }
void ProgramExecutableVk::initializeWriteDescriptorDesc(vk::Context *context)
{ … }
ProgramTransformOptions ProgramExecutableVk::getTransformOptions(
ContextVk *contextVk,
const vk::GraphicsPipelineDesc &desc)
{ … }
angle::Result ProgramExecutableVk::initGraphicsShaderPrograms(
vk::Context *context,
ProgramTransformOptions transformOptions)
{ … }
angle::Result ProgramExecutableVk::initProgramThenCreateGraphicsPipeline(
vk::Context *context,
ProgramTransformOptions transformOptions,
vk::GraphicsPipelineSubset pipelineSubset,
vk::PipelineCacheAccess *pipelineCache,
PipelineSource source,
const vk::GraphicsPipelineDesc &desc,
const vk::RenderPass &compatibleRenderPass,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
{ … }
angle::Result ProgramExecutableVk::createGraphicsPipelineImpl(
vk::Context *context,
ProgramTransformOptions transformOptions,
vk::GraphicsPipelineSubset pipelineSubset,
vk::PipelineCacheAccess *pipelineCache,
PipelineSource source,
const vk::GraphicsPipelineDesc &desc,
const vk::RenderPass &compatibleRenderPass,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
{ … }
angle::Result ProgramExecutableVk::getGraphicsPipeline(ContextVk *contextVk,
vk::GraphicsPipelineSubset pipelineSubset,
const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
{ … }
angle::Result ProgramExecutableVk::createGraphicsPipeline(
ContextVk *contextVk,
vk::GraphicsPipelineSubset pipelineSubset,
vk::PipelineCacheAccess *pipelineCache,
PipelineSource source,
const vk::GraphicsPipelineDesc &desc,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
{ … }
angle::Result ProgramExecutableVk::linkGraphicsPipelineLibraries(
ContextVk *contextVk,
vk::PipelineCacheAccess *pipelineCache,
const vk::GraphicsPipelineDesc &desc,
vk::PipelineHelper *vertexInputPipeline,
vk::PipelineHelper *shadersPipeline,
vk::PipelineHelper *fragmentOutputPipeline,
const vk::GraphicsPipelineDesc **descPtrOut,
vk::PipelineHelper **pipelineOut)
{ … }
angle::Result ProgramExecutableVk::getOrCreateComputePipeline(
vk::Context *context,
vk::PipelineCacheAccess *pipelineCache,
PipelineSource source,
vk::PipelineRobustness pipelineRobustness,
vk::PipelineProtectedAccess pipelineProtectedAccess,
vk::PipelineHelper **pipelineOut)
{ … }
angle::Result ProgramExecutableVk::createPipelineLayout(
vk::Context *context,
PipelineLayoutCache *pipelineLayoutCache,
DescriptorSetLayoutCache *descriptorSetLayoutCache,
gl::ActiveTextureArray<TextureVk *> *activeTextures)
{ … }
angle::Result ProgramExecutableVk::initializeDescriptorPools(
vk::Context *context,
DescriptorSetLayoutCache *descriptorSetLayoutCache,
vk::DescriptorSetArray<vk::MetaDescriptorPool> *metaDescriptorPools)
{ … }
void ProgramExecutableVk::resolvePrecisionMismatch(const gl::ProgramMergedVaryings &mergedVaryings)
{ … }
angle::Result ProgramExecutableVk::getOrAllocateDescriptorSet(
vk::Context *context,
UpdateDescriptorSetsBuilder *updateBuilder,
vk::CommandBufferHelperCommon *commandBufferHelper,
const vk::DescriptorSetDescBuilder &descriptorSetDesc,
const vk::WriteDescriptorDescs &writeDescriptorDescs,
DescriptorSetIndex setIndex,
vk::SharedDescriptorSetCacheKey *newSharedCacheKeyOut)
{ … }
angle::Result ProgramExecutableVk::updateShaderResourcesDescriptorSet(
vk::Context *context,
UpdateDescriptorSetsBuilder *updateBuilder,
const vk::WriteDescriptorDescs &writeDescriptorDescs,
vk::CommandBufferHelperCommon *commandBufferHelper,
const vk::DescriptorSetDescBuilder &shaderResourcesDesc,
vk::SharedDescriptorSetCacheKey *newSharedCacheKeyOut)
{ … }
angle::Result ProgramExecutableVk::updateUniformsAndXfbDescriptorSet(
vk::Context *context,
UpdateDescriptorSetsBuilder *updateBuilder,
const vk::WriteDescriptorDescs &writeDescriptorDescs,
vk::CommandBufferHelperCommon *commandBufferHelper,
vk::BufferHelper *defaultUniformBuffer,
vk::DescriptorSetDescBuilder *uniformsAndXfbDesc,
vk::SharedDescriptorSetCacheKey *sharedCacheKeyOut)
{ … }
angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(
vk::Context *context,
const gl::ActiveTextureArray<TextureVk *> &textures,
const gl::SamplerBindingVector &samplers,
PipelineType pipelineType,
UpdateDescriptorSetsBuilder *updateBuilder,
vk::CommandBufferHelperCommon *commandBufferHelper,
const vk::DescriptorSetDesc &texturesDesc)
{ … }
template <typename CommandBufferT>
angle::Result ProgramExecutableVk::bindDescriptorSets(
vk::Context *context,
vk::CommandBufferHelperCommon *commandBufferHelper,
CommandBufferT *commandBuffer,
PipelineType pipelineType)
{ … }
template angle::Result ProgramExecutableVk::bindDescriptorSets<vk::priv::SecondaryCommandBuffer>(
vk::Context *context,
vk::CommandBufferHelperCommon *commandBufferHelper,
vk::priv::SecondaryCommandBuffer *commandBuffer,
PipelineType pipelineType);
template angle::Result ProgramExecutableVk::bindDescriptorSets<vk::VulkanSecondaryCommandBuffer>(
vk::Context *context,
vk::CommandBufferHelperCommon *commandBufferHelper,
vk::VulkanSecondaryCommandBuffer *commandBuffer,
PipelineType pipelineType);
void ProgramExecutableVk::setAllDefaultUniformsDirty()
{ … }
angle::Result ProgramExecutableVk::updateUniforms(
vk::Context *context,
UpdateDescriptorSetsBuilder *updateBuilder,
vk::CommandBufferHelperCommon *commandBufferHelper,
vk::BufferHelper *emptyBuffer,
vk::DynamicBuffer *defaultUniformStorage,
bool isTransformFeedbackActiveUnpaused,
TransformFeedbackVk *transformFeedbackVk)
{ … }
size_t ProgramExecutableVk::calcUniformUpdateRequiredSpace(
vk::Context *context,
gl::ShaderMap<VkDeviceSize> *uniformOffsets) const
{ … }
void ProgramExecutableVk::onProgramBind()
{ … }
angle::Result ProgramExecutableVk::resizeUniformBlockMemory(
vk::Context *context,
const gl::ShaderMap<size_t> &requiredBufferSize)
{ … }
template <typename T>
void ProgramExecutableVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) const
{ … }
void ProgramExecutableVk::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
{ … }
void ProgramExecutableVk::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
{ … }
void ProgramExecutableVk::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
{ … }
void ProgramExecutableVk::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
{ … }
void ProgramExecutableVk::setUniform1iv(GLint location, GLsizei count, const GLint *v)
{ … }
void ProgramExecutableVk::setUniform2iv(GLint location, GLsizei count, const GLint *v)
{ … }
void ProgramExecutableVk::setUniform3iv(GLint location, GLsizei count, const GLint *v)
{ … }
void ProgramExecutableVk::setUniform4iv(GLint location, GLsizei count, const GLint *v)
{ … }
void ProgramExecutableVk::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
{ … }
void ProgramExecutableVk::setUniform2uiv(GLint location, GLsizei count, const GLuint *v)
{ … }
void ProgramExecutableVk::setUniform3uiv(GLint location, GLsizei count, const GLuint *v)
{ … }
void ProgramExecutableVk::setUniform4uiv(GLint location, GLsizei count, const GLuint *v)
{ … }
void ProgramExecutableVk::setUniformMatrix2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix2x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix3x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix2x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix4x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix3x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::setUniformMatrix4x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{ … }
void ProgramExecutableVk::getUniformfv(const gl::Context *context,
GLint location,
GLfloat *params) const
{ … }
void ProgramExecutableVk::getUniformiv(const gl::Context *context,
GLint location,
GLint *params) const
{ … }
void ProgramExecutableVk::getUniformuiv(const gl::Context *context,
GLint location,
GLuint *params) const
{ … }
}