From 83eb6e766de36c305846eedf49e34b618dc6d8eb Mon Sep 17 00:00:00 2001 From: taosang2 Date: Mon, 10 Jun 2024 17:11:08 -0400 Subject: [PATCH] SWDEV-465162 - Fix some issue with image support Fix some small issues regarding image and mipmap support Change-Id: I8e64223d44f37c2dbb115cbb343441a48021ba7b [ROCm/clr commit: 1566ff7639fda1c7962b6f758aadb29deffbedad] --- projects/clr/hipamd/src/hip_memory.cpp | 2 +- projects/clr/hipamd/src/hip_texture.cpp | 19 ++++++++++++++++--- .../clr/rocclr/device/pal/palsettings.cpp | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index dcf79badb2..6e38c7e1f6 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -921,7 +921,7 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder, const std::vector& devices = context.devices(); if (!devices[0]->info().imageSupport_) { LogPrintfError("Device: 0x%x does not support image", devices[0]); - status = hipErrorInvalidValue; + status = hipErrorNotSupported; return nullptr; } diff --git a/projects/clr/hipamd/src/hip_texture.cpp b/projects/clr/hipamd/src/hip_texture.cpp index e7db6f730f..df34da0669 100644 --- a/projects/clr/hipamd/src/hip_texture.cpp +++ b/projects/clr/hipamd/src/hip_texture.cpp @@ -110,9 +110,22 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject, // If hipResourceDesc::resType is set to hipResourceTypeMipmappedArray, // hipResourceDesc::res::mipmap::mipmap must be set to a valid HIP mipmapped array handle // and hipTextureDesc::normalizedCoords must be set to true. - if ((pResDesc->resType == hipResourceTypeMipmappedArray) && - ((pResDesc->res.mipmap.mipmap == nullptr) || (pTexDesc->normalizedCoords == 0))) { - return hipErrorInvalidValue; + if (pResDesc->resType == hipResourceTypeMipmappedArray) { + bool mipMapSupport = true; + amd::Context& context = *hip::getCurrentDevice()->asContext(); + const std::vector& devices = context.devices(); + for (auto& dev : devices) { + if (!dev->settings().checkExtension(ClKhrMipMapImage)) { + mipMapSupport = false; // Now PAL-backend can support mipmap, Rocm-backend cannot. + } + } + if (mipMapSupport == false) { + LogInfo("Mipmap not supported on the device"); + return hipErrorNotSupported; + } + if (pResDesc->res.mipmap.mipmap == nullptr || pTexDesc->normalizedCoords == 0) { + return hipErrorInvalidValue; + } } // If hipResourceDesc::resType is set to hipResourceTypeLinear, diff --git a/projects/clr/rocclr/device/pal/palsettings.cpp b/projects/clr/rocclr/device/pal/palsettings.cpp index c11fe9d741..a83520cbf2 100644 --- a/projects/clr/rocclr/device/pal/palsettings.cpp +++ b/projects/clr/rocclr/device/pal/palsettings.cpp @@ -393,7 +393,7 @@ bool Settings::create(const Pal::DeviceProperties& palProp, enableExtension(ClKhrSubGroups); enableExtension(ClKhrDepthImages); - if (GPU_MIPMAP) { + if (GPU_MIPMAP && imageSupport_) { enableExtension(ClKhrMipMapImage); enableExtension(ClKhrMipMapImageWrites); }