Commit 1ebe6014 by Jiacheng Lu Committed by Commit Bot

Vulkan: Only check sampler when setUniform1i(v)

1. only do isSampler checking when update int uniforms 2. inline some simple methods of LinkUniform This fix reduce CPU time spent on `isSampler` call from 70ms to 30ms in T-Rex bench on specific platform. Bug: angleproject:3743 Change-Id: I98ef3c892df27e08d54ed40946d924b5a50c796c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1725114 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 8b2dfa0f
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include "libANGLE/Uniform.h" #include "libANGLE/Uniform.h"
#include "common/utilities.h"
#include <cstring> #include <cstring>
namespace gl namespace gl
...@@ -97,41 +95,6 @@ LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform) ...@@ -97,41 +95,6 @@ LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform)
LinkedUniform::~LinkedUniform() {} LinkedUniform::~LinkedUniform() {}
bool LinkedUniform::isInDefaultBlock() const
{
return bufferIndex == -1;
}
bool LinkedUniform::isSampler() const
{
return typeInfo->isSampler;
}
bool LinkedUniform::isImage() const
{
return typeInfo->isImageType;
}
bool LinkedUniform::isAtomicCounter() const
{
return IsAtomicCounterType(type);
}
bool LinkedUniform::isField() const
{
return name.find('.') != std::string::npos;
}
size_t LinkedUniform::getElementSize() const
{
return typeInfo->externalSize;
}
size_t LinkedUniform::getElementComponents() const
{
return typeInfo->componentCount;
}
BufferVariable::BufferVariable() BufferVariable::BufferVariable()
: bufferIndex(-1), blockInfo(sh::kDefaultBlockMemberInfo), topLevelArraySize(-1) : bufferIndex(-1), blockInfo(sh::kDefaultBlockMemberInfo), topLevelArraySize(-1)
{} {}
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "common/MemoryBuffer.h" #include "common/MemoryBuffer.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/utilities.h"
#include "compiler/translator/blocklayout.h" #include "compiler/translator/blocklayout.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
...@@ -61,13 +62,13 @@ struct LinkedUniform : public sh::Uniform, public ActiveVariable ...@@ -61,13 +62,13 @@ struct LinkedUniform : public sh::Uniform, public ActiveVariable
LinkedUniform &operator=(const LinkedUniform &uniform); LinkedUniform &operator=(const LinkedUniform &uniform);
~LinkedUniform() override; ~LinkedUniform() override;
bool isSampler() const; bool isSampler() const { return typeInfo->isSampler; }
bool isImage() const; bool isImage() const { return typeInfo->isImageType; }
bool isAtomicCounter() const; bool isAtomicCounter() const { return IsAtomicCounterType(type); }
bool isInDefaultBlock() const; bool isInDefaultBlock() const { return bufferIndex == -1; }
bool isField() const; bool isField() const { return name.find('.') != std::string::npos; }
size_t getElementSize() const; size_t getElementSize() const { return typeInfo->externalSize; }
size_t getElementComponents() const; size_t getElementComponents() const { return typeInfo->componentCount; }
const UniformTypeInfo *typeInfo; const UniformTypeInfo *typeInfo;
......
...@@ -757,12 +757,7 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum ...@@ -757,12 +757,7 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum
const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location]; const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location];
const gl::LinkedUniform &linkedUniform = mState.getUniforms()[locationInfo.index]; const gl::LinkedUniform &linkedUniform = mState.getUniforms()[locationInfo.index];
if (linkedUniform.isSampler()) ASSERT(!linkedUniform.isSampler());
{
// We could potentially cache some indexing here. For now this is a no-op since the mapping
// is handled entirely in ContextVk.
return;
}
if (linkedUniform.typeInfo->type == entryPointType) if (linkedUniform.typeInfo->type == entryPointType)
{ {
...@@ -872,6 +867,15 @@ void ProgramVk::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) ...@@ -872,6 +867,15 @@ void ProgramVk::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
void ProgramVk::setUniform1iv(GLint location, GLsizei count, const GLint *v) void ProgramVk::setUniform1iv(GLint location, GLsizei count, const GLint *v)
{ {
const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location];
const gl::LinkedUniform &linkedUniform = mState.getUniforms()[locationInfo.index];
if (linkedUniform.isSampler())
{
// We could potentially cache some indexing here. For now this is a no-op since the mapping
// is handled entirely in ContextVk.
return;
}
setUniformImpl(location, count, v, GL_INT); setUniformImpl(location, count, v, GL_INT);
} }
......
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