mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Remove "const UniformTypeInfo *typeInfo" from struct LinkedUniform
This is a cached pointer to the const kInfoTable. There isn't much of performance benefit to cache here compare to directly retrieve from the table. This cached pointer is removed in this CL, which means we do not need to update the pointer in the ProgramExecutable::load(). This and a few earlier CLs that attempt to do memcpy for entire mUniforms reduced average frame time of blade_and_soul_revolution app trace 3%, from 4.3359 ms to 4.2066ms on pixel 7 pro. Bug: b/275102061 Change-Id: I6fd34d665234e3a5cc85344924049bf5b13aaa80 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4753933 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
This commit is contained in:
committed by
Angle LUCI CQ
parent
c40d31b026
commit
719165c8eb
@@ -230,11 +230,6 @@ void LoadUniforms(BinaryInputStream *stream,
|
||||
// for performance.
|
||||
stream->readBytes(reinterpret_cast<unsigned char *>(uniforms->data()),
|
||||
sizeof(LinkedUniform) * uniforms->size());
|
||||
for (size_t uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex)
|
||||
{
|
||||
(*uniforms)[uniformIndex].typeInfo =
|
||||
&GetUniformTypeInfo((*uniforms)[uniformIndex].getType());
|
||||
}
|
||||
uniformNames->resize(uniformCount);
|
||||
for (size_t uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex)
|
||||
{
|
||||
@@ -1686,9 +1681,9 @@ void ProgramExecutable::linkSamplerAndImageBindings(GLuint *combinedImageUniform
|
||||
{
|
||||
const auto &samplerUniform = mUniforms[samplerIndex];
|
||||
TextureType textureType = SamplerTypeToTextureType(samplerUniform.getType());
|
||||
GLenum samplerType = samplerUniform.typeInfo->type;
|
||||
GLenum samplerType = samplerUniform.getType();
|
||||
unsigned int elementCount = samplerUniform.getBasicTypeElementCount();
|
||||
SamplerFormat format = samplerUniform.typeInfo->samplerFormat;
|
||||
SamplerFormat format = GetUniformTypeInfo(samplerType).samplerFormat;
|
||||
mSamplerBindings.emplace_back(textureType, samplerType, format, elementCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,6 @@ LinkedUniform::LinkedUniform(GLenum typeIn,
|
||||
flagBitsAsUInt = 0;
|
||||
flagBits.isArray = !arraySizesIn.empty();
|
||||
ASSERT(arraySizesIn.size() <= 1);
|
||||
|
||||
typeInfo = &GetUniformTypeInfo(typeIn);
|
||||
}
|
||||
|
||||
LinkedUniform::LinkedUniform(const LinkedUniform &other)
|
||||
@@ -109,8 +107,6 @@ LinkedUniform::LinkedUniform(const UsedUniform &usedUniform)
|
||||
flagBits.isFragmentInOut = usedUniform.isFragmentInOut;
|
||||
flagBits.texelFetchStaticUse = usedUniform.texelFetchStaticUse;
|
||||
flagBits.isArray = usedUniform.isArray();
|
||||
|
||||
typeInfo = usedUniform.typeInfo;
|
||||
}
|
||||
|
||||
LinkedUniform::~LinkedUniform() {}
|
||||
|
||||
@@ -77,12 +77,12 @@ struct LinkedUniform
|
||||
LinkedUniform(const UsedUniform &usedUniform);
|
||||
~LinkedUniform();
|
||||
|
||||
bool isSampler() const { return typeInfo->isSampler; }
|
||||
bool isImage() const { return typeInfo->isImageType; }
|
||||
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 typeInfo->externalSize; }
|
||||
size_t getElementComponents() const { return typeInfo->componentCount; }
|
||||
size_t getElementSize() const { return GetUniformTypeInfo(type).externalSize; }
|
||||
GLint getElementComponents() const { return GetUniformTypeInfo(type).componentCount; }
|
||||
|
||||
bool isTexelFetchStaticUse() const { return flagBits.texelFetchStaticUse; }
|
||||
bool isFragmentInOut() const { return flagBits.isFragmentInOut; }
|
||||
@@ -123,7 +123,6 @@ struct LinkedUniform
|
||||
ShaderBitSet activeShaders() const { return activeVariable.activeShaders(); }
|
||||
GLuint activeShaderCount() const { return activeVariable.activeShaderCount(); }
|
||||
|
||||
const UniformTypeInfo *typeInfo;
|
||||
sh::BlockMemberInfo blockInfo;
|
||||
ActiveVariable activeVariable;
|
||||
|
||||
|
||||
@@ -2516,8 +2516,8 @@ void CaptureUpdateUniformValues(const gl::State &replayState,
|
||||
}
|
||||
|
||||
gl::UniformLocation uniformLoc = program->getUniformLocation(uniformName);
|
||||
const gl::UniformTypeInfo *typeInfo = uniform.typeInfo;
|
||||
int componentCount = typeInfo->componentCount;
|
||||
const gl::UniformTypeInfo &typeInfo = gl::GetUniformTypeInfo(uniform.getType());
|
||||
int componentCount = typeInfo.componentCount;
|
||||
int uniformSize = uniformCount * componentCount;
|
||||
|
||||
// For arrayed uniforms, we'll need to increment a read location
|
||||
@@ -2530,7 +2530,7 @@ void CaptureUpdateUniformValues(const gl::State &replayState,
|
||||
}
|
||||
|
||||
// Image uniforms are special and cannot be set this way
|
||||
if (typeInfo->isImageType)
|
||||
if (typeInfo.isImageType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -2542,7 +2542,7 @@ void CaptureUpdateUniformValues(const gl::State &replayState,
|
||||
CallVector defaultUniformCalls({callsOut, &resetCalls[uniformLoc]});
|
||||
|
||||
// Samplers should be populated with GL_INT, regardless of return type
|
||||
if (typeInfo->isSampler)
|
||||
if (typeInfo.isSampler)
|
||||
{
|
||||
std::vector<GLint> uniformBuffer(uniformSize);
|
||||
for (int index = 0; index < uniformCount; index++, readLoc.value++)
|
||||
@@ -2561,7 +2561,7 @@ void CaptureUpdateUniformValues(const gl::State &replayState,
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (typeInfo->componentType)
|
||||
switch (typeInfo.componentType)
|
||||
{
|
||||
case GL_FLOAT:
|
||||
{
|
||||
@@ -2573,7 +2573,7 @@ void CaptureUpdateUniformValues(const gl::State &replayState,
|
||||
resourceTracker->setDefaultUniformBaseLocation(program->id(), readLoc,
|
||||
uniformLoc);
|
||||
}
|
||||
switch (typeInfo->type)
|
||||
switch (typeInfo.type)
|
||||
{
|
||||
// Note: All matrix uniforms are populated without transpose
|
||||
case GL_FLOAT_MAT4x3:
|
||||
|
||||
@@ -1289,7 +1289,7 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu
|
||||
return;
|
||||
}
|
||||
|
||||
if (linkedUniform.typeInfo->type == entryPointType)
|
||||
if (linkedUniform.type == entryPointType)
|
||||
{
|
||||
for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
|
||||
{
|
||||
@@ -1302,9 +1302,9 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu
|
||||
continue;
|
||||
}
|
||||
|
||||
const GLint componentCount = (GLint)linkedUniform.typeInfo->componentCount;
|
||||
const GLint baseComponentSize = (GLint)mtl::GetMetalSizeForGLType(
|
||||
gl::VariableComponentType(linkedUniform.typeInfo->type));
|
||||
const GLint componentCount = (GLint)linkedUniform.getElementComponents();
|
||||
const GLint baseComponentSize =
|
||||
(GLint)mtl::GetMetalSizeForGLType(gl::VariableComponentType(linkedUniform.type));
|
||||
UpdateDefaultUniformBlockWithElementSize(count, locationInfo.arrayIndex, componentCount,
|
||||
v, baseComponentSize, layoutInfo,
|
||||
&uniformBlock.uniformData);
|
||||
@@ -1324,9 +1324,9 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu
|
||||
continue;
|
||||
}
|
||||
|
||||
const GLint componentCount = linkedUniform.typeInfo->componentCount;
|
||||
const GLint componentCount = linkedUniform.getElementComponents();
|
||||
|
||||
ASSERT(linkedUniform.typeInfo->type == gl::VariableBoolVectorType(entryPointType));
|
||||
ASSERT(linkedUniform.type == gl::VariableBoolVectorType(entryPointType));
|
||||
|
||||
GLint initialArrayOffset =
|
||||
locationInfo.arrayIndex * layoutInfo.arrayStride + layoutInfo.offset;
|
||||
@@ -1362,10 +1362,11 @@ void ProgramMtl::getUniformImpl(GLint location, T *v, GLenum entryPointType) con
|
||||
const DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
|
||||
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
|
||||
|
||||
ASSERT(linkedUniform.typeInfo->componentType == entryPointType ||
|
||||
linkedUniform.typeInfo->componentType == gl::VariableBoolVectorType(entryPointType));
|
||||
ASSERT(gl::GetUniformTypeInfo(linkedUniform.type).componentType == entryPointType ||
|
||||
gl::GetUniformTypeInfo(linkedUniform.type).componentType ==
|
||||
gl::VariableBoolVectorType(entryPointType));
|
||||
const GLint baseComponentSize =
|
||||
(GLint)mtl::GetMetalSizeForGLType(gl::VariableComponentType(linkedUniform.typeInfo->type));
|
||||
(GLint)mtl::GetMetalSizeForGLType(gl::VariableComponentType(linkedUniform.type));
|
||||
|
||||
if (gl::IsMatrixType(linkedUniform.getType()))
|
||||
{
|
||||
@@ -1380,9 +1381,9 @@ void ProgramMtl::getUniformImpl(GLint location, T *v, GLenum entryPointType) con
|
||||
{
|
||||
bool bVals[4] = {0};
|
||||
ReadFromDefaultUniformBlockWithElementSize(
|
||||
linkedUniform.typeInfo->componentCount, locationInfo.arrayIndex, bVals,
|
||||
baseComponentSize, layoutInfo, &uniformBlock.uniformData);
|
||||
for (int bCol = 0; bCol < linkedUniform.typeInfo->componentCount; ++bCol)
|
||||
linkedUniform.getElementComponents(), locationInfo.arrayIndex, bVals, baseComponentSize,
|
||||
layoutInfo, &uniformBlock.uniformData);
|
||||
for (int bCol = 0; bCol < linkedUniform.getElementComponents(); ++bCol)
|
||||
{
|
||||
unsigned int data = bVals[bCol];
|
||||
*(v + bCol) = static_cast<T>(data);
|
||||
@@ -1392,7 +1393,7 @@ void ProgramMtl::getUniformImpl(GLint location, T *v, GLenum entryPointType) con
|
||||
{
|
||||
|
||||
assert(baseComponentSize == sizeof(T));
|
||||
ReadFromDefaultUniformBlockWithElementSize(linkedUniform.typeInfo->componentCount,
|
||||
ReadFromDefaultUniformBlockWithElementSize(linkedUniform.getElementComponents(),
|
||||
locationInfo.arrayIndex, v, baseComponentSize,
|
||||
layoutInfo, &uniformBlock.uniformData);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum
|
||||
|
||||
ASSERT(!linkedUniform.isSampler());
|
||||
|
||||
if (linkedUniform.typeInfo->type == entryPointType)
|
||||
if (linkedUniform.type == entryPointType)
|
||||
{
|
||||
for (const gl::ShaderType shaderType : glExecutable.getLinkedShaderStages())
|
||||
{
|
||||
@@ -371,7 +371,7 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum
|
||||
continue;
|
||||
}
|
||||
|
||||
const GLint componentCount = linkedUniform.typeInfo->componentCount;
|
||||
const GLint componentCount = linkedUniform.getElementComponents();
|
||||
UpdateDefaultUniformBlock(count, locationInfo.arrayIndex, componentCount, v, layoutInfo,
|
||||
&uniformBlock.uniformData);
|
||||
mExecutable.mDefaultUniformBlocksDirty.set(shaderType);
|
||||
@@ -390,9 +390,9 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum
|
||||
continue;
|
||||
}
|
||||
|
||||
const GLint componentCount = linkedUniform.typeInfo->componentCount;
|
||||
const GLint componentCount = linkedUniform.getElementComponents();
|
||||
|
||||
ASSERT(linkedUniform.typeInfo->type == gl::VariableBoolVectorType(entryPointType));
|
||||
ASSERT(linkedUniform.type == gl::VariableBoolVectorType(entryPointType));
|
||||
|
||||
GLint initialArrayOffset =
|
||||
locationInfo.arrayIndex * layoutInfo.arrayStride + layoutInfo.offset;
|
||||
@@ -428,8 +428,9 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons
|
||||
const DefaultUniformBlock &uniformBlock = *mExecutable.mDefaultUniformBlocks[shaderType];
|
||||
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
|
||||
|
||||
ASSERT(linkedUniform.typeInfo->componentType == entryPointType ||
|
||||
linkedUniform.typeInfo->componentType == gl::VariableBoolVectorType(entryPointType));
|
||||
ASSERT(gl::GetUniformTypeInfo(linkedUniform.type).componentType == entryPointType ||
|
||||
gl::GetUniformTypeInfo(linkedUniform.type).componentType ==
|
||||
gl::VariableBoolVectorType(entryPointType));
|
||||
|
||||
if (gl::IsMatrixType(linkedUniform.getType()))
|
||||
{
|
||||
@@ -440,7 +441,7 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadFromDefaultUniformBlock(linkedUniform.typeInfo->componentCount, locationInfo.arrayIndex,
|
||||
ReadFromDefaultUniformBlock(linkedUniform.getElementComponents(), locationInfo.arrayIndex,
|
||||
v, layoutInfo, &uniformBlock.uniformData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user