Commit 34e28778 by Tim Van Patten Committed by Commit Bot

Reorder ShaderVariable functions and members

ShaderVariable's functions and members are all mixed up. This CL reorders things to move the functions before the members, to better match ANGLE's coding style. This also adds a note that any new members that are added need to be added to gl::WriteShaderVar() and gl::LoadShaderVar(), which are actually implemented in Program.cpp, since ShaderVars.h/cpp can't include libANGLE/BinaryStream.h. There are currently several members that are missing, leading to save/load errors, which are fixed in a follow-on CL in this chain. Bug: b/182409935 Change-Id: I1381a5efffb56c0989961bbcfd405b95d59d6396 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2770682 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 2be71410
......@@ -125,14 +125,6 @@ struct ShaderVariable
bool isBuiltIn() const;
bool isEmulatedBuiltIn() const;
GLenum type;
GLenum precision;
std::string name;
std::string mappedName;
// Used to make an array type. Outermost array size is stored at the end of the vector.
std::vector<unsigned int> arraySizes;
// Offset of this variable in parent arrays. In case the parent is an array of arrays, the
// offset is outerArrayElement * innerArraySize + innerArrayElement.
// For example, if there's a variable declared as size 3 array of size 4 array of int:
......@@ -144,10 +136,51 @@ struct ShaderVariable
return hasParentArrayIndex() ? flattenedOffsetInParentArrays : 0;
}
int getFlattenedOffsetInParentArrays() const { return flattenedOffsetInParentArrays; }
void setParentArrayIndex(int indexIn) { flattenedOffsetInParentArrays = indexIn; }
bool hasParentArrayIndex() const { return flattenedOffsetInParentArrays != -1; }
void resetEffectiveLocation();
void updateEffectiveLocation(const sh::ShaderVariable &parent);
// Decide whether two uniforms are the same at shader link time,
// assuming they are from consecutive shader stages.
// GLSL ES Spec 3.00.3, section 4.3.5.
// GLSL ES Spec 3.10.4, section 4.4.5
bool isSameUniformAtLinkTime(const ShaderVariable &other) const;
// InterfaceBlockField
// Decide whether two InterfaceBlock fields are the same at shader
// link time, assuming they are from consecutive shader stages.
// See GLSL ES Spec 3.00.3, sec 4.3.7.
bool isSameInterfaceBlockFieldAtLinkTime(const ShaderVariable &other) const;
// Decide whether two varyings are the same at shader link time,
// assuming they are from consecutive shader stages.
// Invariance needs to match only in ESSL1. Relevant spec sections:
// GLSL ES 3.00.4, sections 4.6.1 and 4.3.9.
// GLSL ES 1.00.17, section 4.6.4.
bool isSameVaryingAtLinkTime(const ShaderVariable &other, int shaderVersion) const;
// Deprecated version of isSameVaryingAtLinkTime, which assumes ESSL1.
bool isSameVaryingAtLinkTime(const ShaderVariable &other) const;
// Shader I/O blocks may match by block name or instance, based on whether both stages have an
// instance name or not.
bool isSameNameAtLinkTime(const ShaderVariable &other) const;
// NOTE: When adding new members, the following functions also need to be updated:
// gl::WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
// gl::LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
GLenum type;
GLenum precision;
std::string name;
std::string mappedName;
// Used to make an array type. Outermost array size is stored at the end of the vector.
std::vector<unsigned int> arraySizes;
// Static use means that the variable is accessed somewhere in the shader source.
bool staticUse;
// A variable is active unless the compiler determined that it is not accessed by the shader.
......@@ -156,7 +189,6 @@ struct ShaderVariable
bool active;
std::vector<ShaderVariable> fields;
// structOrBlockName is used for:
//
// - varyings of struct type, in which case it contains the struct name.
// - shader I/O blocks, in which case it contains the block name.
std::string structOrBlockName;
......@@ -173,16 +205,9 @@ struct ShaderVariable
// Not all active variables are assigned valid locations;
// the following variables will have an effective location of -1:
bool hasImplicitLocation;
void resetEffectiveLocation();
void updateEffectiveLocation(const sh::ShaderVariable &parent);
// Uniform
int binding;
// Decide whether two uniforms are the same at shader link time,
// assuming they are from consecutive shader stages.
// GLSL ES Spec 3.00.3, section 4.3.5.
// GLSL ES Spec 3.10.4, section 4.4.5
bool isSameUniformAtLinkTime(const ShaderVariable &other) const;
GLenum imageUnitFormat;
int offset;
bool readonly;
......@@ -198,31 +223,12 @@ struct ShaderVariable
// From EXT_YUV_target
bool yuv;
// InterfaceBlockField
// Decide whether two InterfaceBlock fields are the same at shader
// link time, assuming they are from consecutive shader stages.
// See GLSL ES Spec 3.00.3, sec 4.3.7.
bool isSameInterfaceBlockFieldAtLinkTime(const ShaderVariable &other) const;
// Varying
InterpolationType interpolation;
bool isInvariant;
bool isShaderIOBlock;
bool isPatch;
// Decide whether two varyings are the same at shader link time,
// assuming they are from consecutive shader stages.
// Invariance needs to match only in ESSL1. Relevant spec sections:
// GLSL ES 3.00.4, sections 4.6.1 and 4.3.9.
// GLSL ES 1.00.17, section 4.6.4.
bool isSameVaryingAtLinkTime(const ShaderVariable &other, int shaderVersion) const;
// Deprecated version of isSameVaryingAtLinkTime, which assumes ESSL1.
bool isSameVaryingAtLinkTime(const ShaderVariable &other) const;
// Shader I/O blocks may match by block name or instance, based on whether both stages have an
// instance name or not.
bool isSameNameAtLinkTime(const ShaderVariable &other) const;
// If the variable is a sampler that has ever been statically used with texelFetch
bool texelFetchStaticUse;
......@@ -231,6 +237,10 @@ struct ShaderVariable
bool matchPrecision,
bool matchName) const;
// NOTE: When adding new members, the following functions also need to be updated:
// gl::WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
// gl::LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
int flattenedOffsetInParentArrays;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment