Skip to content

Commit

Permalink
Capture/Replay: Use resource ID maps in cpp replay.
Browse files Browse the repository at this point in the history
Introduces a new enum for resource ID types. This is used in auto-
generated code to convert ParamType to resource ID map types.

Also implements a lot of new parameter captures for gen/delete calls.

Bug: angleproject:3611
Change-Id: I26cca1df88d1783d9830c89438c99f7593a70ea9
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1784059
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tobin Ehlis <tobine@google.com>
Reviewed-by: Cody Northrop <cnorthrop@google.com>
  • Loading branch information
null77 authored and Commit Bot committed Sep 17, 2019
1 parent db7a36f commit 01dfe40
Show file tree
Hide file tree
Showing 11 changed files with 492 additions and 66 deletions.
6 changes: 3 additions & 3 deletions scripts/code_generation_hashes/GL_EGL_entry_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts/entry_point_packed_gl_enums.json":
"5550f249db54a698036d5d9aa65e043b",
"scripts/generate_entry_points.py":
"00dc8410ad87e122314ac58579445188",
"29fd14951357959ad8e562867c0b12f6",
"scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"scripts/gl_angle_ext.xml":
Expand Down Expand Up @@ -90,9 +90,9 @@
"src/libANGLE/frame_capture_replay_autogen.cpp":
"1e4e55ea044ff8fc3764622a2f1cf240",
"src/libANGLE/frame_capture_utils_autogen.cpp":
"7465f826ea0196541bddd95540b0f599",
"f0a704d60de3f1f175a7799b49c45408",
"src/libANGLE/frame_capture_utils_autogen.h":
"4d16f676a1f5f70a882161fcb585db5b",
"cc6e5b6c49d51da1cebea6ea48422511",
"src/libANGLE/validationES1_autogen.h":
"8d3131d2bf2e6f521f46b44e64a6bff9",
"src/libANGLE/validationES2_autogen.h":
Expand Down
88 changes: 85 additions & 3 deletions scripts/generate_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ class Context;
{param_types}
}};
constexpr uint32_t kParamTypeCount = {param_type_count};
union ParamValue
{{
{param_union_values}
Expand All @@ -532,7 +534,6 @@ class Context;
{get_param_val_specializations}
template <ParamType PType, typename T>
T GetParamVal(const ParamValue &value)
{{
Expand Down Expand Up @@ -571,6 +572,14 @@ class Context;
void WriteParamTypeToStream(std::ostream &os, ParamType paramType, const ParamValue& paramValue);
const char *ParamTypeToString(ParamType paramType);
enum class ResourceIDType
{{
{resource_id_types}
}};
ResourceIDType GetResourceIDTypeFromParamType(ParamType paramType);
const char *GetResourceIDTypeName(ResourceIDType resourceIDType);
}} // namespace angle
#endif // LIBANGLE_FRAME_CAPTURE_UTILS_AUTOGEN_H_
Expand Down Expand Up @@ -613,6 +622,27 @@ class Context;
return "unknown";
}}
}}
ResourceIDType GetResourceIDTypeFromParamType(ParamType paramType)
{{
switch (paramType)
{{
{param_type_resource_id_cases}
default:
return ResourceIDType::InvalidEnum;
}}
}}
const char *GetResourceIDTypeName(ResourceIDType resourceIDType)
{{
switch (resourceIDType)
{{
{resource_id_type_name_cases}
default:
UNREACHABLE();
return "GetResourceIDTypeName error";
}}
}}
}} // namespace angle
"""

Expand Down Expand Up @@ -642,6 +672,12 @@ class Context;
template_param_type_to_string_case = """ case ParamType::T{enum}:
return "{type}";"""

template_param_type_to_resource_id_type_case = """ case ParamType::T{enum}:
return ResourceIDType::{resource_id_type};"""

template_resource_id_type_name_case = """ case ResourceIDType::{resource_id_type}:
return "{resource_id_type}";"""


def script_relative(path):
return os.path.join(os.path.dirname(sys.argv[0]), path)
Expand Down Expand Up @@ -1314,6 +1350,17 @@ def format_write_param_type_to_stream_case(param_type):
enum=param_type, union_name=get_param_type_union_name(param_type))


def get_resource_id_types(all_param_types):
return [t[:-2] for t in filter(lambda t: t.endswith("ID"), all_param_types)]


def format_resource_id_types(all_param_types):
resource_id_types = get_resource_id_types(all_param_types)
resource_id_types += ["EnumCount", "InvalidEnum = EnumCount"]
resource_id_types = ",\n ".join(resource_id_types)
return resource_id_types


def write_capture_helper_header(all_param_types):

param_types = "\n ".join(["T%s," % t for t in all_param_types])
Expand All @@ -1325,17 +1372,20 @@ def write_capture_helper_header(all_param_types):
set_param_val_specializations = "\n\n".join(
[format_set_param_val_specialization(t) for t in all_param_types])
init_param_value_cases = "\n".join([format_init_param_value_case(t) for t in all_param_types])
resource_id_types = format_resource_id_types(all_param_types)

content = template_frame_capture_utils_header.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
year=date.today().year,
param_types=param_types,
param_type_count=len(all_param_types),
param_union_values=param_union_values,
get_param_val_specializations=get_param_val_specializations,
access_param_value_cases=access_param_value_cases,
set_param_val_specializations=set_param_val_specializations,
init_param_value_cases=init_param_value_cases)
init_param_value_cases=init_param_value_cases,
resource_id_types=resource_id_types)

path = path_to("libANGLE", "frame_capture_utils_autogen.h")

Expand All @@ -1349,19 +1399,51 @@ def format_param_type_to_string_case(param_type):
enum=param_type, type=get_gl_param_type_type(param_type))


def get_resource_id_type_from_param_type(param_type):
if param_type.endswith("ConstPointer"):
return param_type.replace("ConstPointer", "")[:-2]
if param_type.endswith("Pointer"):
return param_type.replace("Pointer", "")[:-2]
return param_type[:-2]


def format_param_type_to_resource_id_type_case(param_type):
return template_param_type_to_resource_id_type_case.format(
enum=param_type, resource_id_type=get_resource_id_type_from_param_type(param_type))


def format_param_type_resource_id_cases(all_param_types):
id_types = filter(
lambda t: t.endswith("ID") or t.endswith("IDConstPointer") or t.endswith("IDPointer"),
all_param_types)
return "\n".join([format_param_type_to_resource_id_type_case(t) for t in id_types])


def format_resource_id_type_name_case(resource_id_type):
return template_resource_id_type_name_case.format(resource_id_type=resource_id_type)


def write_capture_helper_source(all_param_types):

write_param_type_to_stream_cases = "\n".join(
[format_write_param_type_to_stream_case(t) for t in all_param_types])
param_type_to_string_cases = "\n".join(
[format_param_type_to_string_case(t) for t in all_param_types])

param_type_resource_id_cases = format_param_type_resource_id_cases(all_param_types)

resource_id_types = get_resource_id_types(all_param_types)
resource_id_type_name_cases = "\n".join(
[format_resource_id_type_name_case(t) for t in resource_id_types])

content = template_frame_capture_utils_source.format(
script_name=os.path.basename(sys.argv[0]),
data_source_name="gl.xml and gl_angle_ext.xml",
year=date.today().year,
write_param_type_to_stream_cases=write_param_type_to_stream_cases,
param_type_to_string_cases=param_type_to_string_cases)
param_type_to_string_cases=param_type_to_string_cases,
param_type_resource_id_cases=param_type_resource_id_cases,
resource_id_type_name_cases=resource_id_type_name_cases)

path = path_to("libANGLE", "frame_capture_utils_autogen.cpp")

Expand Down
2 changes: 1 addition & 1 deletion src/common/PackedEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PackedEnumMap

// No explicit construct/copy/destroy for aggregate type
void fill(const T &u) { mPrivateData.fill(u); }
void swap(PackedEnumMap<E, T> &a) noexcept { mPrivateData.swap(a.mPrivateData); }
void swap(PackedEnumMap<E, T, MaxSize> &a) noexcept { mPrivateData.swap(a.mPrivateData); }

// iterators:
iterator begin() noexcept { return mPrivateData.begin(); }
Expand Down
Loading

0 comments on commit 01dfe40

Please sign in to comment.