| #!amber |
| # Copyright 2020 The Amber Authors. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # https:#www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| SET ENGINE_DATA fence_timeout_ms 1000000 |
| |
| SHADER vertex vtex_shader SPIRV-ASM |
| ; SPIR-V |
| ; Version: 1.0 |
| ; Generator: Khronos SPIR-V Tools Assembler; 0 |
| ; Bound: 28 |
| ; Schema: 0 |
| OpCapability Shader |
| %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Vertex %main "main" %pos %color %gl_Position %out_var_COLOR |
| %src = OpString "simple_vs.hlsl" |
| %code = OpString " |
| struct VS_OUTPUT { |
| float4 pos : SV_POSITION; |
| float4 color : COLOR; |
| }; |
| |
| VS_OUTPUT main(float4 pos : POSITION, |
| float4 color : COLOR) { |
| VS_OUTPUT vout; |
| vout.pos = pos; |
| vout.color = color; |
| return vout; |
| } |
| " |
| OpSource HLSL 600 %src " |
| struct VS_OUTPUT { |
| float4 pos : SV_POSITION; |
| float4 color : COLOR; |
| }; |
| |
| VS_OUTPUT main(float4 pos : POSITION, |
| float4 color : COLOR) { |
| VS_OUTPUT vout; |
| vout.pos = pos; |
| vout.color = color; |
| return vout; |
| } |
| " |
| OpName %out_var_COLOR "out.var.COLOR" |
| OpName %main "main" |
| OpName %VS_OUTPUT "VS_OUTPUT" |
| OpMemberName %VS_OUTPUT 0 "pos" |
| OpMemberName %VS_OUTPUT 1 "color" |
| OpName %pos "pos" |
| OpName %color "color" |
| OpName %vout "vout" |
| OpDecorate %gl_Position BuiltIn Position |
| OpDecorate %pos Location 0 |
| OpDecorate %color Location 1 |
| OpDecorate %out_var_COLOR Location 0 |
| %int = OpTypeInt 32 1 |
| %int_0 = OpConstant %int 0 |
| %int_1 = OpConstant %int 1 |
| %float = OpTypeFloat 32 |
| %v4float = OpTypeVector %float 4 |
| %_ptr_Input_v4float = OpTypePointer Input %v4float |
| %_ptr_Output_v4float = OpTypePointer Output %v4float |
| %void = OpTypeVoid |
| %16 = OpTypeFunction %void |
| %_ptr_Function_v4float = OpTypePointer Function %v4float |
| %VS_OUTPUT = OpTypeStruct %v4float %v4float |
| %18 = OpTypeFunction %VS_OUTPUT %_ptr_Function_v4float %_ptr_Function_v4float |
| %_ptr_Function_VS_OUTPUT = OpTypePointer Function %VS_OUTPUT |
| |
| ; Compilation Unit |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL |
| |
| ; Type names |
| %VS_OUTPUT_name = OpString "struct VS_OUTPUT" |
| %float_name = OpString "float" |
| %VS_OUTPUT_pos_name = OpString "pos" |
| %VS_OUTPUT_color_name = OpString "color" |
| %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" |
| %main_name = OpString "main" |
| %main_linkage_name = OpString "VS_OUTPUT_main_v4f_v4f" |
| %pos_name = OpString "pos" |
| %color_name = OpString "color" |
| %vout_name = OpString "vout" |
| |
| ; Type sizes in bit unit. For example, 128 means "128 bits" |
| %int_32 = OpConstant %int 32 |
| %int_128 = OpConstant %int 128 |
| |
| ; Type information |
| ; %VS_OUTPUT_info and %VS_OUTPUT_pos_info have cycling reference |
| %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %VS_OUTPUT_color_info |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float |
| %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 |
| %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %int_0 %int_128 FlagIsPublic |
| %VS_OUTPUT_color_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_color_name %v4float_info %dbg_src 3 3 %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic |
| %main_type = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %VS_OUTPUT_info %v4float_info %v4float_info |
| |
| ; DebugExpression without any information |
| %null_expr = OpExtInst %void %DbgExt DebugExpression |
| |
| ; Lexical scope for main |
| %main_lex_scope = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src 6 1 %comp_unit |
| |
| ; Function information |
| %main_func = OpExtInst %void %DbgExt DebugFunction %main_name %main_type %dbg_src 6 1 %main_lex_scope %main_linkage_name FlagIsPublic 7 %src_main |
| |
| ; Local variable information |
| %pos_info = OpExtInst %void %DbgExt DebugLocalVariable %pos_name %v4float_info %dbg_src 6 16 %main_lex_scope FlagIsLocal 0 |
| %color_info = OpExtInst %void %DbgExt DebugLocalVariable %color_name %v4float_info %dbg_src 7 16 %main_lex_scope FlagIsLocal 1 |
| %vout_info = OpExtInst %void %DbgExt DebugLocalVariable %vout_name %VS_OUTPUT_info %dbg_src 8 3 %main_lex_scope FlagIsLocal |
| |
| %pos = OpVariable %_ptr_Input_v4float Input |
| |
| ; Declaration of "float4 pos : POSITION" argument of main() |
| %pos_decl = OpExtInst %void %DbgExt DebugDeclare %pos_info %pos %null_expr |
| |
| %color = OpVariable %_ptr_Input_v4float Input |
| |
| ; Declaration of "float4 color : COLOR" argument of main() |
| %color_decl = OpExtInst %void %DbgExt DebugDeclare %color_info %color %null_expr |
| |
| %gl_Position = OpVariable %_ptr_Output_v4float Output |
| %out_var_COLOR = OpVariable %_ptr_Output_v4float Output |
| %main = OpFunction %void None %16 |
| %20 = OpLabel |
| |
| ; Start the scope of function "main()" |
| %main_scope = OpExtInst %void %DbgExt DebugScope %main_lex_scope |
| |
| %vout = OpVariable %_ptr_Function_VS_OUTPUT Function |
| |
| ; Declaration of "VS_OUTPUT vout" local variable in main() |
| %vout_decl = OpExtInst %void %DbgExt DebugDeclare %vout_info %vout %null_expr |
| |
| OpLine %src 9 3 |
| %21 = OpLoad %v4float %pos |
| %22 = OpAccessChain %_ptr_Function_v4float %vout %int_0 |
| |
| ; Tracking value of "float4 pos : SV_POSITION" member of "vout" |
| %vout_pos_value = OpExtInst %void %DbgExt DebugValue %vout_info %22 %null_expr %int_0 |
| |
| OpStore %22 %21 |
| OpLine %src 10 3 |
| %23 = OpLoad %v4float %color |
| %24 = OpAccessChain %_ptr_Function_v4float %vout %int_1 |
| |
| ; Tracking value of "float4 color : COLOR" member of "vout" |
| %vout_color_value = OpExtInst %void %DbgExt DebugValue %vout_info %24 %null_expr %int_1 |
| |
| OpStore %24 %23 |
| OpLine %src 11 3 |
| %25 = OpLoad %VS_OUTPUT %vout |
| %26 = OpCompositeExtract %v4float %25 0 |
| OpStore %gl_Position %26 |
| %27 = OpCompositeExtract %v4float %25 1 |
| OpStore %out_var_COLOR %27 |
| OpLine %src 12 3 |
| OpReturn |
| |
| ; End the scope of function "main()" |
| %main_scope_end = OpExtInst %void %DbgExt DebugNoScope |
| |
| OpFunctionEnd |
| END |
| |
| SHADER fragment frag_shader SPIRV-ASM |
| ; SPIR-V |
| ; Version: 1.0 |
| ; Generator: Khronos SPIR-V Tools Assembler; 0 |
| ; Bound: 14 |
| ; Schema: 0 |
| OpCapability Shader |
| %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint Fragment %main "main" %color %out_var_SV_TARGET |
| OpExecutionMode %main OriginUpperLeft |
| %src = OpString "simple_ps.hlsl" |
| %code = OpString "#line 1 \"simple_ps.hlsl\" |
| float4 main(float4 color : COLOR) : SV_TARGET { |
| return color; |
| } |
| " |
| OpSource HLSL 600 %src "#line 1 \"simple_ps.hlsl\" |
| float4 main(float4 color : COLOR) : SV_TARGET { |
| return color; |
| } |
| " |
| OpName %out_var_SV_TARGET "out.var.SV_TARGET" |
| OpName %main "main" |
| OpName %color "color" |
| OpDecorate %color Location 0 |
| OpDecorate %out_var_SV_TARGET Location 0 |
| %int = OpTypeInt 32 1 |
| %float = OpTypeFloat 32 |
| %v4float = OpTypeVector %float 4 |
| %_ptr_Input_v4float = OpTypePointer Input %v4float |
| %_ptr_Output_v4float = OpTypePointer Output %v4float |
| %void = OpTypeVoid |
| %9 = OpTypeFunction %void |
| %_ptr_Function_v4float = OpTypePointer Function %v4float |
| %11 = OpTypeFunction %v4float %_ptr_Function_v4float |
| |
| ; Compilation Unit |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL |
| |
| ; Type names |
| %float_name = OpString "float" |
| %main_name = OpString "main" |
| %main_linkage_name = OpString "v4f_main_v4f" |
| %color_name = OpString "color : COLOR" |
| |
| ; Type sizes in bit unit. For example, 128 means "128 bits" |
| %int_32 = OpConstant %int 32 |
| %int_128 = OpConstant %int 128 |
| |
| ; Type information |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float |
| %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 |
| %main_type = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %v4float_info |
| |
| ; DebugExpression without any information |
| %null_expr = OpExtInst %void %DbgExt DebugExpression |
| |
| ; Lexical scope for main |
| %main_lex_scope = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src 1 1 %comp_unit |
| |
| ; Function information |
| %main_func = OpExtInst %void %DbgExt DebugFunction %main_name %main_type %dbg_src 1 1 %main_lex_scope %main_linkage_name FlagIsPublic 1 %src_main |
| |
| ; Local variable information |
| %color_info = OpExtInst %void %DbgExt DebugLocalVariable %color_name %v4float_info %dbg_src 1 13 %main_lex_scope FlagIsLocal 0 |
| |
| OpLine %src 1 28 |
| %color = OpVariable %_ptr_Input_v4float Input |
| |
| ; Declaration of "float4 color : COLOR" argument of main() |
| %color_decl = OpExtInst %void %DbgExt DebugDeclare %color_info %color %null_expr |
| |
| OpLine %src 1 37 |
| %out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output |
| OpLine %src 1 1 |
| %main = OpFunction %void None %9 |
| %12 = OpLabel |
| |
| ; Start the scope of function "main()" |
| %main_scope = OpExtInst %void %DbgExt DebugScope %main_lex_scope |
| |
| OpLine %src 2 10 |
| %13 = OpLoad %v4float %color |
| OpLine %src 2 3 |
| OpStore %out_var_SV_TARGET %13 |
| OpReturn |
| |
| ; End the scope of function "main()" |
| %main_scope_end = OpExtInst %void %DbgExt DebugNoScope |
| |
| OpFunctionEnd |
| END |
| |
| BUFFER position_buf DATA_TYPE R8G8_SNORM DATA |
| # Full frame |
| -128 -128 |
| 127 127 |
| -128 127 |
| -128 -128 |
| 127 127 |
| 127 -128 |
| END |
| |
| BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA |
| 255 0 0 255 |
| 255 0 0 255 |
| 255 0 0 255 |
| 255 0 0 255 |
| 255 0 0 255 |
| 255 0 0 255 |
| |
| 0 255 0 255 |
| 0 255 0 255 |
| 0 255 0 255 |
| 0 255 0 255 |
| 0 255 0 255 |
| 0 255 0 255 |
| |
| 0 0 255 255 |
| 0 0 255 255 |
| 0 0 255 255 |
| 0 0 255 255 |
| 0 0 255 255 |
| 0 0 255 255 |
| |
| 127 127 127 255 |
| 127 127 127 255 |
| 127 127 127 255 |
| 127 127 127 255 |
| 127 127 127 255 |
| 127 127 127 255 |
| END |
| |
| BUFFER framebuffer FORMAT B8G8R8A8_UNORM |
| |
| PIPELINE graphics pipeline |
| ATTACH vtex_shader |
| ATTACH frag_shader |
| |
| VERTEX_DATA position_buf LOCATION 0 |
| VERTEX_DATA vert_color LOCATION 1 |
| |
| BIND BUFFER framebuffer AS color LOCATION 0 |
| END |
| |
| CLEAR pipeline |
| |
| DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 |
| THREAD VERTEX_INDEX 2 |
| EXPECT CALLSTACK |
| "main" "simple_vs.hlsl" 9 |
| "VertexShader" |
| END |
| EXPECT LOCATION "simple_vs.hlsl" 9 " VS_OUTPUT vout;" |
| EXPECT LOCAL "pos.x" EQ -1.007874 |
| EXPECT LOCAL "pos.y" EQ 1.000000 |
| EXPECT LOCAL "pos.z" EQ 0.000000 |
| EXPECT LOCAL "color.x" EQ 1.000000 |
| EXPECT LOCAL "color.y" EQ 0.000000 |
| EXPECT LOCAL "color.z" EQ 0.000000 |
| STEP_IN |
| EXPECT LOCATION "simple_vs.hlsl" 10 " vout.pos = pos;" |
| STEP_IN |
| EXPECT LOCAL "vout.pos.x" EQ -1.007874 |
| EXPECT LOCAL "vout.pos.y" EQ 1.000000 |
| EXPECT LOCAL "vout.pos.z" EQ 0.000000 |
| EXPECT LOCATION "simple_vs.hlsl" 11 " vout.color = color;" |
| STEP_IN |
| EXPECT LOCAL "vout.color.x" EQ 1.000000 |
| EXPECT LOCAL "vout.color.y" EQ 0.000000 |
| EXPECT LOCAL "vout.color.z" EQ 0.000000 |
| EXPECT LOCATION "simple_vs.hlsl" 12 " return vout;" |
| CONTINUE |
| END |
| END |
| |
| EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGB 255 0 0 |