Commit 76b258f8 by Nicolas Capens

Rename getBaseTexture to getResource, and refactor swizzleRequired.

BUG=angle:596 Change-Id: I72d8796172c5db57ddeb86bbc6c08cbb2ec125f1 Reviewed-on: https://chromium-review.googlesource.com/193230Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 948f5571
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
namespace gl namespace gl
{ {
bool SamplerState::swizzleRequired() const
{
return swizzleRed != GL_RED || swizzleGreen != GL_GREEN ||
swizzleBlue != GL_BLUE || swizzleAlpha != GL_ALPHA;
}
static void MinMax(int a, int b, int *minimum, int *maximum) static void MinMax(int a, int b, int *minimum, int *maximum)
{ {
if (a < b) if (a < b)
......
...@@ -162,6 +162,8 @@ struct SamplerState ...@@ -162,6 +162,8 @@ struct SamplerState
GLenum swizzleGreen; GLenum swizzleGreen;
GLenum swizzleBlue; GLenum swizzleBlue;
GLenum swizzleAlpha; GLenum swizzleAlpha;
bool swizzleRequired() const;
}; };
struct ClearParameters struct ClearParameters
......
...@@ -2576,7 +2576,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface2D *dest, TextureStor ...@@ -2576,7 +2576,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface2D *dest, TextureStor
TextureStorage11_2D *source11 = TextureStorage11_2D::makeTextureStorage11_2D(source->getStorageInstance()); TextureStorage11_2D *source11 = TextureStorage11_2D::makeTextureStorage11_2D(source->getStorageInstance());
TextureStorage11_2D *dest11 = TextureStorage11_2D::makeTextureStorage11_2D(dest->getStorageInstance()); TextureStorage11_2D *dest11 = TextureStorage11_2D::makeTextureStorage11_2D(dest->getStorageInstance());
mDeviceContext->CopyResource(dest11->getBaseTexture(), source11->getBaseTexture()); mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
dest11->invalidateSwizzleCache(); dest11->invalidateSwizzleCache();
...@@ -2593,7 +2593,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureSt ...@@ -2593,7 +2593,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureSt
TextureStorage11_Cube *source11 = TextureStorage11_Cube::makeTextureStorage11_Cube(source->getStorageInstance()); TextureStorage11_Cube *source11 = TextureStorage11_Cube::makeTextureStorage11_Cube(source->getStorageInstance());
TextureStorage11_Cube *dest11 = TextureStorage11_Cube::makeTextureStorage11_Cube(dest->getStorageInstance()); TextureStorage11_Cube *dest11 = TextureStorage11_Cube::makeTextureStorage11_Cube(dest->getStorageInstance());
mDeviceContext->CopyResource(dest11->getBaseTexture(), source11->getBaseTexture()); mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
dest11->invalidateSwizzleCache(); dest11->invalidateSwizzleCache();
...@@ -2610,7 +2610,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface3D *dest, TextureStor ...@@ -2610,7 +2610,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface3D *dest, TextureStor
TextureStorage11_3D *source11 = TextureStorage11_3D::makeTextureStorage11_3D(source->getStorageInstance()); TextureStorage11_3D *source11 = TextureStorage11_3D::makeTextureStorage11_3D(source->getStorageInstance());
TextureStorage11_3D *dest11 = TextureStorage11_3D::makeTextureStorage11_3D(dest->getStorageInstance()); TextureStorage11_3D *dest11 = TextureStorage11_3D::makeTextureStorage11_3D(dest->getStorageInstance());
mDeviceContext->CopyResource(dest11->getBaseTexture(), source11->getBaseTexture()); mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
dest11->invalidateSwizzleCache(); dest11->invalidateSwizzleCache();
...@@ -2627,7 +2627,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface2DArray *dest, Textur ...@@ -2627,7 +2627,7 @@ bool Renderer11::copyToRenderTarget(TextureStorageInterface2DArray *dest, Textur
TextureStorage11_2DArray *source11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(source->getStorageInstance()); TextureStorage11_2DArray *source11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(source->getStorageInstance());
TextureStorage11_2DArray *dest11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(dest->getStorageInstance()); TextureStorage11_2DArray *dest11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(dest->getStorageInstance());
mDeviceContext->CopyResource(dest11->getBaseTexture(), source11->getBaseTexture()); mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
dest11->invalidateSwizzleCache(); dest11->invalidateSwizzleCache();
......
...@@ -134,7 +134,7 @@ int TextureStorage11::getLevelDepth(int mipLevel) const ...@@ -134,7 +134,7 @@ int TextureStorage11::getLevelDepth(int mipLevel) const
UINT TextureStorage11::getSubresourceIndex(int mipLevel, int layerTarget) const UINT TextureStorage11::getSubresourceIndex(int mipLevel, int layerTarget) const
{ {
UINT index = 0; UINT index = 0;
if (getBaseTexture()) if (getResource())
{ {
index = D3D11CalcSubresource(mipLevel, layerTarget, mMipLevels); index = D3D11CalcSubresource(mipLevel, layerTarget, mMipLevels);
} }
...@@ -205,7 +205,7 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign ...@@ -205,7 +205,7 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign
copyArea.height == texSize.height && copyArea.height == texSize.height &&
copyArea.depth == texSize.depth; copyArea.depth == texSize.depth;
ID3D11Resource *dstTexture = getBaseTexture(); ID3D11Resource *dstTexture = getResource();
unsigned int dstSubresource = getSubresourceIndex(level + mTopLevel, layerTarget); unsigned int dstSubresource = getSubresourceIndex(level + mTopLevel, layerTarget);
ASSERT(dstTexture); ASSERT(dstTexture);
...@@ -410,7 +410,7 @@ TextureStorage11_2D *TextureStorage11_2D::makeTextureStorage11_2D(TextureStorage ...@@ -410,7 +410,7 @@ TextureStorage11_2D *TextureStorage11_2D::makeTextureStorage11_2D(TextureStorage
return static_cast<TextureStorage11_2D*>(storage); return static_cast<TextureStorage11_2D*>(storage);
} }
ID3D11Resource *TextureStorage11_2D::getBaseTexture() const ID3D11Resource *TextureStorage11_2D::getResource() const
{ {
return mTexture; return mTexture;
} }
...@@ -491,8 +491,7 @@ RenderTarget *TextureStorage11_2D::getRenderTarget(int level) ...@@ -491,8 +491,7 @@ RenderTarget *TextureStorage11_2D::getRenderTarget(int level)
ID3D11ShaderResourceView *TextureStorage11_2D::getSRV(const gl::SamplerState &samplerState) ID3D11ShaderResourceView *TextureStorage11_2D::getSRV(const gl::SamplerState &samplerState)
{ {
bool swizzleRequired = samplerState.swizzleRed != GL_RED || samplerState.swizzleGreen != GL_GREEN || bool swizzleRequired = samplerState.swizzleRequired();
samplerState.swizzleBlue != GL_BLUE || samplerState.swizzleAlpha != GL_ALPHA;
bool mipmapping = gl::IsMipmapFiltered(samplerState); bool mipmapping = gl::IsMipmapFiltered(samplerState);
ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping]; ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping];
...@@ -733,7 +732,7 @@ TextureStorage11_Cube *TextureStorage11_Cube::makeTextureStorage11_Cube(TextureS ...@@ -733,7 +732,7 @@ TextureStorage11_Cube *TextureStorage11_Cube::makeTextureStorage11_Cube(TextureS
return static_cast<TextureStorage11_Cube*>(storage); return static_cast<TextureStorage11_Cube*>(storage);
} }
ID3D11Resource *TextureStorage11_Cube::getBaseTexture() const ID3D11Resource *TextureStorage11_Cube::getResource() const
{ {
return mTexture; return mTexture;
} }
...@@ -832,8 +831,7 @@ RenderTarget *TextureStorage11_Cube::getRenderTargetFace(GLenum faceTarget, int ...@@ -832,8 +831,7 @@ RenderTarget *TextureStorage11_Cube::getRenderTargetFace(GLenum faceTarget, int
ID3D11ShaderResourceView *TextureStorage11_Cube::getSRV(const gl::SamplerState &samplerState) ID3D11ShaderResourceView *TextureStorage11_Cube::getSRV(const gl::SamplerState &samplerState)
{ {
bool swizzleRequired = samplerState.swizzleRed != GL_RED || samplerState.swizzleGreen != GL_GREEN || bool swizzleRequired = samplerState.swizzleRequired();
samplerState.swizzleBlue != GL_BLUE || samplerState.swizzleAlpha != GL_ALPHA;
bool mipmapping = gl::IsMipmapFiltered(samplerState); bool mipmapping = gl::IsMipmapFiltered(samplerState);
ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping]; ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping];
...@@ -1097,15 +1095,14 @@ TextureStorage11_3D *TextureStorage11_3D::makeTextureStorage11_3D(TextureStorage ...@@ -1097,15 +1095,14 @@ TextureStorage11_3D *TextureStorage11_3D::makeTextureStorage11_3D(TextureStorage
return static_cast<TextureStorage11_3D*>(storage); return static_cast<TextureStorage11_3D*>(storage);
} }
ID3D11Resource *TextureStorage11_3D::getBaseTexture() const ID3D11Resource *TextureStorage11_3D::getResource() const
{ {
return mTexture; return mTexture;
} }
ID3D11ShaderResourceView *TextureStorage11_3D::getSRV(const gl::SamplerState &samplerState) ID3D11ShaderResourceView *TextureStorage11_3D::getSRV(const gl::SamplerState &samplerState)
{ {
bool swizzleRequired = samplerState.swizzleRed != GL_RED || samplerState.swizzleGreen != GL_GREEN || bool swizzleRequired = samplerState.swizzleRequired();
samplerState.swizzleBlue != GL_BLUE || samplerState.swizzleAlpha != GL_ALPHA;
bool mipmapping = gl::IsMipmapFiltered(samplerState); bool mipmapping = gl::IsMipmapFiltered(samplerState);
ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping]; ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping];
...@@ -1456,15 +1453,14 @@ TextureStorage11_2DArray *TextureStorage11_2DArray::makeTextureStorage11_2DArray ...@@ -1456,15 +1453,14 @@ TextureStorage11_2DArray *TextureStorage11_2DArray::makeTextureStorage11_2DArray
return static_cast<TextureStorage11_2DArray*>(storage); return static_cast<TextureStorage11_2DArray*>(storage);
} }
ID3D11Resource *TextureStorage11_2DArray::getBaseTexture() const ID3D11Resource *TextureStorage11_2DArray::getResource() const
{ {
return mTexture; return mTexture;
} }
ID3D11ShaderResourceView *TextureStorage11_2DArray::getSRV(const gl::SamplerState &samplerState) ID3D11ShaderResourceView *TextureStorage11_2DArray::getSRV(const gl::SamplerState &samplerState)
{ {
bool swizzleRequired = samplerState.swizzleRed != GL_RED || samplerState.swizzleGreen != GL_GREEN || bool swizzleRequired = samplerState.swizzleRequired();
samplerState.swizzleBlue != GL_BLUE || samplerState.swizzleAlpha != GL_ALPHA;
bool mipmapping = gl::IsMipmapFiltered(samplerState); bool mipmapping = gl::IsMipmapFiltered(samplerState);
ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping]; ID3D11ShaderResourceView **resultSRV = &mSRV[swizzleRequired][mipmapping];
......
...@@ -32,7 +32,7 @@ class TextureStorage11 : public TextureStorage ...@@ -32,7 +32,7 @@ class TextureStorage11 : public TextureStorage
UINT getBindFlags() const; UINT getBindFlags() const;
virtual ID3D11Resource *getBaseTexture() const = 0; virtual ID3D11Resource *getResource() const = 0;
virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState) = 0; virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState) = 0;
virtual RenderTarget *getRenderTarget(int level) { return NULL; } virtual RenderTarget *getRenderTarget(int level) { return NULL; }
virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level) { return NULL; } virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level) { return NULL; }
...@@ -114,7 +114,7 @@ class TextureStorage11_2D : public TextureStorage11 ...@@ -114,7 +114,7 @@ class TextureStorage11_2D : public TextureStorage11
static TextureStorage11_2D *makeTextureStorage11_2D(TextureStorage *storage); static TextureStorage11_2D *makeTextureStorage11_2D(TextureStorage *storage);
virtual ID3D11Resource *getBaseTexture() const; virtual ID3D11Resource *getResource() const;
virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState); virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState);
virtual RenderTarget *getRenderTarget(int level); virtual RenderTarget *getRenderTarget(int level);
...@@ -149,7 +149,7 @@ class TextureStorage11_Cube : public TextureStorage11 ...@@ -149,7 +149,7 @@ class TextureStorage11_Cube : public TextureStorage11
static TextureStorage11_Cube *makeTextureStorage11_Cube(TextureStorage *storage); static TextureStorage11_Cube *makeTextureStorage11_Cube(TextureStorage *storage);
virtual ID3D11Resource *getBaseTexture() const; virtual ID3D11Resource *getResource() const;
virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState); virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState);
virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level); virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level);
...@@ -185,7 +185,7 @@ class TextureStorage11_3D : public TextureStorage11 ...@@ -185,7 +185,7 @@ class TextureStorage11_3D : public TextureStorage11
static TextureStorage11_3D *makeTextureStorage11_3D(TextureStorage *storage); static TextureStorage11_3D *makeTextureStorage11_3D(TextureStorage *storage);
virtual ID3D11Resource *getBaseTexture() const; virtual ID3D11Resource *getResource() const;
virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState); virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState);
virtual RenderTarget *getRenderTarget(int mipLevel); virtual RenderTarget *getRenderTarget(int mipLevel);
virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer); virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer);
...@@ -226,7 +226,7 @@ class TextureStorage11_2DArray : public TextureStorage11 ...@@ -226,7 +226,7 @@ class TextureStorage11_2DArray : public TextureStorage11
static TextureStorage11_2DArray *makeTextureStorage11_2DArray(TextureStorage *storage); static TextureStorage11_2DArray *makeTextureStorage11_2DArray(TextureStorage *storage);
virtual ID3D11Resource *getBaseTexture() const; virtual ID3D11Resource *getResource() const;
virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState); virtual ID3D11ShaderResourceView *getSRV(const gl::SamplerState &samplerState);
virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer); virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer);
......
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