1 // 2 // Copyright 2016 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // QueryVk.h: 7 // Defines the class interface for QueryVk, implementing QueryImpl. 8 // 9 10 #ifndef LIBANGLE_RENDERER_VULKAN_QUERYVK_H_ 11 #define LIBANGLE_RENDERER_VULKAN_QUERYVK_H_ 12 13 #include "libANGLE/renderer/QueryImpl.h" 14 #include "libANGLE/renderer/vulkan/vk_helpers.h" 15 16 namespace rx 17 { 18 class TransformFeedbackVk; 19 20 class QueryVk : public QueryImpl 21 { 22 public: 23 QueryVk(gl::QueryType type); 24 ~QueryVk() override; 25 26 void onDestroy(const gl::Context *context) override; 27 28 angle::Result begin(const gl::Context *context) override; 29 angle::Result end(const gl::Context *context) override; 30 angle::Result queryCounter(const gl::Context *context) override; 31 angle::Result getResult(const gl::Context *context, GLint *params) override; 32 angle::Result getResult(const gl::Context *context, GLuint *params) override; 33 angle::Result getResult(const gl::Context *context, GLint64 *params) override; 34 angle::Result getResult(const gl::Context *context, GLuint64 *params) override; 35 angle::Result isResultAvailable(const gl::Context *context, bool *available) override; 36 37 void onTransformFeedbackEnd(const gl::Context *context); getQueryHelper()38 vk::QueryHelper *getQueryHelper() { return &mQueryHelper; } 39 angle::Result stashQueryHelper(ContextVk *contextVk); 40 angle::Result retrieveStashedQueryResult(ContextVk *contextVk, uint64_t *result); 41 42 private: 43 angle::Result getResult(const gl::Context *context, bool wait); 44 45 // Used for AnySamples, AnySamplesConservative, Timestamp and TimeElapsed (end). 46 vk::QueryHelper mQueryHelper; 47 // Used for occlusion query that we may end up with multiple outstanding query helper objects. 48 std::vector<vk::QueryHelper> mStashedQueryHelpers; 49 // An additional query used for TimeElapsed (begin), as it is implemented using Timestamp. 50 vk::QueryHelper mQueryHelperTimeElapsedBegin; 51 // Used with TransformFeedbackPrimitivesWritten when transform feedback is emulated. 52 size_t mTransformFeedbackPrimitivesDrawn; 53 54 uint64_t mCachedResult; 55 bool mCachedResultValid; 56 }; 57 58 } // namespace rx 59 60 #endif // LIBANGLE_RENDERER_VULKAN_QUERYVK_H_ 61