SWDEV-381627 - Move cl_vk_amd.hpp into rocclr

Rename VK interop to ExternalMemory object, since it should handle
DX interops also

Change-Id: I536ec46d3e53ece35234a2e29030393ad411b96d


[ROCm/clr commit: 3e5803c4c0]
This commit is contained in:
German Andryeyev
2023-04-19 16:48:00 -04:00
parent a00b618051
commit b2525dfb82
6 changed files with 123 additions and 163 deletions
-132
View File
@@ -1,132 +0,0 @@
/* Copyright (c) 2010 - 2021 Advanced Micro Devices, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
#pragma once
#include "platform/context.hpp"
#include "platform/memory.hpp"
namespace amd
{
class VkObject : public InteropObject
{
public:
enum HandleType {
ExternalMemoryFd = 1,
ExternalMemoryWin32 = 2,
ExternalMemoryWin32KMT = 3,
};
//! GLObject constructor initializes member variables
VkObject(
amd::Os::FileDesc handle,
VkObject::HandleType handle_type
) // Initialization of member variables
{
handleVk_ = handle;
handle_type_ = handle_type;
}
virtual ~VkObject() {}
VkObject* asVkObject() { return this; }
amd::Os::FileDesc getVkSharedHandle() const { return handleVk_; }
HandleType getHandleType() const { return handle_type_; }
protected:
amd::Os::FileDesc handleVk_;
VkObject::HandleType handle_type_;
};
class BufferVk : public Buffer, public VkObject
{
protected:
//! Initializes the device memory array which is nested
// after'BufferVk' object in memory layout.
void initDeviceMemory() {
deviceMemories_ =
reinterpret_cast<DeviceMemory*>(reinterpret_cast<char*>(this) + sizeof(BufferVk));
memset(deviceMemories_, 0, context_().devices().size() * sizeof(DeviceMemory));
}
public:
//! BufferVk constructor just calls constructors of base classes
//! to pass down the parameters
BufferVk(
Context& amdContext,
size_t uiSizeInBytes,
amd::Os::FileDesc handle,
VkObject::HandleType handle_type) : // Call base classes constructors
Buffer(
amdContext,
0,
uiSizeInBytes
),
VkObject(
handle, handle_type
)
{
setInteropObj(this);
}
virtual ~BufferVk() {}
BufferVk* asBufferVk() { return this; }
};
// to be modified once image requirments are known, for now, implement like buffer
class ImageVk : public Buffer, public VkObject
{
protected:
//! Initializes the device memory array which is nested
// after'ImageVk' object in memory layout.
void initDeviceMemory() {
deviceMemories_ =
reinterpret_cast<DeviceMemory*>(reinterpret_cast<char*>(this) + sizeof(ImageVk));
memset(deviceMemories_, 0, context_().devices().size() * sizeof(DeviceMemory));
}
public:
//! ImageVk constructor just calls constructors of base classes
//! to pass down the parameters
ImageVk(
Context& amdContext,
size_t uiSizeInBytes,
amd::Os::FileDesc handle,
VkObject::HandleType handle_type): // Call base classes constructors
Buffer(
amdContext,
0,
uiSizeInBytes
),
VkObject(
handle, handle_type
)
{
setInteropObj(this);
}
virtual ~ImageVk() {}
ImageVk* asImageVk() { return this; }
};
}