Cleanup POD struct usage to make them more consistent

In recent months, I have made many CLs to wrap various data structures
into a trivially copy-able struct. Some of them uses different
terminology. This CL replaces all of these to use a consistent name
"pod" in the struct, and "mPod" in a class.

This CL also turns ActiveVariable methods into macros to remove the code
duplication.

This CL also moves ProgramInput/ProgramOutput struct implementations
from Program.cpp to ProgramExecutable.cpp

Bug: b/275102061
Change-Id: Ia2a4210a9ea633f3d323bebe674ee74f8b90b363
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4877335
Commit-Queue: Charlie Lao <cclao@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Roman Lavrov <romanl@google.com>
This commit is contained in:
Charlie Lao
2023-09-19 14:08:14 -07:00
committed by Angle LUCI CQ
parent 9ca025d2b5
commit 8fcd4a50ab
16 changed files with 589 additions and 706 deletions

View File

@@ -316,68 +316,6 @@ bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock)
return interfaceBlock.active || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED;
}
// ProgramInput implementation.
ProgramInput::ProgramInput() {}
ProgramInput::ProgramInput(const sh::ShaderVariable &var)
{
ASSERT(!var.isStruct());
name = var.name;
mappedName = var.mappedName;
SetBitField(basicDataTypeStruct.type, var.type);
basicDataTypeStruct.location = var.hasImplicitLocation ? -1 : var.location;
SetBitField(basicDataTypeStruct.interpolation, var.interpolation);
basicDataTypeStruct.flagBitsAsUByte = 0;
basicDataTypeStruct.flagBits.active = var.active;
basicDataTypeStruct.flagBits.isPatch = var.isPatch;
basicDataTypeStruct.flagBits.hasImplicitLocation = var.hasImplicitLocation;
basicDataTypeStruct.flagBits.isArray = var.isArray();
basicDataTypeStruct.flagBits.isBuiltIn = IsBuiltInName(var.name);
SetBitField(basicDataTypeStruct.basicTypeElementCount, var.getBasicTypeElementCount());
basicDataTypeStruct.id = var.id;
SetBitField(basicDataTypeStruct.arraySizeProduct, var.getArraySizeProduct());
}
ProgramInput::ProgramInput(const ProgramInput &other)
{
*this = other;
}
ProgramInput &ProgramInput::operator=(const ProgramInput &rhs)
{
if (this != &rhs)
{
name = rhs.name;
mappedName = rhs.mappedName;
basicDataTypeStruct = rhs.basicDataTypeStruct;
}
return *this;
}
// ProgramOutput implementation.
ProgramOutput::ProgramOutput(const sh::ShaderVariable &var)
{
name = var.name;
mappedName = var.mappedName;
podStruct.type = var.type;
podStruct.location = var.location;
podStruct.index = var.index;
podStruct.id = var.id;
SetBitField(podStruct.outermostArraySize, var.getOutermostArraySize());
SetBitField(podStruct.basicTypeElementCount, var.getBasicTypeElementCount());
SetBitField(podStruct.isPatch, var.isPatch);
SetBitField(podStruct.yuv, var.yuv);
SetBitField(podStruct.isBuiltIn, IsBuiltInName(var.name));
SetBitField(podStruct.isArray, var.isArray());
SetBitField(podStruct.hasImplicitLocation, var.hasImplicitLocation);
SetBitField(podStruct.pad, 0);
}
// VariableLocation implementation.
VariableLocation::VariableLocation() : index(kUnused), arrayIndex(0), ignored(false) {}
@@ -528,25 +466,6 @@ std::map<std::string, ProgramBinding> ProgramAliasedBindings::getStableIteration
return std::map<std::string, ProgramBinding>(mBindings.begin(), mBindings.end());
}
// ImageBinding implementation.
ImageBinding::ImageBinding(size_t count, TextureType textureTypeIn)
: textureType(textureTypeIn), boundImageUnits(count, 0)
{}
ImageBinding::ImageBinding(GLuint imageUnit, size_t count, TextureType textureTypeIn)
: textureType(textureTypeIn)
{
for (size_t index = 0; index < count; ++index)
{
boundImageUnits.push_back(imageUnit + static_cast<GLuint>(index));
}
}
ImageBinding::ImageBinding() = default;
ImageBinding::ImageBinding(const ImageBinding &other) = default;
ImageBinding::~ImageBinding() = default;
// ProgramState implementation.
ProgramState::ProgramState(rx::GLImplFactory *factory)
: mLabel(),
@@ -987,10 +906,9 @@ angle::Result Program::linkImpl(const Context *context)
//
// The isSeparable state is duplicated for convenience; it is used when setting sampler/image
// uniforms.
mState.mExecutable->mPODStruct.transformFeedbackBufferMode =
mState.mTransformFeedbackBufferMode;
mState.mExecutable->mTransformFeedbackVaryingNames = mState.mTransformFeedbackVaryingNames;
mState.mExecutable->mPODStruct.isSeparable = mState.mSeparable;
mState.mExecutable->mPod.transformFeedbackBufferMode = mState.mTransformFeedbackBufferMode;
mState.mExecutable->mTransformFeedbackVaryingNames = mState.mTransformFeedbackVaryingNames;
mState.mExecutable->mPod.isSeparable = mState.mSeparable;
mState.mInfoLog.reset();
@@ -1150,9 +1068,9 @@ angle::Result Program::linkJobImpl(const Caps &caps,
const SharedCompiledShaderState &vertexShader = mState.mAttachedShaders[ShaderType::Vertex];
if (vertexShader)
{
mState.mExecutable->mPODStruct.numViews = vertexShader->numViews;
mState.mExecutable->mPODStruct.hasClipDistance = vertexShader->hasClipDistance;
mState.mExecutable->mPODStruct.specConstUsageBits |= vertexShader->specConstUsageBits;
mState.mExecutable->mPod.numViews = vertexShader->numViews;
mState.mExecutable->mPod.hasClipDistance = vertexShader->hasClipDistance;
mState.mExecutable->mPod.specConstUsageBits |= vertexShader->specConstUsageBits;
}
const SharedCompiledShaderState &fragmentShader =
@@ -1174,12 +1092,12 @@ angle::Result Program::linkJobImpl(const Caps &caps,
return angle::Result::Stop;
}
mState.mExecutable->mPODStruct.hasDiscard = fragmentShader->hasDiscard;
mState.mExecutable->mPODStruct.enablesPerSampleShading =
mState.mExecutable->mPod.hasDiscard = fragmentShader->hasDiscard;
mState.mExecutable->mPod.enablesPerSampleShading =
fragmentShader->enablesPerSampleShading;
mState.mExecutable->mPODStruct.advancedBlendEquations =
mState.mExecutable->mPod.advancedBlendEquations =
fragmentShader->advancedBlendEquations;
mState.mExecutable->mPODStruct.specConstUsageBits |= fragmentShader->specConstUsageBits;
mState.mExecutable->mPod.specConstUsageBits |= fragmentShader->specConstUsageBits;
}
*mergedVaryingsOut = GetMergedVaryingsFromLinkingVariables(*linkingVariables);
@@ -1596,7 +1514,7 @@ void Program::bindUniformBlock(UniformBlockIndex uniformBlockIndex, GLuint unifo
{
ASSERT(!mLinkingState);
if (mState.mExecutable->mPODStruct.activeUniformBlockBindings[uniformBlockIndex.value])
if (mState.mExecutable->mPod.activeUniformBlockBindings[uniformBlockIndex.value])
{
GLuint previousBinding =
mState.mExecutable->mUniformBlocks[uniformBlockIndex.value].pod.binding;
@@ -1613,8 +1531,8 @@ void Program::bindUniformBlock(UniformBlockIndex uniformBlockIndex, GLuint unifo
mUniformBlockBindingMasks.resize(uniformBlockBinding + 1, UniformBlockBindingMask());
}
mUniformBlockBindingMasks[uniformBlockBinding].set(uniformBlockIndex.value);
mState.mExecutable->mPODStruct.activeUniformBlockBindings.set(uniformBlockIndex.value,
uniformBlockBinding != 0);
mState.mExecutable->mPod.activeUniformBlockBindings.set(uniformBlockIndex.value,
uniformBlockBinding != 0);
mDirtyBits.set(DIRTY_BIT_UNIFORM_BLOCK_BINDING_0 + uniformBlockIndex.value);
}
@@ -1811,8 +1729,7 @@ void Program::linkShaders()
if (isComputeShaderAttached)
{
mState.mExecutable->mPODStruct.computeShaderLocalSize =
shaders[ShaderType::Compute]->localSize;
mState.mExecutable->mPod.computeShaderLocalSize = shaders[ShaderType::Compute]->localSize;
}
else
{
@@ -1825,12 +1742,10 @@ void Program::linkShaders()
geometryShader->geometryShaderOutputPrimitiveType;
Optional<GLint> maxVertices = geometryShader->geometryShaderMaxVertices;
mState.mExecutable->mPODStruct.geometryShaderInputPrimitiveType =
inputPrimitive.value();
mState.mExecutable->mPODStruct.geometryShaderOutputPrimitiveType =
outputPrimitive.value();
mState.mExecutable->mPODStruct.geometryShaderMaxVertices = maxVertices.value();
mState.mExecutable->mPODStruct.geometryShaderInvocations =
mState.mExecutable->mPod.geometryShaderInputPrimitiveType = inputPrimitive.value();
mState.mExecutable->mPod.geometryShaderOutputPrimitiveType = outputPrimitive.value();
mState.mExecutable->mPod.geometryShaderMaxVertices = maxVertices.value();
mState.mExecutable->mPod.geometryShaderInvocations =
geometryShader->geometryShaderInvocations;
}
@@ -1838,7 +1753,7 @@ void Program::linkShaders()
if (tessControlShader)
{
int tcsShaderVertices = tessControlShader->tessControlShaderVertices;
mState.mExecutable->mPODStruct.tessControlShaderVertices = tcsShaderVertices;
mState.mExecutable->mPod.tessControlShaderVertices = tcsShaderVertices;
}
const SharedCompiledShaderState &tessEvaluationShader = shaders[ShaderType::TessEvaluation];
@@ -1846,12 +1761,10 @@ void Program::linkShaders()
{
GLenum tesPrimitiveMode = tessEvaluationShader->tessGenMode;
mState.mExecutable->mPODStruct.tessGenMode = tesPrimitiveMode;
mState.mExecutable->mPODStruct.tessGenSpacing = tessEvaluationShader->tessGenSpacing;
mState.mExecutable->mPODStruct.tessGenVertexOrder =
tessEvaluationShader->tessGenVertexOrder;
mState.mExecutable->mPODStruct.tessGenPointMode =
tessEvaluationShader->tessGenPointMode;
mState.mExecutable->mPod.tessGenMode = tesPrimitiveMode;
mState.mExecutable->mPod.tessGenSpacing = tessEvaluationShader->tessGenSpacing;
mState.mExecutable->mPod.tessGenVertexOrder = tessEvaluationShader->tessGenVertexOrder;
mState.mExecutable->mPod.tessGenPointMode = tessEvaluationShader->tessGenPointMode;
}
}
}
@@ -2047,8 +1960,8 @@ bool Program::linkAttributes(const Caps &caps,
}
}
ASSERT(mState.mExecutable->mPODStruct.attributesTypeMask.none());
ASSERT(mState.mExecutable->mPODStruct.attributesMask.none());
ASSERT(mState.mExecutable->mPod.attributesTypeMask.none());
ASSERT(mState.mExecutable->mPod.attributesMask.none());
// Prune inactive attributes. This step is only needed on shaderVersion >= 300 since on earlier
// shader versions we're only processing active attributes to begin with.
@@ -2080,16 +1993,16 @@ bool Program::linkAttributes(const Caps &caps,
// Built-in active program inputs don't have a bound attribute.
if (!attribute.isBuiltIn())
{
mState.mExecutable->mPODStruct.activeAttribLocationsMask.set(location);
mState.mExecutable->mPODStruct.maxActiveAttribLocation =
std::max(mState.mExecutable->mPODStruct.maxActiveAttribLocation, location + 1);
mState.mExecutable->mPod.activeAttribLocationsMask.set(location);
mState.mExecutable->mPod.maxActiveAttribLocation =
std::max(mState.mExecutable->mPod.maxActiveAttribLocation, location + 1);
ComponentType componentType =
GLenumToComponentType(VariableComponentType(attribute.getType()));
SetComponentTypeMask(componentType, location,
&mState.mExecutable->mPODStruct.attributesTypeMask);
mState.mExecutable->mPODStruct.attributesMask.set(location);
&mState.mExecutable->mPod.attributesTypeMask);
mState.mExecutable->mPod.attributesMask.set(location);
location++;
}
@@ -2262,7 +2175,7 @@ angle::Result Program::deserialize(const Context *context, BinaryInputStream &st
// mSeparable must be before mExecutable->load(), since it uses the value. This state is
// duplicated in the executable for convenience.
mState.mExecutable->mPODStruct.isSeparable = mState.mSeparable;
mState.mExecutable->mPod.isSeparable = mState.mSeparable;
mState.mExecutable->load(&stream);
static_assert(static_cast<unsigned long>(ShaderType::EnumCount) <= sizeof(unsigned long) * 8,
@@ -2314,15 +2227,15 @@ void Program::postResolveLink(const Context *context)
if (context->getExtensions().multiDrawANGLE)
{
mState.mExecutable->mPODStruct.drawIDLocation =
mState.mExecutable->mPod.drawIDLocation =
mState.mExecutable->getUniformLocation("gl_DrawID").value;
}
if (context->getExtensions().baseVertexBaseInstanceShaderBuiltinANGLE)
{
mState.mExecutable->mPODStruct.baseVertexLocation =
mState.mExecutable->mPod.baseVertexLocation =
mState.mExecutable->getUniformLocation("gl_BaseVertex").value;
mState.mExecutable->mPODStruct.baseInstanceLocation =
mState.mExecutable->mPod.baseInstanceLocation =
mState.mExecutable->getUniformLocation("gl_BaseInstance").value;
}
}

View File

@@ -120,9 +120,9 @@ void AssignOutputLocations(std::vector<VariableLocation> &outputLocations,
if (std::find(reservedLocations.begin(), reservedLocations.end(), locationInfo) ==
reservedLocations.end())
{
outputVariable.podStruct.location = baseLocation;
const unsigned int location = baseLocation + elementIndex;
outputLocations[location] = locationInfo;
outputVariable.pod.location = baseLocation;
const unsigned int location = baseLocation + elementIndex;
outputLocations[location] = locationInfo;
}
}
}
@@ -130,9 +130,9 @@ void AssignOutputLocations(std::vector<VariableLocation> &outputLocations,
int GetOutputLocationForLink(const ProgramAliasedBindings &fragmentOutputLocations,
const ProgramOutput &outputVariable)
{
if (outputVariable.podStruct.location != -1)
if (outputVariable.pod.location != -1)
{
return outputVariable.podStruct.location;
return outputVariable.pod.location;
}
int apiLocation = fragmentOutputLocations.getBinding(outputVariable);
if (apiLocation != -1)
@@ -145,10 +145,10 @@ int GetOutputLocationForLink(const ProgramAliasedBindings &fragmentOutputLocatio
bool IsOutputSecondaryForLink(const ProgramAliasedBindings &fragmentOutputIndexes,
const ProgramOutput &outputVariable)
{
if (outputVariable.podStruct.index != -1)
if (outputVariable.pod.index != -1)
{
ASSERT(outputVariable.podStruct.index == 0 || outputVariable.podStruct.index == 1);
return (outputVariable.podStruct.index == 1);
ASSERT(outputVariable.pod.index == 0 || outputVariable.pod.index == 1);
return (outputVariable.pod.index == 1);
}
int apiIndex = fragmentOutputIndexes.getBinding(outputVariable);
if (apiIndex != -1)
@@ -213,7 +213,7 @@ void SaveProgramInputs(BinaryOutputStream *stream, const std::vector<ProgramInpu
{
stream->writeString(attrib.name);
stream->writeString(attrib.mappedName);
stream->writeStruct(attrib.basicDataTypeStruct);
stream->writeStruct(attrib.pod);
}
}
void LoadProgramInputs(BinaryInputStream *stream, std::vector<ProgramInput> *programInputs)
@@ -228,7 +228,7 @@ void LoadProgramInputs(BinaryInputStream *stream, std::vector<ProgramInput> *pro
ProgramInput &attrib = (*programInputs)[attribIndex];
stream->readString(&attrib.name);
stream->readString(&attrib.mappedName);
stream->readStruct(&attrib.basicDataTypeStruct);
stream->readStruct(&attrib.pod);
}
}
}
@@ -657,6 +657,61 @@ void UniformStateQueryCastLoop(DestT *dataOut, const uint8_t *srcPointer, int co
}
} // anonymous namespace
// ImageBinding implementation.
ImageBinding::ImageBinding(GLuint imageUnit, size_t count, TextureType textureTypeIn)
: textureType(textureTypeIn)
{
for (size_t index = 0; index < count; ++index)
{
boundImageUnits.push_back(imageUnit + static_cast<GLuint>(index));
}
}
// ProgramInput implementation.
ProgramInput::ProgramInput(const sh::ShaderVariable &var)
{
ASSERT(!var.isStruct());
name = var.name;
mappedName = var.mappedName;
SetBitField(pod.type, var.type);
pod.location = var.hasImplicitLocation ? -1 : var.location;
SetBitField(pod.interpolation, var.interpolation);
pod.flagBitsAsUByte = 0;
pod.flagBits.active = var.active;
pod.flagBits.isPatch = var.isPatch;
pod.flagBits.hasImplicitLocation = var.hasImplicitLocation;
pod.flagBits.isArray = var.isArray();
pod.flagBits.isBuiltIn = IsBuiltInName(var.name);
SetBitField(pod.basicTypeElementCount, var.getBasicTypeElementCount());
pod.id = var.id;
SetBitField(pod.arraySizeProduct, var.getArraySizeProduct());
}
// ProgramOutput implementation.
ProgramOutput::ProgramOutput(const sh::ShaderVariable &var)
{
name = var.name;
mappedName = var.mappedName;
pod.type = var.type;
pod.location = var.location;
pod.index = var.index;
pod.id = var.id;
SetBitField(pod.outermostArraySize, var.getOutermostArraySize());
SetBitField(pod.basicTypeElementCount, var.getBasicTypeElementCount());
SetBitField(pod.isPatch, var.isPatch);
SetBitField(pod.yuv, var.yuv);
SetBitField(pod.isBuiltIn, IsBuiltInName(var.name));
SetBitField(pod.isArray, var.isArray());
SetBitField(pod.hasImplicitLocation, var.hasImplicitLocation);
SetBitField(pod.pad, 0);
}
// ProgramExecutable implementation.
ProgramExecutable::ProgramExecutable(rx::GLImplFactory *factory, InfoLog *infoLog)
: mImplementation(factory->createProgramExecutable(this)),
mInfoLog(infoLog),
@@ -664,12 +719,12 @@ ProgramExecutable::ProgramExecutable(rx::GLImplFactory *factory, InfoLog *infoLo
mCachedBaseVertex(0),
mCachedBaseInstance(0)
{
memset(&mPODStruct, 0, sizeof(mPODStruct));
mPODStruct.geometryShaderInputPrimitiveType = PrimitiveMode::Triangles;
mPODStruct.geometryShaderOutputPrimitiveType = PrimitiveMode::TriangleStrip;
mPODStruct.geometryShaderInvocations = 1;
mPODStruct.transformFeedbackBufferMode = GL_INTERLEAVED_ATTRIBS;
mPODStruct.computeShaderLocalSize.fill(1);
memset(&mPod, 0, sizeof(mPod));
mPod.geometryShaderInputPrimitiveType = PrimitiveMode::Triangles;
mPod.geometryShaderOutputPrimitiveType = PrimitiveMode::TriangleStrip;
mPod.geometryShaderInvocations = 1;
mPod.transformFeedbackBufferMode = GL_INTERLEAVED_ATTRIBS;
mPod.computeShaderLocalSize.fill(1);
reset();
}
@@ -689,47 +744,47 @@ void ProgramExecutable::destroy(const Context *context)
void ProgramExecutable::reset()
{
mPODStruct.activeAttribLocationsMask.reset();
mPODStruct.attributesTypeMask.reset();
mPODStruct.attributesMask.reset();
mPODStruct.maxActiveAttribLocation = 0;
mPODStruct.activeOutputVariablesMask.reset();
mPODStruct.activeSecondaryOutputVariablesMask.reset();
mPod.activeAttribLocationsMask.reset();
mPod.attributesTypeMask.reset();
mPod.attributesMask.reset();
mPod.maxActiveAttribLocation = 0;
mPod.activeOutputVariablesMask.reset();
mPod.activeSecondaryOutputVariablesMask.reset();
mPODStruct.defaultUniformRange = RangeUI(0, 0);
mPODStruct.samplerUniformRange = RangeUI(0, 0);
mPODStruct.imageUniformRange = RangeUI(0, 0);
mPODStruct.atomicCounterUniformRange = RangeUI(0, 0);
mPODStruct.fragmentInoutRange = RangeUI(0, 0);
mPod.defaultUniformRange = RangeUI(0, 0);
mPod.samplerUniformRange = RangeUI(0, 0);
mPod.imageUniformRange = RangeUI(0, 0);
mPod.atomicCounterUniformRange = RangeUI(0, 0);
mPod.fragmentInoutRange = RangeUI(0, 0);
mPODStruct.hasClipDistance = false;
mPODStruct.hasDiscard = false;
mPODStruct.enablesPerSampleShading = false;
mPODStruct.hasYUVOutput = false;
mPod.hasClipDistance = false;
mPod.hasDiscard = false;
mPod.enablesPerSampleShading = false;
mPod.hasYUVOutput = false;
mPODStruct.advancedBlendEquations.reset();
mPod.advancedBlendEquations.reset();
mPODStruct.geometryShaderInputPrimitiveType = PrimitiveMode::Triangles;
mPODStruct.geometryShaderOutputPrimitiveType = PrimitiveMode::TriangleStrip;
mPODStruct.geometryShaderInvocations = 1;
mPODStruct.geometryShaderMaxVertices = 0;
mPod.geometryShaderInputPrimitiveType = PrimitiveMode::Triangles;
mPod.geometryShaderOutputPrimitiveType = PrimitiveMode::TriangleStrip;
mPod.geometryShaderInvocations = 1;
mPod.geometryShaderMaxVertices = 0;
mPODStruct.numViews = -1;
mPod.numViews = -1;
mPODStruct.drawIDLocation = -1;
mPod.drawIDLocation = -1;
mPODStruct.baseVertexLocation = -1;
mPODStruct.baseInstanceLocation = -1;
mPod.baseVertexLocation = -1;
mPod.baseInstanceLocation = -1;
mPODStruct.tessControlShaderVertices = 0;
mPODStruct.tessGenMode = GL_NONE;
mPODStruct.tessGenSpacing = GL_NONE;
mPODStruct.tessGenVertexOrder = GL_NONE;
mPODStruct.tessGenPointMode = GL_NONE;
mPODStruct.drawBufferTypeMask.reset();
mPODStruct.computeShaderLocalSize.fill(1);
mPod.tessControlShaderVertices = 0;
mPod.tessGenMode = GL_NONE;
mPod.tessGenSpacing = GL_NONE;
mPod.tessGenVertexOrder = GL_NONE;
mPod.tessGenPointMode = GL_NONE;
mPod.drawBufferTypeMask.reset();
mPod.computeShaderLocalSize.fill(1);
mPODStruct.specConstUsageBits.reset();
mPod.specConstUsageBits.reset();
mActiveSamplersMask.reset();
mActiveSamplerRefCounts = {};
@@ -767,7 +822,7 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
"All bits of mDrawBufferTypeMask and mActiveOutputVariables types and mask fit "
"into 32 bits each");
stream->readStruct(&mPODStruct);
stream->readStruct(&mPod);
LoadProgramInputs(stream, &mProgramInputs);
LoadUniforms(stream, &mUniforms, &mUniformNames, &mUniformMappedNames, &mUniformLocations);
@@ -779,7 +834,7 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
{
InterfaceBlock &uniformBlock = mUniformBlocks[uniformBlockIndex];
LoadInterfaceBlock(stream, &uniformBlock);
ASSERT(mPODStruct.activeUniformBlockBindings.test(uniformBlockIndex) ==
ASSERT(mPod.activeUniformBlockBindings.test(uniformBlockIndex) ==
(uniformBlock.pod.binding != 0));
}
@@ -833,7 +888,7 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
ProgramOutput &output = mOutputVariables[outputIndex];
stream->readString(&output.name);
stream->readString(&output.mappedName);
stream->readStruct(&output.podStruct);
stream->readStruct(&output.pod);
}
stream->readVector(&mOutputLocations);
@@ -857,7 +912,7 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
// These values are currently only used by PPOs, so only load them when the program is marked
// separable to save memory.
if (mPODStruct.isSeparable)
if (mPod.isSeparable)
{
for (ShaderType shaderType : getLinkedShaderStages())
{
@@ -893,8 +948,8 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
IMPLEMENTATION_MAX_DRAW_BUFFERS * 2 <= 8 * sizeof(uint32_t),
"All bits of mDrawBufferTypeMask and mActiveOutputVariables can be contained in 32 bits");
ASSERT(mPODStruct.geometryShaderInvocations >= 1 && mPODStruct.geometryShaderMaxVertices >= 0);
stream->writeStruct(mPODStruct);
ASSERT(mPod.geometryShaderInvocations >= 1 && mPod.geometryShaderMaxVertices >= 0);
stream->writeStruct(mPod);
SaveProgramInputs(stream, mProgramInputs);
SaveUniforms(stream, mUniforms, mUniformNames, mUniformMappedNames, mUniformLocations);
@@ -938,7 +993,7 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
{
stream->writeString(output.name);
stream->writeString(output.mappedName);
stream->writeStruct(output.podStruct);
stream->writeStruct(output.pod);
}
stream->writeVector(mOutputLocations);
@@ -958,7 +1013,7 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
// These values are currently only used by PPOs, so only save them when the program is marked
// separable to save memory.
if (mPODStruct.isSeparable)
if (mPod.isSeparable)
{
for (ShaderType shaderType : getLinkedShaderStages())
{
@@ -993,7 +1048,7 @@ std::string ProgramExecutable::getInfoLogString() const
ShaderType ProgramExecutable::getFirstLinkedShaderStageType() const
{
const ShaderBitSet linkedStages = mPODStruct.linkedShaderStages;
const ShaderBitSet linkedStages = mPod.linkedShaderStages;
if (linkedStages.none())
{
return ShaderType::InvalidEnum;
@@ -1004,7 +1059,7 @@ ShaderType ProgramExecutable::getFirstLinkedShaderStageType() const
ShaderType ProgramExecutable::getLastLinkedShaderStageType() const
{
const ShaderBitSet linkedStages = mPODStruct.linkedShaderStages;
const ShaderBitSet linkedStages = mPod.linkedShaderStages;
if (linkedStages.none())
{
return ShaderType::InvalidEnum;
@@ -1156,11 +1211,11 @@ void ProgramExecutable::saveLinkedStateInfo(const ProgramState &state)
{
const SharedCompiledShaderState &shader = state.getAttachedShader(shaderType);
ASSERT(shader);
mPODStruct.linkedShaderVersions[shaderType] = shader->shaderVersion;
mLinkedOutputVaryings[shaderType] = shader->outputVaryings;
mLinkedInputVaryings[shaderType] = shader->inputVaryings;
mLinkedUniforms[shaderType] = shader->uniforms;
mLinkedUniformBlocks[shaderType] = shader->uniformBlocks;
mPod.linkedShaderVersions[shaderType] = shader->shaderVersion;
mLinkedOutputVaryings[shaderType] = shader->outputVaryings;
mLinkedInputVaryings[shaderType] = shader->inputVaryings;
mLinkedUniforms[shaderType] = shader->uniforms;
mLinkedUniformBlocks[shaderType] = shader->uniformBlocks;
}
}
@@ -1209,7 +1264,7 @@ bool ProgramExecutable::linkMergedVaryings(const Caps &caps,
if (!varyingPacking->collectAndPackUserVaryings(*mInfoLog, caps, packMode, activeShadersMask,
mergedVaryings, mTransformFeedbackVaryingNames,
mPODStruct.isSeparable))
mPod.isSeparable))
{
return false;
}
@@ -1321,7 +1376,7 @@ bool ProgramExecutable::linkValidateTransformFeedback(const Caps &caps,
}
componentCount = VariableComponentCount(var->type) * elementCount;
if (mPODStruct.transformFeedbackBufferMode == GL_SEPARATE_ATTRIBS &&
if (mPod.transformFeedbackBufferMode == GL_SEPARATE_ATTRIBS &&
componentCount > static_cast<GLuint>(caps.maxTransformFeedbackSeparateComponents))
{
*mInfoLog << "Transform feedback varying " << tfVaryingName << " components ("
@@ -1331,7 +1386,7 @@ bool ProgramExecutable::linkValidateTransformFeedback(const Caps &caps,
}
totalComponents += componentCount;
if (mPODStruct.transformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS &&
if (mPod.transformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS &&
totalComponents > static_cast<GLuint>(caps.maxTransformFeedbackInterleavedComponents))
{
*mInfoLog << "Transform feedback varying total components (" << totalComponents
@@ -1392,7 +1447,7 @@ void ProgramExecutable::updateTransformFeedbackStrides()
return;
}
if (mPODStruct.transformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS)
if (mPod.transformFeedbackBufferMode == GL_INTERLEAVED_ATTRIBS)
{
mTransformFeedbackStrides.resize(1);
size_t totalSize = 0;
@@ -1447,10 +1502,10 @@ bool ProgramExecutable::linkValidateOutputVariables(
const ProgramAliasedBindings &fragmentOutputLocations,
const ProgramAliasedBindings &fragmentOutputIndices)
{
ASSERT(mPODStruct.activeOutputVariablesMask.none());
ASSERT(mPODStruct.activeSecondaryOutputVariablesMask.none());
ASSERT(mPODStruct.drawBufferTypeMask.none());
ASSERT(!mPODStruct.hasYUVOutput);
ASSERT(mPod.activeOutputVariablesMask.none());
ASSERT(mPod.activeSecondaryOutputVariablesMask.none());
ASSERT(mPod.drawBufferTypeMask.none());
ASSERT(!mPod.hasYUVOutput);
if (fragmentShaderVersion == 100)
{
@@ -1554,7 +1609,7 @@ bool ProgramExecutable::linkValidateOutputVariables(
// GLSL ES 3.10 section 4.3.6: Output variables cannot be arrays of arrays or arrays of
// structures, so we may use getBasicTypeElementCount().
unsigned int elementCount = outputVariable.podStruct.basicTypeElementCount;
unsigned int elementCount = outputVariable.pod.basicTypeElementCount;
if (FindUsedOutputLocation(outputLocations, baseLocation, elementCount, reservedLocations,
outputVariableIndex))
{
@@ -1594,7 +1649,7 @@ bool ProgramExecutable::linkValidateOutputVariables(
? mSecondaryOutputLocations
: mOutputLocations;
unsigned int baseLocation = 0;
unsigned int elementCount = outputVariable.podStruct.basicTypeElementCount;
unsigned int elementCount = outputVariable.pod.basicTypeElementCount;
if (fixedLocation != -1)
{
// Secondary inputs might have caused the max location to drop below what has already
@@ -1645,7 +1700,7 @@ bool ProgramExecutable::linkValidateOutputVariables(
// fragment shader outputs exceeds the implementation-dependent value of
// MAX_COMBINED_SHADER_OUTPUT_RESOURCES.
if (combinedImageUniformsCount + combinedShaderStorageBlocksCount +
mPODStruct.activeOutputVariablesMask.count() >
mPod.activeOutputVariablesMask.count() >
static_cast<GLuint>(caps.maxCombinedShaderOutputResources))
{
*mInfoLog
@@ -1672,39 +1727,38 @@ bool ProgramExecutable::gatherOutputTypes()
continue;
}
unsigned int baseLocation =
(outputVariable.podStruct.location == -1
? 0u
: static_cast<unsigned int>(outputVariable.podStruct.location));
unsigned int baseLocation = (outputVariable.pod.location == -1
? 0u
: static_cast<unsigned int>(outputVariable.pod.location));
const bool secondary = outputVariable.podStruct.index == 1 ||
(outputVariable.name == "gl_SecondaryFragColorEXT" ||
outputVariable.name == "gl_SecondaryFragDataEXT");
const bool secondary =
outputVariable.pod.index == 1 || (outputVariable.name == "gl_SecondaryFragColorEXT" ||
outputVariable.name == "gl_SecondaryFragDataEXT");
const ComponentType componentType =
GLenumToComponentType(VariableComponentType(outputVariable.podStruct.type));
GLenumToComponentType(VariableComponentType(outputVariable.pod.type));
// GLSL ES 3.10 section 4.3.6: Output variables cannot be arrays of arrays or arrays of
// structures, so we may use getBasicTypeElementCount().
unsigned int elementCount = outputVariable.podStruct.basicTypeElementCount;
unsigned int elementCount = outputVariable.pod.basicTypeElementCount;
for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++)
{
const unsigned int location = baseLocation + elementIndex;
ASSERT(location < mPODStruct.activeOutputVariablesMask.size());
ASSERT(location < mPODStruct.activeSecondaryOutputVariablesMask.size());
ASSERT(location < mPod.activeOutputVariablesMask.size());
ASSERT(location < mPod.activeSecondaryOutputVariablesMask.size());
if (secondary)
{
mPODStruct.activeSecondaryOutputVariablesMask.set(location);
mPod.activeSecondaryOutputVariablesMask.set(location);
}
else
{
mPODStruct.activeOutputVariablesMask.set(location);
mPod.activeOutputVariablesMask.set(location);
}
const ComponentType storedComponentType =
gl::GetComponentTypeMask(mPODStruct.drawBufferTypeMask, location);
gl::GetComponentTypeMask(mPod.drawBufferTypeMask, location);
if (storedComponentType == ComponentType::InvalidEnum)
{
SetComponentTypeMask(componentType, location, &mPODStruct.drawBufferTypeMask);
SetComponentTypeMask(componentType, location, &mPod.drawBufferTypeMask);
}
else if (storedComponentType != componentType)
{
@@ -1714,10 +1768,10 @@ bool ProgramExecutable::gatherOutputTypes()
}
}
if (outputVariable.podStruct.yuv)
if (outputVariable.pod.yuv)
{
ASSERT(mOutputVariables.size() == 1);
mPODStruct.hasYUVOutput = true;
mPod.hasYUVOutput = true;
}
}
@@ -1731,7 +1785,7 @@ bool ProgramExecutable::linkUniforms(
GLuint *combinedImageUniformsCountOut,
std::vector<UnusedUniform> *unusedUniformsOutOrNull)
{
UniformLinker linker(mPODStruct.linkedShaderStages, shaderUniforms);
UniformLinker linker(mPod.linkedShaderStages, shaderUniforms);
if (!linker.link(caps, *mInfoLog, uniformLocationBindings))
{
return false;
@@ -1771,7 +1825,7 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
--low;
}
mPODStruct.fragmentInoutRange = RangeUI(low, high);
mPod.fragmentInoutRange = RangeUI(low, high);
highIter = lowIter;
high = low;
@@ -1781,7 +1835,7 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
--low;
}
mPODStruct.atomicCounterUniformRange = RangeUI(low, high);
mPod.atomicCounterUniformRange = RangeUI(low, high);
highIter = lowIter;
high = low;
@@ -1791,10 +1845,10 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
--low;
}
mPODStruct.imageUniformRange = RangeUI(low, high);
*combinedImageUniforms = 0u;
mPod.imageUniformRange = RangeUI(low, high);
*combinedImageUniforms = 0u;
// If uniform is a image type, insert it into the mImageBindings array.
for (unsigned int imageIndex : mPODStruct.imageUniformRange)
for (unsigned int imageIndex : mPod.imageUniformRange)
{
// ES3.1 (section 7.6.1) and GLSL ES3.1 (section 4.4.5), Uniform*i{v} commands
// cannot load values into a uniform defined as an image. if declare without a
@@ -1813,9 +1867,9 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
{
// The arrays of arrays are flattened to arrays, it needs to record the array offset for
// the correct binding image unit.
mImageBindings.emplace_back(
ImageBinding(imageUniform.getBinding() + imageUniform.parentArrayIndex * arraySize,
imageUniform.getBasicTypeElementCount(), textureType));
mImageBindings.emplace_back(ImageBinding(
imageUniform.getBinding() + imageUniform.pod.parentArrayIndex * arraySize,
imageUniform.getBasicTypeElementCount(), textureType));
}
*combinedImageUniforms += imageUniform.activeShaderCount() * arraySize;
@@ -1829,11 +1883,11 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
--low;
}
mPODStruct.samplerUniformRange = RangeUI(low, high);
mPod.samplerUniformRange = RangeUI(low, high);
// If uniform is a sampler type, insert it into the mSamplerBindings array.
uint16_t totalCount = 0;
for (unsigned int samplerIndex : mPODStruct.samplerUniformRange)
for (unsigned int samplerIndex : mPod.samplerUniformRange)
{
const auto &samplerUniform = mUniforms[samplerIndex];
TextureType textureType = SamplerTypeToTextureType(samplerUniform.getType());
@@ -1846,20 +1900,20 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
mSamplerBoundTextureUnits.resize(totalCount, 0);
// Whatever is left constitutes the default uniforms.
mPODStruct.defaultUniformRange = RangeUI(0, low);
mPod.defaultUniformRange = RangeUI(0, low);
}
bool ProgramExecutable::linkAtomicCounterBuffers(const Caps &caps)
{
for (unsigned int index : mPODStruct.atomicCounterUniformRange)
for (unsigned int index : mPod.atomicCounterUniformRange)
{
auto &uniform = mUniforms[index];
uniform.blockOffset = uniform.getOffset();
uniform.blockArrayStride = uniform.isArray() ? 4 : 0;
uniform.blockMatrixStride = 0;
uniform.flagBits.blockIsRowMajorMatrix = false;
uniform.flagBits.isBlock = true;
uniform.pod.blockOffset = uniform.getOffset();
uniform.pod.blockArrayStride = uniform.isArray() ? 4 : 0;
uniform.pod.blockMatrixStride = 0;
uniform.pod.flagBits.blockIsRowMajorMatrix = false;
uniform.pod.flagBits.isBlock = true;
bool found = false;
for (size_t bufferIndex = 0; bufferIndex < mAtomicCounterBuffers.size(); ++bufferIndex)
@@ -1868,7 +1922,7 @@ bool ProgramExecutable::linkAtomicCounterBuffers(const Caps &caps)
if (buffer.pod.binding == uniform.getBinding())
{
buffer.memberIndexes.push_back(index);
SetBitField(uniform.bufferIndex, bufferIndex);
SetBitField(uniform.pod.bufferIndex, bufferIndex);
found = true;
buffer.unionReferencesWith(uniform);
break;
@@ -1881,7 +1935,7 @@ bool ProgramExecutable::linkAtomicCounterBuffers(const Caps &caps)
atomicCounterBuffer.memberIndexes.push_back(index);
atomicCounterBuffer.unionReferencesWith(uniform);
mAtomicCounterBuffers.push_back(atomicCounterBuffer);
SetBitField(uniform.bufferIndex, mAtomicCounterBuffers.size() - 1);
SetBitField(uniform.pod.bufferIndex, mAtomicCounterBuffers.size() - 1);
}
}
@@ -1972,41 +2026,37 @@ void ProgramExecutable::copyUniformsFromProgramMap(
auto getDefaultRange = [](const ProgramExecutable &state) {
return state.getDefaultUniformRange();
};
mPODStruct.defaultUniformRange =
AddUniforms(executables, mPODStruct.linkedShaderStages, &mUniforms, &mUniformNames,
&mUniformMappedNames, getDefaultRange);
mPod.defaultUniformRange = AddUniforms(executables, mPod.linkedShaderStages, &mUniforms,
&mUniformNames, &mUniformMappedNames, getDefaultRange);
// Merge sampler uniforms.
auto getSamplerRange = [](const ProgramExecutable &state) {
return state.getSamplerUniformRange();
};
mPODStruct.samplerUniformRange =
AddUniforms(executables, mPODStruct.linkedShaderStages, &mUniforms, &mUniformNames,
&mUniformMappedNames, getSamplerRange);
mPod.samplerUniformRange = AddUniforms(executables, mPod.linkedShaderStages, &mUniforms,
&mUniformNames, &mUniformMappedNames, getSamplerRange);
// Merge image uniforms.
auto getImageRange = [](const ProgramExecutable &state) {
return state.getImageUniformRange();
};
mPODStruct.imageUniformRange =
AddUniforms(executables, mPODStruct.linkedShaderStages, &mUniforms, &mUniformNames,
&mUniformMappedNames, getImageRange);
mPod.imageUniformRange = AddUniforms(executables, mPod.linkedShaderStages, &mUniforms,
&mUniformNames, &mUniformMappedNames, getImageRange);
// Merge atomic counter uniforms.
auto getAtomicRange = [](const ProgramExecutable &state) {
return state.getAtomicCounterUniformRange();
};
mPODStruct.atomicCounterUniformRange =
AddUniforms(executables, mPODStruct.linkedShaderStages, &mUniforms, &mUniformNames,
mPod.atomicCounterUniformRange =
AddUniforms(executables, mPod.linkedShaderStages, &mUniforms, &mUniformNames,
&mUniformMappedNames, getAtomicRange);
// Merge fragment in/out uniforms.
auto getInoutRange = [](const ProgramExecutable &state) {
return state.getFragmentInoutRange();
};
mPODStruct.fragmentInoutRange =
AddUniforms(executables, mPODStruct.linkedShaderStages, &mUniforms, &mUniformNames,
&mUniformMappedNames, getInoutRange);
mPod.fragmentInoutRange = AddUniforms(executables, mPod.linkedShaderStages, &mUniforms,
&mUniformNames, &mUniformMappedNames, getInoutRange);
// Note: uniforms are set through the program, and the program pipeline never needs it.
ASSERT(mUniformLocations.empty());
@@ -2090,7 +2140,7 @@ GLuint ProgramExecutable::getOutputResourceLocation(const GLchar *name) const
const gl::ProgramOutput &variable = getOutputResource(index);
return GetResourceLocation(name, variable, variable.podStruct.location);
return GetResourceLocation(name, variable, variable.pod.location);
}
GLuint ProgramExecutable::getOutputResourceIndex(const GLchar *name) const
@@ -2429,24 +2479,24 @@ Optional<GLuint> ProgramExecutable::getSamplerIndex(UniformLocation location) co
bool ProgramExecutable::isSamplerUniformIndex(GLuint index) const
{
return mPODStruct.samplerUniformRange.contains(index);
return mPod.samplerUniformRange.contains(index);
}
GLuint ProgramExecutable::getSamplerIndexFromUniformIndex(GLuint uniformIndex) const
{
ASSERT(isSamplerUniformIndex(uniformIndex));
return uniformIndex - mPODStruct.samplerUniformRange.low();
return uniformIndex - mPod.samplerUniformRange.low();
}
bool ProgramExecutable::isImageUniformIndex(GLuint index) const
{
return mPODStruct.imageUniformRange.contains(index);
return mPod.imageUniformRange.contains(index);
}
GLuint ProgramExecutable::getImageIndexFromUniformIndex(GLuint uniformIndex) const
{
ASSERT(isImageUniformIndex(uniformIndex));
return uniformIndex - mPODStruct.imageUniformRange.low();
return uniformIndex - mPod.imageUniformRange.low();
}
void ProgramExecutable::getActiveUniformBlockName(const Context *context,
@@ -2798,7 +2848,7 @@ void ProgramExecutable::getUniformuiv(const Context *context,
void ProgramExecutable::setUniformValuesFromBindingQualifiers()
{
for (unsigned int samplerIndex : mPODStruct.samplerUniformRange)
for (unsigned int samplerIndex : mPod.samplerUniformRange)
{
const auto &samplerUniform = mUniforms[samplerIndex];
if (samplerUniform.getBinding() != -1)
@@ -2954,7 +3004,7 @@ void ProgramExecutable::updateSamplerUniform(Context *context,
// Update the observing PPO's executable, if any.
// Do this before any of the Context work, since that uses the current ProgramExecutable,
// which will be the PPO's if this Program is bound to it, rather than this Program's.
if (mPODStruct.isSeparable)
if (mPod.isSeparable)
{
onStateChange(angle::SubjectMessage::ProgramTextureOrImageBindingChanged);
}
@@ -3025,7 +3075,7 @@ void ProgramExecutable::getUniformInternal(const Context *context,
void ProgramExecutable::setDrawIDUniform(GLint drawid)
{
ASSERT(hasDrawIDUniform());
mImplementation->setUniform1iv(mPODStruct.drawIDLocation, 1, &drawid);
mImplementation->setUniform1iv(mPod.drawIDLocation, 1, &drawid);
}
void ProgramExecutable::setBaseVertexUniform(GLint baseVertex)
@@ -3036,7 +3086,7 @@ void ProgramExecutable::setBaseVertexUniform(GLint baseVertex)
return;
}
mCachedBaseVertex = baseVertex;
mImplementation->setUniform1iv(mPODStruct.baseVertexLocation, 1, &baseVertex);
mImplementation->setUniform1iv(mPod.baseVertexLocation, 1, &baseVertex);
}
void ProgramExecutable::setBaseInstanceUniform(GLuint baseInstance)
@@ -3048,7 +3098,7 @@ void ProgramExecutable::setBaseInstanceUniform(GLuint baseInstance)
}
mCachedBaseInstance = baseInstance;
GLint baseInstanceInt = baseInstance;
mImplementation->setUniform1iv(mPODStruct.baseInstanceLocation, 1, &baseInstanceInt);
mImplementation->setUniform1iv(mPod.baseInstanceLocation, 1, &baseInstanceInt);
}
void InstallExecutable(const Context *context,

View File

@@ -44,7 +44,6 @@ struct SamplerBinding
{
SetBitField(samplerType, samplerTypeIn);
}
~SamplerBinding() = default;
GLuint getTextureUnit(const std::vector<GLuint> &boundTextureUnits,
unsigned int arrayIndex) const
@@ -66,11 +65,11 @@ ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
struct ImageBinding
{
ImageBinding();
ImageBinding(size_t count, TextureType textureTypeIn);
ImageBinding() = default;
ImageBinding(size_t count, TextureType textureTypeIn)
: textureType(textureTypeIn), boundImageUnits(count, 0)
{}
ImageBinding(GLuint imageUnit, size_t count, TextureType textureTypeIn);
ImageBinding(const ImageBinding &other);
~ImageBinding();
// Necessary for distinguishing between textures with images and texture buffers.
TextureType textureType;
@@ -83,34 +82,29 @@ struct ImageBinding
ANGLE_ENABLE_STRUCT_PADDING_WARNINGS
struct ProgramInput
{
ProgramInput();
ProgramInput() = default;
ProgramInput(const sh::ShaderVariable &var);
ProgramInput(const ProgramInput &other);
ProgramInput &operator=(const ProgramInput &rhs);
GLenum getType() const { return basicDataTypeStruct.type; }
bool isBuiltIn() const { return basicDataTypeStruct.flagBits.isBuiltIn; }
bool isArray() const { return basicDataTypeStruct.flagBits.isArray; }
bool isActive() const { return basicDataTypeStruct.flagBits.active; }
bool isPatch() const { return basicDataTypeStruct.flagBits.isPatch; }
int getLocation() const { return basicDataTypeStruct.location; }
unsigned int getBasicTypeElementCount() const
{
return basicDataTypeStruct.basicTypeElementCount;
}
unsigned int getArraySizeProduct() const { return basicDataTypeStruct.arraySizeProduct; }
uint32_t getId() const { return basicDataTypeStruct.id; }
GLenum getType() const { return pod.type; }
bool isBuiltIn() const { return pod.flagBits.isBuiltIn; }
bool isArray() const { return pod.flagBits.isArray; }
bool isActive() const { return pod.flagBits.active; }
bool isPatch() const { return pod.flagBits.isPatch; }
int getLocation() const { return pod.location; }
unsigned int getBasicTypeElementCount() const { return pod.basicTypeElementCount; }
unsigned int getArraySizeProduct() const { return pod.arraySizeProduct; }
uint32_t getId() const { return pod.id; }
sh::InterpolationType getInterpolation() const
{
return static_cast<sh::InterpolationType>(basicDataTypeStruct.interpolation);
return static_cast<sh::InterpolationType>(pod.interpolation);
}
void setLocation(int location) { basicDataTypeStruct.location = location; }
void setLocation(int location) { pod.location = location; }
void resetEffectiveLocation()
{
if (basicDataTypeStruct.flagBits.hasImplicitLocation)
if (pod.flagBits.hasImplicitLocation)
{
basicDataTypeStruct.location = -1;
pod.location = -1;
}
}
@@ -142,23 +136,23 @@ struct ProgramInput
int16_t basicTypeElementCount;
uint32_t id;
} basicDataTypeStruct;
} pod;
};
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
ANGLE_ENABLE_STRUCT_PADDING_WARNINGS
struct ProgramOutput
{
ProgramOutput() {}
ProgramOutput() = default;
ProgramOutput(const sh::ShaderVariable &var);
bool isBuiltIn() const { return podStruct.isBuiltIn; }
bool isArray() const { return podStruct.isArray; }
unsigned int getOutermostArraySize() const { return podStruct.outermostArraySize; }
bool isBuiltIn() const { return pod.isBuiltIn; }
bool isArray() const { return pod.isArray; }
unsigned int getOutermostArraySize() const { return pod.outermostArraySize; }
void resetEffectiveLocation()
{
if (podStruct.hasImplicitLocation)
if (pod.hasImplicitLocation)
{
podStruct.location = -1;
pod.location = -1;
}
}
@@ -181,7 +175,7 @@ struct ProgramOutput
uint32_t isArray : 1;
uint32_t hasImplicitLocation : 1;
uint32_t pad : 27;
} podStruct;
} pod;
};
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
@@ -255,50 +249,50 @@ class ProgramExecutable final : public angle::Subject
std::string getInfoLogString() const;
void resetInfoLog() const { mInfoLog->reset(); }
void resetLinkedShaderStages() { mPODStruct.linkedShaderStages.reset(); }
const ShaderBitSet getLinkedShaderStages() const { return mPODStruct.linkedShaderStages; }
void resetLinkedShaderStages() { mPod.linkedShaderStages.reset(); }
const ShaderBitSet getLinkedShaderStages() const { return mPod.linkedShaderStages; }
void setLinkedShaderStages(ShaderType shaderType)
{
mPODStruct.linkedShaderStages.set(shaderType);
mPod.linkedShaderStages.set(shaderType);
updateCanDrawWith();
}
bool hasLinkedShaderStage(ShaderType shaderType) const
{
ASSERT(shaderType != ShaderType::InvalidEnum);
return mPODStruct.linkedShaderStages[shaderType];
return mPod.linkedShaderStages[shaderType];
}
size_t getLinkedShaderStageCount() const { return mPODStruct.linkedShaderStages.count(); }
size_t getLinkedShaderStageCount() const { return mPod.linkedShaderStages.count(); }
bool hasLinkedGraphicsShader() const
{
return mPODStruct.linkedShaderStages.any() &&
mPODStruct.linkedShaderStages != gl::ShaderBitSet{gl::ShaderType::Compute};
return mPod.linkedShaderStages.any() &&
mPod.linkedShaderStages != gl::ShaderBitSet{gl::ShaderType::Compute};
}
bool hasLinkedTessellationShader() const
{
return mPODStruct.linkedShaderStages[ShaderType::TessEvaluation];
return mPod.linkedShaderStages[ShaderType::TessEvaluation];
}
ShaderType getFirstLinkedShaderStageType() const;
ShaderType getLastLinkedShaderStageType() const;
ShaderType getLinkedTransformFeedbackStage() const
{
return GetLastPreFragmentStage(mPODStruct.linkedShaderStages);
return GetLastPreFragmentStage(mPod.linkedShaderStages);
}
const AttributesMask &getActiveAttribLocationsMask() const
{
return mPODStruct.activeAttribLocationsMask;
return mPod.activeAttribLocationsMask;
}
bool isAttribLocationActive(size_t attribLocation) const
{
ASSERT(attribLocation < mPODStruct.activeAttribLocationsMask.size());
return mPODStruct.activeAttribLocationsMask[attribLocation];
ASSERT(attribLocation < mPod.activeAttribLocationsMask.size());
return mPod.activeAttribLocationsMask[attribLocation];
}
AttributesMask getNonBuiltinAttribLocationsMask() const { return mPODStruct.attributesMask; }
unsigned int getMaxActiveAttribLocation() const { return mPODStruct.maxActiveAttribLocation; }
ComponentTypeMask getAttributesTypeMask() const { return mPODStruct.attributesTypeMask; }
AttributesMask getAttributesMask() const { return mPODStruct.attributesMask; }
AttributesMask getNonBuiltinAttribLocationsMask() const { return mPod.attributesMask; }
unsigned int getMaxActiveAttribLocation() const { return mPod.maxActiveAttribLocation; }
ComponentTypeMask getAttributesTypeMask() const { return mPod.attributesTypeMask; }
AttributesMask getAttributesMask() const { return mPod.attributesMask; }
const ActiveTextureMask &getActiveSamplersMask() const { return mActiveSamplersMask; }
void setActiveTextureMask(ActiveTextureMask mask) { mActiveSamplersMask = mask; }
@@ -343,13 +337,13 @@ class ProgramExecutable final : public angle::Subject
{
return !getLinkedTransformFeedbackVaryings().empty();
}
bool usesFramebufferFetch() const { return (mPODStruct.fragmentInoutRange.length() > 0); }
bool usesFramebufferFetch() const { return (mPod.fragmentInoutRange.length() > 0); }
// Count the number of uniform and storage buffer declarations, counting arrays as one.
size_t getTransformFeedbackBufferCount() const { return mTransformFeedbackStrides.size(); }
void updateCanDrawWith() { mPODStruct.canDrawWith = hasLinkedShaderStage(ShaderType::Vertex); }
bool hasVertexShader() const { return mPODStruct.canDrawWith; }
void updateCanDrawWith() { mPod.canDrawWith = hasLinkedShaderStage(ShaderType::Vertex); }
bool hasVertexShader() const { return mPod.canDrawWith; }
const std::vector<ProgramInput> &getProgramInputs() const { return mProgramInputs; }
const std::vector<ProgramOutput> &getOutputVariables() const { return mOutputVariables; }
@@ -365,7 +359,7 @@ class ProgramExecutable final : public angle::Subject
const std::vector<VariableLocation> &getUniformLocations() const { return mUniformLocations; }
const UniformBlockBindingMask &getActiveUniformBlockBindings() const
{
return mPODStruct.activeUniformBlockBindings;
return mPod.activeUniformBlockBindings;
}
const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; }
const std::vector<GLuint> &getSamplerBoundTextureUnits() const
@@ -374,29 +368,23 @@ class ProgramExecutable final : public angle::Subject
}
const std::vector<ImageBinding> &getImageBindings() const { return mImageBindings; }
std::vector<ImageBinding> *getImageBindings() { return &mImageBindings; }
const RangeUI &getDefaultUniformRange() const { return mPODStruct.defaultUniformRange; }
const RangeUI &getSamplerUniformRange() const { return mPODStruct.samplerUniformRange; }
const RangeUI &getImageUniformRange() const { return mPODStruct.imageUniformRange; }
const RangeUI &getAtomicCounterUniformRange() const
{
return mPODStruct.atomicCounterUniformRange;
}
const RangeUI &getFragmentInoutRange() const { return mPODStruct.fragmentInoutRange; }
bool hasClipDistance() const { return mPODStruct.hasClipDistance; }
bool hasDiscard() const { return mPODStruct.hasDiscard; }
bool enablesPerSampleShading() const { return mPODStruct.enablesPerSampleShading; }
BlendEquationBitSet getAdvancedBlendEquations() const
{
return mPODStruct.advancedBlendEquations;
}
const RangeUI &getDefaultUniformRange() const { return mPod.defaultUniformRange; }
const RangeUI &getSamplerUniformRange() const { return mPod.samplerUniformRange; }
const RangeUI &getImageUniformRange() const { return mPod.imageUniformRange; }
const RangeUI &getAtomicCounterUniformRange() const { return mPod.atomicCounterUniformRange; }
const RangeUI &getFragmentInoutRange() const { return mPod.fragmentInoutRange; }
bool hasClipDistance() const { return mPod.hasClipDistance; }
bool hasDiscard() const { return mPod.hasDiscard; }
bool enablesPerSampleShading() const { return mPod.enablesPerSampleShading; }
BlendEquationBitSet getAdvancedBlendEquations() const { return mPod.advancedBlendEquations; }
const std::vector<TransformFeedbackVarying> &getLinkedTransformFeedbackVaryings() const
{
return mLinkedTransformFeedbackVaryings;
}
GLint getTransformFeedbackBufferMode() const { return mPODStruct.transformFeedbackBufferMode; }
GLint getTransformFeedbackBufferMode() const { return mPod.transformFeedbackBufferMode; }
const sh::WorkGroupSize &getComputeShaderLocalSize() const
{
return mPODStruct.computeShaderLocalSize;
return mPod.computeShaderLocalSize;
}
GLuint getUniformBlockBinding(size_t uniformBlockIndex) const
{
@@ -449,14 +437,14 @@ class ProgramExecutable final : public angle::Subject
GLuint getUniformIndexFromImageIndex(size_t imageIndex) const
{
ASSERT(imageIndex < mPODStruct.imageUniformRange.length());
return static_cast<GLuint>(imageIndex) + mPODStruct.imageUniformRange.low();
ASSERT(imageIndex < mPod.imageUniformRange.length());
return static_cast<GLuint>(imageIndex) + mPod.imageUniformRange.low();
}
GLuint getUniformIndexFromSamplerIndex(size_t samplerIndex) const
{
ASSERT(samplerIndex < mPODStruct.samplerUniformRange.length());
return static_cast<GLuint>(samplerIndex) + mPODStruct.samplerUniformRange.low();
ASSERT(samplerIndex < mPod.samplerUniformRange.length());
return static_cast<GLuint>(samplerIndex) + mPod.samplerUniformRange.low();
}
void saveLinkedStateInfo(const ProgramState &state);
@@ -481,39 +469,39 @@ class ProgramExecutable final : public angle::Subject
int getLinkedShaderVersion(ShaderType shaderType) const
{
return mPODStruct.linkedShaderVersions[shaderType];
return mPod.linkedShaderVersions[shaderType];
}
bool isYUVOutput() const { return mPODStruct.hasYUVOutput; }
bool isYUVOutput() const { return mPod.hasYUVOutput; }
PrimitiveMode getGeometryShaderInputPrimitiveType() const
{
return mPODStruct.geometryShaderInputPrimitiveType;
return mPod.geometryShaderInputPrimitiveType;
}
PrimitiveMode getGeometryShaderOutputPrimitiveType() const
{
return mPODStruct.geometryShaderOutputPrimitiveType;
return mPod.geometryShaderOutputPrimitiveType;
}
int getGeometryShaderInvocations() const { return mPODStruct.geometryShaderInvocations; }
int getGeometryShaderInvocations() const { return mPod.geometryShaderInvocations; }
int getGeometryShaderMaxVertices() const { return mPODStruct.geometryShaderMaxVertices; }
int getGeometryShaderMaxVertices() const { return mPod.geometryShaderMaxVertices; }
GLint getTessControlShaderVertices() const { return mPODStruct.tessControlShaderVertices; }
GLenum getTessGenMode() const { return mPODStruct.tessGenMode; }
GLenum getTessGenPointMode() const { return mPODStruct.tessGenPointMode; }
GLenum getTessGenSpacing() const { return mPODStruct.tessGenSpacing; }
GLenum getTessGenVertexOrder() const { return mPODStruct.tessGenVertexOrder; }
GLint getTessControlShaderVertices() const { return mPod.tessControlShaderVertices; }
GLenum getTessGenMode() const { return mPod.tessGenMode; }
GLenum getTessGenPointMode() const { return mPod.tessGenPointMode; }
GLenum getTessGenSpacing() const { return mPod.tessGenSpacing; }
GLenum getTessGenVertexOrder() const { return mPod.tessGenVertexOrder; }
int getNumViews() const { return mPODStruct.numViews; }
bool usesMultiview() const { return mPODStruct.numViews != -1; }
int getNumViews() const { return mPod.numViews; }
bool usesMultiview() const { return mPod.numViews != -1; }
rx::SpecConstUsageBits getSpecConstUsageBits() const { return mPODStruct.specConstUsageBits; }
rx::SpecConstUsageBits getSpecConstUsageBits() const { return mPod.specConstUsageBits; }
int getDrawIDLocation() const { return mPODStruct.drawIDLocation; }
int getBaseVertexLocation() const { return mPODStruct.baseVertexLocation; }
int getBaseInstanceLocation() const { return mPODStruct.baseInstanceLocation; }
int getDrawIDLocation() const { return mPod.drawIDLocation; }
int getBaseVertexLocation() const { return mPod.baseVertexLocation; }
int getBaseInstanceLocation() const { return mPod.baseInstanceLocation; }
bool hasDrawIDUniform() const { return getDrawIDLocation() >= 0; }
bool hasBaseVertexUniform() const { return getBaseVertexLocation() >= 0; }
@@ -533,14 +521,11 @@ class ProgramExecutable final : public angle::Subject
return validateSamplersImpl(caps);
}
ComponentTypeMask getFragmentOutputsTypeMask() const { return mPODStruct.drawBufferTypeMask; }
DrawBufferMask getActiveOutputVariablesMask() const
{
return mPODStruct.activeOutputVariablesMask;
}
ComponentTypeMask getFragmentOutputsTypeMask() const { return mPod.drawBufferTypeMask; }
DrawBufferMask getActiveOutputVariablesMask() const { return mPod.activeOutputVariablesMask; }
DrawBufferMask getActiveSecondaryOutputVariablesMask() const
{
return mPODStruct.activeSecondaryOutputVariablesMask;
return mPod.activeSecondaryOutputVariablesMask;
}
GLuint getInputResourceIndex(const GLchar *name) const;
@@ -872,7 +857,7 @@ class ProgramExecutable final : public angle::Subject
UniformBlockBindingMask activeUniformBlockBindings;
// 24 bytes
ShaderMap<int> linkedShaderVersions;
} mPODStruct;
} mPod;
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
// Cached mask of active samplers and sampler types.

View File

@@ -143,7 +143,7 @@ void ProgramPipelineState::updateExecutableSpecConstUsageBits()
ASSERT(programExecutable);
specConstUsageBits |= programExecutable->getSpecConstUsageBits();
}
mExecutable->mPODStruct.specConstUsageBits = specConstUsageBits;
mExecutable->mPod.specConstUsageBits = specConstUsageBits;
}
ProgramPipeline::ProgramPipeline(rx::GLImplFactory *factory, ProgramPipelineID handle)
@@ -302,21 +302,18 @@ void ProgramPipeline::updateExecutableAttributes()
return;
}
mState.mExecutable->mPODStruct.activeAttribLocationsMask =
vertexExecutable->mPODStruct.activeAttribLocationsMask;
mState.mExecutable->mPODStruct.maxActiveAttribLocation =
vertexExecutable->mPODStruct.maxActiveAttribLocation;
mState.mExecutable->mPODStruct.attributesTypeMask =
vertexExecutable->mPODStruct.attributesTypeMask;
mState.mExecutable->mPODStruct.attributesMask = vertexExecutable->mPODStruct.attributesMask;
mState.mExecutable->mProgramInputs = vertexExecutable->mProgramInputs;
mState.mExecutable->mPod.activeAttribLocationsMask =
vertexExecutable->mPod.activeAttribLocationsMask;
mState.mExecutable->mPod.maxActiveAttribLocation =
vertexExecutable->mPod.maxActiveAttribLocation;
mState.mExecutable->mPod.attributesTypeMask = vertexExecutable->mPod.attributesTypeMask;
mState.mExecutable->mPod.attributesMask = vertexExecutable->mPod.attributesMask;
mState.mExecutable->mProgramInputs = vertexExecutable->mProgramInputs;
mState.mExecutable->mPODStruct.numViews = vertexExecutable->mPODStruct.numViews;
mState.mExecutable->mPODStruct.drawIDLocation = vertexExecutable->mPODStruct.drawIDLocation;
mState.mExecutable->mPODStruct.baseVertexLocation =
vertexExecutable->mPODStruct.baseVertexLocation;
mState.mExecutable->mPODStruct.baseInstanceLocation =
vertexExecutable->mPODStruct.baseInstanceLocation;
mState.mExecutable->mPod.numViews = vertexExecutable->mPod.numViews;
mState.mExecutable->mPod.drawIDLocation = vertexExecutable->mPod.drawIDLocation;
mState.mExecutable->mPod.baseVertexLocation = vertexExecutable->mPod.baseVertexLocation;
mState.mExecutable->mPod.baseInstanceLocation = vertexExecutable->mPod.baseInstanceLocation;
}
void ProgramPipeline::updateTransformFeedbackMembers()
@@ -399,14 +396,14 @@ void ProgramPipeline::updateExecutableGeometryProperties()
return;
}
mState.mExecutable->mPODStruct.geometryShaderInputPrimitiveType =
geometryExecutable->mPODStruct.geometryShaderInputPrimitiveType;
mState.mExecutable->mPODStruct.geometryShaderOutputPrimitiveType =
geometryExecutable->mPODStruct.geometryShaderOutputPrimitiveType;
mState.mExecutable->mPODStruct.geometryShaderInvocations =
geometryExecutable->mPODStruct.geometryShaderInvocations;
mState.mExecutable->mPODStruct.geometryShaderMaxVertices =
geometryExecutable->mPODStruct.geometryShaderMaxVertices;
mState.mExecutable->mPod.geometryShaderInputPrimitiveType =
geometryExecutable->mPod.geometryShaderInputPrimitiveType;
mState.mExecutable->mPod.geometryShaderOutputPrimitiveType =
geometryExecutable->mPod.geometryShaderOutputPrimitiveType;
mState.mExecutable->mPod.geometryShaderInvocations =
geometryExecutable->mPod.geometryShaderInvocations;
mState.mExecutable->mPod.geometryShaderMaxVertices =
geometryExecutable->mPod.geometryShaderMaxVertices;
}
void ProgramPipeline::updateExecutableTessellationProperties()
@@ -418,19 +415,16 @@ void ProgramPipeline::updateExecutableTessellationProperties()
if (tessControlExecutable)
{
mState.mExecutable->mPODStruct.tessControlShaderVertices =
tessControlExecutable->mPODStruct.tessControlShaderVertices;
mState.mExecutable->mPod.tessControlShaderVertices =
tessControlExecutable->mPod.tessControlShaderVertices;
}
if (tessEvalExecutable)
{
mState.mExecutable->mPODStruct.tessGenMode = tessEvalExecutable->mPODStruct.tessGenMode;
mState.mExecutable->mPODStruct.tessGenSpacing =
tessEvalExecutable->mPODStruct.tessGenSpacing;
mState.mExecutable->mPODStruct.tessGenVertexOrder =
tessEvalExecutable->mPODStruct.tessGenVertexOrder;
mState.mExecutable->mPODStruct.tessGenPointMode =
tessEvalExecutable->mPODStruct.tessGenPointMode;
mState.mExecutable->mPod.tessGenMode = tessEvalExecutable->mPod.tessGenMode;
mState.mExecutable->mPod.tessGenSpacing = tessEvalExecutable->mPod.tessGenSpacing;
mState.mExecutable->mPod.tessGenVertexOrder = tessEvalExecutable->mPod.tessGenVertexOrder;
mState.mExecutable->mPod.tessGenPointMode = tessEvalExecutable->mPod.tessGenPointMode;
}
}
@@ -444,11 +438,10 @@ void ProgramPipeline::updateFragmentInoutRangeAndEnablesPerSampleShading()
return;
}
mState.mExecutable->mPODStruct.fragmentInoutRange =
fragmentExecutable->mPODStruct.fragmentInoutRange;
mState.mExecutable->mPODStruct.hasDiscard = fragmentExecutable->mPODStruct.hasDiscard;
mState.mExecutable->mPODStruct.enablesPerSampleShading =
fragmentExecutable->mPODStruct.enablesPerSampleShading;
mState.mExecutable->mPod.fragmentInoutRange = fragmentExecutable->mPod.fragmentInoutRange;
mState.mExecutable->mPod.hasDiscard = fragmentExecutable->mPod.hasDiscard;
mState.mExecutable->mPod.enablesPerSampleShading =
fragmentExecutable->mPod.enablesPerSampleShading;
}
void ProgramPipeline::updateLinkedVaryings()

View File

@@ -13,39 +13,6 @@
namespace gl
{
ActiveVariable::ActiveVariable()
{
std::fill(mIds.begin(), mIds.end(), 0);
}
ActiveVariable::~ActiveVariable() {}
ActiveVariable::ActiveVariable(const ActiveVariable &rhs) = default;
ActiveVariable &ActiveVariable::operator=(const ActiveVariable &rhs) = default;
void ActiveVariable::setActive(ShaderType shaderType, bool used, uint32_t id)
{
ASSERT(shaderType != ShaderType::InvalidEnum);
mActiveUseBits.set(shaderType, used);
mIds[shaderType] = id;
}
void ActiveVariable::unionReferencesWith(const LinkedUniform &other)
{
mActiveUseBits |= other.mActiveUseBits;
for (const ShaderType shaderType : AllShaderTypes())
{
ASSERT(mIds[shaderType] == 0 || other.getId(shaderType) == 0 ||
mIds[shaderType] == other.getId(shaderType));
if (mIds[shaderType] == 0)
{
mIds[shaderType] = other.getId(shaderType);
}
}
}
LinkedUniform::LinkedUniform() = default;
LinkedUniform::LinkedUniform(GLenum typeIn,
GLenum precisionIn,
const std::vector<unsigned int> &arraySizesIn,
@@ -59,22 +26,22 @@ LinkedUniform::LinkedUniform(GLenum typeIn,
ASSERT(arraySizesIn.size() <= 1);
memset(this, 0, sizeof(*this));
SetBitField(type, typeIn);
SetBitField(precision, precisionIn);
location = locationIn;
SetBitField(binding, bindingIn);
SetBitField(offset, offsetIn);
SetBitField(bufferIndex, bufferIndexIn);
outerArraySizeProduct = 1;
SetBitField(arraySize, arraySizesIn.empty() ? 1u : arraySizesIn[0]);
SetBitField(flagBits.isArray, !arraySizesIn.empty());
SetBitField(pod.type, typeIn);
SetBitField(pod.precision, precisionIn);
pod.location = locationIn;
SetBitField(pod.binding, bindingIn);
SetBitField(pod.offset, offsetIn);
SetBitField(pod.bufferIndex, bufferIndexIn);
pod.outerArraySizeProduct = 1;
SetBitField(pod.arraySize, arraySizesIn.empty() ? 1u : arraySizesIn[0]);
SetBitField(pod.flagBits.isArray, !arraySizesIn.empty());
if (!(blockInfoIn == sh::kDefaultBlockMemberInfo))
{
flagBits.isBlock = 1;
flagBits.blockIsRowMajorMatrix = blockInfoIn.isRowMajorMatrix;
SetBitField(blockOffset, blockInfoIn.offset);
SetBitField(blockArrayStride, blockInfoIn.arrayStride);
SetBitField(blockMatrixStride, blockInfoIn.matrixStride);
pod.flagBits.isBlock = 1;
pod.flagBits.blockIsRowMajorMatrix = blockInfoIn.isRowMajorMatrix;
SetBitField(pod.blockOffset, blockInfoIn.offset);
SetBitField(pod.blockArrayStride, blockInfoIn.arrayStride);
SetBitField(pod.blockMatrixStride, blockInfoIn.matrixStride);
}
}
@@ -86,31 +53,31 @@ LinkedUniform::LinkedUniform(const UsedUniform &usedUniform)
ASSERT(usedUniform.blockInfo == sh::kDefaultBlockMemberInfo);
// Note: Ensure every data member is initialized.
flagBitsAsUByte = 0;
SetBitField(type, usedUniform.type);
SetBitField(precision, usedUniform.precision);
SetBitField(imageUnitFormat, usedUniform.imageUnitFormat);
location = usedUniform.location;
blockOffset = 0;
blockArrayStride = 0;
blockMatrixStride = 0;
SetBitField(binding, usedUniform.binding);
SetBitField(offset, usedUniform.offset);
pod.flagBitsAsUByte = 0;
SetBitField(pod.type, usedUniform.type);
SetBitField(pod.precision, usedUniform.precision);
SetBitField(pod.imageUnitFormat, usedUniform.imageUnitFormat);
pod.location = usedUniform.location;
pod.blockOffset = 0;
pod.blockArrayStride = 0;
pod.blockMatrixStride = 0;
SetBitField(pod.binding, usedUniform.binding);
SetBitField(pod.offset, usedUniform.offset);
SetBitField(bufferIndex, usedUniform.bufferIndex);
SetBitField(parentArrayIndex, usedUniform.parentArrayIndex());
SetBitField(outerArraySizeProduct, ArraySizeProduct(usedUniform.outerArraySizes));
SetBitField(outerArrayOffset, usedUniform.outerArrayOffset);
SetBitField(arraySize, usedUniform.isArray() ? usedUniform.getArraySizeProduct() : 1u);
SetBitField(flagBits.isArray, usedUniform.isArray());
SetBitField(pod.bufferIndex, usedUniform.bufferIndex);
SetBitField(pod.parentArrayIndex, usedUniform.parentArrayIndex());
SetBitField(pod.outerArraySizeProduct, ArraySizeProduct(usedUniform.outerArraySizes));
SetBitField(pod.outerArrayOffset, usedUniform.outerArrayOffset);
SetBitField(pod.arraySize, usedUniform.isArray() ? usedUniform.getArraySizeProduct() : 1u);
SetBitField(pod.flagBits.isArray, usedUniform.isArray());
id = usedUniform.id;
mActiveUseBits = usedUniform.activeVariable.activeShaders();
mIds = usedUniform.activeVariable.getIds();
pod.id = usedUniform.id;
pod.activeUseBits = usedUniform.activeVariable.activeShaders();
pod.ids = usedUniform.activeVariable.getIds();
SetBitField(flagBits.isFragmentInOut, usedUniform.isFragmentInOut);
SetBitField(flagBits.texelFetchStaticUse, usedUniform.texelFetchStaticUse);
ASSERT(!usedUniform.isArray() || arraySize == usedUniform.getArraySizeProduct());
SetBitField(pod.flagBits.isFragmentInOut, usedUniform.isFragmentInOut);
SetBitField(pod.flagBits.texelFetchStaticUse, usedUniform.texelFetchStaticUse);
ASSERT(!usedUniform.isArray() || pod.arraySize == usedUniform.getArraySizeProduct());
}
BufferVariable::BufferVariable()
@@ -147,7 +114,7 @@ ShaderVariableBuffer::ShaderVariableBuffer()
void ShaderVariableBuffer::unionReferencesWith(const LinkedUniform &other)
{
pod.activeUseBits |= other.mActiveUseBits;
pod.activeUseBits |= other.pod.activeUseBits;
for (const ShaderType shaderType : AllShaderTypes())
{
ASSERT(pod.ids[shaderType] == 0 || other.getId(shaderType) == 0 ||

View File

@@ -25,37 +25,51 @@ struct UniformTypeInfo;
struct UsedUniform;
struct LinkedUniform;
// Note: keep this struct memcpy-able: i.e, a simple struct with basic types only and no virtual
// functions. LinkedUniform relies on this so that it can use memcpy to initialize uniform for
// performance.
#define ACTIVE_VARIABLE_COMMON_INTERFACES \
void setActive(ShaderType shaderType, bool used, uint32_t id) \
{ \
ASSERT(shaderType != ShaderType::InvalidEnum); \
pod.activeUseBits.set(shaderType, used); \
pod.ids[shaderType] = id; \
} \
ShaderType getFirstActiveShaderType() const \
{ \
return pod.activeUseBits.first(); \
} \
bool isActive(ShaderType shaderType) const \
{ \
return pod.activeUseBits[shaderType]; \
} \
const ShaderMap<uint32_t> &getIds() const \
{ \
return pod.ids; \
} \
uint32_t getId(ShaderType shaderType) const \
{ \
return pod.ids[shaderType]; \
} \
ShaderBitSet activeShaders() const \
{ \
return pod.activeUseBits; \
} \
uint32_t activeShaderCount() const \
{ \
return static_cast<uint32_t>(pod.activeUseBits.count()); \
}
struct ActiveVariable
{
ActiveVariable();
ActiveVariable(const ActiveVariable &rhs);
~ActiveVariable();
ActiveVariable() { memset(&pod, 0, sizeof(pod)); }
ActiveVariable &operator=(const ActiveVariable &rhs);
ACTIVE_VARIABLE_COMMON_INTERFACES
ShaderType getFirstActiveShaderType() const
struct PODStruct
{
return static_cast<ShaderType>(ScanForward(mActiveUseBits.bits()));
}
void setActive(ShaderType shaderType, bool used, uint32_t id);
void unionReferencesWith(const LinkedUniform &otherUniform);
bool isActive(ShaderType shaderType) const
{
ASSERT(shaderType != ShaderType::InvalidEnum);
return mActiveUseBits[shaderType];
}
const ShaderMap<uint32_t> &getIds() const { return mIds; }
uint32_t getId(ShaderType shaderType) const { return mIds[shaderType]; }
ShaderBitSet activeShaders() const { return mActiveUseBits; }
private:
ShaderBitSet mActiveUseBits;
// The id of a linked variable in each shader stage. This id originates from
// sh::ShaderVariable::id or sh::InterfaceBlock::id
ShaderMap<uint32_t> mIds;
ShaderBitSet activeUseBits;
// The id of a linked variable in each shader stage. This id originates from
// sh::ShaderVariable::id or sh::InterfaceBlock::id
ShaderMap<uint32_t> ids;
} pod;
};
// Important: This struct must have basic data types only, so that we can initialize with memcpy. Do
@@ -65,7 +79,7 @@ struct ActiveVariable
ANGLE_ENABLE_STRUCT_PADDING_WARNINGS
struct LinkedUniform
{
LinkedUniform();
LinkedUniform() = default;
LinkedUniform(GLenum typeIn,
GLenum precisionIn,
const std::vector<unsigned int> &arraySizesIn,
@@ -76,91 +90,80 @@ struct LinkedUniform
const sh::BlockMemberInfo &blockInfoIn);
LinkedUniform(const UsedUniform &usedUniform);
bool isSampler() const { return GetUniformTypeInfo(type).isSampler; }
bool isImage() const { return GetUniformTypeInfo(type).isImageType; }
bool isAtomicCounter() const { return IsAtomicCounterType(type); }
bool isInDefaultBlock() const { return bufferIndex == -1; }
size_t getElementSize() const { return GetUniformTypeInfo(type).externalSize; }
GLint getElementComponents() const { return GetUniformTypeInfo(type).componentCount; }
bool isSampler() const { return GetUniformTypeInfo(pod.type).isSampler; }
bool isImage() const { return GetUniformTypeInfo(pod.type).isImageType; }
bool isAtomicCounter() const { return IsAtomicCounterType(pod.type); }
bool isInDefaultBlock() const { return pod.bufferIndex == -1; }
size_t getElementSize() const { return GetUniformTypeInfo(pod.type).externalSize; }
GLint getElementComponents() const { return GetUniformTypeInfo(pod.type).componentCount; }
bool isTexelFetchStaticUse() const { return flagBits.texelFetchStaticUse; }
bool isFragmentInOut() const { return flagBits.isFragmentInOut; }
bool isTexelFetchStaticUse() const { return pod.flagBits.texelFetchStaticUse; }
bool isFragmentInOut() const { return pod.flagBits.isFragmentInOut; }
bool isArray() const { return flagBits.isArray; }
bool isArray() const { return pod.flagBits.isArray; }
uint16_t getBasicTypeElementCount() const
{
ASSERT(flagBits.isArray || arraySize == 1u);
return arraySize;
ASSERT(pod.flagBits.isArray || pod.arraySize == 1u);
return pod.arraySize;
}
GLenum getType() const { return type; }
uint16_t getOuterArrayOffset() const { return outerArrayOffset; }
uint16_t getOuterArraySizeProduct() const { return outerArraySizeProduct; }
int16_t getBinding() const { return binding; }
int16_t getOffset() const { return offset; }
int getBufferIndex() const { return bufferIndex; }
int getLocation() const { return location; }
GLenum getImageUnitFormat() const { return imageUnitFormat; }
GLenum getType() const { return pod.type; }
uint16_t getOuterArrayOffset() const { return pod.outerArrayOffset; }
uint16_t getOuterArraySizeProduct() const { return pod.outerArraySizeProduct; }
int16_t getBinding() const { return pod.binding; }
int16_t getOffset() const { return pod.offset; }
int getBufferIndex() const { return pod.bufferIndex; }
int getLocation() const { return pod.location; }
GLenum getImageUnitFormat() const { return pod.imageUnitFormat; }
ShaderType getFirstActiveShaderType() const
ACTIVE_VARIABLE_COMMON_INTERFACES
struct PODStruct
{
return static_cast<ShaderType>(ScanForward(mActiveUseBits.bits()));
}
void setActive(ShaderType shaderType, bool used, uint32_t _id)
{
mActiveUseBits.set(shaderType, used);
mIds[shaderType] = id;
}
bool isActive(ShaderType shaderType) const { return mActiveUseBits[shaderType]; }
const ShaderMap<uint32_t> &getIds() const { return mIds; }
uint32_t getId(ShaderType shaderType) const { return mIds[shaderType]; }
ShaderBitSet activeShaders() const { return mActiveUseBits; }
GLuint activeShaderCount() const { return static_cast<GLuint>(mActiveUseBits.count()); }
uint16_t type;
uint16_t precision;
uint16_t type;
uint16_t precision;
int32_t location;
int location;
// These are from sh::struct BlockMemberInfo struct. See locklayout.h for detail.
uint16_t blockOffset;
uint16_t blockArrayStride;
// These are from sh::struct BlockMemberInfo struct. See locklayout.h for detail.
uint16_t blockOffset;
uint16_t blockArrayStride;
uint16_t blockMatrixStride;
uint16_t imageUnitFormat;
uint16_t blockMatrixStride;
uint16_t imageUnitFormat;
// maxUniformVectorsCount is 4K due to we clamp maxUniformBlockSize to 64KB. All of these
// variable should be enough to pack into 16 bits to reduce the size of mUniforms.
int16_t binding;
int16_t bufferIndex;
// maxUniformVectorsCount is 4K due to we clamp maxUniformBlockSize to 64KB. All of these
// variable should be enough to pack into 16 bits to reduce the size of mUniforms.
int16_t binding;
int16_t bufferIndex;
int16_t offset;
uint16_t arraySize;
int16_t offset;
uint16_t arraySize;
uint16_t outerArraySizeProduct;
uint16_t outerArrayOffset;
uint16_t outerArraySizeProduct;
uint16_t outerArrayOffset;
uint16_t parentArrayIndex;
union
{
struct
uint16_t parentArrayIndex;
union
{
uint8_t isFragmentInOut : 1;
uint8_t texelFetchStaticUse : 1;
uint8_t isArray : 1;
uint8_t blockIsRowMajorMatrix : 1;
uint8_t isBlock : 1;
uint8_t padding : 3;
} flagBits;
uint8_t flagBitsAsUByte;
};
ShaderBitSet mActiveUseBits;
struct
{
uint8_t isFragmentInOut : 1;
uint8_t texelFetchStaticUse : 1;
uint8_t isArray : 1;
uint8_t blockIsRowMajorMatrix : 1;
uint8_t isBlock : 1;
uint8_t padding : 3;
} flagBits;
uint8_t flagBitsAsUByte;
};
ShaderBitSet activeUseBits;
uint32_t id;
// The id of a linked variable in each shader stage. This id originates from
// sh::ShaderVariable::id or sh::InterfaceBlock::id
ShaderMap<uint32_t> mIds;
uint32_t id;
// The id of a linked variable in each shader stage. This id originates from
// sh::ShaderVariable::id or sh::InterfaceBlock::id
ShaderMap<uint32_t> ids;
} pod;
};
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
@@ -179,14 +182,7 @@ struct BufferVariable
bool isArray() const { return pod.isArray; }
uint32_t getBasicTypeElementCount() const { return pod.basicTypeElementCount; }
void setActive(ShaderType shaderType, bool used, uint32_t id)
{
pod.activeUseBits.set(shaderType, used);
pod.ids[shaderType] = id;
}
bool isActive(ShaderType shaderType) const { return pod.activeUseBits[shaderType]; }
uint32_t getId(ShaderType shaderType) const { return pod.ids[shaderType]; }
ShaderBitSet activeShaders() const { return pod.activeUseBits; }
ACTIVE_VARIABLE_COMMON_INTERFACES
std::string name;
std::string mappedName;
@@ -222,14 +218,7 @@ struct ShaderVariableBuffer
ShaderVariableBuffer();
~ShaderVariableBuffer() {}
ShaderType getFirstActiveShaderType() const
{
return static_cast<ShaderType>(ScanForward(pod.activeUseBits.bits()));
}
bool isActive(ShaderType shaderType) const { return pod.activeUseBits[shaderType]; }
const ShaderMap<uint32_t> &getIds() const { return pod.ids; }
uint32_t getId(ShaderType shaderType) const { return pod.ids[shaderType]; }
ShaderBitSet activeShaders() const { return pod.activeUseBits; }
ACTIVE_VARIABLE_COMMON_INTERFACES
int numActiveVariables() const { return static_cast<int>(memberIndexes.size()); }
void unionReferencesWith(const LinkedUniform &otherUniform);
@@ -266,19 +255,7 @@ struct InterfaceBlock
std::string nameWithArrayIndex() const;
std::string mappedNameWithArrayIndex() const;
ShaderType getFirstActiveShaderType() const
{
return static_cast<ShaderType>(ScanForward(pod.activeUseBits.bits()));
}
void setActive(ShaderType shaderType, bool used, uint32_t id)
{
pod.activeUseBits.set(shaderType, used);
pod.ids[shaderType] = id;
}
bool isActive(ShaderType shaderType) const { return pod.activeUseBits[shaderType]; }
const ShaderMap<uint32_t> &getIds() const { return pod.ids; }
uint32_t getId(ShaderType shaderType) const { return pod.ids[shaderType]; }
ShaderBitSet activeShaders() const { return pod.activeUseBits; }
ACTIVE_VARIABLE_COMMON_INTERFACES
int numActiveVariables() const { return static_cast<int>(memberIndexes.size()); }
void setBinding(GLuint binding) { SetBitField(pod.binding, binding); }
@@ -308,6 +285,7 @@ struct InterfaceBlock
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
};
#undef ACTIVE_VARIABLE_COMMON_INTERFACES
} // namespace gl
#endif // LIBANGLE_UNIFORM_H_

View File

@@ -774,15 +774,15 @@ GLint GetOutputResourceProperty(const Program *program, GLuint index, const GLen
switch (prop)
{
case GL_TYPE:
return clampCast<GLint>(outputVariable.podStruct.type);
return clampCast<GLint>(outputVariable.pod.type);
case GL_ARRAY_SIZE:
return clampCast<GLint>(outputVariable.podStruct.basicTypeElementCount);
return clampCast<GLint>(outputVariable.pod.basicTypeElementCount);
case GL_NAME_LENGTH:
return clampCast<GLint>(executable.getOutputResourceName(index).size() + 1u);
case GL_LOCATION:
return outputVariable.podStruct.location;
return outputVariable.pod.location;
case GL_LOCATION_INDEX_EXT:
// EXT_blend_func_extended
@@ -809,7 +809,7 @@ GLint GetOutputResourceProperty(const Program *program, GLuint index, const GLen
case GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT:
return executable.getLastLinkedShaderStageType() == ShaderType::TessEvaluation;
case GL_IS_PER_PATCH_EXT:
return outputVariable.podStruct.isPatch;
return outputVariable.pod.isPatch;
default:
UNREACHABLE();
@@ -1946,16 +1946,16 @@ GLint GetUniformResourceProperty(const Program *program, GLuint index, const GLe
return (uniform.isAtomicCounter() ? -1 : uniform.getBufferIndex());
case GL_OFFSET:
return uniform.flagBits.isBlock ? uniform.blockOffset : -1;
return uniform.pod.flagBits.isBlock ? uniform.pod.blockOffset : -1;
case GL_ARRAY_STRIDE:
return uniform.flagBits.isBlock ? uniform.blockArrayStride : -1;
return uniform.pod.flagBits.isBlock ? uniform.pod.blockArrayStride : -1;
case GL_MATRIX_STRIDE:
return uniform.flagBits.isBlock ? uniform.blockMatrixStride : -1;
return uniform.pod.flagBits.isBlock ? uniform.pod.blockMatrixStride : -1;
case GL_IS_ROW_MAJOR:
return uniform.flagBits.blockIsRowMajorMatrix ? 1 : 0;
return uniform.pod.flagBits.blockIsRowMajorMatrix ? 1 : 0;
case GL_REFERENCED_BY_VERTEX_SHADER:
return uniform.isActive(ShaderType::Vertex);

View File

@@ -2075,7 +2075,7 @@ void ProgramExecutableD3D::assignSamplerRegisters(
// outermost array.
std::vector<unsigned int> subscripts;
const std::string baseName = gl::ParseResourceName(d3dUniform->name, &subscripts);
unsigned int registerOffset = mExecutable->getUniforms()[uniformIndex].parentArrayIndex *
unsigned int registerOffset = mExecutable->getUniforms()[uniformIndex].pod.parentArrayIndex *
d3dUniform->getArraySizeProduct();
bool hasUniform = false;
@@ -2174,7 +2174,7 @@ void ProgramExecutableD3D::assignImageRegisters(size_t uniformIndex)
// outermost array.
std::vector<unsigned int> subscripts;
const std::string baseName = gl::ParseResourceName(d3dUniform->name, &subscripts);
unsigned int registerOffset = mExecutable->getUniforms()[uniformIndex].parentArrayIndex *
unsigned int registerOffset = mExecutable->getUniforms()[uniformIndex].pod.parentArrayIndex *
d3dUniform->getArraySizeProduct();
const SharedCompiledShaderStateD3D &computeShader = mAttachedShaders[gl::ShaderType::Compute];

View File

@@ -423,13 +423,13 @@ void ProgramGL::linkJobImpl(const gl::Extensions &extensions)
{
const gl::ProgramOutput &outputVar =
executable.getOutputVariables()[outputLocation.index];
if (outputVar.podStruct.location == -1 || outputVar.podStruct.index == -1)
if (outputVar.pod.location == -1 || outputVar.pod.index == -1)
{
// We only need to assign the location and index via the API in case the
// variable doesn't have a shader-assigned location and index. If a
// variable doesn't have its location set in the shader it doesn't have
// the index set either.
ASSERT(outputVar.podStruct.index == -1);
ASSERT(outputVar.pod.index == -1);
mFunctions->bindFragDataLocationIndexed(
mProgramID, static_cast<int>(outputLocationIndex), 0,
outputVar.mappedName.c_str());
@@ -446,13 +446,13 @@ void ProgramGL::linkJobImpl(const gl::Extensions &extensions)
{
const gl::ProgramOutput &outputVar =
executable.getOutputVariables()[outputLocation.index];
if (outputVar.podStruct.location == -1 || outputVar.podStruct.index == -1)
if (outputVar.pod.location == -1 || outputVar.pod.index == -1)
{
// We only need to assign the location and index via the API in case the
// variable doesn't have a shader-assigned location and index. If a
// variable doesn't have its location set in the shader it doesn't have
// the index set either.
ASSERT(outputVar.podStruct.index == -1);
ASSERT(outputVar.pod.index == -1);
mFunctions->bindFragDataLocationIndexed(
mProgramID, static_cast<int>(outputLocationIndex), 1,
outputVar.mappedName.c_str());

View File

@@ -1520,7 +1520,7 @@ void ProgramExecutableMtl::setUniformImpl(GLint location,
return;
}
if (linkedUniform.type == entryPointType)
if (linkedUniform.pod.type == entryPointType)
{
for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{
@@ -1533,9 +1533,9 @@ void ProgramExecutableMtl::setUniformImpl(GLint location,
continue;
}
const GLint componentCount = (GLint)linkedUniform.getElementComponents();
const GLint baseComponentSize =
(GLint)mtl::GetMetalSizeForGLType(gl::VariableComponentType(linkedUniform.type));
const GLint componentCount = (GLint)linkedUniform.getElementComponents();
const GLint baseComponentSize = (GLint)mtl::GetMetalSizeForGLType(
gl::VariableComponentType(linkedUniform.pod.type));
UpdateDefaultUniformBlockWithElementSize(count, locationInfo.arrayIndex, componentCount,
v, baseComponentSize, layoutInfo,
&uniformBlock.uniformData);
@@ -1557,7 +1557,7 @@ void ProgramExecutableMtl::setUniformImpl(GLint location,
const GLint componentCount = linkedUniform.getElementComponents();
ASSERT(linkedUniform.type == gl::VariableBoolVectorType(entryPointType));
ASSERT(linkedUniform.pod.type == gl::VariableBoolVectorType(entryPointType));
GLint initialArrayOffset =
locationInfo.arrayIndex * layoutInfo.arrayStride + layoutInfo.offset;
@@ -1593,11 +1593,11 @@ void ProgramExecutableMtl::getUniformImpl(GLint location, T *v, GLenum entryPoin
const DefaultUniformBlockMtl &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
ASSERT(gl::GetUniformTypeInfo(linkedUniform.type).componentType == entryPointType ||
gl::GetUniformTypeInfo(linkedUniform.type).componentType ==
ASSERT(gl::GetUniformTypeInfo(linkedUniform.pod.type).componentType == entryPointType ||
gl::GetUniformTypeInfo(linkedUniform.pod.type).componentType ==
gl::VariableBoolVectorType(entryPointType));
const GLint baseComponentSize =
(GLint)mtl::GetMetalSizeForGLType(gl::VariableComponentType(linkedUniform.type));
(GLint)mtl::GetMetalSizeForGLType(gl::VariableComponentType(linkedUniform.pod.type));
if (gl::IsMatrixType(linkedUniform.getType()))
{

View File

@@ -227,8 +227,8 @@ std::string UpdateFragmentShaderOutputs(std::string shaderSourceIn,
const gl::ProgramOutput &outputVar = outputVariables[outputLocation.index];
ASSERT(outputVar.podStruct.location >= 0);
int elementLocation = outputVar.podStruct.location;
ASSERT(outputVar.pod.location >= 0);
int elementLocation = outputVar.pod.location;
stream.str("");
stream << outputVar.mappedName;
@@ -253,7 +253,7 @@ std::string UpdateFragmentShaderOutputs(std::string shaderSourceIn,
}
if (defineAlpha0 && elementLocation == 0 && !secondary &&
outputVar.podStruct.type == GL_FLOAT_VEC4)
outputVar.pod.type == GL_FLOAT_VEC4)
{
ASSERT(alphaOutputName.empty());
std::ostringstream nameStream;

View File

@@ -118,12 +118,12 @@ void SetupDefaultPipelineState(const vk::Context *context,
}
uint32_t location = 0;
if (outputVar.podStruct.location != -1)
if (outputVar.pod.location != -1)
{
location = outputVar.podStruct.location;
location = outputVar.pod.location;
}
GLenum type = gl::VariableComponentType(outputVar.podStruct.type);
GLenum type = gl::VariableComponentType(outputVar.pod.type);
angle::FormatID format = angle::FormatID::R8G8B8A8_UNORM;
if (type == GL_INT)
{
@@ -1770,7 +1770,7 @@ void ProgramExecutableVk::setUniformImpl(GLint location,
ASSERT(!linkedUniform.isSampler());
if (linkedUniform.type == entryPointType)
if (linkedUniform.pod.type == entryPointType)
{
for (const gl::ShaderType shaderType : mExecutable->getLinkedShaderStages())
{
@@ -1804,7 +1804,7 @@ void ProgramExecutableVk::setUniformImpl(GLint location,
const GLint componentCount = linkedUniform.getElementComponents();
ASSERT(linkedUniform.type == gl::VariableBoolVectorType(entryPointType));
ASSERT(linkedUniform.pod.type == gl::VariableBoolVectorType(entryPointType));
GLint initialArrayOffset =
locationInfo.arrayIndex * layoutInfo.arrayStride + layoutInfo.offset;
@@ -1840,8 +1840,8 @@ void ProgramExecutableVk::getUniformImpl(GLint location, T *v, GLenum entryPoint
const DefaultUniformBlockVk &uniformBlock = *mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
ASSERT(gl::GetUniformTypeInfo(linkedUniform.type).componentType == entryPointType ||
gl::GetUniformTypeInfo(linkedUniform.type).componentType ==
ASSERT(gl::GetUniformTypeInfo(linkedUniform.pod.type).componentType == entryPointType ||
gl::GetUniformTypeInfo(linkedUniform.pod.type).componentType ==
gl::VariableBoolVectorType(entryPointType));
if (gl::IsMatrixType(linkedUniform.getType()))

View File

@@ -22,7 +22,7 @@ uint32_t HashSPIRVId(uint32_t id)
void LoadShaderInterfaceVariableXfbInfo(gl::BinaryInputStream *stream,
ShaderInterfaceVariableXfbInfo *xfb)
{
stream->readStruct(&xfb->podStruct);
stream->readStruct(&xfb->pod);
xfb->arrayElements.resize(stream->readInt<size_t>());
for (ShaderInterfaceVariableXfbInfo &arrayElement : xfb->arrayElements)
{
@@ -33,7 +33,7 @@ void LoadShaderInterfaceVariableXfbInfo(gl::BinaryInputStream *stream,
void SaveShaderInterfaceVariableXfbInfo(const ShaderInterfaceVariableXfbInfo &xfb,
gl::BinaryOutputStream *stream)
{
stream->writeStruct(xfb.podStruct);
stream->writeStruct(xfb.pod);
stream->writeInt(xfb.arrayElements.size());
for (const ShaderInterfaceVariableXfbInfo &arrayElement : xfb.arrayElements)
{
@@ -51,7 +51,7 @@ void ShaderInterfaceVariableInfoMap::clear()
{
mData.clear();
mXFBData.clear();
memset(&mPodStruct, 0, sizeof(mPodStruct));
memset(&mPod, 0, sizeof(mPod));
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
mIdToIndexMap[shaderType].clear();
@@ -61,7 +61,7 @@ void ShaderInterfaceVariableInfoMap::clear()
void ShaderInterfaceVariableInfoMap::save(gl::BinaryOutputStream *stream)
{
ASSERT(mXFBData.size() <= mData.size());
stream->writeStruct(mPodStruct);
stream->writeStruct(mPod);
for (const IdToIndexMap &idToIndexMap : mIdToIndexMap)
{
@@ -74,7 +74,7 @@ void ShaderInterfaceVariableInfoMap::save(gl::BinaryOutputStream *stream)
}
stream->writeVector(mData);
if (mPodStruct.xfbInfoCount > 0)
if (mPod.xfbInfoCount > 0)
{
uint32_t xfbInfoCount = 0;
for (size_t xfbIndex = 0; xfbIndex < mXFBData.size(); xfbIndex++)
@@ -93,12 +93,12 @@ void ShaderInterfaceVariableInfoMap::save(gl::BinaryOutputStream *stream)
SaveShaderInterfaceVariableXfbInfo(xfb, stream);
}
}
ASSERT(xfbInfoCount == mPodStruct.xfbInfoCount);
ASSERT(xfbInfoCount == mPod.xfbInfoCount);
}
}
void ShaderInterfaceVariableInfoMap::load(gl::BinaryInputStream *stream)
{
stream->readStruct(&mPodStruct);
stream->readStruct(&mPod);
for (IdToIndexMap &idToIndexMap : mIdToIndexMap)
{
@@ -113,11 +113,11 @@ void ShaderInterfaceVariableInfoMap::load(gl::BinaryInputStream *stream)
stream->readVector(&mData);
ASSERT(mXFBData.empty());
ASSERT(mPodStruct.xfbInfoCount <= mData.size());
if (mPodStruct.xfbInfoCount > 0)
ASSERT(mPod.xfbInfoCount <= mData.size());
if (mPod.xfbInfoCount > 0)
{
mXFBData.resize(mData.size());
for (uint32_t i = 0; i < mPodStruct.xfbInfoCount; ++i)
for (uint32_t i = 0; i < mPod.xfbInfoCount; ++i)
{
size_t xfbIndex = stream->readInt<size_t>();
mXFBData[xfbIndex] = std::make_unique<XFBInterfaceVariableInfo>();
@@ -141,7 +141,7 @@ void ShaderInterfaceVariableInfoMap::setInputPerVertexActiveMembers(
ASSERT(shaderType == gl::ShaderType::TessControl ||
shaderType == gl::ShaderType::TessEvaluation || shaderType == gl::ShaderType::Geometry ||
activeMembers.none());
mPodStruct.inputPerVertexActiveMembers[shaderType] = activeMembers;
mPod.inputPerVertexActiveMembers[shaderType] = activeMembers;
}
void ShaderInterfaceVariableInfoMap::setOutputPerVertexActiveMembers(
@@ -152,7 +152,7 @@ void ShaderInterfaceVariableInfoMap::setOutputPerVertexActiveMembers(
ASSERT(shaderType == gl::ShaderType::Vertex || shaderType == gl::ShaderType::TessControl ||
shaderType == gl::ShaderType::TessEvaluation || shaderType == gl::ShaderType::Geometry ||
activeMembers.none());
mPodStruct.outputPerVertexActiveMembers[shaderType] = activeMembers;
mPod.outputPerVertexActiveMembers[shaderType] = activeMembers;
}
void ShaderInterfaceVariableInfoMap::setVariableIndex(gl::ShaderType shaderType,
@@ -189,7 +189,7 @@ XFBInterfaceVariableInfo *ShaderInterfaceVariableInfoMap::getXFBMutable(gl::Shad
{
mXFBData[index] = std::make_unique<XFBInterfaceVariableInfo>();
mData[index].hasTransformFeedback = true;
mPodStruct.xfbInfoCount++;
mPod.xfbInfoCount++;
}
return mXFBData[index].get();
}

View File

@@ -90,15 +90,15 @@ class ShaderInterfaceVariableInfoMap final : angle::NonCopyable
}
const gl::ShaderMap<gl::PerVertexMemberBitSet> &getInputPerVertexActiveMembers() const
{
return mPodStruct.inputPerVertexActiveMembers;
return mPod.inputPerVertexActiveMembers;
}
const gl::ShaderMap<gl::PerVertexMemberBitSet> &getOutputPerVertexActiveMembers() const
{
return mPodStruct.outputPerVertexActiveMembers;
return mPod.outputPerVertexActiveMembers;
}
void setHasAliasingAttributes() { mPodStruct.hasAliasingAttributes = true; }
bool hasAliasingAttributes() const { return mPodStruct.hasAliasingAttributes; }
void setHasAliasingAttributes() { mPod.hasAliasingAttributes = true; }
bool hasAliasingAttributes() const { return mPod.hasAliasingAttributes; }
private:
void setVariableIndex(gl::ShaderType shaderType, uint32_t id, VariableIndex index);
@@ -121,7 +121,7 @@ class ShaderInterfaceVariableInfoMap final : angle::NonCopyable
// Whether the vertex shader has aliasing attributes. Used by the SPIR-V transformer to
// tell if emulation is needed.
uint32_t hasAliasingAttributes : 1;
} mPodStruct;
} mPod;
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
};

View File

@@ -185,9 +185,9 @@ void SetXfbInfo(ShaderInterfaceVariableInfoMap *infoMap,
xfb = &info->fieldXfb[fieldIndex];
}
ASSERT(xfb->podStruct.buffer == ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb->podStruct.offset == ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb->podStruct.stride == ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb->pod.buffer == ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb->pod.offset == ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb->pod.stride == ShaderInterfaceVariableXfbInfo::kInvalid);
if (arrayIndex != ShaderInterfaceVariableXfbInfo::kInvalid)
{
@@ -195,14 +195,14 @@ void SetXfbInfo(ShaderInterfaceVariableInfoMap *infoMap,
xfb = &xfb->arrayElements.back();
}
xfb->podStruct.buffer = xfbBuffer;
xfb->podStruct.offset = xfbOffset;
xfb->podStruct.stride = xfbStride;
xfb->podStruct.arraySize = arraySize;
xfb->podStruct.columnCount = columnCount;
xfb->podStruct.rowCount = rowCount;
xfb->podStruct.arrayIndex = arrayIndex;
xfb->podStruct.componentType = componentType;
xfb->pod.buffer = xfbBuffer;
xfb->pod.offset = xfbOffset;
xfb->pod.stride = xfbStride;
xfb->pod.arraySize = arraySize;
xfb->pod.columnCount = columnCount;
xfb->pod.rowCount = rowCount;
xfb->pod.arrayIndex = arrayIndex;
xfb->pod.componentType = componentType;
}
void AssignTransformFeedbackEmulationBindings(gl::ShaderType shaderType,
@@ -343,14 +343,14 @@ void AssignSecondaryOutputLocations(const gl::ProgramExecutable &programExecutab
const gl::ProgramOutput &outputVar = outputVariables[outputLocation.index];
uint32_t location = 0;
if (outputVar.podStruct.location != -1)
if (outputVar.pod.location != -1)
{
location = outputVar.podStruct.location;
location = outputVar.pod.location;
}
ShaderInterfaceVariableInfo *info = AddLocationInfo(
variableInfoMapOut, gl::ShaderType::Fragment, outputVar.podStruct.id, location,
ShaderInterfaceVariableInfo::kInvalid, 0, 0);
ShaderInterfaceVariableInfo *info =
AddLocationInfo(variableInfoMapOut, gl::ShaderType::Fragment, outputVar.pod.id,
location, ShaderInterfaceVariableInfo::kInvalid, 0, 0);
// Index 1 is used to specify that the color be used as the second color input to
// the blend equation
@@ -372,9 +372,9 @@ void AssignSecondaryOutputLocations(const gl::ProgramExecutable &programExecutab
if (std::find(secondaryFrag.begin(), secondaryFrag.end(), outputVar.name) !=
secondaryFrag.end())
{
ShaderInterfaceVariableInfo *info = AddLocationInfo(
variableInfoMapOut, gl::ShaderType::Fragment, outputVar.podStruct.id, 0,
ShaderInterfaceVariableInfo::kInvalid, 0, 0);
ShaderInterfaceVariableInfo *info =
AddLocationInfo(variableInfoMapOut, gl::ShaderType::Fragment, outputVar.pod.id,
0, ShaderInterfaceVariableInfo::kInvalid, 0, 0);
info->index = 1;
@@ -407,9 +407,9 @@ void AssignOutputLocations(const gl::ProgramExecutable &programExecutable,
const gl::ProgramOutput &outputVar = outputVariables[outputLocation.index];
uint32_t location = 0;
if (outputVar.podStruct.location != -1)
if (outputVar.pod.location != -1)
{
location = outputVar.podStruct.location;
location = outputVar.pod.location;
}
else if (std::find(implicitOutputs.begin(), implicitOutputs.end(), outputVar.name) ==
implicitOutputs.end())
@@ -420,7 +420,7 @@ void AssignOutputLocations(const gl::ProgramExecutable &programExecutable,
implicitOutputs.begin(), implicitOutputs.end()) == 1);
}
AddLocationInfo(variableInfoMapOut, shaderType, outputVar.podStruct.id, location,
AddLocationInfo(variableInfoMapOut, shaderType, outputVar.pod.id, location,
ShaderInterfaceVariableInfo::kInvalid, 0, 0);
}
}
@@ -432,9 +432,8 @@ void AssignOutputLocations(const gl::ProgramExecutable &programExecutable,
{
if (outputVar.name == "gl_FragColor" || outputVar.name == "gl_FragData")
{
AddLocationInfo(variableInfoMapOut, gl::ShaderType::Fragment,
outputVar.podStruct.id, 0, ShaderInterfaceVariableInfo::kInvalid, 0,
0);
AddLocationInfo(variableInfoMapOut, gl::ShaderType::Fragment, outputVar.pod.id, 0,
ShaderInterfaceVariableInfo::kInvalid, 0, 0);
}
}
}
@@ -1771,7 +1770,7 @@ void SpirvTransformFeedbackCodeGenerator::visitVariable(const ShaderInterfaceVar
// Note if the variable is captured by transform feedback. In that case, the TransformFeedback
// capability needs to be added.
if ((xfbInfo.xfb.podStruct.buffer != ShaderInterfaceVariableInfo::kInvalid ||
if ((xfbInfo.xfb.pod.buffer != ShaderInterfaceVariableInfo::kInvalid ||
!xfbInfo.fieldXfb.empty()) &&
info.activeStages[shaderType])
{
@@ -1960,16 +1959,16 @@ void SpirvTransformFeedbackCodeGenerator::visitXfbVarying(const ShaderInterfaceV
visitXfbVarying(arrayElement, baseId, fieldIndex);
}
if (xfb.podStruct.buffer == ShaderInterfaceVariableXfbInfo::kInvalid)
if (xfb.pod.buffer == ShaderInterfaceVariableXfbInfo::kInvalid)
{
return;
}
// Varyings captured to the same buffer have the same stride.
ASSERT(mXfbVaryings[xfb.podStruct.buffer].empty() ||
mXfbVaryings[xfb.podStruct.buffer][0].info->podStruct.stride == xfb.podStruct.stride);
ASSERT(mXfbVaryings[xfb.pod.buffer].empty() ||
mXfbVaryings[xfb.pod.buffer][0].info->pod.stride == xfb.pod.stride);
mXfbVaryings[xfb.podStruct.buffer].push_back({&xfb, baseId, fieldIndex});
mXfbVaryings[xfb.pod.buffer].push_back({&xfb, baseId, fieldIndex});
}
void SpirvTransformFeedbackCodeGenerator::writeIntConstant(uint32_t value,
@@ -2044,30 +2043,30 @@ void SpirvTransformFeedbackCodeGenerator::writePendingDeclarations(
const ShaderInterfaceVariableXfbInfo *info0 = varyings[0].info;
// Define the buffer stride constant
ASSERT(info0->podStruct.stride % sizeof(float) == 0);
uint32_t stride = info0->podStruct.stride / sizeof(float);
ASSERT(info0->pod.stride % sizeof(float) == 0);
uint32_t stride = info0->pod.stride / sizeof(float);
mBufferStrides[info0->podStruct.buffer] = SpirvTransformerBase::GetNewId(blobOut);
spirv::WriteConstant(blobOut, ID::Int, mBufferStrides[info0->podStruct.buffer],
mBufferStrides[info0->pod.buffer] = SpirvTransformerBase::GetNewId(blobOut);
spirv::WriteConstant(blobOut, ID::Int, mBufferStrides[info0->pod.buffer],
spirv::LiteralContextDependentNumber(stride));
compositeIds.push_back(mBufferStrides[info0->podStruct.buffer]);
compositeIds.push_back(mBufferStrides[info0->pod.buffer]);
// Define all the constants that would be necessary to load the components of the varying.
for (const XfbVarying &varying : varyings)
{
writeIntConstant(varying.fieldIndex, ID::Int, blobOut);
const ShaderInterfaceVariableXfbInfo *info = varying.info;
if (info->podStruct.arraySize == ShaderInterfaceVariableXfbInfo::kInvalid)
if (info->pod.arraySize == ShaderInterfaceVariableXfbInfo::kInvalid)
{
continue;
}
uint32_t arrayIndexStart =
varying.info->podStruct.arrayIndex != ShaderInterfaceVariableXfbInfo::kInvalid
? varying.info->podStruct.arrayIndex
varying.info->pod.arrayIndex != ShaderInterfaceVariableXfbInfo::kInvalid
? varying.info->pod.arrayIndex
: 0;
uint32_t arrayIndexEnd = arrayIndexStart + info->podStruct.arraySize;
uint32_t arrayIndexEnd = arrayIndexStart + info->pod.arraySize;
for (uint32_t arrayIndex = arrayIndexStart; arrayIndex < arrayIndexEnd; ++arrayIndex)
{
@@ -2138,7 +2137,7 @@ void SpirvTransformFeedbackCodeGenerator::writeTransformFeedbackEmulationOutput(
{
std::sort(varyings.begin(), varyings.end(),
[](const XfbVarying &first, const XfbVarying &second) {
return first.info->podStruct.offset < second.info->podStruct.offset;
return first.info->pod.offset < second.info->pod.offset;
});
}
@@ -2214,7 +2213,7 @@ void SpirvTransformFeedbackCodeGenerator::writeTransformFeedbackEmulationOutput(
{
const XfbVarying &varying = varyings[varyingIndex];
const ShaderInterfaceVariableXfbInfo *info = varying.info;
ASSERT(info->podStruct.buffer == bufferIndex);
ASSERT(info->pod.buffer == bufferIndex);
// Each component of the varying being captured is loaded one by one. This uses the
// OpAccessChain instruction that takes a chain of "indices" to end up with the
@@ -2246,13 +2245,12 @@ void SpirvTransformFeedbackCodeGenerator::writeTransformFeedbackEmulationOutput(
// - The whole array
//
uint32_t arrayIndexStart = 0;
uint32_t arrayIndexEnd = info->podStruct.arraySize;
const bool isArray =
info->podStruct.arraySize != ShaderInterfaceVariableXfbInfo::kInvalid;
if (varying.info->podStruct.arrayIndex != ShaderInterfaceVariableXfbInfo::kInvalid)
uint32_t arrayIndexEnd = info->pod.arraySize;
const bool isArray = info->pod.arraySize != ShaderInterfaceVariableXfbInfo::kInvalid;
if (varying.info->pod.arrayIndex != ShaderInterfaceVariableXfbInfo::kInvalid)
{
// Capturing a single element.
arrayIndexStart = varying.info->podStruct.arrayIndex;
arrayIndexStart = varying.info->pod.arrayIndex;
arrayIndexEnd = arrayIndexStart + 1;
}
else if (!isArray)
@@ -2263,9 +2261,9 @@ void SpirvTransformFeedbackCodeGenerator::writeTransformFeedbackEmulationOutput(
// Sorting the varyings should have ensured that offsets are in order and that writing
// to the output buffer sequentially ends up using the correct offsets.
ASSERT(info->podStruct.offset == offsetForVerification);
offsetForVerification += (arrayIndexEnd - arrayIndexStart) * info->podStruct.rowCount *
info->podStruct.columnCount * sizeof(float);
ASSERT(info->pod.offset == offsetForVerification);
offsetForVerification += (arrayIndexEnd - arrayIndexStart) * info->pod.rowCount *
info->pod.columnCount * sizeof(float);
// Determine the type of the component being captured. OpBitcast is used (the
// implementation of intBitsToFloat() and uintBitsToFloat() for non-float types).
@@ -2274,28 +2272,27 @@ void SpirvTransformFeedbackCodeGenerator::writeTransformFeedbackEmulationOutput(
const bool isPrivate =
inactiveVaryingRemover.isInactive(varying.baseId) ||
(usePrecisionFixer && varyingPrecisionFixer.isReplaced(varying.baseId));
getVaryingTypeIds(info->podStruct.componentType, isPrivate, &varyingTypeId,
&varyingTypePtr);
getVaryingTypeIds(info->pod.componentType, isPrivate, &varyingTypeId, &varyingTypePtr);
for (uint32_t arrayIndex = arrayIndexStart; arrayIndex < arrayIndexEnd; ++arrayIndex)
{
AccessChainIndexListAppend appendArrayIndex(isArray, mIntNIds, arrayIndex,
&indexList);
for (uint32_t col = 0; col < info->podStruct.columnCount; ++col)
for (uint32_t col = 0; col < info->pod.columnCount; ++col)
{
AccessChainIndexListAppend appendColumn(info->podStruct.columnCount > 1,
mIntNIds, col, &indexList);
for (uint32_t row = 0; row < info->podStruct.rowCount; ++row)
AccessChainIndexListAppend appendColumn(info->pod.columnCount > 1, mIntNIds,
col, &indexList);
for (uint32_t row = 0; row < info->pod.rowCount; ++row)
{
AccessChainIndexListAppend appendRow(info->podStruct.rowCount > 1, mIntNIds,
row, &indexList);
AccessChainIndexListAppend appendRow(info->pod.rowCount > 1, mIntNIds, row,
&indexList);
// Generate the code to capture a single component of the varying:
//
// ANGLEXfbN.xfbOut[xfbOffset] = tfVarying0.field[index][row][col]
writeComponentCapture(bufferIndex, xfbOffset, varyingTypeId, varyingTypePtr,
varying.baseId, indexList,
info->podStruct.componentType, blobOut);
varying.baseId, indexList, info->pod.componentType,
blobOut);
// Increment the offset:
//
@@ -2444,18 +2441,18 @@ void SpirvTransformFeedbackCodeGenerator::addMemberDecorate(const XFBInterfaceVa
{
const ShaderInterfaceVariableXfbInfo &xfb = info.fieldXfb[fieldIndex];
if (xfb.podStruct.buffer == ShaderInterfaceVariableXfbInfo::kInvalid)
if (xfb.pod.buffer == ShaderInterfaceVariableXfbInfo::kInvalid)
{
continue;
}
ASSERT(xfb.podStruct.stride != ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb.podStruct.offset != ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb.pod.stride != ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(xfb.pod.offset != ShaderInterfaceVariableXfbInfo::kInvalid);
const uint32_t xfbDecorationValues[kXfbDecorationCount] = {
xfb.podStruct.buffer,
xfb.podStruct.stride,
xfb.podStruct.offset,
xfb.pod.buffer,
xfb.pod.stride,
xfb.pod.offset,
};
// Generate the following three instructions:
@@ -2476,18 +2473,18 @@ void SpirvTransformFeedbackCodeGenerator::addDecorate(const XFBInterfaceVariable
spirv::IdRef id,
spirv::Blob *blobOut)
{
if (mIsEmulated || info.xfb.podStruct.buffer == ShaderInterfaceVariableXfbInfo::kInvalid)
if (mIsEmulated || info.xfb.pod.buffer == ShaderInterfaceVariableXfbInfo::kInvalid)
{
return;
}
ASSERT(info.xfb.podStruct.stride != ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(info.xfb.podStruct.offset != ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(info.xfb.pod.stride != ShaderInterfaceVariableXfbInfo::kInvalid);
ASSERT(info.xfb.pod.offset != ShaderInterfaceVariableXfbInfo::kInvalid);
const uint32_t xfbDecorationValues[kXfbDecorationCount] = {
info.xfb.podStruct.buffer,
info.xfb.podStruct.stride,
info.xfb.podStruct.offset,
info.xfb.pod.buffer,
info.xfb.pod.stride,
info.xfb.pod.offset,
};
// Generate the following three instructions:

View File

@@ -69,7 +69,7 @@ struct ShaderInterfaceVariableXfbInfo
uint32_t rowCount = kInvalid;
uint32_t arrayIndex = kInvalid;
GLenum componentType = GL_FLOAT;
} podStruct;
} pod;
ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
// If empty, the whole array is captured. Otherwise only the specified members are captured.
std::vector<ShaderInterfaceVariableXfbInfo> arrayElements;