Commit 7b591905 by Olli Etuaho Committed by Commit Bot

D3D11: Use blit SRV format for blits

blitSRVFormat stores the format that is used with ANGLE's internal blit shaders. By default, it is the same as the normal SRV format. For integer textures with a red channel, the RTV format is used instead. This makes it possible to change the storage format and the SRV format for the integer textures without affecting the blit format. The blitSRVFormat is used when doing blits in Blit11::copyTexture(). An exception is made for depth/stencil renderbuffer blit - in these cases it is okay to assume that the regular SRV format works for blitting. In the future the regular SRV format for integer textures will be changed to be different from their blit SRV format. TEST=angle_end2end_tests dEQP-GLES3.functional.fbo.blit.* (no regression) dEQP-GLES3.functional.texture.swizzle.* (no regression) BUG=angleproject:1244 Change-Id: Ie0e790e58ec054b64ef5983a09dbfc7754f269ca Reviewed-on: https://chromium-review.googlesource.com/327104Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 84c9f593
......@@ -208,6 +208,7 @@ void RenderTarget11::signalDirty()
TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
ID3D11Resource *resource,
ID3D11ShaderResourceView *srv,
ID3D11ShaderResourceView *blitSRV,
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
......@@ -224,7 +225,8 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
mTexture(resource),
mRenderTarget(rtv),
mDepthStencil(NULL),
mShaderResource(srv)
mShaderResource(srv),
mBlitShaderResource(blitSRV)
{
if (mTexture)
{
......@@ -241,6 +243,11 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
mShaderResource->AddRef();
}
if (mBlitShaderResource)
{
mBlitShaderResource->AddRef();
}
if (mRenderTarget && mTexture)
{
mSubresourceIndex = getRTVSubresourceIndex(mTexture, mRenderTarget);
......@@ -267,7 +274,8 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
mTexture(resource),
mRenderTarget(NULL),
mDepthStencil(dsv),
mShaderResource(srv)
mShaderResource(srv),
mBlitShaderResource(nullptr)
{
if (mTexture)
{
......@@ -297,6 +305,7 @@ TextureRenderTarget11::~TextureRenderTarget11()
SafeRelease(mRenderTarget);
SafeRelease(mDepthStencil);
SafeRelease(mShaderResource);
SafeRelease(mBlitShaderResource);
}
ID3D11Resource *TextureRenderTarget11::getTexture() const
......@@ -319,6 +328,11 @@ ID3D11ShaderResourceView *TextureRenderTarget11::getShaderResourceView() const
return mShaderResource;
}
ID3D11ShaderResourceView *TextureRenderTarget11::getBlitShaderResourceView() const
{
return mBlitShaderResource;
}
GLsizei TextureRenderTarget11::getWidth() const
{
return mWidth;
......@@ -420,6 +434,12 @@ ID3D11ShaderResourceView *SurfaceRenderTarget11::getShaderResourceView() const
: mSwapChain->getRenderTargetShaderResource());
}
ID3D11ShaderResourceView *SurfaceRenderTarget11::getBlitShaderResourceView() const
{
// The SurfaceRenderTargetView format should always be such that the normal SRV works for blits.
return getShaderResourceView();
}
unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
{
return 0;
......
......@@ -30,6 +30,7 @@ class RenderTarget11 : public RenderTargetD3D
virtual ID3D11RenderTargetView *getRenderTargetView() const = 0;
virtual ID3D11DepthStencilView *getDepthStencilView() const = 0;
virtual ID3D11ShaderResourceView *getShaderResourceView() const = 0;
virtual ID3D11ShaderResourceView *getBlitShaderResourceView() const = 0;
virtual unsigned int getSubresourceIndex() const = 0;
......@@ -51,6 +52,7 @@ class TextureRenderTarget11 : public RenderTarget11
TextureRenderTarget11(ID3D11RenderTargetView *rtv,
ID3D11Resource *resource,
ID3D11ShaderResourceView *srv,
ID3D11ShaderResourceView *blitSRV,
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
......@@ -78,6 +80,7 @@ class TextureRenderTarget11 : public RenderTarget11
ID3D11RenderTargetView *getRenderTargetView() const override;
ID3D11DepthStencilView *getDepthStencilView() const override;
ID3D11ShaderResourceView *getShaderResourceView() const override;
ID3D11ShaderResourceView *getBlitShaderResourceView() const override;
unsigned int getSubresourceIndex() const override;
......@@ -93,6 +96,10 @@ class TextureRenderTarget11 : public RenderTarget11
ID3D11RenderTargetView *mRenderTarget;
ID3D11DepthStencilView *mDepthStencil;
ID3D11ShaderResourceView *mShaderResource;
// Shader resource view to use with internal blit shaders. Not set for depth/stencil render
// targets.
ID3D11ShaderResourceView *mBlitShaderResource;
};
class SurfaceRenderTarget11 : public RenderTarget11
......@@ -111,6 +118,7 @@ class SurfaceRenderTarget11 : public RenderTarget11
ID3D11RenderTargetView *getRenderTargetView() const override;
ID3D11DepthStencilView *getDepthStencilView() const override;
ID3D11ShaderResourceView *getShaderResourceView() const override;
ID3D11ShaderResourceView *getBlitShaderResourceView() const override;
unsigned int getSubresourceIndex() const override;
......
......@@ -2823,7 +2823,7 @@ gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::
}
ASSERT(sourceRenderTarget);
ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
ID3D11ShaderResourceView *source = sourceRenderTarget->getBlitShaderResourceView();
ASSERT(source);
TextureStorage11_2D *storage11 = GetAs<TextureStorage11_2D>(storage);
......@@ -2882,7 +2882,7 @@ gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl
}
ASSERT(sourceRenderTarget);
ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
ID3D11ShaderResourceView *source = sourceRenderTarget->getBlitShaderResourceView();
ASSERT(source);
TextureStorage11_Cube *storage11 = GetAs<TextureStorage11_Cube>(storage);
......@@ -2941,7 +2941,7 @@ gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::
}
ASSERT(sourceRenderTarget);
ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
ID3D11ShaderResourceView *source = sourceRenderTarget->getBlitShaderResourceView();
ASSERT(source);
TextureStorage11_3D *storage11 = GetAs<TextureStorage11_3D>(storage);
......@@ -2993,7 +2993,7 @@ gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const
}
ASSERT(sourceRenderTarget);
ID3D11ShaderResourceView *source = sourceRenderTarget->getShaderResourceView();
ID3D11ShaderResourceView *source = sourceRenderTarget->getBlitShaderResourceView();
ASSERT(source);
TextureStorage11_2DArray *storage11 = GetAs<TextureStorage11_2DArray>(storage);
......@@ -3083,7 +3083,8 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target texture, result: 0x%X.", result);
}
ID3D11ShaderResourceView *srv = NULL;
ID3D11ShaderResourceView *srv = nullptr;
ID3D11ShaderResourceView *blitSRV = nullptr;
if (bindSRV)
{
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
......@@ -3099,6 +3100,34 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
SafeRelease(texture);
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target shader resource view, result: 0x%X.", result);
}
if (formatInfo.formatSet.blitSRVFormat != formatInfo.formatSet.srvFormat)
{
D3D11_SHADER_RESOURCE_VIEW_DESC blitSRVDesc;
blitSRVDesc.Format = formatInfo.formatSet.blitSRVFormat;
blitSRVDesc.ViewDimension = (supportedSamples == 0)
? D3D11_SRV_DIMENSION_TEXTURE2D
: D3D11_SRV_DIMENSION_TEXTURE2DMS;
blitSRVDesc.Texture2D.MostDetailedMip = 0;
blitSRVDesc.Texture2D.MipLevels = 1;
result = mDevice->CreateShaderResourceView(texture, &blitSRVDesc, &blitSRV);
if (FAILED(result))
{
ASSERT(result == E_OUTOFMEMORY);
SafeRelease(texture);
SafeRelease(srv);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create render target shader resource view for "
"blits, result: 0x%X.",
result);
}
}
else
{
blitSRV = srv;
srv->AddRef();
}
}
if (bindDSV)
......@@ -3116,6 +3145,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
ASSERT(result == E_OUTOFMEMORY);
SafeRelease(texture);
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result);
}
......@@ -3139,6 +3169,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
ASSERT(result == E_OUTOFMEMORY);
SafeRelease(texture);
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target render target view, result: 0x%X.", result);
}
......@@ -3148,9 +3179,9 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
mDeviceContext->ClearRenderTargetView(rtv, clearValues);
}
*outRT =
new TextureRenderTarget11(rtv, texture, srv, format, formatInfo.formatSet.format,
width, height, 1, supportedSamples);
*outRT = new TextureRenderTarget11(rtv, texture, srv, blitSRV, format,
formatInfo.formatSet.format, width, height, 1,
supportedSamples);
SafeRelease(rtv);
}
......@@ -3161,12 +3192,13 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
SafeRelease(texture);
SafeRelease(srv);
SafeRelease(blitSRV);
}
else
{
*outRT = new TextureRenderTarget11(static_cast<ID3D11RenderTargetView *>(nullptr), nullptr,
nullptr, format, d3d11::ANGLE_FORMAT_NONE, width, height,
1, supportedSamples);
nullptr, nullptr, format, d3d11::ANGLE_FORMAT_NONE,
width, height, 1, supportedSamples);
}
return gl::Error(GL_NO_ERROR);
......@@ -3863,7 +3895,12 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
readTexture = readRenderTarget11->getTexture();
readTexture->AddRef();
readSubresource = readRenderTarget11->getSubresourceIndex();
readSRV = readRenderTarget11->getShaderResourceView();
readSRV = readRenderTarget11->getBlitShaderResourceView();
if (readSRV == nullptr)
{
ASSERT(depthBlit || stencilBlit);
readSRV = readRenderTarget11->getShaderResourceView();
}
readSRV->AddRef();
}
......
......@@ -79,10 +79,8 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer, UINT bindFlags, UINT mi
mBindFlags(bindFlags),
mMiscFlags(miscFlags)
{
for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{
mLevelSRVs[i] = nullptr;
}
mLevelSRVs.fill(nullptr);
mLevelBlitSRVs.fill(nullptr);
}
TextureStorage11::~TextureStorage11()
......@@ -90,6 +88,7 @@ TextureStorage11::~TextureStorage11()
for (unsigned int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
{
SafeRelease(mLevelSRVs[level]);
SafeRelease(mLevelBlitSRVs[level]);
}
for (SRVCache::iterator i = mSrvCache.begin(); i != mSrvCache.end(); i++)
......@@ -279,28 +278,44 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState,
return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11::getSRVLevel(int mipLevel, ID3D11ShaderResourceView **outSRV)
gl::Error TextureStorage11::getSRVLevel(int mipLevel,
bool blitSRV,
ID3D11ShaderResourceView **outSRV)
{
ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
if (!mLevelSRVs[mipLevel])
auto &levelSRVs = (blitSRV) ? mLevelBlitSRVs : mLevelSRVs;
auto &otherLevelSRVs = (blitSRV) ? mLevelSRVs : mLevelBlitSRVs;
if (!levelSRVs[mipLevel])
{
ID3D11Resource *resource = nullptr;
gl::Error error = getResource(&resource);
if (error.isError())
// Only create a different SRV for blit if blit format is different from regular srv format
if (otherLevelSRVs[mipLevel] &&
mTextureFormatSet.srvFormat == mTextureFormatSet.blitSRVFormat)
{
return error;
levelSRVs[mipLevel] = otherLevelSRVs[mipLevel];
levelSRVs[mipLevel]->AddRef();
}
error =
createSRV(mipLevel, 1, mTextureFormatSet.srvFormat, resource, &mLevelSRVs[mipLevel]);
if (error.isError())
else
{
return error;
ID3D11Resource *resource = nullptr;
gl::Error error = getResource(&resource);
if (error.isError())
{
return error;
}
DXGI_FORMAT resourceFormat =
blitSRV ? mTextureFormatSet.blitSRVFormat : mTextureFormatSet.srvFormat;
error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]);
if (error.isError())
{
return error;
}
}
}
*outSRV = mLevelSRVs[mipLevel];
*outSRV = levelSRVs[mipLevel];
return gl::Error(GL_NO_ERROR);
}
......@@ -376,7 +391,8 @@ gl::Error TextureStorage11::generateSwizzles(GLenum swizzleRed,
{
// Need to re-render the swizzle for this level
ID3D11ShaderResourceView *sourceSRV = nullptr;
gl::Error error = getSRVLevel(level, &sourceSRV);
gl::Error error = getSRVLevel(level, true, &sourceSRV);
if (error.isError())
{
return error;
......@@ -574,7 +590,8 @@ gl::Error TextureStorage11::generateMipmap(const gl::ImageIndex &sourceIndex,
return error;
}
ID3D11ShaderResourceView *sourceSRV = GetAs<RenderTarget11>(source)->getShaderResourceView();
ID3D11ShaderResourceView *sourceSRV =
GetAs<RenderTarget11>(source)->getBlitShaderResourceView();
ID3D11RenderTargetView *destRTV = GetAs<RenderTarget11>(dest)->getRenderTargetView();
gl::Box sourceArea(0, 0, 0, source->getWidth(), source->getHeight(), source->getDepth());
......@@ -619,9 +636,10 @@ void TextureStorage11::clearSRVCache()
}
}
for (size_t level = 0; level < ArraySize(mLevelSRVs); level++)
for (size_t level = 0; level < mLevelSRVs.size(); level++)
{
SafeRelease(mLevelSRVs[level]);
SafeRelease(mLevelBlitSRVs[level]);
}
}
......@@ -1213,7 +1231,14 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
}
ID3D11ShaderResourceView *srv = nullptr;
error = getSRVLevel(level, &srv);
error = getSRVLevel(level, false, &srv);
if (error.isError())
{
return error;
}
ID3D11ShaderResourceView *blitSRV = nullptr;
error = getSRVLevel(level, true, &blitSRV);
if (error.isError())
{
return error;
......@@ -1243,7 +1268,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
ASSERT(SUCCEEDED(result));
mLevelZeroRenderTarget = new TextureRenderTarget11(
rtv, mLevelZeroTexture, nullptr, mInternalFormat, mTextureFormatSet.format,
rtv, mLevelZeroTexture, nullptr, nullptr, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources
......@@ -1273,9 +1298,9 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
result);
}
mRenderTarget[level] =
new TextureRenderTarget11(rtv, texture, srv, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(level), getLevelHeight(level), 1, 0);
mRenderTarget[level] = new TextureRenderTarget11(
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources
SafeRelease(rtv);
......@@ -2168,6 +2193,42 @@ gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels)
return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_Cube::createRenderTargetSRV(ID3D11Resource *texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
ID3D11ShaderResourceView **srv) const
{
ID3D11Device *device = mRenderer->getDevice();
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = resourceFormat;
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + index.mipIndex;
srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = index.layerIndex;
srvDesc.Texture2DArray.ArraySize = 1;
if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3)
{
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
}
else
{
// Will be used with Texture2D sampler, not TextureCube
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
}
HRESULT result = device->CreateShaderResourceView(texture, &srvDesc, srv);
ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
if (FAILED(result))
{
return gl::Error(
GL_OUT_OF_MEMORY,
"Failed to create internal shader resource view for texture storage, result: 0x%X.",
result);
}
return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
RenderTargetD3D **outRT)
{
......@@ -2213,8 +2274,8 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
ASSERT(SUCCEEDED(result));
mLevelZeroRenderTarget[faceIndex] = new TextureRenderTarget11(
rtv, mLevelZeroTexture, nullptr, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(level), getLevelHeight(level), 1, 0);
rtv, mLevelZeroTexture, nullptr, nullptr, mInternalFormat,
mTextureFormatSet.format, getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources
SafeRelease(rtv);
......@@ -2225,34 +2286,27 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
return gl::Error(GL_NO_ERROR);
}
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = mTextureFormatSet.srvFormat;
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + level;
srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = faceIndex;
srvDesc.Texture2DArray.ArraySize = 1;
if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3)
ID3D11ShaderResourceView *srv = nullptr;
error = createRenderTargetSRV(texture, index, mTextureFormatSet.srvFormat, &srv);
if (error.isError())
{
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
return error;
}
else
ID3D11ShaderResourceView *blitSRV = nullptr;
if (mTextureFormatSet.blitSRVFormat != mTextureFormatSet.srvFormat)
{
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; // Will be used with
// Texture2D sampler, not
// TextureCube
error =
createRenderTargetSRV(texture, index, mTextureFormatSet.blitSRVFormat, &blitSRV);
if (error.isError())
{
SafeRelease(srv);
return error;
}
}
ID3D11ShaderResourceView *srv;
result = device->CreateShaderResourceView(texture, &srvDesc, &srv);
ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
if (FAILED(result))
else
{
return gl::Error(
GL_OUT_OF_MEMORY,
"Failed to create internal shader resource view for texture storage, result: 0x%X.",
result);
blitSRV = srv;
blitSRV->AddRef();
}
d3d11::SetDebugName(srv, "TexStorageCube.RenderTargetSRV");
......@@ -2273,6 +2327,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
if (FAILED(result))
{
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create internal render target view for texture "
"storage, result: 0x%X.",
......@@ -2282,12 +2337,13 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(rtv, "TexStorageCube.RenderTargetRTV");
mRenderTarget[faceIndex][level] = new TextureRenderTarget11(
rtv, texture, srv, mInternalFormat, mTextureFormatSet.format, getLevelWidth(level),
getLevelHeight(level), 1, 0);
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources
SafeRelease(rtv);
SafeRelease(srv);
SafeRelease(blitSRV);
}
else if (mTextureFormatSet.dsvFormat != DXGI_FORMAT_UNKNOWN)
{
......@@ -2306,6 +2362,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
if (FAILED(result))
{
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create internal depth stencil view for texture "
"storage, result: 0x%X.",
......@@ -2321,6 +2378,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
// RenderTarget will take ownership of these resources
SafeRelease(dsv);
SafeRelease(srv);
SafeRelease(blitSRV);
}
else
{
......@@ -2727,7 +2785,14 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
}
ID3D11ShaderResourceView *srv = nullptr;
error = getSRVLevel(mipLevel, &srv);
error = getSRVLevel(mipLevel, false, &srv);
if (error.isError())
{
return error;
}
ID3D11ShaderResourceView *blitSRV = nullptr;
error = getSRVLevel(mipLevel, true, &blitSRV);
if (error.isError())
{
return error;
......@@ -2749,6 +2814,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
if (FAILED(result))
{
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create internal render target view for texture "
"storage, result: 0x%X.",
......@@ -2758,7 +2824,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
d3d11::SetDebugName(rtv, "TexStorage3D.RTV");
mLevelRenderTargets[mipLevel] = new TextureRenderTarget11(
rtv, texture, srv, mInternalFormat, mTextureFormatSet.format,
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), getLevelDepth(mipLevel), 0);
// RenderTarget will take ownership of these resources
......@@ -2788,6 +2854,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
// TODO, what kind of SRV is expected here?
ID3D11ShaderResourceView *srv = nullptr;
ID3D11ShaderResourceView *blitSRV = nullptr;
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat;
......@@ -2803,6 +2870,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
if (FAILED(result))
{
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create internal render target view for texture "
"storage, result: 0x%X.",
......@@ -2813,7 +2881,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
d3d11::SetDebugName(rtv, "TexStorage3D.LayerRTV");
mLevelLayerRenderTargets[key] = new TextureRenderTarget11(
rtv, texture, srv, mInternalFormat, mTextureFormatSet.format,
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
// RenderTarget will take ownership of these resources
......@@ -3134,6 +3202,34 @@ gl::Error TextureStorage11_2DArray::createSRV(int baseLevel,
return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2DArray::createRenderTargetSRV(ID3D11Resource *texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
ID3D11ShaderResourceView **srv) const
{
ID3D11Device *device = mRenderer->getDevice();
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = resourceFormat;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + index.mipIndex;
srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = index.layerIndex;
srvDesc.Texture2DArray.ArraySize = 1;
HRESULT result = device->CreateShaderResourceView(texture, &srvDesc, srv);
ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
if (FAILED(result))
{
return gl::Error(
GL_OUT_OF_MEMORY,
"Failed to create internal shader resource view for texture storage, result: 0x%X.",
result);
}
return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
RenderTargetD3D **outRT)
{
......@@ -3156,25 +3252,27 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
{
return error;
}
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = mTextureFormatSet.srvFormat;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + mipLevel;
srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = layer;
srvDesc.Texture2DArray.ArraySize = 1;
ID3D11ShaderResourceView *srv;
result = device->CreateShaderResourceView(texture, &srvDesc, &srv);
ASSERT(result == E_OUTOFMEMORY || SUCCEEDED(result));
if (FAILED(result))
error = createRenderTargetSRV(texture, index, mTextureFormatSet.srvFormat, &srv);
if (error.isError())
{
return gl::Error(
GL_OUT_OF_MEMORY,
"Failed to create internal shader resource view for texture storage, result: 0x%X.",
result);
return error;
}
ID3D11ShaderResourceView *blitSRV;
if (mTextureFormatSet.blitSRVFormat != mTextureFormatSet.srvFormat)
{
error =
createRenderTargetSRV(texture, index, mTextureFormatSet.blitSRVFormat, &blitSRV);
if (error.isError())
{
SafeRelease(srv);
return error;
}
}
else
{
blitSRV = srv;
blitSRV->AddRef();
}
d3d11::SetDebugName(srv, "TexStorage2DArray.RenderTargetSRV");
......@@ -3195,6 +3293,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
if (FAILED(result))
{
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create internal render target view for texture "
"storage, result: 0x%X.",
......@@ -3204,12 +3303,13 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(rtv, "TexStorage2DArray.RenderTargetRTV");
mRenderTargets[key] = new TextureRenderTarget11(
rtv, texture, srv, mInternalFormat, mTextureFormatSet.format,
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
// RenderTarget will take ownership of these resources
SafeRelease(rtv);
SafeRelease(srv);
SafeRelease(blitSRV);
}
else
{
......@@ -3230,6 +3330,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
if (FAILED(result))
{
SafeRelease(srv);
SafeRelease(blitSRV);
return gl::Error(GL_OUT_OF_MEMORY,
"Failed to create TexStorage2DArray DSV. Result: 0x%X.", result);
}
......@@ -3243,6 +3344,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
// RenderTarget will take ownership of these resources
SafeRelease(dsv);
SafeRelease(srv);
SafeRelease(blitSRV);
}
}
......
......@@ -15,6 +15,7 @@
#include "libANGLE/renderer/d3d/TextureStorage.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include <array>
#include <map>
namespace gl
......@@ -91,7 +92,7 @@ class TextureStorage11 : public TextureStorage
virtual gl::Error getSwizzleTexture(ID3D11Resource **outTexture) = 0;
virtual gl::Error getSwizzleRenderTarget(int mipLevel, ID3D11RenderTargetView **outRTV) = 0;
gl::Error getSRVLevel(int mipLevel, ID3D11ShaderResourceView **outSRV);
gl::Error getSRVLevel(int mipLevel, bool blitSRV, ID3D11ShaderResourceView **outSRV);
virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
ID3D11ShaderResourceView **outSRV) const = 0;
......@@ -144,7 +145,8 @@ class TextureStorage11 : public TextureStorage
typedef std::map<SRVKey, ID3D11ShaderResourceView *> SRVCache;
SRVCache mSrvCache;
ID3D11ShaderResourceView *mLevelSRVs[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
std::array<ID3D11ShaderResourceView *, gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS> mLevelSRVs;
std::array<ID3D11ShaderResourceView *, gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS> mLevelBlitSRVs;
};
class TextureStorage11_2D : public TextureStorage11
......@@ -277,6 +279,10 @@ class TextureStorage11_Cube : public TextureStorage11
private:
virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
ID3D11ShaderResourceView **outSRV) const;
gl::Error createRenderTargetSRV(ID3D11Resource *texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
ID3D11ShaderResourceView **srv) const;
static const size_t CUBE_FACE_COUNT = 6;
......@@ -354,6 +360,10 @@ class TextureStorage11_2DArray : public TextureStorage11
private:
virtual gl::Error createSRV(int baseLevel, int mipLevels, DXGI_FORMAT format, ID3D11Resource *texture,
ID3D11ShaderResourceView **outSRV) const;
gl::Error createRenderTargetSRV(ID3D11Resource *texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
ID3D11ShaderResourceView **srv) const;
typedef std::pair<int, int> LevelLayerKey;
typedef std::map<LevelLayerKey, RenderTarget11*> RenderTargetMap;
......
......@@ -144,6 +144,7 @@ ANGLEFormatSet::ANGLEFormatSet()
srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN),
blitSRVFormat(DXGI_FORMAT_UNKNOWN),
swizzleFormat(ANGLE_FORMAT_NONE),
mipGenerationFunction(nullptr),
colorReadFunction(nullptr)
......@@ -174,6 +175,7 @@ ANGLEFormatSet::ANGLEFormatSet(ANGLEFormat format,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
DXGI_FORMAT blitSRVFormat,
ANGLEFormat swizzleFormat,
MipGenerationFunction mipGenerationFunction,
ColorReadFunction colorReadFunction)
......@@ -183,6 +185,7 @@ ANGLEFormatSet::ANGLEFormatSet(ANGLEFormat format,
srvFormat(srvFormat),
rtvFormat(rtvFormat),
dsvFormat(dsvFormat),
blitSRVFormat(blitSRVFormat),
swizzleFormat(swizzleFormat),
mipGenerationFunction(mipGenerationFunction),
colorReadFunction(colorReadFunction)
......@@ -441,6 +444,14 @@ def get_color_read_function(angle_format):
}
return 'ReadColor<' + channel_struct + ', '+ component_type_map[angle_format['componentType']] + '>'
def get_blit_srv_format(angle_format):
if 'channels' not in angle_format:
return 'DXGI_FORMAT_UNKNOWN'
if 'r' in angle_format['channels'] and angle_format['componentType'] in ['int', 'uint']:
return angle_format['rtvFormat']
return angle_format["srvFormat"] if "srvFormat" in angle_format else "DXGI_FORMAT_UNKNOWN"
def parse_json_into_switch_angle_format_string(json_data):
table_data = ''
for angle_format_item in sorted(json_data.iteritems()):
......@@ -451,6 +462,7 @@ def parse_json_into_switch_angle_format_string(json_data):
srv_format = angle_format["srvFormat"] if "srvFormat" in angle_format else "DXGI_FORMAT_UNKNOWN"
rtv_format = angle_format["rtvFormat"] if "rtvFormat" in angle_format else "DXGI_FORMAT_UNKNOWN"
dsv_format = angle_format["dsvFormat"] if "dsvFormat" in angle_format else "DXGI_FORMAT_UNKNOWN"
blit_srv_format = get_blit_srv_format(angle_format)
swizzle_format = get_swizzle_format_id(angle_format_item[0], angle_format)
mip_generation_function = get_mip_generation_function(angle_format)
color_read_function = get_color_read_function(angle_format)
......@@ -461,6 +473,7 @@ def parse_json_into_switch_angle_format_string(json_data):
table_data += ' ' + srv_format + ',\n'
table_data += ' ' + rtv_format + ',\n'
table_data += ' ' + dsv_format + ',\n'
table_data += ' ' + blit_srv_format + ',\n'
table_data += ' ' + swizzle_format + ',\n'
table_data += ' ' + mip_generation_function + ',\n'
table_data += ' ' + color_read_function + ');\n'
......
......@@ -46,6 +46,7 @@ struct ANGLEFormatSet
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
DXGI_FORMAT blitSRVFormat,
ANGLEFormat swizzleFormat,
MipGenerationFunction mipGenerationFunction,
ColorReadFunction colorReadFunction);
......@@ -63,6 +64,8 @@ struct ANGLEFormatSet
DXGI_FORMAT rtvFormat;
DXGI_FORMAT dsvFormat;
DXGI_FORMAT blitSRVFormat;
ANGLEFormat swizzleFormat;
MipGenerationFunction mipGenerationFunction;
......
......@@ -106,6 +106,7 @@ ANGLEFormatSet::ANGLEFormatSet()
srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN),
blitSRVFormat(DXGI_FORMAT_UNKNOWN),
swizzleFormat(ANGLE_FORMAT_NONE),
mipGenerationFunction(nullptr),
colorReadFunction(nullptr)
......@@ -136,6 +137,7 @@ ANGLEFormatSet::ANGLEFormatSet(ANGLEFormat format,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
DXGI_FORMAT blitSRVFormat,
ANGLEFormat swizzleFormat,
MipGenerationFunction mipGenerationFunction,
ColorReadFunction colorReadFunction)
......@@ -145,6 +147,7 @@ ANGLEFormatSet::ANGLEFormatSet(ANGLEFormat format,
srvFormat(srvFormat),
rtvFormat(rtvFormat),
dsvFormat(dsvFormat),
blitSRVFormat(blitSRVFormat),
swizzleFormat(swizzleFormat),
mipGenerationFunction(mipGenerationFunction),
colorReadFunction(colorReadFunction)
......@@ -164,6 +167,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_A8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<A8>,
ReadColor<A8, GLfloat>);
......@@ -177,6 +181,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B4G4R4A4_UNORM,
ANGLE_FORMAT_B4G4R4A4_UNORM,
GenerateMip<A4R4G4B4>,
ReadColor<A4R4G4B4, GLfloat>);
......@@ -190,6 +195,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B5G5R5A1_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<A1R5G5B5>,
ReadColor<A1R5G5B5, GLfloat>);
......@@ -203,6 +209,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B5G6R5_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R5G6B5>,
ReadColor<R5G6B5, GLfloat>);
......@@ -216,6 +223,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B8G8R8A8_UNORM,
ANGLE_FORMAT_B8G8R8A8_UNORM,
GenerateMip<B8G8R8A8>,
ReadColor<B8G8R8A8, GLfloat>);
......@@ -229,6 +237,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC1_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
nullptr,
nullptr);
......@@ -242,6 +251,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_BC2_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC2_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
nullptr,
nullptr);
......@@ -255,6 +265,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_BC3_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC3_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
nullptr,
nullptr);
......@@ -268,6 +279,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_R16_UNORM,
ANGLE_FORMAT_R16G16B16A16_UNORM,
nullptr,
nullptr);
......@@ -281,6 +293,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_UNKNOWN,
ANGLE_FORMAT_R16G16B16A16_UNORM,
nullptr,
nullptr);
......@@ -294,6 +307,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R24_UNORM_X8_TYPELESS,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
nullptr,
nullptr);
......@@ -307,6 +321,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_UNKNOWN,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
nullptr,
nullptr);
......@@ -320,6 +335,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D32_FLOAT,
DXGI_FORMAT_R32_FLOAT,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
nullptr,
nullptr);
......@@ -333,6 +349,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
nullptr,
nullptr);
......@@ -346,6 +363,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
ANGLE_FORMAT_NONE,
nullptr,
nullptr);
......@@ -359,6 +377,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R10G10B10A2_UINT,
DXGI_FORMAT_R10G10B10A2_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R10G10B10A2_UINT,
ANGLE_FORMAT_R16G16B16A16_UINT,
GenerateMip<R10G10B10A2>,
ReadColor<R10G10B10A2, GLuint>);
......@@ -372,6 +391,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R10G10B10A2_UNORM,
ANGLE_FORMAT_R16G16B16A16_UNORM,
GenerateMip<R10G10B10A2>,
ReadColor<R10G10B10A2, GLfloat>);
......@@ -385,6 +405,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R11G11B10_FLOAT,
ANGLE_FORMAT_R16G16B16A16_FLOAT,
GenerateMip<R11G11B10F>,
ReadColor<R11G11B10F, GLfloat>);
......@@ -398,6 +419,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16B16A16_FLOAT,
ANGLE_FORMAT_R16G16B16A16_FLOAT,
GenerateMip<R16G16B16A16F>,
ReadColor<R16G16B16A16F, GLfloat>);
......@@ -411,6 +433,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16B16A16_SINT,
DXGI_FORMAT_R16G16B16A16_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16B16A16_SINT,
ANGLE_FORMAT_R16G16B16A16_SINT,
GenerateMip<R16G16B16A16S>,
ReadColor<R16G16B16A16S, GLint>);
......@@ -424,6 +447,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16B16A16_UINT,
DXGI_FORMAT_R16G16B16A16_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16B16A16_UINT,
ANGLE_FORMAT_R16G16B16A16_UINT,
GenerateMip<R16G16B16A16>,
ReadColor<R16G16B16A16, GLuint>);
......@@ -437,6 +461,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16B16A16_UNORM,
ANGLE_FORMAT_R16G16B16A16_UNORM,
GenerateMip<R16G16B16A16>,
ReadColor<R16G16B16A16, GLfloat>);
......@@ -450,6 +475,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16_FLOAT,
DXGI_FORMAT_R16G16_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16_FLOAT,
ANGLE_FORMAT_R16G16B16A16_FLOAT,
GenerateMip<R16G16F>,
ReadColor<R16G16F, GLfloat>);
......@@ -463,6 +489,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16_SINT,
DXGI_FORMAT_R16G16_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16_SINT,
ANGLE_FORMAT_R16G16B16A16_SINT,
GenerateMip<R16G16S>,
ReadColor<R16G16S, GLint>);
......@@ -476,6 +503,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16G16_UINT,
DXGI_FORMAT_R16G16_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16G16_UINT,
ANGLE_FORMAT_R16G16B16A16_UINT,
GenerateMip<R16G16>,
ReadColor<R16G16, GLuint>);
......@@ -489,6 +517,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16_FLOAT,
DXGI_FORMAT_R16_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16_FLOAT,
ANGLE_FORMAT_R16G16B16A16_FLOAT,
GenerateMip<R16F>,
ReadColor<R16F, GLfloat>);
......@@ -502,6 +531,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16_SINT,
DXGI_FORMAT_R16_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16_SINT,
ANGLE_FORMAT_R16G16B16A16_SINT,
GenerateMip<R16S>,
ReadColor<R16S, GLint>);
......@@ -515,6 +545,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R16_UINT,
DXGI_FORMAT_R16_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R16_UINT,
ANGLE_FORMAT_R16G16B16A16_UINT,
GenerateMip<R16>,
ReadColor<R16, GLuint>);
......@@ -528,6 +559,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32B32A32_FLOAT,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
GenerateMip<R32G32B32A32F>,
ReadColor<R32G32B32A32F, GLfloat>);
......@@ -541,6 +573,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32G32B32A32_SINT,
DXGI_FORMAT_R32G32B32A32_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32B32A32_SINT,
ANGLE_FORMAT_R32G32B32A32_SINT,
GenerateMip<R32G32B32A32S>,
ReadColor<R32G32B32A32S, GLint>);
......@@ -554,6 +587,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32G32B32A32_UINT,
DXGI_FORMAT_R32G32B32A32_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32B32A32_UINT,
ANGLE_FORMAT_R32G32B32A32_UINT,
GenerateMip<R32G32B32A32>,
ReadColor<R32G32B32A32, GLuint>);
......@@ -567,6 +601,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32_FLOAT,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
GenerateMip<R32G32F>,
ReadColor<R32G32F, GLfloat>);
......@@ -580,6 +615,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32G32_SINT,
DXGI_FORMAT_R32G32_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32_SINT,
ANGLE_FORMAT_R32G32B32A32_SINT,
GenerateMip<R32G32S>,
ReadColor<R32G32S, GLint>);
......@@ -593,6 +629,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32G32_UINT,
DXGI_FORMAT_R32G32_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32_UINT,
ANGLE_FORMAT_R32G32B32A32_UINT,
GenerateMip<R32G32>,
ReadColor<R32G32, GLuint>);
......@@ -606,6 +643,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32_FLOAT,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
GenerateMip<R32F>,
ReadColor<R32F, GLfloat>);
......@@ -619,6 +657,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32_SINT,
DXGI_FORMAT_R32_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32_SINT,
ANGLE_FORMAT_R32G32B32A32_SINT,
GenerateMip<R32S>,
ReadColor<R32S, GLint>);
......@@ -632,6 +671,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R32_UINT,
DXGI_FORMAT_R32_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32_UINT,
ANGLE_FORMAT_R32G32B32A32_UINT,
GenerateMip<R32>,
ReadColor<R32, GLuint>);
......@@ -645,6 +685,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_SINT,
DXGI_FORMAT_R8G8B8A8_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_SINT,
ANGLE_FORMAT_R8G8B8A8_SINT,
GenerateMip<R8G8B8A8S>,
ReadColor<R8G8B8A8S, GLint>);
......@@ -658,6 +699,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_SNORM,
ANGLE_FORMAT_R8G8B8A8_SNORM,
GenerateMip<R8G8B8A8S>,
ReadColor<R8G8B8A8S, GLfloat>);
......@@ -671,6 +713,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_UINT,
DXGI_FORMAT_R8G8B8A8_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UINT,
ANGLE_FORMAT_R8G8B8A8_UINT,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLuint>);
......@@ -684,6 +727,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLfloat>);
......@@ -697,6 +741,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLfloat>);
......@@ -710,6 +755,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
ANGLE_FORMAT_R8G8B8A8_UNORM_SRGB,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLfloat>);
......@@ -723,6 +769,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8G8B8A8>,
ReadColor<R8G8B8A8, GLfloat>);
......@@ -736,6 +783,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8_SINT,
DXGI_FORMAT_R8G8_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8_SINT,
ANGLE_FORMAT_R8G8B8A8_SINT,
GenerateMip<R8G8S>,
ReadColor<R8G8S, GLint>);
......@@ -749,6 +797,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8_SNORM,
ANGLE_FORMAT_R8G8B8A8_SNORM,
GenerateMip<R8G8S>,
ReadColor<R8G8S, GLfloat>);
......@@ -762,6 +811,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8_SNORM,
ANGLE_FORMAT_R8G8B8A8_SNORM,
GenerateMip<R8G8S>,
ReadColor<R8G8S, GLfloat>);
......@@ -775,6 +825,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8_UINT,
DXGI_FORMAT_R8G8_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8_UINT,
ANGLE_FORMAT_R8G8B8A8_UINT,
GenerateMip<R8G8>,
ReadColor<R8G8, GLuint>);
......@@ -788,6 +839,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8G8>,
ReadColor<R8G8, GLfloat>);
......@@ -801,6 +853,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8G8>,
ReadColor<R8G8, GLfloat>);
......@@ -814,6 +867,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8_SINT,
DXGI_FORMAT_R8_SINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8_SINT,
ANGLE_FORMAT_R8G8B8A8_SINT,
GenerateMip<R8S>,
ReadColor<R8S, GLint>);
......@@ -827,6 +881,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8_SNORM,
ANGLE_FORMAT_R8G8B8A8_SNORM,
GenerateMip<R8S>,
ReadColor<R8S, GLfloat>);
......@@ -840,6 +895,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8_SNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8_SNORM,
ANGLE_FORMAT_R8G8B8A8_SNORM,
GenerateMip<R8S>,
ReadColor<R8S, GLfloat>);
......@@ -853,6 +909,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8_UINT,
DXGI_FORMAT_R8_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8_UINT,
ANGLE_FORMAT_R8G8B8A8_UINT,
GenerateMip<R8>,
ReadColor<R8, GLuint>);
......@@ -866,6 +923,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8>,
ReadColor<R8, GLfloat>);
......@@ -879,6 +937,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8_UNORM,
ANGLE_FORMAT_R8G8B8A8_UNORM,
GenerateMip<R8>,
ReadColor<R8, GLfloat>);
......@@ -892,6 +951,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
ANGLE_FORMAT_R16G16B16A16_FLOAT,
GenerateMip<R9G9B9E5>,
ReadColor<R9G9B9E5, GLfloat>);
......@@ -905,6 +965,7 @@ const ANGLEFormatSet &GetANGLEFormatSet(ANGLEFormat angleFormat)
DXGI_FORMAT_X24_TYPELESS_G8_UINT,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_X24_TYPELESS_G8_UINT,
ANGLE_FORMAT_R32G32B32A32_FLOAT,
nullptr,
nullptr);
......
......@@ -85,12 +85,10 @@ class SwizzleTest : public ANGLETest
);
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)
{
FAIL() << "shader compilation failed.";
}
ASSERT_NE(0u, mProgram);
mTextureUniformLocation = glGetUniformLocation(mProgram, "tex");
ASSERT_NE(-1, mTextureUniformLocation);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
ASSERT_GL_NO_ERROR();
......@@ -202,6 +200,54 @@ class SwizzleTest : public ANGLETest
std::vector<swizzlePermutation> mPermutations;
};
class SwizzleIntegerTest : public SwizzleTest
{
protected:
void SetUp() override
{
ANGLETest::SetUp();
const std::string vertexShaderSource =
"#version 300 es\n"
"precision highp float;\n"
"in vec4 position;\n"
"out vec2 texcoord;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = position;\n"
" texcoord = (position.xy * 0.5) + 0.5;\n"
"}\n";
const std::string fragmentShaderSource =
"#version 300 es\n"
"precision highp float;\n"
"precision highp usampler2D;\n"
"uniform usampler2D tex;\n"
"in vec2 texcoord;\n"
"out vec4 my_FragColor;\n"
"\n"
"void main()\n"
"{\n"
" uvec4 s = texture(tex, texcoord);\n"
" if (s[0] == 1u) s[0] = 255u;\n"
" if (s[1] == 1u) s[1] = 255u;\n"
" if (s[2] == 1u) s[2] = 255u;\n"
" if (s[3] == 1u) s[3] = 255u;\n"
" my_FragColor = vec4(s) / 255.0;\n"
"}\n";
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
ASSERT_NE(0u, mProgram);
mTextureUniformLocation = glGetUniformLocation(mProgram, "tex");
ASSERT_NE(-1, mTextureUniformLocation);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
ASSERT_GL_NO_ERROR();
}
};
TEST_P(SwizzleTest, RGBA8_2D)
{
GLubyte data[] = { 1, 64, 128, 200 };
......@@ -346,7 +392,19 @@ TEST_P(SwizzleTest, CompressedDXT_2D)
runTest2D();
}
TEST_P(SwizzleIntegerTest, RGB8UI_2D)
{
GLubyte data[] = {77, 66, 55};
init2DTexture(GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, data);
runTest2D();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(SwizzleTest, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGL(3, 3), ES3_OPENGLES());
ANGLE_INSTANTIATE_TEST(SwizzleIntegerTest,
ES3_D3D11(),
ES3_OPENGL(),
ES3_OPENGL(3, 3),
ES3_OPENGLES());
} // namespace
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