-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[glsl/spv-out] Cull functions that should not be available for a give…
…n stage (#2531)
- Loading branch information
Showing
9 changed files
with
164 additions
and
0 deletions.
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,6 @@ | ||
( | ||
spv: ( | ||
version: (1, 0), | ||
separate_entry_points: true, | ||
), | ||
) |
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,23 @@ | ||
// only available in the fragment stage | ||
fn derivatives() { | ||
let x = dpdx(0.0); | ||
let y = dpdy(0.0); | ||
let width = fwidth(0.0); | ||
} | ||
|
||
// only available in the compute stage | ||
fn barriers() { | ||
storageBarrier(); | ||
workgroupBarrier(); | ||
} | ||
|
||
@fragment | ||
fn fragment() -> @location(0) vec4<f32> { | ||
derivatives(); | ||
return vec4<f32>(); | ||
} | ||
|
||
@compute @workgroup_size(1) | ||
fn compute() { | ||
barriers(); | ||
} |
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,21 @@ | ||
#version 310 es | ||
|
||
precision highp float; | ||
precision highp int; | ||
|
||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; | ||
|
||
|
||
void barriers() { | ||
memoryBarrierBuffer(); | ||
barrier(); | ||
memoryBarrierShared(); | ||
barrier(); | ||
return; | ||
} | ||
|
||
void main() { | ||
barriers(); | ||
return; | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
tests/out/glsl/separate-entry-points.fragment.Fragment.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,19 @@ | ||
#version 310 es | ||
|
||
precision highp float; | ||
precision highp int; | ||
|
||
layout(location = 0) out vec4 _fs2p_location0; | ||
|
||
void derivatives() { | ||
float x = dFdx(0.0); | ||
float y = dFdy(0.0); | ||
float width = fwidth(0.0); | ||
} | ||
|
||
void main() { | ||
derivatives(); | ||
_fs2p_location0 = vec4(0.0); | ||
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,33 @@ | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Generator: rspirv | ||
; Bound: 18 | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint GLCompute %15 "compute" | ||
OpExecutionMode %15 LocalSize 1 1 1 | ||
%2 = OpTypeVoid | ||
%4 = OpTypeFloat 32 | ||
%3 = OpTypeVector %4 4 | ||
%7 = OpTypeFunction %2 | ||
%10 = OpTypeInt 32 0 | ||
%9 = OpConstant %10 2 | ||
%11 = OpConstant %10 1 | ||
%12 = OpConstant %10 72 | ||
%13 = OpConstant %10 264 | ||
%6 = OpFunction %2 None %7 | ||
%5 = OpLabel | ||
OpBranch %8 | ||
%8 = OpLabel | ||
OpControlBarrier %9 %11 %12 | ||
OpControlBarrier %9 %9 %13 | ||
OpReturn | ||
OpFunctionEnd | ||
%15 = OpFunction %2 None %7 | ||
%14 = OpLabel | ||
OpBranch %16 | ||
%16 = OpLabel | ||
%17 = OpFunctionCall %2 %6 | ||
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,35 @@ | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Generator: rspirv | ||
; Bound: 20 | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint Fragment %16 "fragment" %14 | ||
OpExecutionMode %16 OriginUpperLeft | ||
OpDecorate %14 Location 0 | ||
%2 = OpTypeVoid | ||
%4 = OpTypeFloat 32 | ||
%3 = OpTypeVector %4 4 | ||
%7 = OpTypeFunction %2 | ||
%8 = OpConstant %4 0.0 | ||
%15 = OpTypePointer Output %3 | ||
%14 = OpVariable %15 Output | ||
%17 = OpConstantNull %3 | ||
%6 = OpFunction %2 None %7 | ||
%5 = OpLabel | ||
OpBranch %9 | ||
%9 = OpLabel | ||
%10 = OpDPdx %4 %8 | ||
%11 = OpDPdy %4 %8 | ||
%12 = OpFwidth %4 %8 | ||
OpReturn | ||
OpFunctionEnd | ||
%16 = OpFunction %2 None %7 | ||
%13 = OpLabel | ||
OpBranch %18 | ||
%18 = OpLabel | ||
%19 = OpFunctionCall %2 %6 | ||
OpStore %14 %17 | ||
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