Commit c99518fc by Jamie Madill Committed by Commit Bot

Move default ANGLE format map to shared location.

This default format mapping serves as a base for a Renderer format mapping. Any formats that require emulation or other representation in a Renderer can be overridden in the renderer layer. BUG=angleproject:1455 Change-Id: I47f070c2ea132bada9cc0fc4353b89b74b8ee8f3 Reviewed-on: https://chromium-review.googlesource.com/367692Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent c2c106d4
...@@ -42,3 +42,5 @@ TestResults.qpa ...@@ -42,3 +42,5 @@ TestResults.qpa
*.vsp *.vsp
*.nvuser *.nvuser
buildtools/ buildtools/
*.pyc
...@@ -13,22 +13,68 @@ namespace angle ...@@ -13,22 +13,68 @@ namespace angle
enum class Format::ID enum class Format::ID
{ {
NONE, NONE,
A16_FLOAT,
A32_FLOAT,
A8_UNORM, A8_UNORM,
ASTC_10x10_SRGB_BLOCK,
ASTC_10x10_UNORM_BLOCK,
ASTC_10x5_SRGB_BLOCK,
ASTC_10x5_UNORM_BLOCK,
ASTC_10x6_SRGB_BLOCK,
ASTC_10x6_UNORM_BLOCK,
ASTC_10x8_SRGB_BLOCK,
ASTC_10x8_UNORM_BLOCK,
ASTC_12x10_SRGB_BLOCK,
ASTC_12x10_UNORM_BLOCK,
ASTC_12x12_SRGB_BLOCK,
ASTC_12x12_UNORM_BLOCK,
ASTC_4x4_SRGB_BLOCK,
ASTC_4x4_UNORM_BLOCK,
ASTC_5x4_SRGB_BLOCK,
ASTC_5x4_UNORM_BLOCK,
ASTC_5x5_SRGB_BLOCK,
ASTC_5x5_UNORM_BLOCK,
ASTC_6x5_SRGB_BLOCK,
ASTC_6x5_UNORM_BLOCK,
ASTC_6x6_SRGB_BLOCK,
ASTC_6x6_UNORM_BLOCK,
ASTC_8x5_SRGB_BLOCK,
ASTC_8x5_UNORM_BLOCK,
ASTC_8x6_SRGB_BLOCK,
ASTC_8x6_UNORM_BLOCK,
ASTC_8x8_SRGB_BLOCK,
ASTC_8x8_UNORM_BLOCK,
B4G4R4A4_UNORM, B4G4R4A4_UNORM,
B5G5R5A1_UNORM, B5G5R5A1_UNORM,
B5G6R5_UNORM, B5G6R5_UNORM,
B8G8R8A8_UNORM, B8G8R8A8_UNORM,
B8G8R8X8_UNORM, B8G8R8X8_UNORM,
BC1_UNORM, BC1_RGBA_UNORM_BLOCK,
BC2_UNORM, BC1_RGB_UNORM_BLOCK,
BC3_UNORM, BC2_RGBA_UNORM_BLOCK,
BC3_RGBA_UNORM_BLOCK,
D16_UNORM, D16_UNORM,
D24_UNORM,
D24_UNORM_S8_UINT, D24_UNORM_S8_UINT,
D32_FLOAT, D32_FLOAT,
D32_FLOAT_S8X24_UINT, D32_FLOAT_S8X24_UINT,
D32_UNORM, D32_UNORM,
L8A8_LUMA, EAC_R11G11_SNORM_BLOCK,
L8_LUMA, EAC_R11G11_UNORM_BLOCK,
EAC_R11_SNORM_BLOCK,
EAC_R11_UNORM_BLOCK,
ETC2_R8G8B8A1_SRGB_BLOCK,
ETC2_R8G8B8A1_UNORM_BLOCK,
ETC2_R8G8B8A8_SRGB_BLOCK,
ETC2_R8G8B8A8_UNORM_BLOCK,
ETC2_R8G8B8_SRGB_BLOCK,
ETC2_R8G8B8_UNORM_BLOCK,
L16A16_FLOAT,
L16_FLOAT,
L32A32_FLOAT,
L32_FLOAT,
L8A8_UNORM,
L8_UNORM,
R10G10B10A2_UINT, R10G10B10A2_UINT,
R10G10B10A2_UNORM, R10G10B10A2_UNORM,
R11G11B10_FLOAT, R11G11B10_FLOAT,
...@@ -37,6 +83,11 @@ enum class Format::ID ...@@ -37,6 +83,11 @@ enum class Format::ID
R16G16B16A16_SNORM, R16G16B16A16_SNORM,
R16G16B16A16_UINT, R16G16B16A16_UINT,
R16G16B16A16_UNORM, R16G16B16A16_UNORM,
R16G16B16_FLOAT,
R16G16B16_SINT,
R16G16B16_SNORM,
R16G16B16_UINT,
R16G16B16_UNORM,
R16G16_FLOAT, R16G16_FLOAT,
R16G16_SINT, R16G16_SINT,
R16G16_SNORM, R16G16_SNORM,
...@@ -50,18 +101,28 @@ enum class Format::ID ...@@ -50,18 +101,28 @@ enum class Format::ID
R32G32B32A32_FLOAT, R32G32B32A32_FLOAT,
R32G32B32A32_SINT, R32G32B32A32_SINT,
R32G32B32A32_UINT, R32G32B32A32_UINT,
R32G32B32_FLOAT,
R32G32B32_SINT,
R32G32B32_UINT,
R32G32_FLOAT, R32G32_FLOAT,
R32G32_SINT, R32G32_SINT,
R32G32_UINT, R32G32_UINT,
R32_FLOAT, R32_FLOAT,
R32_SINT, R32_SINT,
R32_UINT, R32_UINT,
R4G4B4A4_UNORM,
R5G5B5A1_UNORM,
R5G6B5_UNORM, R5G6B5_UNORM,
R8G8B8A8_SINT, R8G8B8A8_SINT,
R8G8B8A8_SNORM, R8G8B8A8_SNORM,
R8G8B8A8_UINT, R8G8B8A8_UINT,
R8G8B8A8_UNORM, R8G8B8A8_UNORM,
R8G8B8A8_UNORM_SRGB, R8G8B8A8_UNORM_SRGB,
R8G8B8_SINT,
R8G8B8_SNORM,
R8G8B8_UINT,
R8G8B8_UNORM,
R8G8B8_UNORM_SRGB,
R8G8_SINT, R8G8_SINT,
R8G8_SNORM, R8G8_SNORM,
R8G8_UINT, R8G8_UINT,
...@@ -70,7 +131,8 @@ enum class Format::ID ...@@ -70,7 +131,8 @@ enum class Format::ID
R8_SNORM, R8_SNORM,
R8_UINT, R8_UINT,
R8_UNORM, R8_UNORM,
R9G9B9E5_SHAREDEXP R9G9B9E5_SHAREDEXP,
S8_UINT
}; };
} // namespace angle } // namespace angle
#!/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.
#
# angle_format.py:
# Utils for ANGLE formats.
import json
import os
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
def load_json(path):
with open(path) as map_file:
file_data = map_file.read()
map_file.close()
return json.loads(file_data, object_pairs_hook=reject_duplicate_keys)
def load_forward_table(path):
pairs = load_json(path)
reject_duplicate_keys(pairs)
return { gl: angle for gl, angle in pairs }
def load_inverse_table(path):
pairs = load_json(path)
reject_duplicate_keys(pairs)
return { angle: gl for gl, angle in pairs }
def load_with_override(override_path):
map_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'angle_format_map.json')
results = load_forward_table(map_path)
overrides = load_json(override_path)
for k, v in overrides.iteritems():
results[k] = v
return results
{ {
"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"
},
"D32_UNORM": {
"channels": "d",
"componentType": "unorm",
"bits": { "depth": 32 },
"glInternalFormat": "GL_DEPTH_COMPONENT32_OES"
},
"L8_LUMA": {
"channels": "l",
"componentType": "unorm",
"bits": { "luma": 8 },
"glInternalFormat": "GL_LUMINANCE8_EXT"
},
"L8A8_LUMA": {
"channels": "la",
"componentType": "unorm",
"bits": { "luma": 8, "alpha": 8 },
"glInternalFormat": "GL_LUMINANCE8_ALPHA8_EXT",
"channelStruct": "L8A8"
},
"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": { "B5G6R5_UNORM": {
"channels": "bgr", "fboImplementationInternalFormat": "GL_RGB565"
"componentType": "unorm",
"bits": { "red": 5, "green": 6, "blue": 5 },
"glInternalFormat": "GL_BGR565_ANGLEX",
"fboImplementationInternalFormat": "GL_RGB565",
"channelStruct": "B5G6R5"
}, },
"B5G5R5A1_UNORM": { "B5G5R5A1_UNORM": {
"channels": "bgra",
"componentType": "unorm",
"bits": { "red": 5, "green": 5, "blue": 5, "alpha": 1 },
"glInternalFormat": "GL_BGR5_A1_ANGLEX",
"fboImplementationInternalFormat": "GL_RGB5_A1", "fboImplementationInternalFormat": "GL_RGB5_A1",
"channelStruct": "A1R5G5B5" "channelStruct": "A1R5G5B5"
}, },
"R5G6B5_UNORM": {
"channels": "rgb",
"componentType": "unorm",
"bits": { "red": 5, "green": 6, "blue": 5 },
"glInternalFormat": "GL_RGB565"
},
"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"
},
"B8G8R8X8_UNORM": { "B8G8R8X8_UNORM": {
"channels": "bgr",
"componentType": "unorm",
"bits": { "red": 8, "green": 8, "blue": 8 },
"glInternalFormat": "GL_BGRA8_EXT", "glInternalFormat": "GL_BGRA8_EXT",
"channelStruct": "B8G8R8X8" "channelStruct": "B8G8R8X8"
}, },
"R9G9B9E5_SHAREDEXP": { "R9G9B9E5_SHAREDEXP": {
"channels": "rgb",
"componentType": "float", "componentType": "float",
"bits": { "red": 9, "green": 9, "blue": 9, "shared": 5 },
"glInternalFormat": "GL_RGB9_E5",
"channelStruct": "R9G9B9E5" "channelStruct": "R9G9B9E5"
}, },
"B4G4R4A4_UNORM": { "B4G4R4A4_UNORM": {
"channels": "bgra",
"componentType": "unorm",
"bits": { "red": 4, "green": 4, "blue": 4, "alpha": 4 },
"glInternalFormat": "GL_BGRA4_ANGLEX",
"fboImplementationInternalFormat": "GL_RGBA4", "fboImplementationInternalFormat": "GL_RGBA4",
"channelStruct": "A4R4G4B4" "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"
} }
} }
[
[ "GL_ALPHA16F_EXT", "A16_FLOAT" ],
[ "GL_ALPHA32F_EXT", "A32_FLOAT" ],
[ "GL_ALPHA8_EXT", "A8_UNORM" ],
[ "GL_BGR565_ANGLEX", "B5G6R5_UNORM" ],
[ "GL_BGR5_A1_ANGLEX", "B5G5R5A1_UNORM" ],
[ "GL_BGRA4_ANGLEX", "B4G4R4A4_UNORM" ],
[ "GL_BGRA8_EXT", "B8G8R8A8_UNORM" ],
[ "GL_BGRX8_ANGLEX", "B8G8R8X8_UNORM" ],
[ "GL_COMPRESSED_R11_EAC", "EAC_R11_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RG11_EAC", "EAC_R11G11_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGB8_ETC2", "ETC2_R8G8B8_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", "ETC2_R8G8B8A1_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA8_ETC2_EAC", "ETC2_R8G8B8A8_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT", "BC1_RGBA_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE", "BC2_RGBA_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE", "BC3_RGBA_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_4x4_KHR", "ASTC_4x4_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_5x4_KHR", "ASTC_5x4_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_5x5_KHR", "ASTC_5x5_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_6x5_KHR", "ASTC_6x5_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_6x6_KHR", "ASTC_6x6_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_8x5_KHR", "ASTC_8x5_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_8x6_KHR", "ASTC_8x6_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_8x8_KHR", "ASTC_8x8_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_10x5_KHR", "ASTC_10x5_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_10x6_KHR", "ASTC_10x6_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_10x8_KHR", "ASTC_10x8_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_10x10_KHR", "ASTC_10x10_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_12x10_KHR", "ASTC_12x10_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGBA_ASTC_12x12_KHR", "ASTC_12x12_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGB_S3TC_DXT1_EXT", "BC1_RGB_UNORM_BLOCK" ],
[ "GL_COMPRESSED_SIGNED_R11_EAC", "EAC_R11_SNORM_BLOCK" ],
[ "GL_COMPRESSED_SIGNED_RG11_EAC", "EAC_R11G11_SNORM_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR", "ASTC_4x4_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR", "ASTC_5x4_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR", "ASTC_5x5_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR", "ASTC_6x5_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR", "ASTC_6x6_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR", "ASTC_8x5_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR", "ASTC_8x6_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR", "ASTC_8x8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR", "ASTC_10x5_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR", "ASTC_10x6_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR", "ASTC_10x8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR", "ASTC_10x10_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR", "ASTC_12x10_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR", "ASTC_12x12_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", "ETC2_R8G8B8A8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ETC2", "ETC2_R8G8B8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", "ETC2_R8G8B8A1_SRGB_BLOCK" ],
[ "GL_DEPTH24_STENCIL8", "D24_UNORM_S8_UINT" ],
[ "GL_DEPTH32F_STENCIL8", "D32_FLOAT_S8X24_UINT" ],
[ "GL_DEPTH_COMPONENT16", "D16_UNORM" ],
[ "GL_DEPTH_COMPONENT24", "D24_UNORM" ],
[ "GL_DEPTH_COMPONENT32F", "D32_FLOAT" ],
[ "GL_DEPTH_COMPONENT32_OES", "D32_UNORM" ],
[ "GL_ETC1_RGB8_OES", "NONE" ],
[ "GL_ETC1_RGB8_LOSSY_DECODE_ANGLE", "NONE" ],
[ "GL_LUMINANCE16F_EXT", "L16_FLOAT" ],
[ "GL_LUMINANCE32F_EXT", "L32_FLOAT" ],
[ "GL_LUMINANCE8_ALPHA8_EXT", "L8A8_UNORM" ],
[ "GL_LUMINANCE8_EXT", "L8_UNORM" ],
[ "GL_LUMINANCE_ALPHA16F_EXT", "L16A16_FLOAT" ],
[ "GL_LUMINANCE_ALPHA32F_EXT", "L32A32_FLOAT" ],
[ "GL_NONE", "NONE" ],
[ "GL_R11F_G11F_B10F", "R11G11B10_FLOAT" ],
[ "GL_R16F", "R16_FLOAT" ],
[ "GL_R16I", "R16_SINT" ],
[ "GL_R16UI", "R16_UINT" ],
[ "GL_R32F", "R32_FLOAT" ],
[ "GL_R32I", "R32_SINT" ],
[ "GL_R32UI", "R32_UINT" ],
[ "GL_R8", "R8_UNORM" ],
[ "GL_R8I", "R8_SINT" ],
[ "GL_R8UI", "R8_UINT" ],
[ "GL_R8_SNORM", "R8_SNORM" ],
[ "GL_RG16F", "R16G16_FLOAT" ],
[ "GL_RG16I", "R16G16_SINT" ],
[ "GL_RG16UI", "R16G16_UINT" ],
[ "GL_RG32F", "R32G32_FLOAT" ],
[ "GL_RG32I", "R32G32_SINT" ],
[ "GL_RG32UI", "R32G32_UINT" ],
[ "GL_RG8", "R8G8_UNORM" ],
[ "GL_RG8I", "R8G8_SINT" ],
[ "GL_RG8UI", "R8G8_UINT" ],
[ "GL_RG8_SNORM", "R8G8_SNORM" ],
[ "GL_RGB", "R8G8B8_UNORM" ],
[ "GL_RGB10_A2", "R10G10B10A2_UNORM" ],
[ "GL_RGB10_A2UI", "R10G10B10A2_UINT" ],
[ "GL_RGB16F", "R16G16B16_FLOAT" ],
[ "GL_RGB16I", "R16G16B16_SINT" ],
[ "GL_RGB16UI", "R16G16B16_UINT" ],
[ "GL_RGB32F", "R32G32B32_FLOAT" ],
[ "GL_RGB32I", "R32G32B32_SINT" ],
[ "GL_RGB32UI", "R32G32B32_UINT" ],
[ "GL_RGB565", "R5G6B5_UNORM" ],
[ "GL_RGB5_A1", "R5G5B5A1_UNORM" ],
[ "GL_RGB8", "R8G8B8_UNORM" ],
[ "GL_RGB8I", "R8G8B8_SINT" ],
[ "GL_RGB8UI", "R8G8B8_UINT" ],
[ "GL_RGB8_SNORM", "R8G8B8_SNORM" ],
[ "GL_RGB9_E5", "R9G9B9E5_SHAREDEXP" ],
[ "GL_RGBA", "R8G8B8A8_UNORM" ],
[ "GL_RGBA16F", "R16G16B16A16_FLOAT" ],
[ "GL_RGBA16I", "R16G16B16A16_SINT" ],
[ "GL_RGBA16UI", "R16G16B16A16_UINT" ],
[ "GL_RGBA32F", "R32G32B32A32_FLOAT" ],
[ "GL_RGBA32I", "R32G32B32A32_SINT" ],
[ "GL_RGBA32UI", "R32G32B32A32_UINT" ],
[ "GL_RGBA4", "R4G4B4A4_UNORM" ],
[ "GL_RGBA8", "R8G8B8A8_UNORM" ],
[ "GL_RGBA8I", "R8G8B8A8_SINT" ],
[ "GL_RGBA8UI", "R8G8B8A8_UINT" ],
[ "GL_RGBA8_SNORM", "R8G8B8A8_SNORM" ],
[ "GL_SRGB8", "R8G8B8_UNORM_SRGB" ],
[ "GL_SRGB8_ALPHA8", "R8G8B8A8_UNORM_SRGB" ],
[ "GL_STENCIL_INDEX8", "S8_UINT" ],
[ "GL_R16_EXT", "R16_UNORM" ],
[ "GL_RG16_EXT", "R16G16_UNORM" ],
[ "GL_RGB16_EXT", "R16G16B16_UNORM" ],
[ "GL_RGBA16_EXT", "R16G16B16A16_UNORM" ],
[ "GL_R16_SNORM_EXT", "R16_SNORM" ],
[ "GL_RG16_SNORM_EXT", "R16G16_SNORM" ],
[ "GL_RGB16_SNORM_EXT", "R16G16B16_SNORM" ],
[ "GL_RGBA16_SNORM_EXT", "R16G16B16A16_SNORM" ]
]
...@@ -11,9 +11,13 @@ from datetime import date ...@@ -11,9 +11,13 @@ from datetime import date
import json import json
import math import math
import pprint import pprint
import os
import re import re
import sys import sys
sys.path.append('../..')
import angle_format
template_texture_format_table_autogen_cpp = """// GENERATED FILE - DO NOT EDIT. template_texture_format_table_autogen_cpp = """// GENERATED FILE - DO NOT EDIT.
// Generated by gen_texture_format_table.py using data from texture_format_data.json // Generated by gen_texture_format_table.py using data from texture_format_data.json
// //
...@@ -44,8 +48,7 @@ namespace d3d11 ...@@ -44,8 +48,7 @@ namespace d3d11
{{ {{
// static // static
const Format &Format::Get(GLenum internalFormat, const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &deviceCaps)
const Renderer11DeviceCaps &deviceCaps)
{{ {{
// clang-format off // clang-format off
switch (internalFormat) switch (internalFormat)
...@@ -310,6 +313,10 @@ def parse_json_into_switch_angle_format_string(json_map, json_data): ...@@ -310,6 +313,10 @@ def parse_json_into_switch_angle_format_string(json_map, json_data):
table_data = '' table_data = ''
for internal_format, format_name in sorted(json_map.iteritems()): for internal_format, format_name in sorted(json_map.iteritems()):
if format_name not in json_data:
continue
angle_format = json_data[format_name] 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(
...@@ -336,19 +343,17 @@ def reject_duplicate_keys(pairs): ...@@ -336,19 +343,17 @@ def reject_duplicate_keys(pairs):
found_keys[key] = value found_keys[key] = value
return found_keys return found_keys
with open('texture_format_map.json') as texture_format_map_file: json_map = angle_format.load_with_override(os.path.abspath('texture_format_map.json'))
with open('texture_format_data.json') as texture_format_json_file:
texture_format_map = texture_format_map_file.read() with open('texture_format_data.json') as texture_format_json_file:
texture_format_data = texture_format_json_file.read() texture_format_data = texture_format_json_file.read()
texture_format_map_file.close() texture_format_json_file.close()
texture_format_json_file.close() json_data = json.loads(texture_format_data, object_pairs_hook=angle_format.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) angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data)
output_cpp = template_texture_format_table_autogen_cpp.format(
angle_format_cases = parse_json_into_switch_angle_format_string(json_map, json_data) copyright_year=date.today().year,
output_cpp = template_texture_format_table_autogen_cpp.format( angle_format_info_cases=angle_format_cases)
copyright_year=date.today().year, with open('texture_format_table_autogen.cpp', 'wt') as out_file:
angle_format_info_cases=angle_format_cases) out_file.write(output_cpp)
with open('texture_format_table_autogen.cpp', 'wt') as out_file: out_file.close()
out_file.write(output_cpp)
out_file.close()
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 }, "bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_BGRA8_EXT" "glInternalFormat": "GL_BGRA8_EXT"
}, },
"BC1_UNORM": { "BC1_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC1_UNORM", "texFormat": "DXGI_FORMAT_BC1_UNORM",
"srvFormat": "DXGI_FORMAT_BC1_UNORM", "srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba", "channels": "rgba",
...@@ -64,7 +64,15 @@ ...@@ -64,7 +64,15 @@
"swizzleFormat": "GL_RGBA8", "swizzleFormat": "GL_RGBA8",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
}, },
"BC2_UNORM": { "BC1_RGB_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC1_UNORM",
"srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba",
"componentType": "unorm",
"swizzleFormat": "GL_RGBA8",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
},
"BC2_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC2_UNORM", "texFormat": "DXGI_FORMAT_BC2_UNORM",
"srvFormat": "DXGI_FORMAT_BC2_UNORM", "srvFormat": "DXGI_FORMAT_BC2_UNORM",
"channels": "rgba", "channels": "rgba",
...@@ -72,7 +80,7 @@ ...@@ -72,7 +80,7 @@
"swizzleFormat": "GL_RGBA8", "swizzleFormat": "GL_RGBA8",
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE" "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"
}, },
"BC3_UNORM": { "BC3_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC3_UNORM", "texFormat": "DXGI_FORMAT_BC3_UNORM",
"srvFormat": "DXGI_FORMAT_BC3_UNORM", "srvFormat": "DXGI_FORMAT_BC3_UNORM",
"channels": "rgba", "channels": "rgba",
......
{ {
"GL_ALPHA16F_EXT": "R16G16B16A16_FLOAT", "GL_ALPHA16F_EXT": "R16G16B16A16_FLOAT",
"GL_ALPHA32F_EXT": "R32G32B32A32_FLOAT", "GL_ALPHA32F_EXT": "R32G32B32A32_FLOAT",
"GL_ALPHA8_EXT": "A8_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_BGRA_EXT": "B8G8R8A8_UNORM",
"GL_COMPRESSED_R11_EAC": "R8_UNORM", "GL_COMPRESSED_R11_EAC": "R8_UNORM",
"GL_COMPRESSED_RG11_EAC": "R8G8_UNORM", "GL_COMPRESSED_RG11_EAC": "R8G8_UNORM",
"GL_COMPRESSED_RGB8_ETC2": "R8G8B8A8_UNORM", "GL_COMPRESSED_RGB8_ETC2": "R8G8B8A8_UNORM",
"GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": "R8G8B8A8_UNORM", "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": "R8G8B8A8_UNORM",
"GL_COMPRESSED_RGBA8_ETC2_EAC": "R8G8B8A8_UNORM", "GL_COMPRESSED_RGBA8_ETC2_EAC": "R8G8B8A8_UNORM",
"GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": "BC1_UNORM",
"GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": "BC2_UNORM",
"GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": "BC3_UNORM",
"GL_COMPRESSED_RGBA_ASTC_4x4_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_4x4_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_5x4_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_5x4_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_5x5_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_5x5_KHR": "NONE",
...@@ -29,7 +22,7 @@ ...@@ -29,7 +22,7 @@
"GL_COMPRESSED_RGBA_ASTC_10x10_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_10x10_KHR": "NONE",
"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_RGB_UNORM_BLOCK",
"GL_COMPRESSED_SIGNED_R11_EAC": "R8_SNORM", "GL_COMPRESSED_SIGNED_R11_EAC": "R8_SNORM",
"GL_COMPRESSED_SIGNED_RG11_EAC": "R8G8_SNORM", "GL_COMPRESSED_SIGNED_RG11_EAC": "R8G8_SNORM",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE",
...@@ -49,79 +42,33 @@ ...@@ -49,79 +42,33 @@
"GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC": "R8G8B8A8_UNORM_SRGB", "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC": "R8G8B8A8_UNORM_SRGB",
"GL_COMPRESSED_SRGB8_ETC2": "R8G8B8A8_UNORM_SRGB", "GL_COMPRESSED_SRGB8_ETC2": "R8G8B8A8_UNORM_SRGB",
"GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": "R8G8B8A8_UNORM_SRGB", "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": "R8G8B8A8_UNORM_SRGB",
"GL_DEPTH24_STENCIL8": "D24_UNORM_S8_UINT",
"GL_DEPTH32F_STENCIL8": "D32_FLOAT_S8X24_UINT",
"GL_DEPTH_COMPONENT16": "D16_UNORM",
"GL_DEPTH_COMPONENT24": "D24_UNORM_S8_UINT", "GL_DEPTH_COMPONENT24": "D24_UNORM_S8_UINT",
"GL_DEPTH_COMPONENT32F": "D32_FLOAT",
"GL_DEPTH_COMPONENT32_OES": "D24_UNORM_S8_UINT", "GL_DEPTH_COMPONENT32_OES": "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_RGB_UNORM_BLOCK",
"GL_LUMINANCE16F_EXT": "R16G16B16A16_FLOAT", "GL_LUMINANCE16F_EXT": "R16G16B16A16_FLOAT",
"GL_LUMINANCE32F_EXT": "R32G32B32A32_FLOAT", "GL_LUMINANCE32F_EXT": "R32G32B32A32_FLOAT",
"GL_LUMINANCE8_ALPHA8_EXT": "R8G8B8A8_UNORM", "GL_LUMINANCE8_ALPHA8_EXT": "R8G8B8A8_UNORM",
"GL_LUMINANCE8_EXT": "R8G8B8A8_UNORM", "GL_LUMINANCE8_EXT": "R8G8B8A8_UNORM",
"GL_LUMINANCE_ALPHA16F_EXT": "R16G16B16A16_FLOAT", "GL_LUMINANCE_ALPHA16F_EXT": "R16G16B16A16_FLOAT",
"GL_LUMINANCE_ALPHA32F_EXT": "R32G32B32A32_FLOAT", "GL_LUMINANCE_ALPHA32F_EXT": "R32G32B32A32_FLOAT",
"GL_NONE": "NONE",
"GL_R11F_G11F_B10F": "R11G11B10_FLOAT",
"GL_R16F": "R16_FLOAT",
"GL_R16I": "R16_SINT",
"GL_R16UI": "R16_UINT",
"GL_R32F": "R32_FLOAT",
"GL_R32I": "R32_SINT",
"GL_R32UI": "R32_UINT",
"GL_R8": "R8_UNORM",
"GL_R8I": "R8_SINT",
"GL_R8UI": "R8_UINT",
"GL_R8_SNORM": "R8_SNORM",
"GL_RG16F": "R16G16_FLOAT",
"GL_RG16I": "R16G16_SINT",
"GL_RG16UI": "R16G16_UINT",
"GL_RG32F": "R32G32_FLOAT",
"GL_RG32I": "R32G32_SINT",
"GL_RG32UI": "R32G32_UINT",
"GL_RG8": "R8G8_UNORM",
"GL_RG8I": "R8G8_SINT",
"GL_RG8UI": "R8G8_UINT",
"GL_RG8_SNORM": "R8G8_SNORM",
"GL_RGB": "R8G8B8A8_UNORM", "GL_RGB": "R8G8B8A8_UNORM",
"GL_RGB10_A2": "R10G10B10A2_UNORM",
"GL_RGB10_A2UI": "R10G10B10A2_UINT",
"GL_RGB16F": "R16G16B16A16_FLOAT", "GL_RGB16F": "R16G16B16A16_FLOAT",
"GL_RGB16I": "R16G16B16A16_SINT", "GL_RGB16I": "R16G16B16A16_SINT",
"GL_RGB16UI": "R16G16B16A16_UINT", "GL_RGB16UI": "R16G16B16A16_UINT",
"GL_RGB32F": "R32G32B32A32_FLOAT",
"GL_RGB32I": "R32G32B32A32_SINT",
"GL_RGB32UI": "R32G32B32A32_UINT",
"GL_RGB565": "B5G6R5_UNORM", "GL_RGB565": "B5G6R5_UNORM",
"GL_RGB5_A1": "B5G5R5A1_UNORM", "GL_RGB5_A1": "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",
"GL_RGB8_SNORM": "R8G8B8A8_SNORM", "GL_RGB8_SNORM": "R8G8B8A8_SNORM",
"GL_RGB9_E5": "R9G9B9E5_SHAREDEXP",
"GL_RGBA": "R8G8B8A8_UNORM",
"GL_RGBA16F": "R16G16B16A16_FLOAT",
"GL_RGBA16I": "R16G16B16A16_SINT",
"GL_RGBA16UI": "R16G16B16A16_UINT",
"GL_RGBA32F": "R32G32B32A32_FLOAT",
"GL_RGBA32I": "R32G32B32A32_SINT",
"GL_RGBA32UI": "R32G32B32A32_UINT",
"GL_RGBA4": "B4G4R4A4_UNORM", "GL_RGBA4": "B4G4R4A4_UNORM",
"GL_RGBA8": "R8G8B8A8_UNORM",
"GL_RGBA8I": "R8G8B8A8_SINT",
"GL_RGBA8UI": "R8G8B8A8_UINT",
"GL_RGBA8_SNORM": "R8G8B8A8_SNORM",
"GL_SRGB8": "R8G8B8A8_UNORM_SRGB", "GL_SRGB8": "R8G8B8A8_UNORM_SRGB",
"GL_SRGB8_ALPHA8": "R8G8B8A8_UNORM_SRGB",
"GL_STENCIL_INDEX8": "D24_UNORM_S8_UINT", "GL_STENCIL_INDEX8": "D24_UNORM_S8_UINT",
"GL_R16_EXT": "R16_UNORM",
"GL_RG16_EXT": "R16G16_UNORM",
"GL_RGB16_EXT": "R16G16B16A16_UNORM", "GL_RGB16_EXT": "R16G16B16A16_UNORM",
"GL_RGBA16_EXT": "R16G16B16A16_UNORM", "GL_RGBA16_EXT": "R16G16B16A16_UNORM",
"GL_R16_SNORM_EXT": "R16_SNORM",
"GL_RG16_SNORM_EXT": "R16G16_SNORM",
"GL_RGB16_SNORM_EXT": "R16G16B16A16_SNORM", "GL_RGB16_SNORM_EXT": "R16G16B16A16_SNORM",
"GL_RGBA16_SNORM_EXT": "R16G16B16A16_SNORM" "GL_RGB32F": "R32G32B32A32_FLOAT",
"GL_RGB32I": "R32G32B32A32_SINT",
"GL_RGB32UI": "R32G32B32A32_UINT"
} }
...@@ -28,8 +28,7 @@ namespace d3d11 ...@@ -28,8 +28,7 @@ namespace d3d11
{ {
// static // static
const Format &Format::Get(GLenum internalFormat, const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &deviceCaps)
const Renderer11DeviceCaps &deviceCaps)
{ {
// clang-format off // clang-format off
switch (internalFormat) switch (internalFormat)
...@@ -166,20 +165,6 @@ const Format &Format::Get(GLenum internalFormat, ...@@ -166,20 +165,6 @@ const Format &Format::Get(GLenum internalFormat,
deviceCaps); deviceCaps);
return info; return info;
} }
case GL_BGRA_EXT:
{
static const Format info(GL_BGRA_EXT,
angle::Format::ID::B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B8G8R8A8_UNORM,
GL_BGRA8_EXT,
nullptr,
deviceCaps);
return info;
}
case GL_COMPRESSED_R11_EAC: case GL_COMPRESSED_R11_EAC:
{ {
static const Format info(GL_COMPRESSED_R11_EAC, static const Format info(GL_COMPRESSED_R11_EAC,
...@@ -449,7 +434,7 @@ const Format &Format::Get(GLenum internalFormat, ...@@ -449,7 +434,7 @@ const Format &Format::Get(GLenum internalFormat,
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
{ {
static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
angle::Format::ID::BC1_UNORM, angle::Format::ID::BC1_RGBA_UNORM_BLOCK,
DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
...@@ -463,7 +448,7 @@ const Format &Format::Get(GLenum internalFormat, ...@@ -463,7 +448,7 @@ const Format &Format::Get(GLenum internalFormat,
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
{ {
static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,
angle::Format::ID::BC2_UNORM, angle::Format::ID::BC2_RGBA_UNORM_BLOCK,
DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM,
DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
...@@ -477,7 +462,7 @@ const Format &Format::Get(GLenum internalFormat, ...@@ -477,7 +462,7 @@ const Format &Format::Get(GLenum internalFormat,
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
{ {
static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, static const Format info(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
angle::Format::ID::BC3_UNORM, angle::Format::ID::BC3_RGBA_UNORM_BLOCK,
DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM,
DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
...@@ -491,7 +476,7 @@ const Format &Format::Get(GLenum internalFormat, ...@@ -491,7 +476,7 @@ const Format &Format::Get(GLenum internalFormat,
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
{ {
static const Format info(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, static const Format info(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
angle::Format::ID::BC1_UNORM, angle::Format::ID::BC1_RGB_UNORM_BLOCK,
DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
...@@ -923,7 +908,7 @@ const Format &Format::Get(GLenum internalFormat, ...@@ -923,7 +908,7 @@ const Format &Format::Get(GLenum internalFormat,
case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE:
{ {
static const Format info(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, static const Format info(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE,
angle::Format::ID::BC1_UNORM, angle::Format::ID::BC1_RGB_UNORM_BLOCK,
DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN,
......
...@@ -86,9 +86,9 @@ static D3D9FormatInfoMap BuildD3D9FormatInfoMap() ...@@ -86,9 +86,9 @@ static D3D9FormatInfoMap BuildD3D9FormatInfoMap()
InsertD3DFormatInfo(&map, D3DFMT_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE ); InsertD3DFormatInfo(&map, D3DFMT_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE );
InsertD3DFormatInfo(&map, D3DFMT_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE ); InsertD3DFormatInfo(&map, D3DFMT_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Format::ID::NONE );
InsertD3DFormatInfo(&map, D3DFMT_L8, 8, 1, 1, 0, 0, 0, 0, 8, 0, 0, Format::ID::L8_LUMA ); InsertD3DFormatInfo(&map, D3DFMT_L8, 8, 1, 1, 0, 0, 0, 0, 8, 0, 0, Format::ID::L8_UNORM );
InsertD3DFormatInfo(&map, D3DFMT_A8, 8, 1, 1, 0, 0, 0, 8, 0, 0, 0, Format::ID::A8_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_A8, 8, 1, 1, 0, 0, 0, 8, 0, 0, 0, Format::ID::A8_UNORM );
InsertD3DFormatInfo(&map, D3DFMT_A8L8, 16, 1, 1, 0, 0, 0, 8, 8, 0, 0, Format::ID::L8A8_LUMA ); InsertD3DFormatInfo(&map, D3DFMT_A8L8, 16, 1, 1, 0, 0, 0, 8, 8, 0, 0, Format::ID::L8A8_UNORM );
InsertD3DFormatInfo(&map, D3DFMT_A4R4G4B4, 16, 1, 1, 4, 4, 4, 4, 0, 0, 0, Format::ID::B4G4R4A4_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_A4R4G4B4, 16, 1, 1, 4, 4, 4, 4, 0, 0, 0, Format::ID::B4G4R4A4_UNORM );
InsertD3DFormatInfo(&map, D3DFMT_A1R5G5B5, 16, 1, 1, 5, 5, 5, 1, 0, 0, 0, Format::ID::B5G5R5A1_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_A1R5G5B5, 16, 1, 1, 5, 5, 5, 1, 0, 0, 0, Format::ID::B5G5R5A1_UNORM );
InsertD3DFormatInfo(&map, D3DFMT_R5G6B5, 16, 1, 1, 5, 6, 5, 0, 0, 0, 0, Format::ID::R5G6B5_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_R5G6B5, 16, 1, 1, 5, 6, 5, 0, 0, 0, 0, Format::ID::R5G6B5_UNORM );
...@@ -108,9 +108,9 @@ static D3D9FormatInfoMap BuildD3D9FormatInfoMap() ...@@ -108,9 +108,9 @@ static D3D9FormatInfoMap BuildD3D9FormatInfoMap()
InsertD3DFormatInfo(&map, D3DFMT_INTZ, 32, 1, 1, 0, 0, 0, 0, 0, 24, 8, Format::ID::D24_UNORM_S8_UINT ); InsertD3DFormatInfo(&map, D3DFMT_INTZ, 32, 1, 1, 0, 0, 0, 0, 0, 24, 8, Format::ID::D24_UNORM_S8_UINT );
InsertD3DFormatInfo(&map, D3DFMT_DXT1, 64, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC1_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_DXT1, 64, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC1_RGBA_UNORM_BLOCK);
InsertD3DFormatInfo(&map, D3DFMT_DXT3, 128, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC2_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_DXT3, 128, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC2_RGBA_UNORM_BLOCK);
InsertD3DFormatInfo(&map, D3DFMT_DXT5, 128, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC3_UNORM ); InsertD3DFormatInfo(&map, D3DFMT_DXT5, 128, 4, 4, 0, 0, 0, 0, 0, 0, 0, Format::ID::BC3_RGBA_UNORM_BLOCK);
// clang-format on // clang-format on
return map; return map;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# Code generation for ANGLE format map. # Code generation for ANGLE format map.
# #
import angle_format
from datetime import date from datetime import date
import json import json
import math import math
...@@ -74,10 +75,12 @@ const Format &Format::Get(ID id) ...@@ -74,10 +75,12 @@ const Format &Format::Get(ID id)
""" """
def get_channel_struct(angle_format): def get_channel_struct(angle_format):
if 'bits' not in angle_format: if 'bits' not in angle_format or angle_format['bits'] is None:
return None
if 'BLOCK' in angle_format['id']:
return None return None
bits = angle_format['bits'] bits = angle_format['bits']
if 'depth' in bits or 'stencil' in bits: if 'D' in bits or 'S' in bits:
return None return None
if 'channelStruct' in angle_format: if 'channelStruct' in angle_format:
...@@ -86,15 +89,15 @@ def get_channel_struct(angle_format): ...@@ -86,15 +89,15 @@ def get_channel_struct(angle_format):
struct_name = '' struct_name = ''
for channel in angle_format['channels']: for channel in angle_format['channels']:
if channel == 'r': if channel == 'r':
struct_name += 'R{}'.format(bits['red']) struct_name += 'R{}'.format(bits['R'])
if channel == 'g': if channel == 'g':
struct_name += 'G{}'.format(bits['green']) struct_name += 'G{}'.format(bits['G'])
if channel == 'b': if channel == 'b':
struct_name += 'B{}'.format(bits['blue']) struct_name += 'B{}'.format(bits['B'])
if channel == 'a': if channel == 'a':
struct_name += 'A{}'.format(bits['alpha']) struct_name += 'A{}'.format(bits['A'])
if channel == 'l': if channel == 'l':
struct_name += 'L{}'.format(bits['luma']) struct_name += 'L{}'.format(bits['L'])
if angle_format['componentType'] == 'float': if angle_format['componentType'] == 'float':
struct_name += 'F' struct_name += 'F'
if angle_format['componentType'] == 'int' or angle_format['componentType'] == 'snorm': if angle_format['componentType'] == 'int' or angle_format['componentType'] == 'snorm':
...@@ -103,7 +106,7 @@ def get_channel_struct(angle_format): ...@@ -103,7 +106,7 @@ def get_channel_struct(angle_format):
def get_mip_generation_function(angle_format): def get_mip_generation_function(angle_format):
channel_struct = get_channel_struct(angle_format) channel_struct = get_channel_struct(angle_format)
if channel_struct == None: if channel_struct == None or "BLOCK" in angle_format["id"]:
return 'nullptr' return 'nullptr'
return 'GenerateMip<' + channel_struct + '>' return 'GenerateMip<' + channel_struct + '>'
...@@ -130,74 +133,115 @@ format_entry_template = """{space}{{ ...@@ -130,74 +133,115 @@ format_entry_template = """{space}{{
{space}}} {space}}}
""" """
def json_to_table_data(format_id, json): def get_component_type(format_id):
if "SNORM" in format_id:
return "snorm"
elif "UNORM" in format_id:
return "unorm"
elif "FLOAT" in format_id:
return "float"
elif "UINT" in format_id:
return "uint"
elif "SINT" in format_id:
return "int"
elif format_id == "NONE":
return "none"
elif "SRGB" in format_id:
return "unorm"
else:
raise ValueError("Unknown component type for " + format_id)
def get_channel_tokens(format_id):
r = re.compile(r'([ABDGLRS][\d]+)')
return filter(r.match, r.split(format_id))
def get_channels(format_id):
channels = ''
tokens = get_channel_tokens(format_id)
if len(tokens) == 0:
return None
for token in tokens:
channels += token[0].lower()
return channels
def get_bits(format_id):
bits = {}
tokens = get_channel_tokens(format_id)
if len(tokens) == 0:
return None
for token in tokens:
bits[token[0]] = int(token[1:])
return bits
def json_to_table_data(format_id, json, angle_to_gl):
table_data = "" table_data = ""
parsed = { parsed = {
"space": " ", "space": " ",
"id": format_id, "id": format_id,
"glInternalFormat": "GL_NONE",
} }
for k, v in json.iteritems(): for k, v in json.iteritems():
parsed[k] = v parsed[k] = v
if (format_id != "NONE") and (parsed["glInternalFormat"] == "GL_NONE"): if "glInternalFormat" not in parsed:
print("Missing 'glInternalFormat' from " + format_id) parsed["glInternalFormat"] = angle_to_gl[format_id]
sys.exit(1)
if "fboImplementationInternalFormat" not in parsed: if "fboImplementationInternalFormat" not in parsed:
parsed["fboImplementationInternalFormat"] = parsed["glInternalFormat"] parsed["fboImplementationInternalFormat"] = parsed["glInternalFormat"]
if "componentType" not in parsed:
parsed["componentType"] = get_component_type(format_id)
if "channels" not in parsed:
parsed["channels"] = get_channels(format_id)
if "bits" not in parsed:
parsed["bits"] = get_bits(format_id)
# Derived values. # Derived values.
parsed["mipGenerationFunction"] = get_mip_generation_function(parsed) parsed["mipGenerationFunction"] = get_mip_generation_function(parsed)
parsed["colorReadFunction"] = get_color_read_function(parsed) parsed["colorReadFunction"] = get_color_read_function(parsed)
return format_entry_template.format(**parsed) return format_entry_template.format(**parsed)
def parse_json_into_angle_format_switch_string(json_data): def parse_json_into_angle_format_switch_string(all_angle, json_data, angle_to_gl):
table_data = '' table_data = ''
for format_id, angle_format in sorted(json_data.iteritems()): for format_id in sorted(all_angle):
format_info = json_data[format_id] if format_id in json_data else {}
table_data += ' case ID::' + format_id + ':\n' table_data += ' case ID::' + format_id + ':\n'
table_data += json_to_table_data(format_id, angle_format) table_data += json_to_table_data(format_id, format_info, angle_to_gl)
return table_data return table_data
def parse_json_into_angle_format_enum_string(json_data): def gen_enum_string(all_angle):
enum_data = ' NONE' enum_data = ' NONE'
for format_id, _ in sorted(json_data.iteritems()): for format_id in sorted(all_angle):
if format_id == 'NONE': if format_id == 'NONE':
continue continue
enum_data += ',\n ' + format_id enum_data += ',\n ' + format_id
return enum_data return enum_data
def reject_duplicate_keys(pairs): gl_to_angle = angle_format.load_forward_table('angle_format_map.json')
found_keys = {} angle_to_gl = angle_format.load_inverse_table('angle_format_map.json')
for key, value in pairs: json_data = angle_format.load_json('angle_format_data.json')
if key in found_keys: all_angle = angle_to_gl.keys()
raise ValueError("duplicate key: %r" % (key,))
else: angle_format_cases = parse_json_into_angle_format_switch_string(
found_keys[key] = value all_angle, json_data, angle_to_gl)
return found_keys output_cpp = template_autogen_cpp.format(
copyright_year=date.today().year,
with open('angle_format_data.json') as format_json_file: angle_format_info_cases=angle_format_cases)
format_data = format_json_file.read() with open('Format_autogen.cpp', 'wt') as out_file:
format_json_file.close() out_file.write(output_cpp)
json_data = json.loads(format_data, object_pairs_hook=reject_duplicate_keys) out_file.close()
angle_format_cases = parse_json_into_angle_format_switch_string(json_data) enum_data = gen_enum_string(all_angle)
output_cpp = template_autogen_cpp.format( output_h = template_autogen_h.format(
copyright_year=date.today().year, copyright_year=date.today().year,
angle_format_info_cases=angle_format_cases) angle_format_enum=enum_data)
with open('Format_autogen.cpp', 'wt') as out_file: with open('Format_ID_autogen.inl', 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_h)
out_file.close() 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()
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