| 1 | /* |
| 2 | * Copyright (c) 2018, Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included |
| 12 | * in all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | //! |
| 24 | //! \file media_scalability_multipipe.h |
| 25 | //! \brief Defines the common interface for media scalability mulitpipe mode. |
| 26 | //! \details The media scalability mulitpipe interface is further sub-divided by component, |
| 27 | //! this file is for the base interface which is shared by all components. |
| 28 | //! |
| 29 | |
| 30 | #ifndef __MEDIA_SCALABILITY_MULTIPIPE_H__ |
| 31 | #define __MEDIA_SCALABILITY_MULTIPIPE_H__ |
| 32 | #include "mos_defs.h" |
| 33 | #include "media_scalability.h" |
| 34 | class MediaContext; |
| 35 | class MhwMiInterface; |
| 36 | |
| 37 | class MediaScalabilityMultiPipe: public MediaScalability |
| 38 | { |
| 39 | |
| 40 | public: |
| 41 | MediaScalabilityMultiPipe(MediaContext *mediaContext) : MediaScalability(mediaContext){}; |
| 42 | |
| 43 | //! |
| 44 | //! \brief Media scalability mulitipipe destructor |
| 45 | //! |
| 46 | virtual ~MediaScalabilityMultiPipe(){}; |
| 47 | |
| 48 | //! |
| 49 | //! \brief Destroy the media scalability multipipe |
| 50 | //! \return MOS_STATUS |
| 51 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 52 | //! |
| 53 | virtual MOS_STATUS Destroy() override; |
| 54 | |
| 55 | //! |
| 56 | //! \brief Update the media scalability mulitipipe state mode |
| 57 | //! \return MOS_STATUS |
| 58 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 59 | //! |
| 60 | virtual MOS_STATUS UpdateState(void *statePars); |
| 61 | |
| 62 | protected: |
| 63 | //! |
| 64 | //! \brief Allocate GPU memory resources for NativeFence barrier counters |
| 65 | //! \return MOS_STATUS |
| 66 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 67 | //! |
| 68 | MOS_STATUS AllocateNativeFenceCounters(); |
| 69 | |
| 70 | //! |
| 71 | //! \brief Implement NativeFence barrier sync algorithm using counterChild and counterParent |
| 72 | //! \param [in] cmdBuffer |
| 73 | //! Pointer to command buffer |
| 74 | //! \return MOS_STATUS |
| 75 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 76 | //! |
| 77 | MOS_STATUS SyncPipesWithNativeFence(PMOS_COMMAND_BUFFER cmdBuffer); |
| 78 | |
| 79 | //! |
| 80 | //! \brief Send MI_ATOMIC command (virtual function for derived class override) |
| 81 | //! \param [in] resource |
| 82 | //! Resource to perform atomic operation on |
| 83 | //! \param [in] offset |
| 84 | //! Offset within the resource |
| 85 | //! \param [in] immData |
| 86 | //! Immediate data for atomic operation |
| 87 | //! \param [in] opCode |
| 88 | //! Atomic operation code |
| 89 | //! \param [in] cmdBuffer |
| 90 | //! Pointer to command buffer |
| 91 | //! \return MOS_STATUS |
| 92 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 93 | //! |
| 94 | virtual MOS_STATUS SendMiAtomicCmd( |
| 95 | PMOS_RESOURCE resource, |
| 96 | uint32_t offset, |
| 97 | uint32_t immData, |
| 98 | MHW_COMMON_MI_ATOMIC_OPCODE opCode, |
| 99 | PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 100 | |
| 101 | //! |
| 102 | //! \brief Send MI_SEMAPHORE_WAIT command (virtual function for derived class override) |
| 103 | //! \param [in] semaMem |
| 104 | //! Semaphore memory resource |
| 105 | //! \param [in] offset |
| 106 | //! Offset within the semaphore memory |
| 107 | //! \param [in] semaData |
| 108 | //! Semaphore data to compare |
| 109 | //! \param [in] opCode |
| 110 | //! Comparison operation code |
| 111 | //! \param [in] cmdBuffer |
| 112 | //! Pointer to command buffer |
| 113 | //! \return MOS_STATUS |
| 114 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 115 | //! |
| 116 | virtual MOS_STATUS SendMiSemaphoreWaitCmd( |
| 117 | PMOS_RESOURCE semaMem, |
| 118 | uint32_t offset, |
| 119 | uint32_t semaData, |
| 120 | MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION opCode, |
| 121 | PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 122 | |
| 123 | //! |
| 124 | //! \brief Send MI_STORE_DATA_IMM command (virtual function for derived class override) |
| 125 | //! \param [in] resource |
| 126 | //! Resource to store data to |
| 127 | //! \param [in] offset |
| 128 | //! Offset within the resource |
| 129 | //! \param [in] value |
| 130 | //! Immediate value to store |
| 131 | //! \param [in] cmdBuffer |
| 132 | //! Pointer to command buffer |
| 133 | //! \return MOS_STATUS |
| 134 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 135 | //! |
| 136 | virtual MOS_STATUS SendMiStoreDataImmCmd( |
| 137 | PMOS_RESOURCE resource, |
| 138 | uint32_t offset, |
| 139 | uint32_t value, |
| 140 | PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 141 | |
| 142 | inline bool IsFirstPipe() { return (m_currentPipe == 0) ? true : false; } |
| 143 | inline bool IsFirstPass() { return (m_currentPass == 0) ? true : false; } |
| 144 | inline bool IsLastPipe() { return (m_currentPipe == (m_pipeNum - 1)) ? true : false; } |
| 145 | |
| 146 | inline bool IsPipeReadyToSubmit() { return (m_currentPipe == (m_pipeIndexForSubmit - 1)) ? true : false; } |
| 147 | |
| 148 | MOS_RESOURCE m_counterChild = {}; //!< NativeFence: Child-to-parent completion counter (N-1 children increment to signal) |
| 149 | MOS_RESOURCE m_counterParent = {}; //!< NativeFence: Parent-to-child go signal counter (parent increments to 1 to release) |
| 150 | |
| 151 | MEDIA_CLASS_DEFINE_END(MediaScalabilityMultiPipe) |
| 152 | }; |
| 153 | #endif // !__MEDIA_SCALABILITY_MULTIPIPE_H__ |