Commit e5922891 by Jamie Madill Committed by Commit Bot

D3D11: Partially squash D3D11 format types.

d3d11::TextureFormat and d3d11::FormatSet don't really do different things, so it would be best to merge them. BUG=angleproject:1455 Change-Id: I8c09ae763e4cb284bb611fed9d74b9048fb9f13e Reviewed-on: https://chromium-review.googlesource.com/367091Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 950ee3cc
...@@ -157,7 +157,8 @@ def get_internal_format_initializer(internal_format, angle_format): ...@@ -157,7 +157,8 @@ def get_internal_format_initializer(internal_format, angle_format):
return internal_format_initializer return internal_format_initializer
def get_swizzle_format_id(angle_format_id, angle_format): def get_swizzle_format_id(angle_format):
angle_format_id = angle_format["formatName"]
if angle_format_id == 'NONE': if angle_format_id == 'NONE':
return 'NONE' return 'NONE'
elif 'swizzleFormat' in angle_format: elif 'swizzleFormat' in angle_format:
...@@ -207,17 +208,22 @@ def get_swizzle_format_id(angle_format_id, angle_format): ...@@ -207,17 +208,22 @@ def get_swizzle_format_id(angle_format_id, angle_format):
else: else:
raise ValueError('could not determine swizzleformat based on componentType for format: ' + angle_format_id) raise ValueError('could not determine swizzleformat based on componentType for format: ' + angle_format_id)
def get_texture_format_item(idx, internal_format, requirements_fn, angle_format_id, angle_format): def get_texture_format_item(idx, internal_format, requirements_fn, angle_format_id, json_data):
table_data = ''; table_data = '';
angle_format = json_data[angle_format_id]
# TODO(jmadill): Remove this hack.
if requirements_fn != None and idx == 0 and 'fallbackFormat' in angle_format:
angle_format = json_data[angle_format['fallbackFormat']]
internal_format_initializer = get_internal_format_initializer(internal_format, angle_format) internal_format_initializer = get_internal_format_initializer(internal_format, angle_format)
indent = ' ' indent = ' '
if requirements_fn != None: if requirements_fn != None:
if idx == 0: if idx == 0:
table_data += ' if (' + requirements_fn + '(deviceCaps))\n' table_data += ' if (' + requirements_fn + ')\n'
else: else:
table_data += ' else if (' + requirements_fn + '(deviceCaps))\n' table_data += ' else if (' + requirements_fn + ')\n'
table_data += ' {\n' table_data += ' {\n'
indent += ' ' indent += ' '
...@@ -243,11 +249,11 @@ def parse_json_into_switch_texture_format_string(json_map, json_data): ...@@ -243,11 +249,11 @@ def parse_json_into_switch_texture_format_string(json_map, json_data):
if isinstance(json_map[internal_format], basestring): if isinstance(json_map[internal_format], basestring):
angle_format_id = json_map[internal_format] angle_format_id = json_map[internal_format]
table_data += get_texture_format_item(0, internal_format, None, angle_format_id, json_data[angle_format_id]) table_data += get_texture_format_item(0, internal_format, None, angle_format_id, json_data)
else: else:
for idx, requirements_map in enumerate(sorted(json_map[internal_format].iteritems())): for idx, requirements_map in enumerate(sorted(json_map[internal_format].iteritems())):
angle_format_id = requirements_map[1] angle_format_id = requirements_map[1]
table_data += get_texture_format_item(idx, internal_format, requirements_map[0], angle_format_id, json_data[angle_format_id]) table_data += get_texture_format_item(idx, internal_format, requirements_map[0], angle_format_id, json_data)
table_data += ' else\n' table_data += ' else\n'
table_data += ' {\n' table_data += ' {\n'
table_data += ' break;\n' table_data += ' break;\n'
...@@ -312,45 +318,64 @@ def json_to_table_data(format_name, prefix, json): ...@@ -312,45 +318,64 @@ def json_to_table_data(format_name, prefix, json):
# Derived values. # Derived values.
parsed["blitSRVFormat"] = get_blit_srv_format(parsed) parsed["blitSRVFormat"] = get_blit_srv_format(parsed)
parsed["swizzleFormat"] = get_swizzle_format_id(format_name, parsed) parsed["swizzleFormat"] = get_swizzle_format_id(parsed)
if len(prefix) > 0: if len(prefix) > 0:
return split_format_entry_template.format(**parsed) return split_format_entry_template.format(**parsed)
else: else:
return format_entry_template.format(**parsed) return format_entry_template.format(**parsed)
def parse_json_into_switch_angle_format_string(json_data): def parse_json_angle_format_case(format_name, angle_format, json_data):
table_data = '' supported_case = {}
for angle_format_item in sorted(json_data.iteritems()): unsupported_case = {}
table_data += ' case angle::Format::ID::' + angle_format_item[0] + ':\n' support_test = None
format_name = angle_format_item[0] fallback = None
angle_format = angle_format_item[1]
fl10plus = {}
fl9_3 = {}
split = False
for k, v in angle_format.iteritems(): for k, v in angle_format.iteritems():
if k == "FL10Plus": if k == "FL10Plus":
split = True assert support_test is None
support_test = "OnlyFL10Plus(deviceCaps)"
for k2, v2 in v.iteritems(): for k2, v2 in v.iteritems():
fl10plus[k2] = v2 supported_case[k2] = v2
elif k == "FL9_3": elif k == "FL9_3":
split = True split = True
for k2, v2 in v.iteritems(): for k2, v2 in v.iteritems():
fl9_3[k2] = v2 unsupported_case[k2] = v2
elif k == "supportTest":
assert support_test is None
support_test = v
elif k == "fallbackFormat":
fallback = v
else: else:
fl10plus[k] = v supported_case[k] = v
fl9_3[k] = v unsupported_case[k] = v
if fallback != None:
unsupported_case, _, _ = parse_json_angle_format_case(
fallback, json_data[fallback], json_data)
unsupported_case["formatName"] = fallback
if support_test != None:
return supported_case, unsupported_case, support_test
else:
return supported_case, None, None
def parse_json_into_switch_angle_format_string(json_data):
table_data = ''
for format_name, angle_format in sorted(json_data.iteritems()):
supported_case, unsupported_case, support_test = parse_json_angle_format_case(
format_name, angle_format, json_data)
table_data += ' case angle::Format::ID::' + format_name + ':\n'
if split: if support_test != None:
table_data += " {\n" table_data += " {\n"
table_data += json_to_table_data(format_name, "if (OnlyFL10Plus(deviceCaps))", fl10plus) table_data += json_to_table_data(format_name, "if (" + support_test + ")", supported_case)
table_data += json_to_table_data(format_name, "else", fl9_3) table_data += json_to_table_data(format_name, "else", unsupported_case)
table_data += " }\n" table_data += " }\n"
table_data += " break;\n"
else: else:
table_data += json_to_table_data(format_name, "", fl10plus) table_data += json_to_table_data(format_name, "", supported_case)
return table_data return table_data
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
"rtvFormat": "DXGI_FORMAT_A8_UNORM", "rtvFormat": "DXGI_FORMAT_A8_UNORM",
"channels": "a", "channels": "a",
"componentType": "unorm", "componentType": "unorm",
"bits": { "alpha": 8 } "bits": { "alpha": 8 },
"supportTest": "OnlyFL10Plus(deviceCaps)",
"fallbackFormat": "R8G8B8A8_UNORM"
}, },
"R8G8B8A8_UNORM": { "R8G8B8A8_UNORM": {
"texFormat": "DXGI_FORMAT_R8G8B8A8_UNORM", "texFormat": "DXGI_FORMAT_R8G8B8A8_UNORM",
...@@ -369,7 +371,9 @@ ...@@ -369,7 +371,9 @@
"rtvFormat": "DXGI_FORMAT_B5G6R5_UNORM", "rtvFormat": "DXGI_FORMAT_B5G6R5_UNORM",
"channels": "bgr", "channels": "bgr",
"componentType": "unorm", "componentType": "unorm",
"bits": { "red": 5, "green": 6, "blue": 5 } "bits": { "red": 5, "green": 6, "blue": 5 },
"supportTest": "SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)",
"fallbackFormat": "R8G8B8A8_UNORM"
}, },
"B5G5R5A1_UNORM": { "B5G5R5A1_UNORM": {
"texFormat": "DXGI_FORMAT_B5G5R5A1_UNORM", "texFormat": "DXGI_FORMAT_B5G5R5A1_UNORM",
...@@ -377,7 +381,9 @@ ...@@ -377,7 +381,9 @@
"rtvFormat": "DXGI_FORMAT_B5G5R5A1_UNORM", "rtvFormat": "DXGI_FORMAT_B5G5R5A1_UNORM",
"channels": "bgra", "channels": "bgra",
"componentType": "unorm", "componentType": "unorm",
"bits": { "red": 5, "green": 5, "blue": 5, "alpha": 1 } "bits": { "red": 5, "green": 5, "blue": 5, "alpha": 1 },
"supportTest": "SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)",
"fallbackFormat": "R8G8B8A8_UNORM"
}, },
"R8G8B8A8_SINT": { "R8G8B8A8_SINT": {
"texFormat": "DXGI_FORMAT_R8G8B8A8_SINT", "texFormat": "DXGI_FORMAT_R8G8B8A8_SINT",
...@@ -418,7 +424,9 @@ ...@@ -418,7 +424,9 @@
"rtvFormat": "DXGI_FORMAT_B4G4R4A4_UNORM", "rtvFormat": "DXGI_FORMAT_B4G4R4A4_UNORM",
"channels": "bgra", "channels": "bgra",
"componentType": "unorm", "componentType": "unorm",
"bits": { "red": 4, "green": 4, "blue": 4, "alpha": 4 } "bits": { "red": 4, "green": 4, "blue": 4, "alpha": 4 },
"supportTest": "SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)",
"fallbackFormat": "R8G8B8A8_UNORM"
}, },
"R8G8B8A8_UNORM_SRGB": { "R8G8B8A8_UNORM_SRGB": {
"texFormat": "DXGI_FORMAT_R8G8B8A8_UNORM_SRGB", "texFormat": "DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",
......
{ {
"GL_ALPHA": { "GL_ALPHA": {
"OnlyFL10Plus": "A8_UNORM", "OnlyFL10Plus(deviceCaps)": "A8_UNORM",
"OnlyFL9_3": "R8G8B8A8_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": {
"OnlyFL10Plus": "A8_UNORM", "OnlyFL10Plus(deviceCaps)": "A8_UNORM",
"OnlyFL9_3": "R8G8B8A8_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",
...@@ -15,19 +15,19 @@ ...@@ -15,19 +15,19 @@
"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": {
"OnlyFL10Plus": "R8_UNORM" "OnlyFL10Plus(deviceCaps)": "R8_UNORM"
}, },
"GL_COMPRESSED_RG11_EAC": { "GL_COMPRESSED_RG11_EAC": {
"OnlyFL10Plus": "R8G8_UNORM" "OnlyFL10Plus(deviceCaps)": "R8G8_UNORM"
}, },
"GL_COMPRESSED_RGB8_ETC2": { "GL_COMPRESSED_RGB8_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM" "OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
}, },
"GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": { "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM" "OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
}, },
"GL_COMPRESSED_RGBA8_ETC2_EAC": { "GL_COMPRESSED_RGBA8_ETC2_EAC": {
"OnlyFL10Plus": "R8G8B8A8_UNORM" "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",
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
"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": {
"OnlyFL10Plus": "R8_SNORM" "OnlyFL10Plus(deviceCaps)": "R8_SNORM"
}, },
"GL_COMPRESSED_SIGNED_RG11_EAC": { "GL_COMPRESSED_SIGNED_RG11_EAC": {
"OnlyFL10Plus": "R8G8_SNORM" "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",
...@@ -68,34 +68,34 @@ ...@@ -68,34 +68,34 @@
"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": {
"OnlyFL10Plus": "R8G8B8A8_UNORM_SRGB" "OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB"
}, },
"GL_COMPRESSED_SRGB8_ETC2": { "GL_COMPRESSED_SRGB8_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM_SRGB" "OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB"
}, },
"GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": { "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM_SRGB" "OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB"
}, },
"GL_DEPTH24_STENCIL8": { "GL_DEPTH24_STENCIL8": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT", "OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3": "D24_UNORM_S8_UINT" "OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
}, },
"GL_DEPTH32F_STENCIL8": { "GL_DEPTH32F_STENCIL8": {
"OnlyFL10Plus": "D32_FLOAT_S8X24_UINT" "OnlyFL10Plus(deviceCaps)": "D32_FLOAT_S8X24_UINT"
}, },
"GL_DEPTH_COMPONENT16": { "GL_DEPTH_COMPONENT16": {
"OnlyFL10Plus": "D16_UNORM", "OnlyFL10Plus(deviceCaps)": "D16_UNORM",
"OnlyFL9_3": "D16_UNORM" "OnlyFL9_3(deviceCaps)": "D16_UNORM"
}, },
"GL_DEPTH_COMPONENT24": { "GL_DEPTH_COMPONENT24": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT", "OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3": "D24_UNORM_S8_UINT" "OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
}, },
"GL_DEPTH_COMPONENT32F": { "GL_DEPTH_COMPONENT32F": {
"OnlyFL10Plus": "D32_FLOAT" "OnlyFL10Plus(deviceCaps)": "D32_FLOAT"
}, },
"GL_DEPTH_COMPONENT32_OES": { "GL_DEPTH_COMPONENT32_OES": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT" "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",
...@@ -139,12 +139,12 @@ ...@@ -139,12 +139,12 @@
"GL_RGB32I": "R32G32B32A32_SINT", "GL_RGB32I": "R32G32B32A32_SINT",
"GL_RGB32UI": "R32G32B32A32_UINT", "GL_RGB32UI": "R32G32B32A32_UINT",
"GL_RGB565": { "GL_RGB565": {
"SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,false>": "R8G8B8A8_UNORM", "SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)": "B5G6R5_UNORM",
"SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,true>": "B5G6R5_UNORM" "!SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)": "B5G6R5_UNORM"
}, },
"GL_RGB5_A1": { "GL_RGB5_A1": {
"SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,false>": "R8G8B8A8_UNORM", "SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)": "B5G5R5A1_UNORM",
"SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,true>": "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",
...@@ -159,8 +159,8 @@ ...@@ -159,8 +159,8 @@
"GL_RGBA32I": "R32G32B32A32_SINT", "GL_RGBA32I": "R32G32B32A32_SINT",
"GL_RGBA32UI": "R32G32B32A32_UINT", "GL_RGBA32UI": "R32G32B32A32_UINT",
"GL_RGBA4": { "GL_RGBA4": {
"SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,false>": "R8G8B8A8_UNORM", "SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)": "B4G4R4A4_UNORM",
"SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,true>": "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",
...@@ -169,8 +169,8 @@ ...@@ -169,8 +169,8 @@
"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": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT", "OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3": "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",
......
...@@ -35,6 +35,8 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -35,6 +35,8 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
{ {
case angle::Format::ID::A8_UNORM: case angle::Format::ID::A8_UNORM:
{ {
if (OnlyFL10Plus(deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::A8_UNORM, static const ANGLEFormatSet info(angle::Format::ID::A8_UNORM,
DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM,
...@@ -45,8 +47,23 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -45,8 +47,23 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
deviceCaps); deviceCaps);
return info; return info;
} }
else
{
static const ANGLEFormatSet info(angle::Format::ID::R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
}
}
case angle::Format::ID::B4G4R4A4_UNORM: case angle::Format::ID::B4G4R4A4_UNORM:
{ {
if (SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::B4G4R4A4_UNORM, static const ANGLEFormatSet info(angle::Format::ID::B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM, DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM, DXGI_FORMAT_B4G4R4A4_UNORM,
...@@ -57,8 +74,23 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -57,8 +74,23 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
deviceCaps); deviceCaps);
return info; return info;
} }
else
{
static const ANGLEFormatSet info(angle::Format::ID::R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
}
}
case angle::Format::ID::B5G5R5A1_UNORM: case angle::Format::ID::B5G5R5A1_UNORM:
{ {
if (SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::B5G5R5A1_UNORM, static const ANGLEFormatSet info(angle::Format::ID::B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM,
...@@ -69,8 +101,23 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -69,8 +101,23 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
deviceCaps); deviceCaps);
return info; return info;
} }
else
{
static const ANGLEFormatSet info(angle::Format::ID::R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
}
}
case angle::Format::ID::B5G6R5_UNORM: case angle::Format::ID::B5G6R5_UNORM:
{ {
if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::B5G6R5_UNORM, static const ANGLEFormatSet info(angle::Format::ID::B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B5G6R5_UNORM,
...@@ -81,6 +128,19 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -81,6 +128,19 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
deviceCaps); deviceCaps);
return info; return info;
} }
else
{
static const ANGLEFormatSet info(angle::Format::ID::R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
}
}
case angle::Format::ID::B8G8R8A8_UNORM: case angle::Format::ID::B8G8R8A8_UNORM:
{ {
static const ANGLEFormatSet info(angle::Format::ID::B8G8R8A8_UNORM, static const ANGLEFormatSet info(angle::Format::ID::B8G8R8A8_UNORM,
...@@ -156,7 +216,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -156,7 +216,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
return info; return info;
} }
} }
break;
case angle::Format::ID::D24_UNORM_S8_UINT: case angle::Format::ID::D24_UNORM_S8_UINT:
{ {
if (OnlyFL10Plus(deviceCaps)) if (OnlyFL10Plus(deviceCaps))
...@@ -184,7 +243,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID, ...@@ -184,7 +243,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
return info; return info;
} }
} }
break;
case angle::Format::ID::D32_FLOAT: case angle::Format::ID::D32_FLOAT:
{ {
static const ANGLEFormatSet info(angle::Format::ID::D32_FLOAT, static const ANGLEFormatSet info(angle::Format::ID::D32_FLOAT,
...@@ -743,7 +801,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -743,7 +801,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
else if (OnlyFL9_3(deviceCaps)) else if (OnlyFL9_3(deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM, angle::Format::ID::A8_UNORM,
nullptr, nullptr,
deviceCaps); deviceCaps);
return info; return info;
...@@ -782,7 +840,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -782,7 +840,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
else if (OnlyFL9_3(deviceCaps)) else if (OnlyFL9_3(deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM, angle::Format::ID::A8_UNORM,
nullptr, nullptr,
deviceCaps); deviceCaps);
return info; return info;
...@@ -1730,15 +1788,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1730,15 +1788,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
} }
case GL_RGB565: case GL_RGB565:
{ {
if (SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,false>(deviceCaps)) if (!SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM, angle::Format::ID::B5G6R5_UNORM,
Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>, Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>,
deviceCaps); deviceCaps);
return info; return info;
} }
else if (SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,true>(deviceCaps)) else if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::B5G6R5_UNORM, angle::Format::ID::B5G6R5_UNORM,
...@@ -1753,15 +1811,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1753,15 +1811,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
} }
case GL_RGB5_A1: case GL_RGB5_A1:
{ {
if (SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,false>(deviceCaps)) if (!SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM, angle::Format::ID::B5G5R5A1_UNORM,
nullptr, nullptr,
deviceCaps); deviceCaps);
return info; return info;
} }
else if (SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,true>(deviceCaps)) else if (SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::B5G5R5A1_UNORM, angle::Format::ID::B5G5R5A1_UNORM,
...@@ -1888,15 +1946,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -1888,15 +1946,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
} }
case GL_RGBA4: case GL_RGBA4:
{ {
if (SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,false>(deviceCaps)) if (!SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM, angle::Format::ID::B4G4R4A4_UNORM,
nullptr, nullptr,
deviceCaps); deviceCaps);
return info; return info;
} }
else if (SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,true>(deviceCaps)) else if (SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps))
{ {
static const TextureFormat info(internalFormat, static const TextureFormat info(internalFormat,
angle::Format::ID::B4G4R4A4_UNORM, angle::Format::ID::B4G4R4A4_UNORM,
......
...@@ -28,8 +28,7 @@ inline bool OnlyFL9_3(const Renderer11DeviceCaps &deviceCaps) ...@@ -28,8 +28,7 @@ inline bool OnlyFL9_3(const Renderer11DeviceCaps &deviceCaps)
return (deviceCaps.featureLevel == D3D_FEATURE_LEVEL_9_3); return (deviceCaps.featureLevel == D3D_FEATURE_LEVEL_9_3);
} }
template <DXGI_FORMAT format, bool requireSupport> inline bool SupportsFormat(DXGI_FORMAT format, const Renderer11DeviceCaps &deviceCaps)
bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
{ {
// Must support texture, SRV and RTV support // Must support texture, SRV and RTV support
UINT mustSupport = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURECUBE | UINT mustSupport = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURECUBE |
...@@ -63,26 +62,12 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps) ...@@ -63,26 +62,12 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
return false; return false;
} }
// This 'SupportsFormat' function is used by individual entries in the D3D11 Format Map below,
// which maps GL formats to DXGI formats.
if (requireSupport)
{
// This means that ANGLE would like to use the entry in the map if the inputted DXGI format // This means that ANGLE would like to use the entry in the map if the inputted DXGI format
// *IS* supported. // *IS* supported.
// e.g. the entry might map GL_RGB5_A1 to DXGI_FORMAT_B5G5R5A1, which should only be used if // e.g. the entry might map GL_RGB5_A1 to DXGI_FORMAT_B5G5R5A1, which should only be used if
// DXGI_FORMAT_B5G5R5A1 is supported. // DXGI_FORMAT_B5G5R5A1 is supported.
// In this case, we should only return 'true' if the format *IS* supported. // In this case, we should only return 'true' if the format *IS* supported.
return fullSupport; return fullSupport;
}
else
{
// This means that ANGLE would like to use the entry in the map if the inputted DXGI format
// *ISN'T* supported.
// This might be a fallback entry. e.g. for ANGLE to use DXGI_FORMAT_R8G8B8A8_UNORM if
// DXGI_FORMAT_B5G5R5A1 isn't supported.
// In this case, we should only return 'true' if the format *ISN'T* supported.
return !fullSupport;
}
} }
} // namespace d3d11 } // namespace d3d11
......
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