Skip to content

Commit bf43e7b

Browse files
committed
Dirty fix
1 parent c97e537 commit bf43e7b

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

packages/typegpu/src/data/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ assignInfixOperator(MatBase, 'mul', Operator.star);
4848
};
4949
}
5050

51+
// TODO: Remove this side-effect once we have shaderbits
52+
import { f32 } from './numeric.ts';
53+
// oxlint-disable-next-line typescript/no-explicit-any
54+
(globalThis as any).__TYPEGPU_F32__ = f32;
55+
5156
export { bool, f16, f32, i32, u16, u32 } from './numeric.ts';
5257
export {
5358
isAlignAttrib,

packages/typegpu/src/tgsl/conversion.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,19 @@ function getImplicitConversionRank(src: BaseData, dest: BaseData): ConversionRan
124124
if ((trueSrc.type === 'u32' || trueSrc.type === 'i32') && trueDst.type === 'abstractFloat') {
125125
// When one of the types is a float (abstract or not), we don't want to cast it to a non-float type,
126126
// which would cause it to lose precision. We instead choose the common type to be f32.
127-
return { rank: 1, action: 'cast', targetType: f32 };
127+
128+
// TODO: Remove this side-effect once we have shaderbits
129+
// oxlint-disable-next-line typescript/no-explicit-any
130+
return { rank: 1, action: 'cast', targetType: (globalThis as any).__TYPEGPU_F32__ };
128131
}
129132

130133
if (trueSrc.type === 'abstractFloat') {
131-
if (trueDst.type === 'u32') {
132-
return { rank: 3, action: 'cast', targetType: trueDst };
133-
}
134134
if (trueDst.type === 'i32') {
135135
return { rank: 2, action: 'cast', targetType: trueDst };
136136
}
137+
if (trueDst.type === 'u32') {
138+
return { rank: 3, action: 'cast', targetType: trueDst };
139+
}
137140
}
138141

139142
return INFINITE_RANK;

0 commit comments

Comments
 (0)