-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[naga wgsl-in] Allow abstract literals to be used as return values #7035
Open
jamienicol
wants to merge
1
commit into
gfx-rs:trunk
Choose a base branch
from
jamienicol:abstract-return
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+288
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@compute @workgroup_size(1) | ||
fn main() {} | ||
|
||
fn return_i32_ai() -> i32 { | ||
return 1; | ||
} | ||
|
||
fn return_u32_ai() -> u32 { | ||
return 1; | ||
} | ||
|
||
fn return_f32_ai() -> f32 { | ||
return 1; | ||
} | ||
|
||
fn return_f32_af() -> f32 { | ||
return 1.0; | ||
} | ||
|
||
fn return_vec2f32_ai() -> vec2<f32> { | ||
return vec2(1); | ||
} | ||
|
||
fn return_arrf32_ai() -> array<f32, 4> { | ||
return array(1, 1, 1, 1); | ||
} |
36 changes: 36 additions & 0 deletions
36
naga/tests/out/glsl/abstract-types-return.main.Compute.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#version 310 es | ||
|
||
precision highp float; | ||
precision highp int; | ||
|
||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; | ||
|
||
|
||
int return_i32_ai() { | ||
return 1; | ||
} | ||
|
||
uint return_u32_ai() { | ||
return 1u; | ||
} | ||
|
||
float return_f32_ai() { | ||
return 1.0; | ||
} | ||
|
||
float return_f32_af() { | ||
return 1.0; | ||
} | ||
|
||
vec2 return_vec2f32_ai() { | ||
return vec2(1.0); | ||
} | ||
|
||
float[4] return_arrf32_ai() { | ||
return float[4](1.0, 1.0, 1.0, 1.0); | ||
} | ||
|
||
void main() { | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
int return_i32_ai() | ||
{ | ||
return 1; | ||
} | ||
|
||
uint return_u32_ai() | ||
{ | ||
return 1u; | ||
} | ||
|
||
float return_f32_ai() | ||
{ | ||
return 1.0; | ||
} | ||
|
||
float return_f32_af() | ||
{ | ||
return 1.0; | ||
} | ||
|
||
float2 return_vec2f32_ai() | ||
{ | ||
return (1.0).xx; | ||
} | ||
|
||
typedef float ret_Constructarray4_float_[4]; | ||
ret_Constructarray4_float_ Constructarray4_float_(float arg0, float arg1, float arg2, float arg3) { | ||
float ret[4] = { arg0, arg1, arg2, arg3 }; | ||
return ret; | ||
} | ||
|
||
typedef float ret_return_arrf32_ai[4]; | ||
ret_return_arrf32_ai return_arrf32_ai() | ||
{ | ||
return Constructarray4_float_(1.0, 1.0, 1.0, 1.0); | ||
} | ||
|
||
[numthreads(1, 1, 1)] | ||
void main() | ||
{ | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
( | ||
vertex:[ | ||
], | ||
fragment:[ | ||
], | ||
compute:[ | ||
( | ||
entry_point:"main", | ||
target_profile:"cs_5_1", | ||
), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// language: metal1.0 | ||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using metal::uint; | ||
|
||
struct type_4 { | ||
float inner[4]; | ||
}; | ||
|
||
int return_i32_ai( | ||
) { | ||
return 1; | ||
} | ||
|
||
uint return_u32_ai( | ||
) { | ||
return 1u; | ||
} | ||
|
||
float return_f32_ai( | ||
) { | ||
return 1.0; | ||
} | ||
|
||
float return_f32_af( | ||
) { | ||
return 1.0; | ||
} | ||
|
||
metal::float2 return_vec2f32_ai( | ||
) { | ||
return metal::float2(1.0); | ||
} | ||
|
||
type_4 return_arrf32_ai( | ||
) { | ||
return type_4 {1.0, 1.0, 1.0, 1.0}; | ||
} | ||
|
||
kernel void main_( | ||
) { | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
; SPIR-V | ||
; Version: 1.1 | ||
; Generator: rspirv | ||
; Bound: 41 | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint GLCompute %38 "main" | ||
OpExecutionMode %38 LocalSize 1 1 1 | ||
OpDecorate %7 ArrayStride 4 | ||
%2 = OpTypeVoid | ||
%3 = OpTypeInt 32 1 | ||
%4 = OpTypeInt 32 0 | ||
%5 = OpTypeFloat 32 | ||
%6 = OpTypeVector %5 2 | ||
%8 = OpConstant %4 4 | ||
%7 = OpTypeArray %5 %8 | ||
%11 = OpTypeFunction %3 | ||
%12 = OpConstant %3 1 | ||
%16 = OpTypeFunction %4 | ||
%17 = OpConstant %4 1 | ||
%21 = OpTypeFunction %5 | ||
%22 = OpConstant %5 1.0 | ||
%29 = OpTypeFunction %6 | ||
%30 = OpConstantComposite %6 %22 %22 | ||
%34 = OpTypeFunction %7 | ||
%35 = OpConstantComposite %7 %22 %22 %22 %22 | ||
%39 = OpTypeFunction %2 | ||
%10 = OpFunction %3 None %11 | ||
%9 = OpLabel | ||
OpBranch %13 | ||
%13 = OpLabel | ||
OpReturnValue %12 | ||
OpFunctionEnd | ||
%15 = OpFunction %4 None %16 | ||
%14 = OpLabel | ||
OpBranch %18 | ||
%18 = OpLabel | ||
OpReturnValue %17 | ||
OpFunctionEnd | ||
%20 = OpFunction %5 None %21 | ||
%19 = OpLabel | ||
OpBranch %23 | ||
%23 = OpLabel | ||
OpReturnValue %22 | ||
OpFunctionEnd | ||
%25 = OpFunction %5 None %21 | ||
%24 = OpLabel | ||
OpBranch %26 | ||
%26 = OpLabel | ||
OpReturnValue %22 | ||
OpFunctionEnd | ||
%28 = OpFunction %6 None %29 | ||
%27 = OpLabel | ||
OpBranch %31 | ||
%31 = OpLabel | ||
OpReturnValue %30 | ||
OpFunctionEnd | ||
%33 = OpFunction %7 None %34 | ||
%32 = OpLabel | ||
OpBranch %36 | ||
%36 = OpLabel | ||
OpReturnValue %35 | ||
OpFunctionEnd | ||
%38 = OpFunction %2 None %39 | ||
%37 = OpLabel | ||
OpBranch %40 | ||
%40 = OpLabel | ||
OpReturn | ||
OpFunctionEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
fn return_i32_ai() -> i32 { | ||
return 1i; | ||
} | ||
|
||
fn return_u32_ai() -> u32 { | ||
return 1u; | ||
} | ||
|
||
fn return_f32_ai() -> f32 { | ||
return 1f; | ||
} | ||
|
||
fn return_f32_af() -> f32 { | ||
return 1f; | ||
} | ||
|
||
fn return_vec2f32_ai() -> vec2<f32> { | ||
return vec2(1f); | ||
} | ||
|
||
fn return_arrf32_ai() -> array<f32, 4> { | ||
return array<f32, 4>(1f, 1f, 1f, 1f); | ||
} | ||
|
||
@compute @workgroup_size(1, 1, 1) | ||
fn main() { | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimblandy I'm avoiding calling
try_automatic_conversions()
here for non-abstract types, as otherwise I saw in one of the tests that this code:used to fail with this error:
but would now fail with:
which is less clear.
Would it make sense to have this check as part of
try_automatic_conversions()
? Do we ever convert from things that are not abstract?