[Impeller] Revert support for multi-arch shader archives. (flutter/engine#53158)
This was never fully wired up and we never ended up needing this as there is only still on backend per platform. Earlier, we expected to have both GLES and Vulkan on Android. Reverts4b9e254019anda6ea96ab20with fixups.
This commit is contained in:
@@ -42902,11 +42902,6 @@ ORIGIN: ../../../flutter/impeller/scene/shaders/unlit.frag + ../../../flutter/LI
|
||||
ORIGIN: ../../../flutter/impeller/scene/shaders/unskinned.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/scene/skin.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/scene/skin.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive.fbs + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive_writer.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive_writer.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/shader_archive.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/shader_archive.fbs + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/shader_archive/shader_archive.h + ../../../flutter/LICENSE
|
||||
@@ -45771,11 +45766,6 @@ FILE: ../../../flutter/impeller/scene/shaders/unlit.frag
|
||||
FILE: ../../../flutter/impeller/scene/shaders/unskinned.vert
|
||||
FILE: ../../../flutter/impeller/scene/skin.cc
|
||||
FILE: ../../../flutter/impeller/scene/skin.h
|
||||
FILE: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive.cc
|
||||
FILE: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive.fbs
|
||||
FILE: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive.h
|
||||
FILE: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive_writer.cc
|
||||
FILE: ../../../flutter/impeller/shader_archive/multi_arch_shader_archive_writer.h
|
||||
FILE: ../../../flutter/impeller/shader_archive/shader_archive.cc
|
||||
FILE: ../../../flutter/impeller/shader_archive/shader_archive.fbs
|
||||
FILE: ../../../flutter/impeller/shader_archive/shader_archive.h
|
||||
|
||||
@@ -175,9 +175,6 @@ flowchart TD
|
||||
|
||||
spirv -- Reflector --> cxx_sources[C++ Sources]
|
||||
cxx_sources -- Ninja Build --> cxx_library[C++ Library]
|
||||
|
||||
vulkan_shader_archive -- Multi Arch Archiver --> multi_arch_archive[Multi Architecture Archive]
|
||||
gles_shader_archive -- Multi Arch Archiver --> multi_arch_archive
|
||||
```
|
||||
|
||||
## Try Impeller in Flutter
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "impeller/base/config.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/renderer/backend/gles/shader_function_gles.h"
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive.h"
|
||||
#include "impeller/shader_archive/shader_archive.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -69,13 +68,12 @@ ShaderLibraryGLES::ShaderLibraryGLES(
|
||||
return true;
|
||||
};
|
||||
for (auto library : shader_libraries) {
|
||||
auto gles_archive = MultiArchShaderArchive::CreateArchiveFromMapping(
|
||||
std::move(library), ArchiveRenderingBackend::kOpenGLES);
|
||||
if (!gles_archive || !gles_archive->IsValid()) {
|
||||
VALIDATION_LOG << "Could not construct shader library.";
|
||||
auto blob_library = ShaderArchive{std::move(library)};
|
||||
if (!blob_library.IsValid()) {
|
||||
VALIDATION_LOG << "Could not construct blob library for shaders.";
|
||||
return;
|
||||
}
|
||||
gles_archive->IterateAllShaders(iterator);
|
||||
blob_library.IterateAllShaders(iterator);
|
||||
}
|
||||
|
||||
functions_ = functions;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/shader_function_vk.h"
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive.h"
|
||||
#include "impeller/shader_archive/shader_archive.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -68,13 +67,12 @@ ShaderLibraryVK::ShaderLibraryVK(
|
||||
return true;
|
||||
};
|
||||
for (const auto& library_data : shader_libraries_data) {
|
||||
auto vulkan_library = MultiArchShaderArchive::CreateArchiveFromMapping(
|
||||
library_data, ArchiveRenderingBackend::kVulkan);
|
||||
if (!vulkan_library || !vulkan_library->IsValid()) {
|
||||
VALIDATION_LOG << "Could not construct Vulkan shader library archive.";
|
||||
auto blob_library = ShaderArchive{library_data};
|
||||
if (!blob_library.IsValid()) {
|
||||
VALIDATION_LOG << "Could not construct shader blob library.";
|
||||
return;
|
||||
}
|
||||
vulkan_library->IterateAllShaders(iterator);
|
||||
blob_library.IterateAllShaders(iterator);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
|
||||
@@ -11,20 +11,13 @@ config("shader_archive_config") {
|
||||
}
|
||||
|
||||
flatbuffers("shader_archive_flatbuffers") {
|
||||
flatbuffers = [
|
||||
"shader_archive.fbs",
|
||||
"multi_arch_shader_archive.fbs",
|
||||
]
|
||||
flatbuffers = [ "shader_archive.fbs" ]
|
||||
public_configs = [ ":shader_archive_config" ]
|
||||
public_deps = [ "//flutter/third_party/flatbuffers" ]
|
||||
}
|
||||
|
||||
impeller_component("shader_archive") {
|
||||
sources = [
|
||||
"multi_arch_shader_archive.cc",
|
||||
"multi_arch_shader_archive.h",
|
||||
"multi_arch_shader_archive_writer.cc",
|
||||
"multi_arch_shader_archive_writer.h",
|
||||
"shader_archive.cc",
|
||||
"shader_archive.h",
|
||||
"shader_archive_types.h",
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive.h"
|
||||
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive_flatbuffers.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
constexpr ArchiveRenderingBackend ToArchiveRenderingBackend(
|
||||
fb::RenderingBackend backend) {
|
||||
switch (backend) {
|
||||
case fb::RenderingBackend::kOpenGLES:
|
||||
return ArchiveRenderingBackend::kOpenGLES;
|
||||
case fb::RenderingBackend::kVulkan:
|
||||
return ArchiveRenderingBackend::kVulkan;
|
||||
case fb::RenderingBackend::kMetal:
|
||||
return ArchiveRenderingBackend::kMetal;
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
std::shared_ptr<ShaderArchive> MultiArchShaderArchive::CreateArchiveFromMapping(
|
||||
const std::shared_ptr<const fml::Mapping>& mapping,
|
||||
ArchiveRenderingBackend backend) {
|
||||
{
|
||||
auto multi_archive = std::make_shared<MultiArchShaderArchive>(mapping);
|
||||
if (multi_archive->IsValid()) {
|
||||
return multi_archive->GetShaderArchive(backend);
|
||||
}
|
||||
}
|
||||
{
|
||||
auto single_archive =
|
||||
std::shared_ptr<ShaderArchive>(new ShaderArchive(mapping));
|
||||
if (single_archive->IsValid()) {
|
||||
return single_archive;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MultiArchShaderArchive::MultiArchShaderArchive(
|
||||
const std::shared_ptr<const fml::Mapping>& mapping) {
|
||||
if (!mapping) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fb::MultiArchShaderArchiveBufferHasIdentifier(mapping->GetMapping())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto* multi_arch = fb::GetMultiArchShaderArchive(mapping->GetMapping());
|
||||
|
||||
if (!multi_arch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto archives = multi_arch->items()) {
|
||||
for (auto i = archives->begin(), end = archives->end(); i != end; i++) {
|
||||
// This implementation is unable to handle multiple archives for the same
|
||||
// backend.
|
||||
backend_mappings_[ToArchiveRenderingBackend(i->rendering_backend())] =
|
||||
std::make_shared<fml::NonOwnedMapping>(i->mapping()->Data(),
|
||||
i->mapping()->size(),
|
||||
[mapping](auto, auto) {
|
||||
// Just hold the mapping.
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
MultiArchShaderArchive::~MultiArchShaderArchive() = default;
|
||||
|
||||
bool MultiArchShaderArchive::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
std::shared_ptr<const fml::Mapping> MultiArchShaderArchive::GetArchive(
|
||||
ArchiveRenderingBackend backend) const {
|
||||
auto found = backend_mappings_.find(backend);
|
||||
if (found == backend_mappings_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<ShaderArchive> MultiArchShaderArchive::GetShaderArchive(
|
||||
ArchiveRenderingBackend backend) const {
|
||||
auto archive = GetArchive(backend);
|
||||
if (!archive) {
|
||||
return nullptr;
|
||||
}
|
||||
auto shader_archive =
|
||||
std::shared_ptr<ShaderArchive>(new ShaderArchive(std::move(archive)));
|
||||
if (!shader_archive->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return shader_archive;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
namespace impeller.fb;
|
||||
|
||||
enum RenderingBackend:byte {
|
||||
kOpenGLES,
|
||||
kVulkan,
|
||||
kMetal,
|
||||
}
|
||||
|
||||
table ShaderArchiveBlob {
|
||||
rendering_backend: RenderingBackend;
|
||||
mapping: [ubyte];
|
||||
}
|
||||
|
||||
table MultiArchShaderArchive {
|
||||
// We could have just as easily used the existing `ShaderArchive` table here.
|
||||
// However, those tables aren't used by Metal.
|
||||
items: [ShaderArchiveBlob];
|
||||
}
|
||||
|
||||
root_type MultiArchShaderArchive;
|
||||
file_identifier "MARC";
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_IMPELLER_SHADER_ARCHIVE_MULTI_ARCH_SHADER_ARCHIVE_H_
|
||||
#define FLUTTER_IMPELLER_SHADER_ARCHIVE_MULTI_ARCH_SHADER_ARCHIVE_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "impeller/shader_archive/shader_archive.h"
|
||||
#include "impeller/shader_archive/shader_archive_types.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class MultiArchShaderArchive {
|
||||
public:
|
||||
static std::shared_ptr<ShaderArchive> CreateArchiveFromMapping(
|
||||
const std::shared_ptr<const fml::Mapping>& mapping,
|
||||
ArchiveRenderingBackend backend);
|
||||
|
||||
explicit MultiArchShaderArchive(
|
||||
const std::shared_ptr<const fml::Mapping>& mapping);
|
||||
|
||||
~MultiArchShaderArchive();
|
||||
|
||||
std::shared_ptr<const fml::Mapping> GetArchive(
|
||||
ArchiveRenderingBackend backend) const;
|
||||
|
||||
std::shared_ptr<ShaderArchive> GetShaderArchive(
|
||||
ArchiveRenderingBackend backend) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
std::map<ArchiveRenderingBackend, std::shared_ptr<const fml::Mapping>>
|
||||
backend_mappings_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
MultiArchShaderArchive(const MultiArchShaderArchive&) = delete;
|
||||
|
||||
MultiArchShaderArchive& operator=(const MultiArchShaderArchive&) = delete;
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
#endif // FLUTTER_IMPELLER_SHADER_ARCHIVE_MULTI_ARCH_SHADER_ARCHIVE_H_
|
||||
@@ -1,64 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive_writer.h"
|
||||
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive_flatbuffers.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
MultiArchShaderArchiveWriter::MultiArchShaderArchiveWriter() = default;
|
||||
|
||||
MultiArchShaderArchiveWriter::~MultiArchShaderArchiveWriter() = default;
|
||||
|
||||
bool MultiArchShaderArchiveWriter::RegisterShaderArchive(
|
||||
ArchiveRenderingBackend backend,
|
||||
std::shared_ptr<const fml::Mapping> mapping) {
|
||||
if (!mapping || mapping->GetMapping() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (archives_.find(backend) != archives_.end()) {
|
||||
VALIDATION_LOG << "Multi-archive already has a shader library registered "
|
||||
"for that backend.";
|
||||
return false;
|
||||
}
|
||||
archives_[backend] = std::move(mapping);
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr fb::RenderingBackend ToRenderingBackend(
|
||||
ArchiveRenderingBackend backend) {
|
||||
switch (backend) {
|
||||
case ArchiveRenderingBackend::kMetal:
|
||||
return fb::RenderingBackend::kMetal;
|
||||
case ArchiveRenderingBackend::kVulkan:
|
||||
return fb::RenderingBackend::kVulkan;
|
||||
case ArchiveRenderingBackend::kOpenGLES:
|
||||
return fb::RenderingBackend::kOpenGLES;
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
std::shared_ptr<fml::Mapping> MultiArchShaderArchiveWriter::CreateMapping()
|
||||
const {
|
||||
fb::MultiArchShaderArchiveT multi_archive;
|
||||
for (const auto& archive : archives_) {
|
||||
auto archive_blob = std::make_unique<fb::ShaderArchiveBlobT>();
|
||||
archive_blob->rendering_backend = ToRenderingBackend(archive.first);
|
||||
archive_blob->mapping = {
|
||||
archive.second->GetMapping(),
|
||||
archive.second->GetMapping() + archive.second->GetSize()};
|
||||
multi_archive.items.emplace_back(std::move(archive_blob));
|
||||
}
|
||||
auto builder = std::make_shared<flatbuffers::FlatBufferBuilder>();
|
||||
builder->Finish(
|
||||
fb::MultiArchShaderArchive::Pack(*builder.get(), &multi_archive),
|
||||
fb::MultiArchShaderArchiveIdentifier());
|
||||
return std::make_shared<fml::NonOwnedMapping>(builder->GetBufferPointer(),
|
||||
builder->GetSize(),
|
||||
[builder](auto, auto) {});
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_IMPELLER_SHADER_ARCHIVE_MULTI_ARCH_SHADER_ARCHIVE_WRITER_H_
|
||||
#define FLUTTER_IMPELLER_SHADER_ARCHIVE_MULTI_ARCH_SHADER_ARCHIVE_WRITER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "impeller/shader_archive/shader_archive_types.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class MultiArchShaderArchiveWriter {
|
||||
public:
|
||||
MultiArchShaderArchiveWriter();
|
||||
|
||||
~MultiArchShaderArchiveWriter();
|
||||
|
||||
[[nodiscard]] bool RegisterShaderArchive(
|
||||
ArchiveRenderingBackend backend,
|
||||
std::shared_ptr<const fml::Mapping> mapping);
|
||||
|
||||
std::shared_ptr<fml::Mapping> CreateMapping() const;
|
||||
|
||||
private:
|
||||
std::map<ArchiveRenderingBackend, std::shared_ptr<const fml::Mapping>>
|
||||
archives_;
|
||||
|
||||
MultiArchShaderArchiveWriter(const MultiArchShaderArchiveWriter&) = delete;
|
||||
|
||||
MultiArchShaderArchiveWriter& operator=(const MultiArchShaderArchiveWriter&) =
|
||||
delete;
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
#endif // FLUTTER_IMPELLER_SHADER_ARCHIVE_MULTI_ARCH_SHADER_ARCHIVE_WRITER_H_
|
||||
@@ -25,7 +25,7 @@ constexpr ArchiveShaderType ToShaderType(fb::Stage stage) {
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
ShaderArchive::ShaderArchive(std::shared_ptr<const fml::Mapping> payload)
|
||||
ShaderArchive::ShaderArchive(std::shared_ptr<fml::Mapping> payload)
|
||||
: payload_(std::move(payload)) {
|
||||
if (!payload_ || payload_->GetMapping() == nullptr) {
|
||||
VALIDATION_LOG << "Shader mapping was absent.";
|
||||
@@ -33,7 +33,7 @@ ShaderArchive::ShaderArchive(std::shared_ptr<const fml::Mapping> payload)
|
||||
}
|
||||
|
||||
if (!fb::ShaderArchiveBufferHasIdentifier(payload_->GetMapping())) {
|
||||
VALIDATION_LOG << "Invalid shader archive magic.";
|
||||
VALIDATION_LOG << "Invalid shader magic.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class MultiArchShaderArchive;
|
||||
|
||||
class ShaderArchive {
|
||||
public:
|
||||
explicit ShaderArchive(std::shared_ptr<fml::Mapping> payload);
|
||||
|
||||
ShaderArchive(ShaderArchive&&);
|
||||
|
||||
~ShaderArchive();
|
||||
@@ -37,8 +37,6 @@ class ShaderArchive {
|
||||
const;
|
||||
|
||||
private:
|
||||
friend MultiArchShaderArchive;
|
||||
|
||||
struct ShaderKey {
|
||||
ArchiveShaderType type = ArchiveShaderType::kFragment;
|
||||
std::string name;
|
||||
@@ -63,12 +61,10 @@ class ShaderArchive {
|
||||
ShaderKey::Hash,
|
||||
ShaderKey::Equal>;
|
||||
|
||||
std::shared_ptr<const fml::Mapping> payload_;
|
||||
std::shared_ptr<fml::Mapping> payload_;
|
||||
Shaders shaders_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
explicit ShaderArchive(std::shared_ptr<const fml::Mapping> payload);
|
||||
|
||||
ShaderArchive(const ShaderArchive&) = delete;
|
||||
|
||||
ShaderArchive& operator=(const ShaderArchive&) = delete;
|
||||
|
||||
@@ -13,12 +13,6 @@ enum class ArchiveShaderType {
|
||||
kCompute,
|
||||
};
|
||||
|
||||
enum class ArchiveRenderingBackend {
|
||||
kMetal,
|
||||
kVulkan,
|
||||
kOpenGLES,
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
#endif // FLUTTER_IMPELLER_SHADER_ARCHIVE_SHADER_ARCHIVE_TYPES_H_
|
||||
|
||||
@@ -6,12 +6,7 @@
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive.h"
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive_flatbuffers.h"
|
||||
#include "impeller/shader_archive/multi_arch_shader_archive_writer.h"
|
||||
#include "impeller/shader_archive/shader_archive.h"
|
||||
#include "impeller/shader_archive/shader_archive_flatbuffers.h"
|
||||
#include "impeller/shader_archive/shader_archive_writer.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -46,51 +41,17 @@ TEST(ShaderArchiveTest, CanReadAndWriteBlobs) {
|
||||
auto mapping = writer.CreateMapping();
|
||||
ASSERT_NE(mapping, nullptr);
|
||||
|
||||
MultiArchShaderArchiveWriter multi_writer;
|
||||
|
||||
ASSERT_TRUE(multi_writer.RegisterShaderArchive(
|
||||
ArchiveRenderingBackend::kOpenGLES, mapping));
|
||||
|
||||
{
|
||||
ScopedValidationDisable no_val;
|
||||
// Can't add the same backend again.
|
||||
ASSERT_FALSE(multi_writer.RegisterShaderArchive(
|
||||
ArchiveRenderingBackend::kOpenGLES, mapping));
|
||||
}
|
||||
|
||||
auto multi_mapping = multi_writer.CreateMapping();
|
||||
ASSERT_TRUE(multi_mapping);
|
||||
|
||||
{
|
||||
ScopedValidationDisable no_val;
|
||||
auto no_library = MultiArchShaderArchive::CreateArchiveFromMapping(
|
||||
multi_mapping, ArchiveRenderingBackend::kVulkan);
|
||||
ASSERT_EQ(no_library, nullptr);
|
||||
}
|
||||
|
||||
auto library = MultiArchShaderArchive::CreateArchiveFromMapping(
|
||||
multi_mapping, ArchiveRenderingBackend::kOpenGLES);
|
||||
ASSERT_EQ(library->GetShaderCount(), 5u);
|
||||
ShaderArchive library(mapping);
|
||||
ASSERT_TRUE(library.IsValid());
|
||||
ASSERT_EQ(library.GetShaderCount(), 5u);
|
||||
|
||||
// Wrong type.
|
||||
ASSERT_EQ(library->GetMapping(ArchiveShaderType::kFragment, "Hello"),
|
||||
nullptr);
|
||||
ASSERT_EQ(library.GetMapping(ArchiveShaderType::kFragment, "Hello"), nullptr);
|
||||
|
||||
auto hello_vtx = library->GetMapping(ArchiveShaderType::kVertex, "Hello");
|
||||
auto hello_vtx = library.GetMapping(ArchiveShaderType::kVertex, "Hello");
|
||||
ASSERT_NE(hello_vtx, nullptr);
|
||||
ASSERT_EQ(CreateStringFromMapping(*hello_vtx), "World");
|
||||
}
|
||||
|
||||
TEST(ShaderArchiveTest, ArchiveAndMultiArchiveHaveDifferentIdentifiers) {
|
||||
// The unarchiving process depends on these identifiers to check to see if its
|
||||
// a standalone archive or a multi-archive. Things will get nutty if these are
|
||||
// ever the same.
|
||||
auto archive_id = fb::ShaderArchiveIdentifier();
|
||||
auto multi_archive_id = fb::MultiArchShaderArchiveIdentifier();
|
||||
ASSERT_EQ(std::strlen(archive_id), std::strlen(multi_archive_id));
|
||||
ASSERT_NE(std::strncmp(archive_id, multi_archive_id, std::strlen(archive_id)),
|
||||
0);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
Reference in New Issue
Block a user