Changeset 88 for trunk/VUT/work/ogre_changes/RenderSystem/Direct3D9/src
- Timestamp:
- 05/09/05 22:55:21 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.