1/*------------------------------------------------------------------------ 2 * Vulkan Conformance Tests 3 * ------------------------ 4 * 5 * Copyright (c) 2020 The Khronos Group Inc. 6 * Copyright (c) 2020 Google Inc. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 * 20 *//*! 21 * \file 22 * \brief Texture multisample tests. 23 *//*--------------------------------------------------------------------*/ 24 25#include "vktTextureMultisampleTests.hpp" 26#include "vktAmberTestCase.hpp" 27#include "vktTestGroupUtil.hpp" 28 29using namespace vk; 30 31namespace vkt 32{ 33namespace texture 34{ 35namespace 36{ 37 38tcu::TestCaseGroup* createAtomicTests (tcu::TestContext& testCtx) 39{ 40 // Test atomic oprerations on multisample textures 41 de::MovePtr<tcu::TestCaseGroup> atomic (new tcu::TestCaseGroup(testCtx, "atomic")); 42#ifndef CTS_USES_VULKANSC 43 static const char dataDir[] = "texture/multisample/atomic"; 44 45 static const std::string cases[] = 46 { 47 "storage_image_r32i", 48 "storage_image_r32ui" 49 }; 50 51 std::vector<std::string> requirements; 52 53 requirements.push_back("Features.shaderStorageImageMultisample"); 54 55 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i) 56 { 57 const std::string fileName = cases[i] + ".amber"; 58 cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), dataDir, fileName, requirements); 59 60 atomic->addChild(testCase); 61 } 62#endif 63 64 return atomic.release(); 65} 66 67tcu::TestCaseGroup* createInvalidSampleIndexTests(tcu::TestContext& testCtx) 68{ 69 std::pair <std::string, VkSampleCountFlagBits> cases[] = 70 { 71 { "sample_count_2", VK_SAMPLE_COUNT_2_BIT }, 72 { "sample_count_4", VK_SAMPLE_COUNT_4_BIT }, 73 { "sample_count_8", VK_SAMPLE_COUNT_8_BIT }, 74 { "sample_count_16", VK_SAMPLE_COUNT_16_BIT }, 75 { "sample_count_32", VK_SAMPLE_COUNT_32_BIT }, 76 { "sample_count_64", VK_SAMPLE_COUNT_64_BIT } 77 }; 78 79 de::MovePtr<tcu::TestCaseGroup> invalidWrites (new tcu::TestCaseGroup(testCtx, "invalid_sample_index", "Writes to invalid sample indices should be discarded.")); 80 static const char dataDir[] = "texture/multisample/invalidsampleindex"; 81 std::vector<std::string> requirements = { "Features.shaderStorageImageMultisample" }; 82 83 for (const auto& testCase : cases) 84 { 85 const VkImageCreateInfo vkImageCreateInfo = 86 { 87 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType 88 DE_NULL, // pNext 89 0, // flags 90 VK_IMAGE_TYPE_2D, // imageType 91 VK_FORMAT_R8G8B8A8_UNORM, // format 92 { 16, 16, 1 }, // extent 93 1, // mipLevels 94 1, // arrayLayers 95 testCase.second, // samples 96 VK_IMAGE_TILING_OPTIMAL, // tiling 97 VK_IMAGE_USAGE_SAMPLED_BIT, // usage 98 VK_SHARING_MODE_EXCLUSIVE, // sharingMode 99 0, // queueFamilyIndexCount 100 DE_NULL, // pQueueFamilyIndices 101 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout 102 }; 103 104 std::vector<VkImageCreateInfo> imageRequirements = { vkImageCreateInfo }; 105 const std::string fileName = testCase.first + ".amber"; 106 107 invalidWrites->addChild(cts_amber::createAmberTestCase(testCtx, testCase.first.c_str(), dataDir, fileName, requirements, imageRequirements)); 108 } 109 110 return invalidWrites.release(); 111} 112 113} // anonymous 114 115tcu::TestCaseGroup* createTextureMultisampleTests (tcu::TestContext& testCtx) 116{ 117 de::MovePtr<tcu::TestCaseGroup> multisample (new tcu::TestCaseGroup(testCtx, "multisample")); 118 119 multisample->addChild(createAtomicTests(testCtx)); 120 multisample->addChild(createInvalidSampleIndexTests(testCtx)); 121 122 return multisample.release(); 123} 124 125} // texture 126} // vkt 127