Commit e3e680ca by Jamie Madill Committed by Commit Bot

Remove State::syncProgramTextures.

Removes the concept of the program textures dirty object. Instead we use a set of dirty bits to represent dirty texture samples. We mark certain textures dirty and update state structures whenever there is a new Texture/Program/Sampler bound, or when Texture/Program/Sampler state changes. This is in preparation for making clearing the uncleared active textures into a dirty bit as well. Also includes new dirty bit handling for texture image units. These are a GLES 3.1 feature. Bug: angleproject:2966 Change-Id: Ibb8619dd2669bb39fdbcd75e3685be9a8aeeee91 Reviewed-on: https://chromium-review.googlesource.com/c/1346649 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent ff03e51e
......@@ -60,6 +60,7 @@ enum
// Limit active textures so we can use fast bitsets.
IMPLEMENTATION_MAX_SHADER_TEXTURES = 32,
IMPLEMENTATION_MAX_ACTIVE_TEXTURES = IMPLEMENTATION_MAX_SHADER_TEXTURES * 2,
IMPLEMENTATION_MAX_IMAGE_UNITS = IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
};
} // namespace gl
......
......@@ -284,12 +284,14 @@ constexpr angle::PackedEnumMap<PrimitiveMode, bool, angle::EnumSize<PrimitiveMod
enum SubjectIndexes : angle::SubjectIndex
{
kTexture0SubjectIndex = 0,
kTextureMaxSubjectIndex = kTexture0SubjectIndex + gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
kUniformBuffer0SubjectIndex = kTextureMaxSubjectIndex,
kTextureMaxSubjectIndex = kTexture0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
kImage0SubjectIndex = kTextureMaxSubjectIndex,
kImageMaxSubjectIndex = kImage0SubjectIndex + IMPLEMENTATION_MAX_IMAGE_UNITS,
kUniformBuffer0SubjectIndex = kImageMaxSubjectIndex,
kUniformBufferMaxSubjectIndex =
kUniformBuffer0SubjectIndex + gl::IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS,
kUniformBuffer0SubjectIndex + IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS,
kSampler0SubjectIndex = kUniformBufferMaxSubjectIndex,
kSamplerMaxSubjectIndex = kSampler0SubjectIndex + gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
kSamplerMaxSubjectIndex = kSampler0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
kVertexArraySubjectIndex = kSamplerMaxSubjectIndex,
kReadFramebufferSubjectIndex,
kDrawFramebufferSubjectIndex
......@@ -357,6 +359,12 @@ Context::Context(rx::EGLImplFactory *implFactory,
{
mSamplerObserverBindings.emplace_back(this, samplerIndex);
}
for (angle::SubjectIndex imageIndex = kImage0SubjectIndex; imageIndex < kImageMaxSubjectIndex;
++imageIndex)
{
mImageObserverBindings.emplace_back(this, imageIndex);
}
}
void Context::initialize()
......@@ -463,13 +471,13 @@ void Context::initialize()
mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM_TEXTURES);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM_TEXTURES);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS);
mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE);
......@@ -513,7 +521,7 @@ void Context::initialize()
mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS);
mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS);
mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM_TEXTURES);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS);
......@@ -1090,7 +1098,7 @@ void Context::bindTexture(TextureType target, GLuint handle)
}
ASSERT(texture);
ANGLE_CONTEXT_TRY(mGLState.setSamplerTexture(this, target, texture));
mGLState.setSamplerTexture(this, target, texture);
mStateCache.onActiveTextureChange(this);
}
......@@ -1148,6 +1156,7 @@ void Context::bindImageTexture(GLuint unit,
{
Texture *tex = mState.mTextures->getTexture(texture);
mGLState.setImageUnit(this, unit, tex, level, layered, layer, access, format);
mImageObserverBindings[unit].bind(tex);
}
void Context::useProgram(GLuint program)
......@@ -2139,14 +2148,12 @@ void Context::texParameterf(TextureType target, GLenum pname, GLfloat param)
{
Texture *const texture = getTargetTexture(target);
SetTexParameterf(this, texture, pname, param);
onTextureChange(texture);
}
void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params)
{
Texture *const texture = getTargetTexture(target);
SetTexParameterfv(this, texture, pname, params);
onTextureChange(texture);
}
void Context::texParameterfvRobust(TextureType target,
......@@ -2161,28 +2168,24 @@ void Context::texParameteri(TextureType target, GLenum pname, GLint param)
{
Texture *const texture = getTargetTexture(target);
SetTexParameteri(this, texture, pname, param);
onTextureChange(texture);
}
void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params)
{
Texture *const texture = getTargetTexture(target);
SetTexParameteriv(this, texture, pname, params);
onTextureChange(texture);
}
void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params)
{
Texture *const texture = getTargetTexture(target);
SetTexParameterIiv(this, texture, pname, params);
onTextureChange(texture);
}
void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params)
{
Texture *const texture = getTargetTexture(target);
SetTexParameterIuiv(this, texture, pname, params);
onTextureChange(texture);
}
void Context::texParameterivRobust(TextureType target,
......@@ -3145,7 +3148,7 @@ void Context::requestExtension(const char *name)
{
if (zeroTexture.get() != nullptr)
{
zeroTexture->signalDirty(this, InitState::Initialized);
zeroTexture->signalDirtyStorage(this, InitState::Initialized);
}
}
......@@ -3331,6 +3334,8 @@ void Context::initCaps()
LimitCap(&mCaps.maxShaderTextureImageUnits[ShaderType::Fragment],
IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2);
LimitCap(&mCaps.maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS);
mCaps.maxSampleMaskWords = std::min<GLuint>(mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS);
// WebGL compatibility
......@@ -6093,11 +6098,13 @@ void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v)
void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v)
{
if (program->setUniform1iv(location, count, v) == Program::SetUniformResult::SamplerChanged)
{
mGLState.setObjectDirty(GL_PROGRAM);
mStateCache.onActiveTextureChange(this);
}
program->setUniform1iv(this, location, count, v);
}
void Context::onSamplerUniformChange(size_t textureUnitIndex)
{
mGLState.onActiveTextureChange(this, textureUnitIndex);
mStateCache.onActiveTextureChange(this);
}
void Context::uniform1i(GLint location, GLint x)
......@@ -7013,13 +7020,6 @@ void Context::programUniformMatrix4x3fv(GLuint program,
programObject->setUniformMatrix4x3fv(location, count, transpose, value);
}
void Context::onTextureChange(const Texture *texture)
{
// Conservatively assume all textures are dirty.
// TODO(jmadill): More fine-grained update.
mGLState.setObjectDirty(GL_TEXTURE);
}
bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const
{
return mGLState.isCurrentTransformFeedback(tf);
......@@ -8117,9 +8117,13 @@ void Context::onSubjectStateChange(const Context *context,
default:
if (index < kTextureMaxSubjectIndex)
{
mGLState.onActiveTextureStateChange(index);
mGLState.onActiveTextureStateChange(this, index);
mStateCache.onActiveTextureChange(this);
}
else if (index < kImageMaxSubjectIndex)
{
mGLState.onImageStateChange(this, index - kImage0SubjectIndex);
}
else if (index < kUniformBufferMaxSubjectIndex)
{
mGLState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex);
......
......@@ -1648,9 +1648,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
MemoryProgramCache *getMemoryProgramCache() const { return mMemoryProgramCache; }
// Notification for a state change in a Texture.
void onTextureChange(const Texture *texture);
bool hasBeenCurrent() const { return mHasBeenCurrent; }
egl::Display *getCurrentDisplay() const { return mCurrentDisplay; }
egl::Surface *getCurrentDrawSurface() const { return mCurrentSurface; }
......@@ -1732,6 +1729,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
angle::SubjectIndex index,
angle::SubjectMessage message) override;
void onSamplerUniformChange(size_t textureUnitIndex);
private:
void initialize();
......@@ -1879,6 +1878,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
angle::ObserverBinding mReadFramebufferObserverBinding;
std::vector<angle::ObserverBinding> mUniformBufferObserverBindings;
std::vector<angle::ObserverBinding> mSamplerObserverBindings;
std::vector<angle::ObserverBinding> mImageObserverBindings;
// Not really a property of context state. The size and contexts change per-api-call.
mutable angle::ScratchBuffer mScratchBuffer;
......
......@@ -70,8 +70,12 @@ class GLES1Renderer final : angle::NonCopyable
GLuint *programOut);
angle::Result initializeRendererProgram(Context *context, State *glState);
void setUniform1i(Program *programObject, GLint loc, GLint value);
void setUniform1iv(Program *programObject, GLint loc, GLint count, const GLint *value);
void setUniform1i(Context *context, Program *programObject, GLint loc, GLint value);
void setUniform1iv(Context *context,
Program *programObject,
GLint loc,
GLint count,
const GLint *value);
void setUniformMatrix4fv(Program *programObject,
GLint loc,
GLint count,
......
......@@ -2052,7 +2052,7 @@ void Program::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
mProgram->setUniform4fv(location, clampedCount, v);
}
Program::SetUniformResult Program::setUniform1iv(GLint location, GLsizei count, const GLint *v)
void Program::setUniform1iv(Context *context, GLint location, GLsizei count, const GLint *v)
{
ASSERT(mLinkResolved);
const VariableLocation &locationInfo = mState.mUniformLocations[location];
......@@ -2062,11 +2062,8 @@ Program::SetUniformResult Program::setUniform1iv(GLint location, GLsizei count,
if (mState.isSamplerUniformIndex(locationInfo.index))
{
updateSamplerUniform(locationInfo, clampedCount, v);
return SetUniformResult::SamplerChanged;
updateSamplerUniform(context, locationInfo, clampedCount, v);
}
return SetUniformResult::NoSamplerChange;
}
void Program::setUniform2iv(GLint location, GLsizei count, const GLint *v)
......@@ -3858,7 +3855,10 @@ void Program::setUniformValuesFromBindingQualifiers()
{
boundTextureUnits.push_back(samplerUniform.binding + elementIndex);
}
setUniform1iv(location, static_cast<GLsizei>(boundTextureUnits.size()),
// Here we pass nullptr to avoid a large chain of calls that need a non-const Context.
// We know it's safe not to notify the Context because this is only called after link.
setUniform1iv(nullptr, location, static_cast<GLsizei>(boundTextureUnits.size()),
boundTextureUnits.data());
}
}
......@@ -3874,7 +3874,8 @@ void Program::initInterfaceBlockBindings()
}
}
void Program::updateSamplerUniform(const VariableLocation &locationInfo,
void Program::updateSamplerUniform(Context *context,
const VariableLocation &locationInfo,
GLsizei clampedCount,
const GLint *v)
{
......@@ -3889,30 +3890,30 @@ void Program::updateSamplerUniform(const VariableLocation &locationInfo,
// Update the sampler uniforms.
for (GLsizei arrayIndex = 0; arrayIndex < clampedCount; ++arrayIndex)
{
GLint oldSamplerIndex = boundTextureUnits[arrayIndex + locationInfo.arrayIndex];
GLint newSamplerIndex = v[arrayIndex];
GLint oldTextureUnit = boundTextureUnits[arrayIndex + locationInfo.arrayIndex];
GLint newTextureUnit = v[arrayIndex];
if (oldSamplerIndex == newSamplerIndex)
if (oldTextureUnit == newTextureUnit)
continue;
boundTextureUnits[arrayIndex + locationInfo.arrayIndex] = newSamplerIndex;
boundTextureUnits[arrayIndex + locationInfo.arrayIndex] = newTextureUnit;
// Update the reference counts.
uint32_t &oldRefCount = mState.mActiveSamplerRefCounts[oldSamplerIndex];
uint32_t &newRefCount = mState.mActiveSamplerRefCounts[newSamplerIndex];
uint32_t &oldRefCount = mState.mActiveSamplerRefCounts[oldTextureUnit];
uint32_t &newRefCount = mState.mActiveSamplerRefCounts[newTextureUnit];
ASSERT(oldRefCount > 0);
ASSERT(newRefCount < std::numeric_limits<uint32_t>::max());
oldRefCount--;
newRefCount++;
// Check for binding type change.
TextureType &newSamplerType = mState.mActiveSamplerTypes[newSamplerIndex];
TextureType &oldSamplerType = mState.mActiveSamplerTypes[oldSamplerIndex];
TextureType &newSamplerType = mState.mActiveSamplerTypes[newTextureUnit];
TextureType &oldSamplerType = mState.mActiveSamplerTypes[oldTextureUnit];
if (newRefCount == 1)
{
newSamplerType = samplerBinding.textureType;
mState.mActiveSamplersMask.set(newSamplerIndex);
mState.mActiveSamplersMask.set(newTextureUnit);
}
else if (newSamplerType != samplerBinding.textureType)
{
......@@ -3924,12 +3925,19 @@ void Program::updateSamplerUniform(const VariableLocation &locationInfo,
if (oldRefCount == 0)
{
oldSamplerType = TextureType::InvalidEnum;
mState.mActiveSamplersMask.reset(oldSamplerIndex);
mState.mActiveSamplersMask.reset(oldTextureUnit);
}
else if (oldSamplerType == TextureType::InvalidEnum)
{
// Previous conflict. Check if this new change fixed the conflict.
oldSamplerType = mState.getSamplerUniformTextureType(oldSamplerIndex);
oldSamplerType = mState.getSamplerUniformTextureType(oldTextureUnit);
}
// Notify context.
if (context)
{
context->onSamplerUniformChange(newTextureUnit);
context->onSamplerUniformChange(oldTextureUnit);
}
}
......
......@@ -625,7 +625,7 @@ class Program final : angle::NonCopyable, public LabeledObject
void setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform4fv(GLint location, GLsizei count, const GLfloat *v);
SetUniformResult setUniform1iv(GLint location, GLsizei count, const GLint *v);
void setUniform1iv(Context *context, GLint location, GLsizei count, const GLint *v);
void setUniform2iv(GLint location, GLsizei count, const GLint *v);
void setUniform3iv(GLint location, GLsizei count, const GLint *v);
void setUniform4iv(GLint location, GLsizei count, const GLint *v);
......@@ -932,7 +932,8 @@ class Program final : angle::NonCopyable, public LabeledObject
template <size_t cols, size_t rows, typename T>
GLsizei clampMatrixUniformCount(GLint location, GLsizei count, GLboolean transpose, const T *v);
void updateSamplerUniform(const VariableLocation &locationInfo,
void updateSamplerUniform(Context *context,
const VariableLocation &locationInfo,
GLsizei clampedCount,
const GLint *v);
......
......@@ -243,7 +243,7 @@ void TextureManager::signalAllTexturesDirty(const Context *context) const
{
// We don't know if the Texture needs init, but that's ok, since it will only force
// a re-check, and will not initialize the pixels if it's not needed.
texture.second->signalDirty(context, InitState::MayNeedInit);
texture.second->signalDirtyStorage(context, InitState::MayNeedInit);
}
}
}
......
......@@ -179,7 +179,7 @@ class State : angle::NonCopyable
void setActiveSampler(unsigned int active);
unsigned int getActiveSampler() const { return static_cast<unsigned int>(mActiveSampler); }
angle::Result setSamplerTexture(const Context *context, TextureType type, Texture *texture);
void setSamplerTexture(const Context *context, TextureType type, Texture *texture);
Texture *getTargetTexture(TextureType type) const;
Texture *getSamplerTexture(unsigned int sampler, TextureType type) const
......@@ -487,10 +487,9 @@ class State : angle::NonCopyable
DIRTY_OBJECT_DRAW_FRAMEBUFFER,
DIRTY_OBJECT_DRAW_ATTACHMENTS,
DIRTY_OBJECT_VERTEX_ARRAY,
DIRTY_OBJECT_SAMPLERS,
// Use a very coarse bit for any program or texture change.
// TODO(jmadill): Fine-grained dirty bits for each texture/sampler.
DIRTY_OBJECT_PROGRAM_TEXTURES,
DIRTY_OBJECT_TEXTURES, // Top-level dirty bit. Also see mDirtyTextures.
DIRTY_OBJECT_IMAGES, // Top-level dirty bit. Also see mDirtyImages.
DIRTY_OBJECT_SAMPLERS, // Top-level dirty bit. Also see mDirtySamplers.
DIRTY_OBJECT_PROGRAM,
DIRTY_OBJECT_UNKNOWN,
DIRTY_OBJECT_MAX = DIRTY_OBJECT_UNKNOWN,
......@@ -508,6 +507,7 @@ class State : angle::NonCopyable
angle::Result syncDirtyObjects(const Context *context, const DirtyObjects &bitset);
angle::Result syncDirtyObject(const Context *context, GLenum target);
void setObjectDirty(GLenum target);
void setTextureDirty(size_t textureUnitIndex);
void setSamplerDirty(size_t samplerIndex);
ANGLE_INLINE void setDrawFramebufferDirty()
......@@ -533,7 +533,14 @@ class State : angle::NonCopyable
const ActiveTexturePointerArray &getActiveTexturesCache() const { return mActiveTexturesCache; }
ComponentTypeMask getCurrentValuesTypeMask() const { return mCurrentValuesTypeMask; }
void onActiveTextureStateChange(size_t textureIndex);
// "onActiveTextureChange" is called when a texture binding changes.
void onActiveTextureChange(const Context *context, size_t textureUnit);
// "onActiveTextureStateChange" calls when the Texture itself changed but the binding did not.
void onActiveTextureStateChange(const Context *context, size_t textureUnit);
void onImageStateChange(const Context *context, size_t unit);
void onUniformBufferStateChange(size_t uniformBufferIndex);
angle::Result clearUnclearedActiveTextures(const Context *context);
......@@ -559,32 +566,36 @@ class State : angle::NonCopyable
private:
void unsetActiveTextures(ActiveTextureMask textureMask);
angle::Result updateActiveTexture(const Context *context,
size_t textureIndex,
Texture *texture);
void updateActiveTexture(const Context *context, size_t textureIndex, Texture *texture);
void updateActiveTextureState(const Context *context,
size_t textureIndex,
const Sampler *sampler,
Texture *texture);
// Functions to synchronize dirty states
angle::Result syncReadFramebuffer(const Context *context);
angle::Result syncDrawFramebuffer(const Context *context);
angle::Result syncDrawAttachments(const Context *context);
angle::Result syncVertexArray(const Context *context);
angle::Result syncTextures(const Context *context);
angle::Result syncImages(const Context *context);
angle::Result syncSamplers(const Context *context);
angle::Result syncProgramTextures(const Context *context);
angle::Result syncProgram(const Context *context);
using DirtyObjectHandler = angle::Result (State::*)(const Context *context);
static constexpr DirtyObjectHandler kDirtyObjectHandlers[DIRTY_OBJECT_MAX] = {
&State::syncReadFramebuffer, &State::syncDrawFramebuffer, &State::syncDrawAttachments,
&State::syncVertexArray, &State::syncSamplers, &State::syncProgramTextures,
&State::syncProgram};
&State::syncVertexArray, &State::syncTextures, &State::syncImages,
&State::syncSamplers, &State::syncProgram};
static_assert(DIRTY_OBJECT_READ_FRAMEBUFFER == 0, "check DIRTY_OBJECT_READ_FRAMEBUFFER index");
static_assert(DIRTY_OBJECT_DRAW_FRAMEBUFFER == 1, "check DIRTY_OBJECT_DRAW_FRAMEBUFFER index");
static_assert(DIRTY_OBJECT_DRAW_ATTACHMENTS == 2, "check DIRTY_OBJECT_DRAW_ATTACHMENTS index");
static_assert(DIRTY_OBJECT_VERTEX_ARRAY == 3, "check DIRTY_OBJECT_VERTEX_ARRAY index");
static_assert(DIRTY_OBJECT_SAMPLERS == 4, "check DIRTY_OBJECT_SAMPLERS index");
static_assert(DIRTY_OBJECT_PROGRAM_TEXTURES == 5, "check DIRTY_OBJECT_PROGRAM_TEXTURES index");
static_assert(DIRTY_OBJECT_PROGRAM == 6, "check DIRTY_OBJECT_PROGRAM index");
static_assert(DIRTY_OBJECT_TEXTURES == 4, "check DIRTY_OBJECT_TEXTURES index");
static_assert(DIRTY_OBJECT_IMAGES == 5, "check DIRTY_OBJECT_IMAGES index");
static_assert(DIRTY_OBJECT_SAMPLERS == 6, "check DIRTY_OBJECT_SAMPLERS index");
static_assert(DIRTY_OBJECT_PROGRAM == 7, "check DIRTY_OBJECT_PROGRAM index");
// Dispatch table for buffer update functions.
static const angle::PackedEnumMap<BufferBinding, BufferBindingSetter> kBufferSetters;
......@@ -666,8 +677,8 @@ class State : angle::NonCopyable
SamplerBindingVector mSamplers;
using ImageUnitVector = std::vector<ImageUnit>;
ImageUnitVector mImageUnits;
// It would be nice to merge the image and observer binding. Same for textures.
std::vector<ImageUnit> mImageUnits;
using ActiveQueryMap = angle::PackedEnumMap<QueryType, BindingPointer<Query>>;
ActiveQueryMap mActiveQueries;
......@@ -722,7 +733,9 @@ class State : angle::NonCopyable
DirtyBits mDirtyBits;
DirtyObjects mDirtyObjects;
mutable AttributesMask mDirtyCurrentValues;
ActiveTextureMask mDirtyTextures;
ActiveTextureMask mDirtySamplers;
ImageUnitMask mDirtyImages;
};
ANGLE_INLINE angle::Result State::syncDirtyObjects(const Context *context,
......
......@@ -206,49 +206,49 @@ class Texture final : public RefCountObject,
TextureType getType() const { return mState.mType; }
void setSwizzleRed(GLenum swizzleRed);
void setSwizzleRed(const Context *context, GLenum swizzleRed);
GLenum getSwizzleRed() const;
void setSwizzleGreen(GLenum swizzleGreen);
void setSwizzleGreen(const Context *context, GLenum swizzleGreen);
GLenum getSwizzleGreen() const;
void setSwizzleBlue(GLenum swizzleBlue);
void setSwizzleBlue(const Context *context, GLenum swizzleBlue);
GLenum getSwizzleBlue() const;
void setSwizzleAlpha(GLenum swizzleAlpha);
void setSwizzleAlpha(const Context *context, GLenum swizzleAlpha);
GLenum getSwizzleAlpha() const;
void setMinFilter(GLenum minFilter);
void setMinFilter(const Context *context, GLenum minFilter);
GLenum getMinFilter() const;
void setMagFilter(GLenum magFilter);
void setMagFilter(const Context *context, GLenum magFilter);
GLenum getMagFilter() const;
void setWrapS(GLenum wrapS);
void setWrapS(const Context *context, GLenum wrapS);
GLenum getWrapS() const;
void setWrapT(GLenum wrapT);
void setWrapT(const Context *context, GLenum wrapT);
GLenum getWrapT() const;
void setWrapR(GLenum wrapR);
void setWrapR(const Context *context, GLenum wrapR);
GLenum getWrapR() const;
void setMaxAnisotropy(float maxAnisotropy);
void setMaxAnisotropy(const Context *context, float maxAnisotropy);
float getMaxAnisotropy() const;
void setMinLod(GLfloat minLod);
void setMinLod(const Context *context, GLfloat minLod);
GLfloat getMinLod() const;
void setMaxLod(GLfloat maxLod);
void setMaxLod(const Context *context, GLfloat maxLod);
GLfloat getMaxLod() const;
void setCompareMode(GLenum compareMode);
void setCompareMode(const Context *context, GLenum compareMode);
GLenum getCompareMode() const;
void setCompareFunc(GLenum compareFunc);
void setCompareFunc(const Context *context, GLenum compareFunc);
GLenum getCompareFunc() const;
void setSRGBDecode(GLenum sRGBDecode);
void setSRGBDecode(const Context *context, GLenum sRGBDecode);
GLenum getSRGBDecode() const;
const SamplerState &getSamplerState() const;
......@@ -256,19 +256,22 @@ class Texture final : public RefCountObject,
angle::Result setBaseLevel(const Context *context, GLuint baseLevel);
GLuint getBaseLevel() const;
void setMaxLevel(GLuint maxLevel);
void setMaxLevel(const Context *context, GLuint maxLevel);
GLuint getMaxLevel() const;
void setDepthStencilTextureMode(GLenum mode);
void setDepthStencilTextureMode(const Context *context, GLenum mode);
GLenum getDepthStencilTextureMode() const;
bool getImmutableFormat() const;
GLuint getImmutableLevels() const;
void setUsage(GLenum usage);
void setUsage(const Context *context, GLenum usage);
GLenum getUsage() const;
void setBorderColor(const Context *context, const ColorGeneric &color);
const ColorGeneric &getBorderColor() const;
const TextureState &getTextureState() const;
size_t getWidth(TextureTarget target, size_t level) const;
......@@ -377,7 +380,7 @@ class Texture final : public RefCountObject,
GLint getMemorySize() const;
GLint getLevelMemorySize(TextureTarget target, GLint level) const;
void signalDirty(const Context *context, InitState initState);
void signalDirtyStorage(const Context *context, InitState initState);
bool isSamplerComplete(const Context *context, const Sampler *optionalSampler);
......@@ -393,9 +396,6 @@ class Texture final : public RefCountObject,
bool getAttachmentFixedSampleLocations(const ImageIndex &imageIndex) const;
void setBorderColor(const ColorGeneric &color);
const ColorGeneric &getBorderColor() const;
// GLES1 emulation
void setCrop(const gl::Rectangle &rect);
const gl::Rectangle &getCrop() const;
......@@ -480,6 +480,8 @@ class Texture final : public RefCountObject,
angle::Result handleMipmapGenerationHint(Context *context, int level);
void signalDirtyState(const Context *context, size_t dirtyBit);
TextureState mState;
DirtyBits mDirtyBits;
rx::TextureImpl *mTexture;
......
......@@ -428,6 +428,8 @@ using ActiveTextureArray = std::array<T, IMPLEMENTATION_MAX_ACTIVE_TEXTURES>;
using ActiveTexturePointerArray = ActiveTextureArray<Texture *>;
using ActiveTextureTypeArray = ActiveTextureArray<TextureType>;
using ImageUnitMask = angle::BitSet<IMPLEMENTATION_MAX_IMAGE_UNITS>;
// OffsetBindingPointer.getSize() returns the size specified by the user, which may be larger than
// the size of the bound buffer. This function reduces the returned size to fit the bound buffer if
// necessary. Returns 0 if no buffer is bound or if integer overflow occurs.
......
......@@ -318,43 +318,43 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const
switch (pname)
{
case GL_TEXTURE_WRAP_S:
texture->setWrapS(ConvertToGLenum(pname, params[0]));
texture->setWrapS(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_WRAP_T:
texture->setWrapT(ConvertToGLenum(pname, params[0]));
texture->setWrapT(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_WRAP_R:
texture->setWrapR(ConvertToGLenum(pname, params[0]));
texture->setWrapR(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_MIN_FILTER:
texture->setMinFilter(ConvertToGLenum(pname, params[0]));
texture->setMinFilter(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_MAG_FILTER:
texture->setMagFilter(ConvertToGLenum(pname, params[0]));
texture->setMagFilter(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_USAGE_ANGLE:
texture->setUsage(ConvertToGLenum(pname, params[0]));
texture->setUsage(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
texture->setMaxAnisotropy(CastQueryValueTo<GLfloat>(pname, params[0]));
texture->setMaxAnisotropy(context, CastQueryValueTo<GLfloat>(pname, params[0]));
break;
case GL_TEXTURE_COMPARE_MODE:
texture->setCompareMode(ConvertToGLenum(pname, params[0]));
texture->setCompareMode(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_COMPARE_FUNC:
texture->setCompareFunc(ConvertToGLenum(pname, params[0]));
texture->setCompareFunc(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_SWIZZLE_R:
texture->setSwizzleRed(ConvertToGLenum(pname, params[0]));
texture->setSwizzleRed(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_SWIZZLE_G:
texture->setSwizzleGreen(ConvertToGLenum(pname, params[0]));
texture->setSwizzleGreen(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_SWIZZLE_B:
texture->setSwizzleBlue(ConvertToGLenum(pname, params[0]));
texture->setSwizzleBlue(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_SWIZZLE_A:
texture->setSwizzleAlpha(ConvertToGLenum(pname, params[0]));
texture->setSwizzleAlpha(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_BASE_LEVEL:
{
......@@ -363,19 +363,20 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const
break;
}
case GL_TEXTURE_MAX_LEVEL:
texture->setMaxLevel(clampCast<GLuint>(CastQueryValueTo<GLint>(pname, params[0])));
texture->setMaxLevel(context,
clampCast<GLuint>(CastQueryValueTo<GLint>(pname, params[0])));
break;
case GL_TEXTURE_MIN_LOD:
texture->setMinLod(CastQueryValueTo<GLfloat>(pname, params[0]));
texture->setMinLod(context, CastQueryValueTo<GLfloat>(pname, params[0]));
break;
case GL_TEXTURE_MAX_LOD:
texture->setMaxLod(CastQueryValueTo<GLfloat>(pname, params[0]));
texture->setMaxLod(context, CastQueryValueTo<GLfloat>(pname, params[0]));
break;
case GL_DEPTH_STENCIL_TEXTURE_MODE:
texture->setDepthStencilTextureMode(ConvertToGLenum(pname, params[0]));
texture->setDepthStencilTextureMode(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_SRGB_DECODE_EXT:
texture->setSRGBDecode(ConvertToGLenum(pname, params[0]));
texture->setSRGBDecode(context, ConvertToGLenum(pname, params[0]));
break;
case GL_TEXTURE_CROP_RECT_OES:
texture->setCrop(gl::Rectangle(CastQueryValueTo<GLint>(pname, params[0]),
......@@ -387,7 +388,7 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const
texture->setGenerateMipmapHint(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_BORDER_COLOR:
texture->setBorderColor(ConvertToColor<isPureInteger>(params));
texture->setBorderColor(context, ConvertToColor<isPureInteger>(params));
break;
default:
UNREACHABLE();
......
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