mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 14:00:09 -10:00
Remove Texture serials and Texture::INCOMPLETE_TEXTURE_ID.
Texture serials were not used in any place that pointers could not be used and Texture::INCOMPLETE_TEXTURE_ID was only referenced by RendererD3D. This was the last place that serials are used in the gl layer. BUG=angleproject:681 Change-Id: Iad24321fba57db8ade3c9eb8f04cc20e98ded1b0 Reviewed-on: https://chromium-review.googlesource.com/263659 Reviewed-by: Brandon Jones <[email protected]> Reviewed-by: Geoff Lang <[email protected]> Tested-by: Geoff Lang <[email protected]>
This commit is contained in:
1 parent
c2520564c3
commit
eaa759c46f
7 files changed
+32
-60
No files matched your search
@@ -45,12 +45,9 @@ static size_t GetImageDescIndex(GLenum target, size_t level)
|
||||
return IsCubeMapTextureTarget(target) ? ((level * 6) + CubeMapTextureTargetToLayerIndex(target)) : level;
|
||||
}
|
||||
|
||||
unsigned int Texture::mCurrentTextureSerial = 1;
|
||||
|
||||
Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target)
|
||||
: FramebufferAttachmentObject(id),
|
||||
mTexture(impl),
|
||||
mTextureSerial(issueTextureSerial()),
|
||||
mUsage(GL_NONE),
|
||||
mImmutableLevelCount(0),
|
||||
mTarget(target),
|
||||
@@ -155,16 +152,6 @@ bool Texture::isCubeComplete() const
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int Texture::getTextureSerial() const
|
||||
{
|
||||
return mTextureSerial;
|
||||
}
|
||||
|
||||
unsigned int Texture::issueTextureSerial()
|
||||
{
|
||||
return mCurrentTextureSerial++;
|
||||
}
|
||||
|
||||
bool Texture::isImmutable() const
|
||||
{
|
||||
return (mImmutableLevelCount > 0);
|
||||
|
||||
@@ -75,10 +75,6 @@ class Texture final : public FramebufferAttachmentObject
|
||||
|
||||
virtual Error generateMipmaps();
|
||||
|
||||
// Texture serials provide a unique way of identifying a Texture that isn't a raw pointer.
|
||||
// "id" is not good enough, as Textures can be deleted, then re-allocated with the same id.
|
||||
unsigned int getTextureSerial() const;
|
||||
|
||||
bool isImmutable() const;
|
||||
GLsizei immutableLevelCount();
|
||||
|
||||
@@ -88,8 +84,6 @@ class Texture final : public FramebufferAttachmentObject
|
||||
rx::TextureImpl *getImplementation() { return mTexture; }
|
||||
const rx::TextureImpl *getImplementation() const { return mTexture; }
|
||||
|
||||
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
|
||||
|
||||
// FramebufferAttachmentObject implementation
|
||||
GLsizei getAttachmentWidth(const FramebufferAttachment::Target &target) const override;
|
||||
GLsizei getAttachmentHeight(const FramebufferAttachment::Target &target) const override;
|
||||
@@ -98,7 +92,6 @@ class Texture final : public FramebufferAttachmentObject
|
||||
|
||||
private:
|
||||
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mTexture; }
|
||||
static unsigned int issueTextureSerial();
|
||||
|
||||
rx::TextureImpl *mTexture;
|
||||
|
||||
@@ -109,7 +102,6 @@ class Texture final : public FramebufferAttachmentObject
|
||||
|
||||
GLenum mTarget;
|
||||
|
||||
|
||||
struct ImageDesc
|
||||
{
|
||||
Extents size;
|
||||
@@ -119,9 +111,6 @@ class Texture final : public FramebufferAttachmentObject
|
||||
ImageDesc(const Extents &size, GLenum internalFormat);
|
||||
};
|
||||
|
||||
const unsigned int mTextureSerial;
|
||||
static unsigned int mCurrentTextureSerial;
|
||||
|
||||
GLenum getBaseImageTarget() const;
|
||||
size_t getExpectedMipLevels() const;
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace
|
||||
const int ScratchMemoryBufferLifetime = 1000;
|
||||
}
|
||||
|
||||
const uintptr_t RendererD3D::DirtyPointer = std::numeric_limits<uintptr_t>::max();
|
||||
|
||||
RendererD3D::RendererD3D(egl::Display *display)
|
||||
: mDisplay(display),
|
||||
mDeviceLost(false),
|
||||
@@ -372,7 +374,7 @@ gl::Error RendererD3D::applyShaders(const gl::Data &data)
|
||||
// looks up the corresponding OpenGL texture image unit and texture type,
|
||||
// and sets the texture and its addressing/filtering state (or NULL when inactive).
|
||||
gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shaderType,
|
||||
const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount)
|
||||
const FramebufferTextureArray &framebufferTextures, size_t framebufferTextureCount)
|
||||
{
|
||||
gl::Program *program = data.state->getProgram();
|
||||
|
||||
@@ -395,7 +397,7 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shade
|
||||
|
||||
// TODO: std::binary_search may become unavailable using older versions of GCC
|
||||
if (texture->isSamplerComplete(sampler, data) &&
|
||||
!std::binary_search(framebufferSerials.begin(), framebufferSerials.begin() + framebufferSerialCount, texture->getTextureSerial()))
|
||||
!std::binary_search(framebufferTextures.begin(), framebufferTextures.begin() + framebufferTextureCount, texture))
|
||||
{
|
||||
gl::Error error = setSamplerState(shaderType, samplerIndex, texture, sampler);
|
||||
if (error.isError())
|
||||
@@ -448,16 +450,16 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shade
|
||||
|
||||
gl::Error RendererD3D::applyTextures(const gl::Data &data)
|
||||
{
|
||||
FramebufferTextureSerialArray framebufferSerials;
|
||||
size_t framebufferSerialCount = getBoundFramebufferTextureSerials(data, &framebufferSerials);
|
||||
FramebufferTextureArray framebufferTextures;
|
||||
size_t framebufferSerialCount = getBoundFramebufferTextures(data, &framebufferTextures);
|
||||
|
||||
gl::Error error = applyTextures(data, gl::SAMPLER_VERTEX, framebufferSerials, framebufferSerialCount);
|
||||
gl::Error error = applyTextures(data, gl::SAMPLER_VERTEX, framebufferTextures, framebufferSerialCount);
|
||||
if (error.isError())
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
error = applyTextures(data, gl::SAMPLER_PIXEL, framebufferSerials, framebufferSerialCount);
|
||||
error = applyTextures(data, gl::SAMPLER_PIXEL, framebufferTextures, framebufferSerialCount);
|
||||
if (error.isError())
|
||||
{
|
||||
return error;
|
||||
@@ -507,10 +509,9 @@ void RendererD3D::markTransformFeedbackUsage(const gl::Data &data)
|
||||
}
|
||||
}
|
||||
|
||||
size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data,
|
||||
FramebufferTextureSerialArray *outSerialArray)
|
||||
size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray)
|
||||
{
|
||||
size_t serialCount = 0;
|
||||
size_t textureCount = 0;
|
||||
|
||||
const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer();
|
||||
for (unsigned int i = 0; i < data.caps->maxColorAttachments; i++)
|
||||
@@ -518,21 +519,19 @@ size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data,
|
||||
const gl::FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
|
||||
if (attachment && attachment->type() == GL_TEXTURE)
|
||||
{
|
||||
gl::Texture *texture = attachment->getTexture();
|
||||
(*outSerialArray)[serialCount++] = texture->getTextureSerial();
|
||||
(*outTextureArray)[textureCount++] = attachment->getTexture();
|
||||
}
|
||||
}
|
||||
|
||||
const gl::FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer();
|
||||
if (depthStencilAttachment && depthStencilAttachment->type() == GL_TEXTURE)
|
||||
{
|
||||
gl::Texture *depthStencilTexture = depthStencilAttachment->getTexture();
|
||||
(*outSerialArray)[serialCount++] = depthStencilTexture->getTextureSerial();
|
||||
(*outTextureArray)[textureCount++] = depthStencilAttachment->getTexture();
|
||||
}
|
||||
|
||||
std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount);
|
||||
std::sort(outTextureArray->begin(), outTextureArray->begin() + textureCount);
|
||||
|
||||
return serialCount;
|
||||
return textureCount;
|
||||
}
|
||||
|
||||
gl::Texture *RendererD3D::getIncompleteTexture(GLenum type)
|
||||
@@ -543,7 +542,7 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLenum type)
|
||||
const gl::Extents colorSize(1, 1, 1);
|
||||
const gl::PixelUnpackState incompleteUnpackState(1, 0);
|
||||
|
||||
gl::Texture* t = new gl::Texture(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID, type);
|
||||
gl::Texture* t = new gl::Texture(createTexture(type), std::numeric_limits<GLuint>::max(), type);
|
||||
|
||||
if (type == GL_TEXTURE_CUBE_MAP)
|
||||
{
|
||||
|
||||
@@ -193,12 +193,15 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
|
||||
|
||||
void cleanup();
|
||||
|
||||
// dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state.
|
||||
static const uintptr_t DirtyPointer;
|
||||
|
||||
egl::Display *mDisplay;
|
||||
bool mDeviceLost;
|
||||
|
||||
private:
|
||||
//FIXME(jmadill): std::array is currently prohibited by Chromium style guide
|
||||
typedef std::array<unsigned int, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureSerialArray;
|
||||
typedef std::array<gl::Texture*, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureArray;
|
||||
|
||||
gl::Error generateSwizzles(const gl::Data &data, gl::SamplerType type);
|
||||
gl::Error generateSwizzles(const gl::Data &data);
|
||||
@@ -207,14 +210,13 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
|
||||
gl::Error applyState(const gl::Data &data, GLenum drawMode);
|
||||
gl::Error applyShaders(const gl::Data &data);
|
||||
gl::Error applyTextures(const gl::Data &data, gl::SamplerType shaderType,
|
||||
const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount);
|
||||
const FramebufferTextureArray &framebufferTextures, size_t framebufferTextureCount);
|
||||
gl::Error applyTextures(const gl::Data &data);
|
||||
|
||||
bool skipDraw(const gl::Data &data, GLenum drawMode);
|
||||
void markTransformFeedbackUsage(const gl::Data &data);
|
||||
|
||||
size_t getBoundFramebufferTextureSerials(const gl::Data &data,
|
||||
FramebufferTextureSerialArray *outSerialArray);
|
||||
size_t getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray);
|
||||
gl::Texture *getIncompleteTexture(GLenum type);
|
||||
|
||||
gl::TextureMap mIncompleteTextures;
|
||||
|
||||
@@ -75,9 +75,6 @@ enum
|
||||
MAX_TEXTURE_IMAGE_UNITS_VTF_SM4 = 16
|
||||
};
|
||||
|
||||
// dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state.
|
||||
static const uintptr_t DirtyPointer = static_cast<uintptr_t>(-1);
|
||||
|
||||
static bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOURCE_VIEW_DESC desc)
|
||||
{
|
||||
unsigned mipLevel = index.mipIndex;
|
||||
|
||||
@@ -360,8 +360,8 @@ void Renderer9::initializeDevice()
|
||||
mForceSetPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
|
||||
mCurPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
|
||||
|
||||
mCurVertexTextureSerials.resize(rendererCaps.maxVertexTextureImageUnits);
|
||||
mCurPixelTextureSerials.resize(rendererCaps.maxTextureImageUnits);
|
||||
mCurVertexTextures.resize(rendererCaps.maxVertexTextureImageUnits);
|
||||
mCurPixelTextures.resize(rendererCaps.maxTextureImageUnits);
|
||||
|
||||
markAllStateDirty();
|
||||
|
||||
@@ -821,10 +821,9 @@ gl::Error Renderer9::setTexture(gl::SamplerType type, int index, gl::Texture *te
|
||||
int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
|
||||
int d3dSampler = index + d3dSamplerOffset;
|
||||
IDirect3DBaseTexture9 *d3dTexture = NULL;
|
||||
unsigned int serial = 0;
|
||||
bool forceSetTexture = false;
|
||||
|
||||
std::vector<unsigned int> &appliedSerials = (type == gl::SAMPLER_PIXEL) ? mCurPixelTextureSerials : mCurVertexTextureSerials;
|
||||
std::vector<uintptr_t> &appliedTextures = (type == gl::SAMPLER_PIXEL) ? mCurPixelTextures : mCurVertexTextures;
|
||||
|
||||
if (texture)
|
||||
{
|
||||
@@ -851,17 +850,16 @@ gl::Error Renderer9::setTexture(gl::SamplerType type, int index, gl::Texture *te
|
||||
// in the texture class and we're unexpectedly missing the d3d texture
|
||||
ASSERT(d3dTexture != NULL);
|
||||
|
||||
serial = texture->getTextureSerial();
|
||||
forceSetTexture = textureImpl->hasDirtyImages();
|
||||
textureImpl->resetDirty();
|
||||
}
|
||||
|
||||
if (forceSetTexture || appliedSerials[index] != serial)
|
||||
if (forceSetTexture || appliedTextures[index] != reinterpret_cast<uintptr_t>(d3dTexture))
|
||||
{
|
||||
mDevice->SetTexture(d3dSampler, d3dTexture);
|
||||
}
|
||||
|
||||
appliedSerials[index] = serial;
|
||||
appliedTextures[index] = reinterpret_cast<uintptr_t>(d3dTexture);
|
||||
|
||||
return gl::Error(GL_NO_ERROR);
|
||||
}
|
||||
@@ -2241,18 +2239,18 @@ void Renderer9::markAllStateDirty()
|
||||
mForceSetViewport = true;
|
||||
mForceSetBlendState = true;
|
||||
|
||||
ASSERT(mForceSetVertexSamplerStates.size() == mCurVertexTextureSerials.size());
|
||||
ASSERT(mForceSetVertexSamplerStates.size() == mCurVertexTextures.size());
|
||||
for (unsigned int i = 0; i < mForceSetVertexSamplerStates.size(); i++)
|
||||
{
|
||||
mForceSetVertexSamplerStates[i] = true;
|
||||
mCurVertexTextureSerials[i] = 0;
|
||||
mCurVertexTextures[i] = DirtyPointer;
|
||||
}
|
||||
|
||||
ASSERT(mForceSetPixelSamplerStates.size() == mCurPixelTextureSerials.size());
|
||||
ASSERT(mForceSetPixelSamplerStates.size() == mCurPixelTextures.size());
|
||||
for (unsigned int i = 0; i < mForceSetPixelSamplerStates.size(); i++)
|
||||
{
|
||||
mForceSetPixelSamplerStates[i] = true;
|
||||
mCurPixelTextureSerials[i] = 0;
|
||||
mCurPixelTextures[i] = DirtyPointer;
|
||||
}
|
||||
|
||||
mAppliedIBSerial = 0;
|
||||
|
||||
@@ -338,8 +338,8 @@ class Renderer9 : public RendererD3D
|
||||
std::vector<gl::SamplerState> mCurPixelSamplerStates;
|
||||
|
||||
// Currently applied textures
|
||||
std::vector<unsigned int> mCurVertexTextureSerials;
|
||||
std::vector<unsigned int> mCurPixelTextureSerials;
|
||||
std::vector<uintptr_t> mCurVertexTextures;
|
||||
std::vector<uintptr_t> mCurPixelTextures;
|
||||
|
||||
unsigned int mAppliedIBSerial;
|
||||
IDirect3DVertexShader9 *mAppliedVertexShader;
|
||||
|
||||
Reference in new issue
Block a user