[Impeller] use specific format for bootstrap texture. (flutter/engine#51082)
If we select a wide gamut format then 32 bits isn't enough to fill the texture.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
namespace impeller {
|
||||
|
||||
static std::atomic_int32_t sValidationLogsDisabledCount = 0;
|
||||
static bool sValidationLogsAreFatal = false;
|
||||
static std::atomic_int32_t sValidationLogsAreFatal = 0;
|
||||
|
||||
void ImpellerValidationErrorsSetFatal(bool fatal) {
|
||||
sValidationLogsAreFatal = fatal;
|
||||
@@ -25,6 +25,14 @@ ScopedValidationDisable::~ScopedValidationDisable() {
|
||||
sValidationLogsDisabledCount--;
|
||||
}
|
||||
|
||||
ScopedValidationFatal::ScopedValidationFatal() {
|
||||
sValidationLogsAreFatal++;
|
||||
}
|
||||
|
||||
ScopedValidationFatal::~ScopedValidationFatal() {
|
||||
sValidationLogsAreFatal--;
|
||||
}
|
||||
|
||||
ValidationLog::ValidationLog() = default;
|
||||
|
||||
ValidationLog::~ValidationLog() {
|
||||
@@ -43,7 +51,7 @@ void ImpellerValidationBreak(const char* message) {
|
||||
std::stringstream stream;
|
||||
stream << "Break on '" << __FUNCTION__
|
||||
<< "' to inspect point of failure: " << message;
|
||||
if (sValidationLogsAreFatal) {
|
||||
if (sValidationLogsAreFatal > 0) {
|
||||
FML_LOG(FATAL) << stream.str();
|
||||
} else {
|
||||
FML_LOG(ERROR) << stream.str();
|
||||
|
||||
@@ -49,6 +49,16 @@ struct ScopedValidationDisable {
|
||||
ScopedValidationDisable& operator=(const ScopedValidationDisable&) = delete;
|
||||
};
|
||||
|
||||
struct ScopedValidationFatal {
|
||||
ScopedValidationFatal();
|
||||
|
||||
~ScopedValidationFatal();
|
||||
|
||||
ScopedValidationFatal(const ScopedValidationFatal&) = delete;
|
||||
|
||||
ScopedValidationFatal& operator=(const ScopedValidationFatal&) = delete;
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -662,7 +662,7 @@ void ContentContext::InitializeCommonlyUsedShadersIfNeeded() const {
|
||||
TextureDescriptor desc;
|
||||
desc.size = {1, 1};
|
||||
desc.storage_mode = StorageMode::kHostVisible;
|
||||
desc.format = context_->GetCapabilities()->GetDefaultColorFormat();
|
||||
desc.format = PixelFormat::kR8G8B8A8UNormInt;
|
||||
auto texture = GetContext()->GetResourceAllocator()->CreateTexture(desc);
|
||||
uint32_t color = 0;
|
||||
if (!texture->SetContents(reinterpret_cast<uint8_t*>(&color), 4u)) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "impeller/base/comparable.h"
|
||||
#include "impeller/core/allocator.h"
|
||||
#include "impeller/core/device_buffer_descriptor.h"
|
||||
#include "impeller/core/formats.h"
|
||||
#include "impeller/core/texture_descriptor.h"
|
||||
#include "impeller/entity/contents/content_context.h"
|
||||
#include "impeller/entity/contents/test/recording_render_pass.h"
|
||||
@@ -50,6 +51,9 @@ class FakeTexture : public Texture {
|
||||
bool OnSetContents(const uint8_t* contents,
|
||||
size_t length,
|
||||
size_t slice) override {
|
||||
if (GetTextureDescriptor().GetByteSizeOfBaseMipLevel() != length) {
|
||||
return false;
|
||||
}
|
||||
did_set_contents = true;
|
||||
return true;
|
||||
}
|
||||
@@ -209,11 +213,15 @@ class FakeCommandBuffer : public CommandBuffer {
|
||||
class FakeContext : public Context,
|
||||
public std::enable_shared_from_this<FakeContext> {
|
||||
public:
|
||||
explicit FakeContext(const std::string& gpu_model = "")
|
||||
explicit FakeContext(
|
||||
const std::string& gpu_model = "",
|
||||
PixelFormat default_color_format = PixelFormat::kR8G8B8A8UNormInt)
|
||||
: Context(),
|
||||
allocator_(std::make_shared<FakeAllocator>()),
|
||||
capabilities_(
|
||||
std::shared_ptr<Capabilities>(CapabilitiesBuilder().Build())),
|
||||
capabilities_(std::shared_ptr<Capabilities>(
|
||||
CapabilitiesBuilder()
|
||||
.SetDefaultColorFormat(default_color_format)
|
||||
.Build())),
|
||||
pipelines_(std::make_shared<FakePipelineLibrary>()),
|
||||
queue_(std::make_shared<CommandQueue>()),
|
||||
shader_library_(std::make_shared<FakeShaderLibrary>()),
|
||||
@@ -327,7 +335,10 @@ TEST(ContentContext, InvalidatesAllPipelinesWithSameUniqueNameOnClear) {
|
||||
}
|
||||
|
||||
TEST(ContentContext, InitializeCommonlyUsedShadersIfNeeded) {
|
||||
auto context = std::make_shared<FakeContext>("Mali G70");
|
||||
ScopedValidationFatal fatal_validations;
|
||||
// Set a pixel format that is larger than 32bpp.
|
||||
auto context = std::make_shared<FakeContext>("Mali G70",
|
||||
PixelFormat::kR16G16B16A16Float);
|
||||
ContentContext content_context(context, nullptr);
|
||||
|
||||
FakeAllocator& fake_allocator =
|
||||
|
||||
Reference in New Issue
Block a user