Commit a5b1561e by Jamie Madill Committed by Commit Bot

Place format info in angle::Format.

Some bits of information, like the copy functions and mipmap gen functions, can be shared across back-ends in the angle::Format class. Also name the info struct angle::Format, and use an enum class angle::Format::ID to identify the particular format. This patch introduces a new table generator for angle formats and updates the D3D11 generator accordingly. BUG=angleproject:1455 Change-Id: I13b8b98822b1186c6a9e436dc232c18fef50980c Reviewed-on: https://chromium-review.googlesource.com/365824Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 20f69ce5
...@@ -12,69 +12,47 @@ ...@@ -12,69 +12,47 @@
#ifndef LIBANGLE_RENDERER_FORMAT_H_ #ifndef LIBANGLE_RENDERER_FORMAT_H_
#define LIBANGLE_RENDERER_FORMAT_H_ #define LIBANGLE_RENDERER_FORMAT_H_
#include "libANGLE/renderer/renderer_utils.h"
namespace angle namespace angle
{ {
// TODO(jmadill): It would be nice if we could auto-generate this. struct Format final : angle::NonCopyable
enum class Format
{ {
NONE, enum class ID;
A8_UNORM,
B4G4R4A4_UNORM, Format(ID id,
B5G5R5A1_UNORM, GLenum glFormat,
B5G6R5_UNORM, GLenum fboFormat,
B8G8R8A8_UNORM, rx::MipGenerationFunction mipGen,
BC1_UNORM, rx::ColorReadFunction colorRead)
BC2_UNORM, : id(id),
BC3_UNORM, glInternalFormat(glFormat),
D16_UNORM, fboImplementationInternalFormat(fboFormat),
D24_UNORM_S8_UINT, mipGenerationFunction(mipGen),
D32_FLOAT, colorReadFunction(colorRead)
D32_FLOAT_S8X24_UINT, {
R10G10B10A2_UINT, }
R10G10B10A2_UNORM,
R11G11B10_FLOAT, static const Format &Get(ID id);
R16G16B16A16_FLOAT,
R16G16B16A16_SINT, ID id;
R16G16B16A16_SNORM,
R16G16B16A16_UINT, // The closest matching GL internal format for the storage this format uses. Note that this
R16G16B16A16_UNORM, // may be a different internal format than the one this ANGLE format is used for.
R16G16_FLOAT, GLenum glInternalFormat;
R16G16_SINT,
R16G16_SNORM, // The format we should report to the GL layer when querying implementation formats from a FBO.
R16G16_UINT, // This might not be the same as the glInternalFormat, since some DXGI formats don't have
R16G16_UNORM, // matching GL format enums, like BGRA4, BGR5A1 and B5G6R6.
R16_FLOAT, GLenum fboImplementationInternalFormat;
R16_SINT,
R16_SNORM, rx::MipGenerationFunction mipGenerationFunction;
R16_UINT, rx::ColorReadFunction colorReadFunction;
R16_UNORM,
R32G32B32A32_FLOAT,
R32G32B32A32_SINT,
R32G32B32A32_UINT,
R32G32_FLOAT,
R32G32_SINT,
R32G32_UINT,
R32_FLOAT,
R32_SINT,
R32_UINT,
R8G8B8A8_SINT,
R8G8B8A8_SNORM,
R8G8B8A8_UINT,
R8G8B8A8_UNORM,
R8G8B8A8_UNORM_SRGB,
R8G8_SINT,
R8G8_SNORM,
R8G8_UINT,
R8G8_UNORM,
R8_SINT,
R8_SNORM,
R8_UINT,
R8_UNORM,
R9G9B9E5_SHAREDEXP,
}; };
} // namespace angle } // namespace angle
#include "libANGLE/renderer/Format_ID_autogen.inl"
#endif // LIBANGLE_RENDERER_FORMAT_H_ #endif // LIBANGLE_RENDERER_FORMAT_H_
// GENERATED FILE - DO NOT EDIT.
// Generated by gen_angle_format_table.py using data from angle_format_data.json
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ANGLE format enumeration.
namespace angle
{
enum class Format::ID
{
NONE,
A8_UNORM,
B4G4R4A4_UNORM,
B5G5R5A1_UNORM,
B5G6R5_UNORM,
B8G8R8A8_UNORM,
BC1_UNORM,
BC2_UNORM,
BC3_UNORM,
D16_UNORM,
D24_UNORM_S8_UINT,
D32_FLOAT,
D32_FLOAT_S8X24_UINT,
R10G10B10A2_UINT,
R10G10B10A2_UNORM,
R11G11B10_FLOAT,
R16G16B16A16_FLOAT,
R16G16B16A16_SINT,
R16G16B16A16_SNORM,
R16G16B16A16_UINT,
R16G16B16A16_UNORM,
R16G16_FLOAT,
R16G16_SINT,
R16G16_SNORM,
R16G16_UINT,
R16G16_UNORM,
R16_FLOAT,
R16_SINT,
R16_SNORM,
R16_UINT,
R16_UNORM,
R32G32B32A32_FLOAT,
R32G32B32A32_SINT,
R32G32B32A32_UINT,
R32G32_FLOAT,
R32G32_SINT,
R32G32_UINT,
R32_FLOAT,
R32_SINT,
R32_UINT,
R8G8B8A8_SINT,
R8G8B8A8_SNORM,
R8G8B8A8_UINT,
R8G8B8A8_UNORM,
R8G8B8A8_UNORM_SRGB,
R8G8_SINT,
R8G8_SNORM,
R8G8_UINT,
R8G8_UNORM,
R8_SINT,
R8_SNORM,
R8_UINT,
R8_UNORM,
R9G9B9E5_SHAREDEXP
};
} // namespace angle
{
"NONE": {
},
"A8_UNORM": {
"channels": "a",
"componentType": "unorm",
"bits": { "alpha": 8 },
"glInternalFormat": "GL_ALPHA8_EXT"
},
"R8G8B8A8_UNORM": {
"channels": "rgba",
"componentType": "unorm",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_RGBA8"
},
"R16G16B16A16_UNORM": {
"channels": "rgba",
"componentType": "unorm",
"bits": { "red": 16, "green": 16, "blue": 16, "alpha": 16 },
"glInternalFormat": "GL_RGBA16_EXT"
},
"R16G16B16A16_FLOAT": {
"channels": "rgba",
"componentType": "float",
"bits": { "red": 16, "green": 16, "blue": 16, "alpha": 16 },
"glInternalFormat": "GL_RGBA16F"
},
"R32G32B32A32_FLOAT": {
"channels": "rgba",
"componentType": "float",
"bits": { "red": 32, "green": 32, "blue": 32, "alpha": 32 },
"glInternalFormat": "GL_RGBA32F"
},
"B8G8R8A8_UNORM": {
"channels": "bgra",
"componentType": "unorm",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_BGRA8_EXT"
},
"BC1_UNORM": {
"channels": "rgba",
"componentType": "unorm",
"swizzleFormat": "R8G8B8A8_UNORM",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
},
"BC2_UNORM": {
"channels": "rgba",
"componentType": "unorm",
"swizzleFormat": "R8G8B8A8_UNORM",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"
},
"BC3_UNORM": {
"channels": "rgba",
"componentType": "unorm",
"swizzleFormat": "R8G8B8A8_UNORM",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"
},
"D24_UNORM_S8_UINT": {
"channels": "ds",
"bits": { "depth": 24, "stencil": 8 },
"glInternalFormat": "GL_DEPTH24_STENCIL8_OES"
},
"D32_FLOAT_S8X24_UINT": {
"channels": "ds",
"bits": { "depth": 32, "stencil": 8 },
"glInternalFormat": "GL_DEPTH32F_STENCIL8"
},
"D16_UNORM": {
"channels": "d",
"componentType": "unorm",
"bits": { "depth": 16 },
"glInternalFormat": "GL_DEPTH_COMPONENT16"
},
"D32_FLOAT": {
"channels": "d",
"componentType": "float",
"bits": { "depth": 32 },
"glInternalFormat": "GL_DEPTH_COMPONENT32F"
},
"R11G11B10_FLOAT": {
"channels": "rgb",
"componentType": "float",
"bits": { "red": 11, "green": 11, "blue": 10 },
"glInternalFormat": "GL_R11F_G11F_B10F"
},
"R16_FLOAT": {
"channels": "r",
"componentType": "float",
"bits": { "red": 16 },
"glInternalFormat": "GL_R16F"
},
"R16_SINT": {
"channels": "r",
"componentType": "int",
"bits": { "red": 16 },
"glInternalFormat": "GL_R16I"
},
"R16_UINT": {
"channels": "r",
"componentType": "uint",
"bits": { "red": 16 },
"glInternalFormat": "GL_R16UI"
},
"R32_FLOAT": {
"channels": "r",
"componentType": "float",
"bits": { "red": 32 },
"glInternalFormat": "GL_R32F"
},
"R32_SINT": {
"channels": "r",
"componentType": "int",
"bits": { "red": 32 },
"glInternalFormat": "GL_R32I"
},
"R32_UINT": {
"channels": "r",
"componentType": "uint",
"bits": { "red": 32 },
"glInternalFormat": "GL_R32UI"
},
"R8_UNORM": {
"channels": "r",
"componentType": "unorm",
"bits": { "red": 8 },
"glInternalFormat": "GL_R8"
},
"R8_SINT": {
"channels": "r",
"componentType": "int",
"bits": { "red": 8 },
"glInternalFormat": "GL_R8I"
},
"R8_UINT": {
"channels": "r",
"componentType": "uint",
"bits": { "red": 8 },
"glInternalFormat": "GL_R8UI"
},
"R8_SNORM": {
"channels": "r",
"componentType": "snorm",
"bits": { "red": 8 },
"glInternalFormat": "GL_R8_SNORM"
},
"R16G16_FLOAT": {
"channels": "rg",
"componentType": "float",
"bits": { "red": 16, "green": 16 },
"glInternalFormat": "GL_RG16F"
},
"R16G16_SINT": {
"channels": "rg",
"componentType": "int",
"bits": { "red": 16, "green": 16 },
"glInternalFormat": "GL_RG16I"
},
"R16G16_UINT": {
"channels": "rg",
"componentType": "uint",
"bits": { "red": 16, "green": 16 },
"glInternalFormat": "GL_RG16UI"
},
"R32G32_FLOAT": {
"channels": "rg",
"componentType": "float",
"bits": { "red": 32, "green": 32 },
"glInternalFormat": "GL_RG32F"
},
"R32G32_SINT": {
"channels": "rg",
"componentType": "int",
"bits": { "red": 32, "green": 32 },
"glInternalFormat": "GL_RG32I"
},
"R32G32_UINT": {
"channels": "rg",
"componentType": "uint",
"bits": { "red": 32, "green": 32 },
"glInternalFormat": "GL_RG32UI"
},
"R8G8_UNORM": {
"channels": "rg",
"componentType": "unorm",
"bits": { "red": 8, "green": 8 },
"glInternalFormat": "GL_RG8"
},
"R8G8_SINT": {
"channels": "rg",
"componentType": "int",
"bits": { "red": 8, "green": 8 },
"glInternalFormat": "GL_RG8I"
},
"R8G8_UINT": {
"channels": "rg",
"componentType": "uint",
"bits": { "red": 8, "green": 8 },
"glInternalFormat": "GL_RG8UI"
},
"R8G8_SNORM": {
"channels": "rg",
"componentType": "snorm",
"bits": { "red": 8, "green": 8 },
"glInternalFormat": "GL_RG8_SNORM"
},
"R10G10B10A2_UNORM": {
"channels": "rgba",
"componentType": "unorm",
"bits": { "red": 10, "green": 10, "blue": 10, "alpha": 2 },
"glInternalFormat": "GL_RGB10_A2"
},
"R10G10B10A2_UINT": {
"channels": "rgba",
"componentType": "uint",
"bits": { "red": 10, "green": 10, "blue": 10, "alpha": 2 },
"glInternalFormat": "GL_RGB10_A2UI"
},
"R16G16B16A16_SINT": {
"channels": "rgba",
"componentType": "int",
"bits": { "red": 16, "green": 16, "blue": 16, "alpha": 16 },
"glInternalFormat": "GL_RGBA16I"
},
"R16G16B16A16_UINT": {
"channels": "rgba",
"componentType": "uint",
"bits": { "red": 16, "green": 16, "blue": 16, "alpha": 16 },
"glInternalFormat": "GL_RGBA16UI"
},
"R32G32B32A32_SINT": {
"channels": "rgba",
"componentType": "int",
"bits": { "red": 32, "green": 32, "blue": 32, "alpha": 32 },
"glInternalFormat": "GL_RGBA32I"
},
"R32G32B32A32_UINT": {
"channels": "rgba",
"componentType": "uint",
"bits": { "red": 32, "green": 32, "blue": 32, "alpha": 32 },
"glInternalFormat": "GL_RGBA32UI"
},
"B5G6R5_UNORM": {
"channels": "bgr",
"componentType": "unorm",
"bits": { "red": 5, "green": 6, "blue": 5 },
"glInternalFormat": "GL_BGR565_ANGLEX",
"fboImplementationInternalFormat": "GL_RGB565",
"channelStruct": "B5G6R5"
},
"B5G5R5A1_UNORM": {
"channels": "bgra",
"componentType": "unorm",
"bits": { "red": 5, "green": 5, "blue": 5, "alpha": 1 },
"glInternalFormat": "GL_BGR5_A1_ANGLEX",
"fboImplementationInternalFormat": "GL_RGB5_A1",
"channelStruct": "A1R5G5B5"
},
"R8G8B8A8_SINT": {
"channels": "rgba",
"componentType": "int",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_RGBA8I"
},
"R8G8B8A8_UINT": {
"channels": "rgba",
"componentType": "uint",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_RGBA8UI"
},
"R8G8B8A8_SNORM": {
"channels": "rgba",
"componentType": "snorm",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_RGBA8_SNORM"
},
"R9G9B9E5_SHAREDEXP": {
"channels": "rgb",
"componentType": "float",
"bits": { "red": 9, "green": 9, "blue": 9, "shared": 5 },
"glInternalFormat": "GL_RGB9_E5",
"channelStruct": "R9G9B9E5"
},
"B4G4R4A4_UNORM": {
"channels": "bgra",
"componentType": "unorm",
"bits": { "red": 4, "green": 4, "blue": 4, "alpha": 4 },
"glInternalFormat": "GL_BGRA4_ANGLEX",
"fboImplementationInternalFormat": "GL_RGBA4",
"channelStruct": "A4R4G4B4"
},
"R8G8B8A8_UNORM_SRGB": {
"channels": "rgba",
"componentType": "unorm",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_SRGB8_ALPHA8"
},
"R16_UNORM": {
"channels": "r",
"componentType": "unorm",
"bits": { "red": 16 },
"glInternalFormat": "GL_R16_EXT"
},
"R16G16_UNORM": {
"channels": "rg",
"componentType": "unorm",
"bits": { "red": 16, "green": 16 },
"glInternalFormat": "GL_RG16_EXT"
},
"R16_SNORM": {
"channels": "r",
"componentType": "snorm",
"bits": { "red": 16 },
"glInternalFormat": "GL_R16_SNORM_EXT"
},
"R16G16_SNORM": {
"channels": "rg",
"componentType": "snorm",
"bits": { "red": 16, "green": 16 },
"glInternalFormat": "GL_RG16_SNORM_EXT"
},
"R16G16B16A16_SNORM": {
"channels": "rgba",
"componentType": "snorm",
"bits": { "red": 16, "green": 16, "blue": 16, "alpha": 16 },
"glInternalFormat": "GL_RGBA16_SNORM_EXT"
}
}
...@@ -1984,7 +1984,7 @@ gl::Error Blit11::initResolveDepthStencil(const gl::Extents &extents) ...@@ -1984,7 +1984,7 @@ gl::Error Blit11::initResolveDepthStencil(const gl::Extents &extents)
releaseResolveDepthStencilResources(); releaseResolveDepthStencilResources();
} }
auto resolvedFormat = angle::Format::R32G32_FLOAT; auto resolvedFormat = angle::Format::ID::R32G32_FLOAT;
const auto &formatSet = const auto &formatSet =
d3d11::GetANGLEFormatSet(resolvedFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::GetANGLEFormatSet(resolvedFormat, mRenderer->getRenderer11DeviceCaps());
......
...@@ -358,7 +358,7 @@ gl::Error Framebuffer11::blitImpl(const gl::Rectangle &sourceArea, ...@@ -358,7 +358,7 @@ gl::Error Framebuffer11::blitImpl(const gl::Rectangle &sourceArea,
GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const
{ {
RenderTarget11 *renderTarget11 = GetAs<RenderTarget11>(renderTarget); RenderTarget11 *renderTarget11 = GetAs<RenderTarget11>(renderTarget);
return renderTarget11->getFormatSet().fboImplementationInternalFormat; return renderTarget11->getFormatSet().format.fboImplementationInternalFormat;
} }
void Framebuffer11::updateColorRenderTarget(size_t colorIndex) void Framebuffer11::updateColorRenderTarget(size_t colorIndex)
......
...@@ -68,7 +68,7 @@ gl::Error Image11::generateMipmap(Image11 *dest, ...@@ -68,7 +68,7 @@ gl::Error Image11::generateMipmap(Image11 *dest,
uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData); uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData);
auto mipGenerationFunction = d3d11::GetTextureFormatInfo(src->getInternalFormat(), rendererCaps) auto mipGenerationFunction = d3d11::GetTextureFormatInfo(src->getInternalFormat(), rendererCaps)
.formatSet.mipGenerationFunction; .formatSet.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);
......
...@@ -261,7 +261,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ...@@ -261,7 +261,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
{ {
mSubresourceIndex = GetRTVSubresourceIndex(mTexture, mRenderTarget); mSubresourceIndex = GetRTVSubresourceIndex(mTexture, mRenderTarget);
} }
ASSERT(mFormatSet.format != angle::Format::NONE || mWidth == 0 || mHeight == 0); ASSERT(mFormatSet.format.id != angle::Format::ID::NONE || mWidth == 0 || mHeight == 0);
} }
TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
...@@ -305,7 +305,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ...@@ -305,7 +305,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
{ {
mSubresourceIndex = GetDSVSubresourceIndex(mTexture, mDepthStencil); mSubresourceIndex = GetDSVSubresourceIndex(mTexture, mDepthStencil);
} }
ASSERT(mFormatSet.format != angle::Format::NONE || mWidth == 0 || mHeight == 0); ASSERT(mFormatSet.format.id != angle::Format::ID::NONE || mWidth == 0 || mHeight == 0);
} }
TextureRenderTarget11::~TextureRenderTarget11() TextureRenderTarget11::~TextureRenderTarget11()
......
...@@ -3280,8 +3280,8 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3280,8 +3280,8 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
{ {
*outRT = new TextureRenderTarget11( *outRT = new TextureRenderTarget11(
static_cast<ID3D11RenderTargetView *>(nullptr), nullptr, nullptr, nullptr, format, static_cast<ID3D11RenderTargetView *>(nullptr), nullptr, nullptr, nullptr, format,
d3d11::GetANGLEFormatSet(angle::Format::NONE, mRenderer11DeviceCaps), width, height, 1, d3d11::GetANGLEFormatSet(angle::Format::ID::NONE, mRenderer11DeviceCaps), width, height,
supportedSamples); 1, supportedSamples);
} }
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
...@@ -3538,7 +3538,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const ...@@ -3538,7 +3538,7 @@ bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
} }
// We don't support formats which we can't represent without conversion // We don't support formats which we can't represent without conversion
if (d3d11FormatInfo.formatSet.glInternalFormat != internalFormat) if (d3d11FormatInfo.formatSet.format.glInternalFormat != internalFormat)
{ {
return false; return false;
} }
...@@ -3788,11 +3788,11 @@ gl::Error Renderer11::packPixels(const TextureHelper11 &textureHelper, ...@@ -3788,11 +3788,11 @@ gl::Error Renderer11::packPixels(const TextureHelper11 &textureHelper,
int inputPitch = static_cast<int>(mapping.RowPitch); int inputPitch = static_cast<int>(mapping.RowPitch);
const auto &angleFormatInfo = textureHelper.getFormatSet(); const auto &angleFormatInfo = textureHelper.getFormatSet();
ASSERT(angleFormatInfo.glInternalFormat != GL_NONE); ASSERT(angleFormatInfo.format.glInternalFormat != GL_NONE);
const gl::InternalFormat &sourceFormatInfo = const gl::InternalFormat &sourceFormatInfo =
gl::GetInternalFormatInfo(angleFormatInfo.glInternalFormat); gl::GetInternalFormatInfo(angleFormatInfo.format.glInternalFormat);
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(textureHelper.getFormat()); const auto &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(textureHelper.getFormat());
ColorReadFunction colorReadFunction = angleFormatInfo.colorReadFunction; ColorReadFunction colorReadFunction = angleFormatInfo.format.colorReadFunction;
PackPixels(params, sourceFormatInfo, dxgiFormatInfo.fastCopyFunctions, colorReadFunction, PackPixels(params, sourceFormatInfo, dxgiFormatInfo.fastCopyFunctions, colorReadFunction,
inputPitch, source, pixelsOut); inputPitch, source, pixelsOut);
...@@ -3988,7 +3988,8 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn, ...@@ -3988,7 +3988,8 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRectIn,
bool partialDSBlit = (dxgiFormatInfo.depthBits > 0 && depthBlit) != (dxgiFormatInfo.stencilBits > 0 && stencilBlit); bool partialDSBlit = (dxgiFormatInfo.depthBits > 0 && depthBlit) != (dxgiFormatInfo.stencilBits > 0 && stencilBlit);
if (readRenderTarget11->getFormatSet().format == drawRenderTarget11->getFormatSet().format && if (readRenderTarget11->getFormatSet().format.id ==
drawRenderTarget11->getFormatSet().format.id &&
!stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit && !stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit &&
!colorMaskingNeeded && (!(depthBlit || stencilBlit) || wholeBufferCopy)) !colorMaskingNeeded && (!(depthBlit || stencilBlit) || wholeBufferCopy))
{ {
......
...@@ -16,42 +16,30 @@ namespace d3d11 ...@@ -16,42 +16,30 @@ namespace d3d11
{ {
ANGLEFormatSet::ANGLEFormatSet() ANGLEFormatSet::ANGLEFormatSet()
: format(angle::Format::NONE), : format(angle::Format::Get(angle::Format::ID::NONE)),
glInternalFormat(GL_NONE),
fboImplementationInternalFormat(GL_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),
swizzleFormat(angle::Format::NONE), swizzleFormat(angle::Format::ID::NONE)
mipGenerationFunction(nullptr),
colorReadFunction(nullptr)
{ {
} }
ANGLEFormatSet::ANGLEFormatSet(angle::Format format, ANGLEFormatSet::ANGLEFormatSet(angle::Format::ID formatID,
GLenum glInternalFormat,
GLenum fboImplementationInternalFormat,
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 swizzleFormat, angle::Format::ID swizzleFormat)
MipGenerationFunction mipGenerationFunction, : format(angle::Format::Get(formatID)),
ColorReadFunction colorReadFunction)
: format(format),
glInternalFormat(glInternalFormat),
fboImplementationInternalFormat(fboImplementationInternalFormat),
texFormat(texFormat), texFormat(texFormat),
srvFormat(srvFormat), srvFormat(srvFormat),
rtvFormat(rtvFormat), rtvFormat(rtvFormat),
dsvFormat(dsvFormat), dsvFormat(dsvFormat),
blitSRVFormat(blitSRVFormat), blitSRVFormat(blitSRVFormat),
swizzleFormat(swizzleFormat), swizzleFormat(swizzleFormat)
mipGenerationFunction(mipGenerationFunction),
colorReadFunction(colorReadFunction)
{ {
} }
...@@ -60,16 +48,16 @@ ANGLEFormatSet::ANGLEFormatSet(angle::Format format, ...@@ -60,16 +48,16 @@ ANGLEFormatSet::ANGLEFormatSet(angle::Format format,
// This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and // This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format. // DSVs given a GL internal format.
TextureFormat::TextureFormat(GLenum internalFormat, TextureFormat::TextureFormat(GLenum internalFormat,
const angle::Format angleFormat, const angle::Format::ID angleFormatID,
InitializeTextureDataFunction internalFormatInitializer, InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps) const Renderer11DeviceCaps &deviceCaps)
: internalFormat(internalFormat), : internalFormat(internalFormat),
formatSet(GetANGLEFormatSet(angleFormat, deviceCaps)), formatSet(GetANGLEFormatSet(angleFormatID, deviceCaps)),
swizzleFormatSet(GetANGLEFormatSet(formatSet.swizzleFormat, deviceCaps)), swizzleFormatSet(GetANGLEFormatSet(formatSet.swizzleFormat, deviceCaps)),
dataInitializerFunction(internalFormatInitializer), dataInitializerFunction(internalFormatInitializer),
loadFunctions(GetLoadFunctionsMap(internalFormat, formatSet.texFormat)) loadFunctions(GetLoadFunctionsMap(internalFormat, formatSet.texFormat))
{ {
ASSERT(!loadFunctions.empty() || angleFormat == angle::Format::NONE); ASSERT(!loadFunctions.empty() || angleFormatID == angle::Format::ID::NONE);
} }
} // namespace d3d11 } // namespace d3d11
......
...@@ -41,28 +41,15 @@ struct LoadImageFunctionInfo ...@@ -41,28 +41,15 @@ struct LoadImageFunctionInfo
struct ANGLEFormatSet final : angle::NonCopyable struct ANGLEFormatSet final : angle::NonCopyable
{ {
ANGLEFormatSet(); ANGLEFormatSet();
ANGLEFormatSet(angle::Format format, ANGLEFormatSet(angle::Format::ID formatID,
GLenum glInternalFormat,
GLenum fboImplementationInternalFormat,
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 swizzleFormat, angle::Format::ID swizzleFormat);
MipGenerationFunction mipGenerationFunction,
ColorReadFunction colorReadFunction);
angle::Format format; const angle::Format &format;
// The closest matching GL internal format for the DXGI formats this format uses. Note that this
// may be a different internal format than the one this ANGLE format is used for.
GLenum glInternalFormat;
// The format we should report to the GL layer when querying implementation formats from a FBO.
// This might not be the same as the glInternalFormat, since some DXGI formats don't have
// matching GL format enums, like BGRA4, BGR5A1 and B5G6R6.
GLenum fboImplementationInternalFormat;
DXGI_FORMAT texFormat; DXGI_FORMAT texFormat;
DXGI_FORMAT srvFormat; DXGI_FORMAT srvFormat;
...@@ -71,16 +58,13 @@ struct ANGLEFormatSet final : angle::NonCopyable ...@@ -71,16 +58,13 @@ struct ANGLEFormatSet final : angle::NonCopyable
DXGI_FORMAT blitSRVFormat; DXGI_FORMAT blitSRVFormat;
angle::Format swizzleFormat; angle::Format::ID swizzleFormat;
MipGenerationFunction mipGenerationFunction;
ColorReadFunction colorReadFunction;
}; };
struct TextureFormat : public angle::NonCopyable struct TextureFormat : public angle::NonCopyable
{ {
TextureFormat(GLenum internalFormat, TextureFormat(GLenum internalFormat,
const angle::Format angleFormat, const angle::Format::ID angleFormatID,
InitializeTextureDataFunction internalFormatInitializer, InitializeTextureDataFunction internalFormatInitializer,
const Renderer11DeviceCaps &deviceCaps); const Renderer11DeviceCaps &deviceCaps);
...@@ -94,7 +78,7 @@ struct TextureFormat : public angle::NonCopyable ...@@ -94,7 +78,7 @@ struct TextureFormat : public angle::NonCopyable
LoadFunctionMap loadFunctions; LoadFunctionMap loadFunctions;
}; };
const ANGLEFormatSet &GetANGLEFormatSet(angle::Format angleFormat, const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID angleFormat,
const Renderer11DeviceCaps &deviceCaps); const Renderer11DeviceCaps &deviceCaps);
const TextureFormat &GetTextureFormatInfo(GLenum internalformat, const TextureFormat &GetTextureFormatInfo(GLenum internalformat,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -24,10 +24,6 @@ struct FormatType; ...@@ -24,10 +24,6 @@ struct FormatType;
namespace rx namespace rx
{ {
typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth, typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
......
#!/usr/bin/python
# Copyright 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# gen_angle_format_table.py:
# Code generation for ANGLE format map.
#
from datetime import date
import json
import math
import pprint
import re
import sys
template_autogen_h = """// GENERATED FILE - DO NOT EDIT.
// Generated by gen_angle_format_table.py using data from angle_format_data.json
//
// Copyright {copyright_year} The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ANGLE format enumeration.
namespace angle
{{
enum class Format::ID
{{
{angle_format_enum}
}};
}} // namespace angle
"""
template_autogen_cpp = """// GENERATED FILE - DO NOT EDIT.
// Generated by gen_angle_format_table.py using data from angle_format_data.json
//
// Copyright {copyright_year} The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ANGLE Format table:
// Queries for typed format information from the ANGLE format enum.
#include "libANGLE/renderer/Format.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
namespace angle
{{
// static
const Format &Format::Get(ID id)
{{
// clang-format off
switch (id)
{{
{angle_format_info_cases}
default:
UNREACHABLE();
break;
}}
// clang-format on
static const Format noneInfo(ID::NONE, GL_NONE, GL_NONE, nullptr, nullptr);
return noneInfo;
}}
}} // namespace angle
"""
def get_channel_struct(angle_format):
if 'bits' not in angle_format:
return None
bits = angle_format['bits']
if 'depth' in bits or 'stencil' in bits:
return None
if 'channelStruct' in angle_format:
return angle_format['channelStruct']
struct_name = ''
for channel in angle_format['channels']:
if channel == 'r':
struct_name += 'R{}'.format(bits['red'])
if channel == 'g':
struct_name += 'G{}'.format(bits['green'])
if channel == 'b':
struct_name += 'B{}'.format(bits['blue'])
if channel == 'a':
struct_name += 'A{}'.format(bits['alpha'])
if angle_format['componentType'] == 'float':
struct_name += 'F'
if angle_format['componentType'] == 'int' or angle_format['componentType'] == 'snorm':
struct_name += 'S'
return struct_name
def get_mip_generation_function(angle_format):
channel_struct = get_channel_struct(angle_format)
if channel_struct == None:
return 'nullptr'
return 'GenerateMip<' + channel_struct + '>'
def get_color_read_function(angle_format):
channel_struct = get_channel_struct(angle_format)
if channel_struct == None:
return 'nullptr'
component_type_map = {
'uint': 'GLuint',
'int': 'GLint',
'unorm': 'GLfloat',
'snorm': 'GLfloat',
'float': 'GLfloat'
}
return 'ReadColor<' + channel_struct + ', '+ component_type_map[angle_format['componentType']] + '>'
format_entry_template = """{space}{{
{space} static const Format info(ID::{id},
{space} {glInternalFormat},
{space} {fboImplementationInternalFormat},
{space} {mipGenerationFunction},
{space} {colorReadFunction});
{space} return info;
{space}}}
"""
def json_to_table_data(format_id, json):
table_data = ""
parsed = {
"space": " ",
"id": format_id,
"glInternalFormat": "GL_NONE",
}
for k, v in json.iteritems():
parsed[k] = v
if (format_id != "NONE") and (parsed["glInternalFormat"] == "GL_NONE"):
print("Missing 'glInternalFormat' from " + format_id)
sys.exit(1)
if "fboImplementationInternalFormat" not in parsed:
parsed["fboImplementationInternalFormat"] = parsed["glInternalFormat"]
# Derived values.
parsed["mipGenerationFunction"] = get_mip_generation_function(parsed)
parsed["colorReadFunction"] = get_color_read_function(parsed)
return format_entry_template.format(**parsed)
def parse_json_into_angle_format_switch_string(json_data):
table_data = ''
for format_id, angle_format in sorted(json_data.iteritems()):
table_data += ' case ID::' + format_id + ':\n'
table_data += json_to_table_data(format_id, angle_format)
return table_data
def parse_json_into_angle_format_enum_string(json_data):
enum_data = ' NONE'
for format_id, _ in sorted(json_data.iteritems()):
if format_id == 'NONE':
continue
enum_data += ',\n ' + format_id
return enum_data
def reject_duplicate_keys(pairs):
found_keys = {}
for key, value in pairs:
if key in found_keys:
raise ValueError("duplicate key: %r" % (key,))
else:
found_keys[key] = value
return found_keys
with open('angle_format_data.json') as format_json_file:
format_data = format_json_file.read()
format_json_file.close()
json_data = json.loads(format_data, object_pairs_hook=reject_duplicate_keys)
angle_format_cases = parse_json_into_angle_format_switch_string(json_data)
output_cpp = template_autogen_cpp.format(
copyright_year=date.today().year,
angle_format_info_cases=angle_format_cases)
with open('Format_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp)
out_file.close()
enum_data = parse_json_into_angle_format_enum_string(json_data)
output_h = template_autogen_h.format(
copyright_year=date.today().year,
angle_format_enum=enum_data)
with open('Format_ID_autogen.inl', 'wt') as out_file:
out_file.write(output_h)
out_file.close()
...@@ -25,6 +25,16 @@ struct InternalFormat; ...@@ -25,6 +25,16 @@ struct InternalFormat;
namespace rx namespace rx
{ {
using MipGenerationFunction = void (*)(size_t sourceWidth,
size_t sourceHeight,
size_t sourceDepth,
const uint8_t *sourceData,
size_t sourceRowPitch,
size_t sourceDepthPitch,
uint8_t *destData,
size_t destRowPitch,
size_t destDepthPitch);
typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest); typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest); typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest); typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
......
...@@ -169,6 +169,8 @@ ...@@ -169,6 +169,8 @@
'libANGLE/renderer/EGLImplFactory.h', 'libANGLE/renderer/EGLImplFactory.h',
'libANGLE/renderer/FenceNVImpl.h', 'libANGLE/renderer/FenceNVImpl.h',
'libANGLE/renderer/FenceSyncImpl.h', 'libANGLE/renderer/FenceSyncImpl.h',
'libANGLE/renderer/Format_ID_autogen.inl',
'libANGLE/renderer/Format_autogen.cpp',
'libANGLE/renderer/Format.h', 'libANGLE/renderer/Format.h',
'libANGLE/renderer/FramebufferAttachmentObjectImpl.h', 'libANGLE/renderer/FramebufferAttachmentObjectImpl.h',
'libANGLE/renderer/FramebufferImpl.h', 'libANGLE/renderer/FramebufferImpl.h',
......
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