Image9 and Image11 determine the d3d formats through the new helper methods.

TRAC #22972 Signed-off-by: Jamie Madill Signed-off-by: Nicolas Capens Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2320 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent cead8ad7
......@@ -22,6 +22,7 @@ Image::Image()
mInternalFormat = GL_NONE;
mActualFormat = GL_NONE;
mTarget = GL_NONE;
mRenderable = false;
}
}
......@@ -38,6 +38,7 @@ class Image
GLenum getInternalFormat() const { return mInternalFormat; }
GLenum getActualFormat() const { return mActualFormat; }
GLenum getTarget() const { return mTarget; }
bool isRenderableFormat() const { return mRenderable; }
void markDirty() {mDirty = true;}
void markClean() {mDirty = false;}
......@@ -54,8 +55,6 @@ class Image
virtual bool redefine(Renderer *renderer, GLenum target, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0;
virtual bool isRenderableFormat() const = 0;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input) = 0;
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
......@@ -69,6 +68,7 @@ class Image
GLsizei mDepth;
GLint mInternalFormat;
GLenum mActualFormat;
bool mRenderable;
GLenum mTarget;
bool mDirty;
......
......@@ -119,15 +119,18 @@ bool Image11::redefine(Renderer *renderer, GLenum target, GLint internalformat,
forceRelease)
{
mRenderer = Renderer11::makeRenderer11(renderer);
GLuint clientVersion = mRenderer->getCurrentClientVersion();
mWidth = width;
mHeight = height;
mDepth = depth;
mInternalFormat = internalformat;
mTarget = target;
// compute the d3d format that will be used
mDXGIFormat = gl_d3d11::ConvertTextureFormat(internalformat);
mActualFormat = d3d11_gl::ConvertTextureInternalFormat(mDXGIFormat);
mDXGIFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
mActualFormat = d3d11_gl::GetInternalFormat(mDXGIFormat);
mRenderable = gl_d3d11::GetTexFormat(internalformat, clientVersion) != DXGI_FORMAT_UNKNOWN;
if (mStagingTexture)
{
......@@ -141,11 +144,6 @@ bool Image11::redefine(Renderer *renderer, GLenum target, GLint internalformat,
return false;
}
bool Image11::isRenderableFormat() const
{
return TextureStorage11::IsTextureFormatRenderable(mDXGIFormat);
}
DXGI_FORMAT Image11::getDXGIFormat() const
{
// this should only happen if the image hasn't been redefined first
......@@ -288,11 +286,12 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y
HRESULT result = map(D3D11_MAP_WRITE, &mappedImage);
// determine the offset coordinate into the destination buffer
GLsizei rowOffset = gl::ComputePixelSize(mActualFormat) * xoffset;
GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei rowOffset = gl::GetPixelBytes(mActualFormat, clientVersion) * xoffset;
void *dataOffset = static_cast<unsigned char*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
mRenderer->readPixels(source, x, y, width, height, gl::ExtractFormat(mInternalFormat),
gl::ExtractType(mInternalFormat), mappedImage.RowPitch, false, 4, dataOffset);
mRenderer->readPixels(source, x, y, width, height, gl::GetFormat(mInternalFormat, clientVersion),
gl::GetType(mInternalFormat, clientVersion), mappedImage.RowPitch, false, 4, dataOffset);
unmap();
}
......@@ -320,7 +319,6 @@ void Image11::createStagingTexture()
}
const DXGI_FORMAT dxgiFormat = getDXGIFormat();
ASSERT(!d3d11::IsDepthStencilFormat(dxgiFormat)); // We should never get here for depth textures
if (mWidth > 0 && mHeight > 0 && mDepth > 0)
{
......@@ -331,7 +329,7 @@ void Image11::createStagingTexture()
GLsizei height = mHeight;
// adjust size if needed for compressed textures
gl::MakeValidSize(false, d3d11::IsCompressed(dxgiFormat), &width, &height, &lodOffset);
d3d11::MakeValidSize(false, dxgiFormat, &width, &height, &lodOffset);
if (mTarget == GL_TEXTURE_3D)
{
......
......@@ -45,7 +45,6 @@ class Image11 : public Image
virtual bool redefine(Renderer *renderer, GLenum target, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
virtual bool isRenderableFormat() const;
DXGI_FORMAT getDXGIFormat() const;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
......
......@@ -109,8 +109,10 @@ void Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *so
D3DSURFACE_DESC desc;
source->GetDesc(&desc);
int rows = d3d9::IsCompressedFormat(desc.Format) ? desc.Height / 4 : desc.Height;
int bytes = d3d9::ComputeRowSize(desc.Format, desc.Width);
int blockHeight = d3d9::GetBlockHeight(desc.Format);
int rows = desc.Height / blockHeight;
int bytes = d3d9::GetBlockSize(desc.Format, desc.Width, blockHeight);
ASSERT(bytes <= sourceLock.Pitch && bytes <= destLock.Pitch);
for(int i = 0; i < rows; i++)
......@@ -139,14 +141,17 @@ bool Image9::redefine(rx::Renderer *renderer, GLenum target, GLint internalforma
forceRelease)
{
mRenderer = Renderer9::makeRenderer9(renderer);
GLuint clientVersion = mRenderer->getCurrentClientVersion();
mWidth = width;
mHeight = height;
mDepth = depth;
mInternalFormat = internalformat;
// compute the d3d format that will be used
mD3DFormat = mRenderer->ConvertTextureInternalFormat(internalformat);
mActualFormat = d3d9_gl::GetEquivalentFormat(mD3DFormat);
mD3DFormat = gl_d3d9::GetTexureFormat(internalformat, mRenderer);
mActualFormat = d3d9_gl::GetInternalFormat(mD3DFormat);
mRenderable = gl_d3d9::GetRenderFormat(internalformat, mRenderer) != D3DFMT_UNKNOWN;
if (mSurface)
{
......@@ -171,14 +176,13 @@ void Image9::createSurface()
IDirect3DSurface9 *newSurface = NULL;
const D3DPOOL poolToUse = D3DPOOL_SYSTEMMEM;
const D3DFORMAT d3dFormat = getD3DFormat();
ASSERT(d3dFormat != D3DFMT_INTZ); // We should never get here for depth textures
if (mWidth != 0 && mHeight != 0)
{
int levelToFetch = 0;
GLsizei requestWidth = mWidth;
GLsizei requestHeight = mHeight;
gl::MakeValidSize(true, gl::IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch);
d3d9::MakeValidSize(true, d3dFormat, &requestWidth, &requestHeight, &levelToFetch);
IDirect3DDevice9 *device = mRenderer->getDevice();
......@@ -227,11 +231,6 @@ void Image9::unlock()
}
}
bool Image9::isRenderableFormat() const
{
return TextureStorage9::IsTextureFormatRenderable(getD3DFormat());
}
D3DFORMAT Image9::getD3DFormat() const
{
// this should only happen if the image hasn't been redefined first
......
......@@ -39,7 +39,6 @@ class Image9 : public Image
virtual bool redefine(Renderer *renderer, GLenum target, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
virtual bool isRenderableFormat() const;
D3DFORMAT getD3DFormat() const;
virtual bool isDirty() const {return mSurface && mDirty;}
......
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