fix: program binding table for bindless kernels

- if binding table entries are used in bindless kernel, program Binding
table

Related-To: NEO-7063

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2023-11-30 15:30:14 +00:00
committed by Compute-Runtime-Automation
parent f06c2f04d0
commit 8056476d8d
5 changed files with 124 additions and 18 deletions

View File

@@ -98,7 +98,13 @@ ze_result_t KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device
kernelDescriptor->payloadMappings.implicitArgs.simdSize, kernelDescriptor->kernelAttributes.simdSize);
}
if (NEO::KernelDescriptor::isBindlessAddressingKernel(kernelInfo->kernelDescriptor)) {
if (kernelInfo->heapInfo.surfaceStateHeapSize != 0) {
this->surfaceStateHeapSize = kernelInfo->heapInfo.surfaceStateHeapSize;
surfaceStateHeapTemplate.reset(new uint8_t[surfaceStateHeapSize]);
memcpy_s(surfaceStateHeapTemplate.get(), surfaceStateHeapSize,
kernelInfo->heapInfo.pSsh, surfaceStateHeapSize);
} else if (NEO::KernelDescriptor::isBindlessAddressingKernel(kernelInfo->kernelDescriptor)) {
auto &gfxCoreHelper = deviceImp->getNEODevice()->getGfxCoreHelper();
auto surfaceStateSize = static_cast<uint32_t>(gfxCoreHelper.getRenderSurfaceStateSize());
@@ -106,12 +112,6 @@ ze_result_t KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device
DEBUG_BREAK_IF(kernelInfo->kernelDescriptor.kernelAttributes.numArgsStateful != kernelInfo->kernelDescriptor.getBindlessOffsetToSurfaceState().size());
surfaceStateHeapTemplate.reset(new uint8_t[surfaceStateHeapSize]);
} else if (kernelInfo->heapInfo.surfaceStateHeapSize != 0) {
this->surfaceStateHeapSize = kernelInfo->heapInfo.surfaceStateHeapSize;
surfaceStateHeapTemplate.reset(new uint8_t[surfaceStateHeapSize]);
memcpy_s(surfaceStateHeapTemplate.get(), surfaceStateHeapSize,
kernelInfo->heapInfo.pSsh, surfaceStateHeapSize);
}
if (kernelInfo->heapInfo.dynamicStateHeapSize != 0) {

View File

@@ -3681,5 +3681,42 @@ TEST_F(BindlessKernelTest, givenNoStatefulArgsWhenPatchingBindlessOffsetsInCross
EXPECT_EQ(0u, crossThreadData[0]);
}
TEST(KernelImmutableDataTest, givenBindlessKernelWhenInitializingImmDataThenSshTemplateIsAllocated) {
HardwareInfo hwInfo = *defaultHwInfo;
auto device = std::unique_ptr<NEO::MockDevice>(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
{
device->incRefInternal();
MockDeviceImp deviceImp(device.get(), device->getExecutionEnvironment());
auto kernelInfo = std::make_unique<KernelInfo>();
kernelInfo->heapInfo.kernelHeapSize = 1;
char kernelHeap[1];
kernelInfo->heapInfo.pKernelHeap = &kernelHeap;
kernelInfo->heapInfo.surfaceStateHeapSize = 0;
kernelInfo->heapInfo.pSsh = nullptr;
kernelInfo->kernelDescriptor.kernelMetadata.kernelName = ZebinTestData::ValidEmptyProgram<>::kernelName;
kernelInfo->kernelDescriptor.kernelAttributes.bufferAddressingMode = NEO::KernelDescriptor::BindlessAndStateless;
kernelInfo->kernelDescriptor.kernelAttributes.imageAddressingMode = NEO::KernelDescriptor::Bindless;
auto argDescriptor = NEO::ArgDescriptor(NEO::ArgDescriptor::ArgTPointer);
argDescriptor.as<NEO::ArgDescPointer>() = NEO::ArgDescPointer();
argDescriptor.as<NEO::ArgDescPointer>().bindful = NEO::undefined<NEO::SurfaceStateHeapOffset>;
argDescriptor.as<NEO::ArgDescPointer>().bindless = 0x0;
kernelInfo->kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptor);
kernelInfo->kernelDescriptor.kernelAttributes.numArgsStateful = 1;
auto kernelImmutableData = std::make_unique<KernelImmutableData>(&deviceImp);
kernelImmutableData->initialize(kernelInfo.get(), &deviceImp, 0, nullptr, nullptr, false);
auto &gfxCoreHelper = device->getGfxCoreHelper();
auto surfaceStateSize = static_cast<uint32_t>(gfxCoreHelper.getRenderSurfaceStateSize());
EXPECT_EQ(surfaceStateSize, kernelImmutableData->getSurfaceStateHeapSize());
}
}
} // namespace ult
} // namespace L0