Commit b2022a76 by Nicolas Capens

Use gl::Object to reference count egl::Image.

Bug 26851951 Change-Id: I5b594bdd34e6fa1074d5439ee2c09f6731839dee Reviewed-on: https://swiftshader-review.googlesource.com/4534Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 3d7be4ea
...@@ -1132,7 +1132,7 @@ namespace egl ...@@ -1132,7 +1132,7 @@ namespace egl
Image::~Image() Image::~Image()
{ {
ASSERT(referenceCount == 0); ASSERT(!shared);
} }
void Image::addRef() void Image::addRef()
...@@ -1141,8 +1141,8 @@ namespace egl ...@@ -1141,8 +1141,8 @@ namespace egl
{ {
return parentTexture->addRef(); return parentTexture->addRef();
} }
int newCount = sw::atomicIncrement(&referenceCount);
LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount); Object::addRef();
} }
void Image::release() void Image::release()
...@@ -1152,20 +1152,14 @@ namespace egl ...@@ -1152,20 +1152,14 @@ namespace egl
return parentTexture->release(); return parentTexture->release();
} }
int newCount = sw::atomicDecrement(&referenceCount); Object::release();
LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
if (newCount == 0)
{
ASSERT(!shared); // Should still hold a reference if eglDestroyImage hasn't been called
delete this;
}
} }
void Image::unbind(const egl::Texture *parent) void Image::unbind(const egl::Texture *parent)
{ {
if(parentTexture == parent) if(parentTexture == parent)
{ {
parentTexture = 0; parentTexture = nullptr;
} }
release(); release();
......
...@@ -36,7 +36,7 @@ static inline sw::Resource *getParentResource(egl::Texture *texture) ...@@ -36,7 +36,7 @@ static inline sw::Resource *getParentResource(egl::Texture *texture)
return texture ? texture->getResource() : nullptr; return texture ? texture->getResource() : nullptr;
} }
class Image : public sw::Surface class Image : public sw::Surface, public gl::Object
{ {
public: public:
Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type) Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type)
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
parentTexture(parentTexture) parentTexture(parentTexture)
{ {
shared = false; shared = false;
referenceCount = 1; Object::addRef();
} }
Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pitchP = 0) Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pitchP = 0)
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
parentTexture(parentTexture) parentTexture(parentTexture)
{ {
shared = false; shared = false;
referenceCount = 1; Object::addRef();
} }
Image(GLsizei width, GLsizei height, sw::Format internalFormat, int multiSampleDepth, bool lockable, bool renderTarget) Image(GLsizei width, GLsizei height, sw::Format internalFormat, int multiSampleDepth, bool lockable, bool renderTarget)
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
width(width), height(height), format(0 /*GL_NONE*/), type(0 /*GL_NONE*/), internalFormat(internalFormat), depth(multiSampleDepth), parentTexture(nullptr) width(width), height(height), format(0 /*GL_NONE*/), type(0 /*GL_NONE*/), internalFormat(internalFormat), depth(multiSampleDepth), parentTexture(nullptr)
{ {
shared = false; shared = false;
referenceCount = 1; Object::addRef();
} }
GLsizei getWidth() const GLsizei getWidth() const
...@@ -137,8 +137,8 @@ public: ...@@ -137,8 +137,8 @@ public:
void loadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const UnpackInfo& unpackInfo, const void *input); void loadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const UnpackInfo& unpackInfo, const void *input);
void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void addRef(); void addRef() override;
virtual void release(); void release() override;
virtual void unbind(const Texture *parent); // Break parent ownership and release virtual void unbind(const Texture *parent); // Break parent ownership and release
virtual void destroyShared() // Release a shared image virtual void destroyShared() // Release a shared image
...@@ -160,8 +160,6 @@ protected: ...@@ -160,8 +160,6 @@ protected:
egl::Texture *parentTexture; egl::Texture *parentTexture;
volatile int referenceCount;
virtual ~Image(); virtual ~Image();
void loadD24S8ImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, int inputPitch, int inputHeight, const void *input, void *buffer); void loadD24S8ImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, int inputPitch, int inputHeight, const void *input, void *buffer);
......
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