From 7b3ea34b6b132efe7d93f0025dc7cbbe50641b9c Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 5 Dec 2018 10:13:52 +0000 Subject: [PATCH] WireCmd: Update buffer pointer when serializing sub elements Without this the serialize step failed to increment the pointer to the buffer to account for the recording of "main" in the render pipeline descriptor: descriptor->vertexStage->entryPoint = "main"; BUG=dawn:4 Change-Id: Ic3829787af2213577ac67ee93625679afdae1cc9 Reviewed-on: https://dawn-review.googlesource.com/c/2880 Reviewed-by: Kai Ninomiya Reviewed-by: Austin Eng Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- generator/templates/dawn_wire/WireCmd.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/generator/templates/dawn_wire/WireCmd.cpp b/generator/templates/dawn_wire/WireCmd.cpp index ceb828f123..99f1a25822 100644 --- a/generator/templates/dawn_wire/WireCmd.cpp +++ b/generator/templates/dawn_wire/WireCmd.cpp @@ -144,7 +144,7 @@ //* Serializes `record` into `transfer`, using `buffer` to get more space for pointed-to data //* and `provider` to serialize objects. void {{name}}Serialize(const {{name}}& record, {{name}}Transfer* transfer, - char* buffer, const ObjectIdProvider& provider) { + char** buffer, const ObjectIdProvider& provider) { DAWN_UNUSED(provider); DAWN_UNUSED(buffer); @@ -170,8 +170,8 @@ {% set memberName = as_varName(member.name) %} transfer->{{memberName}}Strlen = std::strlen(record.{{memberName}}); - memcpy(buffer, record.{{memberName}}, transfer->{{memberName}}Strlen); - buffer += transfer->{{memberName}}Strlen; + memcpy(*buffer, record.{{memberName}}, transfer->{{memberName}}Strlen); + *buffer += transfer->{{memberName}}Strlen; {% endfor %} //* Allocate space and write the non-value arguments in it. @@ -179,9 +179,9 @@ {% set memberName = as_varName(member.name) %} { size_t memberLength = {{member_length(member, "record.")}}; - auto memberBuffer = reinterpret_cast<{{member_transfer_type(member)}}*>(buffer); + auto memberBuffer = reinterpret_cast<{{member_transfer_type(member)}}*>(*buffer); - buffer += memberLength * {{member_transfer_sizeof(member)}}; + *buffer += memberLength * {{member_transfer_sizeof(member)}}; for (size_t i = 0; i < memberLength; ++i) { {{serialize_member(member, "record." + memberName + "[i]", "memberBuffer[i]" )}} } @@ -345,7 +345,7 @@ namespace dawn_wire { auto transfer = reinterpret_cast<{{name}}Transfer*>(buffer); buffer += sizeof({{name}}Transfer); - {{name}}Serialize(*this, transfer, buffer, objectIdProvider); + {{name}}Serialize(*this, transfer, &buffer, objectIdProvider); } DeserializeResult {{Cmd}}::Deserialize(const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver) {