SWDEV-570501 - Add Windows support for hipGraphicsGLRegisterBuffer (#2323)
This commit is contained in:
@@ -992,19 +992,15 @@ hsa_status_t hsa_amd_agent_memory_pool_get_info(
|
||||
CATCH;
|
||||
}
|
||||
|
||||
hsa_status_t hsa_amd_interop_map_buffer(uint32_t num_agents,
|
||||
hsa_agent_t* agents,
|
||||
hsa_handle_t interop_handle,
|
||||
uint32_t flags, size_t* size,
|
||||
void** ptr, size_t* metadata_size,
|
||||
const void** metadata) {
|
||||
static const int tinyArraySize=8;
|
||||
hsa_status_t hsa_amd_interop_map_buffer(uint32_t num_agents, hsa_agent_t* agents,
|
||||
hsa_handle_t interop_handle, uint32_t flags, size_t* size,
|
||||
void** ptr, size_t* metadata_size, const void** metadata) {
|
||||
static const int tinyArraySize = 8;
|
||||
TRY;
|
||||
IS_OPEN();
|
||||
IS_BAD_PTR(agents);
|
||||
IS_BAD_PTR(size);
|
||||
IS_BAD_PTR(ptr);
|
||||
if (flags != 0) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
if (num_agents == 0) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
core::Agent* short_agents[tinyArraySize];
|
||||
@@ -1025,8 +1021,8 @@ hsa_status_t hsa_amd_interop_map_buffer(uint32_t num_agents,
|
||||
}
|
||||
|
||||
auto ret = core::Runtime::runtime_singleton_->InteropMap(
|
||||
num_agents, core_agents, interop_handle, flags, size, ptr, metadata_size,
|
||||
metadata);
|
||||
num_agents, core_agents, interop_handle, static_cast<hsa_interop_map_flag_t>(flags), size,
|
||||
ptr, metadata_size, metadata);
|
||||
|
||||
return ret;
|
||||
CATCH;
|
||||
|
||||
@@ -868,24 +868,21 @@ hsa_status_t Runtime::SetAsyncSignalHandler(hsa_signal_t signal,
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t Runtime::InteropMap(uint32_t num_agents, Agent** agents,
|
||||
hsa_handle_t interop_handle,
|
||||
uint32_t flags,
|
||||
size_t* size, void** ptr,
|
||||
hsa_status_t Runtime::InteropMap(uint32_t num_agents, Agent** agents, hsa_handle_t handle,
|
||||
hsa_interop_map_flag_t flags, size_t* size, void** ptr,
|
||||
size_t* metadata_size, const void** metadata) {
|
||||
static const int tinyArraySize=8;
|
||||
constexpr int tinyArraySize = 8;
|
||||
HsaGraphicsResourceInfo info;
|
||||
|
||||
HSAuint32 short_nodes[tinyArraySize];
|
||||
HSAuint32* nodes = short_nodes;
|
||||
|
||||
static_assert(sizeof(HSAint64) >= sizeof(interop_handle),
|
||||
"HSAint64 too small for interop_handle");
|
||||
static_assert(sizeof(HSAint64) >= sizeof(handle), "HSAint64 too small for interop_handle");
|
||||
HSAint64 resource_handle =
|
||||
#ifdef _WIN32
|
||||
static_cast<HSAint64>(reinterpret_cast<uintptr_t>(interop_handle));
|
||||
static_cast<HSAint64>(reinterpret_cast<uintptr_t>(handle));
|
||||
#else
|
||||
static_cast<HSAint64>(interop_handle);
|
||||
static_cast<HSAint64>(handle);
|
||||
#endif
|
||||
|
||||
if (num_agents > tinyArraySize) {
|
||||
@@ -903,9 +900,12 @@ hsa_status_t Runtime::InteropMap(uint32_t num_agents, Agent** agents,
|
||||
agents[i]->GetInfo(static_cast<hsa_agent_info_t>(HSA_AMD_AGENT_INFO_DRIVER_NODE_ID), &nodes[i]);
|
||||
}
|
||||
|
||||
if (HSAKMT_CALL(hsaKmtRegisterGraphicsHandleToNodes(resource_handle, &info, num_agents,
|
||||
nodes)) != HSAKMT_STATUS_SUCCESS)
|
||||
return HSA_STATUS_ERROR;
|
||||
const HSA_REGISTER_MEM_FLAGS reg_flags = {
|
||||
.ui32 = {.kmtHandle = ((flags & HSA_INTEROP_MAP_FLAG_KMT_HANDLE) != 0)}};
|
||||
|
||||
auto status =
|
||||
hsaKmtRegisterGraphicsHandleToNodesExt(resource_handle, &info, num_agents, nodes, reg_flags);
|
||||
if (status != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR;
|
||||
|
||||
assert(num_agents > 0);
|
||||
auto& driver = agents[0]->driver();
|
||||
|
||||
Reference in New Issue
Block a user