Skip to content

Commit

Permalink
Add test for pure initializer gl_FragDepth.
Browse files Browse the repository at this point in the history
Tests that the builtin is considered active.
  • Loading branch information
HansKristian-Work committed Jan 7, 2021
1 parent 3776d89 commit 03ee71e
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
static float gl_FragDepth = 0.5f;
struct SPIRV_Cross_Output
{
float gl_FragDepth : SV_Depth;
};

void frag_main()
{
}

SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_FragDepth = gl_FragDepth;
return stage_output;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct main0_out
{
float gl_FragDepth [[depth(any)]];
};

fragment main0_out main0()
{
main0_out out = {};
out.gl_FragDepth = 0.5;
return out;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 450

const float _3_init = 0.5;
void main()
{
gl_FragDepth = _3_init;
}

25 changes: 25 additions & 0 deletions shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 10
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %gl_FragDepth
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main DepthReplacing
OpSource GLSL 450
OpName %main "main"
OpName %gl_FragDepth "gl_FragDepth"
OpDecorate %gl_FragDepth BuiltIn FragDepth
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float
%float_0_5 = OpConstant %float 0.5
%gl_FragDepth = OpVariable %_ptr_Output_float Output %float_0_5
%main = OpFunction %void None %3
%5 = OpLabel
OpReturn
OpFunctionEnd
25 changes: 25 additions & 0 deletions shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 10
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %gl_FragDepth
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main DepthReplacing
OpSource GLSL 450
OpName %main "main"
OpName %gl_FragDepth "gl_FragDepth"
OpDecorate %gl_FragDepth BuiltIn FragDepth
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float
%float_0_5 = OpConstant %float 0.5
%gl_FragDepth = OpVariable %_ptr_Output_float Output %float_0_5
%main = OpFunction %void None %3
%5 = OpLabel
OpReturn
OpFunctionEnd
25 changes: 25 additions & 0 deletions shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 10
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %gl_FragDepth
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main DepthReplacing
OpSource GLSL 450
OpName %main "main"
OpName %gl_FragDepth "gl_FragDepth"
OpDecorate %gl_FragDepth BuiltIn FragDepth
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float
%float_0_5 = OpConstant %float 0.5
%gl_FragDepth = OpVariable %_ptr_Output_float Output %float_0_5
%main = OpFunction %void None %3
%5 = OpLabel
OpReturn
OpFunctionEnd

0 comments on commit 03ee71e

Please sign in to comment.