Commit 1a4523f3 by Olli Etuaho Committed by Commit Bot

Avoid copying of texture format info structures

Use const pointers to the statically allocated structures instead of copying them in TextureStorage11. This avoids the cost of copying and saves a little bit of memory. BUG=angleproject:1244 TEST=angle_end2end_tests Change-Id: Ib59fddd68ba9bc53e491d55683416c0661f26e0e Reviewed-on: https://chromium-review.googlesource.com/333930Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 90a96efc
...@@ -68,7 +68,7 @@ gl::Error Image11::generateMipmap(Image11 *dest, ...@@ -68,7 +68,7 @@ gl::Error Image11::generateMipmap(Image11 *dest,
uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData); uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData);
auto mipGenerationFunction = d3d11::GetTextureFormatInfo(src->getInternalFormat(), rendererCaps) auto mipGenerationFunction = d3d11::GetTextureFormatInfo(src->getInternalFormat(), rendererCaps)
.formatSet.mipGenerationFunction; .formatSet->mipGenerationFunction;
mipGenerationFunction(src->getWidth(), src->getHeight(), src->getDepth(), sourceData, mipGenerationFunction(src->getWidth(), src->getHeight(), src->getDepth(), sourceData,
srcMapped.RowPitch, srcMapped.DepthPitch, destData, destMapped.RowPitch, srcMapped.RowPitch, srcMapped.DepthPitch, destData, destMapped.RowPitch,
destMapped.DepthPitch); destMapped.DepthPitch);
...@@ -222,8 +222,8 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents & ...@@ -222,8 +222,8 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &
// compute the d3d format that will be used // compute the d3d format that will be used
const d3d11::TextureFormat &formatInfo = const d3d11::TextureFormat &formatInfo =
d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps());
mDXGIFormat = formatInfo.formatSet.texFormat; mDXGIFormat = formatInfo.formatSet->texFormat;
mRenderable = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN); mRenderable = (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN);
releaseStagingTexture(); releaseStagingTexture();
mDirty = (formatInfo.dataInitializerFunction != NULL); mDirty = (formatInfo.dataInitializerFunction != NULL);
...@@ -344,7 +344,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset, ...@@ -344,7 +344,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const auto &d3d11Format = d3d11::GetTextureFormatInfo(srcAttachment->getInternalFormat(), const auto &d3d11Format = d3d11::GetTextureFormatInfo(srcAttachment->getInternalFormat(),
mRenderer->getRenderer11DeviceCaps()); mRenderer->getRenderer11DeviceCaps());
if (d3d11Format.formatSet.texFormat == mDXGIFormat) if (d3d11Format.formatSet->texFormat == mDXGIFormat)
{ {
RenderTargetD3D *renderTarget = nullptr; RenderTargetD3D *renderTarget = nullptr;
gl::Error error = srcAttachment->getRenderTarget(&renderTarget); gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
......
...@@ -205,7 +205,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac ...@@ -205,7 +205,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac
GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType); GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType);
const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat, mRenderer->getRenderer11DeviceCaps());
DXGI_FORMAT srvFormat = sourceFormatInfo.formatSet.srvFormat; DXGI_FORMAT srvFormat = sourceFormatInfo.formatSet->srvFormat;
ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
Buffer11 *bufferStorage11 = GetAs<Buffer11>(sourceBuffer.getImplementation()); Buffer11 *bufferStorage11 = GetAs<Buffer11>(sourceBuffer.getImplementation());
ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat); ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat);
......
...@@ -381,7 +381,7 @@ SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, ...@@ -381,7 +381,7 @@ SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain,
mANGLEFormat = d3d11::GetTextureFormatInfo(getInternalFormatInternal(), mANGLEFormat = d3d11::GetTextureFormatInfo(getInternalFormatInternal(),
mRenderer->getRenderer11DeviceCaps()) mRenderer->getRenderer11DeviceCaps())
.formatSet.format; .formatSet->format;
} }
SurfaceRenderTarget11::~SurfaceRenderTarget11() SurfaceRenderTarget11::~SurfaceRenderTarget11()
......
...@@ -3036,7 +3036,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3036,7 +3036,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
desc.Height = height; desc.Height = height;
desc.MipLevels = 1; desc.MipLevels = 1;
desc.ArraySize = 1; desc.ArraySize = 1;
desc.Format = formatInfo.formatSet.texFormat; desc.Format = formatInfo.formatSet->texFormat;
desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples; desc.SampleDesc.Count = (supportedSamples == 0) ? 1 : supportedSamples;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -3047,14 +3047,14 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3047,14 +3047,14 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
// we'll flag it to allow binding that way. Shader resource views are a little // we'll flag it to allow binding that way. Shader resource views are a little
// more complicated. // more complicated.
bool bindRTV = false, bindDSV = false, bindSRV = false; bool bindRTV = false, bindDSV = false, bindSRV = false;
bindRTV = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN); bindRTV = (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN); bindDSV = (formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN);
if (formatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN) if (formatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
// Multisample targets flagged for binding as depth stencil cannot also be // Multisample targets flagged for binding as depth stencil cannot also be
// flagged for binding as SRV, so make certain not to add the SRV flag for // flagged for binding as SRV, so make certain not to add the SRV flag for
// these targets. // these targets.
bindSRV = !(formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN && bindSRV = !(formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN &&
desc.SampleDesc.Count > 1); desc.SampleDesc.Count > 1);
} }
...@@ -3078,7 +3078,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3078,7 +3078,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
if (bindSRV) if (bindSRV)
{ {
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = formatInfo.formatSet.srvFormat; srvDesc.Format = formatInfo.formatSet->srvFormat;
srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS; srvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS;
srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.MostDetailedMip = 0;
srvDesc.Texture2D.MipLevels = 1; srvDesc.Texture2D.MipLevels = 1;
...@@ -3091,10 +3091,10 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3091,10 +3091,10 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target shader resource view, result: 0x%X.", result); 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) if (formatInfo.formatSet->blitSRVFormat != formatInfo.formatSet->srvFormat)
{ {
D3D11_SHADER_RESOURCE_VIEW_DESC blitSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC blitSRVDesc;
blitSRVDesc.Format = formatInfo.formatSet.blitSRVFormat; blitSRVDesc.Format = formatInfo.formatSet->blitSRVFormat;
blitSRVDesc.ViewDimension = (supportedSamples == 0) blitSRVDesc.ViewDimension = (supportedSamples == 0)
? D3D11_SRV_DIMENSION_TEXTURE2D ? D3D11_SRV_DIMENSION_TEXTURE2D
: D3D11_SRV_DIMENSION_TEXTURE2DMS; : D3D11_SRV_DIMENSION_TEXTURE2DMS;
...@@ -3123,7 +3123,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3123,7 +3123,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
if (bindDSV) if (bindDSV)
{ {
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = formatInfo.formatSet.dsvFormat; dsvDesc.Format = formatInfo.formatSet->dsvFormat;
dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS; dsvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS;
dsvDesc.Texture2D.MipSlice = 0; dsvDesc.Texture2D.MipSlice = 0;
dsvDesc.Flags = 0; dsvDesc.Flags = 0;
...@@ -3140,7 +3140,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3140,7 +3140,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
} }
*outRT = *outRT =
new TextureRenderTarget11(dsv, texture, srv, format, formatInfo.formatSet.format, new TextureRenderTarget11(dsv, texture, srv, format, formatInfo.formatSet->format,
width, height, 1, supportedSamples); width, height, 1, supportedSamples);
SafeRelease(dsv); SafeRelease(dsv);
...@@ -3148,7 +3148,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3148,7 +3148,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
else if (bindRTV) else if (bindRTV)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = formatInfo.formatSet.rtvFormat; rtvDesc.Format = formatInfo.formatSet->rtvFormat;
rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS; rtvDesc.ViewDimension = (supportedSamples == 0) ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS;
rtvDesc.Texture2D.MipSlice = 0; rtvDesc.Texture2D.MipSlice = 0;
...@@ -3170,7 +3170,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3170,7 +3170,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
} }
*outRT = new TextureRenderTarget11(rtv, texture, srv, blitSRV, format, *outRT = new TextureRenderTarget11(rtv, texture, srv, blitSRV, format,
formatInfo.formatSet.format, width, height, 1, formatInfo.formatSet->format, width, height, 1,
supportedSamples); supportedSamples);
SafeRelease(rtv); SafeRelease(rtv);
...@@ -3473,7 +3473,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -3473,7 +3473,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
} }
// We cannot support direct copies to non-color-renderable formats // We cannot support direct copies to non-color-renderable formats
if (d3d11FormatInfo.formatSet.rtvFormat == DXGI_FORMAT_UNKNOWN) if (d3d11FormatInfo.formatSet->rtvFormat == DXGI_FORMAT_UNKNOWN)
{ {
return false; return false;
} }
...@@ -3485,7 +3485,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -3485,7 +3485,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
} }
// We don't support formats which we can't represent without conversion // We don't support formats which we can't represent without conversion
if (d3d11FormatInfo.formatSet.glInternalFormat != internalFormat) if (d3d11FormatInfo.formatSet->glInternalFormat != internalFormat)
{ {
return false; return false;
} }
......
...@@ -208,7 +208,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -208,7 +208,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
if (offscreenTextureDesc.Width != (UINT)backbufferWidth || if (offscreenTextureDesc.Width != (UINT)backbufferWidth ||
offscreenTextureDesc.Height != (UINT)backbufferHeight || offscreenTextureDesc.Height != (UINT)backbufferHeight ||
offscreenTextureDesc.Format != backbufferFormatInfo.formatSet.texFormat || offscreenTextureDesc.Format != backbufferFormatInfo.formatSet->texFormat ||
offscreenTextureDesc.MipLevels != 1 || offscreenTextureDesc.ArraySize != 1) offscreenTextureDesc.MipLevels != 1 || offscreenTextureDesc.ArraySize != 1)
{ {
ERR("Invalid texture parameters in the shared offscreen texture pbuffer"); ERR("Invalid texture parameters in the shared offscreen texture pbuffer");
...@@ -223,7 +223,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -223,7 +223,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0}; D3D11_TEXTURE2D_DESC offscreenTextureDesc = {0};
offscreenTextureDesc.Width = backbufferWidth; offscreenTextureDesc.Width = backbufferWidth;
offscreenTextureDesc.Height = backbufferHeight; offscreenTextureDesc.Height = backbufferHeight;
offscreenTextureDesc.Format = backbufferFormatInfo.formatSet.texFormat; offscreenTextureDesc.Format = backbufferFormatInfo.formatSet->texFormat;
offscreenTextureDesc.MipLevels = 1; offscreenTextureDesc.MipLevels = 1;
offscreenTextureDesc.ArraySize = 1; offscreenTextureDesc.ArraySize = 1;
offscreenTextureDesc.SampleDesc.Count = 1; offscreenTextureDesc.SampleDesc.Count = 1;
...@@ -281,7 +281,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -281,7 +281,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
mKeyedMutex = d3d11::DynamicCastComObject<IDXGIKeyedMutex>(mOffscreenTexture); mKeyedMutex = d3d11::DynamicCastComObject<IDXGIKeyedMutex>(mOffscreenTexture);
D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc; D3D11_RENDER_TARGET_VIEW_DESC offscreenRTVDesc;
offscreenRTVDesc.Format = backbufferFormatInfo.formatSet.rtvFormat; offscreenRTVDesc.Format = backbufferFormatInfo.formatSet->rtvFormat;
offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
offscreenRTVDesc.Texture2D.MipSlice = 0; offscreenRTVDesc.Texture2D.MipSlice = 0;
...@@ -290,7 +290,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -290,7 +290,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
d3d11::SetDebugName(mOffscreenRTView, "Offscreen back buffer render target"); d3d11::SetDebugName(mOffscreenRTView, "Offscreen back buffer render target");
D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc;
offscreenSRVDesc.Format = backbufferFormatInfo.formatSet.srvFormat; offscreenSRVDesc.Format = backbufferFormatInfo.formatSet->srvFormat;
offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; offscreenSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
offscreenSRVDesc.Texture2D.MostDetailedMip = 0; offscreenSRVDesc.Texture2D.MostDetailedMip = 0;
offscreenSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1); offscreenSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1);
...@@ -337,7 +337,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -337,7 +337,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
D3D11_TEXTURE2D_DESC depthStencilTextureDesc; D3D11_TEXTURE2D_DESC depthStencilTextureDesc;
depthStencilTextureDesc.Width = backbufferWidth; depthStencilTextureDesc.Width = backbufferWidth;
depthStencilTextureDesc.Height = backbufferHeight; depthStencilTextureDesc.Height = backbufferHeight;
depthStencilTextureDesc.Format = depthBufferFormatInfo.formatSet.texFormat; depthStencilTextureDesc.Format = depthBufferFormatInfo.formatSet->texFormat;
depthStencilTextureDesc.MipLevels = 1; depthStencilTextureDesc.MipLevels = 1;
depthStencilTextureDesc.ArraySize = 1; depthStencilTextureDesc.ArraySize = 1;
depthStencilTextureDesc.SampleDesc.Count = 1; depthStencilTextureDesc.SampleDesc.Count = 1;
...@@ -345,7 +345,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -345,7 +345,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT; depthStencilTextureDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthStencilTextureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
if (depthBufferFormatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN) if (depthBufferFormatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
} }
...@@ -373,7 +373,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -373,7 +373,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
d3d11::SetDebugName(mDepthStencilTexture, "Offscreen depth stencil texture"); d3d11::SetDebugName(mDepthStencilTexture, "Offscreen depth stencil texture");
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc; D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc;
depthStencilDesc.Format = depthBufferFormatInfo.formatSet.dsvFormat; depthStencilDesc.Format = depthBufferFormatInfo.formatSet->dsvFormat;
depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; depthStencilDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilDesc.Flags = 0; depthStencilDesc.Flags = 0;
depthStencilDesc.Texture2D.MipSlice = 0; depthStencilDesc.Texture2D.MipSlice = 0;
...@@ -382,10 +382,10 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -382,10 +382,10 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
d3d11::SetDebugName(mDepthStencilDSView, "Offscreen depth stencil view"); d3d11::SetDebugName(mDepthStencilDSView, "Offscreen depth stencil view");
if (depthBufferFormatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN) if (depthBufferFormatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc;
depthStencilSRVDesc.Format = depthBufferFormatInfo.formatSet.srvFormat; depthStencilSRVDesc.Format = depthBufferFormatInfo.formatSet->srvFormat;
depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; depthStencilSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
depthStencilSRVDesc.Texture2D.MostDetailedMip = 0; depthStencilSRVDesc.Texture2D.MostDetailedMip = 0;
depthStencilSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1); depthStencilSRVDesc.Texture2D.MipLevels = static_cast<UINT>(-1);
......
...@@ -73,6 +73,8 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer, UINT bindFlags, UINT mi ...@@ -73,6 +73,8 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer, UINT bindFlags, UINT mi
mTopLevel(0), mTopLevel(0),
mMipLevels(0), mMipLevels(0),
mInternalFormat(GL_NONE), mInternalFormat(GL_NONE),
mTextureFormatSet(nullptr),
mSwizzleFormatSet(nullptr),
mTextureWidth(0), mTextureWidth(0),
mTextureHeight(0), mTextureHeight(0),
mTextureDepth(0), mTextureDepth(0),
...@@ -106,15 +108,15 @@ DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, ...@@ -106,15 +108,15 @@ DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat,
const d3d11::TextureFormat &formatInfo = const d3d11::TextureFormat &formatInfo =
d3d11::GetTextureFormatInfo(internalFormat, renderer11DeviceCaps); d3d11::GetTextureFormatInfo(internalFormat, renderer11DeviceCaps);
if (formatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN) if (formatInfo.formatSet->srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
bindFlags |= D3D11_BIND_SHADER_RESOURCE; bindFlags |= D3D11_BIND_SHADER_RESOURCE;
} }
if (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) if (formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
bindFlags |= D3D11_BIND_DEPTH_STENCIL; bindFlags |= D3D11_BIND_DEPTH_STENCIL;
} }
if (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN && renderTarget) if (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN && renderTarget)
{ {
bindFlags |= D3D11_BIND_RENDER_TARGET; bindFlags |= D3D11_BIND_RENDER_TARGET;
} }
...@@ -134,7 +136,7 @@ DWORD TextureStorage11::GetTextureMiscFlags(GLenum internalFormat, ...@@ -134,7 +136,7 @@ DWORD TextureStorage11::GetTextureMiscFlags(GLenum internalFormat,
if (renderTarget && levels > 1) if (renderTarget && levels > 1)
{ {
const d3d11::DXGIFormat &dxgiFormatInfo = const d3d11::DXGIFormat &dxgiFormatInfo =
d3d11::GetDXGIFormatInfo(formatInfo.formatSet.texFormat); d3d11::GetDXGIFormatInfo(formatInfo.formatSet->texFormat);
if (dxgiFormatInfo.nativeMipmapSupport(renderer11DeviceCaps.featureLevel)) if (dxgiFormatInfo.nativeMipmapSupport(renderer11DeviceCaps.featureLevel))
{ {
...@@ -265,7 +267,7 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState, ...@@ -265,7 +267,7 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState,
ID3D11ShaderResourceView *srv = nullptr; ID3D11ShaderResourceView *srv = nullptr;
DXGI_FORMAT format = DXGI_FORMAT format =
(swizzleRequired ? mSwizzleFormatSet.srvFormat : mTextureFormatSet.srvFormat); (swizzleRequired ? mSwizzleFormatSet->srvFormat : mTextureFormatSet->srvFormat);
gl::Error error = createSRV(textureState.baseLevel, mipLevels, format, texture, &srv); gl::Error error = createSRV(textureState.baseLevel, mipLevels, format, texture, &srv);
if (error.isError()) if (error.isError())
{ {
...@@ -291,7 +293,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel, ...@@ -291,7 +293,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel,
{ {
// Only create a different SRV for blit if blit format is different from regular srv format // Only create a different SRV for blit if blit format is different from regular srv format
if (otherLevelSRVs[mipLevel] && if (otherLevelSRVs[mipLevel] &&
mTextureFormatSet.srvFormat == mTextureFormatSet.blitSRVFormat) mTextureFormatSet->srvFormat == mTextureFormatSet->blitSRVFormat)
{ {
levelSRVs[mipLevel] = otherLevelSRVs[mipLevel]; levelSRVs[mipLevel] = otherLevelSRVs[mipLevel];
levelSRVs[mipLevel]->AddRef(); levelSRVs[mipLevel]->AddRef();
...@@ -306,7 +308,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel, ...@@ -306,7 +308,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel,
} }
DXGI_FORMAT resourceFormat = DXGI_FORMAT resourceFormat =
blitSRV ? mTextureFormatSet.blitSRVFormat : mTextureFormatSet.srvFormat; blitSRV ? mTextureFormatSet->blitSRVFormat : mTextureFormatSet->srvFormat;
error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]); error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]);
if (error.isError()) if (error.isError())
{ {
...@@ -361,7 +363,7 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel, ...@@ -361,7 +363,7 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel,
} }
ID3D11ShaderResourceView *srv = nullptr; ID3D11ShaderResourceView *srv = nullptr;
error = createSRV(baseLevel, mipLevels, mTextureFormatSet.srvFormat, texture, &srv); error = createSRV(baseLevel, mipLevels, mTextureFormatSet->srvFormat, texture, &srv);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -375,7 +377,7 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel, ...@@ -375,7 +377,7 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel,
d3d11::ANGLEFormat TextureStorage11::getANGLEFormat() const d3d11::ANGLEFormat TextureStorage11::getANGLEFormat() const
{ {
return mTextureFormatSet.format; return mTextureFormatSet->format;
} }
gl::Error TextureStorage11::generateSwizzles(GLenum swizzleRed, gl::Error TextureStorage11::generateSwizzles(GLenum swizzleRed,
...@@ -482,8 +484,8 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, ...@@ -482,8 +484,8 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture,
ASSERT(dstTexture); ASSERT(dstTexture);
const d3d11::DXGIFormatSize &dxgiFormatSizeInfo = const d3d11::DXGIFormatSize &dxgiFormatSizeInfo =
d3d11::GetDXGIFormatSizeInfo(mTextureFormatSet.texFormat); d3d11::GetDXGIFormatSizeInfo(mTextureFormatSet->texFormat);
if (!fullCopy && mTextureFormatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) if (!fullCopy && mTextureFormatSet->dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
// CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead // CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead
Blit11 *blitter = mRenderer->getBlitter(); Blit11 *blitter = mRenderer->getBlitter();
...@@ -553,7 +555,7 @@ gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource *dstTexture, ...@@ -553,7 +555,7 @@ gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource *dstTexture,
// However, D3D10Level9 doesn't always perform CopySubresourceRegion correctly unless the // However, D3D10Level9 doesn't always perform CopySubresourceRegion correctly unless the
// source box is specified. This is okay, since we don't perform CopySubresourceRegion on // source box is specified. This is okay, since we don't perform CopySubresourceRegion on
// depth/stencil textures on 9_3. // depth/stencil textures on 9_3.
ASSERT(mTextureFormatSet.dsvFormat == DXGI_FORMAT_UNKNOWN); ASSERT(mTextureFormatSet->dsvFormat == DXGI_FORMAT_UNKNOWN);
srcBox.left = region.x; srcBox.left = region.x;
srcBox.right = region.x + region.width; srcBox.right = region.x + region.width;
srcBox.top = region.y; srcBox.top = region.y;
...@@ -716,7 +718,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ...@@ -716,7 +718,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
const d3d11::TextureFormat &d3d11Format = d3d11::GetTextureFormatInfo( const d3d11::TextureFormat &d3d11Format = d3d11::GetTextureFormatInfo(
image->getInternalFormat(), mRenderer->getRenderer11DeviceCaps()); image->getInternalFormat(), mRenderer->getRenderer11DeviceCaps());
const d3d11::DXGIFormatSize &dxgiFormatInfo = const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3d11Format.formatSet.texFormat); d3d11::GetDXGIFormatSizeInfo(d3d11Format.formatSet->texFormat);
const size_t outputPixelSize = dxgiFormatInfo.pixelBytes; const size_t outputPixelSize = dxgiFormatInfo.pixelBytes;
...@@ -842,7 +844,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, ...@@ -842,7 +844,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer,
mTextureFormatSet = formatInfo.formatSet; mTextureFormatSet = formatInfo.formatSet;
mSwizzleFormatSet = formatInfo.swizzleFormatSet; mSwizzleFormatSet = formatInfo.swizzleFormatSet;
d3d11::MakeValidSize(false, mTextureFormatSet.texFormat, &width, &height, &mTopLevel); d3d11::MakeValidSize(false, mTextureFormatSet->texFormat, &width, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = width; mTextureWidth = width;
mTextureHeight = height; mTextureHeight = height;
...@@ -1170,7 +1172,7 @@ gl::Error TextureStorage11_2D::ensureTextureExists(int mipLevels) ...@@ -1170,7 +1172,7 @@ gl::Error TextureStorage11_2D::ensureTextureExists(int mipLevels)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mipLevels; desc.MipLevels = mipLevels;
desc.ArraySize = 1; desc.ArraySize = 1;
desc.Format = mTextureFormatSet.texFormat; desc.Format = mTextureFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -1251,7 +1253,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1251,7 +1253,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
if (!mLevelZeroRenderTarget) if (!mLevelZeroRenderTarget)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + level; rtvDesc.Texture2D.MipSlice = mTopLevel + level;
...@@ -1268,8 +1270,8 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1268,8 +1270,8 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
mLevelZeroRenderTarget = new TextureRenderTarget11( mLevelZeroRenderTarget = new TextureRenderTarget11(
rtv, mLevelZeroTexture, nullptr, nullptr, mInternalFormat, mTextureFormatSet.format, rtv, mLevelZeroTexture, nullptr, nullptr, mInternalFormat,
getLevelWidth(level), getLevelHeight(level), 1, 0); mTextureFormatSet->format, getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
SafeRelease(rtv); SafeRelease(rtv);
...@@ -1279,10 +1281,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1279,10 +1281,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
if (mTextureFormatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) if (mTextureFormatSet->rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + level; rtvDesc.Texture2D.MipSlice = mTopLevel + level;
...@@ -1299,7 +1301,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1299,7 +1301,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
} }
mRenderTarget[level] = new TextureRenderTarget11( mRenderTarget[level] = new TextureRenderTarget11(
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format, rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(level), getLevelHeight(level), 1, 0); getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -1309,10 +1311,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1309,10 +1311,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
ASSERT(mTextureFormatSet.dsvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(mTextureFormatSet->dsvFormat != DXGI_FORMAT_UNKNOWN);
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = mTextureFormatSet.dsvFormat; dsvDesc.Format = mTextureFormatSet->dsvFormat;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
dsvDesc.Texture2D.MipSlice = mTopLevel + level; dsvDesc.Texture2D.MipSlice = mTopLevel + level;
dsvDesc.Flags = 0; dsvDesc.Flags = 0;
...@@ -1330,7 +1332,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1330,7 +1332,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
} }
mRenderTarget[level] = mRenderTarget[level] =
new TextureRenderTarget11(dsv, texture, srv, mInternalFormat, mTextureFormatSet.format, new TextureRenderTarget11(dsv, texture, srv, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(level), getLevelHeight(level), 1, 0); getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -1405,7 +1407,7 @@ gl::Error TextureStorage11_2D::getSwizzleTexture(ID3D11Resource **outTexture) ...@@ -1405,7 +1407,7 @@ gl::Error TextureStorage11_2D::getSwizzleTexture(ID3D11Resource **outTexture)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.ArraySize = 1; desc.ArraySize = 1;
desc.Format = mSwizzleFormatSet.texFormat; desc.Format = mSwizzleFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -1446,7 +1448,7 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render ...@@ -1446,7 +1448,7 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mSwizzleFormatSet.rtvFormat; rtvDesc.Format = mSwizzleFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
...@@ -1479,8 +1481,8 @@ TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer, EGLIm ...@@ -1479,8 +1481,8 @@ TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer, EGLIm
mCurrentRenderTarget = reinterpret_cast<uintptr_t>(renderTarget11); mCurrentRenderTarget = reinterpret_cast<uintptr_t>(renderTarget11);
mMipLevels = 1; mMipLevels = 1;
mTextureFormatSet = d3d11::GetANGLEFormatSet(renderTarget11->getANGLEFormat()); mTextureFormatSet = &d3d11::GetANGLEFormatSet(renderTarget11->getANGLEFormat());
mSwizzleFormatSet = d3d11::GetANGLEFormatSet(mTextureFormatSet.swizzleFormat); mSwizzleFormatSet = &d3d11::GetANGLEFormatSet(mTextureFormatSet->swizzleFormat);
mTextureWidth = renderTarget11->getWidth(); mTextureWidth = renderTarget11->getWidth();
mTextureHeight = renderTarget11->getHeight(); mTextureHeight = renderTarget11->getHeight();
mTextureDepth = 1; mTextureDepth = 1;
...@@ -1614,7 +1616,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleTexture(ID3D11Resource **outTextu ...@@ -1614,7 +1616,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleTexture(ID3D11Resource **outTextu
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.ArraySize = 1; desc.ArraySize = 1;
desc.Format = mSwizzleFormatSet.texFormat; desc.Format = mSwizzleFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -1656,7 +1658,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel, ...@@ -1656,7 +1658,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel,
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mSwizzleFormatSet.rtvFormat; rtvDesc.Format = mSwizzleFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
...@@ -1800,7 +1802,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer11 *renderer, ...@@ -1800,7 +1802,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer11 *renderer,
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
int height = size; int height = size;
d3d11::MakeValidSize(false, mTextureFormatSet.texFormat, &size, &height, &mTopLevel); d3d11::MakeValidSize(false, mTextureFormatSet->texFormat, &size, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = size; mTextureWidth = size;
...@@ -2163,7 +2165,7 @@ gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels) ...@@ -2163,7 +2165,7 @@ gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mipLevels; desc.MipLevels = mipLevels;
desc.ArraySize = CUBE_FACE_COUNT; desc.ArraySize = CUBE_FACE_COUNT;
desc.Format = mTextureFormatSet.texFormat; desc.Format = mTextureFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -2255,7 +2257,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2255,7 +2257,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
if (!mLevelZeroRenderTarget[faceIndex]) if (!mLevelZeroRenderTarget[faceIndex])
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + level; rtvDesc.Texture2DArray.MipSlice = mTopLevel + level;
rtvDesc.Texture2DArray.FirstArraySlice = faceIndex; rtvDesc.Texture2DArray.FirstArraySlice = faceIndex;
...@@ -2275,7 +2277,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2275,7 +2277,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
mLevelZeroRenderTarget[faceIndex] = new TextureRenderTarget11( mLevelZeroRenderTarget[faceIndex] = new TextureRenderTarget11(
rtv, mLevelZeroTexture, nullptr, nullptr, mInternalFormat, rtv, mLevelZeroTexture, nullptr, nullptr, mInternalFormat,
mTextureFormatSet.format, getLevelWidth(level), getLevelHeight(level), 1, 0); mTextureFormatSet->format, getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
SafeRelease(rtv); SafeRelease(rtv);
...@@ -2287,16 +2289,16 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2287,16 +2289,16 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
} }
ID3D11ShaderResourceView *srv = nullptr; ID3D11ShaderResourceView *srv = nullptr;
error = createRenderTargetSRV(texture, index, mTextureFormatSet.srvFormat, &srv); error = createRenderTargetSRV(texture, index, mTextureFormatSet->srvFormat, &srv);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
ID3D11ShaderResourceView *blitSRV = nullptr; ID3D11ShaderResourceView *blitSRV = nullptr;
if (mTextureFormatSet.blitSRVFormat != mTextureFormatSet.srvFormat) if (mTextureFormatSet->blitSRVFormat != mTextureFormatSet->srvFormat)
{ {
error = error =
createRenderTargetSRV(texture, index, mTextureFormatSet.blitSRVFormat, &blitSRV); createRenderTargetSRV(texture, index, mTextureFormatSet->blitSRVFormat, &blitSRV);
if (error.isError()) if (error.isError())
{ {
SafeRelease(srv); SafeRelease(srv);
...@@ -2311,10 +2313,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2311,10 +2313,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(srv, "TexStorageCube.RenderTargetSRV"); d3d11::SetDebugName(srv, "TexStorageCube.RenderTargetSRV");
if (mTextureFormatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) if (mTextureFormatSet->rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + level; rtvDesc.Texture2DArray.MipSlice = mTopLevel + level;
rtvDesc.Texture2DArray.FirstArraySlice = faceIndex; rtvDesc.Texture2DArray.FirstArraySlice = faceIndex;
...@@ -2337,7 +2339,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2337,7 +2339,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(rtv, "TexStorageCube.RenderTargetRTV"); d3d11::SetDebugName(rtv, "TexStorageCube.RenderTargetRTV");
mRenderTarget[faceIndex][level] = new TextureRenderTarget11( mRenderTarget[faceIndex][level] = new TextureRenderTarget11(
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format, rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(level), getLevelHeight(level), 1, 0); getLevelWidth(level), getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -2345,10 +2347,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2345,10 +2347,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
SafeRelease(srv); SafeRelease(srv);
SafeRelease(blitSRV); SafeRelease(blitSRV);
} }
else if (mTextureFormatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) else if (mTextureFormatSet->dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = mTextureFormatSet.dsvFormat; dsvDesc.Format = mTextureFormatSet->dsvFormat;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY; dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Flags = 0; dsvDesc.Flags = 0;
dsvDesc.Texture2DArray.MipSlice = mTopLevel + level; dsvDesc.Texture2DArray.MipSlice = mTopLevel + level;
...@@ -2372,7 +2374,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2372,7 +2374,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(dsv, "TexStorageCube.RenderTargetDSV"); d3d11::SetDebugName(dsv, "TexStorageCube.RenderTargetDSV");
mRenderTarget[faceIndex][level] = new TextureRenderTarget11( mRenderTarget[faceIndex][level] = new TextureRenderTarget11(
dsv, texture, srv, mInternalFormat, mTextureFormatSet.format, getLevelWidth(level), dsv, texture, srv, mInternalFormat, mTextureFormatSet->format, getLevelWidth(level),
getLevelHeight(level), 1, 0); getLevelHeight(level), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -2471,7 +2473,7 @@ gl::Error TextureStorage11_Cube::getSwizzleTexture(ID3D11Resource **outTexture) ...@@ -2471,7 +2473,7 @@ gl::Error TextureStorage11_Cube::getSwizzleTexture(ID3D11Resource **outTexture)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.ArraySize = CUBE_FACE_COUNT; desc.ArraySize = CUBE_FACE_COUNT;
desc.Format = mSwizzleFormatSet.texFormat; desc.Format = mSwizzleFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -2513,7 +2515,7 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel, ...@@ -2513,7 +2515,7 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel,
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mSwizzleFormatSet.rtvFormat; rtvDesc.Format = mSwizzleFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture2DArray.FirstArraySlice = 0; rtvDesc.Texture2DArray.FirstArraySlice = 0;
...@@ -2568,7 +2570,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer, ...@@ -2568,7 +2570,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer,
mSwizzleFormatSet = formatInfo.swizzleFormatSet; mSwizzleFormatSet = formatInfo.swizzleFormatSet;
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormatSet.texFormat, &width, &height, &mTopLevel); d3d11::MakeValidSize(false, mTextureFormatSet->texFormat, &width, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = width; mTextureWidth = width;
...@@ -2708,7 +2710,7 @@ gl::Error TextureStorage11_3D::getResource(ID3D11Resource **outResource) ...@@ -2708,7 +2710,7 @@ gl::Error TextureStorage11_3D::getResource(ID3D11Resource **outResource)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.Depth = mTextureDepth; desc.Depth = mTextureDepth;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.Format = mTextureFormatSet.texFormat; desc.Format = mTextureFormatSet->texFormat;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = getBindFlags(); desc.BindFlags = getBindFlags();
desc.CPUAccessFlags = 0; desc.CPUAccessFlags = 0;
...@@ -2771,7 +2773,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2771,7 +2773,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
const int mipLevel = index.mipIndex; const int mipLevel = index.mipIndex;
ASSERT(mipLevel >= 0 && mipLevel < getLevelCount()); ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
ASSERT(mTextureFormatSet.rtvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(mTextureFormatSet->rtvFormat != DXGI_FORMAT_UNKNOWN);
if (!index.hasLayer()) if (!index.hasLayer())
{ {
...@@ -2801,7 +2803,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2801,7 +2803,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture3D.FirstWSlice = 0; rtvDesc.Texture3D.FirstWSlice = 0;
...@@ -2824,7 +2826,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2824,7 +2826,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
d3d11::SetDebugName(rtv, "TexStorage3D.RTV"); d3d11::SetDebugName(rtv, "TexStorage3D.RTV");
mLevelRenderTargets[mipLevel] = new TextureRenderTarget11( mLevelRenderTargets[mipLevel] = new TextureRenderTarget11(
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format, rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), getLevelDepth(mipLevel), 0); getLevelWidth(mipLevel), getLevelHeight(mipLevel), getLevelDepth(mipLevel), 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -2857,7 +2859,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2857,7 +2859,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
ID3D11ShaderResourceView *blitSRV = nullptr; ID3D11ShaderResourceView *blitSRV = nullptr;
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture3D.FirstWSlice = layer; rtvDesc.Texture3D.FirstWSlice = layer;
...@@ -2881,7 +2883,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2881,7 +2883,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
d3d11::SetDebugName(rtv, "TexStorage3D.LayerRTV"); d3d11::SetDebugName(rtv, "TexStorage3D.LayerRTV");
mLevelLayerRenderTargets[key] = new TextureRenderTarget11( mLevelLayerRenderTargets[key] = new TextureRenderTarget11(
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format, rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0); getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -2907,7 +2909,7 @@ gl::Error TextureStorage11_3D::getSwizzleTexture(ID3D11Resource **outTexture) ...@@ -2907,7 +2909,7 @@ gl::Error TextureStorage11_3D::getSwizzleTexture(ID3D11Resource **outTexture)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.Depth = mTextureDepth; desc.Depth = mTextureDepth;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.Format = mSwizzleFormatSet.texFormat; desc.Format = mSwizzleFormatSet->texFormat;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
desc.CPUAccessFlags = 0; desc.CPUAccessFlags = 0;
...@@ -2946,7 +2948,7 @@ gl::Error TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel, ID3D11Render ...@@ -2946,7 +2948,7 @@ gl::Error TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel, ID3D11Render
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mSwizzleFormatSet.rtvFormat; rtvDesc.Format = mSwizzleFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture3D.FirstWSlice = 0; rtvDesc.Texture3D.FirstWSlice = 0;
...@@ -3001,7 +3003,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer11 *renderer, ...@@ -3001,7 +3003,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer11 *renderer,
mSwizzleFormatSet = formatInfo.swizzleFormatSet; mSwizzleFormatSet = formatInfo.swizzleFormatSet;
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormatSet.texFormat, &width, &height, &mTopLevel); d3d11::MakeValidSize(false, mTextureFormatSet->texFormat, &width, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = width; mTextureWidth = width;
...@@ -3142,7 +3144,7 @@ gl::Error TextureStorage11_2DArray::getResource(ID3D11Resource **outResource) ...@@ -3142,7 +3144,7 @@ gl::Error TextureStorage11_2DArray::getResource(ID3D11Resource **outResource)
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.ArraySize = mTextureDepth; desc.ArraySize = mTextureDepth;
desc.Format = mTextureFormatSet.texFormat; desc.Format = mTextureFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -3253,16 +3255,16 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3253,16 +3255,16 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
return error; return error;
} }
ID3D11ShaderResourceView *srv; ID3D11ShaderResourceView *srv;
error = createRenderTargetSRV(texture, index, mTextureFormatSet.srvFormat, &srv); error = createRenderTargetSRV(texture, index, mTextureFormatSet->srvFormat, &srv);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
ID3D11ShaderResourceView *blitSRV; ID3D11ShaderResourceView *blitSRV;
if (mTextureFormatSet.blitSRVFormat != mTextureFormatSet.srvFormat) if (mTextureFormatSet->blitSRVFormat != mTextureFormatSet->srvFormat)
{ {
error = error =
createRenderTargetSRV(texture, index, mTextureFormatSet.blitSRVFormat, &blitSRV); createRenderTargetSRV(texture, index, mTextureFormatSet->blitSRVFormat, &blitSRV);
if (error.isError()) if (error.isError())
{ {
SafeRelease(srv); SafeRelease(srv);
...@@ -3277,10 +3279,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3277,10 +3279,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(srv, "TexStorage2DArray.RenderTargetSRV"); d3d11::SetDebugName(srv, "TexStorage2DArray.RenderTargetSRV");
if (mTextureFormatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) if (mTextureFormatSet->rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mTextureFormatSet.rtvFormat; rtvDesc.Format = mTextureFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture2DArray.FirstArraySlice = layer; rtvDesc.Texture2DArray.FirstArraySlice = layer;
...@@ -3303,7 +3305,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3303,7 +3305,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(rtv, "TexStorage2DArray.RenderTargetRTV"); d3d11::SetDebugName(rtv, "TexStorage2DArray.RenderTargetRTV");
mRenderTargets[key] = new TextureRenderTarget11( mRenderTargets[key] = new TextureRenderTarget11(
rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet.format, rtv, texture, srv, blitSRV, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0); getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -3313,10 +3315,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3313,10 +3315,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
} }
else else
{ {
ASSERT(mTextureFormatSet.dsvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(mTextureFormatSet->dsvFormat != DXGI_FORMAT_UNKNOWN);
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = mTextureFormatSet.dsvFormat; dsvDesc.Format = mTextureFormatSet->dsvFormat;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY; dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; dsvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
dsvDesc.Texture2DArray.FirstArraySlice = layer; dsvDesc.Texture2DArray.FirstArraySlice = layer;
...@@ -3338,7 +3340,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3338,7 +3340,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(dsv, "TexStorage2DArray.RenderTargetDSV"); d3d11::SetDebugName(dsv, "TexStorage2DArray.RenderTargetDSV");
mRenderTargets[key] = new TextureRenderTarget11( mRenderTargets[key] = new TextureRenderTarget11(
dsv, texture, srv, mInternalFormat, mTextureFormatSet.format, dsv, texture, srv, mInternalFormat, mTextureFormatSet->format,
getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0); getLevelWidth(mipLevel), getLevelHeight(mipLevel), 1, 0);
// RenderTarget will take ownership of these resources // RenderTarget will take ownership of these resources
...@@ -3364,7 +3366,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTextur ...@@ -3364,7 +3366,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTextur
desc.Height = mTextureHeight; desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels; desc.MipLevels = mMipLevels;
desc.ArraySize = mTextureDepth; desc.ArraySize = mTextureDepth;
desc.Format = mSwizzleFormatSet.texFormat; desc.Format = mSwizzleFormatSet->texFormat;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -3406,7 +3408,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel, ...@@ -3406,7 +3408,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel,
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mSwizzleFormatSet.rtvFormat; rtvDesc.Format = mSwizzleFormatSet->rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture2DArray.FirstArraySlice = 0; rtvDesc.Texture2DArray.FirstArraySlice = 0;
......
...@@ -107,8 +107,8 @@ class TextureStorage11 : public TextureStorage ...@@ -107,8 +107,8 @@ class TextureStorage11 : public TextureStorage
unsigned int mMipLevels; unsigned int mMipLevels;
GLenum mInternalFormat; GLenum mInternalFormat;
d3d11::ANGLEFormatSet mTextureFormatSet; const d3d11::ANGLEFormatSet *mTextureFormatSet;
d3d11::ANGLEFormatSet mSwizzleFormatSet; const d3d11::ANGLEFormatSet *mSwizzleFormatSet;
unsigned int mTextureWidth; unsigned int mTextureWidth;
unsigned int mTextureHeight; unsigned int mTextureHeight;
unsigned int mTextureDepth; unsigned int mTextureDepth;
......
...@@ -160,11 +160,11 @@ TextureFormat::TextureFormat(GLenum internalFormat, ...@@ -160,11 +160,11 @@ TextureFormat::TextureFormat(GLenum internalFormat,
InitializeTextureDataFunction internalFormatInitializer) InitializeTextureDataFunction internalFormatInitializer)
: dataInitializerFunction(internalFormatInitializer) : dataInitializerFunction(internalFormatInitializer)
{{ {{
formatSet = GetANGLEFormatSet(angleFormat); formatSet = &GetANGLEFormatSet(angleFormat);
swizzleFormatSet = GetANGLEFormatSet(formatSet.swizzleFormat); swizzleFormatSet = &GetANGLEFormatSet(formatSet->swizzleFormat);
// Gather all the load functions for this internal format // Gather all the load functions for this internal format
loadFunctions = GetLoadFunctionsMap(internalFormat, formatSet.texFormat); loadFunctions = GetLoadFunctionsMap(internalFormat, formatSet->texFormat);
ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE); ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE);
}} }}
......
...@@ -358,21 +358,21 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum ...@@ -358,21 +358,21 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
} }
} }
textureCaps.texturable = support.query(formatInfo.formatSet.texFormat, texSupportMask); textureCaps.texturable = support.query(formatInfo.formatSet->texFormat, texSupportMask);
textureCaps.filterable = textureCaps.filterable =
support.query(formatInfo.formatSet.srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE); support.query(formatInfo.formatSet->srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE);
textureCaps.renderable = textureCaps.renderable =
(support.query(formatInfo.formatSet.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) || (support.query(formatInfo.formatSet->rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) ||
(support.query(formatInfo.formatSet.dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)); (support.query(formatInfo.formatSet->dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL));
DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN; DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) if (formatInfo.formatSet->dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
renderFormat = formatInfo.formatSet.dsvFormat; renderFormat = formatInfo.formatSet->dsvFormat;
} }
else if (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) else if (formatInfo.formatSet->rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
renderFormat = formatInfo.formatSet.rtvFormat; renderFormat = formatInfo.formatSet->rtvFormat;
} }
if (renderFormat != DXGI_FORMAT_UNKNOWN && if (renderFormat != DXGI_FORMAT_UNKNOWN &&
support.query(renderFormat, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET)) support.query(renderFormat, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET))
...@@ -1366,7 +1366,7 @@ void GenerateInitialTextureData(GLint internalFormat, ...@@ -1366,7 +1366,7 @@ void GenerateInitialTextureData(GLint internalFormat,
ASSERT(d3dFormatInfo.dataInitializerFunction != NULL); ASSERT(d3dFormatInfo.dataInitializerFunction != NULL);
const d3d11::DXGIFormatSize &dxgiFormatInfo = const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.formatSet.texFormat); d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.formatSet->texFormat);
outSubresourceData->resize(mipLevels); outSubresourceData->resize(mipLevels);
outData->resize(mipLevels); outData->resize(mipLevels);
......
...@@ -78,8 +78,8 @@ struct TextureFormat : public angle::NonCopyable ...@@ -78,8 +78,8 @@ struct TextureFormat : public angle::NonCopyable
const ANGLEFormat angleFormat, const ANGLEFormat angleFormat,
InitializeTextureDataFunction internalFormatInitializer); InitializeTextureDataFunction internalFormatInitializer);
ANGLEFormatSet formatSet; const ANGLEFormatSet *formatSet;
ANGLEFormatSet swizzleFormatSet; const ANGLEFormatSet *swizzleFormatSet;
InitializeTextureDataFunction dataInitializerFunction; InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap; typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap;
......
...@@ -122,11 +122,11 @@ TextureFormat::TextureFormat(GLenum internalFormat, ...@@ -122,11 +122,11 @@ TextureFormat::TextureFormat(GLenum internalFormat,
InitializeTextureDataFunction internalFormatInitializer) InitializeTextureDataFunction internalFormatInitializer)
: dataInitializerFunction(internalFormatInitializer) : dataInitializerFunction(internalFormatInitializer)
{ {
formatSet = GetANGLEFormatSet(angleFormat); formatSet = &GetANGLEFormatSet(angleFormat);
swizzleFormatSet = GetANGLEFormatSet(formatSet.swizzleFormat); swizzleFormatSet = &GetANGLEFormatSet(formatSet->swizzleFormat);
// Gather all the load functions for this internal format // Gather all the load functions for this internal format
loadFunctions = GetLoadFunctionsMap(internalFormat, formatSet.texFormat); loadFunctions = GetLoadFunctionsMap(internalFormat, formatSet->texFormat);
ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE); ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE);
} }
......
...@@ -65,14 +65,14 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport) ...@@ -65,14 +65,14 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
UINT texSupport; UINT texSupport;
bool texSuccess = bool texSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet.texFormat, &texSupport)); SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet->texFormat, &texSupport));
bool textureable = texSuccess && ((texSupport & texSupportMask) == texSupportMask); bool textureable = texSuccess && ((texSupport & texSupportMask) == texSupportMask);
EXPECT_EQ(textureable, textureInfo.texturable); EXPECT_EQ(textureable, textureInfo.texturable);
// Bits for filtering // Bits for filtering
UINT filterSupport; UINT filterSupport;
bool filterSuccess = bool filterSuccess =
SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet.srvFormat, &filterSupport)); SUCCEEDED(device->CheckFormatSupport(formatInfo.formatSet->srvFormat, &filterSupport));
bool filterable = filterSuccess && ((filterSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0); bool filterable = filterSuccess && ((filterSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0);
EXPECT_EQ(filterable, textureInfo.filterable); EXPECT_EQ(filterable, textureInfo.filterable);
...@@ -82,25 +82,25 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport) ...@@ -82,25 +82,25 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN; DXGI_FORMAT renderFormat = DXGI_FORMAT_UNKNOWN;
if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0) if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0)
{ {
renderFormat = formatInfo.formatSet.dsvFormat; renderFormat = formatInfo.formatSet->dsvFormat;
bool depthSuccess = SUCCEEDED( bool depthSuccess = SUCCEEDED(
device->CheckFormatSupport(formatInfo.formatSet.dsvFormat, &renderSupport)); device->CheckFormatSupport(formatInfo.formatSet->dsvFormat, &renderSupport));
renderable = renderable =
depthSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0); depthSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) != 0);
if (renderable) if (renderable)
{ {
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet.dsvFormat); EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet->dsvFormat);
} }
} }
else else
{ {
renderFormat = formatInfo.formatSet.rtvFormat; renderFormat = formatInfo.formatSet->rtvFormat;
bool rtSuccess = SUCCEEDED( bool rtSuccess = SUCCEEDED(
device->CheckFormatSupport(formatInfo.formatSet.rtvFormat, &renderSupport)); device->CheckFormatSupport(formatInfo.formatSet->rtvFormat, &renderSupport));
renderable = rtSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0); renderable = rtSuccess && ((renderSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0);
if (renderable) if (renderable)
{ {
EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet.rtvFormat); EXPECT_NE(DXGI_FORMAT_UNKNOWN, formatInfo.formatSet->rtvFormat);
} }
} }
EXPECT_EQ(renderable, textureInfo.renderable); EXPECT_EQ(renderable, textureInfo.renderable);
......
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