Commit 1377689c by Jamie Madill

Cache validate samplers result.

This gives ~23% increase in the validation-only draw call perf test. BUG=angleproject:959 Change-Id: I384a5c4fbb1c2cd47483bd7cf4bc1d39447a99bc Reviewed-on: https://chromium-review.googlesource.com/267750Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent 667ef099
......@@ -35,6 +35,18 @@ struct Optional
return *this;
}
Optional &operator=(const T &value)
{
mValue = value;
mValid = true;
return *this;
}
void reset()
{
mValid = false;
}
static Optional None()
{
return Optional();
......
......@@ -336,6 +336,13 @@ void ProgramD3D::updateSamplerMapping()
bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
{
// Skip cache if we're using an infolog, so we get the full error.
// Also skip the cache if the sample mapping has changed, or if we haven't ever validated.
if (!mDirtySamplerMapping && infoLog == nullptr && mCachedValidateSamplersResult.valid())
{
return mCachedValidateSamplersResult.value();
}
// if any two active samplers in a program are of different types, but refer to the same
// texture image unit, and this is the current program, then ValidateProgram will fail, and
// DrawArrays and DrawElements will issue the INVALID_OPERATION error.
......@@ -356,6 +363,7 @@ bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
infoLog->append("Sampler uniform (%d) exceeds GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (%d)", unit, caps.maxCombinedTextureImageUnits);
}
mCachedValidateSamplersResult = false;
return false;
}
......@@ -368,6 +376,7 @@ bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
infoLog->append("Samplers of conflicting types refer to the same texture image unit (%d).", unit);
}
mCachedValidateSamplersResult = false;
return false;
}
}
......@@ -391,6 +400,7 @@ bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
infoLog->append("Sampler uniform (%d) exceeds GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (%d)", unit, caps.maxCombinedTextureImageUnits);
}
mCachedValidateSamplersResult = false;
return false;
}
......@@ -403,6 +413,7 @@ bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
infoLog->append("Samplers of conflicting types refer to the same texture image unit (%d).", unit);
}
mCachedValidateSamplersResult = false;
return false;
}
}
......@@ -413,6 +424,7 @@ bool ProgramD3D::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps)
}
}
mCachedValidateSamplersResult = true;
return true;
}
......
......@@ -9,6 +9,7 @@
#ifndef LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_
#define LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_
#include "common/Optional.h"
#include "compiler/translator/blocklayoutHLSL.h"
#include "libANGLE/Constants.h"
#include "libANGLE/renderer/ProgramImpl.h"
......@@ -235,6 +236,8 @@ class ProgramD3D : public ProgramImpl
unsigned int mSerial;
Optional<bool> mCachedValidateSamplersResult;
static unsigned int issueSerial();
static unsigned int mCurrentSerial;
};
......
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