d3ad3f3a4724cb0da4444beb0450b47488856edb
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / spirv_assembly / vktSpvAsmComputeShaderTestUtil.cpp
1 /*-------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 Google Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Compute Shader Based Test Case Utility Structs/Functions
22  *//*--------------------------------------------------------------------*/
23
24 #include "vktSpvAsmComputeShaderTestUtil.hpp"
25
26 namespace vkt
27 {
28 namespace SpirVAssembly
29 {
30
31 const char* getComputeAsmShaderPreamble (void)
32 {
33         return
34                 "OpCapability Shader\n"
35                 "OpMemoryModel Logical GLSL450\n"
36                 "OpEntryPoint GLCompute %main \"main\" %id\n"
37                 "OpExecutionMode %main LocalSize 1 1 1\n";
38 }
39
40 std::string getComputeAsmCommonTypes (std::string blockStorageClass)
41 {
42         return std::string(
43                 "%bool      = OpTypeBool\n"
44                 "%void      = OpTypeVoid\n"
45                 "%voidf     = OpTypeFunction %void\n"
46                 "%u32       = OpTypeInt 32 0\n"
47                 "%i32       = OpTypeInt 32 1\n"
48                 "%f32       = OpTypeFloat 32\n"
49                 "%uvec3     = OpTypeVector %u32 3\n"
50                 "%fvec3     = OpTypeVector %f32 3\n"
51                 "%uvec3ptr  = OpTypePointer Input %uvec3\n") +
52                 "%i32ptr    = OpTypePointer " + blockStorageClass + " %i32\n"
53                 "%f32ptr    = OpTypePointer " + blockStorageClass + " %f32\n"
54                 "%i32arr    = OpTypeRuntimeArray %i32\n"
55                 "%f32arr    = OpTypeRuntimeArray %f32\n";
56 }
57
58 const char* getComputeAsmCommonInt64Types (void)
59 {
60         return
61                 "%i64       = OpTypeInt 64 1\n"
62                 "%i64ptr    = OpTypePointer Uniform %i64\n"
63                 "%i64arr    = OpTypeRuntimeArray %i64\n";
64 }
65
66 const char* getComputeAsmInputOutputBuffer (void)
67 {
68         return
69                 "%buf     = OpTypeStruct %f32arr\n"
70                 "%bufptr  = OpTypePointer Uniform %buf\n"
71                 "%indata    = OpVariable %bufptr Uniform\n"
72                 "%outdata   = OpVariable %bufptr Uniform\n";
73 }
74
75 const char* getComputeAsmInputOutputBufferTraits (void)
76 {
77         return
78                 "OpDecorate %buf BufferBlock\n"
79                 "OpDecorate %indata DescriptorSet 0\n"
80                 "OpDecorate %indata Binding 0\n"
81                 "OpDecorate %outdata DescriptorSet 0\n"
82                 "OpDecorate %outdata Binding 1\n"
83                 "OpDecorate %f32arr ArrayStride 4\n"
84                 "OpMemberDecorate %buf 0 Offset 0\n";
85 }
86
87 } // SpirVAssembly
88 } // vkt