Commit b2e4863c by Jamie Madill Committed by Commit Bot

Replace std::map with switch in load functions.

BUG=angleproject:1455 Change-Id: Ica74ea5503efc0315bc4d98aa322da523a30b24c Reviewed-on: https://chromium-review.googlesource.com/367696Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 2f9b5e6f
......@@ -271,7 +271,7 @@ gl::Error Image11::loadData(const gl::Box &area,
const d3d11::Format &d3dFormatInfo =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(type).loadFunction;
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(type).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
......@@ -310,7 +310,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
const d3d11::Format &d3dFormatInfo =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE).loadFunction;
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(GL_UNSIGNED_BYTE).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
......@@ -403,7 +403,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const auto &destD3D11Format =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
auto loadFunction = destD3D11Format.loadFunctions.at(destFormatInfo.type);
auto loadFunction = destD3D11Format.loadFunctions(destFormatInfo.type);
if (loadFunction.requiresConversion)
{
size_t bufferSize = destFormatInfo.pixelBytes * sourceArea.width * sourceArea.height;
......
......@@ -664,7 +664,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
MemoryBuffer *conversionBuffer = nullptr;
const uint8_t *data = nullptr;
d3d11::LoadImageFunctionInfo loadFunctionInfo = d3d11Format.loadFunctions.at(type);
LoadImageFunctionInfo loadFunctionInfo = d3d11Format.loadFunctions(type);
if (loadFunctionInfo.requiresConversion)
{
ANGLE_TRY(mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer));
......
......@@ -76,19 +76,17 @@ void UnreachableLoadFunction(size_t width,
UNREACHABLE();
}}
}} // namespace
{load_functions_data}}} // namespace
// TODO we can replace these maps with more generated code
const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum {internal_format},
DXGI_FORMAT {dxgi_format})
LoadFunctionMap GetLoadFunctionsMap(GLenum {internal_format}, DXGI_FORMAT {dxgi_format})
{{
// clang-format off
switch ({internal_format})
{{
{data}
{switch_data}
default:
{{
static std::map<GLenum, LoadImageFunctionInfo> emptyLoadFunctionsMap;
static LoadFunctionMap emptyLoadFunctionsMap;
return emptyLoadFunctionsMap;
}}
}}
......@@ -105,32 +103,38 @@ internal_format_param = 'internalFormat'
dxgi_format_param = 'dxgiFormat'
dxgi_format_unknown = "DXGI_FORMAT_UNKNOWN"
def get_function_maps_string(typestr, function):
requiresConversion = str('LoadToNative<' not in function).lower()
return ' { ' + typestr + ', LoadImageFunctionInfo(' + function + ', ' + requiresConversion + ') },\n'
def get_unknown_format_string(s, dxgi_to_type_map, dxgi_unknown_string):
if dxgi_unknown_string not in dxgi_to_type_map:
return ''
table_data = ''
for gl_type, load_function in sorted(dxgi_to_type_map[dxgi_unknown_string].iteritems()):
table_data += s + get_function_maps_string(gl_type, load_function)
return table_data
def get_load_function_map_snippet(s, insert_map_string):
load_function_map_snippet = ''
load_function_map_snippet += s + 'static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = {\n'
load_function_map_snippet += insert_map_string
load_function_map_snippet += s + '};\n\n'
load_function_map_snippet += s + 'return loadFunctionsMap;\n'
return load_function_map_snippet
def parse_json_into_switch_string(json_data):
def load_functions_name(internal_format, dxgi_format):
short_name = dxgi_format if dxgi_format == "default" else dxgi_format[len("DXGI_FORMAT_"):]
return internal_format[3:] + "_to_" + short_name
def unknown_func_name(internal_format):
return load_functions_name(internal_format, "default")
def get_load_func(func_name, type_functions):
snippet = "LoadImageFunctionInfo " + func_name + "(GLenum type)\n"
snippet += "{\n"
snippet += " switch (type)\n"
snippet += " {\n"
for gl_type, load_function in sorted(type_functions.iteritems()):
snippet += " case " + gl_type + ":\n"
requiresConversion = str('LoadToNative<' not in load_function).lower()
snippet += " return LoadImageFunctionInfo(" + load_function + ", " + requiresConversion + ");\n"
snippet += " default:\n"
snippet += " UNREACHABLE();\n"
snippet += " return LoadImageFunctionInfo(UnreachableLoadFunction, true);\n"
snippet += " }\n"
snippet += "}\n"
snippet += "\n"
return snippet
def get_unknown_load_func(dxgi_to_type_map, internal_format):
assert dxgi_format_unknown in dxgi_to_type_map
return get_load_func(unknown_func_name(internal_format), dxgi_to_type_map[dxgi_format_unknown])
def parse_json(json_data):
table_data = ''
load_functions_data = ''
for internal_format, dxgi_to_type_map in sorted(json_data.iteritems()):
s = ' '
......@@ -151,35 +155,25 @@ def parse_json_into_switch_string(json_data):
if dxgi_format == dxgi_format_unknown:
continue
func_name = load_functions_name(internal_format, dxgi_format)
# Main case statements
table_data += s + 'case ' + dxgi_format + ':\n'
table_data += s + '{\n'
s += ' '
insert_map_string = ''
table_data += s + ' return ' + func_name + ';\n'
if dxgi_format_unknown in dxgi_to_type_map:
for gl_type, load_function in dxgi_to_type_map[dxgi_format_unknown].iteritems():
if gl_type not in type_functions:
type_functions[gl_type] = load_function
for gl_type, load_function in sorted(type_functions.iteritems()):
insert_map_string += s + get_function_maps_string(gl_type, load_function)
table_data += get_load_function_map_snippet(s, insert_map_string)
s = s[4:]
table_data += s + '}\n'
load_functions_data += get_load_func(func_name, type_functions)
if do_switch:
table_data += s + 'default:\n'
if dxgi_format_unknown in dxgi_to_type_map:
table_data += s + '{\n'
s += ' '
dxgi_unknown_str = get_unknown_format_string(
s, dxgi_to_type_map, dxgi_format_unknown);
table_data += get_load_function_map_snippet(s, dxgi_unknown_str)
s = s[4:]
table_data += s + '}\n'
table_data += s + ' return ' + unknown_func_name(internal_format) + ';\n'
load_functions_data += get_unknown_load_func(dxgi_to_type_map, internal_format)
else:
table_data += s + ' break;\n'
......@@ -189,14 +183,15 @@ def parse_json_into_switch_string(json_data):
s = s[4:]
table_data += s + '}\n'
return table_data
return table_data, load_functions_data
json_data = angle_format.load_json('load_functions_data.json')
table_data = parse_json_into_switch_string(json_data)
switch_data, load_functions_data = parse_json(json_data)
output = template.format(internal_format = internal_format_param,
dxgi_format = dxgi_format_param,
data=table_data)
switch_data = switch_data,
load_functions_data = load_functions_data)
with open('load_functions_table_autogen.cpp', 'wt') as out_file:
out_file.write(output)
......
{
"GL_RG8_SNORM": {
"DXGI_FORMAT_R8G8_SNORM": {
"GL_BYTE": "LoadToNative<GLbyte,2>"
"GL_BYTE": "LoadToNative<GLbyte, 2>"
}
},
"GL_SRGB8": {
"DXGI_FORMAT_R8G8B8A8_UNORM_SRGB": {
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte,0xFF>"
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte, 0xFF>"
}
},
"GL_RGBA8I": {
"DXGI_FORMAT_R8G8B8A8_SINT": {
"GL_BYTE": "LoadToNative<GLbyte,4>"
"GL_BYTE": "LoadToNative<GLbyte, 4>"
}
},
"GL_R8_SNORM": {
"DXGI_FORMAT_R8_SNORM": {
"GL_BYTE": "LoadToNative<GLbyte,1>"
"GL_BYTE": "LoadToNative<GLbyte, 1>"
}
},
"GL_RGBA8_SNORM": {
"DXGI_FORMAT_R8G8B8A8_SNORM": {
"GL_BYTE": "LoadToNative<GLbyte,4>"
"GL_BYTE": "LoadToNative<GLbyte, 4>"
}
},
"GL_R16I": {
"DXGI_FORMAT_R16_SINT": {
"GL_SHORT": "LoadToNative<GLshort,1>"
"GL_SHORT": "LoadToNative<GLshort, 1>"
}
},
"GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC": {
......@@ -41,7 +41,7 @@
},
"GL_RGB32UI": {
"DXGI_FORMAT_R32G32B32A32_UINT": {
"GL_UNSIGNED_INT": "LoadToNative3To4<GLuint,0x00000001>"
"GL_UNSIGNED_INT": "LoadToNative3To4<GLuint, 0x00000001>"
}
},
"GL_ALPHA32F_EXT": {
......@@ -51,13 +51,13 @@
},
"GL_R16UI": {
"DXGI_FORMAT_R16_UINT": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,1>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 1>"
}
},
"GL_RGB9_E5": {
"DXGI_FORMAT_R9G9B9E5_SHAREDEXP": {
"GL_HALF_FLOAT": "LoadRGB16FToRGB9E5",
"GL_UNSIGNED_INT_5_9_9_9_REV": "LoadToNative<GLuint,1>",
"GL_UNSIGNED_INT_5_9_9_9_REV": "LoadToNative<GLuint, 1>",
"GL_FLOAT": "LoadRGB32FToRGB9E5",
"GL_HALF_FLOAT_OES": "LoadRGB16FToRGB9E5"
}
......@@ -69,12 +69,12 @@
},
"GL_RGBA32UI": {
"DXGI_FORMAT_R32G32B32A32_UINT": {
"GL_UNSIGNED_INT": "LoadToNative<GLuint,4>"
"GL_UNSIGNED_INT": "LoadToNative<GLuint, 4>"
}
},
"GL_RG8UI": {
"DXGI_FORMAT_R8G8_UINT": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,2>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 2>"
}
},
"GL_LUMINANCE32F_EXT": {
......@@ -89,27 +89,27 @@
},
"GL_R16F": {
"DXGI_FORMAT_R16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative<GLhalf,1>",
"GL_HALF_FLOAT": "LoadToNative<GLhalf, 1>",
"GL_FLOAT": "Load32FTo16F<1>",
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf,1>"
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf, 1>"
}
},
"GL_RGBA8UI": {
"DXGI_FORMAT_R8G8B8A8_UINT": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>"
}
},
"GL_BGRA4_ANGLEX": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT": "LoadRGBA4ToRGBA8",
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>"
}
},
"GL_RGBA16F": {
"DXGI_FORMAT_R16G16B16A16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative<GLhalf,4>",
"GL_HALF_FLOAT": "LoadToNative<GLhalf, 4>",
"GL_FLOAT": "Load32FTo16F<4>",
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf,4>"
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf, 4>"
}
},
"GL_LUMINANCE8_EXT": {
......@@ -119,7 +119,7 @@
},
"GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4,4,16>"
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
},
"GL_RGB": {
......@@ -131,7 +131,7 @@
"GL_RGB5_A1": {
"DXGI_FORMAT_R8G8B8A8_UNORM": {
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadRGB10A2ToRGBA8",
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>",
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>",
"GL_UNSIGNED_SHORT_5_5_5_1": "LoadRGB5A1ToRGBA8"
},
"DXGI_FORMAT_B5G5R5A1_UNORM": {
......@@ -142,7 +142,7 @@
},
"GL_RGB16UI": {
"DXGI_FORMAT_R16G16B16A16_UINT": {
"GL_UNSIGNED_SHORT": "LoadToNative3To4<GLushort,0x0001>"
"GL_UNSIGNED_SHORT": "LoadToNative3To4<GLushort, 0x0001>"
}
},
"GL_BGRA_EXT": {
......@@ -157,12 +157,12 @@
},
"GL_RGBA32F": {
"DXGI_FORMAT_R32G32B32A32_FLOAT": {
"GL_FLOAT": "LoadToNative<GLfloat,4>"
"GL_FLOAT": "LoadToNative<GLfloat, 4>"
}
},
"GL_RGBA32I": {
"DXGI_FORMAT_R32G32B32A32_SINT": {
"GL_INT": "LoadToNative<GLint,4>"
"GL_INT": "LoadToNative<GLint, 4>"
}
},
"GL_LUMINANCE8_ALPHA8_EXT": {
......@@ -172,12 +172,12 @@
},
"GL_RG8": {
"DXGI_FORMAT_R8G8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,2>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 2>"
}
},
"GL_RGB10_A2": {
"DXGI_FORMAT_R10G10B10A2_UNORM": {
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative<GLuint,1>"
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative<GLuint, 1>"
}
},
"GL_COMPRESSED_SIGNED_RG11_EAC": {
......@@ -188,30 +188,30 @@
"GL_DEPTH_COMPONENT16": {
"DXGI_FORMAT_R16_TYPELESS": {
"GL_UNSIGNED_INT": "LoadR32ToR16",
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,1>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 1>"
},
"DXGI_FORMAT_D16_UNORM": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,1>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 1>"
}
},
"GL_RGB32I": {
"DXGI_FORMAT_R32G32B32A32_SINT": {
"GL_INT": "LoadToNative3To4<GLint,0x00000001>"
"GL_INT": "LoadToNative3To4<GLint, 0x00000001>"
}
},
"GL_R8": {
"DXGI_FORMAT_R8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,1>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 1>"
}
},
"GL_RGB32F": {
"DXGI_FORMAT_R32G32B32A32_FLOAT": {
"GL_FLOAT": "LoadToNative3To4<GLfloat,gl::Float32One>"
"GL_FLOAT": "LoadToNative3To4<GLfloat, gl::Float32One>"
}
},
"GL_R11F_G11F_B10F": {
"DXGI_FORMAT_R11G11B10_FLOAT": {
"GL_UNSIGNED_INT_10F_11F_11F_REV": "LoadToNative<GLuint,1>",
"GL_UNSIGNED_INT_10F_11F_11F_REV": "LoadToNative<GLuint, 1>",
"GL_HALF_FLOAT": "LoadRGB16FToRG11B10F",
"GL_FLOAT": "LoadRGB32FToRG11B10F",
"GL_HALF_FLOAT_OES": "LoadRGB16FToRG11B10F"
......@@ -219,7 +219,7 @@
},
"GL_RGB8": {
"DXGI_FORMAT_R8G8B8A8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte,0xFF>"
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte, 0xFF>"
}
},
"GL_LUMINANCE_ALPHA": {
......@@ -236,22 +236,22 @@
},
"GL_RGBA16I": {
"DXGI_FORMAT_R16G16B16A16_SINT": {
"GL_SHORT": "LoadToNative<GLshort,4>"
"GL_SHORT": "LoadToNative<GLshort, 4>"
}
},
"GL_R8I": {
"DXGI_FORMAT_R8_SINT": {
"GL_BYTE": "LoadToNative<GLbyte,1>"
"GL_BYTE": "LoadToNative<GLbyte, 1>"
}
},
"GL_RGB8_SNORM": {
"DXGI_FORMAT_R8G8B8A8_SNORM": {
"GL_BYTE": "LoadToNative3To4<GLbyte,0x7F>"
"GL_BYTE": "LoadToNative3To4<GLbyte, 0x7F>"
}
},
"GL_RG32F": {
"DXGI_FORMAT_R32G32_FLOAT": {
"GL_FLOAT": "LoadToNative<GLfloat,2>"
"GL_FLOAT": "LoadToNative<GLfloat, 2>"
}
},
"GL_DEPTH_COMPONENT32F": {
......@@ -264,12 +264,12 @@
},
"GL_RG32I": {
"DXGI_FORMAT_R32G32_SINT": {
"GL_INT": "LoadToNative<GLint,2>"
"GL_INT": "LoadToNative<GLint, 2>"
}
},
"GL_ALPHA8_EXT": {
"DXGI_FORMAT_A8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,1>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 1>"
},
"DXGI_FORMAT_R8G8B8A8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadA8ToRGBA8"
......@@ -277,12 +277,12 @@
},
"GL_RG32UI": {
"DXGI_FORMAT_R32G32_UINT": {
"GL_UNSIGNED_INT": "LoadToNative<GLuint,2>"
"GL_UNSIGNED_INT": "LoadToNative<GLuint, 2>"
}
},
"GL_RGBA16UI": {
"DXGI_FORMAT_R16G16B16A16_UINT": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,4>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 4>"
}
},
"GL_COMPRESSED_RGBA8_ETC2_EAC": {
......@@ -292,7 +292,7 @@
},
"GL_RGB8I": {
"DXGI_FORMAT_R8G8B8A8_SINT": {
"GL_BYTE": "LoadToNative3To4<GLbyte,0x01>"
"GL_BYTE": "LoadToNative3To4<GLbyte, 0x01>"
}
},
"GL_COMPRESSED_SRGB8_ETC2": {
......@@ -310,24 +310,24 @@
},
"GL_RG8I": {
"DXGI_FORMAT_R8G8_SINT": {
"GL_BYTE": "LoadToNative<GLbyte,2>"
"GL_BYTE": "LoadToNative<GLbyte, 2>"
}
},
"GL_R32UI": {
"DXGI_FORMAT_R32_UINT": {
"GL_UNSIGNED_INT": "LoadToNative<GLuint,1>"
"GL_UNSIGNED_INT": "LoadToNative<GLuint, 1>"
}
},
"GL_BGR5_A1_ANGLEX": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>",
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>",
"GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT": "LoadRGB5A1ToRGBA8"
}
},
"GL_BGR565_ANGLEX": {
"DXGI_FORMAT_B5G6R5_UNORM": {
"GL_UNSIGNED_SHORT_5_6_5": "LoadRGB565ToBGR565",
"GL_UNSIGNED_BYTE": "LoadToNative<GLushort,1>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLushort, 1>"
}
},
"GL_COMPRESSED_RG11_EAC": {
......@@ -337,7 +337,7 @@
},
"GL_SRGB8_ALPHA8": {
"DXGI_FORMAT_R8G8B8A8_UNORM_SRGB": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>"
}
},
"GL_LUMINANCE_ALPHA16F_EXT": {
......@@ -363,12 +363,12 @@
},
"GL_RGB16I": {
"DXGI_FORMAT_R16G16B16A16_SINT": {
"GL_SHORT": "LoadToNative3To4<GLshort,0x0001>"
"GL_SHORT": "LoadToNative3To4<GLshort, 0x0001>"
}
},
"GL_R8UI": {
"DXGI_FORMAT_R8_UINT": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,1>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 1>"
}
},
"GL_ALPHA": {
......@@ -385,9 +385,9 @@
},
"GL_RGB16F": {
"DXGI_FORMAT_R16G16B16A16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative3To4<GLhalf,gl::Float16One>",
"GL_HALF_FLOAT": "LoadToNative3To4<GLhalf, gl::Float16One>",
"GL_FLOAT": "LoadRGB32FToRGBA16F",
"GL_HALF_FLOAT_OES": "LoadToNative3To4<GLhalf,gl::Float16One>"
"GL_HALF_FLOAT_OES": "LoadToNative3To4<GLhalf, gl::Float16One>"
}
},
"GL_COMPRESSED_SIGNED_R11_EAC": {
......@@ -397,18 +397,17 @@
},
"GL_COMPRESSED_RGB_S3TC_DXT1_EXT": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4,4,8>"
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 8>"
}
},
"GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4,4,8>"
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 8>"
}
},
"GL_STENCIL_INDEX8": {
"DXGI_FORMAT_UNKNOWN": {
"DXGI_FORMAT_R24G8_TYPELESS": "UnimplementedLoadFunction",
"DXGI_FORMAT_D24_UNORM_S8_UINT": "UnimplementedLoadFunction"
"GL_UNSIGNED_BYTE": "UnimplementedLoadFunction"
}
},
"GL_LUMINANCE_ALPHA32F_EXT": {
......@@ -418,7 +417,7 @@
},
"GL_RGB8UI": {
"DXGI_FORMAT_R8G8B8A8_UINT": {
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte,0x01>"
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte, 0x01>"
}
},
"GL_DEPTH_COMPONENT24": {
......@@ -431,7 +430,7 @@
},
"GL_R32I": {
"DXGI_FORMAT_R32_SINT": {
"GL_INT": "LoadToNative<GLint,1>"
"GL_INT": "LoadToNative<GLint, 1>"
}
},
"GL_DEPTH_COMPONENT32_OES": {
......@@ -441,24 +440,24 @@
},
"GL_R32F": {
"DXGI_FORMAT_R32_FLOAT": {
"GL_FLOAT": "LoadToNative<GLfloat,1>"
"GL_FLOAT": "LoadToNative<GLfloat, 1>"
}
},
"GL_RG16F": {
"DXGI_FORMAT_R16G16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative<GLhalf,2>",
"GL_HALF_FLOAT": "LoadToNative<GLhalf, 2>",
"GL_FLOAT": "Load32FTo16F<2>",
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf,2>"
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf, 2>"
}
},
"GL_RGB565": {
"DXGI_FORMAT_R8G8B8A8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte,0xFF>",
"GL_UNSIGNED_BYTE": "LoadToNative3To4<GLubyte, 0xFF>",
"GL_UNSIGNED_SHORT_5_6_5": "LoadR5G6B5ToRGBA8"
},
"DXGI_FORMAT_B5G6R5_UNORM": {
"GL_UNSIGNED_BYTE": "LoadRGB8ToBGR565",
"GL_UNSIGNED_SHORT_5_6_5": "LoadToNative<GLushort,1>"
"GL_UNSIGNED_SHORT_5_6_5": "LoadToNative<GLushort, 1>"
}
},
"GL_LUMINANCE16F_EXT": {
......@@ -469,22 +468,22 @@
},
"GL_RG16UI": {
"DXGI_FORMAT_R16G16_UINT": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,2>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 2>"
}
},
"GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4,4,16>"
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
},
"GL_RG16I": {
"DXGI_FORMAT_R16G16_SINT": {
"GL_SHORT": "LoadToNative<GLshort,2>"
"GL_SHORT": "LoadToNative<GLshort, 2>"
}
},
"GL_BGRA8_EXT": {
"DXGI_FORMAT_UNKNOWN": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>"
}
},
"GL_ALPHA16F_EXT": {
......@@ -495,7 +494,7 @@
},
"GL_RGBA4": {
"DXGI_FORMAT_R8G8B8A8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>",
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>",
"GL_UNSIGNED_SHORT_4_4_4_4": "LoadRGBA4ToRGBA8"
},
"DXGI_FORMAT_B4G4R4A4_UNORM": {
......@@ -505,7 +504,7 @@
},
"GL_RGBA8": {
"DXGI_FORMAT_R8G8B8A8_UNORM": {
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte,4>"
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>"
}
},
"GL_LUMINANCE": {
......@@ -522,7 +521,7 @@
},
"GL_RGB10_A2UI": {
"DXGI_FORMAT_R10G10B10A2_UINT": {
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative<GLuint,1>"
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative<GLuint, 1>"
}
},
"GL_ETC1_RGB8_OES": {
......@@ -537,42 +536,42 @@
},
"GL_R16_EXT": {
"DXGI_FORMAT_R16_UNORM": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,1>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 1>"
}
},
"GL_RG16_EXT": {
"DXGI_FORMAT_R16G16_UNORM": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,2>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 2>"
}
},
"GL_RGB16_EXT": {
"DXGI_FORMAT_R16G16B16A16_UNORM": {
"GL_UNSIGNED_SHORT": "LoadToNative3To4<GLushort,0xFFFF>"
"GL_UNSIGNED_SHORT": "LoadToNative3To4<GLushort, 0xFFFF>"
}
},
"GL_RGBA16_EXT": {
"DXGI_FORMAT_R16G16B16A16_UNORM": {
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort,4>"
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 4>"
}
},
"GL_R16_SNORM_EXT": {
"DXGI_FORMAT_R16_SNORM": {
"GL_SHORT": "LoadToNative<GLushort,1>"
"GL_SHORT": "LoadToNative<GLushort, 1>"
}
},
"GL_RG16_SNORM_EXT": {
"DXGI_FORMAT_R16G16_SNORM": {
"GL_SHORT": "LoadToNative<GLushort,2>"
"GL_SHORT": "LoadToNative<GLushort, 2>"
}
},
"GL_RGB16_SNORM_EXT": {
"DXGI_FORMAT_R16G16B16A16_SNORM": {
"GL_SHORT": "LoadToNative3To4<GLushort,0x7FFF>"
"GL_SHORT": "LoadToNative3To4<GLushort, 0x7FFF>"
}
},
"GL_RGBA16_SNORM_EXT": {
"DXGI_FORMAT_R16G16B16A16_SNORM": {
"GL_SHORT": "LoadToNative<GLushort,4>"
"GL_SHORT": "LoadToNative<GLushort, 4>"
}
}
}
......@@ -21,8 +21,7 @@ namespace rx
namespace d3d11
{
const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum internalFormat,
DXGI_FORMAT dxgiFormat);
LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, DXGI_FORMAT dxgiFormat);
} // namespace d3d11
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -49,7 +49,6 @@ Format::Format(GLenum internalFormat,
dataInitializerFunction(internalFormatInitializer),
loadFunctions(GetLoadFunctionsMap(internalFormat, texFormat))
{
ASSERT(!loadFunctions.empty() || formatID == angle::Format::ID::NONE);
}
} // namespace d3d11
......
......@@ -26,18 +26,6 @@ struct Renderer11DeviceCaps;
namespace d3d11
{
struct LoadImageFunctionInfo
{
LoadImageFunctionInfo() : loadFunction(nullptr), requiresConversion(false) {}
LoadImageFunctionInfo(LoadImageFunction loadFunction, bool requiresConversion)
: loadFunction(loadFunction), requiresConversion(requiresConversion)
{
}
LoadImageFunction loadFunction;
bool requiresConversion;
};
// For sized GL internal formats, there are several possible corresponding D3D11 formats depending
// on device capabilities.
// This structure allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
......@@ -71,7 +59,6 @@ struct Format final : angle::NonCopyable
const Format &swizzle;
InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap;
LoadFunctionMap loadFunctions;
};
......
......@@ -24,10 +24,6 @@ struct FormatType;
namespace rx
{
typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
......
......@@ -75,6 +75,30 @@ ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType);
ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions,
const gl::FormatType &formatType);
using LoadImageFunction = void (*)(size_t width,
size_t height,
size_t depth,
const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch);
struct LoadImageFunctionInfo
{
LoadImageFunctionInfo() : loadFunction(nullptr), requiresConversion(false) {}
LoadImageFunctionInfo(LoadImageFunction loadFunction, bool requiresConversion)
: loadFunction(loadFunction), requiresConversion(requiresConversion)
{
}
LoadImageFunction loadFunction;
bool requiresConversion;
};
using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum);
} // namespace rx
#endif // LIBANGLE_RENDERER_RENDERER_UTILS_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