Move Context draw call logic into RendererD3D.

Also move a lot of supporting code.

BUG=angle:789

Change-Id: I098bf7d072ece1f414605783c32ec5354ba63e19
Reviewed-on: https://chromium-review.googlesource.com/226061
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 558d3ce..8ada58c 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -35,7 +35,6 @@
 #include <iterator>
 
 // TODO(jmadill): phase these out
-#include "libGLESv2/renderer/d3d/IndexDataManager.h"
 #include "libGLESv2/renderer/d3d/RendererD3D.h"
 
 namespace gl
@@ -1301,324 +1300,6 @@
     return false;
 }
 
-// Applies the render target surface, depth stencil surface, viewport rectangle and
-// scissor rectangle to the renderer
-Error Context::applyRenderTarget(GLenum drawMode, bool ignoreViewport)
-{
-    Framebuffer *framebufferObject = mState.getDrawFramebuffer();
-    ASSERT(framebufferObject && framebufferObject->completeness(getData()) == GL_FRAMEBUFFER_COMPLETE);
-
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    gl::Error error = rendererD3D->applyRenderTarget(framebufferObject);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    float nearZ, farZ;
-    mState.getDepthRange(&nearZ, &farZ);
-    rendererD3D->setViewport(mState.getViewport(), nearZ, farZ, drawMode,
-                             mState.getRasterizerState().frontFace, ignoreViewport);
-
-    rendererD3D->setScissorRectangle(mState.getScissor(), mState.isScissorTestEnabled());
-
-    return gl::Error(GL_NO_ERROR);
-}
-
-// Applies the fixed-function state (culling, depth test, alpha blending, stenciling, etc) to the Direct3D 9 device
-Error Context::applyState(GLenum drawMode)
-{
-    Framebuffer *framebufferObject = mState.getDrawFramebuffer();
-    int samples = framebufferObject->getSamples(getData());
-
-    RasterizerState rasterizer = mState.getRasterizerState();
-    rasterizer.pointDrawMode = (drawMode == GL_POINTS);
-    rasterizer.multiSample = (samples != 0);
-
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    Error error = rendererD3D->setRasterizerState(rasterizer);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    unsigned int mask = 0;
-    if (mState.isSampleCoverageEnabled())
-    {
-        GLclampf coverageValue;
-        bool coverageInvert = false;
-        mState.getSampleCoverageParams(&coverageValue, &coverageInvert);
-        if (coverageValue != 0)
-        {
-            float threshold = 0.5f;
-
-            for (int i = 0; i < samples; ++i)
-            {
-                mask <<= 1;
-
-                if ((i + 1) * coverageValue >= threshold)
-                {
-                    threshold += 1.0f;
-                    mask |= 1;
-                }
-            }
-        }
-
-        if (coverageInvert)
-        {
-            mask = ~mask;
-        }
-    }
-    else
-    {
-        mask = 0xFFFFFFFF;
-    }
-    error = rendererD3D->setBlendState(framebufferObject, mState.getBlendState(), mState.getBlendColor(), mask);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = rendererD3D->setDepthStencilState(mState.getDepthStencilState(), mState.getStencilRef(),
-                                              mState.getStencilBackRef(), rasterizer.frontFace == GL_CCW);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    return Error(GL_NO_ERROR);
-}
-
-// Applies the shaders and shader constants to the Direct3D 9 device
-Error Context::applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive)
-{
-    VertexFormat inputLayout[MAX_VERTEX_ATTRIBS];
-    VertexFormat::GetInputLayout(inputLayout, programBinary, mState);
-
-    const Framebuffer *fbo = mState.getDrawFramebuffer();
-
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    Error error = rendererD3D->applyShaders(programBinary, inputLayout, fbo,
-                                            mState.getRasterizerState().rasterizerDiscard,
-                                            transformFeedbackActive);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    return programBinary->applyUniforms();
-}
-
-Error Context::generateSwizzles(ProgramBinary *programBinary, SamplerType type)
-{
-    size_t samplerRange = programBinary->getUsedSamplerRange(type);
-
-    for (size_t i = 0; i < samplerRange; i++)
-    {
-        GLenum textureType = programBinary->getSamplerTextureType(type, i);
-        GLint textureUnit = programBinary->getSamplerMapping(type, i, getCaps());
-        if (textureUnit != -1)
-        {
-            Texture *texture = getSamplerTexture(textureUnit, textureType);
-            ASSERT(texture);
-            if (texture->getSamplerState().swizzleRequired())
-            {
-                //TODO(jmadill): MANGLE refactor
-                rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-                Error error = rendererD3D->generateSwizzle(texture);
-                if (error.isError())
-                {
-                    return error;
-                }
-            }
-        }
-    }
-
-    return Error(GL_NO_ERROR);
-}
-
-Error Context::generateSwizzles(ProgramBinary *programBinary)
-{
-    Error error = generateSwizzles(programBinary, SAMPLER_VERTEX);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = generateSwizzles(programBinary, SAMPLER_PIXEL);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    return Error(GL_NO_ERROR);
-}
-
-// For each Direct3D sampler of either the pixel or vertex stage,
-// looks up the corresponding OpenGL texture image unit and texture type,
-// and sets the texture and its addressing/filtering state (or NULL when inactive).
-Error Context::applyTextures(ProgramBinary *programBinary, SamplerType shaderType,
-                             const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount)
-{
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    size_t samplerRange = programBinary->getUsedSamplerRange(shaderType);
-    for (size_t samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
-    {
-        GLenum textureType = programBinary->getSamplerTextureType(shaderType, samplerIndex);
-        GLint textureUnit = programBinary->getSamplerMapping(shaderType, samplerIndex, getCaps());
-        if (textureUnit != -1)
-        {
-            Texture *texture = getSamplerTexture(textureUnit, textureType);
-            ASSERT(texture);
-            SamplerState sampler = texture->getSamplerState();
-
-            Sampler *samplerObject = mState.getSampler(textureUnit);
-            if (samplerObject)
-            {
-                samplerObject->getState(&sampler);
-            }
-
-            // TODO: std::binary_search may become unavailable using older versions of GCC
-            if (texture->isSamplerComplete(sampler, mTextureCaps, mExtensions, mClientVersion) &&
-                !std::binary_search(framebufferSerials.begin(), framebufferSerials.begin() + framebufferSerialCount, texture->getTextureSerial()))
-            {
-                Error error = rendererD3D->setSamplerState(shaderType, samplerIndex, texture, sampler);
-                if (error.isError())
-                {
-                    return error;
-                }
-
-                error = rendererD3D->setTexture(shaderType, samplerIndex, texture);
-                if (error.isError())
-                {
-                    return error;
-                }
-            }
-            else
-            {
-                // Texture is not sampler complete or it is in use by the framebuffer.  Bind the incomplete texture.
-                Texture *incompleteTexture = getIncompleteTexture(textureType);
-                gl::Error error = rendererD3D->setTexture(shaderType, samplerIndex, incompleteTexture);
-                if (error.isError())
-                {
-                    return error;
-                }
-            }
-        }
-        else
-        {
-            // No texture bound to this slot even though it is used by the shader, bind a NULL texture
-            Error error = rendererD3D->setTexture(shaderType, samplerIndex, NULL);
-            if (error.isError())
-            {
-                return error;
-            }
-        }
-    }
-
-    // Set all the remaining textures to NULL
-    size_t samplerCount = (shaderType == SAMPLER_PIXEL) ? mCaps.maxTextureImageUnits
-                                                        : mCaps.maxVertexTextureImageUnits;
-    for (size_t samplerIndex = samplerRange; samplerIndex < samplerCount; samplerIndex++)
-    {
-        //TODO(jmadill): MANGLE refactor
-        rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-        Error error = rendererD3D->setTexture(shaderType, samplerIndex, NULL);
-        if (error.isError())
-        {
-            return error;
-        }
-    }
-
-    return Error(GL_NO_ERROR);
-}
-
-Error Context::applyTextures(ProgramBinary *programBinary)
-{
-    FramebufferTextureSerialArray framebufferSerials;
-    size_t framebufferSerialCount = getBoundFramebufferTextureSerials(&framebufferSerials);
-
-    Error error = applyTextures(programBinary, SAMPLER_VERTEX, framebufferSerials, framebufferSerialCount);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyTextures(programBinary, SAMPLER_PIXEL, framebufferSerials, framebufferSerialCount);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    return Error(GL_NO_ERROR);
-}
-
-Error Context::applyUniformBuffers()
-{
-    Program *programObject = getProgram(mState.getCurrentProgramId());
-    ProgramBinary *programBinary = programObject->getProgramBinary();
-
-    std::vector<Buffer*> boundBuffers;
-
-    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < programBinary->getActiveUniformBlockCount(); uniformBlockIndex++)
-    {
-        GLuint blockBinding = programObject->getUniformBlockBinding(uniformBlockIndex);
-
-        if (mState.getIndexedUniformBuffer(blockBinding)->id() == 0)
-        {
-            // undefined behaviour
-            return gl::Error(GL_INVALID_OPERATION, "It is undefined behaviour to have a used but unbound uniform buffer.");
-        }
-        else
-        {
-            Buffer *uniformBuffer = mState.getIndexedUniformBuffer(blockBinding);
-            ASSERT(uniformBuffer);
-            boundBuffers.push_back(uniformBuffer);
-        }
-    }
-
-    return programBinary->applyUniformBuffers(boundBuffers, getCaps());
-}
-
-bool Context::applyTransformFeedbackBuffers()
-{
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    TransformFeedback *curTransformFeedback = mState.getCurrentTransformFeedback();
-    if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
-    {
-        rendererD3D->applyTransformFeedbackBuffers(mState);
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-void Context::markTransformFeedbackUsage()
-{
-    for (size_t i = 0; i < mCaps.maxTransformFeedbackSeparateAttributes; i++)
-    {
-        Buffer *buffer = mState.getIndexedTransformFeedbackBuffer(i);
-        if (buffer)
-        {
-            buffer->markTransformFeedbackUsage();
-        }
-    }
-}
-
 Error Context::clear(GLbitfield mask)
 {
     if (mState.isRasterizerDiscardEnabled())
@@ -1628,7 +1309,11 @@
 
     ClearParameters clearParams = mState.getClearParameters(mask);
 
-    Error error = applyRenderTarget(GL_TRIANGLES, true);   // Clips the clear to the scissor rectangle but not the viewport
+    //TODO(jmadill): Renderer refactor
+    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
+
+    // Clips the clear to the scissor rectangle but not the viewport
+    Error error = rendererD3D->applyRenderTarget(getData(), GL_TRIANGLES, true);
     if (error.isError())
     {
         return error;
@@ -1663,7 +1348,11 @@
         clearParams.depthClearValue = values[0];
     }
 
-    Error error = applyRenderTarget(GL_TRIANGLES, true);   // Clips the clear to the scissor rectangle but not the viewport
+    //TODO(jmadill): Renderer refactor
+    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
+
+    // Clips the clear to the scissor rectangle but not the viewport
+    Error error = rendererD3D->applyRenderTarget(getData(), GL_TRIANGLES, true);
     if (error.isError())
     {
         return error;
@@ -1688,7 +1377,11 @@
     clearParams.colorUIClearValue = ColorUI(values[0], values[1], values[2], values[3]);
     clearParams.colorClearType = GL_UNSIGNED_INT;
 
-    Error error = applyRenderTarget(GL_TRIANGLES, true);   // Clips the clear to the scissor rectangle but not the viewport
+    //TODO(jmadill): Renderer refactor
+    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
+
+    // Clips the clear to the scissor rectangle but not the viewport
+    Error error = rendererD3D->applyRenderTarget(getData(), GL_TRIANGLES, true);
     if (error.isError())
     {
         return error;
@@ -1723,7 +1416,11 @@
         clearParams.stencilClearValue = values[1];
     }
 
-    Error error = applyRenderTarget(GL_TRIANGLES, true);   // Clips the clear to the scissor rectangle but not the viewport
+    //TODO(jmadill): Renderer refactor
+    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
+
+    // Clips the clear to the scissor rectangle but not the viewport
+    Error error = rendererD3D->applyRenderTarget(getData(), GL_TRIANGLES, true);
     if (error.isError())
     {
         return error;
@@ -1746,7 +1443,11 @@
     clearParams.clearStencil = true;
     clearParams.stencilClearValue = stencil;
 
-    Error error = applyRenderTarget(GL_TRIANGLES, true);   // Clips the clear to the scissor rectangle but not the viewport
+    //TODO(jmadill): Renderer refactor
+    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
+
+    // Clips the clear to the scissor rectangle but not the viewport
+    Error error = rendererD3D->applyRenderTarget(getData(), GL_TRIANGLES, true);
     if (error.isError())
     {
         return error;
@@ -1770,164 +1471,14 @@
 
 Error Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
 {
-    ASSERT(mState.getCurrentProgramId() != 0);
-
-    ProgramBinary *programBinary = mState.getCurrentProgramBinary();
-    programBinary->updateSamplerMapping();
-
-    Error error = generateSwizzles(programBinary);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    if (!rendererD3D->applyPrimitiveType(mode, count))
-    {
-        return Error(GL_NO_ERROR);
-    }
-
-    error = applyRenderTarget(mode, false);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyState(mode);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = rendererD3D->applyVertexBuffer(mState, first, count, instances);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    bool transformFeedbackActive = applyTransformFeedbackBuffers();
-
-    error = applyShaders(programBinary, transformFeedbackActive);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyTextures(programBinary);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyUniformBuffers();
-    if (error.isError())
-    {
-        return error;
-    }
-
-    if (!skipDraw(mode))
-    {
-        error = mRenderer->drawArrays(mode, count, instances, transformFeedbackActive);
-        if (error.isError())
-        {
-            return error;
-        }
-
-        if (transformFeedbackActive)
-        {
-            markTransformFeedbackUsage();
-        }
-    }
-
-    return gl::Error(GL_NO_ERROR);
+    return mRenderer->drawArrays(getData(), mode, first, count, instances);
 }
 
 Error Context::drawElements(GLenum mode, GLsizei count, GLenum type,
                             const GLvoid *indices, GLsizei instances,
                             const rx::RangeUI &indexRange)
 {
-    ASSERT(mState.getCurrentProgramId() != 0);
-
-    ProgramBinary *programBinary = mState.getCurrentProgramBinary();
-    programBinary->updateSamplerMapping();
-
-    Error error = generateSwizzles(programBinary);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    //TODO(jmadill): MANGLE refactor
-    rx::RendererD3D *rendererD3D = rx::RendererD3D::makeRendererD3D(mRenderer);
-
-    if (!rendererD3D->applyPrimitiveType(mode, count))
-    {
-        return Error(GL_NO_ERROR);
-    }
-
-    error = applyRenderTarget(mode, false);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyState(mode);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    VertexArray *vao = mState.getVertexArray();
-    rx::TranslatedIndexData indexInfo;
-    indexInfo.indexRange = indexRange;
-    error = rendererD3D->applyIndexBuffer(indices, vao->getElementArrayBuffer(), count, mode, type, &indexInfo);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    GLsizei vertexCount = indexInfo.indexRange.length() + 1;
-    error = rendererD3D->applyVertexBuffer(mState, indexInfo.indexRange.start, vertexCount, instances);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    bool transformFeedbackActive = applyTransformFeedbackBuffers();
-    // Transform feedback is not allowed for DrawElements, this error should have been caught at the API validation
-    // layer.
-    ASSERT(!transformFeedbackActive);
-
-    error = applyShaders(programBinary, transformFeedbackActive);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyTextures(programBinary);
-    if (error.isError())
-    {
-        return error;
-    }
-
-    error = applyUniformBuffers();
-    if (error.isError())
-    {
-        return error;
-    }
-
-    if (!skipDraw(mode))
-    {
-        error = mRenderer->drawElements(mode, count, type, indices, vao->getElementArrayBuffer(), indexInfo, instances);
-        if (error.isError())
-        {
-            return error;
-        }
-    }
-
-    return Error(GL_NO_ERROR);
+    return mRenderer->drawElements(getData(), mode, count, type, indices, instances, indexRange);
 }
 
 // Implements glFlush when block is false, glFinish when block is true
@@ -2104,95 +1655,6 @@
     mState.detachSampler(sampler);
 }
 
-Texture *Context::getIncompleteTexture(GLenum type)
-{
-    if (mIncompleteTextures.find(type) == mIncompleteTextures.end())
-    {
-        const GLubyte color[] = { 0, 0, 0, 255 };
-        const PixelUnpackState incompleteUnpackState(1);
-
-        Texture* t = NULL;
-        switch (type)
-        {
-          default:
-            UNREACHABLE();
-            // default falls through to TEXTURE_2D
-
-          case GL_TEXTURE_2D:
-            {
-                Texture2D *incomplete2d = new Texture2D(mRenderer->createTexture(GL_TEXTURE_2D), Texture::INCOMPLETE_TEXTURE_ID);
-                incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-                t = incomplete2d;
-            }
-            break;
-
-          case GL_TEXTURE_CUBE_MAP:
-            {
-              TextureCubeMap *incompleteCube = new TextureCubeMap(mRenderer->createTexture(GL_TEXTURE_CUBE_MAP), Texture::INCOMPLETE_TEXTURE_ID);
-
-              incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-              incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-              incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-              incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-              incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-              incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-
-              t = incompleteCube;
-            }
-            break;
-
-          case GL_TEXTURE_3D:
-            {
-                Texture3D *incomplete3d = new Texture3D(mRenderer->createTexture(GL_TEXTURE_3D), Texture::INCOMPLETE_TEXTURE_ID);
-                incomplete3d->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-
-                t = incomplete3d;
-            }
-            break;
-
-          case GL_TEXTURE_2D_ARRAY:
-            {
-                Texture2DArray *incomplete2darray = new Texture2DArray(mRenderer->createTexture(GL_TEXTURE_2D_ARRAY), Texture::INCOMPLETE_TEXTURE_ID);
-                incomplete2darray->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
-
-                t = incomplete2darray;
-            }
-            break;
-        }
-
-        mIncompleteTextures[type].set(t);
-    }
-
-    return mIncompleteTextures[type].get();
-}
-
-bool Context::skipDraw(GLenum drawMode)
-{
-    if (drawMode == GL_POINTS)
-    {
-        // ProgramBinary assumes non-point rendering if gl_PointSize isn't written,
-        // which affects varying interpolation. Since the value of gl_PointSize is
-        // undefined when not written, just skip drawing to avoid unexpected results.
-        if (!mState.getCurrentProgramBinary()->usesPointSize())
-        {
-            // This is stictly speaking not an error, but developers should be
-            // notified of risking undefined behavior.
-            ERR("Point rendering without writing to gl_PointSize.");
-
-            return true;
-        }
-    }
-    else if (IsTriangleMode(drawMode))
-    {
-        if (mState.getRasterizerState().cullFace && mState.getRasterizerState().cullMode == GL_FRONT_AND_BACK)
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
 void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
 {
     mState.getVertexArray()->setVertexAttribDivisor(index, divisor);
@@ -2325,33 +1787,6 @@
     return mExtensionStrings.size();
 }
 
-size_t Context::getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray)
-{
-    size_t serialCount = 0;
-
-    Framebuffer *drawFramebuffer = mState.getDrawFramebuffer();
-    for (unsigned int i = 0; i < IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
-    {
-        FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
-        if (attachment && attachment->isTexture())
-        {
-            Texture *texture = attachment->getTexture();
-            (*outSerialArray)[serialCount++] = texture->getTextureSerial();
-        }
-    }
-
-    FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer();
-    if (depthStencilAttachment && depthStencilAttachment->isTexture())
-    {
-        Texture *depthStencilTexture = depthStencilAttachment->getTexture();
-        (*outSerialArray)[serialCount++] = depthStencilTexture->getTextureSerial();
-    }
-
-    std::sort(outSerialArray->begin(), outSerialArray->begin() + serialCount);
-
-    return serialCount;
-}
-
 Error Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
                                GLbitfield mask, GLenum filter)
 {