Rename various things for more inclusive language
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / protected_memory / vktProtectedMemYCbCrConversionTests.cpp
index f5d4bbe..6540509 100644 (file)
@@ -357,7 +357,7 @@ void uploadYCbCrImage (ProtectedContext&                                    ctx,
                bufferBarriers.push_back(bufferBarrier);
 
                deMemcpy(buffer->getAllocation().getHostPtr(), imageData.getPlanePtr(planeNdx), imageData.getPlaneSize(planeNdx));
-               flushMappedMemoryRange(vk, device, buffer->getAllocation().getMemory(), buffer->getAllocation().getOffset(), (deUint32)imageData.getPlaneSize(planeNdx));
+               flushAlloc(vk, device, buffer->getAllocation());
                stagingBuffers.push_back(de::SharedPtr<de::MovePtr<vk::BufferWithMemory> >(new de::MovePtr<vk::BufferWithMemory>(buffer.release())));
        }
 
@@ -366,7 +366,7 @@ void uploadYCbCrImage (ProtectedContext&                                    ctx,
 
        for (deUint32 planeNdx = 0; planeNdx < imageData.getDescription().numPlanes; ++planeNdx)
        {
-               const vk::VkImageAspectFlagBits aspect  = formatDesc.numPlanes > 1
+               const vk::VkImageAspectFlags    aspect  = formatDesc.numPlanes > 1
                                                                                                ? vk::getPlaneAspect(planeNdx)
                                                                                                : vk::VK_IMAGE_ASPECT_COLOR_BIT;
 
@@ -419,7 +419,7 @@ void uploadYCbCrImage (ProtectedContext&                                    ctx,
 
        for (deUint32 planeNdx = 0; planeNdx < imageData.getDescription().numPlanes; ++planeNdx)
        {
-               const vk::VkImageAspectFlagBits aspect  = formatDesc.numPlanes > 1
+               const vk::VkImageAspectFlags    aspect  = formatDesc.numPlanes > 1
                                                                                                ? vk::getPlaneAspect(planeNdx)
                                                                                                : vk::VK_IMAGE_ASPECT_COLOR_BIT;
 
@@ -495,7 +495,8 @@ void logBoundImages (tcu::TestLog& log, const tcu::UVec2 size, const std::vector
 bool validateImage (ProtectedContext&                                                  ctx,
                                         const std::vector<YCbCrValidationData>&        refData,
                                         const vk::VkSampler                                            sampler,
-                                        const vk::VkImageView                                          imageView)
+                                        const vk::VkImageView                                          imageView,
+                                        const deUint32                                                         combinedSamplerDescriptorCount)
 {
        {
                tcu::TestLog&   log     (ctx.getTestContext().getLog());
@@ -526,7 +527,7 @@ bool validateImage (ProtectedContext&                                                       ctx,
        // Set the reference uniform data
        {
                deMemcpy(refUniform->getAllocation().getHostPtr(), &refData[0], refUniformSize);
-               vk::flushMappedMemoryRange(vk, device, refUniform->getAllocation().getMemory(), refUniform->getAllocation().getOffset(), refUniformSize);
+               flushAlloc(vk, device, refUniform->getAllocation());
        }
 
        const deUint32                                                          helperBufferSize        = (deUint32)(2 * sizeof(deUint32));
@@ -546,7 +547,7 @@ bool validateImage (ProtectedContext&                                                       ctx,
                .addSingleBinding(vk::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, vk::VK_SHADER_STAGE_COMPUTE_BIT)
                .build(vk, device));
        const vk::Unique<vk::VkDescriptorPool>          descriptorPool(vk::DescriptorPoolBuilder()
-               .addType(vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1u)
+               .addType(vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, combinedSamplerDescriptorCount)
                .addType(vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1u)
                .addType(vk::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u)
                .build(vk, device, vk::VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
@@ -645,13 +646,13 @@ void testShaders (vk::SourceCollections& dst, const TestConfig config)
                "layout(std140, set = 0, binding = 2) buffer ProtectedHelper\n"
                "{\n"
                "    highp uint zero;\n"
-               "    highp uint dummyOut;\n"
+               "    highp uint unusedOut;\n"
                "} helper;\n"
                "\n"
                "void error()\n"
                "{\n"
                "    for (uint x = 0u; x < 10u; x += helper.zero)\n"
-               "        atomicAdd(helper.dummyOut, 1u);\n"
+               "        atomicAdd(helper.unusedOut, 1u);\n"
                "}\n"
                "\n"
                "${COMPARE_FUNCTION}"
@@ -673,13 +674,13 @@ void testShaders (vk::SourceCollections& dst, const TestConfig config)
                "layout(std140, set=0, binding=2) buffer ProtectedHelper\n"
                "{\n"
                "    highp uint zero; // set to 0\n"
-               "    highp uint dummyOut;\n"
+               "    highp uint unusedOut;\n"
                "} helper;\n"
                "\n"
                "void main (void)\n"
                "{\n"
                "    helper.zero = 0;\n"
-               "    helper.dummyOut = 0;\n"
+               "    helper.unusedOut = 0;\n"
                "}\n";
 
        dst.glslSources.add("ResetSSBO") << glu::ComputeSource(resetSSBOShader);
@@ -821,7 +822,8 @@ void renderYCbCrToColor (ProtectedContext&                                                  ctx,
                                                 const vk::VkImage                                                      colorImage,
                                                 const vk::VkImageView                                          colorImageView,
                                                 const std::vector<YCbCrValidationData>&        referenceData,
-                                                const std::vector<tcu::Vec2>&                          posCoords)
+                                                const std::vector<tcu::Vec2>&                          posCoords,
+                                                const deUint32                                                         combinedSamplerDescriptorCount)
 {
        const vk::DeviceInterface&                                      vk                                      = ctx.getDeviceInterface();
        const vk::VkDevice                                                      device                          = ctx.getDevice();
@@ -839,7 +841,7 @@ void renderYCbCrToColor (ProtectedContext&                                                  ctx,
                                                                                                                                                .addSingleBinding(vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, vk::VK_SHADER_STAGE_ALL)
                                                                                                                                                .build(vk, device));
        const vk::Unique<vk::VkDescriptorPool>          descriptorPool          (vk::DescriptorPoolBuilder()
-                                                                                                                                               .addType(vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1u)
+                                                                                                                                               .addType(vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, combinedSamplerDescriptorCount)
                                                                                                                                                .addType(vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1u)
                                                                                                                                                .build(vk, device, vk::VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
        const vk::Unique<vk::VkDescriptorSet>           descriptorSet           (makeDescriptorSet(vk, device, *descriptorPool, *descriptorSetLayout));
@@ -857,7 +859,7 @@ void renderYCbCrToColor (ProtectedContext&                                                  ctx,
        // Set the reference uniform data
        {
                deMemcpy(refUniform->getAllocation().getHostPtr(), &referenceData[0], refUniformSize);
-               vk::flushMappedMemoryRange(vk, device, refUniform->getAllocation().getMemory(), refUniform->getAllocation().getOffset(), refUniformSize);
+               flushAlloc(vk, device, refUniform->getAllocation());
        }
 
        // Update descriptor set
@@ -902,7 +904,7 @@ void renderYCbCrToColor (ProtectedContext&                                                  ctx,
                                                                  vk::MemoryRequirement::HostVisible);
 
                deMemcpy(vertexBuffer->getAllocation().getHostPtr(), &posCoords[0], bufferSize);
-               vk::flushMappedMemoryRange(vk, device, vertexBuffer->getAllocation().getMemory(), vertexBuffer->getAllocation().getOffset(), bufferSize);
+               flushAlloc(vk, device, vertexBuffer->getAllocation());
        }
 
        const vk::Unique<vk::VkPipeline>                pipeline                        (makeGraphicsPipeline(vk,
@@ -1182,6 +1184,31 @@ tcu::TestStatus conversionTest (Context& context, TestConfig config)
                                                                                                                                                                                           *conversion));
        const vk::Unique<vk::VkImageView>                                       ycbcrImageView                  (createImageView(vk, device, **ycbcrImage, config.format, *conversion));
 
+       deUint32                                                                                        combinedSamplerDescriptorCount = 1;
+       {
+               const vk::VkPhysicalDeviceImageFormatInfo2                      imageFormatInfo                         =
+               {
+                       vk::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,      // sType
+                       DE_NULL,                                                                                                        // pNext
+                       config.format,                                                                                          // format
+                       vk::VK_IMAGE_TYPE_2D,                                                                           // type
+                       vk::VK_IMAGE_TILING_OPTIMAL,                                                            // tiling
+                       vk::VK_IMAGE_USAGE_TRANSFER_DST_BIT |
+                       vk::VK_IMAGE_USAGE_SAMPLED_BIT,                                                         // usage
+                       ycbcrImageFlags                                                                                         // flags
+               };
+
+               vk::VkSamplerYcbcrConversionImageFormatProperties       samplerYcbcrConversionImage = {};
+               samplerYcbcrConversionImage.sType = vk::VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES;
+               samplerYcbcrConversionImage.pNext = DE_NULL;
+
+               vk::VkImageFormatProperties2                                            imageFormatProperties           = {};
+               imageFormatProperties.sType = vk::VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
+               imageFormatProperties.pNext = &samplerYcbcrConversionImage;
+
+               VK_CHECK(context.getInstanceInterface().getPhysicalDeviceImageFormatProperties2(context.getPhysicalDevice(), &imageFormatInfo, &imageFormatProperties));
+               combinedSamplerDescriptorCount = samplerYcbcrConversionImage.combinedImageSamplerDescriptorCount;
+       }
 
        // Input attributes
        std::vector<tcu::Vec2>                                                          texCoords;
@@ -1244,14 +1271,14 @@ tcu::TestStatus conversionTest (Context& context, TestConfig config)
                const vk::Unique<vk::VkImageView>                       colorImageView          (createImageView(ctx, **colorImage, s_colorFormat));
                const vk::Unique<vk::VkSampler>                         colorSampler            (makeSampler(vk, device));
 
-               renderYCbCrToColor(ctx, size, *ycbcrSampler, *ycbcrImageView, **colorImage, *colorImageView, referenceData, posCoords);
+               renderYCbCrToColor(ctx, size, *ycbcrSampler, *ycbcrImageView, **colorImage, *colorImageView, referenceData, posCoords, combinedSamplerDescriptorCount);
 
-               if (!validateImage(ctx, colorReferenceData, *colorSampler, *colorImageView))
+               if (!validateImage(ctx, colorReferenceData, *colorSampler, *colorImageView, combinedSamplerDescriptorCount))
                        return tcu::TestStatus::fail("YCbCr image conversion via fragment shader failed");
        }
        else if (config.shaderType == glu::SHADERTYPE_COMPUTE)
        {
-               if (!validateImage(ctx, referenceData, *ycbcrSampler, *ycbcrImageView))
+               if (!validateImage(ctx, referenceData, *ycbcrSampler, *ycbcrImageView, combinedSamplerDescriptorCount))
                        return tcu::TestStatus::fail("YCbCr image conversion via compute shader failed");
        }
        else