1e5c31af7Sopenharmony_ci#ifndef _VKTMESHSHADERUTIL_HPP 2e5c31af7Sopenharmony_ci#define _VKTMESHSHADERUTIL_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------ 4e5c31af7Sopenharmony_ci * Vulkan Conformance Tests 5e5c31af7Sopenharmony_ci * ------------------------ 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright (c) 2021 The Khronos Group Inc. 8e5c31af7Sopenharmony_ci * Copyright (c) 2021 Valve Corporation. 9e5c31af7Sopenharmony_ci * 10e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 11e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 12e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 13e5c31af7Sopenharmony_ci * 14e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 15e5c31af7Sopenharmony_ci * 16e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 17e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 18e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 20e5c31af7Sopenharmony_ci * limitations under the License. 21e5c31af7Sopenharmony_ci * 22e5c31af7Sopenharmony_ci *//*! 23e5c31af7Sopenharmony_ci * \file 24e5c31af7Sopenharmony_ci * \brief Mesh Shader Utility Code 25e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ci#include "vktTestCase.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ci#include "vkDefs.hpp" 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ci#include "deSTLUtil.hpp" 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ci#include <vector> 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_cinamespace vkt 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_cinamespace MeshShader 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_ci// Primitive shading rate cases. 41e5c31af7Sopenharmony_cienum class FragmentSize 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_ci SIZE_2X2 = 0, 44e5c31af7Sopenharmony_ci SIZE_2X1 = 1, 45e5c31af7Sopenharmony_ci SIZE_1X1 = 2, 46e5c31af7Sopenharmony_ci SIZE_COUNT = 3, 47e5c31af7Sopenharmony_ci}; 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ciusing FragmentSizeVector = std::vector<FragmentSize>; 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_ci// Get the block extent according to the fragment size. 52e5c31af7Sopenharmony_civk::VkExtent2D getShadingRateSize (FragmentSize fragmentSize); 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_ci// Returns a shading rate size that does not match the given fragment sizes. 55e5c31af7Sopenharmony_citemplate <typename Iterator> 56e5c31af7Sopenharmony_ciFragmentSize getBadShadingRateSize (Iterator itBegin, Iterator itEnd) 57e5c31af7Sopenharmony_ci{ 58e5c31af7Sopenharmony_ci const auto fsCount = static_cast<int>(FragmentSize::SIZE_COUNT); 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ci for (int i = 0; i < fsCount; ++i) 61e5c31af7Sopenharmony_ci { 62e5c31af7Sopenharmony_ci const auto fs = static_cast<FragmentSize>(i); 63e5c31af7Sopenharmony_ci if (!de::contains(itBegin, itEnd, fs)) 64e5c31af7Sopenharmony_ci return fs; 65e5c31af7Sopenharmony_ci } 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci DE_ASSERT(false); 68e5c31af7Sopenharmony_ci return FragmentSize::SIZE_COUNT; 69e5c31af7Sopenharmony_ci} 70e5c31af7Sopenharmony_ci 71e5c31af7Sopenharmony_ci// GLSL representation of the given fragment size. 72e5c31af7Sopenharmony_cistd::string getGLSLShadingRateMask (FragmentSize fragmentSize); 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ci// GLSL/SPV value of the given mask. 75e5c31af7Sopenharmony_ciint getSPVShadingRateValue (FragmentSize fragmentSize); 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci// Basic feature check (NV version) 78e5c31af7Sopenharmony_civoid checkTaskMeshShaderSupportNV (Context& context, bool requireTask, bool requireMesh); 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ci// Basic feature check (EXT version) 81e5c31af7Sopenharmony_civoid checkTaskMeshShaderSupportEXT (Context& context, bool requireTask, bool requireMesh); 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ci// Get the right SPIR-V build options for the EXT. 84e5c31af7Sopenharmony_civk::ShaderBuildOptions getMinMeshEXTBuildOptions (uint32_t vulkanVersion, uint32_t flags = 0u); 85e5c31af7Sopenharmony_civk::SpirVAsmBuildOptions getMinMeshEXTSpvBuildOptions (uint32_t vulkanVersion, bool allowMaintenance4 = false); 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci} 88e5c31af7Sopenharmony_ci} 89e5c31af7Sopenharmony_ci 90e5c31af7Sopenharmony_ci#endif // _VKTMESHSHADERUTIL_HPP 91