vktSpvAsmComputeShaderTestUtil.cpp revision ba23b9e1fccb231af89f3de3e9fff7d8f8055e51
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
26namespace vkt
27{
28namespace SpirVAssembly
29{
30
31const 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
40const char* getComputeAsmCommonTypes (void)
41{
42	return
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 Uniform %i32\n"
53		"%f32ptr    = OpTypePointer Uniform %f32\n"
54		"%i32arr    = OpTypeRuntimeArray %i32\n"
55		"%f32arr    = OpTypeRuntimeArray %f32\n";
56}
57
58const char* getComputeAsmInputOutputBuffer (void)
59{
60	return
61		"%buf     = OpTypeStruct %f32arr\n"
62		"%bufptr  = OpTypePointer Uniform %buf\n"
63		"%indata    = OpVariable %bufptr Uniform\n"
64		"%outdata   = OpVariable %bufptr Uniform\n";
65}
66
67const char* getComputeAsmInputOutputBufferTraits (void)
68{
69	return
70		"OpDecorate %buf BufferBlock\n"
71		"OpDecorate %indata DescriptorSet 0\n"
72		"OpDecorate %indata Binding 0\n"
73		"OpDecorate %outdata DescriptorSet 0\n"
74		"OpDecorate %outdata Binding 1\n"
75		"OpDecorate %f32arr ArrayStride 4\n"
76		"OpMemberDecorate %buf 0 Offset 0\n";
77}
78
79} // SpirVAssembly
80} // vkt
81