mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
feat(const_eval): impl. cos
This commit is contained in:
@@ -44,6 +44,7 @@ Bottom level categories:
|
||||
- Many numeric built-ins have had a constant evaluation implementation added for them, which allows them to be used in a `const` context:
|
||||
- [#4879](https://github.com/gfx-rs/wgpu/pull/4879) by @ErichDonGubler:
|
||||
- `abs`
|
||||
- `cos`
|
||||
- `round`
|
||||
- `saturate`
|
||||
- `sin`
|
||||
|
||||
@@ -834,6 +834,9 @@ impl<'a> ConstantEvaluator<'a> {
|
||||
}
|
||||
)
|
||||
}
|
||||
crate::MathFunction::Cos => {
|
||||
component_wise_float!(self, span, [arg], |e| { Ok([e.cos()]) })
|
||||
}
|
||||
crate::MathFunction::Round => {
|
||||
// TODO: Use `f{32,64}.round_ties_even()` when available on stable. This polyfill
|
||||
// is shamelessly [~~stolen from~~ inspired by `ndarray-image`][polyfill source],
|
||||
|
||||
@@ -366,10 +366,10 @@ OpName %91 "x12"
|
||||
OpName %94 "m"
|
||||
OpName %203 "p"
|
||||
OpName %204 "fbm"
|
||||
OpName %210 "x"
|
||||
OpName %212 "v"
|
||||
OpName %214 "a"
|
||||
OpName %215 "i"
|
||||
OpName %212 "x"
|
||||
OpName %214 "v"
|
||||
OpName %216 "a"
|
||||
OpName %217 "i"
|
||||
OpName %255 "p"
|
||||
OpName %256 "min_max_height"
|
||||
OpName %257 "terrain_point"
|
||||
@@ -575,10 +575,12 @@ OpDecorate %582 Location 0
|
||||
%206 = OpConstant %5 0.01
|
||||
%207 = OpConstant %5 100.0
|
||||
%208 = OpConstantComposite %6 %207 %207
|
||||
%209 = OpConstant %5 0.47942555
|
||||
%211 = OpConstantNull %6
|
||||
%213 = OpTypePointer Function %5
|
||||
%216 = OpTypePointer Function %8
|
||||
%209 = OpConstant %5 0.87758255
|
||||
%210 = OpConstant %5 0.47942555
|
||||
%211 = OpConstantComposite %6 %209 %210
|
||||
%213 = OpConstantNull %6
|
||||
%215 = OpTypePointer Function %5
|
||||
%218 = OpTypePointer Function %8
|
||||
%258 = OpTypeFunction %4 %6 %6
|
||||
%271 = OpTypeFunction %14 %6 %6
|
||||
%272 = OpConstant %5 0.1
|
||||
@@ -836,27 +838,24 @@ OpFunctionEnd
|
||||
%204 = OpFunction %5 None %68
|
||||
%203 = OpFunctionParameter %6
|
||||
%202 = OpLabel
|
||||
%212 = OpVariable %213 Function %74
|
||||
%215 = OpVariable %216 Function %135
|
||||
%210 = OpVariable %87 Function %211
|
||||
%214 = OpVariable %213 Function %78
|
||||
OpBranch %217
|
||||
%217 = OpLabel
|
||||
%214 = OpVariable %215 Function %74
|
||||
%217 = OpVariable %218 Function %135
|
||||
%212 = OpVariable %87 Function %213
|
||||
%216 = OpVariable %215 Function %78
|
||||
OpBranch %219
|
||||
%219 = OpLabel
|
||||
OpLine %3 36 13
|
||||
%218 = OpVectorTimesScalar %6 %203 %206
|
||||
%220 = OpVectorTimesScalar %6 %203 %206
|
||||
OpLine %3 36 5
|
||||
OpStore %210 %218
|
||||
OpStore %212 %220
|
||||
OpLine %3 39 17
|
||||
OpLine %3 40 24
|
||||
%219 = OpExtInst %5 %1 Cos %78
|
||||
OpLine %3 40 14
|
||||
%220 = OpCompositeConstruct %6 %219 %209
|
||||
OpLine %3 41 15
|
||||
%221 = OpCompositeExtract %5 %220 0
|
||||
%222 = OpCompositeExtract %5 %220 1
|
||||
%223 = OpCompositeExtract %5 %220 1
|
||||
%221 = OpCompositeExtract %5 %211 0
|
||||
%222 = OpCompositeExtract %5 %211 1
|
||||
%223 = OpCompositeExtract %5 %211 1
|
||||
%224 = OpFNegate %5 %223
|
||||
%225 = OpCompositeExtract %5 %220 0
|
||||
%225 = OpCompositeExtract %5 %211 0
|
||||
%226 = OpCompositeConstruct %6 %221 %222
|
||||
%227 = OpCompositeConstruct %6 %224 %225
|
||||
%228 = OpCompositeConstruct %9 %226 %227
|
||||
@@ -867,7 +866,7 @@ OpLoopMerge %230 %232 None
|
||||
OpBranch %231
|
||||
%231 = OpLabel
|
||||
OpLine %3 43 22
|
||||
%233 = OpLoad %8 %215
|
||||
%233 = OpLoad %8 %217
|
||||
%234 = OpULessThan %112 %233 %205
|
||||
OpLine %3 43 21
|
||||
OpSelectionMerge %235 None
|
||||
@@ -878,44 +877,44 @@ OpBranch %230
|
||||
OpBranch %237
|
||||
%237 = OpLabel
|
||||
OpLine %3 1 1
|
||||
%239 = OpLoad %5 %212
|
||||
%240 = OpLoad %5 %214
|
||||
%241 = OpLoad %6 %210
|
||||
%239 = OpLoad %5 %214
|
||||
%240 = OpLoad %5 %216
|
||||
%241 = OpLoad %6 %212
|
||||
OpLine %3 44 21
|
||||
%242 = OpFunctionCall %5 %67 %241
|
||||
OpLine %3 44 13
|
||||
%243 = OpFMul %5 %240 %242
|
||||
%244 = OpFAdd %5 %239 %243
|
||||
OpLine %3 44 9
|
||||
OpStore %212 %244
|
||||
OpStore %214 %244
|
||||
OpLine %3 45 13
|
||||
%245 = OpLoad %6 %210
|
||||
%245 = OpLoad %6 %212
|
||||
%246 = OpMatrixTimesVector %6 %228 %245
|
||||
OpLine %3 45 13
|
||||
%247 = OpVectorTimesScalar %6 %246 %81
|
||||
%248 = OpFAdd %6 %247 %208
|
||||
OpLine %3 45 9
|
||||
OpStore %210 %248
|
||||
OpStore %212 %248
|
||||
OpLine %3 1 1
|
||||
%249 = OpLoad %5 %214
|
||||
%249 = OpLoad %5 %216
|
||||
OpLine %3 46 13
|
||||
%250 = OpFMul %5 %249 %78
|
||||
OpLine %3 46 9
|
||||
OpStore %214 %250
|
||||
OpStore %216 %250
|
||||
OpBranch %238
|
||||
%238 = OpLabel
|
||||
OpBranch %232
|
||||
%232 = OpLabel
|
||||
OpLine %3 1 1
|
||||
%251 = OpLoad %8 %215
|
||||
%251 = OpLoad %8 %217
|
||||
OpLine %3 43 43
|
||||
%252 = OpIAdd %8 %251 %126
|
||||
OpLine %3 43 39
|
||||
OpStore %215 %252
|
||||
OpStore %217 %252
|
||||
OpBranch %229
|
||||
%230 = OpLabel
|
||||
OpLine %3 1 1
|
||||
%253 = OpLoad %5 %212
|
||||
%253 = OpLoad %5 %214
|
||||
OpReturnValue %253
|
||||
OpFunctionEnd
|
||||
%257 = OpFunction %4 None %258
|
||||
@@ -1193,8 +1192,8 @@ OpReturn
|
||||
OpFunctionEnd
|
||||
%465 = OpFunction %2 None %346
|
||||
%453 = OpLabel
|
||||
%468 = OpVariable %213 Function %74
|
||||
%469 = OpVariable %216 Function %135
|
||||
%468 = OpVariable %215 Function %74
|
||||
%469 = OpVariable %218 Function %135
|
||||
%456 = OpLoad %8 %455
|
||||
%459 = OpLoad %7 %457
|
||||
%462 = OpLoad %6 %460
|
||||
|
||||
Reference in New Issue
Block a user