Skip to content

Commit 4dd7bf4

Browse files
smilczekigcbot
authored andcommitted
Unused bindless image args treated as bindless fix.
When emitting zeinfo IGC tags addr mode of images with no users as stateful even if the module is compiled to use bindless images. This caused NEO to throw an error as it disallows the use of both bindless and bindful mode in the same module. This commit sets the default addr mode to bindless for modules that have UseBindlessImage set to true.
1 parent 8a4dd2c commit 4dd7bf4

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,19 +771,20 @@ bool COpenCLKernel::CreateZEPayloadArguments(IGC::KernelArg *kernelArg, uint pay
771771
case KernelArg::ArgType::BINDLESS_IMAGE_CUBE_ARRAY:
772772
case KernelArg::ArgType::IMAGE_CUBE_DEPTH_ARRAY:
773773
case KernelArg::ArgType::BINDLESS_IMAGE_CUBE_DEPTH_ARRAY: {
774-
// the image arg is either bindless or stateful. check from "kernelArg->needsAllocation()"
774+
// the image arg is either bindless or stateful.
775775
// For stateful image argument, the arg has 0 offset and 0 size
776-
zebin::PreDefinedAttrGetter::ArgAddrMode arg_addrmode = zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
776+
zebin::PreDefinedAttrGetter::ArgAddrMode arg_addrmode = m_ModuleMetadata->UseBindlessImage
777+
? zebin::PreDefinedAttrGetter::ArgAddrMode::bindless
778+
: zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
777779
uint arg_off = 0;
778780
uint arg_size = 0;
779781

780782
int arg_idx = kernelArg->getAssociatedArgNo();
781783
if (kernelArg->needsAllocation()) {
782-
// set to bindless
783-
arg_addrmode = zebin::PreDefinedAttrGetter::ArgAddrMode::bindless;
784+
// bindless
784785
arg_off = payloadPosition;
785786
arg_size = kernelArg->getSize();
786-
} else {
787+
} else if (arg_addrmode == zebin::PreDefinedAttrGetter::ArgAddrMode::stateful) {
787788
// add bti index for this arg if it's stateful
788789
SOpenCLKernelInfo::SResourceInfo resInfo = getResourceInfo(arg_idx);
789790
zebin::ZEInfoBuilder::addBindingTableIndex(m_kernelInfo.m_zeBTIArgs, getBTI(resInfo), arg_idx);
@@ -904,15 +905,16 @@ bool COpenCLKernel::CreateZEPayloadArguments(IGC::KernelArg *kernelArg, uint pay
904905
// sampler
905906
case KernelArg::ArgType::SAMPLER:
906907
case KernelArg::ArgType::BINDLESS_SAMPLER: {
907-
// the sampler arg is either bindless or stateful. check from "kernelArg->needsAllocation()"
908+
// the sampler arg is either bindless or stateful.
908909
// For stateful image argument, the arg has 0 offset and 0 size
909910
// NOTE: we only have stateful sampler now
910-
zebin::PreDefinedAttrGetter::ArgAddrMode arg_addrmode = zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
911+
zebin::PreDefinedAttrGetter::ArgAddrMode arg_addrmode = m_ModuleMetadata->UseBindlessImage
912+
? zebin::PreDefinedAttrGetter::ArgAddrMode::bindless
913+
: zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
911914
uint arg_off = 0;
912915
uint arg_size = 0;
913916
if (kernelArg->needsAllocation()) {
914-
// set to bindless
915-
arg_addrmode = zebin::PreDefinedAttrGetter::ArgAddrMode::bindless;
917+
// bindless
916918
arg_off = payloadPosition;
917919
arg_size = kernelArg->getSize();
918920
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2025 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
// UNSUPPORTED: system-windows
10+
// RUN: ocloc compile -file %s -options "-igc_opts 'DumpZEInfoToConsole=1'" -internal_options "-cl-intel-use-bindless-mode" -device mtl | FileCheck %s
11+
12+
// Check that unused image args arent tagged with 'stateful' addrmode in bindless mode.
13+
14+
// CHECK-NOT: addrmode: stateful
15+
// CHECK-NOT: binding_table_indices:
16+
17+
const sampler_t sampler =
18+
CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
19+
20+
kernel void test(const global float *a,
21+
global float *c,
22+
read_only image2d_t input,
23+
read_only image2d_t unused,
24+
sampler_t sampler
25+
) {
26+
const int gid = get_global_id(0);
27+
28+
int2 coord = {get_global_id(0), get_global_id(1)};
29+
float4 data = read_imagef(input, coord);
30+
c[gid] = a[gid] + data.x;
31+
}

0 commit comments

Comments
 (0)