diff options
author | Jamie Madill <jmadill@chromium.org> | 2014-09-05 10:12:41 -0400 |
---|---|---|
committer | Jamie Madill <jmadill@chromium.org> | 2014-09-05 14:37:33 +0000 |
commit | aef95dec1cb82857fbe0dd88ad92eb3451e482f2 (patch) | |
tree | f521c552ff7db4708ffb71963cefb693b20f7cac | |
parent | b33b4777b00e3bbff0d9cef374efad54d49885ec (diff) | |
download | angle-aef95dec1cb82857fbe0dd88ad92eb3451e482f2.tar.gz |
Use attachment binding points for dynamic PS key.
Because our output signature is only dependent on the arrangment
of the attachments, not the attachment type, use the output
layout key for now. If we need to, we could store both, in the
future.
BUG=angle:705
Change-Id: I3b99954d30b91a4741fdd6f48f8ffcf88c0bea7a
Reviewed-on: https://chromium-review.googlesource.com/215846
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
-rw-r--r-- | src/libGLESv2/Framebuffer.cpp | 29 | ||||
-rw-r--r-- | src/libGLESv2/Framebuffer.h | 4 | ||||
-rw-r--r-- | src/libGLESv2/FramebufferAttachment.cpp | 31 | ||||
-rw-r--r-- | src/libGLESv2/FramebufferAttachment.h | 18 | ||||
-rw-r--r-- | src/libGLESv2/ProgramBinary.cpp | 19 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp | 2 |
6 files changed, 63 insertions, 40 deletions
diff --git a/src/libGLESv2/Framebuffer.cpp b/src/libGLESv2/Framebuffer.cpp index 60766c2e..b9c4a71c 100644 --- a/src/libGLESv2/Framebuffer.cpp +++ b/src/libGLESv2/Framebuffer.cpp @@ -47,7 +47,7 @@ Framebuffer::~Framebuffer() SafeDelete(mStencilbuffer); } -FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const +FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type, GLuint handle, GLint level, GLint layer) const { if (handle == 0) { @@ -62,7 +62,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, return NULL; case GL_RENDERBUFFER: - return new RenderbufferAttachment(context->getRenderbuffer(handle)); + return new RenderbufferAttachment(binding, context->getRenderbuffer(handle)); case GL_TEXTURE_2D: { @@ -70,7 +70,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, if (texture && texture->getTarget() == GL_TEXTURE_2D) { Texture2D *tex2D = static_cast<Texture2D*>(texture); - return new Texture2DAttachment(tex2D, level); + return new Texture2DAttachment(binding, tex2D, level); } else { @@ -89,7 +89,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP) { TextureCubeMap *texCube = static_cast<TextureCubeMap*>(texture); - return new TextureCubeMapAttachment(texCube, type, level); + return new TextureCubeMapAttachment(binding, texCube, type, level); } else { @@ -103,7 +103,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, if (texture && texture->getTarget() == GL_TEXTURE_3D) { Texture3D *tex3D = static_cast<Texture3D*>(texture); - return new Texture3DAttachment(tex3D, level, layer); + return new Texture3DAttachment(binding, tex3D, level, layer); } else { @@ -117,7 +117,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY) { Texture2DArray *tex2DArray = static_cast<Texture2DArray*>(texture); - return new Texture2DArrayAttachment(tex2DArray, level, layer); + return new Texture2DArrayAttachment(binding, tex2DArray, level, layer); } else { @@ -135,24 +135,25 @@ void Framebuffer::setColorbuffer(unsigned int colorAttachment, GLenum type, GLui { ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); SafeDelete(mColorbuffers[colorAttachment]); - mColorbuffers[colorAttachment] = createAttachment(type, colorbuffer, level, layer); + GLenum binding = colorAttachment + GL_COLOR_ATTACHMENT0; + mColorbuffers[colorAttachment] = createAttachment(binding, type, colorbuffer, level, layer); } void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer) { SafeDelete(mDepthbuffer); - mDepthbuffer = createAttachment(type, depthbuffer, level, layer); + mDepthbuffer = createAttachment(GL_DEPTH_ATTACHMENT, type, depthbuffer, level, layer); } void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer) { SafeDelete(mStencilbuffer); - mStencilbuffer = createAttachment(type, stencilbuffer, level, layer); + mStencilbuffer = createAttachment(GL_STENCIL_ATTACHMENT, type, stencilbuffer, level, layer); } void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer) { - FramebufferAttachment *attachment = createAttachment(type, depthStencilBuffer, level, layer); + FramebufferAttachment *attachment = createAttachment(GL_DEPTH_STENCIL_ATTACHMENT, type, depthStencilBuffer, level, layer); SafeDelete(mDepthbuffer); SafeDelete(mStencilbuffer); @@ -164,7 +165,7 @@ void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, // Make a new attachment object to ensure we do not double-delete // See angle issue 686 - mStencilbuffer = createAttachment(type, depthStencilBuffer, level, layer); + mStencilbuffer = createAttachment(GL_DEPTH_STENCIL_ATTACHMENT, type, depthStencilBuffer, level, layer); } } @@ -594,14 +595,14 @@ DefaultFramebuffer::DefaultFramebuffer(rx::Renderer *renderer, Colorbuffer *colo : Framebuffer(renderer, 0) { Renderbuffer *colorRenderbuffer = new Renderbuffer(0, colorbuffer); - mColorbuffers[0] = new RenderbufferAttachment(colorRenderbuffer); + mColorbuffers[0] = new RenderbufferAttachment(GL_BACK, colorRenderbuffer); Renderbuffer *depthStencilBuffer = new Renderbuffer(0, depthStencil); // Make a new attachment objects to ensure we do not double-delete // See angle issue 686 - mDepthbuffer = (depthStencilBuffer->getDepthSize() != 0 ? new RenderbufferAttachment(depthStencilBuffer) : NULL); - mStencilbuffer = (depthStencilBuffer->getStencilSize() != 0 ? new RenderbufferAttachment(depthStencilBuffer) : NULL); + mDepthbuffer = (depthStencilBuffer->getDepthSize() != 0 ? new RenderbufferAttachment(GL_DEPTH_ATTACHMENT, depthStencilBuffer) : NULL); + mStencilbuffer = (depthStencilBuffer->getStencilSize() != 0 ? new RenderbufferAttachment(GL_STENCIL_ATTACHMENT, depthStencilBuffer) : NULL); mDrawBufferStates[0] = GL_BACK; mReadBufferState = GL_BACK; diff --git a/src/libGLESv2/Framebuffer.h b/src/libGLESv2/Framebuffer.h index d6dce690..8d7678c1 100644 --- a/src/libGLESv2/Framebuffer.h +++ b/src/libGLESv2/Framebuffer.h @@ -93,10 +93,10 @@ class Framebuffer FramebufferAttachment *mDepthbuffer; FramebufferAttachment *mStencilbuffer; -private: + private: DISALLOW_COPY_AND_ASSIGN(Framebuffer); - FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const; + FramebufferAttachment *createAttachment(GLenum binding, GLenum type, GLuint handle, GLint level, GLint layer) const; }; class DefaultFramebuffer : public Framebuffer diff --git a/src/libGLESv2/FramebufferAttachment.cpp b/src/libGLESv2/FramebufferAttachment.cpp index fa75087a..994e1a55 100644 --- a/src/libGLESv2/FramebufferAttachment.cpp +++ b/src/libGLESv2/FramebufferAttachment.cpp @@ -22,7 +22,8 @@ namespace gl ////// FramebufferAttachment Implementation ////// -FramebufferAttachment::FramebufferAttachment() +FramebufferAttachment::FramebufferAttachment(GLenum binding) + : mBinding(binding) { } @@ -77,6 +78,10 @@ bool FramebufferAttachment::isTexture() const ///// TextureAttachment Implementation //////// +TextureAttachment::TextureAttachment(GLenum binding) + : FramebufferAttachment(binding) +{} + rx::TextureStorage *TextureAttachment::getTextureStorage() { return getTexture()->getNativeTexture()->getStorageInstance(); @@ -99,7 +104,9 @@ unsigned int TextureAttachment::getTextureSerial() const ///// Texture2DAttachment Implementation //////// -Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level) +Texture2DAttachment::Texture2DAttachment(GLenum binding, Texture2D *texture, GLint level) + : TextureAttachment(binding), + mLevel(level) { mTexture2D.set(texture); } @@ -161,8 +168,9 @@ Texture *Texture2DAttachment::getTexture() const ///// TextureCubeMapAttachment Implementation //////// -TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level) - : mFaceTarget(faceTarget), mLevel(level) +TextureCubeMapAttachment::TextureCubeMapAttachment(GLenum binding, TextureCubeMap *texture, GLenum faceTarget, GLint level) + : TextureAttachment(binding), + mFaceTarget(faceTarget), mLevel(level) { mTextureCubeMap.set(texture); } @@ -224,8 +232,10 @@ Texture *TextureCubeMapAttachment::getTexture() const ///// Texture3DAttachment Implementation //////// -Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer) - : mLevel(level), mLayer(layer) +Texture3DAttachment::Texture3DAttachment(GLenum binding, Texture3D *texture, GLint level, GLint layer) + : TextureAttachment(binding), + mLevel(level), + mLayer(layer) { mTexture3D.set(texture); } @@ -287,8 +297,10 @@ Texture *Texture3DAttachment::getTexture() const ////// Texture2DArrayAttachment Implementation ////// -Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer) - : mLevel(level), mLayer(layer) +Texture2DArrayAttachment::Texture2DArrayAttachment(GLenum binding, Texture2DArray *texture, GLint level, GLint layer) + : TextureAttachment(binding), + mLevel(level), + mLayer(layer) { mTexture2DArray.set(texture); } @@ -350,7 +362,8 @@ Texture *Texture2DArrayAttachment::getTexture() const ////// RenderbufferAttachment Implementation ////// -RenderbufferAttachment::RenderbufferAttachment(Renderbuffer *renderbuffer) +RenderbufferAttachment::RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer) + : FramebufferAttachment(binding) { ASSERT(renderbuffer); mRenderbuffer.set(renderbuffer); diff --git a/src/libGLESv2/FramebufferAttachment.h b/src/libGLESv2/FramebufferAttachment.h index 12eae077..2244bf44 100644 --- a/src/libGLESv2/FramebufferAttachment.h +++ b/src/libGLESv2/FramebufferAttachment.h @@ -40,7 +40,7 @@ class Renderbuffer; class FramebufferAttachment { public: - FramebufferAttachment(); + explicit FramebufferAttachment(GLenum binding); virtual ~FramebufferAttachment(); // Helper methods @@ -57,6 +57,8 @@ class FramebufferAttachment bool isTextureWithId(GLuint textureId) const { return isTexture() && id() == textureId; } bool isRenderbufferWithId(GLuint renderbufferId) const { return !isTexture() && id() == renderbufferId; } + GLenum getBinding() const { return mBinding; } + // Child class interface virtual rx::RenderTarget *getRenderTarget() = 0; virtual rx::TextureStorage *getTextureStorage() = 0; @@ -77,12 +79,14 @@ class FramebufferAttachment private: DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment); + + GLenum mBinding; }; class TextureAttachment : public FramebufferAttachment { public: - TextureAttachment() {} + TextureAttachment(GLenum binding); rx::TextureStorage *getTextureStorage(); virtual GLsizei getSamples() const; @@ -99,7 +103,7 @@ class TextureAttachment : public FramebufferAttachment class Texture2DAttachment : public TextureAttachment { public: - Texture2DAttachment(Texture2D *texture, GLint level); + Texture2DAttachment(GLenum binding, Texture2D *texture, GLint level); virtual ~Texture2DAttachment(); @@ -127,7 +131,7 @@ class Texture2DAttachment : public TextureAttachment class TextureCubeMapAttachment : public TextureAttachment { public: - TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level); + TextureCubeMapAttachment(GLenum binding, TextureCubeMap *texture, GLenum faceTarget, GLint level); virtual ~TextureCubeMapAttachment(); @@ -156,7 +160,7 @@ class TextureCubeMapAttachment : public TextureAttachment class Texture3DAttachment : public TextureAttachment { public: - Texture3DAttachment(Texture3D *texture, GLint level, GLint layer); + Texture3DAttachment(GLenum binding, Texture3D *texture, GLint level, GLint layer); virtual ~Texture3DAttachment(); @@ -185,7 +189,7 @@ class Texture3DAttachment : public TextureAttachment class Texture2DArrayAttachment : public TextureAttachment { public: - Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer); + Texture2DArrayAttachment(GLenum binding, Texture2DArray *texture, GLint level, GLint layer); virtual ~Texture2DArrayAttachment(); @@ -214,7 +218,7 @@ class Texture2DArrayAttachment : public TextureAttachment class RenderbufferAttachment : public FramebufferAttachment { public: - RenderbufferAttachment(Renderbuffer *renderbuffer); + RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer); virtual ~RenderbufferAttachment(); diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp index b962ca9a..652b7d63 100644 --- a/src/libGLESv2/ProgramBinary.cpp +++ b/src/libGLESv2/ProgramBinary.cpp @@ -10,6 +10,7 @@ #include "libGLESv2/BinaryStream.h" #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/Framebuffer.h" +#include "libGLESv2/FramebufferAttachment.h" #include "libGLESv2/Renderbuffer.h" #include "libGLESv2/renderer/ShaderExecutable.h" @@ -235,17 +236,21 @@ unsigned int ProgramBinary::issueSerial() rx::ShaderExecutable *ProgramBinary::getPixelExecutableForFramebuffer(const Framebuffer *fbo) { - std::vector<GLenum> outputs(IMPLEMENTATION_MAX_DRAW_BUFFERS); - for (size_t outputIndex = 0; outputIndex < IMPLEMENTATION_MAX_DRAW_BUFFERS; outputIndex++) + std::vector<GLenum> outputs; + + const gl::ColorbufferInfo &colorbuffers = fbo->getColorbuffersForRender(); + + for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment) { - if (fbo->getColorbuffer(outputIndex) != NULL) + const gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment]; + + if (colorbuffer) { - // Always output floats for now - outputs[outputIndex] = GL_FLOAT; + outputs.push_back(colorbuffer->getBinding() == GL_BACK ? GL_COLOR_ATTACHMENT0 : colorbuffer->getBinding()); } else { - outputs[outputIndex] = GL_NONE; + outputs.push_back(GL_NONE); } } @@ -1702,7 +1707,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin std::vector<GLenum> defaultPixelOutput(IMPLEMENTATION_MAX_DRAW_BUFFERS); for (size_t i = 0; i < defaultPixelOutput.size(); i++) { - defaultPixelOutput[i] = (i == 0) ? GL_FLOAT : GL_NONE; + defaultPixelOutput[i] = (i == 0) ? GL_COLOR_ATTACHMENT0 : GL_NONE; } rx::ShaderExecutable *defaultPixelExecutable = getPixelExecutableForOutputLayout(defaultPixelOutput); diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp index 7b0e14b7..7450fc03 100644 --- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp +++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp @@ -1111,7 +1111,7 @@ gl::FramebufferAttachment *Renderer9::getNullColorbuffer(gl::FramebufferAttachme } gl::Renderbuffer *nullRenderbuffer = new gl::Renderbuffer(0, new gl::Colorbuffer(this, width, height, GL_NONE, 0)); - gl::RenderbufferAttachment *nullbuffer = new gl::RenderbufferAttachment(nullRenderbuffer); + gl::RenderbufferAttachment *nullbuffer = new gl::RenderbufferAttachment(GL_NONE, nullRenderbuffer); // add nullbuffer to the cache NullColorbufferCacheEntry *oldest = &mNullColorbufferCache[0]; |