(
type: BinaryOpType, useVec4?: boolean)
| 163 | const SUB = 'let resultTemp = a - b;'; |
| 164 | |
| 165 | export function getBinaryOpString( |
| 166 | type: BinaryOpType, useVec4?: boolean): string { |
| 167 | let doOpSnippet: string; |
| 168 | |
| 169 | // Ops with NaN check |
| 170 | do { |
| 171 | switch (type) { |
| 172 | case BinaryOpType.ATAN2: |
| 173 | doOpSnippet = ATAN2; |
| 174 | break; |
| 175 | case BinaryOpType.MAX: |
| 176 | doOpSnippet = MAX; |
| 177 | break; |
| 178 | case BinaryOpType.MIN: |
| 179 | doOpSnippet = MIN; |
| 180 | break; |
| 181 | case BinaryOpType.MOD: |
| 182 | doOpSnippet = useVec4 ? MOD_VEC4 : MOD; |
| 183 | break; |
| 184 | case BinaryOpType.NOT_EQUAL: |
| 185 | doOpSnippet = useVec4 ? NOT_EQUAL_VEC4 : NOT_EQUAL; |
| 186 | break; |
| 187 | case BinaryOpType.POW: |
| 188 | doOpSnippet = useVec4 ? POW_VEC4 : POW; |
| 189 | break; |
| 190 | default: |
| 191 | continue; |
| 192 | } |
| 193 | |
| 194 | let isNaN: string; |
| 195 | let dTypeN: string; |
| 196 | let boolN: string; |
| 197 | if (useVec4) { |
| 198 | isNaN = 'isnanVec4'; |
| 199 | dTypeN = 'vec4<f32>'; |
| 200 | boolN = 'vec4<bool>'; |
| 201 | } else { |
| 202 | isNaN = 'isnan'; |
| 203 | dTypeN = 'f32'; |
| 204 | boolN = 'bool'; |
| 205 | } |
| 206 | |
| 207 | return ` |
| 208 | let aIsNaN = ${isNaN}(a); |
| 209 | let aPostLegalization = select(a, ${dTypeN}(42), aIsNaN); |
| 210 | let bIsNaN = ${isNaN}(b); |
| 211 | let bPostLegalization = select(b, ${dTypeN}(42), bIsNaN); |
| 212 | let isNaN = false; |
| 213 | let valueForNaN = uniforms.NAN; |
| 214 | { |
| 215 | let a = aPostLegalization; |
| 216 | let b = bPostLegalization; |
| 217 | ${doOpSnippet} |
| 218 | return select( |
| 219 | resultTemp, ${dTypeN}(valueForNaN), |
| 220 | ${boolN}(isNaN) | aIsNaN | bIsNaN); |
| 221 | } |
| 222 | `; |
no outgoing calls
no test coverage detected
searching dependent graphs…