gl::Error TextureStorage9_2D::getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT)
{
    ASSERT(index.mipIndex < getLevelCount());

    if (!mRenderTargets[index.mipIndex] && isRenderTarget())
    {
        IDirect3DBaseTexture9 *baseTexture = NULL;
        gl::Error error = getBaseTexture(&baseTexture);
        if (error.isError())
        {
            return error;
        }

        IDirect3DSurface9 *surface = NULL;
        error = getSurfaceLevel(GL_TEXTURE_2D, index.mipIndex, false, &surface);
        if (error.isError())
        {
            return error;
        }

        size_t textureMipLevel = mTopLevel + index.mipIndex;
        size_t mipWidth        = std::max<size_t>(mTextureWidth >> textureMipLevel, 1u);
        size_t mipHeight       = std::max<size_t>(mTextureHeight >> textureMipLevel, 1u);

        baseTexture->AddRef();
        mRenderTargets[index.mipIndex] = new TextureRenderTarget9(
            baseTexture, textureMipLevel, surface, mInternalFormat, static_cast<GLsizei>(mipWidth),
            static_cast<GLsizei>(mipHeight), 1, 0);
    }
Example #2
0
angle::Result TextureStorage9_2D::getRenderTarget(const gl::Context *context,
                                                  const gl::ImageIndex &index,
                                                  RenderTargetD3D **outRT)
{
    ASSERT(index.getLevelIndex() < getLevelCount());

    if (!mRenderTargets[index.getLevelIndex()] && isRenderTarget())
    {
        IDirect3DBaseTexture9 *baseTexture = nullptr;
        ANGLE_TRY(getBaseTexture(context, &baseTexture));

        IDirect3DSurface9 *surface = nullptr;
        ANGLE_TRY(getSurfaceLevel(context, gl::TextureTarget::_2D, index.getLevelIndex(), false,
                                  &surface));

        size_t textureMipLevel = mTopLevel + index.getLevelIndex();
        size_t mipWidth        = std::max<size_t>(mTextureWidth >> textureMipLevel, 1u);
        size_t mipHeight       = std::max<size_t>(mTextureHeight >> textureMipLevel, 1u);

        baseTexture->AddRef();
        mRenderTargets[index.getLevelIndex()] = new TextureRenderTarget9(
            baseTexture, textureMipLevel, surface, mInternalFormat, static_cast<GLsizei>(mipWidth),
            static_cast<GLsizei>(mipHeight), 1, 0);
    }