mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Add array-in-function-return-type test
This commit is contained in:
committed by
Teodor Tanasoaia
parent
304ba5805c
commit
f31093fb3b
2
tests/in/array-in-function-return-type.param.ron
Normal file
2
tests/in/array-in-function-return-type.param.ron
Normal file
@@ -0,0 +1,2 @@
|
||||
(
|
||||
)
|
||||
9
tests/in/array-in-function-return-type.wgsl
Normal file
9
tests/in/array-in-function-return-type.wgsl
Normal file
@@ -0,0 +1,9 @@
|
||||
fn ret_array() -> array<f32, 2> {
|
||||
return array<f32, 2>(1.0, 2.0);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
let a = ret_array();
|
||||
return vec4<f32>(a[0], a[1], 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 310 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) out vec4 _fs2p_location0;
|
||||
|
||||
float[2] ret_array() {
|
||||
return float[2](1.0, 2.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
float _e0[2] = ret_array();
|
||||
_fs2p_location0 = vec4(_e0[0], _e0[1], 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
23
tests/out/msl/array-in-function-return-type.msl
Normal file
23
tests/out/msl/array-in-function-return-type.msl
Normal file
@@ -0,0 +1,23 @@
|
||||
// language: metal2.0
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using metal::uint;
|
||||
|
||||
struct type_1 {
|
||||
float inner[2];
|
||||
};
|
||||
|
||||
type_1 ret_array(
|
||||
) {
|
||||
return type_1 {1.0, 2.0};
|
||||
}
|
||||
|
||||
struct main_Output {
|
||||
metal::float4 member [[color(0)]];
|
||||
};
|
||||
fragment main_Output main_(
|
||||
) {
|
||||
type_1 _e0 = ret_array();
|
||||
return main_Output { metal::float4(_e0.inner[0], _e0.inner[1], 0.0, 1.0) };
|
||||
}
|
||||
44
tests/out/spv/array-in-function-return-type.spvasm
Normal file
44
tests/out/spv/array-in-function-return-type.spvasm
Normal file
@@ -0,0 +1,44 @@
|
||||
; SPIR-V
|
||||
; Version: 1.1
|
||||
; Generator: rspirv
|
||||
; Bound: 28
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %20 "main" %18
|
||||
OpExecutionMode %20 OriginUpperLeft
|
||||
OpDecorate %6 ArrayStride 4
|
||||
OpDecorate %18 Location 0
|
||||
%2 = OpTypeVoid
|
||||
%4 = OpTypeInt 32 1
|
||||
%3 = OpConstant %4 2
|
||||
%5 = OpTypeFloat 32
|
||||
%8 = OpTypeInt 32 0
|
||||
%7 = OpConstant %8 2
|
||||
%6 = OpTypeArray %5 %7
|
||||
%9 = OpTypeVector %5 4
|
||||
%12 = OpTypeFunction %6
|
||||
%13 = OpConstant %5 1.0
|
||||
%14 = OpConstant %5 2.0
|
||||
%19 = OpTypePointer Output %9
|
||||
%18 = OpVariable %19 Output
|
||||
%21 = OpTypeFunction %2
|
||||
%22 = OpConstant %5 0.0
|
||||
%11 = OpFunction %6 None %12
|
||||
%10 = OpLabel
|
||||
OpBranch %15
|
||||
%15 = OpLabel
|
||||
%16 = OpCompositeConstruct %6 %13 %14
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
||||
%20 = OpFunction %2 None %21
|
||||
%17 = OpLabel
|
||||
OpBranch %23
|
||||
%23 = OpLabel
|
||||
%24 = OpFunctionCall %6 %11
|
||||
%25 = OpCompositeExtract %5 %24 0
|
||||
%26 = OpCompositeExtract %5 %24 1
|
||||
%27 = OpCompositeConstruct %9 %25 %26 %22 %13
|
||||
OpStore %18 %27
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
9
tests/out/wgsl/array-in-function-return-type.wgsl
Normal file
9
tests/out/wgsl/array-in-function-return-type.wgsl
Normal file
@@ -0,0 +1,9 @@
|
||||
fn ret_array() -> array<f32, 2> {
|
||||
return array<f32, 2>(1.0, 2.0);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
let _e0 = ret_array();
|
||||
return vec4<f32>(_e0[0], _e0[1], 0.0, 1.0);
|
||||
}
|
||||
@@ -401,10 +401,15 @@ fn convert_wgsl() {
|
||||
|
||||
let root = env!("CARGO_MANIFEST_DIR");
|
||||
let inputs = [
|
||||
// TODO: merge array-in-ctor and array-in-function-return-type tests after fix HLSL issue https://github.com/gfx-rs/naga/issues/1930
|
||||
(
|
||||
"array-in-ctor",
|
||||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
|
||||
),
|
||||
(
|
||||
"array-in-function-return-type",
|
||||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::WGSL,
|
||||
),
|
||||
(
|
||||
"empty",
|
||||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
|
||||
|
||||
Reference in New Issue
Block a user