Image11 now stores an ID3D11Resource for the staging texture and creates 3D…

Image11 now stores an ID3D11Resource for the staging texture and creates 3D staging textures if depth is greater than one. TRAC #22705 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2162 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2058d64a
...@@ -125,8 +125,8 @@ bool Image11::updateSurface(TextureStorageInterfaceCube *storage, int face, int ...@@ -125,8 +125,8 @@ bool Image11::updateSurface(TextureStorageInterfaceCube *storage, int face, int
bool Image11::updateSurface(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) bool Image11::updateSurface(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
{ {
UNIMPLEMENTED(); TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage->getStorageInstance());
return false; return storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, 0, xoffset, yoffset, zoffset, width, height, depth);
} }
bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
...@@ -373,7 +373,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width ...@@ -373,7 +373,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width
} }
} }
ID3D11Texture2D *Image11::getStagingTexture() ID3D11Resource *Image11::getStagingTexture()
{ {
createStagingTexture(); createStagingTexture();
...@@ -394,19 +394,49 @@ void Image11::createStagingTexture() ...@@ -394,19 +394,49 @@ void Image11::createStagingTexture()
return; return;
} }
ID3D11Texture2D *newTexture = NULL;
int lodOffset = 1; int lodOffset = 1;
const DXGI_FORMAT dxgiFormat = getDXGIFormat(); const DXGI_FORMAT dxgiFormat = getDXGIFormat();
ASSERT(!d3d11::IsDepthStencilFormat(dxgiFormat)); // We should never get here for depth textures ASSERT(!d3d11::IsDepthStencilFormat(dxgiFormat)); // We should never get here for depth textures
if (mWidth != 0 && mHeight != 0) if (mWidth > 0 && mHeight > 0 && mDepth > 0)
{ {
ID3D11Device *device = mRenderer->getDevice();
GLsizei width = mWidth; GLsizei width = mWidth;
GLsizei height = mHeight; GLsizei height = mHeight;
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
gl::MakeValidSize(false, d3d11::IsCompressed(dxgiFormat), &width, &height, &lodOffset); gl::MakeValidSize(false, d3d11::IsCompressed(dxgiFormat), &width, &height, &lodOffset);
ID3D11Device *device = mRenderer->getDevice();
if (mDepth > 1)
{
ID3D11Texture3D *newTexture = NULL;
D3D11_TEXTURE3D_DESC desc;
desc.Width = width;
desc.Height = height;
desc.Depth = mDepth;
desc.MipLevels = lodOffset + 1;
desc.Format = dxgiFormat;
desc.Usage = D3D11_USAGE_STAGING;
desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
HRESULT result = device->CreateTexture3D(&desc, NULL, &newTexture);
if (FAILED(result))
{
ASSERT(result == E_OUTOFMEMORY);
ERR("Creating image failed.");
return gl::error(GL_OUT_OF_MEMORY);
}
mStagingTexture = newTexture;
mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
}
else
{
ID3D11Texture2D *newTexture = NULL;
D3D11_TEXTURE2D_DESC desc; D3D11_TEXTURE2D_DESC desc;
desc.Width = width; desc.Width = width;
...@@ -429,10 +459,12 @@ void Image11::createStagingTexture() ...@@ -429,10 +459,12 @@ void Image11::createStagingTexture()
ERR("Creating image failed."); ERR("Creating image failed.");
return gl::error(GL_OUT_OF_MEMORY); return gl::error(GL_OUT_OF_MEMORY);
} }
}
mStagingTexture = newTexture; mStagingTexture = newTexture;
mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1); mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
}
}
mDirty = false; mDirty = false;
} }
......
...@@ -61,14 +61,14 @@ class Image11 : public Image ...@@ -61,14 +61,14 @@ class Image11 : public Image
private: private:
DISALLOW_COPY_AND_ASSIGN(Image11); DISALLOW_COPY_AND_ASSIGN(Image11);
ID3D11Texture2D *getStagingTexture(); ID3D11Resource *getStagingTexture();
unsigned int getStagingSubresource(); unsigned int getStagingSubresource();
void createStagingTexture(); void createStagingTexture();
Renderer11 *mRenderer; Renderer11 *mRenderer;
DXGI_FORMAT mDXGIFormat; DXGI_FORMAT mDXGIFormat;
ID3D11Texture2D *mStagingTexture; ID3D11Resource *mStagingTexture;
unsigned int mStagingSubresource; unsigned int mStagingSubresource;
}; };
......
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