зеркало из https://github.com/AvaloniaUI/angle.git
Remove ProgramLinkedResources from ProgramExecutable.
Instead of storing the entire LinkedResources struct, we can keep it only for the duration of the linking calls. Refactoring change only. It sets the stage for more refactoring. This change also switches the link call to use LinkingState's ProgramLinkedResources directly to avoid the need to copy the varying packing or use a pointer. Bug: angleproject:4514 Bug: angleproject:5496 Change-Id: Iefea3c16a33213dc338cc54efaa7c3064ea6ae08 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2601403 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Родитель
e09e947d93
Коммит
92e7bc892a
|
@ -849,7 +849,7 @@ void LoadInterfaceBlock(BinaryInputStream *stream, InterfaceBlock *block)
|
|||
struct Program::LinkingState
|
||||
{
|
||||
std::shared_ptr<ProgramExecutable> linkedExecutable;
|
||||
std::unique_ptr<ProgramLinkedResources> resources;
|
||||
ProgramLinkedResources resources;
|
||||
egl::BlobCache::Key programHash;
|
||||
std::unique_ptr<rx::LinkEvent> linkEvent;
|
||||
bool linkingFromBinary;
|
||||
|
@ -1499,9 +1499,9 @@ void Program::bindFragmentOutputIndex(GLuint index, const char *name)
|
|||
mFragmentOutputIndexes.bindLocation(index, name);
|
||||
}
|
||||
|
||||
angle::Result Program::linkMergedVaryings(const Context *context,
|
||||
const ProgramExecutable &executable,
|
||||
const ProgramMergedVaryings &mergedVaryings)
|
||||
bool Program::linkMergedVaryings(const Context *context,
|
||||
const ProgramMergedVaryings &mergedVaryings,
|
||||
VaryingPacking *varyingPacking)
|
||||
{
|
||||
ShaderType tfStage =
|
||||
mState.mAttachedShaders[ShaderType::Geometry] ? ShaderType::Geometry : ShaderType::Vertex;
|
||||
|
@ -1510,19 +1510,19 @@ angle::Result Program::linkMergedVaryings(const Context *context,
|
|||
if (!linkValidateTransformFeedback(context->getClientVersion(), infoLog, mergedVaryings,
|
||||
tfStage, context->getCaps()))
|
||||
{
|
||||
return angle::Result::Stop;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!executable.mResources->varyingPacking.collectAndPackUserVaryings(
|
||||
if (!varyingPacking->collectAndPackUserVaryings(
|
||||
infoLog, mergedVaryings, mState.getTransformFeedbackVaryingNames(), isSeparable()))
|
||||
{
|
||||
return angle::Result::Stop;
|
||||
return false;
|
||||
}
|
||||
|
||||
gatherTransformFeedbackVaryings(mergedVaryings, tfStage);
|
||||
mState.updateTransformFeedbackStrides();
|
||||
|
||||
return angle::Result::Continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
angle::Result Program::link(const Context *context)
|
||||
|
@ -1593,19 +1593,21 @@ angle::Result Program::linkImpl(const Context *context)
|
|||
bool result = linkValidateShaders(infoLog);
|
||||
ASSERT(result);
|
||||
|
||||
std::unique_ptr<LinkingState> linkingState(new LinkingState());
|
||||
ProgramMergedVaryings mergedVaryings;
|
||||
ProgramLinkedResources &resources = linkingState->resources;
|
||||
|
||||
if (mState.mAttachedShaders[ShaderType::Compute])
|
||||
{
|
||||
mState.mExecutable->mResources.reset(new ProgramLinkedResources(
|
||||
0, PackMode::ANGLE_RELAXED, &mState.mExecutable->mUniformBlocks,
|
||||
&mState.mExecutable->mUniforms, &mState.mExecutable->mComputeShaderStorageBlocks,
|
||||
&mState.mBufferVariables, &mState.mExecutable->mAtomicCounterBuffers));
|
||||
resources.varyingPacking.init(0, PackMode::ANGLE_RELAXED);
|
||||
resources.init(&mState.mExecutable->mUniformBlocks, &mState.mExecutable->mUniforms,
|
||||
&mState.mExecutable->mComputeShaderStorageBlocks, &mState.mBufferVariables,
|
||||
&mState.mExecutable->mAtomicCounterBuffers);
|
||||
|
||||
GLuint combinedImageUniforms = 0u;
|
||||
if (!linkUniforms(context->getCaps(), context->getClientVersion(), infoLog,
|
||||
mState.mUniformLocationBindings, &combinedImageUniforms,
|
||||
&mState.mExecutable->getResources().unusedUniforms))
|
||||
&resources.unusedUniforms))
|
||||
{
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
@ -1634,9 +1636,8 @@ angle::Result Program::linkImpl(const Context *context)
|
|||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
InitUniformBlockLinker(mState, &mState.mExecutable->getResources().uniformBlockLinker);
|
||||
InitShaderStorageBlockLinker(mState,
|
||||
&mState.mExecutable->getResources().shaderStorageBlockLinker);
|
||||
InitUniformBlockLinker(mState, &resources.uniformBlockLinker);
|
||||
InitShaderStorageBlockLinker(mState, &resources.shaderStorageBlockLinker);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1653,11 +1654,11 @@ angle::Result Program::linkImpl(const Context *context)
|
|||
packMode = PackMode::WEBGL_STRICT;
|
||||
}
|
||||
|
||||
mState.mExecutable->mResources.reset(new ProgramLinkedResources(
|
||||
static_cast<GLuint>(data.getCaps().maxVaryingVectors), packMode,
|
||||
&mState.mExecutable->mUniformBlocks, &mState.mExecutable->mUniforms,
|
||||
&mState.mExecutable->mGraphicsShaderStorageBlocks, &mState.mBufferVariables,
|
||||
&mState.mExecutable->mAtomicCounterBuffers));
|
||||
resources.varyingPacking.init(static_cast<GLuint>(data.getCaps().maxVaryingVectors),
|
||||
packMode);
|
||||
resources.init(&mState.mExecutable->mUniformBlocks, &mState.mExecutable->mUniforms,
|
||||
&mState.mExecutable->mGraphicsShaderStorageBlocks, &mState.mBufferVariables,
|
||||
&mState.mExecutable->mAtomicCounterBuffers);
|
||||
|
||||
if (!linkAttributes(context, infoLog))
|
||||
{
|
||||
|
@ -1672,7 +1673,7 @@ angle::Result Program::linkImpl(const Context *context)
|
|||
GLuint combinedImageUniforms = 0u;
|
||||
if (!linkUniforms(context->getCaps(), context->getClientVersion(), infoLog,
|
||||
mState.mUniformLocationBindings, &combinedImageUniforms,
|
||||
&mState.mExecutable->getResources().unusedUniforms))
|
||||
&resources.unusedUniforms))
|
||||
{
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
@ -1714,9 +1715,8 @@ angle::Result Program::linkImpl(const Context *context)
|
|||
mState.mSpecConstUsageBits |= fragmentShader->getSpecConstUsageBits();
|
||||
}
|
||||
|
||||
InitUniformBlockLinker(mState, &mState.mExecutable->getResources().uniformBlockLinker);
|
||||
InitShaderStorageBlockLinker(mState,
|
||||
&mState.mExecutable->getResources().shaderStorageBlockLinker);
|
||||
InitUniformBlockLinker(mState, &resources.uniformBlockLinker);
|
||||
InitShaderStorageBlockLinker(mState, &resources.shaderStorageBlockLinker);
|
||||
|
||||
ProgramPipeline *programPipeline = context->getState().getProgramPipeline();
|
||||
if (programPipeline && programPipeline->usesShaderProgram(id()))
|
||||
|
@ -1727,16 +1727,18 @@ angle::Result Program::linkImpl(const Context *context)
|
|||
{
|
||||
mergedVaryings = getMergedVaryings();
|
||||
}
|
||||
ANGLE_TRY(linkMergedVaryings(context, *mState.mExecutable, mergedVaryings));
|
||||
if (!linkMergedVaryings(context, mergedVaryings, &resources.varyingPacking))
|
||||
{
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
}
|
||||
|
||||
updateLinkedShaderStages();
|
||||
|
||||
mLinkingState.reset(new LinkingState());
|
||||
mLinkingState = std::move(linkingState);
|
||||
mLinkingState->linkingFromBinary = false;
|
||||
mLinkingState->programHash = programHash;
|
||||
mLinkingState->linkEvent =
|
||||
mProgram->link(context, mState.mExecutable->getResources(), infoLog, mergedVaryings);
|
||||
mLinkingState->linkEvent = mProgram->link(context, resources, infoLog, mergedVaryings);
|
||||
|
||||
// Must be after mProgram->link() to avoid misleading the linker about output variables.
|
||||
mState.updateProgramInterfaceInputs();
|
||||
|
|
|
@ -500,9 +500,9 @@ class Program final : public LabeledObject, public angle::Subject
|
|||
void bindFragmentOutputLocation(GLuint index, const char *name);
|
||||
void bindFragmentOutputIndex(GLuint index, const char *name);
|
||||
|
||||
angle::Result linkMergedVaryings(const Context *context,
|
||||
const ProgramExecutable &executable,
|
||||
const ProgramMergedVaryings &mergedVaryings);
|
||||
bool linkMergedVaryings(const Context *context,
|
||||
const ProgramMergedVaryings &mergedVaryings,
|
||||
VaryingPacking *varyingPacking);
|
||||
|
||||
// KHR_parallel_shader_compile
|
||||
// Try to link the program asynchrously. As a result, background threads may be launched to
|
||||
|
|
|
@ -297,12 +297,6 @@ class ProgramExecutable final : public angle::Subject
|
|||
|
||||
GLuint getUniformIndexFromImageIndex(GLuint imageIndex) const;
|
||||
|
||||
gl::ProgramLinkedResources &getResources() const
|
||||
{
|
||||
ASSERT(mResources);
|
||||
return *mResources;
|
||||
}
|
||||
|
||||
void saveLinkedStateInfo(const ProgramState &state);
|
||||
std::vector<sh::ShaderVariable> getLinkedOutputVaryings(ShaderType shaderType)
|
||||
{
|
||||
|
@ -412,8 +406,6 @@ class ProgramExecutable final : public angle::Subject
|
|||
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedOutputVaryings;
|
||||
ShaderMap<std::vector<sh::ShaderVariable>> mLinkedInputVaryings;
|
||||
ShaderMap<int> mLinkedShaderVersions;
|
||||
// TODO: http://anglebug.com/4514: Remove
|
||||
std::unique_ptr<gl::ProgramLinkedResources> mResources;
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
@ -1051,12 +1051,16 @@ bool UniformLinker::checkMaxCombinedAtomicCounters(const Caps &caps, InfoLog &in
|
|||
}
|
||||
|
||||
// InterfaceBlockLinker implementation.
|
||||
InterfaceBlockLinker::InterfaceBlockLinker(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut)
|
||||
: mShaderBlocks({}), mBlocksOut(blocksOut), mUnusedInterfaceBlocksOut(unusedInterfaceBlocksOut)
|
||||
{}
|
||||
InterfaceBlockLinker::InterfaceBlockLinker() = default;
|
||||
|
||||
InterfaceBlockLinker::~InterfaceBlockLinker() {}
|
||||
InterfaceBlockLinker::~InterfaceBlockLinker() = default;
|
||||
|
||||
void InterfaceBlockLinker::init(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut)
|
||||
{
|
||||
mBlocksOut = blocksOut;
|
||||
mUnusedInterfaceBlocksOut = unusedInterfaceBlocksOut;
|
||||
}
|
||||
|
||||
void InterfaceBlockLinker::addShaderBlocks(ShaderType shaderType,
|
||||
const std::vector<sh::InterfaceBlock> *blocks)
|
||||
|
@ -1181,14 +1185,18 @@ void InterfaceBlockLinker::defineInterfaceBlock(const GetBlockSizeFunc &getBlock
|
|||
}
|
||||
|
||||
// UniformBlockLinker implementation.
|
||||
UniformBlockLinker::UniformBlockLinker(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut)
|
||||
: InterfaceBlockLinker(blocksOut, unusedInterfaceBlocksOut), mUniformsOut(uniformsOut)
|
||||
{}
|
||||
UniformBlockLinker::UniformBlockLinker() = default;
|
||||
|
||||
UniformBlockLinker::~UniformBlockLinker() {}
|
||||
|
||||
void UniformBlockLinker::init(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut)
|
||||
{
|
||||
InterfaceBlockLinker::init(blocksOut, unusedInterfaceBlocksOut);
|
||||
mUniformsOut = uniformsOut;
|
||||
}
|
||||
|
||||
size_t UniformBlockLinker::getCurrentBlockMemberIndex() const
|
||||
{
|
||||
return mUniformsOut->size();
|
||||
|
@ -1206,15 +1214,17 @@ sh::ShaderVariableVisitor *UniformBlockLinker::getVisitor(
|
|||
}
|
||||
|
||||
// ShaderStorageBlockLinker implementation.
|
||||
ShaderStorageBlockLinker::ShaderStorageBlockLinker(
|
||||
std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut)
|
||||
: InterfaceBlockLinker(blocksOut, unusedInterfaceBlocksOut),
|
||||
mBufferVariablesOut(bufferVariablesOut)
|
||||
{}
|
||||
ShaderStorageBlockLinker::ShaderStorageBlockLinker() = default;
|
||||
|
||||
ShaderStorageBlockLinker::~ShaderStorageBlockLinker() {}
|
||||
ShaderStorageBlockLinker::~ShaderStorageBlockLinker() = default;
|
||||
|
||||
void ShaderStorageBlockLinker::init(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut)
|
||||
{
|
||||
InterfaceBlockLinker::init(blocksOut, unusedInterfaceBlocksOut);
|
||||
mBufferVariablesOut = bufferVariablesOut;
|
||||
}
|
||||
|
||||
size_t ShaderStorageBlockLinker::getCurrentBlockMemberIndex() const
|
||||
{
|
||||
|
@ -1233,12 +1243,14 @@ sh::ShaderVariableVisitor *ShaderStorageBlockLinker::getVisitor(
|
|||
}
|
||||
|
||||
// AtomicCounterBufferLinker implementation.
|
||||
AtomicCounterBufferLinker::AtomicCounterBufferLinker(
|
||||
std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut)
|
||||
: mAtomicCounterBuffersOut(atomicCounterBuffersOut)
|
||||
{}
|
||||
AtomicCounterBufferLinker::AtomicCounterBufferLinker() = default;
|
||||
|
||||
AtomicCounterBufferLinker::~AtomicCounterBufferLinker() {}
|
||||
AtomicCounterBufferLinker::~AtomicCounterBufferLinker() = default;
|
||||
|
||||
void AtomicCounterBufferLinker::init(std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut)
|
||||
{
|
||||
mAtomicCounterBuffersOut = atomicCounterBuffersOut;
|
||||
}
|
||||
|
||||
void AtomicCounterBufferLinker::link(const std::map<int, unsigned int> &sizeMap) const
|
||||
{
|
||||
|
@ -1250,22 +1262,22 @@ void AtomicCounterBufferLinker::link(const std::map<int, unsigned int> &sizeMap)
|
|||
}
|
||||
}
|
||||
|
||||
ProgramLinkedResources::ProgramLinkedResources(
|
||||
GLuint maxVaryingVectors,
|
||||
PackMode packMode,
|
||||
std::vector<InterfaceBlock> *uniformBlocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<InterfaceBlock> *shaderStorageBlocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut)
|
||||
: varyingPacking(maxVaryingVectors, packMode),
|
||||
uniformBlockLinker(uniformBlocksOut, uniformsOut, &unusedInterfaceBlocks),
|
||||
shaderStorageBlockLinker(shaderStorageBlocksOut, bufferVariablesOut, &unusedInterfaceBlocks),
|
||||
atomicCounterBufferLinker(atomicCounterBuffersOut)
|
||||
{}
|
||||
ProgramLinkedResources::ProgramLinkedResources() = default;
|
||||
|
||||
ProgramLinkedResources::~ProgramLinkedResources() = default;
|
||||
|
||||
void ProgramLinkedResources::init(std::vector<InterfaceBlock> *uniformBlocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<InterfaceBlock> *shaderStorageBlocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut)
|
||||
{
|
||||
uniformBlockLinker.init(uniformBlocksOut, uniformsOut, &unusedInterfaceBlocks);
|
||||
shaderStorageBlockLinker.init(shaderStorageBlocksOut, bufferVariablesOut,
|
||||
&unusedInterfaceBlocks);
|
||||
atomicCounterBufferLinker.init(atomicCounterBuffersOut);
|
||||
}
|
||||
|
||||
void ProgramLinkedResourcesLinker::linkResources(const ProgramState &programState,
|
||||
const ProgramLinkedResources &resources) const
|
||||
{
|
||||
|
@ -1294,7 +1306,7 @@ void ProgramLinkedResourcesLinker::linkResources(const ProgramState &programStat
|
|||
// Link uniform interface blocks.
|
||||
resources.uniformBlockLinker.linkBlocks(getUniformBlockSize, getUniformBlockMemberInfo);
|
||||
|
||||
// Gather storage bufer interface block info.
|
||||
// Gather storage buffer interface block info.
|
||||
InterfaceBlockInfo shaderStorageBlockInfo(mCustomEncoderFactory);
|
||||
for (const ShaderType shaderType : AllShaderTypes())
|
||||
{
|
||||
|
|
|
@ -112,8 +112,9 @@ class InterfaceBlockLinker : angle::NonCopyable
|
|||
const GetBlockMemberInfoFunc &getMemberInfo) const;
|
||||
|
||||
protected:
|
||||
InterfaceBlockLinker(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut);
|
||||
InterfaceBlockLinker();
|
||||
void init(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut);
|
||||
void defineInterfaceBlock(const GetBlockSizeFunc &getBlockSize,
|
||||
const GetBlockMemberInfoFunc &getMemberInfo,
|
||||
const sh::InterfaceBlock &interfaceBlock,
|
||||
|
@ -121,26 +122,28 @@ class InterfaceBlockLinker : angle::NonCopyable
|
|||
|
||||
virtual size_t getCurrentBlockMemberIndex() const = 0;
|
||||
|
||||
ShaderMap<const std::vector<sh::InterfaceBlock> *> mShaderBlocks;
|
||||
|
||||
std::vector<InterfaceBlock> *mBlocksOut;
|
||||
std::vector<std::string> *mUnusedInterfaceBlocksOut;
|
||||
|
||||
virtual sh::ShaderVariableVisitor *getVisitor(const GetBlockMemberInfoFunc &getMemberInfo,
|
||||
const std::string &namePrefix,
|
||||
const std::string &mappedNamePrefix,
|
||||
ShaderType shaderType,
|
||||
int blockIndex) const = 0;
|
||||
|
||||
ShaderMap<const std::vector<sh::InterfaceBlock> *> mShaderBlocks = {};
|
||||
|
||||
std::vector<InterfaceBlock> *mBlocksOut = nullptr;
|
||||
std::vector<std::string> *mUnusedInterfaceBlocksOut = nullptr;
|
||||
};
|
||||
|
||||
class UniformBlockLinker final : public InterfaceBlockLinker
|
||||
{
|
||||
public:
|
||||
UniformBlockLinker(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut);
|
||||
UniformBlockLinker();
|
||||
~UniformBlockLinker() override;
|
||||
|
||||
void init(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut);
|
||||
|
||||
private:
|
||||
size_t getCurrentBlockMemberIndex() const override;
|
||||
|
||||
|
@ -150,17 +153,19 @@ class UniformBlockLinker final : public InterfaceBlockLinker
|
|||
ShaderType shaderType,
|
||||
int blockIndex) const override;
|
||||
|
||||
std::vector<LinkedUniform> *mUniformsOut;
|
||||
std::vector<LinkedUniform> *mUniformsOut = nullptr;
|
||||
};
|
||||
|
||||
class ShaderStorageBlockLinker final : public InterfaceBlockLinker
|
||||
{
|
||||
public:
|
||||
ShaderStorageBlockLinker(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut);
|
||||
ShaderStorageBlockLinker();
|
||||
~ShaderStorageBlockLinker() override;
|
||||
|
||||
void init(std::vector<InterfaceBlock> *blocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<std::string> *unusedInterfaceBlocksOut);
|
||||
|
||||
private:
|
||||
size_t getCurrentBlockMemberIndex() const override;
|
||||
|
||||
|
@ -170,19 +175,20 @@ class ShaderStorageBlockLinker final : public InterfaceBlockLinker
|
|||
ShaderType shaderType,
|
||||
int blockIndex) const override;
|
||||
|
||||
std::vector<BufferVariable> *mBufferVariablesOut;
|
||||
std::vector<BufferVariable> *mBufferVariablesOut = nullptr;
|
||||
};
|
||||
|
||||
class AtomicCounterBufferLinker final : angle::NonCopyable
|
||||
{
|
||||
public:
|
||||
AtomicCounterBufferLinker(std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut);
|
||||
AtomicCounterBufferLinker();
|
||||
~AtomicCounterBufferLinker();
|
||||
|
||||
void init(std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut);
|
||||
void link(const std::map<int, unsigned int> &sizeMap) const;
|
||||
|
||||
private:
|
||||
std::vector<AtomicCounterBuffer> *mAtomicCounterBuffersOut;
|
||||
std::vector<AtomicCounterBuffer> *mAtomicCounterBuffersOut = nullptr;
|
||||
};
|
||||
|
||||
// The link operation is responsible for finishing the link of uniform and interface blocks.
|
||||
|
@ -206,15 +212,15 @@ struct UnusedUniform
|
|||
|
||||
struct ProgramLinkedResources
|
||||
{
|
||||
ProgramLinkedResources(GLuint maxVaryingVectors,
|
||||
PackMode packMode,
|
||||
std::vector<InterfaceBlock> *uniformBlocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<InterfaceBlock> *shaderStorageBlocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut);
|
||||
ProgramLinkedResources();
|
||||
~ProgramLinkedResources();
|
||||
|
||||
void init(std::vector<InterfaceBlock> *uniformBlocksOut,
|
||||
std::vector<LinkedUniform> *uniformsOut,
|
||||
std::vector<InterfaceBlock> *shaderStorageBlocksOut,
|
||||
std::vector<BufferVariable> *bufferVariablesOut,
|
||||
std::vector<AtomicCounterBuffer> *atomicCounterBuffersOut);
|
||||
|
||||
VaryingPacking varyingPacking;
|
||||
UniformBlockLinker uniformBlockLinker;
|
||||
ShaderStorageBlockLinker shaderStorageBlockLinker;
|
||||
|
|
|
@ -537,6 +537,7 @@ angle::Result ProgramPipeline::link(const Context *context)
|
|||
}
|
||||
|
||||
ProgramMergedVaryings mergedVaryings;
|
||||
VaryingPacking varyingPacking;
|
||||
|
||||
if (!getExecutable().isCompute())
|
||||
{
|
||||
|
@ -571,20 +572,25 @@ angle::Result ProgramPipeline::link(const Context *context)
|
|||
|
||||
GLuint maxVaryingVectors =
|
||||
static_cast<GLuint>(context->getState().getCaps().maxVaryingVectors);
|
||||
VaryingPacking varyingPacking(maxVaryingVectors, packMode);
|
||||
varyingPacking.init(maxVaryingVectors, packMode);
|
||||
|
||||
mergedVaryings = getMergedVaryings();
|
||||
for (ShaderType shaderType : getExecutable().getLinkedShaderStages())
|
||||
{
|
||||
Program *program = mState.mPrograms[shaderType];
|
||||
ASSERT(program);
|
||||
program->getExecutable().getResources().varyingPacking.reset();
|
||||
ANGLE_TRY(
|
||||
program->linkMergedVaryings(context, program->getExecutable(), mergedVaryings));
|
||||
if (!program->linkMergedVaryings(context, mergedVaryings, &varyingPacking))
|
||||
{
|
||||
return angle::Result::Stop;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
varyingPacking.init(0, gl::PackMode::ANGLE_RELAXED);
|
||||
}
|
||||
|
||||
ANGLE_TRY(getImplementation()->link(context, mergedVaryings));
|
||||
ANGLE_TRY(getImplementation()->link(context, mergedVaryings, varyingPacking));
|
||||
|
||||
mState.mIsLinked = true;
|
||||
|
||||
|
|
|
@ -167,12 +167,16 @@ PackedVarying &PackedVarying::operator=(PackedVarying &&other)
|
|||
}
|
||||
|
||||
// Implementation of VaryingPacking
|
||||
VaryingPacking::VaryingPacking(GLuint maxVaryingVectors, PackMode packMode)
|
||||
: mRegisterMap(maxVaryingVectors), mPackMode(packMode)
|
||||
{}
|
||||
VaryingPacking::VaryingPacking() = default;
|
||||
|
||||
VaryingPacking::~VaryingPacking() = default;
|
||||
|
||||
void VaryingPacking::init(GLuint maxVaryingVectors, PackMode packMode)
|
||||
{
|
||||
mRegisterMap.resize(maxVaryingVectors);
|
||||
mPackMode = packMode;
|
||||
}
|
||||
|
||||
void VaryingPacking::reset()
|
||||
{
|
||||
clearRegisterMap();
|
||||
|
|
|
@ -202,9 +202,11 @@ enum class PackMode
|
|||
class VaryingPacking final : angle::NonCopyable
|
||||
{
|
||||
public:
|
||||
VaryingPacking(GLuint maxVaryingVectors, PackMode packMode);
|
||||
VaryingPacking();
|
||||
~VaryingPacking();
|
||||
|
||||
void init(GLuint maxVaryingVectors, PackMode packMode);
|
||||
|
||||
bool packUserVaryings(gl::InfoLog &infoLog, const std::vector<PackedVarying> &packedVaryings);
|
||||
|
||||
bool collectAndPackUserVaryings(gl::InfoLog &infoLog,
|
||||
|
@ -274,7 +276,7 @@ class VaryingPacking final : angle::NonCopyable
|
|||
ShaderMap<std::vector<std::string>> mInactiveVaryingMappedNames;
|
||||
ShaderMap<std::vector<std::string>> mActiveOutputBuiltIns;
|
||||
|
||||
PackMode mPackMode;
|
||||
PackMode mPackMode = PackMode::ANGLE_RELAXED;
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
@ -46,14 +46,16 @@ class VaryingPackingTest : public ::testing::TestWithParam<GLuint>
|
|||
// Uses the "relaxed" ANGLE packing mode.
|
||||
bool packVaryings(GLuint maxVaryings, const std::vector<sh::ShaderVariable> &shVaryings)
|
||||
{
|
||||
VaryingPacking varyingPacking(maxVaryings, PackMode::ANGLE_RELAXED);
|
||||
VaryingPacking varyingPacking;
|
||||
varyingPacking.init(maxVaryings, PackMode::ANGLE_RELAXED);
|
||||
return testVaryingPacking(shVaryings, &varyingPacking);
|
||||
}
|
||||
|
||||
// Uses the stricter WebGL style packing rules.
|
||||
bool packVaryingsStrict(GLuint maxVaryings, const std::vector<sh::ShaderVariable> &shVaryings)
|
||||
{
|
||||
VaryingPacking varyingPacking(maxVaryings, PackMode::WEBGL_STRICT);
|
||||
VaryingPacking varyingPacking;
|
||||
varyingPacking.init(maxVaryings, PackMode::WEBGL_STRICT);
|
||||
return testVaryingPacking(shVaryings, &varyingPacking);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ namespace rx
|
|||
{
|
||||
|
||||
angle::Result ProgramPipelineImpl::link(const gl::Context *context,
|
||||
const gl::ProgramMergedVaryings &mergedVaryings)
|
||||
const gl::ProgramMergedVaryings &mergedVaryings,
|
||||
const gl::VaryingPacking &varyingPacking)
|
||||
{
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ class ProgramPipelineImpl : public angle::NonCopyable
|
|||
virtual void destroy(const gl::Context *context) {}
|
||||
|
||||
virtual angle::Result link(const gl::Context *context,
|
||||
const gl::ProgramMergedVaryings &mergedVaryings);
|
||||
const gl::ProgramMergedVaryings &mergedVaryings,
|
||||
const gl::VaryingPacking &varyingPacking);
|
||||
|
||||
const gl::ProgramPipelineState &getState() const { return mState; }
|
||||
|
||||
|
|
|
@ -576,7 +576,7 @@ void AssignOutputLocations(const gl::ProgramExecutable &programExecutable,
|
|||
}
|
||||
|
||||
void AssignVaryingLocations(const GlslangSourceOptions &options,
|
||||
const gl::ProgramExecutable &programExecutable,
|
||||
const gl::VaryingPacking &varyingPacking,
|
||||
const gl::ShaderType shaderType,
|
||||
const gl::ShaderType frontShaderType,
|
||||
GlslangProgramInterfaceInfo *programInterfaceInfo,
|
||||
|
@ -596,8 +596,7 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
|
|||
}
|
||||
|
||||
// Assign varying locations.
|
||||
for (const gl::PackedVaryingRegister &varyingReg :
|
||||
programExecutable.getResources().varyingPacking.getRegisterList())
|
||||
for (const gl::PackedVaryingRegister &varyingReg : varyingPacking.getRegisterList())
|
||||
{
|
||||
if (!IsFirstRegisterOfVarying(varyingReg, false))
|
||||
{
|
||||
|
@ -637,7 +636,7 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
|
|||
|
||||
// Add an entry for inactive varyings.
|
||||
const gl::ShaderMap<std::vector<std::string>> &inactiveVaryingMappedNames =
|
||||
programExecutable.getResources().varyingPacking.getInactiveVaryingMappedNames();
|
||||
varyingPacking.getInactiveVaryingMappedNames();
|
||||
for (const std::string &varyingName : inactiveVaryingMappedNames[shaderType])
|
||||
{
|
||||
ASSERT(!gl::IsBuiltInName(varyingName));
|
||||
|
@ -657,7 +656,7 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
|
|||
// Add an entry for active builtins varyings. This will allow inactive builtins, such as
|
||||
// gl_PointSize, gl_ClipDistance etc to be removed.
|
||||
const gl::ShaderMap<std::vector<std::string>> &activeOutputBuiltIns =
|
||||
programExecutable.getResources().varyingPacking.getActiveOutputBuiltIns();
|
||||
varyingPacking.getActiveOutputBuiltIns();
|
||||
for (const std::string &builtInName : activeOutputBuiltIns[shaderType])
|
||||
{
|
||||
ASSERT(gl::IsBuiltInName(builtInName));
|
||||
|
@ -690,6 +689,7 @@ void AssignVaryingLocations(const GlslangSourceOptions &options,
|
|||
// Calculates XFB layout qualifier arguments for each tranform feedback varying. Stores calculated
|
||||
// values for the SPIR-V transformation.
|
||||
void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramExecutable &programExecutable,
|
||||
const gl::VaryingPacking &varyingPacking,
|
||||
uint32_t locationsUsedForXfbExtension,
|
||||
const gl::ShaderType shaderType,
|
||||
ShaderInterfaceVariableInfoMap *variableInfoMapOut)
|
||||
|
@ -788,8 +788,7 @@ void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramExecutable &pro
|
|||
// other hand, we need to decorate the exact member that is captured (as whole-block
|
||||
// capture is not supported).
|
||||
const gl::PackedVarying *originalVarying = nullptr;
|
||||
for (const gl::PackedVaryingRegister &varyingReg :
|
||||
programExecutable.getResources().varyingPacking.getRegisterList())
|
||||
for (const gl::PackedVaryingRegister &varyingReg : varyingPacking.getRegisterList())
|
||||
{
|
||||
if (!IsFirstRegisterOfVarying(varyingReg, tfVarying.isShaderIOBlock))
|
||||
{
|
||||
|
@ -3806,6 +3805,7 @@ void GlslangGenTransformFeedbackEmulationOutputs(const GlslangSourceOptions &opt
|
|||
|
||||
void GlslangAssignLocations(const GlslangSourceOptions &options,
|
||||
const gl::ProgramExecutable &programExecutable,
|
||||
const gl::VaryingPacking &varyingPacking,
|
||||
const gl::ShaderType shaderType,
|
||||
const gl::ShaderType frontShaderType,
|
||||
GlslangProgramInterfaceInfo *programInterfaceInfo,
|
||||
|
@ -3828,7 +3828,7 @@ void GlslangAssignLocations(const GlslangSourceOptions &options,
|
|||
if (!programExecutable.hasLinkedShaderStage(gl::ShaderType::Compute))
|
||||
{
|
||||
// Assign varying locations.
|
||||
AssignVaryingLocations(options, programExecutable, shaderType, frontShaderType,
|
||||
AssignVaryingLocations(options, varyingPacking, shaderType, frontShaderType,
|
||||
programInterfaceInfo, variableInfoMapOut);
|
||||
|
||||
if (!programExecutable.getLinkedTransformFeedbackVaryings().empty() &&
|
||||
|
@ -3836,8 +3836,8 @@ void GlslangAssignLocations(const GlslangSourceOptions &options,
|
|||
(shaderType == programExecutable.getLinkedTransformFeedbackStage()))
|
||||
{
|
||||
AssignTransformFeedbackExtensionQualifiers(
|
||||
programExecutable, programInterfaceInfo->locationsUsedForXfbExtension, shaderType,
|
||||
variableInfoMapOut);
|
||||
programExecutable, varyingPacking,
|
||||
programInterfaceInfo->locationsUsedForXfbExtension, shaderType, variableInfoMapOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3910,8 +3910,9 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options,
|
|||
|
||||
for (const gl::ShaderType shaderType : programState.getExecutable().getLinkedShaderStages())
|
||||
{
|
||||
GlslangAssignLocations(options, programState.getExecutable(), shaderType, frontShaderType,
|
||||
programInterfaceInfo, variableInfoMapOut);
|
||||
GlslangAssignLocations(options, programState.getExecutable(), resources.varyingPacking,
|
||||
shaderType, frontShaderType, programInterfaceInfo,
|
||||
variableInfoMapOut);
|
||||
|
||||
frontShaderType = shaderType;
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ void GlslangGenTransformFeedbackEmulationOutputs(
|
|||
|
||||
void GlslangAssignLocations(const GlslangSourceOptions &options,
|
||||
const gl::ProgramExecutable &programExecutable,
|
||||
const gl::VaryingPacking &varyingPacking,
|
||||
const gl::ShaderType shaderType,
|
||||
const gl::ShaderType frontShaderType,
|
||||
GlslangProgramInterfaceInfo *programInterfaceInfo,
|
||||
|
|
|
@ -432,9 +432,9 @@ void GlslangGetShaderSource(const gl::ProgramState &programState,
|
|||
options, programState, &xfbOnlyInterfaceInfo, xfbOnlyShaderSourceOut,
|
||||
xfbOnlyVSVariableInfoMapOut);
|
||||
|
||||
GlslangAssignLocations(options, programState.getExecutable(), gl::ShaderType::Vertex,
|
||||
gl::ShaderType::InvalidEnum, &xfbOnlyInterfaceInfo,
|
||||
xfbOnlyVSVariableInfoMapOut);
|
||||
GlslangAssignLocations(options, programState.getExecutable(), resources.varyingPacking,
|
||||
gl::ShaderType::Vertex, gl::ShaderType::InvalidEnum,
|
||||
&xfbOnlyInterfaceInfo, xfbOnlyVSVariableInfoMapOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ void ProgramPipelineVk::fillProgramStateMap(
|
|||
}
|
||||
|
||||
angle::Result ProgramPipelineVk::link(const gl::Context *glContext,
|
||||
const gl::ProgramMergedVaryings &mergedVaryings)
|
||||
const gl::ProgramMergedVaryings &mergedVaryings,
|
||||
const gl::VaryingPacking &varyingPacking)
|
||||
{
|
||||
ContextVk *contextVk = vk::GetImpl(glContext);
|
||||
const gl::State &glState = glContext->getState();
|
||||
|
@ -82,8 +83,8 @@ angle::Result ProgramPipelineVk::link(const gl::Context *glContext,
|
|||
glslangProgramInterfaceInfo.locationsUsedForXfbExtension =
|
||||
programProgramInterfaceInfo.locationsUsedForXfbExtension;
|
||||
|
||||
GlslangAssignLocations(options, glProgram->getState().getExecutable(), shaderType,
|
||||
frontShaderType, &glslangProgramInterfaceInfo,
|
||||
GlslangAssignLocations(options, glProgram->getState().getExecutable(), varyingPacking,
|
||||
shaderType, frontShaderType, &glslangProgramInterfaceInfo,
|
||||
&mExecutable.mVariableInfoMap);
|
||||
frontShaderType = shaderType;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ class ProgramPipelineVk : public ProgramPipelineImpl
|
|||
gl::ShaderMap<const gl::ProgramState *> *programStatesOut);
|
||||
|
||||
angle::Result link(const gl::Context *glContext,
|
||||
const gl::ProgramMergedVaryings &mergedVaryings) override;
|
||||
const gl::ProgramMergedVaryings &mergedVaryings,
|
||||
const gl::VaryingPacking &varyingPacking) override;
|
||||
|
||||
angle::Result updateUniforms(ContextVk *contextVk);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче