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):
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':
return 'NONE'
elif 'swizzleFormat' in angle_format:
......@@ -207,17 +208,22 @@ def get_swizzle_format_id(angle_format_id, angle_format):
else:
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 = '';
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)
indent = ' '
if requirements_fn != None:
if idx == 0:
table_data += ' if (' + requirements_fn + '(deviceCaps))\n'
table_data += ' if (' + requirements_fn + ')\n'
else:
table_data += ' else if (' + requirements_fn + '(deviceCaps))\n'
table_data += ' else if (' + requirements_fn + ')\n'
table_data += ' {\n'
indent += ' '
......@@ -243,11 +249,11 @@ def parse_json_into_switch_texture_format_string(json_map, json_data):
if isinstance(json_map[internal_format], basestring):
angle_format_id = json_map[internal_format]
table_data += get_texture_format_item(0, internal_format, None, angle_format_id, json_data[angle_format_id])
table_data += get_texture_format_item(0, internal_format, None, angle_format_id, json_data)
else:
for idx, requirements_map in enumerate(sorted(json_map[internal_format].iteritems())):
angle_format_id = requirements_map[1]
table_data += get_texture_format_item(idx, internal_format, requirements_map[0], angle_format_id, json_data[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 += ' {\n'
table_data += ' break;\n'
......@@ -312,45 +318,64 @@ def json_to_table_data(format_name, prefix, json):
# Derived values.
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:
return split_format_entry_template.format(**parsed)
else:
return format_entry_template.format(**parsed)
def parse_json_angle_format_case(format_name, angle_format, json_data):
supported_case = {}
unsupported_case = {}
support_test = None
fallback = None
for k, v in angle_format.iteritems():
if k == "FL10Plus":
assert support_test is None
support_test = "OnlyFL10Plus(deviceCaps)"
for k2, v2 in v.iteritems():
supported_case[k2] = v2
elif k == "FL9_3":
split = True
for k2, v2 in v.iteritems():
unsupported_case[k2] = v2
elif k == "supportTest":
assert support_test is None
support_test = v
elif k == "fallbackFormat":
fallback = v
else:
supported_case[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 angle_format_item in sorted(json_data.iteritems()):
table_data += ' case angle::Format::ID::' + angle_format_item[0] + ':\n'
format_name = angle_format_item[0]
angle_format = angle_format_item[1]
fl10plus = {}
fl9_3 = {}
split = False
for k, v in angle_format.iteritems():
if k == "FL10Plus":
split = True
for k2, v2 in v.iteritems():
fl10plus[k2] = v2
elif k == "FL9_3":
split = True
for k2, v2 in v.iteritems():
fl9_3[k2] = v2
else:
fl10plus[k] = v
fl9_3[k] = v
if split:
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 support_test != None:
table_data += " {\n"
table_data += json_to_table_data(format_name, "if (OnlyFL10Plus(deviceCaps))", fl10plus)
table_data += json_to_table_data(format_name, "else", fl9_3)
table_data += json_to_table_data(format_name, "if (" + support_test + ")", supported_case)
table_data += json_to_table_data(format_name, "else", unsupported_case)
table_data += " }\n"
table_data += " break;\n"
else:
table_data += json_to_table_data(format_name, "", fl10plus)
table_data += json_to_table_data(format_name, "", supported_case)
return table_data
......
......@@ -7,7 +7,9 @@
"rtvFormat": "DXGI_FORMAT_A8_UNORM",
"channels": "a",
"componentType": "unorm",
"bits": { "alpha": 8 }
"bits": { "alpha": 8 },
"supportTest": "OnlyFL10Plus(deviceCaps)",
"fallbackFormat": "R8G8B8A8_UNORM"
},
"R8G8B8A8_UNORM": {
"texFormat": "DXGI_FORMAT_R8G8B8A8_UNORM",
......@@ -369,7 +371,9 @@
"rtvFormat": "DXGI_FORMAT_B5G6R5_UNORM",
"channels": "bgr",
"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": {
"texFormat": "DXGI_FORMAT_B5G5R5A1_UNORM",
......@@ -377,7 +381,9 @@
"rtvFormat": "DXGI_FORMAT_B5G5R5A1_UNORM",
"channels": "bgra",
"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": {
"texFormat": "DXGI_FORMAT_R8G8B8A8_SINT",
......@@ -418,7 +424,9 @@
"rtvFormat": "DXGI_FORMAT_B4G4R4A4_UNORM",
"channels": "bgra",
"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": {
"texFormat": "DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",
......
{
"GL_ALPHA": {
"OnlyFL10Plus": "A8_UNORM",
"OnlyFL9_3": "R8G8B8A8_UNORM"
"OnlyFL10Plus(deviceCaps)": "A8_UNORM",
"OnlyFL9_3(deviceCaps)": "A8_UNORM"
},
"GL_ALPHA16F_EXT": "R16G16B16A16_FLOAT",
"GL_ALPHA32F_EXT": "R32G32B32A32_FLOAT",
"GL_ALPHA8_EXT": {
"OnlyFL10Plus": "A8_UNORM",
"OnlyFL9_3": "R8G8B8A8_UNORM"
"OnlyFL10Plus(deviceCaps)": "A8_UNORM",
"OnlyFL9_3(deviceCaps)": "A8_UNORM"
},
"GL_BGR565_ANGLEX": "B5G6R5_UNORM",
"GL_BGR5_A1_ANGLEX": "B8G8R8A8_UNORM",
......@@ -15,19 +15,19 @@
"GL_BGRA8_EXT": "B8G8R8A8_UNORM",
"GL_BGRA_EXT": "B8G8R8A8_UNORM",
"GL_COMPRESSED_R11_EAC": {
"OnlyFL10Plus": "R8_UNORM"
"OnlyFL10Plus(deviceCaps)": "R8_UNORM"
},
"GL_COMPRESSED_RG11_EAC": {
"OnlyFL10Plus": "R8G8_UNORM"
"OnlyFL10Plus(deviceCaps)": "R8G8_UNORM"
},
"GL_COMPRESSED_RGB8_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM"
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
},
"GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM"
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
},
"GL_COMPRESSED_RGBA8_ETC2_EAC": {
"OnlyFL10Plus": "R8G8B8A8_UNORM"
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM"
},
"GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": "BC1_UNORM",
"GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": "BC2_UNORM",
......@@ -48,10 +48,10 @@
"GL_COMPRESSED_RGBA_ASTC_12x12_KHR": "NONE",
"GL_COMPRESSED_RGB_S3TC_DXT1_EXT": "BC1_UNORM",
"GL_COMPRESSED_SIGNED_R11_EAC": {
"OnlyFL10Plus": "R8_SNORM"
"OnlyFL10Plus(deviceCaps)": "R8_SNORM"
},
"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_5x4_KHR": "NONE",
......@@ -68,34 +68,34 @@
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR": "NONE",
"GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC": {
"OnlyFL10Plus": "R8G8B8A8_UNORM_SRGB"
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB"
},
"GL_COMPRESSED_SRGB8_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM_SRGB"
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB"
},
"GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2": {
"OnlyFL10Plus": "R8G8B8A8_UNORM_SRGB"
"OnlyFL10Plus(deviceCaps)": "R8G8B8A8_UNORM_SRGB"
},
"GL_DEPTH24_STENCIL8": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT",
"OnlyFL9_3": "D24_UNORM_S8_UINT"
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_DEPTH32F_STENCIL8": {
"OnlyFL10Plus": "D32_FLOAT_S8X24_UINT"
"OnlyFL10Plus(deviceCaps)": "D32_FLOAT_S8X24_UINT"
},
"GL_DEPTH_COMPONENT16": {
"OnlyFL10Plus": "D16_UNORM",
"OnlyFL9_3": "D16_UNORM"
"OnlyFL10Plus(deviceCaps)": "D16_UNORM",
"OnlyFL9_3(deviceCaps)": "D16_UNORM"
},
"GL_DEPTH_COMPONENT24": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT",
"OnlyFL9_3": "D24_UNORM_S8_UINT"
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_DEPTH_COMPONENT32F": {
"OnlyFL10Plus": "D32_FLOAT"
"OnlyFL10Plus(deviceCaps)": "D32_FLOAT"
},
"GL_DEPTH_COMPONENT32_OES": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT"
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_ETC1_RGB8_OES": "R8G8B8A8_UNORM",
"GL_ETC1_RGB8_LOSSY_DECODE_ANGLE": "BC1_UNORM",
......@@ -139,12 +139,12 @@
"GL_RGB32I": "R32G32B32A32_SINT",
"GL_RGB32UI": "R32G32B32A32_UINT",
"GL_RGB565": {
"SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,false>": "R8G8B8A8_UNORM",
"SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,true>": "B5G6R5_UNORM"
"SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)": "B5G6R5_UNORM",
"!SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)": "B5G6R5_UNORM"
},
"GL_RGB5_A1": {
"SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,false>": "R8G8B8A8_UNORM",
"SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,true>": "B5G5R5A1_UNORM"
"SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)": "B5G5R5A1_UNORM",
"!SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps)": "B5G5R5A1_UNORM"
},
"GL_RGB8": "R8G8B8A8_UNORM",
"GL_RGB8I": "R8G8B8A8_SINT",
......@@ -159,8 +159,8 @@
"GL_RGBA32I": "R32G32B32A32_SINT",
"GL_RGBA32UI": "R32G32B32A32_UINT",
"GL_RGBA4": {
"SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,false>": "R8G8B8A8_UNORM",
"SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,true>": "B4G4R4A4_UNORM"
"SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)": "B4G4R4A4_UNORM",
"!SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps)": "B4G4R4A4_UNORM"
},
"GL_RGBA8": "R8G8B8A8_UNORM",
"GL_RGBA8I": "R8G8B8A8_SINT",
......@@ -169,8 +169,8 @@
"GL_SRGB8": "R8G8B8A8_UNORM_SRGB",
"GL_SRGB8_ALPHA8": "R8G8B8A8_UNORM_SRGB",
"GL_STENCIL_INDEX8": {
"OnlyFL10Plus": "D24_UNORM_S8_UINT",
"OnlyFL9_3": "D24_UNORM_S8_UINT"
"OnlyFL10Plus(deviceCaps)": "D24_UNORM_S8_UINT",
"OnlyFL9_3(deviceCaps)": "D24_UNORM_S8_UINT"
},
"GL_R16_EXT": "R16_UNORM",
"GL_RG16_EXT": "R16G16_UNORM",
......
......@@ -35,51 +35,111 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
{
case 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_UNKNOWN,
DXGI_FORMAT_A8_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
if (OnlyFL10Plus(deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::A8_UNORM,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_A8_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
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:
{
static const ANGLEFormatSet info(angle::Format::ID::B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B4G4R4A4_UNORM,
angle::Format::ID::B4G4R4A4_UNORM,
deviceCaps);
return info;
if (SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B4G4R4A4_UNORM,
angle::Format::ID::B4G4R4A4_UNORM,
deviceCaps);
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:
{
static const ANGLEFormatSet info(angle::Format::ID::B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B5G5R5A1_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
if (SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B5G5R5A1_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
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:
{
static const ANGLEFormatSet info(angle::Format::ID::B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B5G6R5_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
return info;
if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps))
{
static const ANGLEFormatSet info(angle::Format::ID::B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B5G6R5_UNORM,
angle::Format::ID::R8G8B8A8_UNORM,
deviceCaps);
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:
{
......@@ -156,7 +216,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
return info;
}
}
break;
case angle::Format::ID::D24_UNORM_S8_UINT:
{
if (OnlyFL10Plus(deviceCaps))
......@@ -184,7 +243,6 @@ const ANGLEFormatSet &GetANGLEFormatSet(angle::Format::ID formatID,
return info;
}
}
break;
case angle::Format::ID::D32_FLOAT:
{
static const ANGLEFormatSet info(angle::Format::ID::D32_FLOAT,
......@@ -743,7 +801,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
else if (OnlyFL9_3(deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM,
angle::Format::ID::A8_UNORM,
nullptr,
deviceCaps);
return info;
......@@ -782,7 +840,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
else if (OnlyFL9_3(deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM,
angle::Format::ID::A8_UNORM,
nullptr,
deviceCaps);
return info;
......@@ -1730,15 +1788,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
}
case GL_RGB565:
{
if (SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,false>(deviceCaps))
if (!SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM,
angle::Format::ID::B5G6R5_UNORM,
Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>,
deviceCaps);
return info;
}
else if (SupportsFormat<DXGI_FORMAT_B5G6R5_UNORM,true>(deviceCaps))
else if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::B5G6R5_UNORM,
......@@ -1753,15 +1811,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
}
case GL_RGB5_A1:
{
if (SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,false>(deviceCaps))
if (!SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM,
angle::Format::ID::B5G5R5A1_UNORM,
nullptr,
deviceCaps);
return info;
}
else if (SupportsFormat<DXGI_FORMAT_B5G5R5A1_UNORM,true>(deviceCaps))
else if (SupportsFormat(DXGI_FORMAT_B5G5R5A1_UNORM, deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::B5G5R5A1_UNORM,
......@@ -1888,15 +1946,15 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
}
case GL_RGBA4:
{
if (SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,false>(deviceCaps))
if (!SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::R8G8B8A8_UNORM,
angle::Format::ID::B4G4R4A4_UNORM,
nullptr,
deviceCaps);
return info;
}
else if (SupportsFormat<DXGI_FORMAT_B4G4R4A4_UNORM,true>(deviceCaps))
else if (SupportsFormat(DXGI_FORMAT_B4G4R4A4_UNORM, deviceCaps))
{
static const TextureFormat info(internalFormat,
angle::Format::ID::B4G4R4A4_UNORM,
......
......@@ -28,8 +28,7 @@ inline bool OnlyFL9_3(const Renderer11DeviceCaps &deviceCaps)
return (deviceCaps.featureLevel == D3D_FEATURE_LEVEL_9_3);
}
template <DXGI_FORMAT format, bool requireSupport>
bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
inline bool SupportsFormat(DXGI_FORMAT format, const Renderer11DeviceCaps &deviceCaps)
{
// Must support texture, SRV and RTV support
UINT mustSupport = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURECUBE |
......@@ -63,26 +62,12 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
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
// *IS* supported.
// e.g. the entry might map GL_RGB5_A1 to DXGI_FORMAT_B5G5R5A1, which should only be used if
// DXGI_FORMAT_B5G5R5A1 is supported.
// In this case, we should only return 'true' if the format *IS* supported.
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;
}
// This means that ANGLE would like to use the entry in the map if the inputted DXGI format
// *IS* supported.
// e.g. the entry might map GL_RGB5_A1 to DXGI_FORMAT_B5G5R5A1, which should only be used if
// DXGI_FORMAT_B5G5R5A1 is supported.
// In this case, we should only return 'true' if the format *IS* supported.
return fullSupport;
}
} // 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