Add glu::ShaderType <-> VkShaderStage utils to vkPrograms
authorPyry Haulos <phaulos@google.com>
Tue, 22 Sep 2015 18:28:13 +0000 (11:28 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 24 Sep 2015 21:16:06 +0000 (14:16 -0700)
Change-Id: I04b98eb3cab6c0676c509e6065a652dc9848cd99

external/vulkancts/framework/vulkan/vkPrograms.cpp
external/vulkancts/framework/vulkan/vkPrograms.hpp

index a73d7f8..4483885 100644 (file)
@@ -84,11 +84,11 @@ Move<VkShaderModule> createShaderModule (const DeviceInterface& deviceInterface,
        {
                const struct VkShaderModuleCreateInfo           shaderModuleInfo        =
                {
-                       VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,    //      VkStructureType         sType;
-                       DE_NULL,                                                                                //      const void*                     pNext;
-                       (deUintptr)binary.getSize(),                                    //      deUintptr                       codeSize;
-                       binary.getBinary(),                                                             //      const void*                     pCode;
-                       flags,                                                                                  //      VkShaderModuleCreateFlags       flags;
+                       VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
+                       DE_NULL,
+                       (deUintptr)binary.getSize(),
+                       binary.getBinary(),
+                       flags,
                };
 
                return createShaderModule(deviceInterface, device, &shaderModuleInfo);
@@ -97,4 +97,34 @@ Move<VkShaderModule> createShaderModule (const DeviceInterface& deviceInterface,
                TCU_THROW(NotSupportedError, "Unsupported program format");
 }
 
+glu::ShaderType getGluShaderType (VkShaderStage shaderStage)
+{
+       static const glu::ShaderType s_shaderTypes[] =
+       {
+               glu::SHADERTYPE_VERTEX,
+               glu::SHADERTYPE_TESSELLATION_CONTROL,
+               glu::SHADERTYPE_TESSELLATION_EVALUATION,
+               glu::SHADERTYPE_GEOMETRY,
+               glu::SHADERTYPE_FRAGMENT,
+               glu::SHADERTYPE_COMPUTE
+       };
+
+       return de::getSizedArrayElement<VK_SHADER_STAGE_LAST>(s_shaderTypes, shaderStage);
+}
+
+VkShaderStage getVkShaderStage (glu::ShaderType shaderType)
+{
+       static const VkShaderStage s_shaderStages[] =
+       {
+               VK_SHADER_STAGE_VERTEX,
+               VK_SHADER_STAGE_FRAGMENT,
+               VK_SHADER_STAGE_GEOMETRY,
+               VK_SHADER_STAGE_TESS_CONTROL,
+               VK_SHADER_STAGE_TESS_EVALUATION,
+               VK_SHADER_STAGE_COMPUTE
+       };
+
+       return de::getSizedArrayElement<glu::SHADERTYPE_LAST>(s_shaderStages, shaderType);
+}
+
 } // vk
index dfc30d9..356eb16 100644 (file)
@@ -185,6 +185,9 @@ ProgramBinary*                      buildProgram            (const glu::ProgramSources& program, ProgramForma
 ProgramBinary*                 assembleProgram         (const vk::SpirVAsmSource& program, SpirVProgramInfo* buildInfo);
 Move<VkShaderModule>   createShaderModule      (const DeviceInterface& deviceInterface, VkDevice device, const ProgramBinary& binary, VkShaderModuleCreateFlags flags);
 
+glu::ShaderType                        getGluShaderType        (VkShaderStage shaderStage);
+VkShaderStage                  getVkShaderStage        (glu::ShaderType shaderType);
+
 } // vk
 
 #endif // _VKPROGRAMS_HPP