SWDEV-245532 - HIP - Vulkan interop
Change-Id: I0e5bc4862925f344b3fcadf1fa0c0acaeaae6c4d
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "amdocl/cl_d3d11_amd.hpp"
|
||||
#endif //_WIN32
|
||||
#include "amdocl/cl_gl_amd.hpp"
|
||||
#include "amdocl/cl_vk_amd.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
@@ -221,6 +222,7 @@ bool Memory::processGLResource(GLResourceOP operation) {
|
||||
bool Memory::createInterop() {
|
||||
Resource::MemoryType memType = Resource::Empty;
|
||||
Resource::OGLInteropParams oglRes;
|
||||
Resource::VkInteropParams vkRes;
|
||||
#ifdef _WIN32
|
||||
Resource::D3DInteropParams d3dRes;
|
||||
#endif //_WIN32
|
||||
@@ -233,6 +235,7 @@ bool Memory::createInterop() {
|
||||
amd::InteropObject* interop = owner()->getInteropObj();
|
||||
assert((interop != nullptr) && "An invalid interop object is impossible!");
|
||||
|
||||
amd::VkObject* vkObject = interop->asVkObject();
|
||||
amd::GLObject* glObject = interop->asGLObject();
|
||||
#ifdef _WIN32
|
||||
amd::D3D10Object* d3d10Object = interop->asD3D10Object();
|
||||
@@ -342,7 +345,16 @@ bool Memory::createInterop() {
|
||||
}
|
||||
} else
|
||||
#endif //_WIN32
|
||||
if (glObject != nullptr) {
|
||||
if (vkObject != nullptr) {
|
||||
createParams = &vkRes;
|
||||
vkRes.owner_ = owner();
|
||||
memType = Resource::VkInterop;
|
||||
vkRes.handle_ = vkObject->getVkSharedHandle();
|
||||
assert(vkRes.handle_ != nullptr);
|
||||
vkRes.type_ = Resource::InteropTypeless;
|
||||
}
|
||||
|
||||
else if (glObject != nullptr) {
|
||||
createParams = &oglRes;
|
||||
|
||||
oglRes.owner_ = owner();
|
||||
|
||||
@@ -753,6 +753,10 @@ bool Resource::CreateInterop(CreateParams* params) {
|
||||
desc_.isDoppTexture_ = (openInfo.doppDesktopInfo.gpuVirtAddr != 0);
|
||||
format = dev().getPalFormat(desc().format_, &channels);
|
||||
}
|
||||
else if (memoryType() == VkInterop) {
|
||||
VkInteropParams* vparams = reinterpret_cast<VkInteropParams*>(params);
|
||||
openInfo.hExternalResource = vparams->handle_;
|
||||
}
|
||||
#ifdef ATI_OS_WIN
|
||||
else {
|
||||
D3DInteropParams* d3dRes = reinterpret_cast<D3DInteropParams*>(params);
|
||||
@@ -1174,6 +1178,7 @@ bool Resource::create(MemoryType memType, CreateParams* params, bool forceLinear
|
||||
case D3D9Interop:
|
||||
case D3D10Interop:
|
||||
case D3D11Interop:
|
||||
case VkInterop:
|
||||
return CreateInterop(params);
|
||||
case P2PAccess:
|
||||
return CreateP2PAccess(params);
|
||||
|
||||
@@ -136,6 +136,11 @@ class Resource : public amd::HeapObject {
|
||||
void* glPlatformContext_;
|
||||
};
|
||||
|
||||
struct VkInteropParams : public CreateParams {
|
||||
InteropType type_; //!< Vulkan resource type
|
||||
void* handle_;
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
struct D3DInteropParams : public CreateParams {
|
||||
InteropType type_; //!< D3D resource type
|
||||
@@ -166,7 +171,8 @@ class Resource : public amd::HeapObject {
|
||||
D3D9Interop, //!< resource is a D3D9 memory object
|
||||
Scratch, //!< resource is scratch memory
|
||||
Shader, //!< resource is a shader
|
||||
P2PAccess //!< resource is a shared resource for P2P access
|
||||
P2PAccess, //!< resource is a shared resource for P2P access
|
||||
VkInterop //!< resource is a Vulkan memory object
|
||||
};
|
||||
|
||||
//! Resource map flags
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace amd {
|
||||
//! Forward declarations of interop classes
|
||||
class GLObject;
|
||||
class BufferGL;
|
||||
class VkObject;
|
||||
class BufferVk;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class D3D10Object;
|
||||
@@ -40,13 +43,16 @@ class InteropObject {
|
||||
virtual ~InteropObject() {}
|
||||
|
||||
// Static cast functions for interop objects
|
||||
virtual GLObject* asGLObject() { return NULL; }
|
||||
virtual BufferGL* asBufferGL() { return NULL; }
|
||||
virtual GLObject* asGLObject() { return nullptr; }
|
||||
virtual BufferGL* asBufferGL() { return nullptr; }
|
||||
|
||||
virtual VkObject* asVkObject() { return nullptr; }
|
||||
virtual BufferVk* asBufferVk() { return nullptr; }
|
||||
|
||||
#ifdef _WIN32
|
||||
virtual D3D10Object* asD3D10Object() { return NULL; }
|
||||
virtual D3D11Object* asD3D11Object() { return NULL; }
|
||||
virtual D3D9Object* asD3D9Object() { return NULL; }
|
||||
virtual D3D10Object* asD3D10Object() { return nullptr; }
|
||||
virtual D3D11Object* asD3D11Object() { return nullptr; }
|
||||
virtual D3D9Object* asD3D9Object() { return nullptr; }
|
||||
#endif //_WIN32
|
||||
|
||||
// On acquire copy data from original resource to shared resource
|
||||
|
||||
مرجع در شماره جدید
Block a user