Forbid copying of objects when it could cause memory leaks.

Change-Id: I079345fb0bf74babb7aa072ddee4f3a853e2572c
This commit is contained in:
Zdunowski, Piotr
2018-06-04 16:11:04 +02:00
committed by sys_ocldev
parent 8b4fdc5b8f
commit 4f3e03b560
4 changed files with 29 additions and 0 deletions

View File

@ -36,6 +36,9 @@ class DeferrableDeletionImpl : public DeferrableDeletion {
void apply() override;
~DeferrableDeletionImpl();
DeferrableDeletionImpl(const DeferrableDeletionImpl &) = delete;
DeferrableDeletionImpl &operator=(const DeferrableDeletionImpl &) = delete;
protected:
Wddm *wddm;
D3DKMT_HANDLE *handles = nullptr;

View File

@ -42,6 +42,9 @@ class WddmMemoryManager : public MemoryManager {
~WddmMemoryManager();
WddmMemoryManager(bool enable64kbPages, Wddm *wddm);
WddmMemoryManager(const WddmMemoryManager &) = delete;
WddmMemoryManager &operator=(const WddmMemoryManager &) = delete;
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;

View File

@ -23,8 +23,20 @@
#include "runtime/os_interface/windows/deferrable_deletion_win.h"
#include "unit_tests/mocks/mock_wddm20.h"
#include "gtest/gtest.h"
#include <type_traits>
using namespace OCLRT;
TEST(DeferrableDeletionImpl, NonCopyable) {
EXPECT_FALSE(std::is_move_constructible<DeferrableDeletionImpl>::value);
EXPECT_FALSE(std::is_copy_constructible<DeferrableDeletionImpl>::value);
}
TEST(DeferrableDeletionImpl, NonAssignable) {
EXPECT_FALSE(std::is_move_assignable<DeferrableDeletionImpl>::value);
EXPECT_FALSE(std::is_copy_assignable<DeferrableDeletionImpl>::value);
}
class MockDeferrableDeletion : public DeferrableDeletionImpl {
public:
MockDeferrableDeletion(Wddm *wddm, D3DKMT_HANDLE *handles, uint32_t allocationCount, uint64_t lastFenceValue,

View File

@ -32,10 +32,21 @@
#include "unit_tests/os_interface/windows/wddm_fixture.h"
#include "unit_tests/os_interface/windows/mock_gdi_interface.h"
#include "unit_tests/os_interface/windows/mock_wddm_memory_manager.h"
#include <type_traits>
using namespace OCLRT;
using namespace ::testing;
TEST(WddmMemoryManager, NonCopyable) {
EXPECT_FALSE(std::is_move_constructible<WddmMemoryManager>::value);
EXPECT_FALSE(std::is_copy_constructible<WddmMemoryManager>::value);
}
TEST(WddmMemoryManager, NonAssignable) {
EXPECT_FALSE(std::is_move_assignable<WddmMemoryManager>::value);
EXPECT_FALSE(std::is_copy_assignable<WddmMemoryManager>::value);
}
class WddmMemoryManagerFixture : public GdiDllFixture {
public:
void SetUp() override;