aboutsummaryrefslogtreecommitdiff
path: root/emulator
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2014-11-06 18:47:40 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-11-06 18:47:40 +0000
commit4f80477b0f021b3e099e792add4c5badd42aa9bf (patch)
tree2d9c89e5c70086a94069ae98a257392f46a17372 /emulator
parent9631afbe3363fc458c16c80eae70a5776fa5fdac (diff)
parent7748c5f71a17c51ede5ed77a17bdad14445e20d2 (diff)
downloadsdk-4f80477b0f021b3e099e792add4c5badd42aa9bf.tar.gz
Merge "Detach texture or renderbuffer when deleting them"
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp25
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp5
2 files changed, 29 insertions, 1 deletions
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index cebd5a92e..4aac5f8d8 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -457,6 +457,27 @@ GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* frame
}
}
+static void s_detachFromFramebuffer(GLuint bufferType, GLuint texture) {
+ GET_CTX();
+ GLuint fbName = ctx->getFramebufferBinding();
+ if (!fbName) return;
+ ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName);
+ if (fbObj.Ptr() == NULL) return;
+ FramebufferData *fbData = (FramebufferData *)fbObj.Ptr();
+ GLenum target;
+ const GLenum kAttachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
+ const size_t sizen = sizeof(kAttachments)/sizeof(GLenum);
+ for (size_t i = 0; i < sizen; ++i ) {
+ GLuint name = fbData->getAttachment(kAttachments[i], &target, NULL);
+ if (name != texture) continue;
+ if (TEXTURE == bufferType && GLESv2Validate::textureTargetEx(target)) {
+ glFramebufferTexture2D(GL_FRAMEBUFFER, kAttachments[i], target, 0, 0);
+ } else if (RENDERBUFFER == bufferType && GLESv2Validate::renderbufferTarget(target)) {
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, kAttachments[i], target, 0);
+ }
+ }
+}
+
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
@@ -465,6 +486,7 @@ GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* rend
const GLuint globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffers[i]);
ctx->shareGroup()->deleteName(RENDERBUFFER,renderbuffers[i]);
ctx->dispatcher().glDeleteRenderbuffersEXT(1,&globalRenderBufferName);
+ s_detachFromFramebuffer(RENDERBUFFER, renderbuffers[i]);
}
}
}
@@ -488,6 +510,7 @@ GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
ctx->setBindedTexture(GL_TEXTURE_2D,0);
if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i])
ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0);
+ s_detachFromFramebuffer(TEXTURE, textures[i]);
}
}
}
@@ -1057,12 +1080,14 @@ GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target
// Take the attachment attribute from our state - if available
//
GLuint fbName = ctx->getFramebufferBinding();
+ SET_ERROR_IF (!fbName, GL_INVALID_OPERATION);
if (fbName) {
ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName);
if (fbObj.Ptr() != NULL) {
FramebufferData *fbData = (FramebufferData *)fbObj.Ptr();
GLenum target;
GLuint name = fbData->getAttachment(attachment, &target, NULL);
+ SET_ERROR_IF(!name && pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_INVALID_ENUM);
if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) {
if (target == GL_TEXTURE_2D) {
*params = GL_TEXTURE;
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp b/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp
index c923bfc8a..2e35c8d7a 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp
@@ -52,7 +52,10 @@ void FramebufferData::setAttachment(GLenum attachment,
ObjectDataPtr obj,
bool takeOwnership) {
int idx = attachmentPointIndex(attachment);
-
+ if (!name) {
+ detachObject(idx);
+ return;
+ }
if (m_attachPoints[idx].target != target ||
m_attachPoints[idx].name != name ||
m_attachPoints[idx].obj.Ptr() != obj.Ptr() ||