1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------ 2e5c31af7Sopenharmony_ci * Vulkan Conformance Tests 3e5c31af7Sopenharmony_ci * ------------------------ 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright (c) 2020 The Khronos Group Inc. 6e5c31af7Sopenharmony_ci * Copyright (c) 2020 Google Inc. 7e5c31af7Sopenharmony_ci * 8e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 9e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 10e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 11e5c31af7Sopenharmony_ci * 12e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 13e5c31af7Sopenharmony_ci * 14e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 15e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 16e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 18e5c31af7Sopenharmony_ci * limitations under the License. 19e5c31af7Sopenharmony_ci * 20e5c31af7Sopenharmony_ci *//*! 21e5c31af7Sopenharmony_ci * \file 22e5c31af7Sopenharmony_ci * \brief Texel buffer tests. 23e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ci#include "vktTextureTexelBufferTests.hpp" 26e5c31af7Sopenharmony_ci#include "vktAmberTestCase.hpp" 27e5c31af7Sopenharmony_ci#include "vktTestGroupUtil.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ciusing namespace vk; 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_cinamespace vkt 32e5c31af7Sopenharmony_ci{ 33e5c31af7Sopenharmony_cinamespace texture 34e5c31af7Sopenharmony_ci{ 35e5c31af7Sopenharmony_cinamespace 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_citcu::TestCaseGroup* createUniformTexelBufferTests (tcu::TestContext& testCtx) 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_ci de::MovePtr<tcu::TestCaseGroup> uniform (new tcu::TestCaseGroup(testCtx, "uniform")); 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_ci // .srgb 43e5c31af7Sopenharmony_ci { 44e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const srgb = new tcu::TestCaseGroup(testCtx, "srgb"); 45e5c31af7Sopenharmony_ci static const char dataDir[] = "texture/texel_buffer/uniform/srgb"; 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci static const struct { 48e5c31af7Sopenharmony_ci std::string testName; 49e5c31af7Sopenharmony_ci VkFormat format; 50e5c31af7Sopenharmony_ci } cases[] = 51e5c31af7Sopenharmony_ci { 52e5c31af7Sopenharmony_ci {"r8g8b8a8_srgb", VK_FORMAT_R8G8B8A8_SRGB}, 53e5c31af7Sopenharmony_ci {"b8g8r8a8_srgb", VK_FORMAT_B8G8R8A8_SRGB}, 54e5c31af7Sopenharmony_ci {"b8g8r8_srgb", VK_FORMAT_B8G8R8_SRGB}, 55e5c31af7Sopenharmony_ci {"r8g8b8_srgb", VK_FORMAT_R8G8B8_SRGB}, 56e5c31af7Sopenharmony_ci {"r8g8_srgb", VK_FORMAT_R8G8_SRGB}, 57e5c31af7Sopenharmony_ci {"r8_srgb", VK_FORMAT_R8_SRGB} 58e5c31af7Sopenharmony_ci }; 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ci uniform->addChild(srgb); 61e5c31af7Sopenharmony_ci 62e5c31af7Sopenharmony_ci for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i) 63e5c31af7Sopenharmony_ci { 64e5c31af7Sopenharmony_ci const std::string fileName = cases[i].testName + ".amber"; 65e5c31af7Sopenharmony_ci const VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci const deUint32 width = 8; 68e5c31af7Sopenharmony_ci const deUint32 height = 8; 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_ci VkImageCreateInfo imageParams = 71e5c31af7Sopenharmony_ci { 72e5c31af7Sopenharmony_ci VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; 73e5c31af7Sopenharmony_ci DE_NULL, // const void* pNext; 74e5c31af7Sopenharmony_ci DE_NULL, // VkImageCreateFlags flags; 75e5c31af7Sopenharmony_ci VK_IMAGE_TYPE_2D, // VkImageType imageType; 76e5c31af7Sopenharmony_ci cases[i].format, // VkFormat format; 77e5c31af7Sopenharmony_ci VkExtent3D({width, height, 1u}), // VkExtent3D extent; 78e5c31af7Sopenharmony_ci 1u, // deUint32 mipLevels; 79e5c31af7Sopenharmony_ci 1u, // deUint32 arrayLayers; 80e5c31af7Sopenharmony_ci VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; 81e5c31af7Sopenharmony_ci VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; 82e5c31af7Sopenharmony_ci usageFlags, // VkImageUsageFlags usage; 83e5c31af7Sopenharmony_ci VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; 84e5c31af7Sopenharmony_ci 0u, // deUint32 queueFamilyIndexCount; 85e5c31af7Sopenharmony_ci DE_NULL, // const deUint32* pQueueFamilyIndices; 86e5c31af7Sopenharmony_ci VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; 87e5c31af7Sopenharmony_ci }; 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci std::vector<VkImageCreateInfo> imageRequirements; 90e5c31af7Sopenharmony_ci imageRequirements.push_back(imageParams); 91e5c31af7Sopenharmony_ci 92e5c31af7Sopenharmony_ci std::vector<cts_amber::BufferRequirement> bufferRequirements; 93e5c31af7Sopenharmony_ci bufferRequirements.push_back({cases[i].format, VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT}); 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci cts_amber::AmberTestCase* testCase = 96e5c31af7Sopenharmony_ci cts_amber::createAmberTestCase(testCtx, cases[i].testName.c_str(), 97e5c31af7Sopenharmony_ci dataDir, fileName, std::vector<std::string>(), 98e5c31af7Sopenharmony_ci imageRequirements, bufferRequirements); 99e5c31af7Sopenharmony_ci srgb->addChild(testCase); 100e5c31af7Sopenharmony_ci } 101e5c31af7Sopenharmony_ci } 102e5c31af7Sopenharmony_ci 103e5c31af7Sopenharmony_ci // .packed 104e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC 105e5c31af7Sopenharmony_ci { 106e5c31af7Sopenharmony_ci // Test uniform texel buffer with packed formats 107e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const packed = new tcu::TestCaseGroup(testCtx, "packed"); 108e5c31af7Sopenharmony_ci static const char dataDir[] = "texture/texel_buffer/uniform/packed"; 109e5c31af7Sopenharmony_ci 110e5c31af7Sopenharmony_ci static const std::string cases[] = 111e5c31af7Sopenharmony_ci { 112e5c31af7Sopenharmony_ci "a2b10g10r10-uint-pack32", 113e5c31af7Sopenharmony_ci "a2b10g10r10-unorm-pack32", 114e5c31af7Sopenharmony_ci "a8b8g8r8-sint-pack32", 115e5c31af7Sopenharmony_ci "a8b8g8r8-snorm-pack32", 116e5c31af7Sopenharmony_ci "a8b8g8r8-uint-pack32", 117e5c31af7Sopenharmony_ci "a8b8g8r8-unorm-pack32", 118e5c31af7Sopenharmony_ci "b10g11r11-ufloat-pack32" 119e5c31af7Sopenharmony_ci }; 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ci uniform->addChild(packed); 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ci for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i) 124e5c31af7Sopenharmony_ci { 125e5c31af7Sopenharmony_ci const std::string fileName = cases[i] + ".amber"; 126e5c31af7Sopenharmony_ci cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), dataDir, fileName); 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ci packed->addChild(testCase); 129e5c31af7Sopenharmony_ci } 130e5c31af7Sopenharmony_ci } 131e5c31af7Sopenharmony_ci#endif 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ci // .snorm 134e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC 135e5c31af7Sopenharmony_ci { 136e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const snorm = new tcu::TestCaseGroup(testCtx, "snorm", "Test uniform texel buffer with SNORM formats"); 137e5c31af7Sopenharmony_ci static const char dataDir[] = "texture/texel_buffer/uniform/snorm"; 138e5c31af7Sopenharmony_ci 139e5c31af7Sopenharmony_ci static const struct { 140e5c31af7Sopenharmony_ci std::string testName; 141e5c31af7Sopenharmony_ci bool mandatoryFormat; 142e5c31af7Sopenharmony_ci VkFormat format; 143e5c31af7Sopenharmony_ci } cases[] = 144e5c31af7Sopenharmony_ci { 145e5c31af7Sopenharmony_ci { "b8g8r8-snorm", false, VK_FORMAT_B8G8R8_SNORM }, 146e5c31af7Sopenharmony_ci { "b8g8r8a8-snorm", false, VK_FORMAT_B8G8R8A8_SINT }, 147e5c31af7Sopenharmony_ci { "r16-snorm", false, VK_FORMAT_R16_SNORM }, 148e5c31af7Sopenharmony_ci { "r16g16-snorm", false, VK_FORMAT_R16G16_SNORM }, 149e5c31af7Sopenharmony_ci { "r16g16b16-snorm", false, VK_FORMAT_R16G16B16_SNORM }, 150e5c31af7Sopenharmony_ci { "r16g16b16a16-snorm", false, VK_FORMAT_R16G16B16A16_SNORM }, 151e5c31af7Sopenharmony_ci { "r8-snorm", true, VK_FORMAT_R8_SNORM }, 152e5c31af7Sopenharmony_ci { "r8g8-snorm", true, VK_FORMAT_R8G8_SNORM }, 153e5c31af7Sopenharmony_ci { "r8g8b8-snorm", false, VK_FORMAT_R8G8B8_SNORM }, 154e5c31af7Sopenharmony_ci { "r8g8b8a8-snorm", false, VK_FORMAT_R8G8B8A8_SNORM } 155e5c31af7Sopenharmony_ci }; 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_ci uniform->addChild(snorm); 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci for (const auto& c : cases) 160e5c31af7Sopenharmony_ci { 161e5c31af7Sopenharmony_ci const std::string fileName = c.testName + ".amber"; 162e5c31af7Sopenharmony_ci std::vector<cts_amber::BufferRequirement> bufferRequirements; 163e5c31af7Sopenharmony_ci 164e5c31af7Sopenharmony_ci if (!c.mandatoryFormat) 165e5c31af7Sopenharmony_ci bufferRequirements.push_back({c.format, VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT}); 166e5c31af7Sopenharmony_ci 167e5c31af7Sopenharmony_ci cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, c.testName.c_str(), 168e5c31af7Sopenharmony_ci dataDir, fileName, 169e5c31af7Sopenharmony_ci std::vector<std::string>(), 170e5c31af7Sopenharmony_ci std::vector<vk::VkImageCreateInfo>(), 171e5c31af7Sopenharmony_ci bufferRequirements); 172e5c31af7Sopenharmony_ci 173e5c31af7Sopenharmony_ci snorm->addChild(testCase); 174e5c31af7Sopenharmony_ci } 175e5c31af7Sopenharmony_ci } 176e5c31af7Sopenharmony_ci#endif 177e5c31af7Sopenharmony_ci 178e5c31af7Sopenharmony_ci return uniform.release(); 179e5c31af7Sopenharmony_ci} 180e5c31af7Sopenharmony_ci 181e5c31af7Sopenharmony_ci} // anonymous 182e5c31af7Sopenharmony_ci 183e5c31af7Sopenharmony_citcu::TestCaseGroup* createTextureTexelBufferTests (tcu::TestContext& testCtx) 184e5c31af7Sopenharmony_ci{ 185e5c31af7Sopenharmony_ci de::MovePtr<tcu::TestCaseGroup> texelBuffer (new tcu::TestCaseGroup(testCtx, "texel_buffer", "Test texel buffer")); 186e5c31af7Sopenharmony_ci 187e5c31af7Sopenharmony_ci texelBuffer->addChild(createUniformTexelBufferTests(testCtx)); 188e5c31af7Sopenharmony_ci 189e5c31af7Sopenharmony_ci return texelBuffer.release(); 190e5c31af7Sopenharmony_ci} 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ci} // texture 193e5c31af7Sopenharmony_ci} // vkt 194