Add snapshots for function.wgsl

This commit is contained in:
Joshua Groves
2020-12-09 01:16:23 -03:30
committed by Dzmitry Malyshau
parent 51cdb0403a
commit d71ebe2881
5 changed files with 77 additions and 0 deletions

View File

@@ -116,3 +116,9 @@ fn converts_wgsl_quad() {
fn converts_wgsl_simple() {
convert_wgsl("simple");
}
#[cfg(feature = "wgsl-in")]
#[test]
fn converts_wgsl_function() {
convert_wgsl("function");
}

View File

@@ -0,0 +1,5 @@
(
spv_capabilities: [ Shader ],
mtl_bindings: {
}
)

View File

@@ -0,0 +1,8 @@
fn test_function(test: f32) -> f32 {
return test;
}
[[stage(vertex)]]
fn main() -> void {
var test: f32 = test_function(1.0);
}

View File

@@ -0,0 +1,27 @@
---
source: tests/snapshots.rs
expression: msl
---
#include <metal_stdlib>
#include <simd/simd.h>
typedef float type;
type test_function(
type test
) {
return test;
}
struct main1Input {
};
struct main1Output {
};
vertex main1Output main1(
main1Input input [[stage_in]]
) {
main1Output output;
type test1;
test1 = test_function(1.0);
return output;
}

View File

@@ -0,0 +1,31 @@
---
source: tests/snapshots.rs
expression: dis
---
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 16
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %11 "main"
%2 = OpTypeFloat 32
%4 = OpTypePointer Function %2
%6 = OpTypeFunction %2 %4
%10 = OpTypeVoid
%12 = OpTypeFunction %10
%15 = OpConstant %2 1.0
%5 = OpFunction %2 None %6
%3 = OpFunctionParameter %4
%7 = OpLabel
%8 = OpLoad %2 %3
OpReturnValue %8
OpFunctionEnd
%11 = OpFunction %10 None %12
%13 = OpLabel
%9 = OpVariable %4 Function
%14 = OpFunctionCall %2 %5 %15
OpStore %9 %14
OpReturn
OpFunctionEnd