SWDEV-508869 - Fix Linux build error for HIP on PAL (#176)

Цей коміт міститься в:
Lin, Qun
2025-06-27 07:51:22 +08:00
зафіксовано GitHub
джерело a2dafbeacf
коміт 9699cc3864
8 змінених файлів з 37 додано та 17 видалено
+1 -1
Переглянути файл
@@ -981,7 +981,7 @@ class Memory : public amd::HeapObject {
//! not a physical map. When a memory object does not use USE_HOST_PTR we
//! can use a remote resource and DMA, avoiding the additional CPU memcpy.
amd::Memory* mapMemory_; //!< Memory used as map target buffer
volatile size_t indirectMapCount_; //!< Number of maps
std::atomic<size_t> indirectMapCount_; //!< Number of maps
std::unordered_map<const void*, WriteMapInfo>
writeMapInfo_; //!< Saved write map info for partial unmap
+7 -4
Переглянути файл
@@ -426,7 +426,7 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp,
uint64_t(heaps[Pal::GpuHeapInvisible].physicalSize));
}
#if defined(ATI_OS_WIN)
#if IS_WINDOWS
if (settings().apuSystem_) {
info_.maxMemAllocSize_ = std::max(
(static_cast<uint64_t>(heaps[Pal::GpuHeapGartUswc].logicalSize) * uswcPercentAvailable) /
@@ -673,8 +673,10 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp,
info_.vgprsPerSimd_ = palProp.gfxipProperties.shaderCore.vgprsPerSimd;
info_.sgprsPerSimd_ = palProp.gfxipProperties.shaderCore.sgprsPerSimd;
info_.availableRegistersPerCU_ = info_.vgprsPerSimd_ * info_.simdPerCU_ * 32;
#if IS_WINDOWS
info_.luidLowPart_ = palProp.osProperties.luidLowPart;
info_.luidHighPart_ = palProp.osProperties.luidHighPart;
#endif
// Setup the node mask for MGPU only case from the original PAL list of all devices
if ((gNumDevices > 1) && (pal_device != nullptr)) {
for (uint32_t i = 0; i < gNumDevices; ++i) {
@@ -2058,6 +2060,7 @@ bool Device::globalFreeMemory(size_t* freeMemory) const {
Pal::gpusize system_memory = allocedMem[Pal::GpuHeapGartCacheable] +
allocedMem[Pal::GpuHeapGartUswc] + cache_group_local - resourceCache().cacheSize();
#if IS_WINDOWS
// Second, query OS for overall memory usage on the system
if (properties().osProperties.supportMemoryBudgetQuery) {
@@ -2086,7 +2089,7 @@ bool Device::globalFreeMemory(size_t* freeMemory) const {
system_memory = system_total_alloced;
}
}
#endif
// Third, finalize reported free memory
// Fill free memory info
@@ -2799,12 +2802,12 @@ bool Device::createBlitProgram() {
if (asm_program->load()) {
trap_handler_ = asm_program;
} else {
DevLogPrintfError("Could not load the trap handler \n");
DevLogError("Could not load the trap handler \n");
asm_program->release();
}
}
} else {
DevLogPrintfError("Trap handler creation failed\n");
DevLogError("Trap handler creation failed\n");
}
}
+10 -1
Переглянути файл
@@ -65,6 +65,15 @@ static PFNGlxGetProcAddress pfnGlxGetProcAddress = nullptr;
typedef int(APIENTRYP PFNMesaGLInteropGLXQueryDeviceInfo)(Display* dpy, GLXContext context,
mesa_glinterop_device_info* out);
static PFNMesaGLInteropGLXQueryDeviceInfo pfnMesaGLInteropGLXQueryDeviceInfo = nullptr;
typedef Bool(APIENTRYP PFNGLXBEGINCLINTEROPAMD)(GLXContext context, GLuint flags);
typedef Bool(APIENTRYP PFNGLXENDCLINTEROPAMD)(GLXContext context, GLuint flags);
typedef Bool(APIENTRYP PFNGLXRESOURCEATTACHAMD)(GLXContext context, GLvoid* resource,
GLvoid* pResourceData);
typedef Bool(APIENTRYP PFNGLXRESOURCEDETACHAMD)(GLXContext context, GLvoid* resource);
typedef Bool(APIENTRYP PFNGLXRESOURCEDETACHAMD)(GLXContext context, GLvoid* resource);
typedef Bool(APIENTRYP PFNGLXRESOURCEDETACHAMD)(GLXContext context, GLvoid* resource);
typedef Bool(APIENTRYP PFNGLXGETCONTEXTMVPUINFOAMD)(GLXContext context, GLuint* deviceId,
GLuint* chainMask);
static PFNGLXBEGINCLINTEROPAMD glXBeginCLInteropAMD = nullptr;
static PFNGLXENDCLINTEROPAMD glXEndCLInteropAMD = nullptr;
static PFNGLXRESOURCEATTACHAMD glXResourceAttachAMD = nullptr;
@@ -90,8 +99,8 @@ static PFNWGLRESOURCEDETACHAMD wglResourceAcquireAMD = nullptr;
static PFNWGLRESOURCEDETACHAMD wglResourceReleaseAMD = nullptr;
static PFNWGLRESOURCEDETACHAMD wglResourceDetachAMD = nullptr;
static PFNWGLGETCONTEXTGPUINFOAMD wglGetContextGPUInfoAMD = nullptr;
bool gGlFuncInit = false;
#endif
bool gGlFuncInit = false;
namespace amd::pal {
+2
Переглянути файл
@@ -1031,8 +1031,10 @@ Memory* Buffer::createBufferView(amd::Memory& subBufferOwner) const {
// ================================================================================================
bool Buffer::ExportHandle(void* handle) const {
Pal::GpuMemoryExportInfo exportInfo = {};
#if IS_WINDOWS
// Set default flags in case they are not provided by application
exportInfo.accessFlags = GENERIC_READ | GENERIC_WRITE;
#endif
*reinterpret_cast<Pal::OsExternalHandle*>(handle) = iMem()->ExportExternalHandle(exportInfo);
return true;
}
+8 -4
Переглянути файл
@@ -792,7 +792,7 @@ bool Resource::CreateInterop(CreateParams* params) {
if (!dev().resGLAssociate(oglRes->glPlatformContext_, oglRes->handle_, glType_,
&openInfo.hExternalResource, &glInteropMbRes_, &offset_, desc_.format_
#ifdef ATI_OS_WIN
#if IS_WINDOWS
,
openInfo.doppDesktopInfo
#endif
@@ -808,6 +808,7 @@ bool Resource::CreateInterop(CreateParams* params) {
if (vparams->handle_) {
openInfo.hExternalResource = vparams->handle_;
} else if (vparams->name_) {
#if IS_WINDOWS
Pal::ExternalHandleInfo eHandleInfo = {};
eHandleInfo.objectType = Pal::ExternalObjectType::Allocation;
eHandleInfo.pNtObjectName = reinterpret_cast<const wchar_t*>(vparams->name_);
@@ -819,10 +820,13 @@ bool Resource::CreateInterop(CreateParams* params) {
dev().iDev()->OpenExternalHandleFromName(eHandleInfo, &openInfo.hExternalResource)) {
return false;
}
#else
return false;
#endif
}
openInfo.flags.ntHandle = vparams->nt_handle_;
}
#ifdef ATI_OS_WIN
#if IS_WINDOWS
else {
D3DInteropParams* d3dRes = reinterpret_cast<D3DInteropParams*>(params);
openInfo.hExternalResource = d3dRes->handle_;
@@ -883,7 +887,7 @@ bool Resource::CreateInterop(CreateParams* params) {
switch (misc) {
case 1: // NV12 or P010 formats
switch (layer) {
case -1:
case std::numeric_limits<uint>::max():
case 0:
break;
case 1:
@@ -899,7 +903,7 @@ bool Resource::CreateInterop(CreateParams* params) {
break;
case 2: // YV12 format
switch (layer) {
case -1:
case std::numeric_limits<uint>::max():
case 0:
break;
case 1:
+2 -1
Переглянути файл
@@ -21,6 +21,7 @@
#pragma once
#include <queue>
#include <inttypes.h>
#include "device/pal/paldefs.hpp"
#include "device/pal/palconstbuf.hpp"
#include "device/pal/palprintf.hpp"
@@ -734,7 +735,7 @@ class VirtualGPU : public device::VirtualDevice {
inline void VirtualGPU::logVmMemory(const std::string name, const Memory* memory) {
if (PAL_EMBED_KERNEL_MD || (AMD_LOG_LEVEL >= amd::LOG_INFO)) {
char buf[256];
sprintf(buf, "%s = ptr:[%p-%p] size:[%llu] heap[%d]", name.c_str(),
sprintf(buf, "%s = ptr:[%p-%p] size:[%" PRIu64 "] heap[%d]", name.c_str(),
reinterpret_cast<void*>(memory->vmAddress()),
reinterpret_cast<void*>(memory->vmAddress() + memory->size()),
memory->iMem()->Desc().size, memory->iMem()->Desc().heaps[0]);
+1 -1
Переглянути файл
@@ -21,7 +21,6 @@
#ifndef GL_INTEROP_H_
#define GL_INTEROP_H_
#ifdef _WIN32
#define GL_RESOURCE_ATTACH_TEXTURE_AMD 0x12a000
#define GL_RESOURCE_ATTACH_FRAMEBUFFER_AMD 0x12a001
#define GL_RESOURCE_ATTACH_RENDERBUFFER_AMD 0x12a002
@@ -88,6 +87,7 @@ typedef struct GLResourceDataRec {
} GLResourceData;
#ifdef _WIN32
typedef BOOL (WINAPI* PFNWGLBEGINCLINTEROPAMD)(HGLRC hglrc, GLuint flags);
typedef BOOL (WINAPI* PFNWGLENDCLINTEROPAMD) (HGLRC hglrc, GLuint flags);
typedef BOOL (WINAPI* PFNWGLRESOURCEATTACHAMD) (HGLRC hglrc, GLvoid* resource, GLvoid* pResourceData);
+6 -5
Переглянути файл
@@ -237,6 +237,7 @@ inline void warning(const char* msg) { amd::report_warning(msg); }
#else /*CL_LOG*/
#define ClPrint(level, mask, format, ...) (void)(0)
#define ClCondPrint(level, mask, condition, format, ...) (void)(0)
#define HIPPrintDuration(level, mask, startTimeUs, format, ...) (void)(0)
#endif /*CL_LOG*/
#define ClTrace(level, mask) ClPrint(level, mask, "%s", __func__)
@@ -245,13 +246,13 @@ inline void warning(const char* msg) { amd::report_warning(msg); }
#define LogError(msg) ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, msg)
#define LogWarning(msg) ClPrint(amd::LOG_WARNING, amd::LOG_ALWAYS, msg)
#define LogPrintfDebug(format, ...) ClPrint(amd::LOG_DEBUG, amd::LOG_ALWAYS, format, __VA_ARGS__)
#define LogPrintfError(format, ...) ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, format, __VA_ARGS__)
#define LogPrintfWarning(format, ...) ClPrint(amd::LOG_WARNING, amd::LOG_ALWAYS, format, __VA_ARGS__)
#define LogPrintfInfo(format, ...) ClPrint(amd::LOG_INFO, amd::LOG_ALWAYS, format, __VA_ARGS__)
#define LogPrintfDebug(format, ...) ClPrint(amd::LOG_DEBUG, amd::LOG_ALWAYS, format, ##__VA_ARGS__)
#define LogPrintfError(format, ...) ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, format, ##__VA_ARGS__)
#define LogPrintfWarning(format, ...) ClPrint(amd::LOG_WARNING, amd::LOG_ALWAYS, format, ##__VA_ARGS__)
#define LogPrintfInfo(format, ...) ClPrint(amd::LOG_INFO, amd::LOG_ALWAYS, format, ##__VA_ARGS__)
#if (defined(DEBUG) || defined(DEV_LOG_ENABLE))
#define DevLogPrintfError(format, ...) LogPrintfError(format, __VA_ARGS__)
#define DevLogPrintfError(format, ...) LogPrintfError(format, ##__VA_ARGS__)
#define DevLogError(msg) LogError(msg)
#else
#define DevLogPrintfError(format, ...)