Edit

kc3-lang/angle/src/tests/perf_tests/VulkanPipelineCachePerf.cpp

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2020-11-27 11:08:41
    Hash : b912eec5
    Message : Vulkan: Support GL_EXT_tessellation_shader. Shader translator changes done in http://crrev.com/c/2633936 Adds a new DIRTY_BIT_PATCH_VERTICES state to Context. Supportes state query and transform feedback. 4 test suppressions remain as follow-up fixes. Adds a new varying packing mode for a simple Vulkan rule set. Based on work by Mohan Maiya (m.maiya@samsung.com). Test: dEQP-GLES31.functional.tessellation.* Bug: angleproject:3572 Change-Id: I4cad2cca30adb754fd12c83027673906541f566a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2568234 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>

  • src/tests/perf_tests/VulkanPipelineCachePerf.cpp
  • //
    // Copyright 2018 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // VulkanPipelineCachePerf:
    //   Performance benchmark for the Vulkan Pipeline cache.
    
    #include "ANGLEPerfTest.h"
    
    #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
    #include "libANGLE/renderer/vulkan/vk_helpers.h"
    #include "util/random_utils.h"
    
    using namespace rx;
    
    namespace
    {
    constexpr unsigned int kIterationsPerStep = 100;
    
    class VulkanPipelineCachePerfTest : public ANGLEPerfTest
    {
      public:
        VulkanPipelineCachePerfTest();
        ~VulkanPipelineCachePerfTest();
    
        void SetUp() override;
        void step() override;
    
        GraphicsPipelineCache mCache;
        angle::RNG mRNG;
    
        std::vector<vk::GraphicsPipelineDesc> mCacheHits;
        std::vector<vk::GraphicsPipelineDesc> mCacheMisses;
        size_t mMissIndex = 0;
    
      private:
        void randomizeDesc(vk::GraphicsPipelineDesc *desc);
    };
    
    VulkanPipelineCachePerfTest::VulkanPipelineCachePerfTest()
        : ANGLEPerfTest("VulkanPipelineCachePerf", "", "", kIterationsPerStep)
    {}
    
    VulkanPipelineCachePerfTest::~VulkanPipelineCachePerfTest()
    {
        mCache.destroy(VK_NULL_HANDLE);
    }
    
    void VulkanPipelineCachePerfTest::SetUp()
    {
        // Insert a number of random pipeline states.
        for (int pipelineCount = 0; pipelineCount < 100; ++pipelineCount)
        {
            vk::Pipeline pipeline;
            vk::GraphicsPipelineDesc desc;
            randomizeDesc(&desc);
    
            if (pipelineCount < 10)
            {
                mCacheHits.push_back(desc);
            }
            mCache.populate(desc, std::move(pipeline));
        }
    
        for (int missCount = 0; missCount < 10000; ++missCount)
        {
            vk::GraphicsPipelineDesc desc;
            randomizeDesc(&desc);
            mCacheMisses.push_back(desc);
        }
    }
    
    void VulkanPipelineCachePerfTest::randomizeDesc(vk::GraphicsPipelineDesc *desc)
    {
        std::vector<uint8_t> bytes(sizeof(vk::GraphicsPipelineDesc));
        FillVectorWithRandomUBytes(&mRNG, &bytes);
        memcpy(desc, bytes.data(), sizeof(vk::GraphicsPipelineDesc));
    }
    
    void VulkanPipelineCachePerfTest::step()
    {
        vk::RenderPass rp;
        vk::PipelineLayout pl;
        vk::PipelineCache pc;
        vk::ShaderModule sm;
        const vk::GraphicsPipelineDesc *desc = nullptr;
        vk::PipelineHelper *result           = nullptr;
        gl::AttributesMask am;
        gl::ComponentTypeMask ctm;
    
        vk::SpecializationConstants defaultSpecConsts{};
    
        for (unsigned int iteration = 0; iteration < kIterationsPerStep; ++iteration)
        {
            for (const auto &hit : mCacheHits)
            {
                (void)mCache.getPipeline(VK_NULL_HANDLE, pc, rp, pl, am, ctm, &sm, &sm, nullptr,
                                         nullptr, nullptr, defaultSpecConsts, hit, &desc, &result);
            }
        }
    
        for (int missCount = 0; missCount < 20 && mMissIndex < mCacheMisses.size();
             ++missCount, ++mMissIndex)
        {
            const auto &miss = mCacheMisses[mMissIndex];
            (void)mCache.getPipeline(VK_NULL_HANDLE, pc, rp, pl, am, ctm, &sm, &sm, nullptr, nullptr,
                                     nullptr, defaultSpecConsts, miss, &desc, &result);
        }
    }
    
    }  // anonymous namespace
    
    TEST_F(VulkanPipelineCachePerfTest, Run)
    {
        run();
    }