@@ -223,6 +223,92 @@ describe('wgslGenerator with console.log', () => {
223223 ` ) ;
224224 } ) ;
225225
226+ it ( 'Works for shellless entry functions' , ( { root } ) => {
227+ const myLog = ( n : number ) => {
228+ 'use gpu' ;
229+ console . log ( n ) ;
230+ } ;
231+
232+ const vs = ( ) => {
233+ 'use gpu' ;
234+ myLog ( 6 ) ;
235+ return { pos : d . vec4f ( ) } ;
236+ } ;
237+ const fs = ( ) => {
238+ 'use gpu' ;
239+ myLog ( 7 ) ;
240+ return d . vec4f ( ) ;
241+ } ;
242+
243+ const pipeline = root . createRenderPipeline ( {
244+ vertex : vs ,
245+ fragment : fs ,
246+ targets : { format : 'rg8unorm' } ,
247+ } ) ;
248+
249+ expect ( tgpu . resolve ( [ pipeline ] ) ) . toMatchInlineSnapshot ( `
250+ "fn myLog(n: i32) {
251+ /* console.log() */;
252+ }
253+
254+ struct VertexOut {
255+ @location(0) pos: vec4f,
256+ }
257+
258+ @vertex fn vs() -> VertexOut {
259+ myLog(6i);
260+ return VertexOut(vec4f());
261+ }
262+
263+ @group(0) @binding(0) var<storage, read_write> indexBuffer: atomic<u32>;
264+
265+ struct SerializedLogData {
266+ id: u32,
267+ serializedData: array<u32, 63>,
268+ }
269+
270+ @group(0) @binding(1) var<storage, read_write> dataBuffer: array<SerializedLogData, 64>;
271+
272+ var<private> dataBlockIndex: u32;
273+
274+ var<private> dataByteIndex: u32;
275+
276+ fn nextByteIndex() -> u32{
277+ let i = dataByteIndex;
278+ dataByteIndex = dataByteIndex + 1u;
279+ return i;
280+ }
281+
282+ fn serializeI32(n: i32) {
283+ dataBuffer[dataBlockIndex].serializedData[nextByteIndex()] = bitcast<u32>(n);
284+ }
285+
286+ fn log1serializer(_arg_0: i32) {
287+ serializeI32(_arg_0);
288+ }
289+
290+ fn log1(_arg_0: i32) {
291+ dataBlockIndex = atomicAdd(&indexBuffer, 1);
292+ if (dataBlockIndex >= 64) {
293+ return;
294+ }
295+ dataBuffer[dataBlockIndex].id = 1;
296+ dataByteIndex = 0;
297+
298+ log1serializer(_arg_0);
299+ }
300+
301+ fn myLog_1(n: i32) {
302+ log1(n);
303+ }
304+
305+ @fragment fn fs() -> @location(0) vec4f {
306+ myLog_1(7i);
307+ return vec4f();
308+ }"
309+ ` ) ;
310+ } ) ;
311+
226312 it ( 'Parses a single console.log in a compute pipeline' , ( { root } ) => {
227313 const fn = tgpu . computeFn ( {
228314 workgroupSize : [ 1 ] ,
0 commit comments