diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp index 9ac61792d7..6cda42b368 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp @@ -1445,7 +1445,8 @@ Resource::gslMap(void** ptr, size_t* pitch, gslMapAccessType flags, gslMemObject if (cal_.cardMemory_ || cal_.tiled_) { // @todo remove const cast - result = const_cast(dev()).resMapLocal(*ptr, *pitch, resource, flags); + result = const_cast(dev()).resMapLocal(*ptr, *pitch, resource, flags, + dev().settings().enableHwDebug_); } else { result = dev().resMapRemote(*ptr, *pitch, resource, flags); @@ -1461,7 +1462,8 @@ Resource::gslUnmap(gslMemObject resource) const if (cal_.cardMemory_) { // @todo remove const cast - result = const_cast(dev()).resUnmapLocal(resource); + result = const_cast(dev()).resUnmapLocal(resource, + dev().settings().enableHwDebug_); } else { result = dev().resUnmapRemote(resource); diff --git a/projects/clr/rocclr/runtime/device/gpu/gputrap.hpp b/projects/clr/rocclr/runtime/device/gpu/gputrap.hpp index 4629905fbf..e1eed63243 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gputrap.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gputrap.hpp @@ -27,7 +27,7 @@ shader main // store all the level 2 trap handler info s_or_b32 ttmp9, ttmp9, 0x01000000 s_mov_b32 ttmp10, 0x00002000 - s_mov_b32 ttmp11, 0x18024fac + s_mov_b32 ttmp11, 0x00024fac // TMA is stored 256 (0x100) bytes before the TBA value s_sub_u32 ttmp8, ttmp8, 0x100 @@ -52,7 +52,7 @@ shader main //store all the level2 trap handler info s_or_b32 ttmp9, ttmp9, 0x00680000 s_mov_b32 ttmp10, 0x00002000 - s_mov_b32 ttmp11, 0x18024fac + s_mov_b32 ttmp11, 0x00024fac //=================================================== // backup the TMA values to be restored later @@ -122,7 +122,7 @@ static const uint32_t RuntimeTrapCode [] = { 0x0000ffff, 0x8879ff79, 0x01000000, 0xbefa03ff, 0x00002000, 0xbefb03ff, - 0x18024fac, 0x80f8ff78, + 0x00024fac, 0x80f8ff78, 0x00000100, 0xbef70300, 0xc2007900, 0xbf8c0000, 0xbeee0300, 0xc2007901, @@ -132,7 +132,7 @@ static const uint32_t RuntimeTrapCode [] = { 0x0000ffff, 0x8879ff79, 0x00680000, 0xbefa03ff, 0x00002000, 0xbefb03ff, - 0x18024fac, 0xbef6036e, + 0x00024fac, 0xbef6036e, 0xbef7036f, 0xbef30300, 0xc2007902, 0xbf8c0000, 0xbeee0300, 0xc2007903, @@ -156,7 +156,7 @@ static const uint32_t RuntimeTrapCodeVi [] = { 0x0000ffff, 0x8779ff79, 0x01000000, 0xbefa00ff, 0x00002000, 0xbefb00ff, - 0x18024fac, 0x80f8ff78, + 0x00024fac, 0x80f8ff78, 0x00000100, 0xbef70000, 0xc022003c, 0x00000000, 0xbf8c0000, 0xbeee0000, @@ -167,7 +167,7 @@ static const uint32_t RuntimeTrapCodeVi [] = { 0x0000ffff, 0x8779ff79, 0x00680000, 0xbefa00ff, 0x00002000, 0xbefb00ff, - 0x18024fac, 0xbef6006e, + 0x00024fac, 0xbef6006e, 0xbef7006f, 0xbef30000, 0xc022003c, 0x00000008, 0xbf8c0000, 0xbeee0000, diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp index e706a42c62..5b2847218a 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -560,6 +560,11 @@ VirtualGPU::create( blitSetup.disableReadBufferRect_ = true; blitSetup.disableWriteBufferRect_ = true; } + // use host blit for HW debug + if (dev().settings().enableHwDebug_) { + blitSetup.disableCopyImageToBuffer_ = true; + blitSetup.disableCopyBufferToImage_ = true; + } blitMgr_ = new KernelBlitManager(*this, blitSetup); break; } @@ -1278,7 +1283,7 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) } } } - else if ((amdImage != NULL) && (amdImage->getMipLevels() > 1) && + else if ((amdImage != NULL) && (amdImage->getMipLevels() > 1) && (!memory->isUnmapWrite())) { // Release a view for a mipmap map amdImage->release(); diff --git a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp index 10a3d7e2ee..c62312ccda 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp @@ -230,7 +230,7 @@ CALGSLDevice::open(uint32 gpuIndex, bool enableHighPerformanceState, bool report #ifdef ATI_OS_WIN m_gpuIndex = gpuIndex; m_usePerVPUAdapterModel = true; - m_PerformLazyDeviceInit = true; + m_PerformLazyDeviceInit = true; #else void * nativeHandle; gslDeviceMode deviceMode; @@ -1007,7 +1007,8 @@ bool CALGSLDevice::resMapLocal(void*& pPtr, size_t& pitch, gslMemObject mem, - gslMapAccessType flags) + gslMapAccessType flags, + bool isHwDebug) { assert(m_cs != 0); assert(mem != 0); @@ -1135,7 +1136,10 @@ CALGSLDevice::resMapLocal(void*& pPtr, pitch = static_cast(tmppitch); uint64 surfaceSize; - CopyType copy = GetCopyType(mem, memMap->mem, 0, 0, m_allowDMA, 0, surfaceSize, 0, 0); + + // avoid using CPDMA, which may cause deadlock with HW Debug + uint32 copyFlag = (isHwDebug) ? CAL_MEMCOPY_ASYNC : 0; + CopyType copy = GetCopyType(mem, memMap->mem, 0, 0, m_allowDMA, copyFlag, surfaceSize, 0, 0); switch (copy) { @@ -1161,7 +1165,7 @@ CALGSLDevice::resMapLocal(void*& pPtr, case MemMap_DMA_DRMDMA: if (flags != GSL_MAP_WRITE_ONLY) { - PerformDMACopy(mem, memMap->mem, (cmSurfFmt)format, CAL_MEMCOPY_SYNC); + PerformDMACopy(mem, memMap->mem, (cmSurfFmt)format, CAL_MEMCOPY_SYNC, isHwDebug); // // Flush then wait // @@ -1212,7 +1216,7 @@ CALGSLDevice::resMapLocal(void*& pPtr, } bool -CALGSLDevice::resUnmapLocal(gslMemObject mem) +CALGSLDevice::resUnmapLocal(gslMemObject mem, bool isHwDebug) { assert(m_cs != 0); @@ -1269,7 +1273,7 @@ CALGSLDevice::resUnmapLocal(gslMemObject mem) if (memMap->flags != GSL_MAP_READ_ONLY) { - if (PerformDMACopy(memMap->mem, mem, format, CAL_MEMCOPY_SYNC) == false) + if (PerformDMACopy(memMap->mem, mem, format, CAL_MEMCOPY_SYNC, isHwDebug) == false) { assert(0); } @@ -1366,7 +1370,7 @@ CALGSLDevice::resUnmapRemote(gslMemObject mem) const } bool -CALGSLDevice::PerformDMACopy(gslMemObject srcMem, gslMemObject destMem, cmSurfFmt format, CALuint flags) +CALGSLDevice::PerformDMACopy(gslMemObject srcMem, gslMemObject destMem, cmSurfFmt format, CALuint flags, bool isHwDebug) { assert(m_cs != 0); @@ -1383,22 +1387,27 @@ CALGSLDevice::PerformDMACopy(gslMemObject srcMem, gslMemObject destMem, cmSurfFm uint32 mode; - switch (flags) - { - case CAL_MEMCOPY_SYNC: - mode = GSL_SYNCUPLOAD_SYNC_WAIT | GSL_SYNCUPLOAD_SYNC_START; - break; + if (isHwDebug) { + mode = 0; // Cannot use any sync flag to avoid possible deadlock due to halted wave + } + else { + switch (flags) + { + case CAL_MEMCOPY_SYNC: + mode = GSL_SYNCUPLOAD_SYNC_WAIT | GSL_SYNCUPLOAD_SYNC_START; + break; - case CAL_MEMCOPY_ASYNC: - assert(0); - // - // XXX -- not currently supported so fall through - // + case CAL_MEMCOPY_ASYNC: + assert(0); + // + // XXX -- not currently supported so fall through + // - case CAL_MEMCOPY_DEFAULT: - default: - mode = GSL_SYNCUPLOAD_SYNC_START; - break; + case CAL_MEMCOPY_DEFAULT: + default: + mode = GSL_SYNCUPLOAD_SYNC_START; + break; + } } m_cs->DMACopy(srcMem, 0, destMem, 0, surfaceSize, mode, NULL); diff --git a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h index 95d5ec54ac..7aa1120cf4 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h +++ b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h @@ -57,8 +57,9 @@ public: void close(); gslMemObject resAlloc(const CALresourceDesc* desc) const; - bool resMapLocal(void*& pPtr, size_t& pitch, gslMemObject res, gslMapAccessType flags); - bool resUnmapLocal(gslMemObject res); + bool resMapLocal(void*& pPtr, size_t& pitch, gslMemObject res, gslMapAccessType flags, + bool isHwDebug = false); + bool resUnmapLocal(gslMemObject res, bool isHwDebug = false); void resFree(gslMemObject mem) const; bool resMapRemote(void*& pPtr, size_t& pitch, gslMemObject res, gslMapAccessType flags) const; @@ -197,7 +198,7 @@ private: bool initGLInteropPrivateExt(CALvoid* GLplatformContext, CALvoid* GLdeviceContext) const; bool glCanInterop(CALvoid* GLplatformContext, CALvoid* GLdeviceContext); - bool PerformDMACopy(gslMemObject srcMem, gslMemObject destMem, cmSurfFmt format, CALuint flags); + bool PerformDMACopy(gslMemObject srcMem, gslMemObject destMem, cmSurfFmt format, CALuint flags, bool isHwDebug = false); void Initialize(void); bool SetupAdapter(int32 &asic_id);