- Timestamp:
- 05/09/05 22:55:21 (20 years ago)
- Location:
- trunk/VUT/work/ogre_changes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h
r61 r88 103 103 * 0 will generate all the levels till 1x1. [default: 0] 104 104 */ 105 virtual bool pullOcclusionQuery( unsigned int* NumOfFragments ) = 0;105 virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ) = 0; 106 106 107 107 /** … … 112 112 * In OpenGL mode it makes no difference if you specify OCCLUSIONQUERY_FLUSH or OCCLUSIONQUERY_NOFLUSH. 113 113 */ 114 virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ) = 0; 114 virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 115 const HW_OCCLUSIONQUERY flag ) = 0; 115 116 116 117 /** … … 133 134 virtual void setSkipRate( int skip ) = 0; 134 135 virtual int getSkipRate() = 0; 135 136 #ifdef GTP_VISIBILITY_MODIFIED_OGRE137 /**138 *139 * @Remarks This function returns true if the result of the140 * query is already availbable, false otherwise.141 */142 virtual bool resultAvailable() = 0;143 #endif // GTP_VISIBILITY_MODIFIED_OGRE144 145 136 //---------------------------------------------------------------------- 146 137 // Private members -
trunk/VUT/work/ogre_changes/RenderSystem/Direct3D9/include/OgreD3D9HardwareOcclusionQuery.h
r61 r88 71 71 void beginOcclusionQuery(); 72 72 void endOcclusionQuery(); 73 bool pullOcclusionQuery( unsigned int* NumOfFragments); 74 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ); 73 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ); 74 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 75 const HW_OCCLUSIONQUERY flag ); 76 75 77 unsigned int getLastQuerysPixelcount() { return m_uintPixelCount; } 76 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 77 bool resultAvailable(); 78 #endif 79 // This functions are optional, it's a simple filter that simply skipps some hardware occlusion tests on visable objects only 78 79 // This functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visable objects only 80 80 // It's easy to use if you don't have to keep track on which objects are visable (can be skipped) and what objects arn't visable.. 81 81 // (None visable objects and object you introduce for the first time have allways to be tested allthough the cheepest possible … … 93 93 94 94 95 void setSkipRate( int skip ) { m_Skip = skip; } // Using 2 only 50 % of the tests are actu lly made and 3 results in only 33% of the tests. So on.95 void setSkipRate( int skip ) { m_Skip = skip; } // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on. 96 96 int getSkipRate() { return m_Skip; } 97 97 … … 100 100 //-- 101 101 protected: 102 103 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 104 const DWORD queryFlag ); 102 105 103 106 unsigned int m_uintPixelCount; -
trunk/VUT/work/ogre_changes/RenderSystem/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp
r61 r88 78 78 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 79 79 { 80 if ( m_SkipCounter == m_Skip ) { m_SkipCounter = 0; }; // Counter starts at 0 again at m_Skip 81 82 if ( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 83 { 84 m_pD3DQuery->Issue(D3DISSUE_BEGIN); 85 } 80 m_pD3DQuery->Issue(D3DISSUE_BEGIN); 86 81 } 87 82 } 88 83 //------------------------------------------------------------------ 89 84 void D3D9HardwareOcclusionQuery::endOcclusionQuery() 90 85 { 91 86 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 92 87 { 93 if (m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 94 { 95 m_pD3DQuery->Issue(D3DISSUE_END); 96 } 97 m_SkipCounter++; // The skip counter is increased 88 m_pD3DQuery->Issue(D3DISSUE_END); 98 89 } 99 90 } … … 104 95 // Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 105 96 //-- 106 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments )97 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ) 107 98 { 108 HRESULT hr; 109 110 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 111 { 112 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 113 114 if ( hr != S_OK ) 115 { 116 return false; 117 } 118 else 119 { 120 m_uintPixelCount = *NumOfFragments; 121 return true; 122 } 123 } 124 else 125 { 126 m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 127 return true; 128 } 99 return pullOcclusionQuery(NumOfFragments, waitForResult, HWOCCLUSIONQUERY_FLUSH); 129 100 } 130 101 … … 135 106 // Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 136 107 //-- 137 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ) 108 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 109 const HW_OCCLUSIONQUERY flag ) 138 110 { 139 HRESULT hr; 140 111 DWORD queryFlag = flag == HWOCCLUSIONQUERY_FLUSH ? D3DGETDATA_FLUSH : 0; 141 112 // TO DO: USE lockOpts= D3D9Mappings::get(options); instead of RS_OCCLUSIONQUERY enum 142 113 143 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 114 return pullOcclusionQuery(NumOfFragments, waitForResult, queryFlag); 115 } 116 //------------------------------------------------------------------ 117 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 118 const DWORD queryFlag ) 119 { 120 HRESULT hr = S_OK; 121 122 if( m_bHWOcclusionSupport ) // In case hardware occlusion isn't supported 123 { 124 do 125 { 126 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), queryFlag ); 127 } 128 while(waitForResult && (hr == S_FALSE)); 129 130 m_uintPixelCount = *NumOfFragments; 131 } 132 else 144 133 { 134 m_uintPixelCount = 100000; // every object is visible 135 } 145 136 146 switch( flag ) 147 { 148 case HWOCCLUSIONQUERY_FLUSH : 149 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 150 break; 151 152 case HWOCCLUSIONQUERY_NOFLUSH : 153 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), 0 ); 154 break; 155 }; 156 157 158 159 if ( hr != S_OK ) 160 { 161 return false; 162 } 163 else 164 { 165 m_uintPixelCount = *NumOfFragments; 166 return true; 167 } 168 } 169 else 170 { 171 m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 172 return true; 173 } 137 return hr == S_OK; 174 138 } 175 176 177 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 178 179 bool D3D9HardwareOcclusionQuery::resultAvailable() 180 { 181 bool result = true; 182 183 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 184 { //TODO: implement 185 //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, &result ); 186 } 187 188 return result; 189 } 190 191 #endif // GTP_VISIBILITY_MODIFIED_OGRE 192 193 } 139 } // namespace OGre -
trunk/VUT/work/ogre_changes/RenderSystem/GL/include/OgreGLHardwareOcclusionQuery.h
r61 r88 88 88 void beginOcclusionQuery(); 89 89 void endOcclusionQuery(); 90 bool pullOcclusionQuery( unsigned int* NumOfFragments); 91 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ); 92 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 93 bool resultAvailable(); 94 #endif 90 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ); 91 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 92 const HW_OCCLUSIONQUERY flag ); 93 95 94 unsigned int getLastQuerysPixelcount() { return m_uintPixelCount; } 96 95 -
trunk/VUT/work/ogre_changes/RenderSystem/GL/src/OgreGLHardwareOcclusionQuery.cpp
r61 r88 95 95 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 96 96 { 97 //if ( m_SkipCounter == m_Skip ) { m_SkipCounter = 0; }; // Counter starts at 0 again at m_Skip 98 //if ( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 99 //{ 100 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 101 //} 97 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 102 98 } 103 99 } … … 107 103 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 108 104 { 109 //if( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 110 //{ 111 glEndOcclusionQueryNV_ptr(); 112 //} 113 //m_SkipCounter++; 105 glEndOcclusionQueryNV_ptr(); 114 106 } 115 107 } 116 108 117 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments )109 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult) 118 110 { 119 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 111 unsigned int isAvailable = GL_TRUE; 112 113 if( m_bHWOcclusionSupport ) 120 114 { 121 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 115 if(!waitForResult) 116 { 117 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 118 } 119 120 if(isAvailable == GL_TRUE) 121 { 122 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 123 } 122 124 } 123 125 else 124 126 { 125 *NumOfFragments = 100000; // Fails quitlly -> every object tested is visable. 127 // In case hardware occlusion isn't supported, every object is set visible. 128 *NumOfFragments = 100000; 126 129 } 127 130 128 131 m_uintPixelCount = *NumOfFragments; 129 132 130 return true;133 return isAvailable == GL_TRUE; 131 134 } 132 135 133 136 //------------------------------------------------------------------ 134 // OpenGL do sn't use the flag, but to fulfilthe abstract interface we need to include this function.137 // OpenGL doesn't use the flag, but to implement the abstract interface we need to include this function. 135 138 // Using this function in OpenGL mode simple works the same way as calling the other function without the flag parameter, 136 139 // but in DX9 it works differentlly, see notes in the DX9 implementation. 137 140 //-- 138 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag )141 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag ) 139 142 { 140 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 141 { 142 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 143 } 144 else 145 { 146 *NumOfFragments = 100000; // Fails quitlly -> every object tested is visable. 147 } 148 149 m_uintPixelCount = *NumOfFragments; 150 151 return true; 143 return pullOcclusionQuery(NumOfFragments, waitForResult); 152 144 } 153 145 154 #ifdef GTP_VISIBILITY_MODIFIED_OGRE155 bool GLHardwareOcclusionQuery::resultAvailable()156 {157 unsigned int result = GL_TRUE;158 159 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported160 {161 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, &result );162 }163 164 return result == GL_TRUE;165 }166 #endif167 146 } 168 147
Note: See TracChangeset
for help on using the changeset viewer.