mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgsl] Add refract built-in
This commit is contained in:
committed by
Teodor Tanasoaia
parent
1be8024bda
commit
9f182ade30
@@ -1582,6 +1582,7 @@ impl<W: Write> Writer<W> {
|
||||
Mf::Normalize => Function::Regular("normalize"),
|
||||
Mf::FaceForward => Function::Regular("faceForward"),
|
||||
Mf::Reflect => Function::Regular("reflect"),
|
||||
Mf::Refract => Function::Regular("refract"),
|
||||
// computational
|
||||
Mf::Sign => Function::Regular("sign"),
|
||||
Mf::Fma => Function::Regular("fma"),
|
||||
|
||||
@@ -178,6 +178,7 @@ pub fn map_standard_fun(word: &str) -> Option<crate::MathFunction> {
|
||||
"normalize" => Mf::Normalize,
|
||||
"faceForward" => Mf::FaceForward,
|
||||
"reflect" => Mf::Reflect,
|
||||
"refract" => Mf::Refract,
|
||||
// computational
|
||||
"sign" => Mf::Sign,
|
||||
"fma" => Mf::Fma,
|
||||
|
||||
@@ -7,6 +7,7 @@ fn main() {
|
||||
let c = degrees(v);
|
||||
let d = radians(v);
|
||||
let e = saturate(v);
|
||||
let g = refract(v, v, f);
|
||||
let const_dot = dot(vec2<i32>(), vec2<i32>());
|
||||
let first_leading_bit_abs = firstLeadingBit(abs(0u));
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ void main() {
|
||||
vec4 c = degrees(v);
|
||||
vec4 d = radians(v);
|
||||
vec4 e = clamp(v, vec4(0.0), vec4(1.0));
|
||||
vec4 g = refract(v, v, 1.0);
|
||||
int const_dot = ( + ivec2(0, 0).x * ivec2(0, 0).x + ivec2(0, 0).y * ivec2(0, 0).y);
|
||||
uint first_leading_bit_abs = uint(findMSB(uint(abs(int(0u)))));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ void main()
|
||||
float4 c = degrees(v);
|
||||
float4 d = radians(v);
|
||||
float4 e = saturate(v);
|
||||
float4 g = refract(v, v, 1.0);
|
||||
int const_dot = dot(int2(0, 0), int2(0, 0));
|
||||
uint first_leading_bit_abs = firstbithigh(abs(0u));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ vertex void main_(
|
||||
metal::float4 c = ((v) * 57.295779513082322865);
|
||||
metal::float4 d = ((v) * 0.017453292519943295474);
|
||||
metal::float4 e = metal::saturate(v);
|
||||
metal::float4 g = metal::refract(v, v, 1.0);
|
||||
int const_dot = ( + const_type_1_.x * const_type_1_.x + const_type_1_.y * const_type_1_.y);
|
||||
uint first_leading_bit_abs = (((metal::clz(metal::abs(0u)) + 1) % 33) - 1);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.1
|
||||
; Generator: rspirv
|
||||
; Bound: 36
|
||||
; Bound: 37
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
@@ -18,7 +18,7 @@ OpEntryPoint Vertex %14 "main"
|
||||
%11 = OpTypeVector %7 2
|
||||
%12 = OpConstantComposite %11 %6 %6
|
||||
%15 = OpTypeFunction %2
|
||||
%26 = OpConstantNull %7
|
||||
%27 = OpConstantNull %7
|
||||
%14 = OpFunction %2 None %15
|
||||
%13 = OpLabel
|
||||
OpBranch %16
|
||||
@@ -31,15 +31,16 @@ OpBranch %16
|
||||
%23 = OpCompositeConstruct %10 %5 %5 %5 %5
|
||||
%24 = OpCompositeConstruct %10 %3 %3 %3 %3
|
||||
%22 = OpExtInst %10 %1 FClamp %17 %23 %24
|
||||
%27 = OpCompositeExtract %7 %12 0
|
||||
%25 = OpExtInst %10 %1 Refract %17 %17 %3
|
||||
%28 = OpCompositeExtract %7 %12 0
|
||||
%29 = OpIMul %7 %27 %28
|
||||
%30 = OpIAdd %7 %26 %29
|
||||
%31 = OpCompositeExtract %7 %12 1
|
||||
%29 = OpCompositeExtract %7 %12 0
|
||||
%30 = OpIMul %7 %28 %29
|
||||
%31 = OpIAdd %7 %27 %30
|
||||
%32 = OpCompositeExtract %7 %12 1
|
||||
%33 = OpIMul %7 %31 %32
|
||||
%25 = OpIAdd %7 %30 %33
|
||||
%34 = OpCopyObject %9 %8
|
||||
%35 = OpExtInst %9 %1 FindUMsb %34
|
||||
%33 = OpCompositeExtract %7 %12 1
|
||||
%34 = OpIMul %7 %32 %33
|
||||
%26 = OpIAdd %7 %31 %34
|
||||
%35 = OpCopyObject %9 %8
|
||||
%36 = OpExtInst %9 %1 FindUMsb %35
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -6,6 +6,7 @@ fn main() {
|
||||
let c = degrees(v);
|
||||
let d = radians(v);
|
||||
let e = saturate(v);
|
||||
let g = refract(v, v, 1.0);
|
||||
let const_dot = dot(vec2<i32>(0, 0), vec2<i32>(0, 0));
|
||||
let first_leading_bit_abs = firstLeadingBit(abs(0u));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user