Skip to content

Commit fec9be8

Browse files
author
Brzak, Branislav
authored
[6.4 Preview] SWDEV-508970 - Match hipBindTextureToArray negative return with Cuda (#129)
1 parent 9b2f847 commit fec9be8

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

hipamd/src/hip_texture.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
8585

8686
// Validate input params
8787
if (pTexObject == nullptr || pResDesc == nullptr || pTexDesc == nullptr) {
88-
return hipErrorInvalidValue;
88+
return hipErrorInvalidChannelDescriptor;
8989
}
9090

9191
// pResViewDesc can only be specified if the type of resource is a HIP array or a HIP mipmapped array.
9292
if ((pResViewDesc != nullptr) &&
9393
((pResDesc->resType != hipResourceTypeArray) && (pResDesc->resType != hipResourceTypeMipmappedArray))) {
94-
return hipErrorInvalidValue;
94+
return hipErrorInvalidChannelDescriptor;
9595
}
9696

9797
// If hipResourceDesc::resType is set to hipResourceTypeArray,
9898
if (pResDesc->resType == hipResourceTypeArray) {
9999
// hipResourceDesc::res::array::array must be set to a valid HIP array handle.
100100
if (pResDesc->res.array.array == nullptr) {
101-
return hipErrorInvalidValue;
101+
return hipErrorInvalidChannelDescriptor;
102102
} else if (pResDesc->res.array.array->depth > 0 &&
103103
pTexDesc->filterMode == hipFilterModeLinear &&
104104
!strncmp(info.name_, "gfx90a", strlen("gfx90a"))) {
@@ -124,7 +124,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
124124
return hipErrorNotSupported;
125125
}
126126
if (pResDesc->res.mipmap.mipmap == nullptr || pTexDesc->normalizedCoords == 0) {
127-
return hipErrorInvalidValue;
127+
return hipErrorInvalidChannelDescriptor;
128128
}
129129
}
130130

@@ -135,7 +135,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
135135
((pResDesc->res.linear.devPtr == nullptr) ||
136136
(!amd::isMultipleOf(pResDesc->res.linear.devPtr, info.imageBaseAddressAlignment_)) ||
137137
(pResDesc->res.linear.sizeInBytes >= info.imageMaxBufferSize_ * hip::getElementSize(pResDesc->res.linear.desc)))) {
138-
return hipErrorInvalidValue;
138+
return hipErrorInvalidChannelDescriptor;
139139
}
140140

141141
// If hipResourceDesc::resType is set to hipResourceTypePitch2D,
@@ -151,7 +151,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
151151
(pResDesc->res.pitch2D.height >= info.image2DMaxHeight_) ||
152152
(!amd::isMultipleOf(pResDesc->res.pitch2D.pitchInBytes, info.imagePitchAlignment_)))) {
153153
// TODO check pitch limits.
154-
return hipErrorInvalidValue;
154+
return hipErrorInvalidChannelDescriptor;
155155
}
156156

157157
// We don't program the max_ansio_ratio field in the the HW sampler SRD.
@@ -658,8 +658,16 @@ hipError_t hipBindTextureToArray(const textureReference* texref,
658658
const hipChannelFormatDesc* desc) {
659659
HIP_INIT_API(hipBindTextureToArray, texref, array, desc);
660660

661-
if ((texref == nullptr) || (array == nullptr) || (desc == nullptr)) {
662-
return hipErrorInvalidValue;
661+
if (texref == nullptr) {
662+
return hipErrorInvalidTexture;
663+
}
664+
665+
if (array == nullptr) {
666+
return hipErrorInvalidResourceHandle;
667+
}
668+
669+
if (desc == nullptr) {
670+
return hipErrorInvalidChannelDescriptor;
663671
}
664672

665673
hipDeviceptr_t refDevPtr = nullptr;

0 commit comments

Comments
 (0)