From 8c8d963c656d65177679d8f48d37fa140c9b9fa3 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Thu, 20 Feb 2020 18:54:58 -0500 Subject: [PATCH] Disable hip{Create/Destroy}SurfaceObject The current implementation of surd2D{read/write} directly addresses into the image buffer via the hipArray::data ptr. This is incorrect to do since we don't know the layout of the image. Also with VDI we won't have access to the underlying image buffer. Disable the surface api untill the device functions are switched to using __ockl_image_{load/store}(). Change-Id: I19a33680176812d5aad3660e9045812061a1c443 --- hipamd/vdi/hip_surface.cpp | 65 +++----------------------------------- 1 file changed, 4 insertions(+), 61 deletions(-) diff --git a/hipamd/vdi/hip_surface.cpp b/hipamd/vdi/hip_surface.cpp index 0cfa5ed8c0..5adaf418cf 100644 --- a/hipamd/vdi/hip_surface.cpp +++ b/hipamd/vdi/hip_surface.cpp @@ -23,72 +23,15 @@ #include "hip_internal.hpp" #include -namespace hip { - -static amd::Monitor surfaceLock("Guards surface objects"); - -struct hipSurface { - hipSurface(const hipResourceDesc* pResDesc): array(nullptr) - { - memcpy(&resDesc, pResDesc, sizeof(hipResourceDesc)); - } - - hipArray* array; - hipResourceDesc resDesc; -}; - -static std::unordered_map surfaceHash; - -}; - -using namespace hip; - hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, const hipResourceDesc* pResDesc) { - HIP_INIT_API(NONE, pSurfObject, pResDesc); + HIP_INIT_API(hipCreateSurfaceObject, pSurfObject, pResDesc); - hipSurface* pSurface = new hipSurface(pResDesc); - assert(pSurface != nullptr); - - switch (pResDesc->resType) { - case hipResourceTypeArray: - pSurface->array = pResDesc->res.array.array; - break; - default: - break; - } - hipSurfaceObject_t surfObj; - hipError_t err = hipMalloc(reinterpret_cast(&surfObj), sizeof(hipArray)); - if (err != hipSuccess) { - delete pSurface; - HIP_RETURN(hipErrorOutOfMemory); - } - err = hipMemcpy(reinterpret_cast(surfObj), reinterpret_cast(pResDesc->res.array.array), sizeof(hipArray), - hipMemcpyHostToDevice); - if (err != hipSuccess) { - delete pSurface; - hipFree(reinterpret_cast(surfObj)); - HIP_RETURN(err); - } - *pSurfObject = surfObj; - - amd::ScopedLock lock(surfaceLock); - surfaceHash[*pSurfObject] = pSurface; - - HIP_RETURN(hipSuccess); + HIP_RETURN(hipErrorNotSupported); } - hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) { - HIP_INIT_API(NONE, surfaceObject); + HIP_INIT_API(hipDestroySurfaceObject, surfaceObject); - amd::ScopedLock lock(surfaceLock); - hipSurface* pSurface = surfaceHash[surfaceObject]; - if (pSurface != nullptr) { - delete pSurface; - surfaceHash.erase(surfaceObject); - HIP_RETURN(hipFree(reinterpret_cast(surfaceObject))); - } - - HIP_RETURN(hipErrorInvalidValue); + HIP_RETURN(hipErrorNotSupported); }