• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2020 Valve Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  */
24 #include "helpers.h"
25 #include "test_isel-spirv.h"
26 
27 using namespace aco;
28 
29 BEGIN_TEST(isel.interp.simple)
30    QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX,
31       layout(location = 0) in vec4 in_color;
32       layout(location = 0) out vec4 out_color;
33       void main() {
34          out_color = in_color;
35       }
36    );
37    QoShaderModuleCreateInfo fs = qoShaderModuleCreateInfoGLSL(FRAGMENT,
38       layout(location = 0) in vec4 in_color;
39       layout(location = 0) out vec4 out_color;
40       void main() {
41          //>> v1: %a_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.w
42          //! v1: %a = v_interp_p2_f32 %by, %pm:m0, %a_tmp attr0.w
43          //! v1: %b_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.z
44          //! v1: %b = v_interp_p2_f32 %by, %pm:m0, %b_tmp attr0.z
45          //! v1: %g_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.y
46          //! v1: %g = v_interp_p2_f32 %by, %pm:m0, %g_tmp attr0.y
47          //! v1: %r_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.x
48          //! v1: %r = v_interp_p2_f32 %by, %pm:m0, %r_tmp attr0.x
49          //! exp %r, %g, %b, %a mrt0
50          out_color = in_color;
51       }
52    );
53 
54    PipelineBuilder bld(get_vk_device(GFX9));
55    bld.add_vsfs(vs, fs);
56    bld.print_ir(VK_SHADER_STAGE_FRAGMENT_BIT, "ACO IR");
57 END_TEST
58 
59 BEGIN_TEST(isel.compute.simple)
60    for (unsigned i = GFX7; i <= GFX8; i++) {
61       if (!set_variant((chip_class)i))
62          continue;
63 
64       QoShaderModuleCreateInfo cs = qoShaderModuleCreateInfoGLSL(COMPUTE,
65          layout(local_size_x=1) in;
66          layout(binding=0) buffer Buf {
67             uint res;
68          };
69          void main() {
70             //~gfx7>> v1: %data = p_parallelcopy 42
71             //~gfx7>> buffer_store_dword %_, v1: undef, 0, %data disable_wqm storage:buffer semantics: scope:invocation
72             //~gfx8>> s1: %data = p_parallelcopy 42
73             //~gfx8>> s_buffer_store_dword %_, 0, %data storage:buffer semantics: scope:invocation
74             res = 42;
75          }
76       );
77 
78       PipelineBuilder bld(get_vk_device((chip_class)i));
79       bld.add_cs(cs);
80       bld.print_ir(VK_SHADER_STAGE_COMPUTE_BIT, "ACO IR", true);
81    }
82 END_TEST
83