Commit c98cd326 by Jamie Madill Committed by Commit Bot

D3D11: Merge d3d11::TextureFormat and ANGLEFormatSet.

BUG=angleproject:1455 Change-Id: I7fc2640ec9d73528feb526b4d8b89cabccda4d17 Reviewed-on: https://chromium-review.googlesource.com/367092Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e5922891
...@@ -1984,9 +1984,8 @@ gl::Error Blit11::initResolveDepthStencil(const gl::Extents &extents) ...@@ -1984,9 +1984,8 @@ gl::Error Blit11::initResolveDepthStencil(const gl::Extents &extents)
releaseResolveDepthStencilResources(); releaseResolveDepthStencilResources();
} }
auto resolvedFormat = angle::Format::ID::R32G32_FLOAT;
const auto &formatSet = const auto &formatSet =
d3d11::GetANGLEFormatSet(resolvedFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(GL_RG32F, mRenderer->getRenderer11DeviceCaps());
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
textureDesc.Width = extents.width; textureDesc.Width = extents.width;
......
...@@ -67,8 +67,8 @@ gl::Error Image11::generateMipmap(Image11 *dest, ...@@ -67,8 +67,8 @@ gl::Error Image11::generateMipmap(Image11 *dest,
const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(srcMapped.pData); const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(srcMapped.pData);
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::GetANGLEFormatSet(src->getInternalFormat(), rendererCaps)
.formatSet.format.mipGenerationFunction; .format.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);
...@@ -90,7 +90,7 @@ bool Image11::isDirty() const ...@@ -90,7 +90,7 @@ bool Image11::isDirty() const
if (mDirty && !mStagingTexture && !mRecoverFromStorage) if (mDirty && !mStagingTexture && !mRecoverFromStorage)
{ {
const Renderer11DeviceCaps &deviceCaps = mRenderer->getRenderer11DeviceCaps(); const Renderer11DeviceCaps &deviceCaps = mRenderer->getRenderer11DeviceCaps();
const auto &formatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, deviceCaps); const auto &formatInfo = d3d11::GetANGLEFormatSet(mInternalFormat, deviceCaps);
if (formatInfo.dataInitializerFunction == nullptr) if (formatInfo.dataInitializerFunction == nullptr)
{ {
return false; return false;
...@@ -220,10 +220,10 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents & ...@@ -220,10 +220,10 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &
mTarget = target; mTarget = target;
// compute the d3d format that will be used // compute the d3d format that will be used
const d3d11::TextureFormat &formatInfo = const d3d11::ANGLEFormatSet &formatInfo =
d3d11::GetTextureFormatInfo(internalformat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(internalformat, mRenderer->getRenderer11DeviceCaps());
mDXGIFormat = formatInfo.formatSet.texFormat; mDXGIFormat = formatInfo.texFormat;
mRenderable = (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN); mRenderable = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
releaseStagingTexture(); releaseStagingTexture();
mDirty = (formatInfo.dataInitializerFunction != NULL); mDirty = (formatInfo.dataInitializerFunction != NULL);
...@@ -269,7 +269,8 @@ gl::Error Image11::loadData(const gl::Box &area, ...@@ -269,7 +269,8 @@ gl::Error Image11::loadData(const gl::Box &area,
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat); const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::ANGLEFormatSet &d3dFormatInfo =
d3d11::GetANGLEFormatSet(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(type).loadFunction; LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(type).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
...@@ -307,7 +308,8 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input) ...@@ -307,7 +308,8 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
ASSERT(area.x % outputBlockWidth == 0); ASSERT(area.x % outputBlockWidth == 0);
ASSERT(area.y % outputBlockHeight == 0); ASSERT(area.y % outputBlockHeight == 0);
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::ANGLEFormatSet &d3dFormatInfo =
d3d11::GetANGLEFormatSet(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE).loadFunction; LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
...@@ -358,9 +360,9 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset, ...@@ -358,9 +360,9 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
GLenum sourceInternalFormat = srcAttachment->getFormat().asSized(); GLenum sourceInternalFormat = srcAttachment->getFormat().asSized();
const auto &d3d11Format = const auto &d3d11Format =
d3d11::GetTextureFormatInfo(sourceInternalFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(sourceInternalFormat, mRenderer->getRenderer11DeviceCaps());
if (d3d11Format.formatSet.texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat) if (d3d11Format.texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat)
{ {
RenderTargetD3D *renderTarget = nullptr; RenderTargetD3D *renderTarget = nullptr;
gl::Error error = srcAttachment->getRenderTarget(&renderTarget); gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
...@@ -399,7 +401,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset, ...@@ -399,7 +401,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(mInternalFormat);
const auto &destD3D11Format = const auto &destD3D11Format =
d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
auto loadFunction = destD3D11Format.loadFunctions.at(destFormatInfo.type); auto loadFunction = destD3D11Format.loadFunctions.at(destFormatInfo.type);
if (loadFunction.requiresConversion) if (loadFunction.requiresConversion)
...@@ -564,7 +566,8 @@ gl::Error Image11::createStagingTexture() ...@@ -564,7 +566,8 @@ gl::Error Image11::createStagingTexture()
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0; desc.MiscFlags = 0;
if (d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()).dataInitializerFunction != NULL) if (d3d11::GetANGLEFormatSet(mInternalFormat, mRenderer->getRenderer11DeviceCaps())
.dataInitializerFunction != NULL)
{ {
std::vector<D3D11_SUBRESOURCE_DATA> initialData; std::vector<D3D11_SUBRESOURCE_DATA> initialData;
std::vector<std::vector<BYTE>> textureData; std::vector<std::vector<BYTE>> textureData;
...@@ -604,7 +607,8 @@ gl::Error Image11::createStagingTexture() ...@@ -604,7 +607,8 @@ gl::Error Image11::createStagingTexture()
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0; desc.MiscFlags = 0;
if (d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()).dataInitializerFunction != NULL) if (d3d11::GetANGLEFormatSet(mInternalFormat, mRenderer->getRenderer11DeviceCaps())
.dataInitializerFunction != NULL)
{ {
std::vector<D3D11_SUBRESOURCE_DATA> initialData; std::vector<D3D11_SUBRESOURCE_DATA> initialData;
std::vector<std::vector<BYTE>> textureData; std::vector<std::vector<BYTE>> textureData;
......
...@@ -196,8 +196,9 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac ...@@ -196,8 +196,9 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac
GLenum unsizedFormat = gl::GetInternalFormatInfo(destinationFormat).format; GLenum unsizedFormat = gl::GetInternalFormatInfo(destinationFormat).format;
GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType); GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType);
const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::ANGLEFormatSet &sourceFormatInfo =
DXGI_FORMAT srvFormat = sourceFormatInfo.formatSet.srvFormat; d3d11::GetANGLEFormatSet(sourceFormat, mRenderer->getRenderer11DeviceCaps());
DXGI_FORMAT srvFormat = sourceFormatInfo.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 = nullptr; ID3D11ShaderResourceView *bufferSRV = nullptr;
......
...@@ -190,9 +190,8 @@ const d3d11::ANGLEFormatSet &GetSurfaceFormatSet(bool depth, ...@@ -190,9 +190,8 @@ const d3d11::ANGLEFormatSet &GetSurfaceFormatSet(bool depth,
SwapChain11 *swapChain, SwapChain11 *swapChain,
Renderer11 *renderer) Renderer11 *renderer)
{ {
return d3d11::GetTextureFormatInfo(GetSurfaceRTFormat(depth, swapChain), return d3d11::GetANGLEFormatSet(GetSurfaceRTFormat(depth, swapChain),
renderer->getRenderer11DeviceCaps()) renderer->getRenderer11DeviceCaps());
.formatSet;
} }
} // anonymous namespace } // anonymous namespace
......
...@@ -3123,7 +3123,8 @@ gl::Error Renderer11::copyTexture(const gl::Texture *source, ...@@ -3123,7 +3123,8 @@ gl::Error Renderer11::copyTexture(const gl::Texture *source,
gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT) gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT)
{ {
const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(format, mRenderer11DeviceCaps); const d3d11::ANGLEFormatSet &formatInfo =
d3d11::GetANGLEFormatSet(format, mRenderer11DeviceCaps);
const gl::TextureCaps &textureCaps = getNativeTextureCaps().get(format); const gl::TextureCaps &textureCaps = getNativeTextureCaps().get(format);
GLuint supportedSamples = textureCaps.getNearestSamples(samples); GLuint supportedSamples = textureCaps.getNearestSamples(samples);
...@@ -3136,7 +3137,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3136,7 +3137,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.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;
...@@ -3147,9 +3148,9 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3147,9 +3148,9 @@ 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.rtvFormat != DXGI_FORMAT_UNKNOWN);
bindDSV = (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN); bindDSV = (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN);
bindSRV = (formatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN); bindSRV = (formatInfo.srvFormat != DXGI_FORMAT_UNKNOWN);
desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) | desc.BindFlags = (bindRTV ? D3D11_BIND_RENDER_TARGET : 0) |
(bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) | (bindDSV ? D3D11_BIND_DEPTH_STENCIL : 0) |
...@@ -3171,7 +3172,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3171,7 +3172,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.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;
...@@ -3184,10 +3185,10 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3184,10 +3185,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.blitSRVFormat != formatInfo.srvFormat)
{ {
D3D11_SHADER_RESOURCE_VIEW_DESC blitSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC blitSRVDesc;
blitSRVDesc.Format = formatInfo.formatSet.blitSRVFormat; blitSRVDesc.Format = formatInfo.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;
...@@ -3216,7 +3217,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3216,7 +3217,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.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;
...@@ -3232,15 +3233,15 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3232,15 +3233,15 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result); return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result);
} }
*outRT = new TextureRenderTarget11(dsv, texture, srv, format, formatInfo.formatSet, *outRT = new TextureRenderTarget11(dsv, texture, srv, format, formatInfo, width, height,
width, height, 1, supportedSamples); 1, supportedSamples);
SafeRelease(dsv); SafeRelease(dsv);
} }
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.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;
...@@ -3261,9 +3262,8 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3261,9 +3262,8 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
mDeviceContext->ClearRenderTargetView(rtv, clearValues); mDeviceContext->ClearRenderTargetView(rtv, clearValues);
} }
*outRT = *outRT = new TextureRenderTarget11(rtv, texture, srv, blitSRV, format, formatInfo,
new TextureRenderTarget11(rtv, texture, srv, blitSRV, format, formatInfo.formatSet, width, height, 1, supportedSamples);
width, height, 1, supportedSamples);
SafeRelease(rtv); SafeRelease(rtv);
} }
...@@ -3278,10 +3278,10 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3278,10 +3278,10 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
} }
else else
{ {
*outRT = new TextureRenderTarget11( *outRT = new TextureRenderTarget11(static_cast<ID3D11RenderTargetView *>(nullptr), nullptr,
static_cast<ID3D11RenderTargetView *>(nullptr), nullptr, nullptr, nullptr, format, nullptr, nullptr, format,
d3d11::GetANGLEFormatSet(angle::Format::ID::NONE, mRenderer11DeviceCaps), width, height, d3d11::GetANGLEFormatSet(GL_NONE, mRenderer11DeviceCaps),
1, supportedSamples); width, height, 1, supportedSamples);
} }
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
...@@ -3517,7 +3517,8 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -3517,7 +3517,8 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
ASSERT(getNativeExtensions().pixelBufferObject); ASSERT(getNativeExtensions().pixelBufferObject);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
const d3d11::TextureFormat &d3d11FormatInfo = d3d11::GetTextureFormatInfo(internalFormat, mRenderer11DeviceCaps); const d3d11::ANGLEFormatSet &d3d11FormatInfo =
d3d11::GetANGLEFormatSet(internalFormat, mRenderer11DeviceCaps);
// sRGB formats do not work with D3D11 buffer SRVs // sRGB formats do not work with D3D11 buffer SRVs
if (internalFormatInfo.colorEncoding == GL_SRGB) if (internalFormatInfo.colorEncoding == GL_SRGB)
...@@ -3526,7 +3527,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -3526,7 +3527,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.rtvFormat == DXGI_FORMAT_UNKNOWN)
{ {
return false; return false;
} }
...@@ -3538,7 +3539,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -3538,7 +3539,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.format.glInternalFormat != internalFormat) if (d3d11FormatInfo.format.glInternalFormat != internalFormat)
{ {
return false; return false;
} }
......
...@@ -177,7 +177,8 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -177,7 +177,8 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe
releaseOffscreenColorBuffer(); releaseOffscreenColorBuffer();
const d3d11::TextureFormat &backbufferFormatInfo = d3d11::GetTextureFormatInfo(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::ANGLEFormatSet &backbufferFormatInfo = d3d11::GetANGLEFormatSet(
mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps());
// If the app passed in a share handle, open the resource // If the app passed in a share handle, open the resource
// See EGL_ANGLE_d3d_share_handle_client_buffer // See EGL_ANGLE_d3d_share_handle_client_buffer
...@@ -209,7 +210,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -209,7 +210,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.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");
...@@ -225,7 +226,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -225,7 +226,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.texFormat;
offscreenTextureDesc.MipLevels = 1; offscreenTextureDesc.MipLevels = 1;
offscreenTextureDesc.ArraySize = 1; offscreenTextureDesc.ArraySize = 1;
offscreenTextureDesc.SampleDesc.Count = 1; offscreenTextureDesc.SampleDesc.Count = 1;
...@@ -283,7 +284,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -283,7 +284,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.rtvFormat;
offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; offscreenRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
offscreenRTVDesc.Texture2D.MipSlice = 0; offscreenRTVDesc.Texture2D.MipSlice = 0;
...@@ -292,7 +293,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(int backbufferWidth, int backbuffe ...@@ -292,7 +293,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.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);
...@@ -333,13 +334,13 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -333,13 +334,13 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe
if (mDepthBufferFormat != GL_NONE) if (mDepthBufferFormat != GL_NONE)
{ {
const d3d11::TextureFormat &depthBufferFormatInfo = const d3d11::ANGLEFormatSet &depthBufferFormatInfo =
d3d11::GetTextureFormatInfo(mDepthBufferFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(mDepthBufferFormat, mRenderer->getRenderer11DeviceCaps());
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.texFormat;
depthStencilTextureDesc.MipLevels = 1; depthStencilTextureDesc.MipLevels = 1;
depthStencilTextureDesc.ArraySize = 1; depthStencilTextureDesc.ArraySize = 1;
depthStencilTextureDesc.SampleDesc.Count = 1; depthStencilTextureDesc.SampleDesc.Count = 1;
...@@ -347,7 +348,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -347,7 +348,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.srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; depthStencilTextureDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
} }
...@@ -375,7 +376,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -375,7 +376,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.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;
...@@ -384,10 +385,10 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(int backbufferWidth, int backbuffe ...@@ -384,10 +385,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.srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSRVDesc;
depthStencilSRVDesc.Format = depthBufferFormatInfo.formatSet.srvFormat; depthStencilSRVDesc.Format = depthBufferFormatInfo.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);
......
...@@ -49,8 +49,7 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer, ...@@ -49,8 +49,7 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer,
: mRenderer(renderer), : mRenderer(renderer),
mTopLevel(0), mTopLevel(0),
mMipLevels(0), mMipLevels(0),
mFormatInfo( mFormatInfo(d3d11::GetANGLEFormatSet(internalFormat, mRenderer->getRenderer11DeviceCaps())),
d3d11::GetTextureFormatInfo(internalFormat, mRenderer->getRenderer11DeviceCaps())),
mTextureWidth(0), mTextureWidth(0),
mTextureHeight(0), mTextureHeight(0),
mTextureDepth(0), mTextureDepth(0),
...@@ -82,17 +81,17 @@ DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat, ...@@ -82,17 +81,17 @@ DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat,
{ {
UINT bindFlags = 0; UINT bindFlags = 0;
const d3d11::TextureFormat &formatInfo = const d3d11::ANGLEFormatSet &formatInfo =
d3d11::GetTextureFormatInfo(internalFormat, renderer11DeviceCaps); d3d11::GetANGLEFormatSet(internalFormat, renderer11DeviceCaps);
if (formatInfo.formatSet.srvFormat != DXGI_FORMAT_UNKNOWN) if (formatInfo.srvFormat != DXGI_FORMAT_UNKNOWN)
{ {
bindFlags |= D3D11_BIND_SHADER_RESOURCE; bindFlags |= D3D11_BIND_SHADER_RESOURCE;
} }
if (formatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) if (formatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
bindFlags |= D3D11_BIND_DEPTH_STENCIL; bindFlags |= D3D11_BIND_DEPTH_STENCIL;
} }
if (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN && renderTarget) if (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN && renderTarget)
{ {
bindFlags |= D3D11_BIND_RENDER_TARGET; bindFlags |= D3D11_BIND_RENDER_TARGET;
} }
...@@ -107,12 +106,11 @@ DWORD TextureStorage11::GetTextureMiscFlags(GLenum internalFormat, ...@@ -107,12 +106,11 @@ DWORD TextureStorage11::GetTextureMiscFlags(GLenum internalFormat,
{ {
UINT miscFlags = 0; UINT miscFlags = 0;
const d3d11::TextureFormat &formatInfo = const d3d11::ANGLEFormatSet &formatInfo =
d3d11::GetTextureFormatInfo(internalFormat, renderer11DeviceCaps); d3d11::GetANGLEFormatSet(internalFormat, renderer11DeviceCaps);
if (renderTarget && levels > 1) if (renderTarget && levels > 1)
{ {
const d3d11::DXGIFormat &dxgiFormatInfo = const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(formatInfo.texFormat);
d3d11::GetDXGIFormatInfo(formatInfo.formatSet.texFormat);
if (dxgiFormatInfo.nativeMipmapSupport(renderer11DeviceCaps.featureLevel)) if (dxgiFormatInfo.nativeMipmapSupport(renderer11DeviceCaps.featureLevel))
{ {
...@@ -246,8 +244,7 @@ gl::Error TextureStorage11::getCachedOrCreateSRV(const SRVKey &key, ...@@ -246,8 +244,7 @@ gl::Error TextureStorage11::getCachedOrCreateSRV(const SRVKey &key,
} }
ID3D11ShaderResourceView *srv = nullptr; ID3D11ShaderResourceView *srv = nullptr;
DXGI_FORMAT format = DXGI_FORMAT format = (key.swizzle ? mFormatInfo.swizzle.srvFormat : mFormatInfo.srvFormat);
(key.swizzle ? mFormatInfo.formatSet.swizzle.srvFormat : mFormatInfo.formatSet.srvFormat);
ANGLE_TRY(createSRV(key.baseLevel, key.mipLevels, format, texture, &srv)); ANGLE_TRY(createSRV(key.baseLevel, key.mipLevels, format, texture, &srv));
mSrvCache.insert(std::make_pair(key, srv)); mSrvCache.insert(std::make_pair(key, srv));
...@@ -268,8 +265,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel, ...@@ -268,8 +265,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel,
if (!levelSRVs[mipLevel]) if (!levelSRVs[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] && mFormatInfo.srvFormat == mFormatInfo.blitSRVFormat)
mFormatInfo.formatSet.srvFormat == mFormatInfo.formatSet.blitSRVFormat)
{ {
levelSRVs[mipLevel] = otherLevelSRVs[mipLevel]; levelSRVs[mipLevel] = otherLevelSRVs[mipLevel];
levelSRVs[mipLevel]->AddRef(); levelSRVs[mipLevel]->AddRef();
...@@ -284,7 +280,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel, ...@@ -284,7 +280,7 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel,
} }
DXGI_FORMAT resourceFormat = DXGI_FORMAT resourceFormat =
blitSRV ? mFormatInfo.formatSet.blitSRVFormat : mFormatInfo.formatSet.srvFormat; blitSRV ? mFormatInfo.blitSRVFormat : mFormatInfo.srvFormat;
error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]); error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]);
if (error.isError()) if (error.isError())
{ {
...@@ -331,7 +327,7 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel, ...@@ -331,7 +327,7 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel,
const d3d11::ANGLEFormatSet &TextureStorage11::getFormatSet() const const d3d11::ANGLEFormatSet &TextureStorage11::getFormatSet() const
{ {
return mFormatInfo.formatSet; return mFormatInfo;
} }
gl::Error TextureStorage11::generateSwizzles(const gl::SwizzleState &swizzleTarget) gl::Error TextureStorage11::generateSwizzles(const gl::SwizzleState &swizzleTarget)
...@@ -427,8 +423,8 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, ...@@ -427,8 +423,8 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture,
ASSERT(dstTexture); ASSERT(dstTexture);
const d3d11::DXGIFormatSize &dxgiFormatSizeInfo = const d3d11::DXGIFormatSize &dxgiFormatSizeInfo =
d3d11::GetDXGIFormatSizeInfo(mFormatInfo.formatSet.texFormat); d3d11::GetDXGIFormatSizeInfo(mFormatInfo.texFormat);
if (!fullCopy && mFormatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) if (!fullCopy && mFormatInfo.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();
...@@ -496,7 +492,7 @@ gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource *dstTexture, ...@@ -496,7 +492,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(mFormatInfo.formatSet.dsvFormat == DXGI_FORMAT_UNKNOWN); ASSERT(mFormatInfo.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;
...@@ -656,10 +652,10 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ...@@ -656,10 +652,10 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
unpack.skipRows, unpack.skipPixels, index.is3D()), unpack.skipRows, unpack.skipPixels, index.is3D()),
srcSkipBytes); srcSkipBytes);
const d3d11::TextureFormat &d3d11Format = d3d11::GetTextureFormatInfo( const d3d11::ANGLEFormatSet &d3d11Format =
image->getInternalFormat(), mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(image->getInternalFormat(), mRenderer->getRenderer11DeviceCaps());
const d3d11::DXGIFormatSize &dxgiFormatInfo = const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3d11Format.formatSet.texFormat); d3d11::GetDXGIFormatSizeInfo(d3d11Format.texFormat);
const size_t outputPixelSize = dxgiFormatInfo.pixelBytes; const size_t outputPixelSize = dxgiFormatInfo.pixelBytes;
...@@ -770,7 +766,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, ...@@ -770,7 +766,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer,
mSwizzleRenderTargets[i] = nullptr; mSwizzleRenderTargets[i] = nullptr;
} }
d3d11::MakeValidSize(false, mFormatInfo.formatSet.texFormat, &width, &height, &mTopLevel); d3d11::MakeValidSize(false, mFormatInfo.texFormat, &width, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = width; mTextureWidth = width;
mTextureHeight = height; mTextureHeight = height;
...@@ -1098,7 +1094,7 @@ gl::Error TextureStorage11_2D::ensureTextureExists(int mipLevels) ...@@ -1098,7 +1094,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 = mFormatInfo.formatSet.texFormat; desc.Format = mFormatInfo.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;
...@@ -1179,7 +1175,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1179,7 +1175,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 = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + level; rtvDesc.Texture2D.MipSlice = mTopLevel + level;
...@@ -1207,10 +1203,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1207,10 +1203,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
if (mFormatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) if (mFormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + level; rtvDesc.Texture2D.MipSlice = mTopLevel + level;
...@@ -1237,10 +1233,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -1237,10 +1233,10 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
ASSERT(mFormatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(mFormatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN);
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = mFormatInfo.formatSet.dsvFormat; dsvDesc.Format = mFormatInfo.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;
...@@ -1333,7 +1329,7 @@ gl::Error TextureStorage11_2D::getSwizzleTexture(ID3D11Resource **outTexture) ...@@ -1333,7 +1329,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 = mFormatInfo.formatSet.swizzle.texFormat; desc.Format = mFormatInfo.swizzle.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;
...@@ -1374,7 +1370,7 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render ...@@ -1374,7 +1370,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 = mFormatInfo.formatSet.swizzle.rtvFormat; rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
...@@ -1674,7 +1670,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleTexture(ID3D11Resource **outTextu ...@@ -1674,7 +1670,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 = mFormatInfo.formatSet.swizzle.texFormat; desc.Format = mFormatInfo.swizzle.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;
...@@ -1716,7 +1712,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel, ...@@ -1716,7 +1712,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 = mFormatInfo.formatSet.swizzle.rtvFormat; rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
...@@ -1845,7 +1841,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer11 *renderer, ...@@ -1845,7 +1841,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, mFormatInfo.formatSet.texFormat, &size, &height, &mTopLevel); d3d11::MakeValidSize(false, mFormatInfo.texFormat, &size, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = size; mTextureWidth = size;
...@@ -2208,7 +2204,7 @@ gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels) ...@@ -2208,7 +2204,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 = mFormatInfo.formatSet.texFormat; desc.Format = mFormatInfo.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;
...@@ -2300,7 +2296,7 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2300,7 +2296,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 = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.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;
...@@ -2332,16 +2328,15 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2332,16 +2328,15 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
} }
ID3D11ShaderResourceView *srv = nullptr; ID3D11ShaderResourceView *srv = nullptr;
error = createRenderTargetSRV(texture, index, mFormatInfo.formatSet.srvFormat, &srv); error = createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
ID3D11ShaderResourceView *blitSRV = nullptr; ID3D11ShaderResourceView *blitSRV = nullptr;
if (mFormatInfo.formatSet.blitSRVFormat != mFormatInfo.formatSet.srvFormat) if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat)
{ {
error = createRenderTargetSRV(texture, index, mFormatInfo.formatSet.blitSRVFormat, error = createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV);
&blitSRV);
if (error.isError()) if (error.isError())
{ {
SafeRelease(srv); SafeRelease(srv);
...@@ -2356,10 +2351,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2356,10 +2351,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(srv, "TexStorageCube.RenderTargetSRV"); d3d11::SetDebugName(srv, "TexStorageCube.RenderTargetSRV");
if (mFormatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) if (mFormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.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;
...@@ -2390,10 +2385,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index, ...@@ -2390,10 +2385,10 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
SafeRelease(srv); SafeRelease(srv);
SafeRelease(blitSRV); SafeRelease(blitSRV);
} }
else if (mFormatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN) else if (mFormatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = mFormatInfo.formatSet.dsvFormat; dsvDesc.Format = mFormatInfo.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;
...@@ -2516,7 +2511,7 @@ gl::Error TextureStorage11_Cube::getSwizzleTexture(ID3D11Resource **outTexture) ...@@ -2516,7 +2511,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 = mFormatInfo.formatSet.swizzle.texFormat; desc.Format = mFormatInfo.swizzle.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;
...@@ -2558,7 +2553,7 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel, ...@@ -2558,7 +2553,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 = mFormatInfo.formatSet.swizzle.rtvFormat; rtvDesc.Format = mFormatInfo.swizzle.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;
...@@ -2607,7 +2602,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer, ...@@ -2607,7 +2602,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer,
} }
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mFormatInfo.formatSet.texFormat, &width, &height, &mTopLevel); d3d11::MakeValidSize(false, mFormatInfo.texFormat, &width, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = width; mTextureWidth = width;
...@@ -2747,7 +2742,7 @@ gl::Error TextureStorage11_3D::getResource(ID3D11Resource **outResource) ...@@ -2747,7 +2742,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 = mFormatInfo.formatSet.texFormat; desc.Format = mFormatInfo.texFormat;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = getBindFlags(); desc.BindFlags = getBindFlags();
desc.CPUAccessFlags = 0; desc.CPUAccessFlags = 0;
...@@ -2810,7 +2805,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2810,7 +2805,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(mFormatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(mFormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
if (!index.hasLayer()) if (!index.hasLayer())
{ {
...@@ -2840,7 +2835,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2840,7 +2835,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 = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.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;
...@@ -2896,7 +2891,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend ...@@ -2896,7 +2891,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 = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.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;
...@@ -2946,7 +2941,7 @@ gl::Error TextureStorage11_3D::getSwizzleTexture(ID3D11Resource **outTexture) ...@@ -2946,7 +2941,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 = mFormatInfo.formatSet.swizzle.texFormat; desc.Format = mFormatInfo.swizzle.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;
...@@ -2985,7 +2980,7 @@ gl::Error TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel, ID3D11Render ...@@ -2985,7 +2980,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 = mFormatInfo.formatSet.swizzle.rtvFormat; rtvDesc.Format = mFormatInfo.swizzle.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;
...@@ -3034,7 +3029,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer11 *renderer, ...@@ -3034,7 +3029,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer11 *renderer,
} }
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mFormatInfo.formatSet.texFormat, &width, &height, &mTopLevel); d3d11::MakeValidSize(false, mFormatInfo.texFormat, &width, &height, &mTopLevel);
mMipLevels = mTopLevel + levels; mMipLevels = mTopLevel + levels;
mTextureWidth = width; mTextureWidth = width;
...@@ -3175,7 +3170,7 @@ gl::Error TextureStorage11_2DArray::getResource(ID3D11Resource **outResource) ...@@ -3175,7 +3170,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 = mFormatInfo.formatSet.texFormat; desc.Format = mFormatInfo.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;
...@@ -3286,16 +3281,15 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3286,16 +3281,15 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
return error; return error;
} }
ID3D11ShaderResourceView *srv; ID3D11ShaderResourceView *srv;
error = createRenderTargetSRV(texture, index, mFormatInfo.formatSet.srvFormat, &srv); error = createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
ID3D11ShaderResourceView *blitSRV; ID3D11ShaderResourceView *blitSRV;
if (mFormatInfo.formatSet.blitSRVFormat != mFormatInfo.formatSet.srvFormat) if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat)
{ {
error = createRenderTargetSRV(texture, index, mFormatInfo.formatSet.blitSRVFormat, error = createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV);
&blitSRV);
if (error.isError()) if (error.isError())
{ {
SafeRelease(srv); SafeRelease(srv);
...@@ -3310,10 +3304,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3310,10 +3304,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
d3d11::SetDebugName(srv, "TexStorage2DArray.RenderTargetSRV"); d3d11::SetDebugName(srv, "TexStorage2DArray.RenderTargetSRV");
if (mFormatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) if (mFormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = mFormatInfo.formatSet.rtvFormat; rtvDesc.Format = mFormatInfo.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;
...@@ -3346,10 +3340,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index, ...@@ -3346,10 +3340,10 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
} }
else else
{ {
ASSERT(mFormatInfo.formatSet.dsvFormat != DXGI_FORMAT_UNKNOWN); ASSERT(mFormatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN);
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
dsvDesc.Format = mFormatInfo.formatSet.dsvFormat; dsvDesc.Format = mFormatInfo.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;
...@@ -3397,7 +3391,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTextur ...@@ -3397,7 +3391,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 = mFormatInfo.formatSet.swizzle.texFormat; desc.Format = mFormatInfo.swizzle.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;
...@@ -3439,7 +3433,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel, ...@@ -3439,7 +3433,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 = mFormatInfo.formatSet.swizzle.rtvFormat; rtvDesc.Format = mFormatInfo.swizzle.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,7 +107,7 @@ class TextureStorage11 : public TextureStorage ...@@ -107,7 +107,7 @@ class TextureStorage11 : public TextureStorage
int mTopLevel; int mTopLevel;
unsigned int mMipLevels; unsigned int mMipLevels;
const d3d11::TextureFormat &mFormatInfo; const d3d11::ANGLEFormatSet &mFormatInfo;
unsigned int mTextureWidth; unsigned int mTextureWidth;
unsigned int mTextureHeight; unsigned int mTextureHeight;
unsigned int mTextureDepth; unsigned int mTextureDepth;
......
...@@ -43,11 +43,11 @@ namespace rx ...@@ -43,11 +43,11 @@ namespace rx
namespace d3d11 namespace d3d11
{{ {{
const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, const ANGLEFormatSet &GetANGLEFormatSet(GLenum internalFormat,
const Renderer11DeviceCaps &deviceCaps) const Renderer11DeviceCaps &deviceCaps)
{{ {{
// clang-format off // clang-format off
switch (formatID) switch (internalFormat)
{{ {{
{angle_format_info_cases} {angle_format_info_cases}
default: default:
...@@ -60,23 +60,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -60,23 +60,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
return defaultInfo; return defaultInfo;
}} }}
const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
const Renderer11DeviceCaps &deviceCaps)
{{
// clang-format off
switch (internalFormat)
{{
{texture_format_info_cases}
default:
UNREACHABLE();
break;
}}
// clang-format on
static const TextureFormat defaultInfo(GL_NONE, angle::Format::ID::NONE, nullptr, deviceCaps);
return defaultInfo;
}} // GetTextureFormatInfo
}} // namespace d3d11 }} // namespace d3d11
}} // namespace rx }} // namespace rx
...@@ -157,17 +140,18 @@ def get_internal_format_initializer(internal_format, angle_format): ...@@ -157,17 +140,18 @@ def get_internal_format_initializer(internal_format, angle_format):
return internal_format_initializer return internal_format_initializer
def get_swizzle_format_id(angle_format): def get_swizzle_format_id(internal_format, angle_format):
angle_format_id = angle_format["formatName"] angle_format_id = angle_format["formatName"]
if angle_format_id == 'NONE': if (internal_format == 'GL_NONE') or (angle_format_id == 'NONE'):
return 'NONE' return 'GL_NONE'
elif 'swizzleFormat' in angle_format: elif 'swizzleFormat' in angle_format:
# For some special formats like compressed formats that don't have a clearly defined number # For some special formats like compressed formats that don't have a clearly defined number
# of bits per channel, swizzle format needs to be specified manually. # of bits per channel, swizzle format needs to be specified manually.
return angle_format['swizzleFormat'] return angle_format['swizzleFormat']
if 'bits' not in angle_format: if 'bits' not in angle_format:
raise ValueError('no bits information for determining swizzleformat for format: ' + angle_format_id) raise ValueError('no bits information for determining swizzleformat for format: ' + internal_format)
bits = angle_format['bits'] bits = angle_format['bits']
max_component_bits = max(bits.itervalues()) max_component_bits = max(bits.itervalues())
...@@ -176,7 +160,7 @@ def get_swizzle_format_id(angle_format): ...@@ -176,7 +160,7 @@ def get_swizzle_format_id(angle_format):
# The format itself can be used for swizzles if it can be accessed as a render target and # The format itself can be used for swizzles if it can be accessed as a render target and
# sampled and the bit count for all 4 channels is the same. # sampled and the bit count for all 4 channels is the same.
if "rtvFormat" in angle_format and "srvFormat" in angle_format and not channels_different and len(angle_format['channels']) == 4: if "rtvFormat" in angle_format and "srvFormat" in angle_format and not channels_different and len(angle_format['channels']) == 4:
return angle_format_id return angle_format["glInternalFormat"] if "glInternalFormat" in angle_format else internal_format
b = int(math.ceil(float(max_component_bits) / 8) * 8) b = int(math.ceil(float(max_component_bits) / 8) * 8)
...@@ -184,84 +168,39 @@ def get_swizzle_format_id(angle_format): ...@@ -184,84 +168,39 @@ def get_swizzle_format_id(angle_format):
# defined component type. # defined component type.
if angle_format['channels'].find('d') >= 0: if angle_format['channels'].find('d') >= 0:
if b == 24 or b == 32: if b == 24 or b == 32:
return 'R32G32B32A32_FLOAT' return 'GL_RGBA32F'
if b == 16: if b == 16:
return 'R16G16B16A16_UNORM' return 'GL_RGBA16_EXT'
if b == 24: if b == 24:
raise ValueError('unexpected 24-bit format when determining swizzleformat for format: ' + angle_format_id) raise ValueError('unexpected 24-bit format when determining swizzleformat for format: ' + internal_format)
if 'componentType' not in angle_format: if 'componentType' not in angle_format:
raise ValueError('no component type information for determining swizzleformat for format: ' + angle_format_id) raise ValueError('no component type information for determining swizzleformat for format: ' + internal_format)
component_type = angle_format['componentType'] component_type = angle_format['componentType']
swizzle = "GL_RGBA" + str(b)
if component_type == 'uint': if component_type == 'uint':
return 'R{}G{}B{}A{}_UINT'.format(b, b, b, b) swizzle += "I"
elif component_type == 'int': elif component_type == 'int':
return 'R{}G{}B{}A{}_SINT'.format(b, b, b, b) swizzle += "I"
elif component_type == 'unorm': elif component_type == 'unorm':
return 'R{}G{}B{}A{}_UNORM'.format(b, b, b, b) if (b == 16):
swizzle += "_EXT"
elif component_type == 'snorm': elif component_type == 'snorm':
return 'R{}G{}B{}A{}_SNORM'.format(b, b, b, b) swizzle += "_SNORM"
if (b == 16):
swizzle += "_EXT"
elif component_type == 'float': elif component_type == 'float':
return 'R{}G{}B{}A{}_FLOAT'.format(b, b, b, b) swizzle += "F"
if (b == 16):
swizzle += "_EXT"
else: else:
raise ValueError('could not determine swizzleformat based on componentType for format: ' + angle_format_id) raise ValueError('could not determine swizzleformat based on componentType for format: ' + internal_format)
def get_texture_format_item(idx, internal_format, requirements_fn, angle_format_id, json_data):
table_data = '';
angle_format = json_data[angle_format_id]
# TODO(jmadill): Remove this hack.
if requirements_fn != None and idx == 0 and 'fallbackFormat' in angle_format:
angle_format = json_data[angle_format['fallbackFormat']]
internal_format_initializer = get_internal_format_initializer(internal_format, angle_format) return swizzle
indent = ' '
if requirements_fn != None:
if idx == 0:
table_data += ' if (' + requirements_fn + ')\n'
else:
table_data += ' else if (' + requirements_fn + ')\n'
table_data += ' {\n'
indent += ' '
table_data += indent + 'static const TextureFormat info(internalFormat,\n'
table_data += indent + ' angle::Format::ID::' + angle_format_id + ',\n'
table_data += indent + ' ' + internal_format_initializer + ',\n'
table_data += indent + ' deviceCaps);\n'
table_data += indent + 'return info;\n'
if requirements_fn != None:
table_data += ' }\n'
return table_data
def parse_json_into_switch_texture_format_string(json_map, json_data):
table_data = ''
angle_format_map = {}
for internal_format_item in sorted(json_map.iteritems()):
internal_format = internal_format_item[0]
table_data += ' case ' + internal_format + ':\n'
table_data += ' {\n'
if isinstance(json_map[internal_format], basestring):
angle_format_id = json_map[internal_format]
table_data += get_texture_format_item(0, internal_format, None, angle_format_id, json_data)
else:
for idx, requirements_map in enumerate(sorted(json_map[internal_format].iteritems())):
angle_format_id = requirements_map[1]
table_data += get_texture_format_item(idx, internal_format, requirements_map[0], angle_format_id, json_data)
table_data += ' else\n'
table_data += ' {\n'
table_data += ' break;\n'
table_data += ' }\n'
table_data += ' }\n'
return table_data
def get_blit_srv_format(angle_format): def get_blit_srv_format(angle_format):
if 'channels' not in angle_format: if 'channels' not in angle_format:
...@@ -273,13 +212,15 @@ def get_blit_srv_format(angle_format): ...@@ -273,13 +212,15 @@ def get_blit_srv_format(angle_format):
format_entry_template = """{space}{{ format_entry_template = """{space}{{
{space} static const ANGLEFormatSet info(angle::Format::ID::{formatName}, {space} static const ANGLEFormatSet info({internalFormat},
{space} angle::Format::ID::{formatName},
{space} {texFormat}, {space} {texFormat},
{space} {srvFormat}, {space} {srvFormat},
{space} {rtvFormat}, {space} {rtvFormat},
{space} {dsvFormat}, {space} {dsvFormat},
{space} {blitSRVFormat}, {space} {blitSRVFormat},
{space} angle::Format::ID::{swizzleFormat}, {space} {swizzleFormat},
{space} {initializer},
{space} deviceCaps); {space} deviceCaps);
{space} return info; {space} return info;
{space}}} {space}}}
...@@ -287,24 +228,27 @@ format_entry_template = """{space}{{ ...@@ -287,24 +228,27 @@ format_entry_template = """{space}{{
split_format_entry_template = """{space} {condition} split_format_entry_template = """{space} {condition}
{space} {{ {space} {{
{space} static const ANGLEFormatSet info(angle::Format::ID::{formatName}, {space} static const ANGLEFormatSet info({internalFormat},
{space} angle::Format::ID::{formatName},
{space} {texFormat}, {space} {texFormat},
{space} {srvFormat}, {space} {srvFormat},
{space} {rtvFormat}, {space} {rtvFormat},
{space} {dsvFormat}, {space} {dsvFormat},
{space} {blitSRVFormat}, {space} {blitSRVFormat},
{space} angle::Format::ID::{swizzleFormat}, {space} {swizzleFormat},
{space} {initializer},
{space} deviceCaps); {space} deviceCaps);
{space} return info; {space} return info;
{space} }} {space} }}
""" """
def json_to_table_data(format_name, prefix, json): def json_to_table_data(internal_format, format_name, prefix, json):
table_data = "" table_data = ""
parsed = { parsed = {
"space": " ", "space": " ",
"internalFormat": internal_format,
"formatName": format_name, "formatName": format_name,
"texFormat": "DXGI_FORMAT_UNKNOWN", "texFormat": "DXGI_FORMAT_UNKNOWN",
"srvFormat": "DXGI_FORMAT_UNKNOWN", "srvFormat": "DXGI_FORMAT_UNKNOWN",
...@@ -318,7 +262,8 @@ def json_to_table_data(format_name, prefix, json): ...@@ -318,7 +262,8 @@ def json_to_table_data(format_name, prefix, json):
# Derived values. # Derived values.
parsed["blitSRVFormat"] = get_blit_srv_format(parsed) parsed["blitSRVFormat"] = get_blit_srv_format(parsed)
parsed["swizzleFormat"] = get_swizzle_format_id(parsed) parsed["swizzleFormat"] = get_swizzle_format_id(internal_format, parsed)
parsed["initializer"] = get_internal_format_initializer(internal_format, json)
if len(prefix) > 0: if len(prefix) > 0:
return split_format_entry_template.format(**parsed) return split_format_entry_template.format(**parsed)
...@@ -360,22 +305,24 @@ def parse_json_angle_format_case(format_name, angle_format, json_data): ...@@ -360,22 +305,24 @@ def parse_json_angle_format_case(format_name, angle_format, json_data):
else: else:
return supported_case, None, None return supported_case, None, None
def parse_json_into_switch_angle_format_string(json_data): def parse_json_into_switch_angle_format_string(json_map, json_data):
table_data = '' table_data = ''
for format_name, angle_format in sorted(json_data.iteritems()):
for internal_format, format_name in sorted(json_map.iteritems()):
angle_format = json_data[format_name]
supported_case, unsupported_case, support_test = parse_json_angle_format_case( supported_case, unsupported_case, support_test = parse_json_angle_format_case(
format_name, angle_format, json_data) format_name, angle_format, json_data)
table_data += ' case angle::Format::ID::' + format_name + ':\n' table_data += ' case ' + internal_format + ':\n'
if support_test != None: if support_test != None:
table_data += " {\n" table_data += " {\n"
table_data += json_to_table_data(format_name, "if (" + support_test + ")", supported_case) table_data += json_to_table_data(internal_format, format_name, "if (" + support_test + ")", supported_case)
table_data += json_to_table_data(format_name, "else", unsupported_case) table_data += json_to_table_data(internal_format, format_name, "else", unsupported_case)
table_data += " }\n" table_data += " }\n"
else: else:
table_data += json_to_table_data(format_name, "", supported_case) table_data += json_to_table_data(internal_format, format_name, "", supported_case)
return table_data return table_data
...@@ -397,11 +344,9 @@ with open('texture_format_map.json') as texture_format_map_file: ...@@ -397,11 +344,9 @@ with open('texture_format_map.json') as texture_format_map_file:
json_map = json.loads(texture_format_map, object_pairs_hook=reject_duplicate_keys) json_map = json.loads(texture_format_map, object_pairs_hook=reject_duplicate_keys)
json_data = json.loads(texture_format_data, object_pairs_hook=reject_duplicate_keys) json_data = json.loads(texture_format_data, object_pairs_hook=reject_duplicate_keys)
texture_format_cases = parse_json_into_switch_texture_format_string(json_map, json_data) angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data)
angle_format_cases = parse_json_into_switch_angle_format_string(json_data)
output_cpp = template_texture_format_table_autogen_cpp.format( output_cpp = template_texture_format_table_autogen_cpp.format(
copyright_year=date.today().year, copyright_year=date.today().year,
texture_format_info_cases=texture_format_cases,
angle_format_info_cases=angle_format_cases) angle_format_info_cases=angle_format_cases)
with open('texture_format_table_autogen.cpp', 'wt') as out_file: with open('texture_format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_cpp)
......
...@@ -349,8 +349,8 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum ...@@ -349,8 +349,8 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
gl::TextureCaps textureCaps; gl::TextureCaps textureCaps;
DXGISupportHelper support(device, renderer11DeviceCaps.featureLevel); DXGISupportHelper support(device, renderer11DeviceCaps.featureLevel);
const d3d11::TextureFormat &formatInfo = const d3d11::ANGLEFormatSet &formatInfo =
d3d11::GetTextureFormatInfo(internalFormat, renderer11DeviceCaps); d3d11::GetANGLEFormatSet(internalFormat, renderer11DeviceCaps);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
...@@ -364,21 +364,21 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum ...@@ -364,21 +364,21 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLint maxClientVersion, GLenum
} }
} }
textureCaps.texturable = support.query(formatInfo.formatSet.texFormat, texSupportMask); textureCaps.texturable = support.query(formatInfo.texFormat, texSupportMask);
textureCaps.filterable = textureCaps.filterable =
support.query(formatInfo.formatSet.srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE); support.query(formatInfo.srvFormat, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE);
textureCaps.renderable = textureCaps.renderable =
(support.query(formatInfo.formatSet.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) || (support.query(formatInfo.rtvFormat, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) ||
(support.query(formatInfo.formatSet.dsvFormat, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)); (support.query(formatInfo.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.dsvFormat != DXGI_FORMAT_UNKNOWN)
{ {
renderFormat = formatInfo.formatSet.dsvFormat; renderFormat = formatInfo.dsvFormat;
} }
else if (formatInfo.formatSet.rtvFormat != DXGI_FORMAT_UNKNOWN) else if (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
{ {
renderFormat = formatInfo.formatSet.rtvFormat; renderFormat = formatInfo.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))
...@@ -1368,11 +1368,12 @@ void GenerateInitialTextureData(GLint internalFormat, ...@@ -1368,11 +1368,12 @@ void GenerateInitialTextureData(GLint internalFormat,
std::vector<D3D11_SUBRESOURCE_DATA> *outSubresourceData, std::vector<D3D11_SUBRESOURCE_DATA> *outSubresourceData,
std::vector<std::vector<BYTE>> *outData) std::vector<std::vector<BYTE>> *outData)
{ {
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(internalFormat, renderer11DeviceCaps); const d3d11::ANGLEFormatSet &d3dFormatInfo =
d3d11::GetANGLEFormatSet(internalFormat, renderer11DeviceCaps);
ASSERT(d3dFormatInfo.dataInitializerFunction != NULL); ASSERT(d3dFormatInfo.dataInitializerFunction != NULL);
const d3d11::DXGIFormatSize &dxgiFormatInfo = const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.formatSet.texFormat); d3d11::GetDXGIFormatSizeInfo(d3dFormatInfo.texFormat);
outSubresourceData->resize(mipLevels); outSubresourceData->resize(mipLevels);
outData->resize(mipLevels); outData->resize(mipLevels);
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
"srvFormat": "DXGI_FORMAT_BC1_UNORM", "srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "R8G8B8A8_UNORM", "swizzleFormat": "GL_RGBA8",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
}, },
"BC2_UNORM": { "BC2_UNORM": {
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
"srvFormat": "DXGI_FORMAT_BC2_UNORM", "srvFormat": "DXGI_FORMAT_BC2_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "R8G8B8A8_UNORM", "swizzleFormat": "GL_RGBA8",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE" "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"
}, },
"BC3_UNORM": { "BC3_UNORM": {
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
"srvFormat": "DXGI_FORMAT_BC3_UNORM", "srvFormat": "DXGI_FORMAT_BC3_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "R8G8B8A8_UNORM", "swizzleFormat": "GL_RGBA8",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE" "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"
}, },
"D24_UNORM_S8_UINT": { "D24_UNORM_S8_UINT": {
......
{ {
"GL_ALPHA": { "GL_ALPHA": "A8_UNORM",
"OnlyFL10Plus(deviceCaps)": "A8_UNORM",
"OnlyFL9_3(deviceCaps)": "A8_UNORM"
},
"GL_ALPHA16F_EXT": "R16G16B16A16_FLOAT", "GL_ALPHA16F_EXT": "R16G16B16A16_FLOAT",
"GL_ALPHA32F_EXT": "R32G32B32A32_FLOAT", "GL_ALPHA32F_EXT": "R32G32B32A32_FLOAT",
"GL_ALPHA8_EXT": { "GL_ALPHA8_EXT": "A8_UNORM",
"OnlyFL10Plus(deviceCaps)": "A8_UNORM",
"OnlyFL9_3(deviceCaps)": "A8_UNORM"
},
"GL_BGR565_ANGLEX": "B5G6R5_UNORM", "GL_BGR565_ANGLEX": "B5G6R5_UNORM",
"GL_BGR5_A1_ANGLEX": "B8G8R8A8_UNORM", "GL_BGR5_A1_ANGLEX": "B8G8R8A8_UNORM",
"GL_BGRA4_ANGLEX": "B8G8R8A8_UNORM", "GL_BGRA4_ANGLEX": "B8G8R8A8_UNORM",
"GL_BGRA8_EXT": "B8G8R8A8_UNORM", "GL_BGRA8_EXT": "B8G8R8A8_UNORM",
"GL_BGRA_EXT": "B8G8R8A8_UNORM", "GL_BGRA_EXT": "B8G8R8A8_UNORM",
"GL_COMPRESSED_R11_EAC": { "GL_COMPRESSED_R11_EAC": "R8_UNORM",
"OnlyFL10Plus(deviceCaps)": "R8_UNORM" "GL_COMPRESSED_RG11_EAC": "R8G8_UNORM",
}, "GL_COMPRESSED_RGB8_ETC2": "R8G8B8A8_UNORM",
"GL_COMPRESSED_RG11_EAC": { "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": "R8G8B8A8_UNORM",
"OnlyFL10Plus(deviceCaps)": "R8G8_UNORM" "GL_COMPRESSED_RGBA8_ETC2_EAC": "R8G8B8A8_UNORM",
},
"GL_COMPRESSED_RGB8_ETC2": {
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
},
"GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": {
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
},
"GL_COMPRESSED_RGBA8_ETC2_EAC": {
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
},
"GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": "BC1_UNORM", "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": "BC1_UNORM",
"GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": "BC2_UNORM", "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": "BC2_UNORM",
"GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": "BC3_UNORM", "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": "BC3_UNORM",
...@@ -47,12 +31,8 @@ ...@@ -47,12 +31,8 @@
"GL_COMPRESSED_RGBA_ASTC_12x10_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_12x10_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_12x12_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_12x12_KHR": "NONE",
"GL_COMPRESSED_RGB_S3TC_DXT1_EXT": "BC1_UNORM", "GL_COMPRESSED_RGB_S3TC_DXT1_EXT": "BC1_UNORM",
"GL_COMPRESSED_SIGNED_R11_EAC": { "GL_COMPRESSED_SIGNED_R11_EAC": "R8_SNORM",
"OnlyFL10Plus(deviceCaps)": "R8_SNORM" "GL_COMPRESSED_SIGNED_RG11_EAC": "R8G8_SNORM",
},
"GL_COMPRESSED_SIGNED_RG11_EAC": {
"OnlyFL10Plus(deviceCaps)": "R8G8_SNORM"
},
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR": "NONE",
...@@ -67,36 +47,15 @@ ...@@ -67,36 +47,15 @@
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC": { "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC": "R8G8B8A8_UNORM_SRGB",
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB" "GL_COMPRESSED_SRGB8_ETC2": "R8G8B8A8_UNORM_SRGB",
}, "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": "R8G8B8A8_UNORM_SRGB",
"GL_COMPRESSED_SRGB8_ETC2": { "GL_DEPTH24_STENCIL8": "D24_UNORM_S8_UINT",
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB" "GL_DEPTH32F_STENCIL8": "D32_FLOAT_S8X24_UINT",
}, "GL_DEPTH_COMPONENT16": "D16_UNORM",
"GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": { "GL_DEPTH_COMPONENT24": "D24_UNORM_S8_UINT",
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB" "GL_DEPTH_COMPONENT32F": "D32_FLOAT",
}, "GL_DEPTH_COMPONENT32_OES": "D24_UNORM_S8_UINT",
"GL_DEPTH24_STENCIL8": {
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_DEPTH32F_STENCIL8": {
"OnlyFL10Plus(deviceCaps)": "D32_FLOAT_S8X24_UINT"
},
"GL_DEPTH_COMPONENT16": {
"OnlyFL10Plus(deviceCaps)": "D16_UNORM",
"OnlyFL9_3(deviceCaps)": "D16_UNORM"
},
"GL_DEPTH_COMPONENT24": {
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_DEPTH_COMPONENT32F": {
"OnlyFL10Plus(deviceCaps)": "D32_FLOAT"
},
"GL_DEPTH_COMPONENT32_OES": {
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_ETC1_RGB8_OES": "R8G8B8A8_UNORM", "GL_ETC1_RGB8_OES": "R8G8B8A8_UNORM",
"GL_ETC1_RGB8_LOSSY_DECODE_ANGLE": "BC1_UNORM", "GL_ETC1_RGB8_LOSSY_DECODE_ANGLE": "BC1_UNORM",
"GL_LUMINANCE": "R8G8B8A8_UNORM", "GL_LUMINANCE": "R8G8B8A8_UNORM",
...@@ -138,14 +97,8 @@ ...@@ -138,14 +97,8 @@
"GL_RGB32F": "R32G32B32A32_FLOAT", "GL_RGB32F": "R32G32B32A32_FLOAT",
"GL_RGB32I": "R32G32B32A32_SINT", "GL_RGB32I": "R32G32B32A32_SINT",
"GL_RGB32UI": "R32G32B32A32_UINT", "GL_RGB32UI": "R32G32B32A32_UINT",
"GL_RGB565": { "GL_RGB565": "B5G6R5_UNORM",
"SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)": "B5G6R5_UNORM", "GL_RGB5_A1": "B5G5R5A1_UNORM",
"!SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)": "B5G6R5_UNORM"
},
"GL_RGB5_A1": {
"SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)": "B5G5R5A1_UNORM",
"!SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)": "B5G5R5A1_UNORM"
},
"GL_RGB8": "R8G8B8A8_UNORM", "GL_RGB8": "R8G8B8A8_UNORM",
"GL_RGB8I": "R8G8B8A8_SINT", "GL_RGB8I": "R8G8B8A8_SINT",
"GL_RGB8UI": "R8G8B8A8_UINT", "GL_RGB8UI": "R8G8B8A8_UINT",
...@@ -158,20 +111,14 @@ ...@@ -158,20 +111,14 @@
"GL_RGBA32F": "R32G32B32A32_FLOAT", "GL_RGBA32F": "R32G32B32A32_FLOAT",
"GL_RGBA32I": "R32G32B32A32_SINT", "GL_RGBA32I": "R32G32B32A32_SINT",
"GL_RGBA32UI": "R32G32B32A32_UINT", "GL_RGBA32UI": "R32G32B32A32_UINT",
"GL_RGBA4": { "GL_RGBA4": "B4G4R4A4_UNORM",
"SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)": "B4G4R4A4_UNORM",
"!SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)": "B4G4R4A4_UNORM"
},
"GL_RGBA8": "R8G8B8A8_UNORM", "GL_RGBA8": "R8G8B8A8_UNORM",
"GL_RGBA8I": "R8G8B8A8_SINT", "GL_RGBA8I": "R8G8B8A8_SINT",
"GL_RGBA8UI": "R8G8B8A8_UINT", "GL_RGBA8UI": "R8G8B8A8_UINT",
"GL_RGBA8_SNORM": "R8G8B8A8_SNORM", "GL_RGBA8_SNORM": "R8G8B8A8_SNORM",
"GL_SRGB8": "R8G8B8A8_UNORM_SRGB", "GL_SRGB8": "R8G8B8A8_UNORM_SRGB",
"GL_SRGB8_ALPHA8": "R8G8B8A8_UNORM_SRGB", "GL_SRGB8_ALPHA8": "R8G8B8A8_UNORM_SRGB",
"GL_STENCIL_INDEX8": { "GL_STENCIL_INDEX8": "D24_UNORM_S8_UINT",
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_R16_EXT": "R16_UNORM", "GL_R16_EXT": "R16_UNORM",
"GL_RG16_EXT": "R16G16_UNORM", "GL_RG16_EXT": "R16G16_UNORM",
"GL_RGB16_EXT": "R16G16B16A16_UNORM", "GL_RGB16_EXT": "R16G16B16A16_UNORM",
......
...@@ -16,48 +16,41 @@ namespace d3d11 ...@@ -16,48 +16,41 @@ namespace d3d11
{ {
ANGLEFormatSet::ANGLEFormatSet() ANGLEFormatSet::ANGLEFormatSet()
: format(angle::Format::Get(angle::Format::ID::NONE)), : internalFormat(GL_NONE),
format(angle::Format::Get(angle::Format::ID::NONE)),
texFormat(DXGI_FORMAT_UNKNOWN), texFormat(DXGI_FORMAT_UNKNOWN),
srvFormat(DXGI_FORMAT_UNKNOWN), srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN), rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN), dsvFormat(DXGI_FORMAT_UNKNOWN),
blitSRVFormat(DXGI_FORMAT_UNKNOWN), blitSRVFormat(DXGI_FORMAT_UNKNOWN),
swizzle(*this) swizzle(*this),
dataInitializerFunction(nullptr)
{ {
} }
ANGLEFormatSet::ANGLEFormatSet(angle::Format::ID formatID, ANGLEFormatSet::ANGLEFormatSet(GLenum internalFormat,
angle::Format::ID formatID,
DXGI_FORMAT texFormat, DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat, DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat, DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat, DXGI_FORMAT dsvFormat,
DXGI_FORMAT blitSRVFormat, DXGI_FORMAT blitSRVFormat,
angle::Format::ID swizzleID, GLenum swizzleFormat,
InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps) const Renderer11DeviceCaps &deviceCaps)
: format(angle::Format::Get(formatID)), : internalFormat(internalFormat),
format(angle::Format::Get(formatID)),
texFormat(texFormat), texFormat(texFormat),
srvFormat(srvFormat), srvFormat(srvFormat),
rtvFormat(rtvFormat), rtvFormat(rtvFormat),
dsvFormat(dsvFormat), dsvFormat(dsvFormat),
blitSRVFormat(blitSRVFormat), blitSRVFormat(blitSRVFormat),
swizzle(swizzleID == formatID ? *this : GetANGLEFormatSet(swizzleID, deviceCaps)) swizzle(swizzleFormat == internalFormat ? *this
{ : GetANGLEFormatSet(swizzleFormat, deviceCaps)),
}
// For sized GL internal formats, there are several possible corresponding D3D11 formats depending
// on device capabilities.
// This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format.
TextureFormat::TextureFormat(GLenum internalFormat,
const angle::Format::ID angleFormatID,
InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps)
: internalFormat(internalFormat),
formatSet(GetANGLEFormatSet(angleFormatID, deviceCaps)),
dataInitializerFunction(internalFormatInitializer), dataInitializerFunction(internalFormatInitializer),
loadFunctions(GetLoadFunctionsMap(internalFormat, formatSet.texFormat)) loadFunctions(GetLoadFunctionsMap(internalFormat, texFormat))
{ {
ASSERT(!loadFunctions.empty() || angleFormatID == angle::Format::ID::NONE); ASSERT(!loadFunctions.empty() || formatID == angle::Format::ID::NONE);
} }
} // namespace d3d11 } // namespace d3d11
......
...@@ -38,18 +38,25 @@ struct LoadImageFunctionInfo ...@@ -38,18 +38,25 @@ struct LoadImageFunctionInfo
bool requiresConversion; bool requiresConversion;
}; };
// For sized GL internal formats, there are several possible corresponding D3D11 formats depending
// on device capabilities.
// This structure allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format.
struct ANGLEFormatSet final : angle::NonCopyable struct ANGLEFormatSet final : angle::NonCopyable
{ {
ANGLEFormatSet(); ANGLEFormatSet();
ANGLEFormatSet(angle::Format::ID formatID, ANGLEFormatSet(GLenum internalFormat,
angle::Format::ID formatID,
DXGI_FORMAT texFormat, DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat, DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat, DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat, DXGI_FORMAT dsvFormat,
DXGI_FORMAT blitSRVFormat, DXGI_FORMAT blitSRVFormat,
angle::Format::ID swizzleID, GLenum swizzleFormat,
InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps); const Renderer11DeviceCaps &deviceCaps);
GLenum internalFormat;
const angle::Format &format; const angle::Format &format;
DXGI_FORMAT texFormat; DXGI_FORMAT texFormat;
...@@ -60,17 +67,6 @@ struct ANGLEFormatSet final : angle::NonCopyable ...@@ -60,17 +67,6 @@ struct ANGLEFormatSet final : angle::NonCopyable
DXGI_FORMAT blitSRVFormat; DXGI_FORMAT blitSRVFormat;
const ANGLEFormatSet &swizzle; const ANGLEFormatSet &swizzle;
};
struct TextureFormat : public angle::NonCopyable
{
TextureFormat(GLenum internalFormat,
const angle::Format::ID angleFormatID,
InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps);
GLenum internalFormat;
const ANGLEFormatSet &formatSet;
InitializeTextureDataFunction dataInitializerFunction; InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap; typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap;
...@@ -78,12 +74,9 @@ struct TextureFormat : public angle::NonCopyable ...@@ -78,12 +74,9 @@ struct TextureFormat : public angle::NonCopyable
LoadFunctionMap loadFunctions; LoadFunctionMap loadFunctions;
}; };
const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID angleFormat, const ANGLEFormatSet &GetANGLEFormatSet(GLenum internalFormat,
const Renderer11DeviceCaps &deviceCaps); const Renderer11DeviceCaps &deviceCaps);
const TextureFormat &GetTextureFormatInfo(GLenum internalformat,
const Renderer11DeviceCaps &renderer11DeviceCaps);
} // namespace d3d11 } // namespace d3d11
} // namespace rx } // namespace rx
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -48,8 +48,8 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport) ...@@ -48,8 +48,8 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats(); const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
for (GLenum internalFormat : allFormats) for (GLenum internalFormat : allFormats)
{ {
const rx::d3d11::TextureFormat &formatInfo = const rx::d3d11::ANGLEFormatSet &formatInfo =
rx::d3d11::GetTextureFormatInfo(internalFormat, renderer->getRenderer11DeviceCaps()); rx::d3d11::GetANGLEFormatSet(internalFormat, renderer->getRenderer11DeviceCaps());
const auto &textureInfo = textureCaps.get(internalFormat); const auto &textureInfo = textureCaps.get(internalFormat);
// Bits for texturing // Bits for texturing
...@@ -66,15 +66,14 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport) ...@@ -66,15 +66,14 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport)
} }
UINT texSupport; UINT texSupport;
bool texSuccess = bool texSuccess = SUCCEEDED(device->CheckFormatSupport(formatInfo.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.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);
...@@ -84,25 +83,25 @@ TEST_P(D3D11FormatTablesTest, TestFormatSupport) ...@@ -84,25 +83,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.dsvFormat;
bool depthSuccess = SUCCEEDED( bool depthSuccess =
device->CheckFormatSupport(formatInfo.formatSet.dsvFormat, &renderSupport)); SUCCEEDED(device->CheckFormatSupport(formatInfo.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.dsvFormat);
} }
} }
else else
{ {
renderFormat = formatInfo.formatSet.rtvFormat; renderFormat = formatInfo.rtvFormat;
bool rtSuccess = SUCCEEDED( bool rtSuccess =
device->CheckFormatSupport(formatInfo.formatSet.rtvFormat, &renderSupport)); SUCCEEDED(device->CheckFormatSupport(formatInfo.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.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