dot
이 페이지에서

dot()

함수, 내장 함수 분류

dot(a, b): dot product, vector to scalar.

import { dot } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

function dot<K extends `vec${number}<f64>`>(
a: ReadonlyNode<K>,
b: NoInfer<ReadonlyNode<K>>,
): Node<'f64'>;
function dot<K extends `vec${number}<i32>`>(
a: ReadonlyNode<K>,
b: NoInfer<ReadonlyNode<K>>,
): Node<'i32'>;
function dot<K extends `vec${number}<u32>`>(
a: ReadonlyNode<K>,
b: NoInfer<ReadonlyNode<K>>,
): Node<'u32'>;
function dot<K extends `vec${number}<f32>`>(
a: ReadonlyNode<K>,
b: NoInfer<ReadonlyNode<K>>,
): Node<'f32'>;

매개변수

a ReadonlyNode<K>
b NoInfer<ReadonlyNode<K>>

반환값

Node<'f64'>

설명

Like length, the return precision follows the operand key: f32 vectors return f32, emulated-double vec${N}<f64> vectors return f64. Both operands share one key, so dot(v2, v3) is a tsc error.

An integer dot returns that integer kind and takes the dotI / dotU id, because GLSL ES 3.00 has no integer dot at all and a WebGL2 driver refuses the call; the ids carry a GLSL column that expands to the multiply-add the spelling is missing. The choice is divergentIntegerId, shared with the "use typeshade" front end.

예제

예제

import { fn, dot, vec3, f32T } from 'typeshade'
const luma = fn('luma', { x: f32T }, ({ x }) => dot(vec3(x, x, x), vec3(0.2, 0.7, 0.1)))

대상별 지원

대상지원비고
WGSL (WebGPU) 지원

dot(a, b). Over f64 operands the fp64 pass rewrites it into its df64 helper.

GLSL ES 3.00 (WebGL2) 지원

dot(a, b). Over f64 operands the fp64 pass rewrites it into its df64 helper.

CPU 오라클 지원

Evaluated in f64 by the oracle.

관련 가이드

함께 보기

소스

src/core/ir/node.ts, 1821행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고