dawn.node: Handle \0 in entryPoint names.
Bug: chromium:1215024 Change-Id: I88fd8b513fbda9b6c55575616afaa0c65882fc1a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85505 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
a2f7d02c5e
commit
2f2977b728
|
@ -538,8 +538,22 @@ namespace wgpu::binding {
|
||||||
bool Converter::Convert(wgpu::ProgrammableStageDescriptor& out,
|
bool Converter::Convert(wgpu::ProgrammableStageDescriptor& out,
|
||||||
const interop::GPUProgrammableStage& in) {
|
const interop::GPUProgrammableStage& in) {
|
||||||
out = {};
|
out = {};
|
||||||
out.entryPoint = in.entryPoint.c_str();
|
|
||||||
out.module = *in.module.As<GPUShaderModule>();
|
out.module = *in.module.As<GPUShaderModule>();
|
||||||
|
|
||||||
|
// Replace nulls in the entryPoint name with another character that's disallowed in
|
||||||
|
// identifiers. This is so that using "main\0" doesn't match an entryPoint named "main".
|
||||||
|
// TODO(dawn:1345): Replace with a way to size strings explicitly in webgpu.h
|
||||||
|
char* entryPoint = Allocate<char>(in.entryPoint.size() + 1);
|
||||||
|
entryPoint[in.entryPoint.size()] = '\0';
|
||||||
|
for (size_t i = 0; i < in.entryPoint.size(); i++) {
|
||||||
|
if (in.entryPoint[i] == '\0') {
|
||||||
|
entryPoint[i] = '#';
|
||||||
|
} else {
|
||||||
|
entryPoint[i] = in.entryPoint[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.entryPoint = entryPoint;
|
||||||
|
|
||||||
return Convert(out.constants, out.constantCount, in.constants);
|
return Convert(out.constants, out.constantCount, in.constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue