SWDEV-555889 - Support mipmap on rocr (#2082)

* SWDEV-555889 - Support mipmap on rocr

Support mipmap in hip-rt on rocr backend.
Enable all mipmap tests in Windows.
Some other minor improvement.

Add some SRD logs that will be removed finally.

* Add sampler.mipFilter to fix sampler issues on mipmap in rocr.
Fix format issues of view of leveled image and  mipmap image in blit kernel in rocr.
Enabled disabled mipmap tests.

* Rewrite view logic

* Set word4.f.PITCH = 0 for mipmap SRD on navi31 to fix unstable test issues.
Reset last error in nagative tests.

* Remove SRD dump log from hip-rt
Let Rocr mipmap log be in condition.

* minor format chang

* Exclude mipmap tests for mi200+ which don't support mipmap.
This commit is contained in:
Tao Sang
2026-01-21 12:10:29 -05:00
committed by GitHub
parent 5daeb14582
commit 163e44d0a8
29 changed files with 224 additions and 142 deletions
@@ -771,8 +771,6 @@ hsa_status_t ImageRuntime::CreateMipmapArrayHandle(
mipmap_array->tile_mode = Image::TileMode::TILED;
}
debug_print("Tile mode = %u (0: LINEAR, 1: TILED)", mipmap_array->tile_mode);
// Initialize the mipmapped array object
mipmap_array->component = component;
mipmap_array->data = const_cast<void*>(image_data);
@@ -782,15 +780,18 @@ hsa_status_t ImageRuntime::CreateMipmapArrayHandle(
mipmap_array->flags = 0;
manager->PopulateMipmapSrd(*mipmap_array);
debug_print("Populating mipmapped array SRD...");
if (core::Runtime::runtime_singleton_->flag().image_print_srd())
mipmap_array->printSRD();
manager->printSRDDetailed(mipmap_array->srd);
// assert(mipmap_array->size == required_size);
image_handle.handle = mipmap_array->Convert();
debug_print("output handle = %lu", image_handle.handle);
if (core::Runtime::runtime_singleton_->flag().image_print_srd()) {
debug_print("Tile mode = %u (0: LINEAR, 1: TILED)", mipmap_array->tile_mode);
debug_print("Populating mipmapped array SRD...");
mipmap_array->printSRD();
manager->printSRDDetailed(mipmap_array->srd);
debug_print("output handle = %lu", image_handle.handle);
}
return HSA_STATUS_SUCCESS;
}
@@ -809,7 +810,12 @@ hsa_status_t ImageRuntime::DestroyMipmapArrayHandle(
hsa_status_t ImageRuntime::GetMipmapArrayLevelHandle(
hsa_agent_t component, const hsa_ext_image_t& mipmapped_array,
uint32_t mip_level, hsa_ext_image_t& level_image_out) {
uint32_t mip_level, const hsa_ext_image_descriptor_v2_t* image_descriptor,
hsa_ext_image_t& level_image_out) {
ImageManager * manager = image_manager(component);
if (!manager) {
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
}
level_image_out.handle = 0;
@@ -837,35 +843,42 @@ hsa_status_t ImageRuntime::GetMipmapArrayLevelHandle(
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
debug_print("Creating mip level %u view for %u level mipmap\n",
if (core::Runtime::runtime_singleton_->flag().image_print_srd()) {
debug_print("Creating mip level %u view for %u level mipmap\n",
mip_level, array->num_levels);
}
// Create a view that references the parent mipmap array
MipmappedArray* level_view = MipmappedArray::Create(component);
if (!level_view) return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
// Copy entire parent structure (srd is a fixed array, so it's deep-copied automatically)
*level_view = *array;
// Modify SRD to select only the specific mip level
ImageManager* manager = image_manager(component);
if (!manager) {
MipmappedArray::Destroy(level_view);
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
auto format = image_descriptor ? &image_descriptor->format : nullptr;
if (format &&
(array->desc.format.channel_type != format->channel_type ||
array->desc.format.channel_order != format->channel_order)) {
MipmappedArray tempArray = *array;
tempArray.desc.format.channel_type = format->channel_type;
tempArray.desc.format.channel_order = format->channel_order;
status = manager->PopulateMipmapSrd(tempArray);
if (status == HSA_STATUS_SUCCESS) {
status = manager->PopulateMipLevelSrd(*level_view, tempArray, mip_level);
}
else {
debug_print("PopulateMipmapSrd() failed with status %d", status);
}
}
else {
status = manager->PopulateMipLevelSrd(*level_view, *array, mip_level);
}
status = manager->PopulateMipLevelSrd(*level_view, *array, mip_level);
if (status != HSA_STATUS_SUCCESS) {
MipmappedArray::Destroy(level_view);
return status;
}
debug_print("Created mip level view using SRD fields");
if (core::Runtime::runtime_singleton_->flag().image_print_srd())
if (core::Runtime::runtime_singleton_->flag().image_print_srd()) {
level_view->printSRD();
manager->printSRDDetailed(level_view->srd);
manager->printSRDDetailed(level_view->srd);
}
// Return handle
level_image_out.handle = level_view->Convert();
return HSA_STATUS_SUCCESS;