1#!amber 2# Copyright 2022 Google LLC 3# Copyright 2022 LunarG, Inc. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17DEVICE_FEATURE geometryShader 18 19SHADER vertex vert_shader PASSTHROUGH 20 21SHADER geometry geom_shader GLSL 22#version 450 23 24layout (triangles) in; 25layout (triangle_strip, max_vertices = 3) out; 26in gl_PerVertex { vec4 gl_Position; float gl_PointSize; float gl_ClipDistance[]; } gl_in[]; 27 28layout(set = 0, binding = 0) buffer block0 29{ 30 int data[20]; 31} ssbo; 32 33void main(void) 34{ 35 // Only want to perform these operations once 36 if(gl_InvocationID == 0) 37 { 38 // Zero constants 39 int ival = ssbo.data[0]; 40 float val = float(ival); 41 42 // int div 43 ssbo.data[1] = 7 / ival; 44 // float div 45 ssbo.data[2] = int(7.0 / val); 46 // normalize float 47 ssbo.data[3] = int(normalize(val)); 48 // normalize vec2 49 ssbo.data[4] = int(normalize(vec2(val))[ival]); 50 // normalize vec3 51 ssbo.data[5] = int(normalize(vec3(val))[ival]); 52 // normalize vec4 53 ssbo.data[6] = int(normalize(vec4(val))[ival]); 54 // integer mod 55 ssbo.data[7] = 7 % ival; 56 // float mod 57 ssbo.data[8] = int(mod(7.0, val)); 58 // vec2 mod 59 ssbo.data[9] = int(mod(vec2(7.0), vec2(val))[ival]); 60 // vec3 mod 61 ssbo.data[10] = int(mod(vec3(7.0), vec3(val))[ival]); 62 // vec4 mod 63 ssbo.data[11] = int(mod(vec4(7.0), vec4(val))[ival]); 64 // float smoothstep 65 ssbo.data[12] = int(smoothstep(val, val, 0.3)); 66 // vec2 smoothstep 67 ssbo.data[13] = int(smoothstep(vec2(val), vec2(val), vec2(0.3))[ival]); 68 // vec3 smoothstep 69 ssbo.data[14] = int(smoothstep(vec3(val), vec3(val), vec3(0.3))[ival]); 70 // vec4 smoothstep 71 ssbo.data[15] = int(smoothstep(vec4(val), vec4(val), vec4(0.3))[ival]); 72 // float atan2 73 ssbo.data[16] = int(atan(7.0, val)); 74 // vec2 atan2 75 ssbo.data[17] = int(atan(vec2(7.0), vec2(val))[ival]); 76 // vec3 atan2 77 ssbo.data[18] = int(atan(vec3(7.0), vec3(val))[ival]); 78 // vec4 atan2 79 ssbo.data[19] = int(atan(vec4(7.0), vec4(val))[ival]); 80 81 // Known good value 82 ssbo.data[0] = 42; 83 } 84 85 gl_Position = gl_in[0].gl_Position; 86 EmitVertex(); 87 88 gl_Position = gl_in[1].gl_Position; 89 EmitVertex(); 90 91 gl_Position = gl_in[2].gl_Position; 92 EmitVertex(); 93 94 EndPrimitive(); 95} 96END 97 98SHADER fragment frag_shader GLSL 99#version 450 100 101layout (location = 0) out vec4 outColor; 102 103void main(void) 104{ 105 outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); 106} 107END 108 109BUFFER ssbo_buffer DATA_TYPE int32 DATA 1100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 111END 112 113BUFFER framebuffer FORMAT R8G8B8A8_UNORM 114 115PIPELINE graphics my_pipeline 116 ATTACH vert_shader 117 ATTACH geom_shader 118 ATTACH frag_shader 119 120 BIND BUFFER framebuffer AS color LOCATION 0 121 BIND BUFFER ssbo_buffer AS storage DESCRIPTOR_SET 0 BINDING 0 122END 123 124RUN my_pipeline DRAW_RECT POS 0 0 SIZE 32 32 125 126EXPECT ssbo_buffer IDX 0 EQ 42