Skip to content

Commit

Permalink
[naga] New tests for GLSL double-precision builtin functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Nov 14, 2023
1 parent eecbb82 commit ee70980
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 0 deletions.
41 changes: 41 additions & 0 deletions naga/tests/in/glsl/double-math-functions.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#version 450

void main() {
dvec4 a = dvec4(1.0);
dvec4 b = dvec4(2.0);
dmat4 m = dmat4(a, b, a, b);
int i = 5;

dvec4 ceilOut = ceil(a);
dvec4 roundOut = round(a);
dvec4 floorOut = floor(a);
dvec4 fractOut = fract(a);
dvec4 truncOut = trunc(a);
dvec4 absOut = abs(a);
dvec4 sqrtOut = sqrt(a);
dvec4 inversesqrtOut = inversesqrt(a);
dvec4 signOut = sign(a);
dmat4 transposeOut = transpose(m);
// TODO: support inverse function in wgsl output
// dmat4 inverseOut = inverse(m);
dvec4 normalizeOut = normalize(a);
double lengthOut = length(a);
double determinantOut = determinant(m);
double modOut = mod(a.x, b.x);
double dotOut = dot(a, b);
dvec4 maxOut = max(a, b);
dvec4 minOut = min(a, b);
dvec4 reflectOut = reflect(a, b);
dvec3 crossOut = cross(a.xyz, b.xyz);
// TODO: support outerProduct function in wgsl output
// dmat4 outerProductOut = outerProduct(a, b);
double distanceOut = distance(a, b);
dvec4 stepOut = step(a, b);
// TODO: support out params in wgsl output
// dvec4 modfOut = modf(a, b);
// dvec4 frexpOut = frexp(a, b);
double ldexpOut = ldexp(a.x, i);
double smoothStepScalar = smoothstep(0.0, 1.0, 0.5);
dvec4 smoothStepVector = smoothstep(dvec4(0.0), dvec4(1.0), dvec4(0.5));
dvec4 smoothStepMixed = smoothstep(0.0, 1.0, dvec4(0.5));
}
107 changes: 107 additions & 0 deletions naga/tests/out/wgsl/double-math-functions.frag.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
fn main_1() {
var a: vec4<f64>;
var b: vec4<f64>;
var m: mat4x4<f64>;
var i: i32 = 5;
var ceilOut: vec4<f64>;
var roundOut: vec4<f64>;
var floorOut: vec4<f64>;
var fractOut: vec4<f64>;
var truncOut: vec4<f64>;
var absOut: vec4<f64>;
var sqrtOut: vec4<f64>;
var inversesqrtOut: vec4<f64>;
var signOut: vec4<f64>;
var transposeOut: mat4x4<f64>;
var normalizeOut: vec4<f64>;
var lengthOut: f64;
var determinantOut: f64;
var modOut: f64;
var dotOut: f64;
var maxOut: vec4<f64>;
var minOut: vec4<f64>;
var reflectOut: vec4<f64>;
var crossOut: vec3<f64>;
var distanceOut: f64;
var stepOut: vec4<f64>;
var ldexpOut: f64;
var smoothStepScalar: f64;
var smoothStepVector: vec4<f64>;
var smoothStepMixed: vec4<f64>;

a = vec4(f64(1.0));
b = vec4(f64(2.0));
let _e8 = a;
let _e9 = b;
let _e10 = a;
let _e11 = b;
m = mat4x4<f64>(vec4<f64>(_e8.x, _e8.y, _e8.z, _e8.w), vec4<f64>(_e9.x, _e9.y, _e9.z, _e9.w), vec4<f64>(_e10.x, _e10.y, _e10.z, _e10.w), vec4<f64>(_e11.x, _e11.y, _e11.z, _e11.w));
let _e37 = a;
ceilOut = ceil(_e37);
let _e41 = a;
roundOut = round(_e41);
let _e45 = a;
floorOut = floor(_e45);
let _e49 = a;
fractOut = fract(_e49);
let _e53 = a;
truncOut = trunc(_e53);
let _e57 = a;
absOut = abs(_e57);
let _e61 = a;
sqrtOut = sqrt(_e61);
let _e65 = a;
inversesqrtOut = inverseSqrt(_e65);
let _e69 = a;
signOut = sign(_e69);
let _e73 = m;
transposeOut = transpose(_e73);
let _e77 = a;
normalizeOut = normalize(_e77);
let _e81 = a;
lengthOut = length(_e81);
let _e85 = m;
determinantOut = determinant(_e85);
let _e88 = a;
let _e90 = b;
let _e92 = a;
let _e94 = b;
modOut = (_e92.x - (floor((_e92.x / _e94.x)) * _e94.x));
let _e103 = a;
let _e104 = b;
dotOut = dot(_e103, _e104);
let _e109 = a;
let _e110 = b;
maxOut = max(_e109, _e110);
let _e115 = a;
let _e116 = b;
minOut = min(_e115, _e116);
let _e121 = a;
let _e122 = b;
reflectOut = reflect(_e121, _e122);
let _e125 = a;
let _e127 = b;
let _e129 = a;
let _e131 = b;
crossOut = cross(_e129.xyz, _e131.xyz);
let _e137 = a;
let _e138 = b;
distanceOut = distance(_e137, _e138);
let _e143 = a;
let _e144 = b;
stepOut = step(_e143, _e144);
let _e147 = a;
let _e150 = a;
let _e152 = i;
ldexpOut = ldexp(_e150.x, _e152);
smoothStepScalar = f64(smoothstep(0.0, 1.0, 0.5));
smoothStepVector = smoothstep(vec4(f64(0.0)), vec4(f64(1.0)), vec4(f64(0.5)));
smoothStepMixed = smoothstep(vec4(f64(0.0)), vec4(f64(1.0)), vec4(f64(0.5)));
return;
}

@fragment
fn main() {
main_1();
return;
}

0 comments on commit ee70980

Please sign in to comment.