mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Revert "fix: store image implicit args in bindless slot 1"
This reverts commit b6d572ddb8.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3c722537dc
commit
f2c9d7172a
@@ -513,26 +513,18 @@ ze_result_t ContextImp::evictMemory(ze_device_handle_t hDevice, void *ptr, size_
|
||||
|
||||
ze_result_t ContextImp::makeImageResident(ze_device_handle_t hDevice, ze_image_handle_t hImage) {
|
||||
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
||||
auto implicitArgsAlloc = Image::fromHandle(hImage)->getImplicitArgsAllocation();
|
||||
|
||||
NEO::Device *neoDevice = L0::Device::fromHandle(hDevice)->getNEODevice();
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto success = memoryOperationsIface->makeResident(neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
||||
if (implicitArgsAlloc) {
|
||||
memoryOperationsIface->makeResident(neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&implicitArgsAlloc, 1));
|
||||
}
|
||||
return changeMemoryOperationStatusToL0ResultType(success);
|
||||
}
|
||||
ze_result_t ContextImp::evictImage(ze_device_handle_t hDevice, ze_image_handle_t hImage) {
|
||||
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
||||
auto implicitArgsAlloc = Image::fromHandle(hImage)->getImplicitArgsAllocation();
|
||||
|
||||
NEO::Device *neoDevice = L0::Device::fromHandle(hDevice)->getNEODevice();
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto success = memoryOperationsIface->evict(neoDevice, *alloc);
|
||||
if (implicitArgsAlloc) {
|
||||
memoryOperationsIface->evict(neoDevice, *implicitArgsAlloc);
|
||||
}
|
||||
return changeMemoryOperationStatusToL0ResultType(success);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,10 @@ struct Image : _ze_image_handle_t {
|
||||
virtual ze_result_t createView(Device *device, const ze_image_desc_t *desc, ze_image_handle_t *pImage) = 0;
|
||||
|
||||
virtual NEO::GraphicsAllocation *getAllocation() = 0;
|
||||
virtual NEO::GraphicsAllocation *getImplicitArgsAllocation() = 0;
|
||||
virtual void copySurfaceStateToSSH(void *surfaceStateHeap,
|
||||
const uint32_t surfaceStateOffset,
|
||||
bool isMediaBlockArg) = 0;
|
||||
virtual void copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) = 0;
|
||||
virtual void copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) = 0;
|
||||
virtual NEO::ImageInfo getImageInfo() = 0;
|
||||
virtual ze_image_desc_t getImageDesc() = 0;
|
||||
virtual ze_result_t getMemoryProperties(ze_image_memory_properties_exp_t *pMemoryProperties) = 0;
|
||||
|
||||
@@ -22,7 +22,6 @@ struct ImageCoreFamily : public ImageImp {
|
||||
ze_result_t initialize(Device *device, const ze_image_desc_t *desc) override;
|
||||
void copySurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset, bool isMediaBlockArg) override;
|
||||
void copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override;
|
||||
void copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override;
|
||||
bool isMediaFormat(const ze_image_format_layout_t layout) {
|
||||
if (layout == ze_image_format_layout_t::ZE_IMAGE_FORMAT_LAYOUT_NV12 ||
|
||||
layout == ze_image_format_layout_t::ZE_IMAGE_FORMAT_LAYOUT_P010 ||
|
||||
@@ -50,7 +49,6 @@ struct ImageCoreFamily : public ImageImp {
|
||||
bool isSuitableForCompression(const StructuresLookupTable &structuresLookupTable, const NEO::ImageInfo &imgInfo);
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState;
|
||||
RENDER_SURFACE_STATE implicitArgsSurfaceState;
|
||||
RENDER_SURFACE_STATE redescribedSurfaceState;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,33 +11,24 @@
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/helpers/surface_format_info.h"
|
||||
#include "shared/source/image/image_surface_state.h"
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/release_helper/release_helper.h"
|
||||
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h"
|
||||
#include "level_zero/core/source/helpers/properties_parser.h"
|
||||
#include "level_zero/core/source/image/image_format_desc_helper.h"
|
||||
#include "level_zero/core/source/image/image_formats.h"
|
||||
#include "level_zero/core/source/image/image_hw.h"
|
||||
|
||||
#include "encode_surface_state_args.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_image_desc_t *desc) {
|
||||
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
|
||||
|
||||
const auto &rootDeviceEnvironment = device->getNEODevice()->getRootDeviceEnvironment();
|
||||
const bool isBindlessMode = rootDeviceEnvironment.getReleaseHelper() ? NEO::ApiSpecificConfig::getBindlessMode(rootDeviceEnvironment.getReleaseHelper()) : false;
|
||||
|
||||
StructuresLookupTable lookupTable = {};
|
||||
|
||||
lookupTable.areImageProperties = true;
|
||||
@@ -113,13 +104,8 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
|
||||
}
|
||||
}
|
||||
|
||||
if (isBindlessMode) {
|
||||
NEO::AllocationProperties imgImplicitArgsAllocProperties(device->getRootDeviceIndex(), NEO::ImageImplicitArgs::getSize(), NEO::AllocationType::buffer, device->getNEODevice()->getDeviceBitfield());
|
||||
implicitArgsAllocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(imgImplicitArgsAllocProperties);
|
||||
}
|
||||
|
||||
auto gmm = this->allocation->getDefaultGmm();
|
||||
auto gmmHelper = static_cast<const NEO::RootDeviceEnvironment &>(rootDeviceEnvironment).getGmmHelper();
|
||||
auto gmmHelper = static_cast<const NEO::RootDeviceEnvironment &>(device->getNEODevice()->getRootDeviceEnvironment()).getGmmHelper();
|
||||
|
||||
if (gmm != nullptr) {
|
||||
NEO::ImagePlane yuvPlaneType = NEO::ImagePlane::noPlane;
|
||||
@@ -171,53 +157,6 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
|
||||
NEO::EncodeSurfaceState<GfxFamily>::setImageAuxParamsForCCS(&surfaceState, gmm);
|
||||
}
|
||||
}
|
||||
|
||||
if (isBindlessMode && implicitArgsAllocation) {
|
||||
implicitArgsSurfaceState = GfxFamily::cmdInitRenderSurfaceState;
|
||||
|
||||
auto clChannelType = getClChannelDataType(imageFormatDesc.format);
|
||||
auto clChannelOrder = getClChannelOrder(imageFormatDesc.format);
|
||||
|
||||
NEO::ImageImplicitArgs imageImplicitArgs{};
|
||||
imageImplicitArgs.structVersion = 0;
|
||||
|
||||
imageImplicitArgs.imageWidth = imgInfo.imgDesc.imageWidth;
|
||||
imageImplicitArgs.imageHeight = imgInfo.imgDesc.imageHeight;
|
||||
imageImplicitArgs.imageDepth = imgInfo.imgDesc.imageDepth;
|
||||
imageImplicitArgs.imageArraySize = imgInfo.imgDesc.imageArraySize;
|
||||
imageImplicitArgs.numSamples = imgInfo.imgDesc.numSamples;
|
||||
imageImplicitArgs.channelType = clChannelType;
|
||||
imageImplicitArgs.channelOrder = clChannelOrder;
|
||||
imageImplicitArgs.numMipLevels = imgInfo.imgDesc.numMipLevels;
|
||||
|
||||
auto pixelSize = imgInfo.surfaceFormat->imageElementSizeInBytes;
|
||||
imageImplicitArgs.flatBaseOffset = implicitArgsAllocation->getGpuAddress();
|
||||
imageImplicitArgs.flatWidth = (imgInfo.imgDesc.imageWidth * pixelSize) - 1u;
|
||||
imageImplicitArgs.flagHeight = (imgInfo.imgDesc.imageHeight * pixelSize) - 1u;
|
||||
imageImplicitArgs.flatPitch = imgInfo.imgDesc.imageRowPitch - 1u;
|
||||
|
||||
const auto &productHelper = rootDeviceEnvironment.getHelper<NEO::ProductHelper>();
|
||||
NEO::MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *implicitArgsAllocation), *this->device->getNEODevice(), implicitArgsAllocation, 0u, &imageImplicitArgs, NEO::ImageImplicitArgs::getSize());
|
||||
|
||||
{
|
||||
auto &gfxCoreHelper = this->device->getGfxCoreHelper();
|
||||
|
||||
NEO::EncodeSurfaceStateArgs args;
|
||||
args.outMemory = &implicitArgsSurfaceState;
|
||||
args.size = NEO::ImageImplicitArgs::getSize();
|
||||
args.graphicsAddress = implicitArgsAllocation->getGpuAddress();
|
||||
args.gmmHelper = gmmHelper;
|
||||
args.allocation = implicitArgsAllocation;
|
||||
args.numAvailableDevices = this->device->getNEODevice()->getNumGenericSubDevices();
|
||||
args.areMultipleSubDevicesInContext = args.numAvailableDevices > 1;
|
||||
args.mocs = gfxCoreHelper.getMocsIndex(*args.gmmHelper, true, false) << 1;
|
||||
args.implicitScaling = this->device->isImplicitScalingCapable();
|
||||
args.isDebuggerActive = this->device->getNEODevice()->getDebugger() != nullptr;
|
||||
|
||||
gfxCoreHelper.encodeBufferSurfaceState(args);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const uint32_t exponent = Math::log2(imgInfo.surfaceFormat->imageElementSizeInBytes);
|
||||
DEBUG_BREAK_IF(exponent >= 5u);
|
||||
@@ -293,18 +232,6 @@ void ImageCoreFamily<gfxCoreFamily>::copyRedescribedSurfaceStateToSSH(void *surf
|
||||
&redescribedSurfaceState, sizeof(RENDER_SURFACE_STATE));
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void ImageCoreFamily<gfxCoreFamily>::copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap,
|
||||
const uint32_t surfaceStateOffset) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
|
||||
|
||||
// Copy the image's surface state into position in the provided surface state heap
|
||||
auto destSurfaceState = ptrOffset(surfaceStateHeap, surfaceStateOffset);
|
||||
memcpy_s(destSurfaceState, sizeof(RENDER_SURFACE_STATE),
|
||||
&implicitArgsSurfaceState, sizeof(RENDER_SURFACE_STATE));
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
bool ImageCoreFamily<gfxCoreFamily>::isSuitableForCompression(const StructuresLookupTable &structuresLookupTable, const NEO::ImageInfo &imgInfo) {
|
||||
auto &hwInfo = device->getHwInfo();
|
||||
|
||||
@@ -31,13 +31,8 @@ ImageImp::~ImageImp() {
|
||||
this->device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[this->allocation->getRootDeviceIndex()]->getBindlessHeapsHelper()->releaseSSToReusePool(*bindlessInfo);
|
||||
}
|
||||
}
|
||||
if (this->device != nullptr) {
|
||||
if (!isImageView()) {
|
||||
this->device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(this->allocation);
|
||||
}
|
||||
if (implicitArgsAllocation) {
|
||||
this->device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(this->implicitArgsAllocation);
|
||||
}
|
||||
if (!isImageView() && this->device != nullptr) {
|
||||
this->device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(this->allocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +100,7 @@ ze_result_t ImageImp::allocateBindlessSlot() {
|
||||
|
||||
if (bindlessHelper && !bindlessInfo) {
|
||||
auto &gfxCoreHelper = this->device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getHelper<NEO::GfxCoreHelper>();
|
||||
const auto surfStateCount = 3;
|
||||
const auto surfStateCount = 2;
|
||||
auto surfaceStateSize = surfStateCount * gfxCoreHelper.getRenderSurfaceStateSize();
|
||||
|
||||
auto surfaceStateInfo = bindlessHelper->allocateSSInHeap(surfaceStateSize, allocation, NEO::BindlessHeapsHelper::globalSsh);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
#include "shared/source/helpers/surface_format_info.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
#include "level_zero/core/source/image/image.h"
|
||||
|
||||
@@ -27,7 +26,6 @@ struct ImageImp : public Image, NEO::NonCopyableOrMovableClass {
|
||||
~ImageImp() override;
|
||||
|
||||
NEO::GraphicsAllocation *getAllocation() override { return allocation; }
|
||||
NEO::GraphicsAllocation *getImplicitArgsAllocation() override { return implicitArgsAllocation; }
|
||||
NEO::ImageInfo getImageInfo() override { return imgInfo; }
|
||||
ze_image_desc_t getImageDesc() override {
|
||||
return imageFormatDesc;
|
||||
@@ -54,7 +52,6 @@ struct ImageImp : public Image, NEO::NonCopyableOrMovableClass {
|
||||
Device *device = nullptr;
|
||||
NEO::ImageInfo imgInfo = {};
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
NEO::GraphicsAllocation *implicitArgsAllocation = nullptr;
|
||||
ze_image_desc_t imageFormatDesc = {};
|
||||
std::optional<ze_image_desc_t> sourceImageFormatDesc = {};
|
||||
std::unique_ptr<NEO::SurfaceStateInHeapInfo> bindlessInfo;
|
||||
|
||||
@@ -571,12 +571,12 @@ ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle
|
||||
|
||||
auto ssInHeap = image->getBindlessSlot();
|
||||
auto patchLocation = ptrOffset(getCrossThreadData(), arg.bindless);
|
||||
// redescribed image's surface state is after image's implicit args
|
||||
auto bindlessSlotOffset = ssInHeap->surfaceStateOffset + surfaceStateSize * 2;
|
||||
// redescribed image's surface state is after image's state
|
||||
auto bindlessSlotOffset = ssInHeap->surfaceStateOffset + surfaceStateSize;
|
||||
auto patchValue = gfxCoreHelper.getBindlessSurfaceExtendedMessageDescriptorValue(static_cast<uint32_t>(bindlessSlotOffset));
|
||||
patchWithRequiredSize(const_cast<uint8_t *>(patchLocation), sizeof(patchValue), patchValue);
|
||||
|
||||
image->copyRedescribedSurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize * 2), 0u);
|
||||
image->copyRedescribedSurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize), 0u);
|
||||
isBindlessOffsetSet[argIndex] = true;
|
||||
this->residencyContainer.push_back(ssInHeap->heapAllocation);
|
||||
} else {
|
||||
@@ -589,10 +589,6 @@ ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle
|
||||
}
|
||||
residencyContainer[argIndex] = image->getAllocation();
|
||||
|
||||
if (image->getImplicitArgsAllocation()) {
|
||||
this->residencyContainer.push_back(image->getImplicitArgsAllocation());
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -782,8 +778,6 @@ ze_result_t KernelImp::setArgImage(uint32_t argIndex, size_t argSize, const void
|
||||
patchWithRequiredSize(const_cast<uint8_t *>(patchLocation), sizeof(patchValue), patchValue);
|
||||
|
||||
image->copySurfaceStateToSSH(ssInHeap->ssPtr, 0u, isMediaBlockImage);
|
||||
image->copyImplicitArgsSurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize), 0u);
|
||||
|
||||
isBindlessOffsetSet[argIndex] = true;
|
||||
this->residencyContainer.push_back(ssInHeap->heapAllocation);
|
||||
} else {
|
||||
@@ -797,10 +791,6 @@ ze_result_t KernelImp::setArgImage(uint32_t argIndex, size_t argSize, const void
|
||||
|
||||
residencyContainer[argIndex] = image->getAllocation();
|
||||
|
||||
if (image->getImplicitArgsAllocation()) {
|
||||
this->residencyContainer.push_back(image->getImplicitArgsAllocation());
|
||||
}
|
||||
|
||||
auto imageInfo = image->getImageInfo();
|
||||
auto clChannelType = getClChannelDataType(image->getImageDesc().format);
|
||||
auto clChannelOrder = getClChannelOrder(image->getImageDesc().format);
|
||||
|
||||
@@ -25,7 +25,6 @@ struct WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>
|
||||
|
||||
~WhiteBox() override {}
|
||||
|
||||
using BaseClass::implicitArgsSurfaceState;
|
||||
using BaseClass::redescribedSurfaceState;
|
||||
using BaseClass::surfaceState;
|
||||
};
|
||||
|
||||
@@ -1901,109 +1901,5 @@ HWTEST2_F(ContextTest, WhenCreatingImageThenSuccessIsReturned, IsAtMostProductDG
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
|
||||
HWTEST2_F(ContextTest, givenBindlessModeDisabledWhenMakeImageResidentAndEvictThenImageImplicitArgsAllocationIsNotMadeResidentAndEvicted, IsAtLeastSkl) {
|
||||
if (!device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper() ||
|
||||
!device->getNEODevice()->getDeviceInfo().imageSupport) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
NEO::debugManager.flags.UseBindlessMode.set(0);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0};
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto mockMemoryOperationsInterface = new NEO::MockMemoryOperations();
|
||||
mockMemoryOperationsInterface->captureGfxAllocationsForMakeResident = true;
|
||||
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[0]->memoryOperationsInterface.reset(mockMemoryOperationsInterface);
|
||||
|
||||
ContextImp *contextImp = static_cast<ContextImp *>(L0::Context::fromHandle(hContext));
|
||||
|
||||
ze_image_handle_t image = {};
|
||||
ze_image_desc_t imageDesc = {};
|
||||
imageDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
|
||||
res = contextImp->createImage(device, &imageDesc, &image);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_NE(nullptr, image);
|
||||
|
||||
{
|
||||
contextImp->makeImageResident(device, image);
|
||||
EXPECT_EQ(1, mockMemoryOperationsInterface->makeResidentCalledCount);
|
||||
auto allocIter = std::find(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.begin(),
|
||||
mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(),
|
||||
Image::fromHandle(image)->getImplicitArgsAllocation());
|
||||
EXPECT_EQ(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(), allocIter);
|
||||
}
|
||||
|
||||
{
|
||||
contextImp->evictImage(device, image);
|
||||
EXPECT_EQ(1, mockMemoryOperationsInterface->evictCalledCount);
|
||||
auto allocIter = std::find(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.begin(),
|
||||
mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(),
|
||||
Image::fromHandle(image)->getImplicitArgsAllocation());
|
||||
EXPECT_EQ(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(), allocIter);
|
||||
}
|
||||
|
||||
Image::fromHandle(image)->destroy();
|
||||
|
||||
res = contextImp->destroy();
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
|
||||
HWTEST2_F(ContextTest, givenBindlessModeEnabledWhenMakeImageResidentAndEvictThenImageImplicitArgsAllocationIsMadeResidentAndEvicted, IsAtLeastSkl) {
|
||||
if (!device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper() ||
|
||||
!device->getNEODevice()->getDeviceInfo().imageSupport) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
NEO::debugManager.flags.UseBindlessMode.set(1);
|
||||
|
||||
ze_context_handle_t hContext;
|
||||
ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0};
|
||||
ze_result_t res = driverHandle->createContext(&desc, 0u, nullptr, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto mockMemoryOperationsInterface = new NEO::MockMemoryOperations();
|
||||
mockMemoryOperationsInterface->captureGfxAllocationsForMakeResident = true;
|
||||
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[0]->memoryOperationsInterface.reset(mockMemoryOperationsInterface);
|
||||
|
||||
ContextImp *contextImp = static_cast<ContextImp *>(L0::Context::fromHandle(hContext));
|
||||
|
||||
ze_image_handle_t image = {};
|
||||
ze_image_desc_t imageDesc = {};
|
||||
imageDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
|
||||
res = contextImp->createImage(device, &imageDesc, &image);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_NE(nullptr, image);
|
||||
|
||||
{
|
||||
contextImp->makeImageResident(device, image);
|
||||
EXPECT_EQ(2, mockMemoryOperationsInterface->makeResidentCalledCount);
|
||||
auto allocIter = std::find(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.begin(),
|
||||
mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(),
|
||||
Image::fromHandle(image)->getImplicitArgsAllocation());
|
||||
EXPECT_NE(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(), allocIter);
|
||||
}
|
||||
|
||||
{
|
||||
contextImp->evictImage(device, image);
|
||||
EXPECT_EQ(2, mockMemoryOperationsInterface->evictCalledCount);
|
||||
auto allocIter = std::find(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.begin(),
|
||||
mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(),
|
||||
Image::fromHandle(image)->getImplicitArgsAllocation());
|
||||
EXPECT_EQ(mockMemoryOperationsInterface->gfxAllocationsForMakeResident.end(), allocIter);
|
||||
}
|
||||
|
||||
Image::fromHandle(image)->destroy();
|
||||
|
||||
res = contextImp->destroy();
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -140,123 +140,6 @@ HWTEST2_F(ImageCreate, givenDifferentSwizzleFormatWhenImageInitializeThenCorrect
|
||||
RENDER_SURFACE_STATE::SHADER_CHANNEL_SELECT_ZERO);
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageCreate, givenBindlessModeWhenImageInitializeThenImageImplicitArgsAreCorrectlyStoredInNewSeparateAllocation, IsAtLeastSkl) {
|
||||
if (!device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
NEO::debugManager.flags.UseBindlessMode.set(1);
|
||||
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
ze_image_desc_t desc = {};
|
||||
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
desc.type = ZE_IMAGE_TYPE_3D;
|
||||
desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8;
|
||||
desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT;
|
||||
desc.width = 11;
|
||||
desc.height = 13;
|
||||
desc.depth = 17;
|
||||
|
||||
desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A;
|
||||
desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0;
|
||||
desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1;
|
||||
desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X;
|
||||
|
||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
|
||||
auto imgImplicitArgsBuffer = imageHW->getImplicitArgsAllocation()->getUnderlyingBuffer();
|
||||
|
||||
{
|
||||
auto imgInfo = imageHW->getImageInfo();
|
||||
|
||||
auto clChannelType = getClChannelDataType(desc.format);
|
||||
auto clChannelOrder = getClChannelOrder(desc.format);
|
||||
|
||||
ImageImplicitArgs imageImplicitArgs{};
|
||||
imageImplicitArgs.structVersion = 0;
|
||||
imageImplicitArgs.imageWidth = desc.width;
|
||||
imageImplicitArgs.imageHeight = desc.height;
|
||||
imageImplicitArgs.imageDepth = desc.depth;
|
||||
|
||||
imageImplicitArgs.imageArraySize = imgInfo.imgDesc.imageArraySize;
|
||||
imageImplicitArgs.numSamples = imgInfo.imgDesc.numSamples;
|
||||
imageImplicitArgs.channelType = clChannelType;
|
||||
imageImplicitArgs.channelOrder = clChannelOrder;
|
||||
imageImplicitArgs.numMipLevels = imgInfo.imgDesc.numMipLevels;
|
||||
imageImplicitArgs.flatBaseOffset = imageHW->getImplicitArgsAllocation()->getGpuAddress();
|
||||
|
||||
auto pixelSize = imgInfo.surfaceFormat->imageElementSizeInBytes;
|
||||
imageImplicitArgs.flatWidth = (imgInfo.imgDesc.imageWidth * pixelSize) - 1u;
|
||||
imageImplicitArgs.flagHeight = (imgInfo.imgDesc.imageHeight * pixelSize) - 1u;
|
||||
imageImplicitArgs.flatPitch = imgInfo.imgDesc.imageRowPitch - 1u;
|
||||
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, structSize)), &imageImplicitArgs.structSize, ImageImplicitArgs::getSize()));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, structVersion)), &imageImplicitArgs.structVersion, sizeof(imageImplicitArgs.structVersion)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, imageWidth)), &imageImplicitArgs.imageWidth, sizeof(imageImplicitArgs.imageWidth)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, imageHeight)), &imageImplicitArgs.imageHeight, sizeof(imageImplicitArgs.imageHeight)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, imageDepth)), &imageImplicitArgs.imageDepth, sizeof(imageImplicitArgs.imageDepth)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, imageArraySize)), &imageImplicitArgs.imageArraySize, sizeof(imageImplicitArgs.imageArraySize)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, numSamples)), &imageImplicitArgs.numSamples, sizeof(imageImplicitArgs.numSamples)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, channelType)), &imageImplicitArgs.channelType, sizeof(imageImplicitArgs.channelType)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, channelOrder)), &imageImplicitArgs.channelOrder, sizeof(imageImplicitArgs.channelOrder)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, numMipLevels)), &imageImplicitArgs.numMipLevels, sizeof(imageImplicitArgs.numMipLevels)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, flatBaseOffset)), &imageImplicitArgs.flatBaseOffset, sizeof(imageImplicitArgs.flatBaseOffset)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, flatWidth)), &imageImplicitArgs.flatWidth, sizeof(imageImplicitArgs.flatWidth)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, flagHeight)), &imageImplicitArgs.flagHeight, sizeof(imageImplicitArgs.flagHeight)));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(imgImplicitArgsBuffer, offsetof(ImageImplicitArgs, flatPitch)), &imageImplicitArgs.flatPitch, sizeof(imageImplicitArgs.flatPitch)));
|
||||
}
|
||||
{
|
||||
auto implicitArgsSurfaceState = &imageHW->implicitArgsSurfaceState;
|
||||
|
||||
auto implicitArgsSurfaceStateBaseAddress = reinterpret_cast<void *>(implicitArgsSurfaceState->getSurfaceBaseAddress());
|
||||
EXPECT_EQ(imgImplicitArgsBuffer, implicitArgsSurfaceStateBaseAddress);
|
||||
|
||||
auto implicitArgsSurfaceType = implicitArgsSurfaceState->getSurfaceType();
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER, implicitArgsSurfaceType);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageCreate, givenBindlessModeDisabledWhenImageInitializeThenImageImplicitArgsAllocationAndSurfaceStateAreNotCreated, IsAtLeastSkl) {
|
||||
if (!device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
NEO::debugManager.flags.UseBindlessMode.set(0);
|
||||
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
ze_image_desc_t desc = {};
|
||||
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
desc.type = ZE_IMAGE_TYPE_3D;
|
||||
desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8;
|
||||
desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT;
|
||||
desc.width = 11;
|
||||
desc.height = 13;
|
||||
desc.depth = 17;
|
||||
|
||||
desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A;
|
||||
desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0;
|
||||
desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1;
|
||||
desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X;
|
||||
|
||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
|
||||
auto imgImplicitArgsAllocation = imageHW->getImplicitArgsAllocation();
|
||||
EXPECT_EQ(nullptr, imgImplicitArgsAllocation);
|
||||
|
||||
auto implicitArgsSurfaceState = &imageHW->implicitArgsSurfaceState;
|
||||
EXPECT_EQ(nullptr, reinterpret_cast<void *>(implicitArgsSurfaceState->getSurfaceBaseAddress()));
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageView, givenPlanarImageWhenCreateImageViewThenProperPlaneIsCreated, IsAtLeastSkl) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
const size_t width = 32;
|
||||
|
||||
@@ -2578,11 +2578,6 @@ struct MyMockImage : public WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>> {
|
||||
passedSurfaceStateOffset = surfaceStateOffset;
|
||||
}
|
||||
|
||||
void copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override {
|
||||
passedImplicitArgsSurfaceStateHeap = surfaceStateHeap;
|
||||
passedImplicitArgsSurfaceStateOffset = surfaceStateOffset;
|
||||
}
|
||||
|
||||
void copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override {
|
||||
passedRedescribedSurfaceStateHeap = surfaceStateHeap;
|
||||
passedRedescribedSurfaceStateOffset = surfaceStateOffset;
|
||||
@@ -2591,9 +2586,6 @@ struct MyMockImage : public WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>> {
|
||||
void *passedSurfaceStateHeap = nullptr;
|
||||
uint32_t passedSurfaceStateOffset = 0;
|
||||
|
||||
void *passedImplicitArgsSurfaceStateHeap = nullptr;
|
||||
uint32_t passedImplicitArgsSurfaceStateOffset = 0;
|
||||
|
||||
void *passedRedescribedSurfaceStateHeap = nullptr;
|
||||
uint32_t passedRedescribedSurfaceStateOffset = 0;
|
||||
};
|
||||
@@ -2686,39 +2678,6 @@ HWTEST2_F(SetKernelArg, givenBindlessKernelAndNoAvailableSpaceOnSshWhenSetArgIma
|
||||
EXPECT_EQ(nullptr, bindlessInfo.heapAllocation);
|
||||
}
|
||||
|
||||
HWTEST2_F(SetKernelArg, givenImageAndBindlessKernelWhenSetArgImageThenCopyImplicitArgsSurfaceStateToSSHCalledWithCorrectArgs, ImageSupport) {
|
||||
createKernel();
|
||||
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(),
|
||||
neoDevice->getNumGenericSubDevices() > 1,
|
||||
neoDevice->getRootDeviceIndex(),
|
||||
neoDevice->getDeviceBitfield());
|
||||
auto &imageArg = const_cast<NEO::ArgDescImage &>(kernel->kernelImmData->getDescriptor().payloadMappings.explicitArgs[3].template as<NEO::ArgDescImage>());
|
||||
auto &addressingMode = kernel->kernelImmData->getDescriptor().kernelAttributes.imageAddressingMode;
|
||||
const_cast<NEO::KernelDescriptor::AddressingMode &>(addressingMode) = NEO::KernelDescriptor::Bindless;
|
||||
imageArg.bindless = 0x0;
|
||||
imageArg.bindful = undefined<SurfaceStateHeapOffset>;
|
||||
ze_image_desc_t desc = {};
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
|
||||
auto imageHW = std::make_unique<MyMockImage<gfxCoreFamily>>();
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
auto handle = imageHW->toHandle();
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
|
||||
ret = kernel->setArgImage(3, sizeof(imageHW.get()), &handle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
|
||||
auto &gfxCoreHelper = neoDevice->getGfxCoreHelper();
|
||||
auto surfaceStateSize = gfxCoreHelper.getRenderSurfaceStateSize();
|
||||
|
||||
auto expectedSsInHeap = imageHW->getAllocation()->getBindlessInfo();
|
||||
EXPECT_EQ(imageHW->passedImplicitArgsSurfaceStateHeap, ptrOffset(expectedSsInHeap.ssPtr, surfaceStateSize));
|
||||
EXPECT_EQ(imageHW->passedImplicitArgsSurfaceStateOffset, 0u);
|
||||
EXPECT_TRUE(kernel->isBindlessOffsetSet[3]);
|
||||
EXPECT_FALSE(kernel->usingSurfaceStateHeap[3]);
|
||||
}
|
||||
|
||||
HWTEST2_F(SetKernelArg, givenImageBindlessKernelAndGlobalBindlessHelperWhenSetArgRedescribedImageCalledThenCopySurfaceStateToSSHCalledWithCorrectArgs, ImageSupport) {
|
||||
createKernel();
|
||||
|
||||
@@ -2746,7 +2705,7 @@ HWTEST2_F(SetKernelArg, givenImageBindlessKernelAndGlobalBindlessHelperWhenSetAr
|
||||
auto surfaceStateSize = gfxCoreHelper.getRenderSurfaceStateSize();
|
||||
|
||||
auto expectedSsInHeap = imageHW->getAllocation()->getBindlessInfo();
|
||||
EXPECT_EQ(imageHW->passedRedescribedSurfaceStateHeap, ptrOffset(expectedSsInHeap.ssPtr, surfaceStateSize * 2));
|
||||
EXPECT_EQ(imageHW->passedRedescribedSurfaceStateHeap, ptrOffset(expectedSsInHeap.ssPtr, surfaceStateSize));
|
||||
EXPECT_EQ(imageHW->passedRedescribedSurfaceStateOffset, 0u);
|
||||
EXPECT_TRUE(kernel->isBindlessOffsetSet[3]);
|
||||
EXPECT_FALSE(kernel->usingSurfaceStateHeap[3]);
|
||||
|
||||
Reference in New Issue
Block a user