Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSL: Fix WGSL Functions using wrong type #28690

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Jun 18, 2024

Related issue: #28669

Description

We just fixed the types of properties for WGSL functions, the type of declaration needed the same treatment.

Example:

const a = tslFn( ( [] ) => {

return ivec2();

}).setLayout({ type: 'ivec2', ... })

const b = uniforms([], 'ivec4')

// Later in the shader:
const c = a().x.add(b.x)

// ----- Transpilation ------
// Before this PR, some operations were casting some nodes to float:
const c = a().x.add( float( vec4<i32>(b).x ) ) // <-- breaks because int32 + float32


// After this PR
const c = a().x.add( vec4<i32>(b).x ) // <-- works because int32 + int32

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger changed the title WebGfix wgslNodeFunction layout type overriding to float Jun 18, 2024
@RenaudRohlinger RenaudRohlinger changed the title TSL: WGSL Functions using wrong declaration type Jun 18, 2024
@Mugen87 Mugen87 added this to the r166 milestone Jun 18, 2024
@sunag
Copy link
Collaborator

sunag commented Jun 18, 2024

@RenaudRohlinger I moved outputType into the parser because it is an immutable value.

@sunag sunag merged commit 7ca25bd into mrdoob:dev Jun 18, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants