Commit 468b26bb by Jamie Madill

Use COM object dynamic cast for RT resource queries.

BUG=angle:729 Change-Id: I55af209211329a7a71728e3c6d55d87154cfb45e Reviewed-on: https://chromium-review.googlesource.com/221269Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 82bf0c5a
......@@ -324,8 +324,9 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse
void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source)
{
RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(source);
ASSERT(renderTarget->getTexture());
ID3D11Texture2D *colorBufferTexture = mRenderer->getRenderTargetResource(renderTarget);
ID3D11Texture2D *colorBufferTexture = d3d11::DynamicCastComObject<ID3D11Texture2D>(renderTarget->getTexture());
unsigned int subresourceIndex = renderTarget->getSubresourceIndex();
if (!colorBufferTexture)
......
......@@ -2472,7 +2472,7 @@ gl::Error Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack
return mPixelTransfer->copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, sourcePixelsType, destArea);
}
bool Renderer11::getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource)
bool Renderer11::getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndexOut, ID3D11Texture2D **texture2DOut)
{
ASSERT(colorbuffer != NULL);
......@@ -2482,39 +2482,12 @@ bool Renderer11::getRenderTargetResource(gl::FramebufferAttachment *colorbuffer,
return false;
}
*subresourceIndex = renderTarget->getSubresourceIndex();
*resource = getRenderTargetResource(renderTarget);
ID3D11Resource *renderTargetResource = renderTarget->getTexture();
return (*resource != NULL);
}
ID3D11Texture2D *Renderer11::getRenderTargetResource(RenderTarget11 *renderTarget)
{
ASSERT(renderTarget);
ID3D11RenderTargetView *colorBufferRTV = renderTarget->getRenderTargetView();
ID3D11Texture2D *texture2D = NULL;
if (colorBufferRTV)
{
ID3D11Resource *textureResource = NULL;
colorBufferRTV->GetResource(&textureResource);
if (textureResource)
{
HRESULT result = textureResource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&texture2D));
SafeRelease(textureResource);
if (FAILED(result))
{
ERR("Failed to extract the ID3D11Texture2D from the render target resource, "
"HRESULT: 0x%X.", result);
return gl::error(GL_OUT_OF_MEMORY, static_cast <ID3D11Texture2D*>(NULL));
}
}
}
*subresourceIndexOut = renderTarget->getSubresourceIndex();
*texture2DOut = d3d11::DynamicCastComObject<ID3D11Texture2D>(renderTargetResource);
return texture2D;
return (*texture2DOut != NULL);
}
gl::Error Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
......
......@@ -189,8 +189,7 @@ class Renderer11 : public Renderer
virtual gl::Error fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource);
ID3D11Texture2D *getRenderTargetResource(RenderTarget11 *renderTarget);
bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndexOut, ID3D11Texture2D **texture2DOut);
void unapplyRenderTargets();
void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment