예제 #1
0
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);
    }
예제 #2
0
// Increments refcount on surface.
// caller must Release() the returned surface
gl::Error TextureStorage9_2D::getSurfaceLevel(GLenum target,
                                              int level,
                                              bool dirty,
                                              IDirect3DSurface9 **outSurface)
{
    ASSERT(target == GL_TEXTURE_2D);
    UNUSED_ASSERTION_VARIABLE(target);

    IDirect3DBaseTexture9 *baseTexture = NULL;
    gl::Error error = getBaseTexture(&baseTexture);
    if (error.isError())
    {
        return error;
    }

    IDirect3DTexture9 *texture = static_cast<IDirect3DTexture9*>(baseTexture);

    HRESULT result = texture->GetSurfaceLevel(level + mTopLevel, outSurface);

    ASSERT(SUCCEEDED(result));
    if (FAILED(result))
    {
        return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the surface from a texture, result: 0x%X.", result);
    }

    // With managed textures the driver needs to be informed of updates to the lower mipmap levels
    if (level + mTopLevel != 0 && isManaged() && dirty)
    {
        texture->AddDirtyRect(NULL);
    }

    return gl::Error(GL_NO_ERROR);
}
예제 #3
0
// Increments refcount on surface.
// caller must Release() the returned surface
gl::Error TextureStorage9_Cube::getCubeMapSurface(GLenum faceTarget, int level, bool dirty, IDirect3DSurface9 **outSurface)
{
    IDirect3DBaseTexture9 *baseTexture = NULL;
    gl::Error error = getBaseTexture(&baseTexture);
    if (error.isError())
    {
        return error;
    }

    IDirect3DCubeTexture9 *texture = static_cast<IDirect3DCubeTexture9*>(baseTexture);

    D3DCUBEMAP_FACES face = gl_d3d9::ConvertCubeFace(faceTarget);
    HRESULT result = texture->GetCubeMapSurface(face, level + mTopLevel, outSurface);

    ASSERT(SUCCEEDED(result));
    if (FAILED(result))
    {
        return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the surface from a texture, result: 0x%X.", result);
    }

    // With managed textures the driver needs to be informed of updates to the lower mipmap levels
    if (level != 0 && isManaged() && dirty)
    {
        texture->AddDirtyRect(face, NULL);
    }

    return gl::Error(GL_NO_ERROR);
}
예제 #4
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);
    }
예제 #5
0
// Increments refcount on surface.
// caller must Release() the returned surface
angle::Result TextureStorage9_2D::getSurfaceLevel(const gl::Context *context,
                                                  gl::TextureTarget target,
                                                  int level,
                                                  bool dirty,
                                                  IDirect3DSurface9 **outSurface)
{
    ASSERT(target == gl::TextureTarget::_2D);

    IDirect3DBaseTexture9 *baseTexture = nullptr;
    ANGLE_TRY(getBaseTexture(context, &baseTexture));

    IDirect3DTexture9 *texture = static_cast<IDirect3DTexture9 *>(baseTexture);

    HRESULT result = texture->GetSurfaceLevel(level + mTopLevel, outSurface);
    ANGLE_TRY_HR(GetImplAs<Context9>(context), result, "Failed to get the surface from a texture");

    // With managed textures the driver needs to be informed of updates to the lower mipmap levels
    if (level + mTopLevel != 0 && isManaged() && dirty)
    {
        texture->AddDirtyRect(nullptr);
    }

    return angle::Result::Continue;
}
예제 #6
0
int TextureStorage9::getLevelCount() const
{
    return getBaseTexture() ? (getBaseTexture()->GetLevelCount() - getTopLevel()) : 0;
}
예제 #7
0
int TextureStorage9::levelCount()
{
    return getBaseTexture() ? getBaseTexture()->GetLevelCount() - getLodOffset() : 0;
}