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);
......
...@@ -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;
......
...@@ -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