200~SWDEV-333583 : hipMallocArray bad channel format
- channel format should be consistent accross parameters
Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Change-Id: I1e7680ab9262a66e7bea4aaa21f061044b0f7956
[ROCm/clr commit: 8ed471f210]
This commit is contained in:
@@ -300,6 +300,24 @@ unsigned int getNumChannels(const hipChannelFormatDesc& desc) {
|
||||
return ((desc.x != 0) + (desc.y != 0) + (desc.z != 0) + (desc.w != 0));
|
||||
}
|
||||
|
||||
inline
|
||||
bool CheckArrayFormat(const hipChannelFormatDesc& desc) {
|
||||
if(desc.x == 0) {
|
||||
return false;
|
||||
} else {
|
||||
if(desc.y != 0 && desc.y != desc.x) {
|
||||
return false;
|
||||
}
|
||||
if(desc.z !=0 && desc.z != desc.x) {
|
||||
return false;
|
||||
}
|
||||
if(desc.w !=0 && desc.w != desc.x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
hipArray_Format getArrayFormat(const hipChannelFormatDesc& desc) {
|
||||
switch (desc.f) {
|
||||
|
||||
@@ -954,7 +954,9 @@ hipError_t hipMallocArray(hipArray** array,
|
||||
hip::getArrayFormat(*desc),
|
||||
hip::getNumChannels(*desc),
|
||||
flags};
|
||||
|
||||
if(!hip::CheckArrayFormat(*desc)) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
HIP_RETURN(ihipArrayCreate(array, &allocateArray, 0 /* numMipLevels */));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user