shrekshao 145337f309 Use SubstituteOverride transform to implement overrides
Remove the old backend specific implementation for
overrides. Use tint SubstituteOverride transform to replace
overrides with const expressions and use the updated program
at pipeline creation time.

This CL also adds support for overrides used as workgroup size
and related tests. Workgroup size validation now happens
in backend code and at compute pipeline creation time.

Bug: dawn:1504
Change-Id: I7df1fe9c3e358caa23235eacd6d13ba0b2998aec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99821
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-09-07 20:09:54 +00:00

64 lines
1.8 KiB
C++

// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn/native/stream/Stream.h"
#include <string>
#include "dawn/native/Limits.h"
namespace dawn::native::stream {
template <>
void Stream<std::string>::Write(Sink* s, const std::string& t) {
StreamIn(s, t.length());
size_t size = t.length() * sizeof(char);
if (size > 0) {
void* ptr = s->GetSpace(size);
memcpy(ptr, t.data(), size);
}
}
template <>
MaybeError Stream<std::string>::Read(Source* s, std::string* t) {
size_t length;
DAWN_TRY(StreamOut(s, &length));
const void* ptr;
DAWN_TRY(s->Read(&ptr, length));
*t = std::string(static_cast<const char*>(ptr), length);
return {};
}
template <>
void Stream<std::string_view>::Write(Sink* s, const std::string_view& t) {
StreamIn(s, t.length());
size_t size = t.length() * sizeof(char);
if (size > 0) {
void* ptr = s->GetSpace(size);
memcpy(ptr, t.data(), size);
}
}
template <>
void Stream<std::wstring_view>::Write(Sink* s, const std::wstring_view& t) {
StreamIn(s, t.length());
size_t size = t.length() * sizeof(wchar_t);
if (size > 0) {
void* ptr = s->GetSpace(size);
memcpy(ptr, t.data(), size);
}
}
} // namespace dawn::native::stream