|
11 | 11 | #include "shared/source/device/device.h" |
12 | 12 | #include "shared/source/execution_environment/root_device_environment.h" |
13 | 13 | #include "shared/source/gmm_helper/gmm.h" |
| 14 | +#include "shared/source/helpers/api_specific_config.h" |
14 | 15 | #include "shared/source/helpers/basic_math.h" |
| 16 | +#include "shared/source/helpers/gfx_core_helper.h" |
15 | 17 | #include "shared/source/helpers/surface_format_info.h" |
16 | 18 | #include "shared/source/image/image_surface_state.h" |
17 | 19 | #include "shared/source/memory_manager/allocation_properties.h" |
18 | 20 | #include "shared/source/memory_manager/memory_manager.h" |
| 21 | +#include "shared/source/release_helper/release_helper.h" |
19 | 22 |
|
20 | 23 | #include "level_zero/core/source/device/device.h" |
21 | 24 | #include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h" |
22 | 25 | #include "level_zero/core/source/helpers/properties_parser.h" |
| 26 | +#include "level_zero/core/source/image/image_format_desc_helper.h" |
23 | 27 | #include "level_zero/core/source/image/image_formats.h" |
24 | 28 | #include "level_zero/core/source/image/image_hw.h" |
25 | 29 |
|
| 30 | +#include "encode_surface_state_args.h" |
| 31 | + |
26 | 32 | namespace L0 { |
27 | 33 |
|
28 | 34 | template <GFXCORE_FAMILY gfxCoreFamily> |
29 | 35 | ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_image_desc_t *desc) { |
30 | 36 | using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; |
31 | 37 |
|
| 38 | + const auto &rootDeviceEnvironment = device->getNEODevice()->getRootDeviceEnvironment(); |
| 39 | + const bool isBindlessMode = rootDeviceEnvironment.getReleaseHelper() ? NEO::ApiSpecificConfig::getBindlessMode(rootDeviceEnvironment.getReleaseHelper()) : false; |
| 40 | + |
32 | 41 | StructuresLookupTable lookupTable = {}; |
33 | 42 |
|
34 | 43 | lookupTable.areImageProperties = true; |
@@ -104,8 +113,13 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_ |
104 | 113 | } |
105 | 114 | } |
106 | 115 |
|
| 116 | + if (isBindlessMode) { |
| 117 | + NEO::AllocationProperties imgImplicitArgsAllocProperties(device->getRootDeviceIndex(), NEO::ImageImplicitArgs::getSize(), NEO::AllocationType::buffer, device->getNEODevice()->getDeviceBitfield()); |
| 118 | + implicitArgsAllocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(imgImplicitArgsAllocProperties); |
| 119 | + } |
| 120 | + |
107 | 121 | auto gmm = this->allocation->getDefaultGmm(); |
108 | | - auto gmmHelper = static_cast<const NEO::RootDeviceEnvironment &>(device->getNEODevice()->getRootDeviceEnvironment()).getGmmHelper(); |
| 122 | + auto gmmHelper = static_cast<const NEO::RootDeviceEnvironment &>(rootDeviceEnvironment).getGmmHelper(); |
109 | 123 |
|
110 | 124 | if (gmm != nullptr) { |
111 | 125 | NEO::ImagePlane yuvPlaneType = NEO::ImagePlane::noPlane; |
@@ -157,6 +171,53 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_ |
157 | 171 | NEO::EncodeSurfaceState<GfxFamily>::setImageAuxParamsForCCS(&surfaceState, gmm); |
158 | 172 | } |
159 | 173 | } |
| 174 | + |
| 175 | + if (isBindlessMode && implicitArgsAllocation) { |
| 176 | + implicitArgsSurfaceState = GfxFamily::cmdInitRenderSurfaceState; |
| 177 | + |
| 178 | + auto clChannelType = getClChannelDataType(imageFormatDesc.format); |
| 179 | + auto clChannelOrder = getClChannelOrder(imageFormatDesc.format); |
| 180 | + |
| 181 | + NEO::ImageImplicitArgs imageImplicitArgs{}; |
| 182 | + imageImplicitArgs.structVersion = 0; |
| 183 | + |
| 184 | + imageImplicitArgs.imageWidth = imgInfo.imgDesc.imageWidth; |
| 185 | + imageImplicitArgs.imageHeight = imgInfo.imgDesc.imageHeight; |
| 186 | + imageImplicitArgs.imageDepth = imgInfo.imgDesc.imageDepth; |
| 187 | + imageImplicitArgs.imageArraySize = imgInfo.imgDesc.imageArraySize; |
| 188 | + imageImplicitArgs.numSamples = imgInfo.imgDesc.numSamples; |
| 189 | + imageImplicitArgs.channelType = clChannelType; |
| 190 | + imageImplicitArgs.channelOrder = clChannelOrder; |
| 191 | + imageImplicitArgs.numMipLevels = imgInfo.imgDesc.numMipLevels; |
| 192 | + |
| 193 | + auto pixelSize = imgInfo.surfaceFormat->imageElementSizeInBytes; |
| 194 | + imageImplicitArgs.flatBaseOffset = implicitArgsAllocation->getGpuAddress(); |
| 195 | + imageImplicitArgs.flatWidth = (imgInfo.imgDesc.imageWidth * pixelSize) - 1u; |
| 196 | + imageImplicitArgs.flagHeight = (imgInfo.imgDesc.imageHeight * pixelSize) - 1u; |
| 197 | + imageImplicitArgs.flatPitch = imgInfo.imgDesc.imageRowPitch - 1u; |
| 198 | + |
| 199 | + const auto &productHelper = rootDeviceEnvironment.getHelper<NEO::ProductHelper>(); |
| 200 | + NEO::MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *implicitArgsAllocation), *this->device->getNEODevice(), implicitArgsAllocation, 0u, &imageImplicitArgs, NEO::ImageImplicitArgs::getSize()); |
| 201 | + |
| 202 | + { |
| 203 | + auto &gfxCoreHelper = this->device->getGfxCoreHelper(); |
| 204 | + |
| 205 | + NEO::EncodeSurfaceStateArgs args; |
| 206 | + args.outMemory = &implicitArgsSurfaceState; |
| 207 | + args.size = NEO::ImageImplicitArgs::getSize(); |
| 208 | + args.graphicsAddress = implicitArgsAllocation->getGpuAddress(); |
| 209 | + args.gmmHelper = gmmHelper; |
| 210 | + args.allocation = implicitArgsAllocation; |
| 211 | + args.numAvailableDevices = this->device->getNEODevice()->getNumGenericSubDevices(); |
| 212 | + args.areMultipleSubDevicesInContext = args.numAvailableDevices > 1; |
| 213 | + args.mocs = gfxCoreHelper.getMocsIndex(*args.gmmHelper, true, false) << 1; |
| 214 | + args.implicitScaling = this->device->isImplicitScalingCapable(); |
| 215 | + args.isDebuggerActive = this->device->getNEODevice()->getDebugger() != nullptr; |
| 216 | + |
| 217 | + gfxCoreHelper.encodeBufferSurfaceState(args); |
| 218 | + } |
| 219 | + } |
| 220 | + |
160 | 221 | { |
161 | 222 | const uint32_t exponent = Math::log2(imgInfo.surfaceFormat->imageElementSizeInBytes); |
162 | 223 | DEBUG_BREAK_IF(exponent >= 5u); |
@@ -232,6 +293,18 @@ void ImageCoreFamily<gfxCoreFamily>::copyRedescribedSurfaceStateToSSH(void *surf |
232 | 293 | &redescribedSurfaceState, sizeof(RENDER_SURFACE_STATE)); |
233 | 294 | } |
234 | 295 |
|
| 296 | +template <GFXCORE_FAMILY gfxCoreFamily> |
| 297 | +void ImageCoreFamily<gfxCoreFamily>::copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, |
| 298 | + const uint32_t surfaceStateOffset) { |
| 299 | + using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily; |
| 300 | + using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; |
| 301 | + |
| 302 | + // Copy the image's surface state into position in the provided surface state heap |
| 303 | + auto destSurfaceState = ptrOffset(surfaceStateHeap, surfaceStateOffset); |
| 304 | + memcpy_s(destSurfaceState, sizeof(RENDER_SURFACE_STATE), |
| 305 | + &implicitArgsSurfaceState, sizeof(RENDER_SURFACE_STATE)); |
| 306 | +} |
| 307 | + |
235 | 308 | template <GFXCORE_FAMILY gfxCoreFamily> |
236 | 309 | bool ImageCoreFamily<gfxCoreFamily>::isSuitableForCompression(const StructuresLookupTable &structuresLookupTable, const NEO::ImageInfo &imgInfo) { |
237 | 310 | auto &hwInfo = device->getHwInfo(); |
|
0 commit comments