1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
|
/*
* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
* Copyright (c) 2015-2024 Google, Inc.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
#pragma once
static const char kMinimalShaderGlsl[] = R"glsl(
#version 460
void main() {}
)glsl";
static const char kVertexMinimalGlsl[] = R"glsl(
#version 460
void main() {
gl_Position = vec4(1);
}
)glsl";
// for GPU-AV tests, we need the vertex shader to actually run and produce
// work for the next shader stages
static const char kVertexDrawPassthroughGlsl[] = R"glsl(
#version 450
vec2 vertices[3];
void main(){
vertices[0] = vec2(-1.0, -1.0);
vertices[1] = vec2( 1.0, -1.0);
vertices[2] = vec2( 0.0, 1.0);
gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);
}
)glsl";
static const char kVertexPointSizeGlsl[] = R"glsl(
#version 460
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
void main() {
gl_Position = vec4(1);
gl_PointSize = 1.0;
}
)glsl";
static char const kGeometryMinimalGlsl[] = R"glsl(
#version 460
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
void main() {
gl_Position = vec4(1);
EmitVertex();
}
)glsl";
static char const kGeometryPointSizeGlsl[] = R"glsl(
#version 460
layout (points) in;
layout (points) out;
layout (max_vertices = 1) out;
in gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
void main() {
gl_Position = vec4(1);
gl_PointSize = 1.0;
EmitVertex();
}
)glsl";
static const char kTessellationControlMinimalGlsl[] = R"glsl(
#version 460
layout(vertices=3) out;
void main() {
gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;
gl_TessLevelInner[0] = 1;
}
)glsl";
static const char kTessellationEvalMinimalGlsl[] = R"glsl(
#version 460
layout(triangles, equal_spacing, cw) in;
void main() { gl_Position = vec4(1); }
)glsl";
static const char kFragmentMinimalGlsl[] = R"glsl(
#version 460
layout(location = 0) out vec4 uFragColor;
void main(){
uFragColor = vec4(0,1,0,1);
}
)glsl";
static const char kFragmentSamplerGlsl[] = R"glsl(
#version 460
layout(set=0, binding=0) uniform sampler2D s;
layout(location=0) out vec4 x;
void main(){
x = texture(s, vec2(1));
}
)glsl";
static const char kFragmentUniformGlsl[] = R"glsl(
#version 460
layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;
layout(location=0) out vec4 x;
void main(){
x = vec4(bar.y);
}
)glsl";
static char const kFragmentSubpassLoadGlsl[] = R"glsl(
#version 460
layout(input_attachment_index=0, set=0, binding=0) uniform subpassInput x;
void main() {
vec4 color = subpassLoad(x);
}
)glsl";
[[maybe_unused]] static const char *kTaskMinimalGlsl = R"glsl(
#version 460
#extension GL_EXT_mesh_shader : require // Requires SPIR-V 1.5 (Vulkan 1.2)
layout (local_size_x=1, local_size_y=1, local_size_z=1) in;
void main() {
EmitMeshTasksEXT(1u, 1u, 1u);
}
)glsl";
[[maybe_unused]] static const char *kMeshMinimalGlsl = R"glsl(
#version 460
#extension GL_EXT_mesh_shader : require // Requires SPIR-V 1.5 (Vulkan 1.2)
layout(max_vertices = 3, max_primitives=1) out;
layout(triangles) out;
void main() {}
)glsl";
[[maybe_unused]] static const char *kRayTracingMinimalGlsl = R"glsl(
#version 460
#extension GL_EXT_ray_tracing : require // Requires SPIR-V 1.5 (Vulkan 1.2)
void main() {}
)glsl";
[[maybe_unused]] static char const kRayTracingPayloadMinimalGlsl[] = R"glsl(
#version 460
#extension GL_EXT_ray_tracing : enable
layout(location = 0) rayPayloadInEXT float hitValue;
void main() {
hitValue = 1.0;
}
)glsl";
[[maybe_unused]] static const char *kRayTracingNVMinimalGlsl = R"glsl(
#version 460
#extension GL_NV_ray_tracing : require
void main() {}
)glsl";
static char const kShaderTileImageDepthReadSpv[] = R"(
OpCapability Shader
OpCapability TileImageDepthReadAccessEXT
OpExtension "SPV_EXT_shader_tile_image"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %depth_output
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main EarlyFragmentTests
OpSource GLSL 450
OpSourceExtension "GL_EXT_shader_tile_image"
OpName %main "main"
OpName %depth "depth"
OpName %depth_output "depth_output"
OpDecorate %depth_output Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%depth_output = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %3
%5 = OpLabel
%depth = OpVariable %_ptr_Function_float Function
%9 = OpDepthAttachmentReadEXT %float
OpStore %depth %9
%13 = OpLoad %float %depth
%14 = OpCompositeConstruct %v4float %13 %13 %13 %13
OpStore %depth_output %14
OpReturn
OpFunctionEnd
)";
static char const kShaderTileImageStencilReadSpv[] = R"(
OpCapability Shader
OpCapability TileImageStencilReadAccessEXT
OpExtension "SPV_EXT_shader_tile_image"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %stencil_output
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main EarlyFragmentTests
OpSource GLSL 450
OpSourceExtension "GL_EXT_shader_tile_image"
OpName %main "main"
OpName %stencil "stencil"
OpName %stencil_output "stencil_output"
OpDecorate %9 RelaxedPrecision
OpDecorate %stencil_output Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%stencil_output = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %3
%5 = OpLabel
%stencil = OpVariable %_ptr_Function_uint Function
%9 = OpStencilAttachmentReadEXT %uint
OpStore %stencil %9
%14 = OpLoad %uint %stencil
%15 = OpConvertUToF %float %14
%16 = OpCompositeConstruct %v4float %15 %15 %15 %15
OpStore %stencil_output %16
OpReturn
OpFunctionEnd
)";
static char const kShaderTileImageColorReadSpv[] = R"(
OpCapability Shader
OpCapability TileImageColorReadAccessEXT
OpExtension "SPV_EXT_shader_tile_image"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %color_output
OpExecutionMode %main OriginUpperLeft
OpSource GLSL 450
OpSourceExtension "GL_EXT_shader_tile_image"
OpName %main "main"
OpName %color_output "color_output"
OpName %color_f "color_f"
OpDecorate %color_output Location 0
OpDecorate %color_f Location 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%color_output = OpVariable %_ptr_Output_v4float Output
%10 = OpTypeImage %float TileImageDataEXT 0 0 0 2 Unknown
%_ptr_TileImageEXT_10 = OpTypePointer TileImageEXT %10
%color_f = OpVariable %_ptr_TileImageEXT_10 TileImageEXT
%main = OpFunction %void None %3
%5 = OpLabel
%13 = OpLoad %10 %color_f
%14 = OpColorAttachmentReadEXT %v4float %13
OpStore %color_output %14
OpReturn
OpFunctionEnd
)";
static char const kShaderTileImageDepthStencilReadSpv[] = R"(
OpCapability Shader
OpCapability TileImageDepthReadAccessEXT
OpCapability TileImageStencilReadAccessEXT
OpExtension "SPV_EXT_shader_tile_image"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %uFragColor
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main EarlyFragmentTests
OpSource GLSL 450
OpSourceExtension "GL_EXT_shader_tile_image"
OpName %main "main"
OpName %depth "depth"
OpName %stencil "stencil"
OpName %uFragColor "uFragColor"
OpDecorate %13 RelaxedPrecision
OpDecorate %uFragColor Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%uFragColor = OpVariable %_ptr_Output_v4float Output
%float_0 = OpConstant %float 0
%float_1 = OpConstant %float 1
%main = OpFunction %void None %3
%5 = OpLabel
%depth = OpVariable %_ptr_Function_float Function
%stencil = OpVariable %_ptr_Function_uint Function
%9 = OpDepthAttachmentReadEXT %float
OpStore %depth %9
%13 = OpStencilAttachmentReadEXT %uint
OpStore %stencil %13
%17 = OpLoad %float %depth
%18 = OpLoad %uint %stencil
%19 = OpConvertUToF %float %18
%22 = OpCompositeConstruct %v4float %17 %19 %float_0 %float_1
OpStore %uFragColor %22
OpReturn
OpFunctionEnd
)";
[[maybe_unused]] static const char kRayGenGlsl[] = R"glsl(
#version 460 core
#extension GL_EXT_ray_tracing : enable
layout(set = 0, binding = 0, rgba8) uniform image2D image;
layout(set = 0, binding = 1) uniform accelerationStructureEXT as;
layout(location = 0) rayPayloadEXT float payload;
void main()
{
vec4 col = vec4(0, 0, 0, 1);
vec3 origin = vec3(float(gl_LaunchIDEXT.x)/float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y)/float(gl_LaunchSizeEXT.y), 1.0);
vec3 dir = vec3(0.0, 0.0, -1.0);
payload = 0.5;
traceRayEXT(as, gl_RayFlagsCullBackFacingTrianglesEXT, 0xff, 0, 1, 0, origin, 0.0, dir, 1000.0, 0);
col.y = payload;
imageStore(image, ivec2(gl_LaunchIDEXT.xy), col);
}
)glsl";
[[maybe_unused]] static char const *kMissGlsl = kRayTracingPayloadMinimalGlsl;
|