Add texref get APIs support (#1471)
Added support for -
hipTexRefGetArray
hipTexRefGetAddressMode
hipTexRefGetAddress
This commit is contained in:
zatwierdzone przez
Maneesh Gupta
rodzic
58a476abc2
commit
bec725dec2
@@ -437,6 +437,7 @@ hipError_t ihipBindTextureImpl(TlsData *tls_, int dim, enum hipTextureReadMode r
|
||||
return hipErrorRuntimeOther;
|
||||
}
|
||||
getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler);
|
||||
pTexture->devPtr = (void*) devPtr;
|
||||
textureHash[textureObject] = pTexture;
|
||||
}
|
||||
|
||||
@@ -509,6 +510,7 @@ hipError_t ihipBindTexture2DImpl(TlsData *tls, int dim, enum hipTextureReadMode
|
||||
return hipErrorRuntimeOther;
|
||||
}
|
||||
getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler);
|
||||
pTexture->devPtr = (void*) devPtr;
|
||||
textureHash[textureObject] = pTexture;
|
||||
}
|
||||
|
||||
@@ -607,6 +609,7 @@ hipError_t ihipBindTextureToArrayImpl(TlsData *tls_, int dim, enum hipTextureRea
|
||||
return hipErrorRuntimeOther;
|
||||
}
|
||||
getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler);
|
||||
pTexture->devPtr = (void*) array;
|
||||
textureHash[textureObject] = pTexture;
|
||||
}
|
||||
|
||||
@@ -724,6 +727,17 @@ hipError_t hipTexRefSetAddressMode(textureReference* tex, int dim, hipTextureAdd
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t hipTexRefGetAddressMode(hipTextureAddressMode* am, textureReference tex, int dim) {
|
||||
HIP_INIT_API(hipTexRefGetAddressMode,am, &tex, dim);
|
||||
|
||||
if ((am == nullptr) || (dim >= 3))
|
||||
return ihipLogStatus(hipErrorInvalidValue);
|
||||
|
||||
*am = tex.addressMode[dim];
|
||||
|
||||
return ihipLogStatus(hipSuccess);
|
||||
}
|
||||
|
||||
hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsigned int flags) {
|
||||
HIP_INIT_API(hipTexRefSetArray, tex, array, flags);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
@@ -733,6 +747,23 @@ hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsi
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t hipTexRefGetArray(hipArray_t* array, textureReference tex) {
|
||||
HIP_INIT_API(hipTexRefGetArray, array, &tex);
|
||||
|
||||
if (array == nullptr)
|
||||
return ihipLogStatus(hipErrorInvalidValue);
|
||||
|
||||
hipTexture* pTexture = textureHash[tex.textureObject];
|
||||
if((pTexture == nullptr) || (hipResourceTypeArray != pTexture->resDesc.resType))
|
||||
return ihipLogStatus(hipErrorInvalidImage);
|
||||
|
||||
if (pTexture->devPtr == nullptr)
|
||||
return ihipLogStatus(hipErrorUnknown);
|
||||
|
||||
*array = reinterpret_cast<hipArray_t>(pTexture->devPtr);
|
||||
|
||||
return ihipLogStatus(hipSuccess);
|
||||
}
|
||||
|
||||
hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDeviceptr_t devPtr,
|
||||
size_t size) {
|
||||
@@ -744,6 +775,23 @@ hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDevicep
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t hipTexRefGetAddress(hipDeviceptr_t* dev_ptr, textureReference tex) {
|
||||
HIP_INIT_API(hipTexRefGetAddress,dev_ptr, &tex);
|
||||
|
||||
if (dev_ptr == nullptr)
|
||||
return ihipLogStatus(hipErrorInvalidValue);
|
||||
|
||||
hipTexture* pTexture = textureHash[tex.textureObject];
|
||||
if (pTexture == nullptr)
|
||||
return ihipLogStatus(hipErrorInvalidImage);
|
||||
|
||||
if (pTexture->devPtr == nullptr)
|
||||
return ihipLogStatus(hipErrorUnknown);
|
||||
|
||||
*dev_ptr = reinterpret_cast<hipDeviceptr_t>(pTexture->devPtr);
|
||||
return ihipLogStatus(hipSuccess);
|
||||
}
|
||||
|
||||
hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPTOR* desc,
|
||||
hipDeviceptr_t devPtr, size_t pitch) {
|
||||
HIP_INIT_API(hipTexRefSetAddress2D, tex, desc, devPtr, pitch);
|
||||
|
||||
@@ -31,6 +31,7 @@ struct hipTexture {
|
||||
hipResourceViewDesc resViewDesc;
|
||||
hsa_ext_image_t image;
|
||||
hsa_ext_sampler_t sampler;
|
||||
void* devPtr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user