Helper method to check if allocation is compressed

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-12-01 18:11:27 +00:00
committed by Compute-Runtime-Automation
parent 7b55d38e34
commit 55959d4d1d
15 changed files with 32 additions and 94 deletions

View File

@ -139,7 +139,7 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
surfaceState.setNumberOfMultisamples(RENDER_SURFACE_STATE::NUMBER_OF_MULTISAMPLES::NUMBER_OF_MULTISAMPLES_MULTISAMPLECOUNT_1);
if (gmm && gmm->isCompressionEnabled) {
if (allocation->isCompressionEnabled()) {
NEO::EncodeSurfaceState<GfxFamily>::setImageAuxParamsForCCS(&surfaceState, gmm);
}
}
@ -180,7 +180,7 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
redescribedSurfaceState.setNumberOfMultisamples(RENDER_SURFACE_STATE::NUMBER_OF_MULTISAMPLES::NUMBER_OF_MULTISAMPLES_MULTISAMPLECOUNT_1);
if (gmm && gmm->isCompressionEnabled) {
if (allocation->isCompressionEnabled()) {
NEO::EncodeSurfaceState<GfxFamily>::setImageAuxParamsForCCS(&redescribedSurfaceState, gmm);
}
}

View File

@ -387,9 +387,8 @@ Buffer *Buffer::create(Context *context,
pBuffer->setHostPtrMinSize(size);
if (allocationInfo[rootDeviceIndex].copyMemoryFromHostPtr && !copyExecuted) {
auto gmm = allocationInfo[rootDeviceIndex].memory->getDefaultGmm();
auto isLocalMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
bool gpuCopyRequired = (gmm && gmm->isCompressionEnabled) || isLocalMemory;
bool gpuCopyRequired = (allocationInfo[rootDeviceIndex].memory->isCompressionEnabled()) || isLocalMemory;
if (gpuCopyRequired) {
auto &device = pBuffer->getContext()->getDevice(0u)->getDevice();

View File

@ -387,14 +387,12 @@ Image *Image::create(Context *context,
auto &hwInfo = *memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
if (context->isProvidingPerformanceHints() && HwHelper::renderCompressedImagesSupported(hwInfo)) {
if (allocationInfo[rootDeviceIndex].memory->getDefaultGmm()) {
if (allocationInfo[rootDeviceIndex].memory->getDefaultGmm()->isCompressionEnabled) {
if (allocationInfo[rootDeviceIndex].memory->isCompressionEnabled()) {
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, IMAGE_IS_COMPRESSED, image);
} else {
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, IMAGE_IS_NOT_COMPRESSED, image);
}
}
}
if (imageDesc->image_type != CL_MEM_OBJECT_IMAGE1D_ARRAY && imageDesc->image_type != CL_MEM_OBJECT_IMAGE2D_ARRAY) {
image->imageDesc.image_array_size = 0;

View File

@ -88,7 +88,7 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
if (imageDesc.num_samples > 1) {
setAuxParamsForMultisamples(surfaceState);
} else if (gmm && gmm->isCompressionEnabled) {
} else if (graphicsAllocation->isCompressionEnabled()) {
EncodeSurfaceState<GfxFamily>::setImageAuxParamsForCCS(surfaceState, gmm);
} else {
EncodeSurfaceState<GfxFamily>::disableCompressionFlags(surfaceState);

View File

@ -418,8 +418,7 @@ bool MemObj::isTiledAllocation() const {
bool MemObj::mappingOnCpuAllowed() const {
auto graphicsAllocation = multiGraphicsAllocation.getDefaultGraphicsAllocation();
return !isTiledAllocation() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() &&
!(graphicsAllocation->getDefaultGmm() && graphicsAllocation->getDefaultGmm()->isCompressionEnabled) &&
MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
!graphicsAllocation->isCompressionEnabled() && MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
}
void MemObj::storeProperties(const cl_mem_properties *properties) {

View File

@ -774,63 +774,6 @@ TEST_F(PerformanceHintTest, givenCompressedImageWhenItsCreatedThenProperPerforma
}
}
TEST_F(PerformanceHintTest, givenImageWithNoGmmWhenItsCreatedThenNoPerformanceHintIsProvided) {
HardwareInfo hwInfo = context->getDevice(0)->getHardwareInfo();
hwInfo.capabilityTable.ftrRenderCompressedImages = true;
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
cl_device_id deviceId = device.get();
cl_context_properties validProperties[3] = {CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL, CL_CONTEXT_DIAGNOSTICS_LEVEL_ALL_INTEL, 0};
auto context = std::unique_ptr<MockContext>(Context::create<NEO::MockContext>(validProperties, ClDeviceVector(&deviceId, 1), callbackFunction, static_cast<void *>(userData), retVal));
const size_t width = 5;
const size_t height = 3;
const size_t depth = 2;
cl_int retVal = CL_SUCCESS;
auto const elementSize = 4;
char *hostPtr = static_cast<char *>(alignedMalloc(width * height * depth * elementSize * 2, 64));
cl_image_format imageFormat;
cl_image_desc imageDesc;
auto mockBuffer = std::unique_ptr<MockBuffer>(new MockBuffer());
cl_mem mem = mockBuffer.get();
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.num_mip_levels = 0;
imageDesc.num_samples = 0;
imageDesc.mem_object = mem;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
imageDesc.image_width = width;
imageDesc.image_height = 0;
imageDesc.image_depth = 0;
imageDesc.image_array_size = 0;
imageDesc.image_row_pitch = 0;
imageDesc.image_slice_pitch = 0;
cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR;
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
context.get(),
ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
flags,
0,
surfaceFormat,
&imageDesc,
hostPtr,
retVal));
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[IMAGE_IS_COMPRESSED], image.get());
EXPECT_FALSE(containsHint(expectedHint, userData));
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[IMAGE_IS_NOT_COMPRESSED], image.get());
EXPECT_FALSE(containsHint(expectedHint, userData));
alignedFree(hostPtr);
}
TEST_F(PerformanceHintTest, givenUncompressedImageWhenItsCreatedThenProperPerformanceHintIsProvided) {
HardwareInfo hwInfo = context->getDevice(0)->getHardwareInfo();
hwInfo.capabilityTable.ftrRenderCompressedImages = true;

View File

@ -68,7 +68,7 @@ SurfaceInfo *getDumpSurfaceInfo(GraphicsAllocation &gfxAllocation, DumpFormat du
surfaceInfo->format = gmm->gmmResourceInfo->getResourceFormatSurfaceState();
surfaceInfo->tilingType = gmm->gmmResourceInfo->getTileModeSurfaceState();
surfaceInfo->surftype = getImageSurfaceTypeFromGmmResourceType<GfxFamily>(gmm->gmmResourceInfo->getResourceType());
surfaceInfo->compressed = gmm->isCompressionEnabled;
surfaceInfo->compressed = gfxAllocation.isCompressionEnabled();
surfaceInfo->dumpType = (AubAllocDump::DumpFormat::IMAGE_TRE == dumpFormat) ? dumpType::tre : dumpType::bmp;
}
@ -163,7 +163,7 @@ template <typename GfxFamily>
void dumpImageInTreFormat(GraphicsAllocation &gfxAllocation, AubMemDump::AubFileStream *stream, uint32_t context) {
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
auto gmm = gfxAllocation.getDefaultGmm();
if ((gmm->gmmResourceInfo->getNumSamples() > 1) || (gmm->isCompressionEnabled)) {
if ((gmm->gmmResourceInfo->getNumSamples() > 1) || (gfxAllocation.isCompressionEnabled())) {
DEBUG_BREAK_IF(true); //unsupported
return;
}

View File

@ -366,8 +366,8 @@ void EncodeSurfaceState<Family>::encodeBuffer(EncodeSurfaceStateArgs &args) {
setCoherencyType(surfaceState, args.cpuCoherent ? R_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT : R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
Gmm *gmm = args.allocation ? args.allocation->getDefaultGmm() : nullptr;
if (gmm && gmm->isCompressionEnabled && !args.forceNonAuxMode) {
auto compressionEnabled = args.allocation ? args.allocation->isCompressionEnabled() : false;
if (compressionEnabled && !args.forceNonAuxMode) {
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
setCoherencyType(surfaceState, R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
setBufferAuxParamsForCCS(surfaceState);

View File

@ -49,9 +49,9 @@ bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getParametersForWriteMem
cpuAddress = graphicsAllocation.getUnderlyingBuffer();
gpuAddress = GmmHelper::decanonize(graphicsAllocation.getGpuAddress());
size = graphicsAllocation.getUnderlyingBufferSize();
auto gmm = graphicsAllocation.getDefaultGmm();
if (gmm && gmm->isCompressionEnabled) {
size = gmm->gmmResourceInfo->getSizeAllocation();
if (graphicsAllocation.isCompressionEnabled()) {
size = graphicsAllocation.getDefaultGmm()->gmmResourceInfo->getSizeAllocation();
}
if (size == 0)

View File

@ -107,9 +107,7 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo
aub_stream::AllocationParams allocationParams(gpuAddress, cpuAddress, size, this->getMemoryBank(&graphicsAllocation),
hint, graphicsAllocation.getUsedPageSize());
auto gmm = graphicsAllocation.getDefaultGmm();
allocationParams.additionalParams.compressionEnabled = gmm ? gmm->isCompressionEnabled : false;
allocationParams.additionalParams.compressionEnabled = graphicsAllocation.isCompressionEnabled();
if (graphicsAllocation.storageInfo.cloningOfPageTables || !graphicsAllocation.isAllocatedInLocalMemoryPool()) {
aubManager->writeMemory2(allocationParams);

View File

@ -37,10 +37,6 @@ uint64_t BlitCommandsHelper<GfxFamily>::getMaxBlitHeightOverride(const RootDevic
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {
using XY_COPY_BLT = typename GfxFamily::XY_COPY_BLT;
auto dstAllocation = blitProperties.dstAllocation;
auto srcAllocation = blitProperties.srcAllocation;
bool dstAllocationisCompressionEnabled = dstAllocation->getDefaultGmm() && dstAllocation->getDefaultGmm()->isCompressionEnabled;
bool srcAllocationisCompressionEnabled = srcAllocation->getDefaultGmm() && srcAllocation->getDefaultGmm()->isCompressionEnabled;
appendClearColor(blitProperties, blitCmd);
@ -54,21 +50,21 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProper
compressionEnabledField = static_cast<typename XY_COPY_BLT::COMPRESSION_ENABLE>(DebugManager.flags.ForceCompressionDisabledForCompressedBlitCopies.get());
}
if (dstAllocationisCompressionEnabled) {
if (blitProperties.dstAllocation->isCompressionEnabled()) {
blitCmd.setDestinationCompressionEnable(compressionEnabledField);
blitCmd.setDestinationAuxiliarysurfacemode(XY_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
blitCmd.setDestinationCompressionFormat(compressionFormat);
}
if (srcAllocationisCompressionEnabled) {
if (blitProperties.srcAllocation->isCompressionEnabled()) {
blitCmd.setSourceCompressionEnable(compressionEnabledField);
blitCmd.setSourceAuxiliarysurfacemode(XY_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
blitCmd.setSourceCompressionFormat(compressionFormat);
}
if (MemoryPool::isSystemMemoryPool(dstAllocation->getMemoryPool())) {
if (MemoryPool::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) {
blitCmd.setDestinationTargetMemory(XY_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
if (MemoryPool::isSystemMemoryPool(srcAllocation->getMemoryPool())) {
if (MemoryPool::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) {
blitCmd.setSourceTargetMemory(XY_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
@ -95,7 +91,7 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProper
}
DEBUG_BREAK_IF((AuxTranslationDirection::None != blitProperties.auxTranslationDirection) &&
(dstAllocation != srcAllocation || !dstAllocationisCompressionEnabled));
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled()));
auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
blitCmd.setDestinationMOCS(mocs);
@ -127,14 +123,13 @@ void setCompressionParamsForFillOperation(typename GfxFamily::XY_COLOR_BLT &xyCo
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
bool dstAllocationisCompressionEnabled = dstAlloc->getDefaultGmm() && dstAlloc->getDefaultGmm()->isCompressionEnabled;
uint32_t compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT);
if (DebugManager.flags.ForceBufferCompressionFormat.get() != -1) {
compressionFormat = DebugManager.flags.ForceBufferCompressionFormat.get();
}
if (dstAllocationisCompressionEnabled) {
if (dstAlloc->isCompressionEnabled()) {
setCompressionParamsForFillOperation<GfxFamily>(blitCmd);
blitCmd.setDestinationCompressionFormat(compressionFormat);
}

View File

@ -158,8 +158,8 @@ void HwHelperHw<Family>::setRenderSurfaceStateForBuffer(const RootDeviceEnvironm
state.setSurfaceBaseAddress(bufferStateAddress);
Gmm *gmm = gfxAlloc ? gfxAlloc->getDefaultGmm() : nullptr;
if (gmm && gmm->isCompressionEnabled && !forceNonAuxMode) {
bool isCompressionEnabled = gfxAlloc ? gfxAlloc->isCompressionEnabled() : false;
if (isCompressionEnabled && !forceNonAuxMode) {
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
EncodeSurfaceState<Family>::setCoherencyType(&state, RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
EncodeSurfaceState<Family>::setBufferAuxParamsForCCS(&state);

View File

@ -94,6 +94,10 @@ void GraphicsAllocation::setTbxWritable(bool writable, uint32_t banks) {
aubInfo.tbxWritable = static_cast<uint32_t>(setBits(aubInfo.tbxWritable, writable, banks));
}
bool GraphicsAllocation::isCompressionEnabled() const {
return (getDefaultGmm() && getDefaultGmm()->isCompressionEnabled);
}
bool GraphicsAllocation::isTbxWritable(uint32_t banks) const {
return isAnyBitSet(aubInfo.tbxWritable, banks);
}

View File

@ -285,6 +285,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
const AubInfo &getAubInfo() const { return aubInfo; }
bool isCompressionEnabled() const;
OsHandleStorage fragmentsStorage;
StorageInfo storageInfo = {};

View File

@ -493,7 +493,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
auto defaultGmm = gfxAllocation->getDefaultGmm();
auto hwInfo = executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->getHardwareInfo();
if (defaultGmm && defaultGmm->isCompressionEnabled && HwInfoConfig::get(hwInfo->platform.eProductFamily)->isPageTableManagerSupported(*hwInfo)) {
if (gfxAllocation->isCompressionEnabled() && HwInfoConfig::get(hwInfo->platform.eProductFamily)->isPageTableManagerSupported(*hwInfo)) {
for (auto engine : registeredEngines) {
if (engine.commandStreamReceiver->pageTableManager.get()) {
[[maybe_unused]] auto status = engine.commandStreamReceiver->pageTableManager->updateAuxTable(input->getGpuAddress(), defaultGmm, false);