P4 to Git Change 1596634 by cpaquot@cpaquot-ocl-lc-lnx on 2018/08/21 18:07:55
SWDEV-145570 - [HIP] Implmented hipSurfaceCreate/Destroy APIs Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_surface.cpp#3 edit
This commit is contained in:
@@ -25,25 +25,62 @@ THE SOFTWARE.
|
|||||||
#include "hip_internal.hpp"
|
#include "hip_internal.hpp"
|
||||||
#include <hip/hcc_detail/hip_surface_types.h>
|
#include <hip/hcc_detail/hip_surface_types.h>
|
||||||
|
|
||||||
|
namespace hip {
|
||||||
|
|
||||||
|
static amd::Monitor surfaceLock("Guards surface objects");
|
||||||
|
|
||||||
struct hipSurface {
|
struct hipSurface {
|
||||||
hipArray* array;
|
hipSurface(const hipResourceDesc* pResDesc): array(0)
|
||||||
hipResourceDesc resDesc;
|
{
|
||||||
|
memcpy((void*)&resDesc, (void*)pResDesc, sizeof(hipResourceDesc));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipArray* array;
|
||||||
|
hipResourceDesc resDesc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::map<hipSurfaceObject_t, hipSurface*> surfaceHash;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
using namespace hip;
|
||||||
|
|
||||||
hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject,
|
hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject,
|
||||||
const hipResourceDesc* pResDesc) {
|
const hipResourceDesc* pResDesc) {
|
||||||
HIP_INIT_API(pSurfObject, pResDesc);
|
HIP_INIT_API(pSurfObject, pResDesc);
|
||||||
|
|
||||||
assert(0 && "Unimplemented");
|
hipSurface* pSurface = new hipSurface(pResDesc);
|
||||||
|
assert(pSurface != nullptr);
|
||||||
|
|
||||||
HIP_RETURN(hipErrorUnknown);
|
switch (pResDesc->resType) {
|
||||||
|
case hipResourceTypeArray:
|
||||||
|
pSurface->array = pResDesc->res.array.array;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unsigned int* surfObj;
|
||||||
|
hipMalloc((void**)&surfObj, sizeof(hipArray));
|
||||||
|
hipMemcpy(surfObj, (void*)pResDesc->res.array.array, sizeof(hipArray),
|
||||||
|
hipMemcpyHostToDevice);
|
||||||
|
*pSurfObject = (hipSurfaceObject_t)surfObj;
|
||||||
|
|
||||||
|
amd::ScopedLock lock(surfaceLock);
|
||||||
|
surfaceHash[*pSurfObject] = pSurface;
|
||||||
|
|
||||||
|
HIP_RETURN(hipSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) {
|
hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) {
|
||||||
HIP_INIT_API(surfaceObject);
|
HIP_INIT_API(surfaceObject);
|
||||||
|
|
||||||
assert(0 && "Unimplemented");
|
amd::ScopedLock lock(surfaceLock);
|
||||||
|
hipSurface* pSurface = surfaceHash[surfaceObject];
|
||||||
|
if (pSurface != nullptr) {
|
||||||
|
delete pSurface;
|
||||||
|
surfaceHash.erase(surfaceObject);
|
||||||
|
}
|
||||||
|
|
||||||
HIP_RETURN(hipErrorUnknown);
|
HIP_RETURN(hipSuccess);
|
||||||
}
|
}
|
||||||
|
|||||||
Verwijs in nieuw issue
Block a user