Home | History | Annotate | Download | only in vulkan
      1 #ifndef _VKSHADERPROGRAM_HPP
      2 #define _VKSHADERPROGRAM_HPP
      3 /*-------------------------------------------------------------------------
      4  * Vulkan CTS Framework
      5  * --------------------
      6  *
      7  * Copyright (c) 2017 Google Inc.
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  *//*!
     22  * \file
     23  * \brief Shader (GLSL/HLSL) source program.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "vkDefs.hpp"
     27 #include "gluShaderProgram.hpp"
     28 
     29 #include <string>
     30 
     31 namespace tcu
     32 {
     33 class TestLog;
     34 } // tcu
     35 
     36 namespace vk
     37 {
     38 
     39 struct ShaderBuildOptions
     40 {
     41 	enum Flags
     42 	{
     43 		FLAG_USE_STORAGE_BUFFER_STORAGE_CLASS	= (1u<<0),
     44 		FLAG_ALLOW_RELAXED_OFFSETS				= (1u<<1)	// allow block offsets to follow VK_KHR_relaxed_block_layout
     45 	};
     46 
     47 	SpirvVersion	targetVersion;
     48 	deUint32		flags;
     49 
     50 	ShaderBuildOptions (SpirvVersion targetVersion_, deUint32 flags_)
     51 		: targetVersion	(targetVersion_)
     52 		, flags			(flags_)
     53 	{}
     54 
     55 	ShaderBuildOptions (void)
     56 		: targetVersion	(SPIRV_VERSION_1_0)
     57 		, flags			(0u)
     58 	{}
     59 };
     60 
     61 enum ShaderLanguage
     62 {
     63 	SHADER_LANGUAGE_GLSL = 0,
     64 	SHADER_LANGUAGE_HLSL,
     65 
     66 	SHADER_LANGUAGE_LAST
     67 };
     68 
     69 struct GlslSource
     70 {
     71 	static const ShaderLanguage	shaderLanguage = SHADER_LANGUAGE_GLSL;
     72 	std::vector<std::string>	sources[glu::SHADERTYPE_LAST];
     73 	ShaderBuildOptions			buildOptions;
     74 
     75 	GlslSource&					operator<<		(const glu::ShaderSource& shaderSource);
     76 	GlslSource&					operator<<		(const ShaderBuildOptions& buildOptions_);
     77 };
     78 
     79 struct HlslSource
     80 {
     81 	static const ShaderLanguage	shaderLanguage = SHADER_LANGUAGE_HLSL;
     82 	std::vector<std::string>	sources[glu::SHADERTYPE_LAST];
     83 	ShaderBuildOptions			buildOptions;
     84 
     85 	HlslSource&					operator<<		(const glu::ShaderSource& shaderSource);
     86 	HlslSource&					operator<<		(const ShaderBuildOptions& buildOptions_);
     87 };
     88 
     89 tcu::TestLog&	operator<<		(tcu::TestLog& log, const GlslSource& shaderSource);
     90 tcu::TestLog&	operator<<		(tcu::TestLog& log, const HlslSource& shaderSource);
     91 
     92 } // vk
     93 
     94 #endif // _VKSHADERPROGRAM_HPP
     95