Fix support for optional const char*
Optional labels were added to command buffer descriptor and compute pass descriptor in https://dawn-review.googlesource.com/c/dawn/+/11601. Sadly, the wire was not updated. This CL fixes support for optional const char*. Bug: dawn:22 Change-Id: I23211456f5e3d5f3c0344d8b8cc604bab20015f6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11660 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
86ac0b93c9
commit
f622a44750
|
@ -119,7 +119,15 @@
|
|||
|
||||
//* Special handling of const char* that have their length embedded directly in the command
|
||||
{% for member in members if member.length == "strlen" %}
|
||||
result += std::strlen(record.{{as_varName(member.name)}});
|
||||
{% set memberName = as_varName(member.name) %}
|
||||
|
||||
{% if member.optional %}
|
||||
bool has_{{memberName}} = record.{{memberName}} != nullptr;
|
||||
if (has_{{memberName}})
|
||||
{% endif %}
|
||||
{
|
||||
result += std::strlen(record.{{memberName}});
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
//* Gather how much space will be needed for pointer members.
|
||||
|
@ -178,10 +186,18 @@
|
|||
//* Special handling of const char* that have their length embedded directly in the command
|
||||
{% for member in members if member.length == "strlen" %}
|
||||
{% set memberName = as_varName(member.name) %}
|
||||
|
||||
bool has_{{memberName}} = record.{{memberName}} != nullptr;
|
||||
transfer->has_{{memberName}} = has_{{memberName}};
|
||||
{% if member.optional %}
|
||||
if (has_{{memberName}})
|
||||
{% endif %}
|
||||
{
|
||||
transfer->{{memberName}}Strlen = std::strlen(record.{{memberName}});
|
||||
|
||||
memcpy(*buffer, record.{{memberName}}, transfer->{{memberName}}Strlen);
|
||||
*buffer += transfer->{{memberName}}Strlen;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
//* Allocate space and write the non-value arguments in it.
|
||||
|
@ -240,6 +256,9 @@
|
|||
//* Special handling of const char* that have their length embedded directly in the command
|
||||
{% for member in members if member.length == "strlen" %}
|
||||
{% set memberName = as_varName(member.name) %}
|
||||
|
||||
bool has_{{memberName}} = transfer->has_{{memberName}};
|
||||
if (has_{{memberName}})
|
||||
{
|
||||
size_t stringLength = transfer->{{memberName}}Strlen;
|
||||
const char* stringInBuffer = nullptr;
|
||||
|
@ -250,6 +269,8 @@
|
|||
memcpy(copiedString, stringInBuffer, stringLength);
|
||||
copiedString[stringLength] = '\0';
|
||||
record->{{memberName}} = copiedString;
|
||||
} else {
|
||||
record->{{memberName}} = nullptr;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue