Skip to content

Commit ae0b4a8

Browse files
smilczekigcbot
authored andcommitted
Unused bindless image args treated as bindful 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 f3bcfa2 commit ae0b4a8

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,9 @@ namespace IGC
11511151
// the image arg is either bindless or stateful. check from "kernelArg->needsAllocation()"
11521152
// For stateful image argument, the arg has 0 offset and 0 size
11531153
zebin::PreDefinedAttrGetter::ArgAddrMode arg_addrmode =
1154-
zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
1154+
m_ModuleMetadata->UseBindlessImage ?
1155+
zebin::PreDefinedAttrGetter::ArgAddrMode::bindless :
1156+
zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
11551157
uint arg_off = 0;
11561158
uint arg_size = 0;
11571159

@@ -1302,7 +1304,9 @@ namespace IGC
13021304
// For stateful image argument, the arg has 0 offset and 0 size
13031305
// NOTE: we only have stateful sampler now
13041306
zebin::PreDefinedAttrGetter::ArgAddrMode arg_addrmode =
1305-
zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
1307+
m_ModuleMetadata->UseBindlessImage ?
1308+
zebin::PreDefinedAttrGetter::ArgAddrMode::bindless :
1309+
zebin::PreDefinedAttrGetter::ArgAddrMode::stateful;
13061310
uint arg_off = 0;
13071311
uint arg_size = 0;
13081312
if (kernelArg->needsAllocation()) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
16+
const sampler_t sampler =
17+
CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
18+
19+
kernel void test(const global float *a,
20+
global float *c,
21+
read_only image2d_t input,
22+
read_only image2d_t unused,
23+
sampler_t sampler
24+
) {
25+
const int gid = get_global_id(0);
26+
27+
int2 coord = {get_global_id(0), get_global_id(1)};
28+
float4 data = read_imagef(input, coord);
29+
c[gid] = a[gid] + data.x;
30+
}

0 commit comments

Comments
 (0)