Texture code reorganized
This commit is contained in:
@@ -2175,10 +2175,7 @@ hipError_t ihipBindTextureImpl(int dim,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t size,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject);
|
||||
textureReference* tex);
|
||||
|
||||
/*
|
||||
* @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex.
|
||||
@@ -2200,9 +2197,7 @@ hipError_t hipBindTexture(size_t *offset,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t size = UINT_MAX)
|
||||
{
|
||||
return ihipBindTextureImpl(dim, readMode, offset, devPtr, desc, size,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
return ihipBindTextureImpl(dim, readMode, offset, devPtr, desc, size, &tex);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2223,9 +2218,7 @@ hipError_t hipBindTexture(size_t *offset,
|
||||
const void *devPtr,
|
||||
size_t size = UINT_MAX)
|
||||
{
|
||||
return ihipBindTextureImpl(dim, readMode, offset, devPtr, tex.channelDesc, size,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
return ihipBindTextureImpl(dim, readMode, offset, devPtr, tex.channelDesc, size, &tex);
|
||||
}
|
||||
|
||||
// C API
|
||||
@@ -2244,10 +2237,7 @@ hipError_t ihipBindTexture2DImpl(int dim,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject);
|
||||
textureReference* tex);
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture2D(size_t *offset,
|
||||
@@ -2257,9 +2247,7 @@ hipError_t hipBindTexture2D(size_t *offset,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, tex.channelDesc, width, height,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, tex.channelDesc, width, height, &tex);
|
||||
}
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
@@ -2271,9 +2259,7 @@ hipError_t hipBindTexture2D(size_t *offset,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, desc, width, height,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, desc, width, height, &tex);
|
||||
}
|
||||
|
||||
//C API
|
||||
@@ -2285,18 +2271,13 @@ hipError_t ihipBindTextureToArrayImpl(int dim,
|
||||
enum hipTextureReadMode readMode,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject);
|
||||
textureReference* tex);
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex,
|
||||
hipArray_const_t array)
|
||||
{
|
||||
return ihipBindTextureToArrayImpl(dim, readMode, array, tex.channelDesc,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
return ihipBindTextureToArrayImpl(dim, readMode, array, tex.channelDesc, &tex);
|
||||
}
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
@@ -2304,9 +2285,7 @@ hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc)
|
||||
{
|
||||
return ihipBindTextureToArrayImpl(dim, readMode, array, desc,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
return ihipBindTextureToArrayImpl(dim, readMode, array, desc, &tex);
|
||||
}
|
||||
|
||||
//C API
|
||||
|
||||
@@ -210,8 +210,6 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
const hipResourceViewDesc* pResViewDesc)
|
||||
{
|
||||
HIP_INIT_API(pTexObject, pResDesc, pTexDesc, pResViewDesc);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
@@ -313,7 +311,6 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject)
|
||||
{
|
||||
HIP_INIT_API(textureObject);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
@@ -338,8 +335,6 @@ hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject)
|
||||
hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc, hipTextureObject_t textureObject)
|
||||
{
|
||||
HIP_INIT_API(pResDesc, textureObject);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
@@ -355,8 +350,6 @@ hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc, hipTexture
|
||||
hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc, hipTextureObject_t textureObject)
|
||||
{
|
||||
HIP_INIT_API(pResViewDesc, textureObject);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
@@ -372,7 +365,6 @@ hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc
|
||||
hipError_t hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc, hipTextureObject_t textureObject)
|
||||
{
|
||||
HIP_INIT_API(pTexDesc, textureObject);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
@@ -392,17 +384,13 @@ hipError_t ihipBindTextureImpl(int dim,
|
||||
size_t *offset,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t size,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject)
|
||||
size_t size, textureReference* tex )
|
||||
{
|
||||
HIP_INIT_API();
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
enum hipTextureAddressMode addressMode = tex->addressMode[0];
|
||||
enum hipTextureFilterMode filterMode = tex->filterMode;
|
||||
int normalizedCoords = tex->normalized;
|
||||
hipTextureObject_t& textureObject = tex->textureObject;
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
if (ctx) {
|
||||
hc::accelerator acc = ctx->getDevice()->_acc;
|
||||
@@ -438,13 +426,13 @@ hipError_t ihipBindTextureImpl(int dim,
|
||||
|
||||
if (HSA_STATUS_SUCCESS != hsa_ext_image_create_with_layout(*agent, &imageDescriptor, devPtr, permission, HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR, 0, 0, &(pTexture->image)) ||
|
||||
HSA_STATUS_SUCCESS != hsa_ext_sampler_create(*agent, &samplerDescriptor, &(pTexture->sampler))) {
|
||||
return ihipLogStatus(hipErrorRuntimeOther);
|
||||
return hipErrorRuntimeOther;
|
||||
}
|
||||
getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler);
|
||||
textureHash[textureObject] = pTexture;
|
||||
}
|
||||
|
||||
return ihipLogStatus(hip_status);
|
||||
return hip_status;
|
||||
}
|
||||
|
||||
hipError_t hipBindTexture(size_t* offset,
|
||||
@@ -453,11 +441,12 @@ hipError_t hipBindTexture(size_t* offset,
|
||||
const hipChannelFormatDesc* desc,
|
||||
size_t size)
|
||||
{
|
||||
HIP_INIT_API(offset, tex, devPtr, desc, size);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
// TODO: hipReadModeElementType is default.
|
||||
return ihipBindTextureImpl(hipTextureType1D, hipReadModeElementType,
|
||||
offset, devPtr, *desc, size,
|
||||
tex->addressMode[0], tex->filterMode, tex->normalized,
|
||||
tex->textureObject);
|
||||
hip_status = ihipBindTextureImpl(hipTextureType1D, hipReadModeElementType,
|
||||
offset, devPtr, *desc, size, tex);
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t ihipBindTexture2DImpl(int dim,
|
||||
@@ -467,16 +456,13 @@ hipError_t ihipBindTexture2DImpl(int dim,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject)
|
||||
textureReference* tex)
|
||||
{
|
||||
HIP_INIT_API();
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
enum hipTextureAddressMode addressMode = tex->addressMode[0];
|
||||
enum hipTextureFilterMode filterMode = tex->filterMode;
|
||||
int normalizedCoords = tex->normalized;
|
||||
hipTextureObject_t& textureObject = tex->textureObject;
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
if (ctx) {
|
||||
hc::accelerator acc = ctx->getDevice()->_acc;
|
||||
@@ -512,13 +498,13 @@ hipError_t ihipBindTexture2DImpl(int dim,
|
||||
|
||||
if (HSA_STATUS_SUCCESS != hsa_ext_image_create_with_layout(*agent, &imageDescriptor, devPtr, permission, HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR, 0, 0, &(pTexture->image)) ||
|
||||
HSA_STATUS_SUCCESS != hsa_ext_sampler_create(*agent, &samplerDescriptor, &(pTexture->sampler))) {
|
||||
return ihipLogStatus(hipErrorRuntimeOther);
|
||||
return hipErrorRuntimeOther;
|
||||
}
|
||||
getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler);
|
||||
textureHash[textureObject] = pTexture;
|
||||
}
|
||||
|
||||
return ihipLogStatus(hip_status);
|
||||
return hip_status;
|
||||
}
|
||||
|
||||
hipError_t hipBindTexture2D(size_t* offset,
|
||||
@@ -529,27 +515,24 @@ hipError_t hipBindTexture2D(size_t* offset,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
// TODO: hipReadModeElementType is default.
|
||||
return ihipBindTexture2DImpl(hipTextureType2D, hipReadModeElementType,
|
||||
offset, devPtr, *desc, width, height,
|
||||
tex->addressMode[0], tex->filterMode, tex->normalized,
|
||||
tex->textureObject);
|
||||
HIP_INIT_API(offset, tex, devPtr, desc, width, height, pitch);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
hip_status = ihipBindTexture2DImpl(hipTextureType2D, hipReadModeElementType,
|
||||
offset, devPtr, *desc, width, height, tex);
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t ihipBindTextureToArrayImpl(int dim,
|
||||
enum hipTextureReadMode readMode,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject)
|
||||
textureReference* tex)
|
||||
{
|
||||
HIP_INIT_API();
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
enum hipTextureAddressMode addressMode = tex->addressMode[0];
|
||||
enum hipTextureFilterMode filterMode = tex->filterMode;
|
||||
int normalizedCoords = tex->normalized;
|
||||
hipTextureObject_t& textureObject = tex->textureObject;
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
if (ctx) {
|
||||
hc::accelerator acc = ctx->getDevice()->_acc;
|
||||
@@ -615,38 +598,38 @@ hipError_t ihipBindTextureToArrayImpl(int dim,
|
||||
|
||||
if (HSA_STATUS_SUCCESS != hsa_ext_image_create_with_layout(*agent, &imageDescriptor, array->data, permission, HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR, 0, 0, &(pTexture->image)) ||
|
||||
HSA_STATUS_SUCCESS != hsa_ext_sampler_create(*agent, &samplerDescriptor, &(pTexture->sampler))) {
|
||||
return ihipLogStatus(hipErrorRuntimeOther);
|
||||
return hipErrorRuntimeOther;
|
||||
}
|
||||
getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler);
|
||||
textureHash[textureObject] = pTexture;
|
||||
}
|
||||
|
||||
return ihipLogStatus(hip_status);
|
||||
return hip_status;
|
||||
}
|
||||
|
||||
hipError_t hipBindTextureToArray(textureReference* tex,
|
||||
hipArray_const_t array,
|
||||
const hipChannelFormatDesc* desc)
|
||||
{
|
||||
HIP_INIT_API(tex, array, desc);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
// TODO: hipReadModeElementType is default.
|
||||
return ihipBindTextureToArrayImpl(hipTextureType2D, hipReadModeElementType,
|
||||
array, *desc,
|
||||
tex->addressMode[0], tex->filterMode, tex->normalized,
|
||||
tex->textureObject);
|
||||
hip_status = ihipBindTextureToArrayImpl(hipTextureType2D, hipReadModeElementType,
|
||||
array, *desc, tex);
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t hipBindTextureToMipmappedArray(textureReference* tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const hipChannelFormatDesc* desc)
|
||||
{
|
||||
return hipSuccess;
|
||||
HIP_INIT_API(tex, mipmappedArray, desc);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject)
|
||||
{
|
||||
HIP_INIT_API();
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
@@ -665,19 +648,20 @@ hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject)
|
||||
}
|
||||
}
|
||||
|
||||
return ihipLogStatus(hip_status);
|
||||
return hip_status;
|
||||
}
|
||||
|
||||
hipError_t hipUnbindTexture(const textureReference* tex)
|
||||
{
|
||||
return ihipUnbindTextureImpl(tex->textureObject);
|
||||
HIP_INIT_API(tex);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
hip_status = ihipUnbindTextureImpl(tex->textureObject);
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array)
|
||||
{
|
||||
HIP_INIT_API(desc, array);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
@@ -690,7 +674,6 @@ hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array)
|
||||
hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* tex)
|
||||
{
|
||||
HIP_INIT_API(offset, tex);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
@@ -703,7 +686,6 @@ hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference*
|
||||
hipError_t hipGetTextureReference(const textureReference** tex, const void* symbol)
|
||||
{
|
||||
HIP_INIT_API(tex, symbol);
|
||||
HIP_SET_DEVICE();
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
@@ -751,8 +733,7 @@ hipError_t hipTexRefSetArray ( textureReference* tex, hipArray_const_t array, u
|
||||
HIP_INIT_API(tex, array, flags);
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
return ihipBindTextureToArrayImpl(hipTextureType2D, hipReadModeElementType,
|
||||
array, array->desc,/* channelOrder, channelType,*/
|
||||
tex->addressMode[0], tex->filterMode, tex->normalized,
|
||||
tex->textureObject);
|
||||
}
|
||||
hip_status = ihipBindTextureToArrayImpl(hipTextureType2D, hipReadModeElementType,
|
||||
array, array->desc,tex );
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
مرجع در شماره جدید
Block a user