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


[ROCm/hip commit: e7f389f030]
This commit is contained in:
Vladislav Sytchenko
2020-02-20 18:54:58 -05:00
committed by Vladislav Sytchenko
parent 6b9e891c1e
commit 26f6f3ad25
+4 -61
View File
@@ -23,72 +23,15 @@
#include "hip_internal.hpp"
#include <hip/hcc_detail/hip_surface_types.h>
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<hipSurfaceObject_t, hipSurface*> 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<void**>(&surfObj), sizeof(hipArray));
if (err != hipSuccess) {
delete pSurface;
HIP_RETURN(hipErrorOutOfMemory);
}
err = hipMemcpy(reinterpret_cast<void*>(surfObj), reinterpret_cast<void*>(pResDesc->res.array.array), sizeof(hipArray),
hipMemcpyHostToDevice);
if (err != hipSuccess) {
delete pSurface;
hipFree(reinterpret_cast<void*>(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<void*>(surfaceObject)));
}
HIP_RETURN(hipErrorInvalidValue);
HIP_RETURN(hipErrorNotSupported);
}