Skip to content

Commit

Permalink
tests: Move and rename test shader templates
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jun 21, 2023
1 parent 33eb828 commit 886d29e
Show file tree
Hide file tree
Showing 54 changed files with 687 additions and 684 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_sources(vk_layer_validation_tests PRIVATE
framework/layer_validation_tests.h
framework/layer_validation_tests.cpp
framework/test_common.h
framework/shader_templates.h
framework/error_monitor.cpp
framework/error_monitor.h
framework/video_objects.h
Expand Down
8 changes: 4 additions & 4 deletions tests/framework/layer_validation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,8 @@ void VkLayerTest::VKTriangleTest(BsoFailSelect failCase) {

ASSERT_NO_FATAL_FAILURE(InitViewport());

VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
VkShaderObj ps(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
VkShaderObj vs(this, kVertexMinimalGlsl, VK_SHADER_STAGE_VERTEX_BIT);
VkShaderObj ps(this, kFragmentMinimalGlsl, VK_SHADER_STAGE_FRAGMENT_BIT);

VkPipelineObj pipelineobj(m_device);
pipelineobj.AddDefaultColorAttachment();
Expand Down Expand Up @@ -1568,7 +1568,7 @@ void CreatePipelineHelper::InitDynamicStateInfo() {
// during late bind
}

void CreatePipelineHelper::InitShaderInfo() { ResetShaderInfo(bindStateVertShaderText, bindStateFragShaderText); }
void CreatePipelineHelper::InitShaderInfo() { ResetShaderInfo(kVertexMinimalGlsl, kFragmentMinimalGlsl); }

void CreatePipelineHelper::ResetShaderInfo(const char *vertex_shader_text, const char *fragment_shader_text) {
vs_.reset(new VkShaderObj(&layer_test_, vertex_shader_text, VK_SHADER_STAGE_VERTEX_BIT));
Expand Down Expand Up @@ -1845,7 +1845,7 @@ void CreateComputePipelineHelper::InitPipelineLayoutInfo() {
}

void CreateComputePipelineHelper::InitShaderInfo() {
cs_.reset(new VkShaderObj(&layer_test_, bindStateMinimalShaderText, VK_SHADER_STAGE_COMPUTE_BIT));
cs_.reset(new VkShaderObj(&layer_test_, kMinimalShaderGlsl, VK_SHADER_STAGE_COMPUTE_BIT));
// We shouldn't need a fragment shader but add it to be able to run on more devices
}

Expand Down
278 changes: 1 addition & 277 deletions tests/framework/layer_validation_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "render.h"
#include "generated/vk_typemap_helper.h"
#include "utils/convert_utils.h"
#include "shader_templates.h"

#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -87,283 +88,6 @@ enum BsoFailSelect {
BsoFailLineStipple,
};

static const char bindStateMinimalShaderText[] = R"glsl(
#version 460
void main() {}
)glsl";

static const char bindStateVertShaderText[] = R"glsl(
#version 460
void main() {
gl_Position = vec4(1);
}
)glsl";

static const char bindStateVertPointSizeShaderText[] = 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 bindStateGeomShaderText[] = 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 bindStateGeomPointSizeShaderText[] = 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 bindStateTscShaderText[] = 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 bindStateTeshaderText[] = R"glsl(
#version 460
layout(triangles, equal_spacing, cw) in;
void main() { gl_Position = vec4(1); }
)glsl";

static const char bindStateFragShaderText[] = R"glsl(
#version 460
layout(location = 0) out vec4 uFragColor;
void main(){
uFragColor = vec4(0,1,0,1);
}
)glsl";

static const char bindStateFragSamplerShaderText[] = 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 bindStateFragUniformShaderText[] = 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 bindStateFragSubpassLoadInputText[] = R"glsl(
#version 460
layout(input_attachment_index=0, set=0, binding=0) uniform subpassInput x;
void main() {
vec4 color = subpassLoad(x);
}
)glsl";

static char const bindStateFragColorOutputText[] = R"glsl(
#version 460
layout(location=0) out vec4 color;
void main() {
color = vec4(1.0f);
}
)glsl";

[[maybe_unused]] static const char *bindStateMeshShaderText = 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 *bindStateRTShaderText = R"glsl(
#version 460
#extension GL_EXT_ray_tracing : require // Requires SPIR-V 1.5 (Vulkan 1.2)
void main() {}
)glsl";

[[maybe_unused]] static const char *bindStateRTNVShaderText = R"glsl(
#version 460
#extension GL_NV_ray_tracing : require
void main() {}
)glsl";

static char const bindShaderTileImageDepthReadSpv[] = 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 bindShaderTileImageStencilReadSpv[] = 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 bindShaderTileImageColorReadSpv[] = 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 bindShaderTileImageDepthStencilReadSpv[] = 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
)";

// Static arrays helper
template <class ElementT, size_t array_size>
size_t size(ElementT (&)[array_size]) {
Expand Down
Loading

0 comments on commit 886d29e

Please sign in to comment.