[Impeller] fix macOS managed memory. (#164635)
Still crashes with non UMA GPU. Reason is that the if check is using `MTLResourceStorageModeManaged` when it should be using `MTLStorageModeManaged` Fixes https://github.com/flutter/flutter/issues/163218
This commit is contained in:
parent
1e9676fc95
commit
1cd6cb0cdc
@ -44,6 +44,11 @@ class AllocatorMTL final : public Allocator {
|
|||||||
// |Allocator|
|
// |Allocator|
|
||||||
Bytes DebugGetHeapUsage() const override;
|
Bytes DebugGetHeapUsage() const override;
|
||||||
|
|
||||||
|
// visible for testing.
|
||||||
|
void DebugSetSupportsUMA(bool value);
|
||||||
|
|
||||||
|
AllocatorMTL(id<MTLDevice> device, std::string label);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ContextMTL;
|
friend class ContextMTL;
|
||||||
|
|
||||||
@ -60,8 +65,6 @@ class AllocatorMTL final : public Allocator {
|
|||||||
|
|
||||||
ISize max_texture_supported_;
|
ISize max_texture_supported_;
|
||||||
|
|
||||||
AllocatorMTL(id<MTLDevice> device, std::string label);
|
|
||||||
|
|
||||||
// |Allocator|
|
// |Allocator|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
@ -255,6 +255,10 @@ ISize AllocatorMTL::GetMaxTextureSizeSupported() const {
|
|||||||
return max_texture_supported_;
|
return max_texture_supported_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AllocatorMTL::DebugSetSupportsUMA(bool value) {
|
||||||
|
supports_uma_ = value;
|
||||||
|
}
|
||||||
|
|
||||||
Bytes AllocatorMTL::DebugGetHeapUsage() const {
|
Bytes AllocatorMTL::DebugGetHeapUsage() const {
|
||||||
#ifdef IMPELLER_DEBUG
|
#ifdef IMPELLER_DEBUG
|
||||||
return debug_allocater_->GetAllocationSize();
|
return debug_allocater_->GetAllocationSize();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "flutter/testing/testing.h"
|
#include "flutter/testing/testing.h"
|
||||||
|
#include "impeller/core/device_buffer_descriptor.h"
|
||||||
#include "impeller/core/formats.h"
|
#include "impeller/core/formats.h"
|
||||||
#include "impeller/core/texture_descriptor.h"
|
#include "impeller/core/texture_descriptor.h"
|
||||||
#include "impeller/playground/playground_test.h"
|
#include "impeller/playground/playground_test.h"
|
||||||
@ -70,5 +71,21 @@ TEST_P(AllocatorMTLTest, DebugTraceMemoryStatistics) {
|
|||||||
0u);
|
0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(AllocatorMTLTest, ManagedMemory) {
|
||||||
|
auto& context_mtl = ContextMTL::Cast(*GetContext());
|
||||||
|
auto allocator = std::make_unique<AllocatorMTL>(context_mtl.GetMTLDevice(),
|
||||||
|
"test-allocator");
|
||||||
|
allocator->DebugSetSupportsUMA(false);
|
||||||
|
|
||||||
|
DeviceBufferDescriptor desc;
|
||||||
|
desc.size = 100;
|
||||||
|
desc.storage_mode = StorageMode::kHostVisible;
|
||||||
|
|
||||||
|
auto buffer = allocator->CreateBuffer(desc);
|
||||||
|
ASSERT_TRUE(buffer);
|
||||||
|
|
||||||
|
EXPECT_NE(buffer->OnGetContents(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
} // namespace impeller
|
} // namespace impeller
|
||||||
|
@ -25,7 +25,7 @@ id<MTLBuffer> DeviceBufferMTL::GetMTLBuffer() const {
|
|||||||
uint8_t* DeviceBufferMTL::OnGetContents() const {
|
uint8_t* DeviceBufferMTL::OnGetContents() const {
|
||||||
#if !FML_OS_IOS
|
#if !FML_OS_IOS
|
||||||
if (storage_mode_ != MTLStorageModeShared &&
|
if (storage_mode_ != MTLStorageModeShared &&
|
||||||
storage_mode_ != MTLResourceStorageModeManaged) {
|
storage_mode_ != MTLStorageModeManaged) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user