mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Trace Interpreter: Improve StringToGLenum performance.
Binary search instead of linear. This gets called a lot when parsing traces to be run by the trace interpreter. I saw ~37 seconds parse time on Panther for minecraft_bedrock trace, this CL makes that ~5 times faster. Bug: b/276742336 Change-Id: Ide32c247b327f36c00f26951a90e4412d71db2b6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4392892 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Roman Lavrov <romanl@google.com>
This commit is contained in:
committed by
Angle LUCI CQ
parent
96cda1ac08
commit
c723d71fc8
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"scripts/gen_gl_enum_utils.py":
|
||||
"3bab69a4a3555ab1551a6e5008534cec",
|
||||
"8afb0a21014862b79b629044ceac8b93",
|
||||
"scripts/gl_angle_ext.xml":
|
||||
"796894fd74d141b88000669104a663ea",
|
||||
"scripts/registry_xml.py":
|
||||
"8dc1bcf2e8324094c19c41613897b212",
|
||||
"src/common/gl_enum_utils_autogen.cpp":
|
||||
"707566f71285a34af9586baeef980b9f",
|
||||
"9a2bc249a97985d81265fc53b94a0744",
|
||||
"src/common/gl_enum_utils_autogen.h":
|
||||
"85dea9edf87ad08c322868823e61a40c",
|
||||
"third_party/OpenGL-Registry/src/xml/gl.xml":
|
||||
|
||||
@@ -92,10 +92,27 @@ const char *GLenumToString(BigGLEnum enumGroup, unsigned int value)
|
||||
}}
|
||||
}}
|
||||
|
||||
namespace
|
||||
{{
|
||||
using StringEnumEntry = std::pair<const char*, unsigned int>;
|
||||
static StringEnumEntry g_stringEnumTable[] = {{
|
||||
{string_to_enum_table}
|
||||
}};
|
||||
|
||||
const size_t g_numStringEnums = std::size(g_stringEnumTable);
|
||||
}} // anonymous namespace
|
||||
|
||||
unsigned int StringToGLenum(const char *str)
|
||||
{{
|
||||
{string_to_enum_table}
|
||||
printf("Unknown enum string: %s\\n", str);
|
||||
auto it = std::lower_bound(
|
||||
&g_stringEnumTable[0], &g_stringEnumTable[g_numStringEnums], str,
|
||||
[](const StringEnumEntry& a, const char* b) {{ return strcmp(a.first, b) < 0; }});
|
||||
|
||||
if (strcmp(it->first, str) == 0)
|
||||
{{
|
||||
return it->second;
|
||||
}}
|
||||
|
||||
UNREACHABLE();
|
||||
return 0;
|
||||
}}
|
||||
@@ -162,12 +179,6 @@ def dump_value_to_string_mapping(enum_groups, api_enum):
|
||||
|
||||
|
||||
def dump_string_to_value_mapping(enums_and_values):
|
||||
templ = """\
|
||||
if (strcmp(str, "{enum}") == 0)
|
||||
{{
|
||||
return {value};
|
||||
}}
|
||||
"""
|
||||
|
||||
def f(value):
|
||||
if value < 0:
|
||||
@@ -179,8 +190,7 @@ def dump_string_to_value_mapping(enums_and_values):
|
||||
else:
|
||||
return "0xFFFFFFFF"
|
||||
|
||||
items = [templ.format(enum=k, value=f(v)) for (k, v) in sorted(enums_and_values)]
|
||||
return ''.join(items)
|
||||
return '\n'.join('{"%s", %s},' % (k, f(v)) for k, v in sorted(enums_and_values))
|
||||
|
||||
|
||||
def main(header_output_path, source_output_path):
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user