P4 to Git Change 1537347 by gandryey@gera-w8 on 2018/04/05 17:42:56
SWDEV-79445 - OCL generic changes and code clean-up - Remove obsolete code in the interop logic Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#81 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#20 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.hpp#4 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#86 edit
Αυτή η υποβολή περιλαμβάνεται σε:
@@ -1309,7 +1309,7 @@ pal::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const {
|
||||
|
||||
// Check if owner is interop memory
|
||||
if (owner.isInterop()) {
|
||||
result = gpuMemory->createInterop(Memory::InteropDirectAccess);
|
||||
result = gpuMemory->createInterop();
|
||||
} else if (owner.getMemFlags() & CL_MEM_USE_PERSISTENT_MEM_AMD) {
|
||||
// Attempt to allocate from persistent heap
|
||||
result = gpuMemory->create(Resource::Persistent);
|
||||
@@ -1454,7 +1454,7 @@ pal::Memory* Device::createImage(amd::Memory& owner, bool directAccess) const {
|
||||
|
||||
// Check if owner is interop memory
|
||||
if (owner.isInterop()) {
|
||||
result = gpuImage->createInterop(Memory::InteropDirectAccess);
|
||||
result = gpuImage->createInterop();
|
||||
} else if (imageBuffer) {
|
||||
Resource::ImageBufferParams params;
|
||||
pal::Memory* buffer = reinterpret_cast<pal::Memory*>(image.parent()->getDeviceMemory(*this));
|
||||
|
||||
@@ -23,22 +23,26 @@
|
||||
namespace pal {
|
||||
|
||||
Memory::Memory(const Device& gpuDev, amd::Memory& owner, size_t size)
|
||||
: device::Memory(owner), Resource(gpuDev, size) {
|
||||
init();
|
||||
: device::Memory(owner), Resource(gpuDev, size)
|
||||
, pinnedMemory_(nullptr)
|
||||
, parent_(nullptr) {
|
||||
|
||||
if (owner.parent() != nullptr) {
|
||||
flags_ |= SubMemoryObject;
|
||||
}
|
||||
}
|
||||
|
||||
Memory::Memory(const Device& gpuDev, size_t size) : device::Memory(size), Resource(gpuDev, size) {
|
||||
init();
|
||||
Memory::Memory(const Device& gpuDev, size_t size)
|
||||
: device::Memory(size), Resource(gpuDev, size)
|
||||
, pinnedMemory_(nullptr)
|
||||
, parent_(nullptr) {
|
||||
}
|
||||
|
||||
Memory::Memory(const Device& gpuDev, amd::Memory& owner, size_t width, size_t height, size_t depth,
|
||||
cl_image_format format, cl_mem_object_type imageType, uint mipLevels)
|
||||
: device::Memory(owner), Resource(gpuDev, width, height, depth, format, imageType, mipLevels) {
|
||||
init();
|
||||
: device::Memory(owner), Resource(gpuDev, width, height, depth, format, imageType, mipLevels)
|
||||
, pinnedMemory_(nullptr)
|
||||
, parent_(nullptr) {
|
||||
|
||||
if (owner.parent() != nullptr) {
|
||||
flags_ |= SubMemoryObject;
|
||||
@@ -47,16 +51,9 @@ Memory::Memory(const Device& gpuDev, amd::Memory& owner, size_t width, size_t he
|
||||
|
||||
Memory::Memory(const Device& gpuDev, size_t size, size_t width, size_t height, size_t depth,
|
||||
cl_image_format format, cl_mem_object_type imageType, uint mipLevels)
|
||||
: device::Memory(size), Resource(gpuDev, width, height, depth, format, imageType, mipLevels) {
|
||||
init();
|
||||
}
|
||||
|
||||
void Memory::init() {
|
||||
indirectMapCount_ = 0;
|
||||
interopType_ = InteropNone;
|
||||
interopMemory_ = nullptr;
|
||||
pinnedMemory_ = nullptr;
|
||||
parent_ = nullptr;
|
||||
: device::Memory(size), Resource(gpuDev, width, height, depth, format, imageType, mipLevels)
|
||||
, pinnedMemory_(nullptr)
|
||||
, parent_(nullptr) {
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -194,7 +191,7 @@ bool Memory::processGLResource(GLResourceOP operation) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool Memory::createInterop(InteropType type) {
|
||||
bool Memory::createInterop() {
|
||||
Resource::MemoryType memType = Resource::Empty;
|
||||
Resource::OGLInteropParams oglRes;
|
||||
#ifdef _WIN32
|
||||
@@ -374,26 +371,11 @@ bool Memory::createInterop(InteropType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the interop settings
|
||||
if (type == InteropDirectAccess) {
|
||||
// Create memory object
|
||||
if (!create(memType, createParams)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Allocate Resource object for interop as buffer
|
||||
interopMemory_ = new Memory(dev(), size());
|
||||
|
||||
// Create the interop object in CAL
|
||||
if (nullptr == interopMemory_ || !interopMemory_->create(memType, createParams)) {
|
||||
delete interopMemory_;
|
||||
interopMemory_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
// Create memory object
|
||||
if (!create(memType, createParams)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setInteropType(type);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -401,8 +383,6 @@ Memory::~Memory() {
|
||||
// Clean VA cache
|
||||
dev().removeVACache(this);
|
||||
|
||||
delete interopMemory_;
|
||||
|
||||
// Release associated map target, if any
|
||||
if (nullptr != mapMemory_) {
|
||||
mapMemory()->unmap(nullptr);
|
||||
|
||||
@@ -28,12 +28,6 @@ class VirtualGPU;
|
||||
// Wrapper that can contain a heap block or an interop buffer/image.
|
||||
class Memory : public device::Memory, public Resource {
|
||||
public:
|
||||
enum InteropType {
|
||||
InteropNone = 0, //!< None interop memory
|
||||
InteropHwEmulation = 1, //!< Uses HW emulaiton with calMemCopy
|
||||
InteropDirectAccess = 2 //!< Uses direct access to the interop surface
|
||||
};
|
||||
|
||||
//! Constructor (with owner)
|
||||
Memory(const Device& gpuDev, //!< GPU device object
|
||||
amd::Memory& owner, //!< Abstraction layer memory object
|
||||
@@ -71,8 +65,7 @@ class Memory : public device::Memory, public Resource {
|
||||
~Memory();
|
||||
|
||||
//! Creates the interop memory
|
||||
bool createInterop(InteropType type //!< The interop type
|
||||
);
|
||||
bool createInterop();
|
||||
|
||||
//! Overloads the resource create method
|
||||
virtual bool create(Resource::MemoryType memType, //!< Memory type
|
||||
@@ -133,18 +126,6 @@ class Memory : public device::Memory, public Resource {
|
||||
//! Accessors for indirect map memory object
|
||||
Memory* mapMemory() const;
|
||||
|
||||
//! Returns the interop memory for this memory object
|
||||
Memory* interop() const { return interopMemory_; }
|
||||
|
||||
//! Gets interop type for this memory object
|
||||
InteropType interopType() const { return interopType_; }
|
||||
|
||||
//! Sets interop type for this memory object
|
||||
void setInteropType(InteropType type) { interopType_ = type; }
|
||||
|
||||
//! Set the owner
|
||||
void setOwner(amd::Memory* owner) { owner_ = owner; }
|
||||
|
||||
// Decompress GL depth-stencil/MSAA resources for CL access
|
||||
// Invalidates any FBOs the resource may be bound to, otherwise the GL driver may crash.
|
||||
virtual bool processGLResource(GLResourceOP operation);
|
||||
@@ -165,9 +146,6 @@ class Memory : public device::Memory, public Resource {
|
||||
//! Decrement map count
|
||||
void decIndMapCount();
|
||||
|
||||
//! Initialize the object members
|
||||
void init();
|
||||
|
||||
private:
|
||||
//! Disable copy constructor
|
||||
Memory(const Memory&);
|
||||
@@ -175,8 +153,6 @@ class Memory : public device::Memory, public Resource {
|
||||
//! Disable operator=
|
||||
Memory& operator=(const Memory&);
|
||||
|
||||
InteropType interopType_; //!< Interop type
|
||||
Memory* interopMemory_; //!< interop memory
|
||||
Memory* pinnedMemory_; //!< Memory used as pinned system memory
|
||||
const Memory* parent_; //!< Parent memory object
|
||||
};
|
||||
|
||||
@@ -2489,25 +2489,6 @@ void VirtualGPU::submitAcquireExtObjects(amd::AcquireExtObjectsCommand& vcmd) {
|
||||
// If resource is a shared copy of original resource, then
|
||||
// runtime needs to copy data from original resource
|
||||
it->getInteropObj()->copyOrigToShared();
|
||||
|
||||
// Check if OpenCL has direct access to the interop memory
|
||||
if (memory->interopType() == Memory::InteropDirectAccess) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Does interop use HW emulation?
|
||||
if (memory->interopType() == Memory::InteropHwEmulation) {
|
||||
static const bool Entire = true;
|
||||
amd::Coord3D origin(0, 0, 0);
|
||||
amd::Coord3D region(memory->size());
|
||||
|
||||
// Synchronize the object
|
||||
if (!blitMgr().copyBuffer(*memory->interop(), *memory, origin, origin, region, Entire)) {
|
||||
LogError("submitAcquireExtObjects - Interop synchronization failed!");
|
||||
vcmd.setStatus(CL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
profilingEnd(vcmd);
|
||||
@@ -2524,24 +2505,6 @@ void VirtualGPU::submitReleaseExtObjects(amd::ReleaseExtObjectsCommand& vcmd) {
|
||||
assert(it && "Memory object for interop is nullptr");
|
||||
pal::Memory* memory = dev().getGpuMemory(it);
|
||||
|
||||
// Check if we can use HW interop
|
||||
if (memory->interopType() == Memory::InteropHwEmulation) {
|
||||
static const bool Entire = true;
|
||||
amd::Coord3D origin(0, 0, 0);
|
||||
amd::Coord3D region(memory->size());
|
||||
|
||||
// Synchronize the object
|
||||
if (!blitMgr().copyBuffer(*memory, *memory->interop(), origin, origin, region, Entire)) {
|
||||
LogError("submitReleaseExtObjects interop synchronization failed!");
|
||||
vcmd.setStatus(CL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (memory->interopType() != Memory::InteropDirectAccess) {
|
||||
LogError("None interop release!");
|
||||
}
|
||||
}
|
||||
|
||||
// If resource is a shared copy of original resource, then
|
||||
// runtime needs to copy data back to original resource
|
||||
it->getInteropObj()->copySharedToOrig();
|
||||
|
||||
Αναφορά σε νέο ζήτημα
Block a user