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

[glsl-out] Add built-in functions to keywords #2410

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

fornwall
Copy link
Contributor

Add built-in functions to keywords. Fixes #2276 and part of gfx-rs/wgpu#4555.

As the comment shows this is taken from https://dawn.googlesource.com/dawn/+/refs/heads/main/src/tint/lang/wgsl/ast/transform/renamer.cc#39 - is that ok? Any ideas for a reference of this?

List of removed keywords:

  • Rect
  • uimage2DMSArraystruct

List of added keywords:

  • abs
  • acos
  • acosh
  • all
  • any
  • asin
  • asinh
  • atan
  • atanh
  • atomicAdd
  • atomicAnd
  • atomicCompSwap
  • atomicCounter
  • atomicCounterDecrement
  • atomicCounterIncrement
  • atomicExchange
  • atomicMax
  • atomicMin
  • atomicOr
  • atomicXor
  • barrier
  • bitCount
  • bitfieldExtract
  • bitfieldInsert
  • bitfieldReverse
  • ceil
  • clamp
  • cos
  • cosh
  • cross
  • dFdx
  • dFdy
  • degrees
  • determinant
  • distance
  • dot
  • equal
  • exp
  • exp2
  • faceforward
  • findLSB
  • findMSB
  • floatBitsToInt
  • floatBitsToUint
  • floor
  • fract
  • frexp
  • fwidth
  • gl_BaseInstance
  • gl_BaseVertex
  • gl_ClipDistance
  • gl_DepthRangeParameters
  • gl_DrawID
  • gl_FragCoord
  • gl_FragDepth
  • gl_FrontFacing
  • gl_GlobalInvocationID
  • gl_InstanceID
  • gl_LocalInvocationID
  • gl_LocalInvocationIndex
  • gl_NumSamples
  • gl_NumWorkGroups
  • gl_PerVertex
  • gl_PointCoord
  • gl_PointSize
  • gl_Position
  • gl_PrimitiveID
  • gl_SampleID
  • gl_SampleMask
  • gl_SampleMaskIn
  • gl_SamplePosition
  • gl_VertexID
  • gl_WorkGroupID
  • gl_WorkGroupSize
  • greaterThan
  • greaterThanEqual
  • groupMemoryBarrier
  • imageLoad
  • imageSize
  • imageStore
  • imulExtended
  • intBitsToFloat
  • inverse
  • inversesqrt
  • isampler2DRect
  • isinf
  • isnan
  • ldexp
  • length
  • lessThan
  • lessThanEqual
  • log
  • log2
  • matrixCompMult
  • max
  • memoryBarrier
  • memoryBarrierAtomicCounter
  • memoryBarrierBuffer
  • memoryBarrierImage
  • memoryBarrierShared
  • min
  • mix
  • mod
  • modf
  • normalize
  • not
  • notEqual
  • outerProduct
  • packHalf2x16
  • packSnorm2x16
  • packSnorm4x8
  • packUnorm2x16
  • packUnorm4x8
  • pow
  • radians
  • reflect
  • refract
  • round
  • roundEven
  • sign
  • sin
  • sinh
  • smoothstep
  • sqrt
  • step
  • struct
  • tan
  • tanh
  • texelFetch
  • texelFetchOffset
  • texture
  • textureGather
  • textureGatherOffset
  • textureGrad
  • textureGradOffset
  • textureLod
  • textureLodOffset
  • textureOffset
  • textureProj
  • textureProjGrad
  • textureProjGradOffset
  • textureProjLod
  • textureProjLodOffset
  • textureProjOffset
  • textureSize
  • transpose
  • trunc
  • uaddCarry
  • uimage2DMSArray
  • uintBitsToFloat
  • umulExtended
  • unpackHalf2x16
  • unpackSnorm2x16
  • unpackSnorm4x8
  • unpackUnorm2x16
  • unpackUnorm4x8
  • usubBorrow

@teoxoy
Copy link
Member

teoxoy commented Jul 25, 2023

Thanks for the PR!

While looking it over, I ended up checking the spec repo and documented where the keywords come from (also adding a few missing ones).

I also removed the ones starting with gl_ since identifiers starting with that prefix are reserved according to the spec and also our current impl.

&["gl_"],

@teoxoy
Copy link
Member

teoxoy commented Jul 25, 2023

Let me know if it looks good, and we can land it.

@teoxoy
Copy link
Member

teoxoy commented Jul 25, 2023

Related: We should be renaming identifiers containing two consecutive underscores (see #2412).

@fornwall
Copy link
Contributor Author

@teoxoy Looks good to me, nice work with the references!

I also removed the ones starting with gl_ since identifiers starting with that prefix are reserved according to the spec and also our current impl.

Aha, didn't know that, thanks for the pointer!

@teoxoy teoxoy merged commit dcce919 into gfx-rs:master Jul 25, 2023
5 checks passed
@fornwall fornwall deleted the more-glsl-keywords branch August 5, 2023 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[glsl-out] Declaring a variable called "texture" leads to a translation error under certain conditions
2 participants