Commit f01c0890 by Nicolas Capens Committed by Nicolas Capens

Delete EGL images only after eglDestroyImageKHR.

BUG=18316605 Change-Id: I85944b87642664c6202bacdfc852e9cedabc79a9 Reviewed-on: https://swiftshader-review.googlesource.com/1357Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 606c86ee
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include "Renderer/Surface.hpp" #include "Renderer/Surface.hpp"
#include <assert.h>
namespace egl namespace egl
{ {
// Types common between gl.h and gl2.h // Types common between gl.h and gl2.h
...@@ -58,27 +60,27 @@ public: ...@@ -58,27 +60,27 @@ public:
return multiSampleDepth; return multiSampleDepth;
} }
bool Image::isShared() const bool isShared() const
{ {
return shared; return shared;
} }
void Image::markShared() void markShared()
{ {
shared = true; shared = true;
} }
void *Image::lock(unsigned int left, unsigned int top, sw::Lock lock) void *lock(unsigned int left, unsigned int top, sw::Lock lock)
{ {
return lockExternal(left, top, 0, lock, sw::PUBLIC); return lockExternal(left, top, 0, lock, sw::PUBLIC);
} }
unsigned int Image::getPitch() const unsigned int getPitch() const
{ {
return getExternalPitchB(); return getExternalPitchB();
} }
void Image::unlock() void unlock()
{ {
unlockExternal(); unlockExternal();
} }
...@@ -87,10 +89,21 @@ public: ...@@ -87,10 +89,21 @@ public:
virtual void release() = 0; virtual void release() = 0;
virtual void unbind() = 0; // Break parent ownership and release virtual void unbind() = 0; // Break parent ownership and release
void destroyShared() // Release a shared image
{
assert(shared);
shared = false;
release();
}
virtual void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *input) = 0; virtual void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *input) = 0;
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) = 0; virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) = 0;
protected: protected:
virtual ~Image() = 0
{
}
const GLsizei width; const GLsizei width;
const GLsizei height; const GLsizei height;
const GLenum format; const GLenum format;
...@@ -98,7 +111,6 @@ protected: ...@@ -98,7 +111,6 @@ protected:
const sw::Format internalFormat; const sw::Format internalFormat;
const int multiSampleDepth; const int multiSampleDepth;
private:
bool shared; // Used as an EGLImage bool shared; // Used as an EGLImage
}; };
} }
......
...@@ -1080,6 +1080,8 @@ EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNat ...@@ -1080,6 +1080,8 @@ EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNat
EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{ {
TRACE("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLenum target = 0x%X, buffer = 0x%0.8p, const EGLint attrib_list = 0x%0.8p)", dpy, ctx, target, buffer, attrib_list);
try try
{ {
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
...@@ -1154,6 +1156,8 @@ EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenu ...@@ -1154,6 +1156,8 @@ EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenu
EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
{ {
TRACE("(EGLDisplay dpy = 0x%0.8p, EGLImageKHR image = 0x%0.8p)", dpy, image);
try try
{ {
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
...@@ -1169,7 +1173,7 @@ EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) ...@@ -1169,7 +1173,7 @@ EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
} }
egl::Image *glImage = static_cast<egl::Image*>(image); egl::Image *glImage = static_cast<egl::Image*>(image);
glImage->release(); glImage->destroyShared();
return success(EGL_TRUE); return success(EGL_TRUE);
} }
......
...@@ -72,7 +72,7 @@ namespace es1 ...@@ -72,7 +72,7 @@ namespace es1
sw::atomicDecrement(&referenceCount); sw::atomicDecrement(&referenceCount);
} }
if(referenceCount == 0) if(referenceCount == 0 && !shared)
{ {
delete this; delete this;
} }
......
...@@ -71,7 +71,7 @@ namespace es2 ...@@ -71,7 +71,7 @@ namespace es2
sw::atomicDecrement(&referenceCount); sw::atomicDecrement(&referenceCount);
} }
if(referenceCount == 0) if(referenceCount == 0 && !shared)
{ {
delete this; delete this;
} }
......
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