mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 05:27:49 +00:00
dawn_wire: Factor the common command serialization pattern.
Bug: dawn:445 Change-Id: I15a99a126c0494fd06dd727ff5c9008cde675d76 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23560 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
8f9523eb38
commit
90abd47a28
@@ -380,7 +380,7 @@ namespace {
|
||||
}
|
||||
|
||||
void {{Cmd}}::Serialize(char* buffer
|
||||
{%- if command.may_have_dawn_object -%}
|
||||
{%- if not is_return -%}
|
||||
, const ObjectIdProvider& objectIdProvider
|
||||
{%- endif -%}
|
||||
) const {
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace dawn_wire {
|
||||
//* Serialize the structure and everything it points to into serializeBuffer which must be
|
||||
//* big enough to contain all the data (as queried from GetRequiredSize).
|
||||
void Serialize(char* serializeBuffer
|
||||
{%- if command.may_have_dawn_object -%}
|
||||
{%- if not is_return_command -%}
|
||||
, const ObjectIdProvider& objectIdProvider
|
||||
{%- endif -%}
|
||||
) const;
|
||||
|
||||
@@ -196,9 +196,7 @@ namespace dawn_wire { namespace client {
|
||||
{% endfor %}
|
||||
|
||||
//* Allocate space to send the command and copy the value args over.
|
||||
size_t requiredSize = cmd.GetRequiredSize();
|
||||
char* allocatedBuffer = static_cast<char*>(device->GetClient()->GetCmdSpace(requiredSize));
|
||||
cmd.Serialize(allocatedBuffer, *device->GetClient());
|
||||
device->GetClient()->SerializeCommand(cmd);
|
||||
|
||||
{% if method.return_type.category == "object" %}
|
||||
return reinterpret_cast<{{as_cType(method.return_type.name)}}>(allocation->object.get());
|
||||
@@ -226,10 +224,7 @@ namespace dawn_wire { namespace client {
|
||||
cmd.objectType = ObjectType::{{type.name.CamelCase()}};
|
||||
cmd.objectId = obj->id;
|
||||
|
||||
size_t requiredSize = cmd.GetRequiredSize();
|
||||
char* allocatedBuffer = static_cast<char*>(obj->device->GetClient()->GetCmdSpace(requiredSize));
|
||||
cmd.Serialize(allocatedBuffer);
|
||||
|
||||
obj->device->GetClient()->SerializeCommand(cmd);
|
||||
obj->device->GetClient()->{{type.name.CamelCase()}}Allocator().Free(obj);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user