Changeset 115 for trunk/VUT/work/ogre_changes/RenderSystems
- Timestamp:
- 05/30/05 03:20:23 (20 years ago)
- Location:
- trunk/VUT/work/ogre_changes/RenderSystems
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9HardwareOcclusionQuery.h
r92 r115 33 33 namespace Ogre { 34 34 35 36 37 35 // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered 38 // if the first pass resultet has too few pixels visable.36 // if the first pass resultet has too few pixels visible. 39 37 40 38 // Be sure to render all occlluder first and whats out so the RenderQue don't switch places on … … 46 44 * 47 45 * @author Lee Sandberg, email lee@abcmedia.se 46 * 47 * Updated on 12/7/2004 by Chris McGuirk 48 48 */ 49 49 class D3D9HardwareOcclusionQuery : public HardwareOcclusionQuery … … 71 71 void beginOcclusionQuery(); 72 72 void endOcclusionQuery(); 73 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH); 74 unsigned int getLastQuerysPixelcount() { return mPixelCount; } 73 75 74 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 75 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 76 const HW_OCCLUSIONQUERY flag ); 77 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ); 78 #else 79 bool pullOcclusionQuery( unsigned int* NumOfFragments ); 80 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ); 81 #endif // GTP_VISIBILITY_MODIFIED_OGRE 82 83 unsigned int getLastQuerysPixelcount() { return m_uintPixelCount; } 84 85 // This functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visable objects only 86 // 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.. 87 // (None visable objects and object you introduce for the first time have allways to be tested allthough the cheepest possible 88 // LOD (Level Of Detail) mesh and material wize). 76 // These functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only 77 // It's easy to use if you don't have to keep track of which objects are visible (can be skipped) and what objects arn't visible.. 78 // (None visible objects and object you introduce for the first time have always to be tested although the cheapest possible 79 // LOD (Level Of Detail) mesh and material-wise). 89 80 90 81 /** 91 82 * 92 * Remarks This function allows you to set how often the hardware occlusion really aresent to the driver83 * Remarks This function allows you to set how often the hardware occlusion query is sent to the driver 93 84 * if you set it to 0 every hw occlusion test is acctually made. If you set it to 1 only the half of your queries are sent 94 * for all visable objects. 2 will result in 25% of all queries to acctualy be sent. 95 * New and none visable objects will be tested all the time. 96 * This functionality is here because this class can keep track on visable and none visable objects for you. 85 * 2 will result in 25% of all queries to acctualy be sent. 86 * This functionality is here because this class can keep track on visible and none visible objects for you. 97 87 * Once you you set the SkipRate for any hardware occlusion instance it effects all others. 98 88 */ 99 89 90 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actully made and 3 results in only 33% of the tests. So on. 91 int getSkipRate() { return mSkipInterval; } 100 92 101 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. 102 int getSkipRate() { return m_Skip; }103 93 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 94 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH ); 95 #endif // GTP_VISIBILITY_MODIFIED_OGRE 104 96 //---------------------------------------------------------------------- 105 97 // Protected members … … 107 99 protected: 108 100 109 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 110 const DWORD queryFlag ); 111 112 unsigned int m_uintPixelCount; 113 IDirect3DQuery9* m_pD3DQuery; 114 IDirect3DDevice9* m_pD3DDevice; // d3d device 115 bool m_bOcclusionQuery; 116 int m_SkipCounter; // m_SkipConter = m_SkipConter % m_Skip; if ( m_SkipConter == 0 && m_uintPixelCount !=0 ) TestHWOcclusion else just return 117 static int m_Skip; // This is shared by all instancies 118 bool m_bHWOcclusionSupport; 101 unsigned int mPixelCount; 102 IDirect3DQuery9* mpQuery; 103 IDirect3DDevice9* mpDevice; 104 int mSkipCounter; 105 int mSkipInterval; 106 bool mHasOcclusionSupport; 119 107 }; 120 108 -
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp
r97 r115 29 29 namespace Ogre { 30 30 31 int D3D9HardwareOcclusionQuery::m_Skip = 0;32 33 31 /** 34 32 * This is a class that is the DirectX9 implementation of … … 36 34 * 37 35 * @author Lee Sandberg 36 * 37 * Updated on 12/7/2004 by Chris McGuirk 38 38 */ 39 39 40 40 /** 41 41 * Default object constructor 42 *43 42 */ 44 43 D3D9HardwareOcclusionQuery::D3D9HardwareOcclusionQuery( IDirect3DDevice9* pD3DDevice ) 45 44 { 46 m_pD3DDevice = pD3DDevice; 47 m_uintPixelCount = 0; 48 m_SkipCounter = 0; 49 m_bHWOcclusionSupport = false; 45 mpDevice = pD3DDevice; 46 mPixelCount = 0; 47 mSkipCounter = 0; 48 mSkipInterval = 0; 49 mHasOcclusionSupport = false; 50 50 51 HRESULT hr = m_pD3DDevice->CreateQuery(D3DQUERYTYPE_OCCLUSION, &m_pD3DQuery); 51 // create the occlusion query 52 HRESULT hr = mpDevice->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mpQuery); 53 52 54 if ( hr != D3D_OK ) 53 55 { 54 //OGRE_EXCEPT(hr, "D3D9HardwareOcclusionQuery couldn't create hardware occlusion query object.", 55 // "D3D9HardwareOcclusionQuery::D3D9HardwareOcclusionQuery"); 56 m_bHWOcclusionSupport = false; 56 mHasOcclusionSupport = false; 57 57 } 58 58 else 59 59 { 60 m_bHWOcclusionSupport = true;60 mHasOcclusionSupport = true; 61 61 } 62 62 } 63 64 63 65 64 /** … … 68 67 D3D9HardwareOcclusionQuery::~D3D9HardwareOcclusionQuery() 69 68 { 70 SAFE_RELEASE( m_pD3DQuery);69 SAFE_RELEASE(mpQuery); 71 70 } 72 71 73 #ifndef GTP_VISIBILITY_MODIFIED_OGRE74 72 //------------------------------------------------------------------ 75 73 // Occlusion query functions (see base class documentation for this) … … 77 75 void D3D9HardwareOcclusionQuery::beginOcclusionQuery() 78 76 { 79 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 77 // Make it fail silently if hardware occlusion isn't supported 78 if(mHasOcclusionSupport) 80 79 { 81 if ( m_SkipCounter == m_Skip ) { m_SkipCounter = 0; }; // Counter starts at 0 again at m_Skip 82 83 if ( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 80 #ifndef GTP_VISIBILITY_MODIFIED_OGRE 81 // Counter starts at 0 again at mSkipInterval 82 if(mSkipCounter == mSkipInterval) 83 #else 84 if (mSkipCounter >= mSkipInterval) // otherwise no query ever issued if mSkipInterval = 0 ! 85 #endif // GTP_VISIBILITY_MODIFIED_OGRE 84 86 { 85 m_pD3DQuery->Issue(D3DISSUE_BEGIN); 87 mSkipCounter = 0; 88 } 89 //std::stringstream d; d << "count: " << mSkipCounter; 90 //LogManager::getSingleton().logMessage(d.str()); 91 if (mSkipCounter == 0) 92 { 93 mpQuery->Issue(D3DISSUE_BEGIN); 86 94 } 87 95 } 96 88 97 } 89 90 void D3D9HardwareOcclusionQuery::endOcclusionQuery() 91 { 92 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 98 99 void D3D9HardwareOcclusionQuery::endOcclusionQuery() 93 100 { 94 if (m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 95 { 96 m_pD3DQuery->Issue(D3DISSUE_END); 97 } 98 m_SkipCounter++; // The skip counter is increased 101 // Make it fail silently if hardware occlusion isn't supported 102 if(mHasOcclusionSupport) 103 { 104 if(mSkipCounter == 0) 105 { 106 mpQuery->Issue(D3DISSUE_END); 107 } 108 109 // The skip counter is increased 110 mSkipCounter++; 99 111 } 100 112 } 101 113 102 114 //------------------------------------------------------------------ 103 // This version of pullOcclusionQuery cases the DX9 API/Driver to flush all commands to the 3D card 104 // to allow a fast result from the query, but at the cost of poorer batching of API calls to the card. 105 // Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 106 //-- 107 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments) 108 { 109 HRESULT hr; 110 111 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 112 { 113 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 114 115 if ( hr != S_OK ) 116 { 117 return false; 118 } 119 else 120 { 121 m_uintPixelCount = *NumOfFragments; 122 return true; 123 } 124 } 125 else 126 { 127 m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 128 return true; 129 } 130 } 131 132 //------------------------------------------------------------------ 133 // This version of pullOcclusionQuery cases the DX9 API/Driver to not flush all commands to the 3D card 115 // This version of pullOcclusionQuery causes the DX9 API/Driver to not flush all commands to the 3D card 134 116 // to allow a fast result from the query, but the batching of API calls to the card will be normal. 135 // But the query wont be processed until the card recives the query in the nexrbatch.117 // But the query wont be processed until the card recives the query in the next batch. 136 118 // Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 137 119 //-- … … 140 122 HRESULT hr; 141 123 142 // TO DO: USE lockOpts= D3D9Mappings::get(options); instead of RS_OCCLUSIONQUERY enum 124 // Make it fail silently if hardware occlusion isn't supported 125 if(mHasOcclusionSupport) 126 { 127 DWORD d3dFlags = (flag == HWOCCLUSIONQUERY_FLUSH) ? D3DGETDATA_FLUSH : 0; 128 129 // run until success (http://www.gamedev.net/reference/programming/features/occlusionculling/page2.asp) 130 while(hr = mpQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), d3dFlags) == S_FALSE); 143 131 144 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 145 { 146 147 switch( flag ) 148 { 149 case HWOCCLUSIONQUERY_FLUSH : 150 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 151 break; 152 153 case HWOCCLUSIONQUERY_NOFLUSH : 154 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), 0 ); 155 break; 156 }; 157 158 159 160 if ( hr != S_OK ) 161 { 162 return false; 132 mPixelCount = *NumOfFragments; 163 133 } 164 134 else 165 135 { 166 m_uintPixelCount = *NumOfFragments;167 return true;136 // fail silently if not supported, assume visible i suppose 137 mPixelCount = 100000; 168 138 } 169 } 170 else 171 { 172 m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 139 173 140 return true; 174 141 } 175 } 176 # else //GTP_VISIBILITY_MODIFIED_OGRE142 143 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 177 144 //------------------------------------------------------------------ 178 void D3D9HardwareOcclusionQuery::beginOcclusionQuery() 179 { 180 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 145 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 146 const HW_OCCLUSIONQUERY flag ) 181 147 { 182 m_pD3DQuery->Issue(D3DISSUE_BEGIN); 148 HRESULT hr = S_OK; 149 DWORD queryFlag = (flag == HWOCCLUSIONQUERY_FLUSH) ? D3DGETDATA_FLUSH : 0; 150 151 if (mHasOcclusionSupport) // In case hardware occlusion isn't supported 152 { 153 do 154 { 155 hr = mpQuery->GetData(NumOfFragments, sizeof(NumOfFragments), queryFlag); 156 } 157 while(waitForResult && (hr == S_FALSE)); 158 159 mPixelCount = *NumOfFragments; 160 } 161 else 162 { 163 mPixelCount = 100000; // every object is visible 164 } 165 166 return hr == S_OK; 183 167 } 184 }185 //------------------------------------------------------------------186 void D3D9HardwareOcclusionQuery::endOcclusionQuery()187 {188 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported189 {190 m_pD3DQuery->Issue(D3DISSUE_END);191 }192 }193 //------------------------------------------------------------------194 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult )195 {196 return pullOcclusionQuery(NumOfFragments, waitForResult, HWOCCLUSIONQUERY_FLUSH);197 }198 199 //------------------------------------------------------------------200 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,201 const HW_OCCLUSIONQUERY flag )202 {203 DWORD queryFlag = flag == HWOCCLUSIONQUERY_FLUSH ? D3DGETDATA_FLUSH : 0;204 // TO DO: USE lockOpts= D3D9Mappings::get(options); instead of RS_OCCLUSIONQUERY enum205 206 return pullOcclusionQuery(NumOfFragments, waitForResult, queryFlag);207 }208 209 //------------------------------------------------------------------210 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,211 const DWORD queryFlag )212 {213 HRESULT hr = S_OK;214 215 if( m_bHWOcclusionSupport ) // In case hardware occlusion isn't supported216 {217 do218 {219 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), queryFlag );220 }221 while(waitForResult && (hr == S_FALSE));222 223 m_uintPixelCount = *NumOfFragments;224 }225 else226 {227 m_uintPixelCount = 100000; // every object is visible228 }229 230 return hr == S_OK;231 }232 168 233 169 234 170 #endif // GTP_VISIBILITY_MODIFIED_OGRE 235 171 236 } // namespace OGre 172 173 } -
trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreGLHardwareOcclusionQuery.h
r92 r115 88 88 void beginOcclusionQuery(); 89 89 void endOcclusionQuery(); 90 91 #ifdef GTP_VISIBILITY_MODIFIED_OGRE92 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,93 const HW_OCCLUSIONQUERY flag );94 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult );95 #else96 bool pullOcclusionQuery( unsigned int* NumOfFragments );97 90 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ); 98 #endif // GTP_VISIBILITY_MODIFIED_OGRE 99 100 unsigned int getLastQuerysPixelcount() { return m_uintPixelCount; } 91 unsigned int getLastQuerysPixelcount() { return mPixelCount; } 101 92 102 93 // This functions are optional, it's a simple filter that simply skipps some hardware occlusion tests on visable objects only … … 115 106 */ 116 107 117 void setSkipRate( int skip ) { m _Skip= skip; } // Using 2 only 50 % of the tests are actully made and 3 results in only 33% of the tests. So on.118 int getSkipRate() { return m _Skip; }108 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actully made and 3 results in only 33% of the tests. So on. 109 int getSkipRate() { return mSkipInterval; } 119 110 120 111 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 112 bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH ); 113 #endif // GTP_VISIBILITY_MODIFIED_OGRE 121 114 //---------------------------------------------------------------------- 122 115 // Protected members … … 124 117 protected: 125 118 126 unsigned int m _uintPixelCount;127 unsigned int m_uintQuery[1];119 unsigned int mPixelCount; 120 GLuint mQueryID; 128 121 bool m_bOcclusionQuery; 129 int m _SkipCounter; // m_SkipConter = m_SkipConter % m_Skip; if ( m_SkipConter == 0 && m_uintPixelCount !=0 ) TestHWOcclusion else just return130 static int m_Skip; // This is shared by all instancies131 bool m _bHWOcclusionSupport;122 int mSkipCounter; 123 int mSkipInterval; 124 bool mHasOcclusionSupport; 132 125 }; 133 134 126 135 127 } -
trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreGLPrerequisites.h
r97 r115 70 70 extern GL_SecondaryColorPointerEXT_Func glSecondaryColorPointerEXT_ptr; 71 71 72 // Pointer to glSecondaryColor3fEXT function 73 typedef void (APIENTRY *GL_SecondaryColor3fEXT_Func)(GLfloat, GLfloat, GLfloat); 74 extern GL_SecondaryColor3fEXT_Func glSecondaryColor3fEXT_ptr; 75 72 76 // Pointer to glGenBuffersARB function 73 77 typedef void (APIENTRY *GL_GenBuffersARB_Func)(GLsizei, GLuint*); … … 208 212 extern GL_GetOcclusionQueryuivNV_Func glGetOcclusionQueryuivNV_ptr; 209 213 210 #ifdef GTP_VISIBILITY_MODIFIED_OGRE211 // Pointer to glGenQueriesARB function212 typedef void (APIENTRY *GL_GenQueriesARB_Func) (GLsizei n, GLuint *ids);213 extern GL_GenQueriesARB_Func glGenQueriesARB_ptr;214 215 // Pointer to glDeleteQueriesARB function216 typedef void (APIENTRY *GL_DeleteQueriesARB_Func) (GLsizei n, const GLuint *ids);217 extern GL_DeleteQueriesARB_Func glDeleteQueriesARB_ptr;218 219 // Pointer to glIsQueryARB function220 typedef GLboolean (APIENTRY *GL_IsQueryARB_Func) (GLuint id);221 extern GL_IsQueryARB_Func glIsQueryARB_ptr;222 223 // Pointer to glBeginQueryARB function224 typedef void (APIENTRY *GL_BeginQueryARB_Func) (GLenum target, GLuint id);225 extern GL_BeginQueryARB_Func glBeginQueryARB_ptr;226 227 // Pointer to glEndQueryARB function228 typedef void (APIENTRY *GL_EndQueryARB_Func) (GLenum target);229 extern GL_EndQueryARB_Func glEndQueryARB_ptr;230 231 // Pointer to glGetQueryivARB function232 typedef void (APIENTRY *GL_GetQueryivARB_Func) (GLuint id, GLenum pname, GLint *params);233 extern GL_GetQueryivARB_Func glGetQueryivARB_ptr;234 235 // Pointer to glGetQueryObjectivARB function236 typedef void (APIENTRY *GL_GetQueryObjectivARB_Func) (GLuint id, GLenum pname, GLint *params);237 extern GL_GetQueryObjectivARB_Func glGetQueryObjectivARB_ptr;238 239 // Pointer to glGetQueryObjectuivARB function240 typedef void (APIENTRY *GL_GetQueryObjectuivARB_Func) (GLuint id, GLenum pname, GLuint *params);241 extern GL_GetQueryObjectuivARB_Func glGetQueryObjectuivARB_ptr;242 243 #endif // GTP_VISIBILITY_MODIFIED_OGRE244 245 214 extern PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glCompressedTexImage1DARB_ptr; 246 215 extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB_ptr; … … 253 222 }; 254 223 224 // Pointer to glGenQueriesARB function 225 typedef void (APIENTRY *GL_GenQueriesARB_Func) (GLuint n, GLuint *ids); 226 extern GL_GenQueriesARB_Func glGenQueriesARB_ptr; 227 228 // Pointer to glDeleteQueriesARB function 229 typedef void (APIENTRY *GL_DeleteQueriesARB_Func) (GLuint n, const GLuint *ids); 230 extern GL_DeleteQueriesARB_Func glDeleteQueriesARB_ptr; 231 232 // Pointer to glBeginQueryARB function 233 typedef void (APIENTRY *GL_BeginQueryARB_Func) (GLenum target, GLuint id); 234 extern GL_BeginQueryARB_Func glBeginQueryARB_ptr; 235 236 // Pointer to glEndQueryARB function 237 typedef void (APIENTRY *GL_EndQueryARB_Func) (GLenum target); 238 extern GL_EndQueryARB_Func glEndQueryARB_ptr; 239 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 240 // Pointer to glGetQueryivARB function 241 typedef void (APIENTRY *GL_GetQueryivARB_Func) (GLuint id, GLenum pname, GLint *params); 242 extern GL_GetQueryivARB_Func glGetQueryivARB_ptr; 243 244 // Pointer to glGetQueryObjectivARB function 245 typedef void (APIENTRY *GL_GetQueryObjectivARB_Func) (GLuint id, GLenum pname, GLint *params); 246 extern GL_GetQueryObjectivARB_Func glGetQueryObjectivARB_ptr; 247 #endif // GTP_VISIBILITY_MODIFIED_OGRE 248 // Pointer to glGetQueryObjectuivARB function 249 typedef void (APIENTRY *GL_GetQueryObjectuivARB_Func) (GLuint id, GLenum pname, GLuint *params); 250 extern GL_GetQueryObjectuivARB_Func glGetQueryObjectuivARB_ptr; 255 251 256 252 -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp
r99 r115 27 27 #include "OgreException.h" 28 28 29 29 30 namespace Ogre { 30 31 int GLHardwareOcclusionQuery::m_Skip = 0;32 31 33 32 /** … … 36 35 * 37 36 * @author Lee Sandberg email: lee@abcmedia.se 37 * 38 * Updated on 12/7/2004 by Chris McGuirk 39 * - Implemented ARB_occlusion_query 38 40 */ 39 41 40 /* Functions used;41 42 glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );43 glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );44 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] );45 glEndOcclusionQueryNV_ptr();46 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments );47 48 TO DO: change this to the new ARB functions...49 50 */51 52 #ifndef GTP_VISIBILITY_MODIFIED_OGRE53 42 /** 54 43 * Default object constructor … … 57 46 GLHardwareOcclusionQuery::GLHardwareOcclusionQuery() 58 47 { 59 m_uintPixelCount = 0; 60 m_SkipCounter = 0; 48 mPixelCount = 0; 49 mSkipCounter = 0; 50 mSkipInterval = 0; 61 51 62 52 // Check for hardware occlusion support 63 if( glDeleteOcclusionQueriesNV_ptr != 0 ) // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 53 // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 54 //if (glGenQueriesARB_ptr != 0) 55 if (glGenOcclusionQueriesNV_ptr != 0) 64 56 { 65 m _bHWOcclusionSupport = true;57 mHasOcclusionSupport = true; 66 58 } 67 59 else 68 60 { 69 m _bHWOcclusionSupport = false;61 mHasOcclusionSupport = false; 70 62 } 71 63 72 if( m_bHWOcclusionSupport)64 if(mHasOcclusionSupport) 73 65 { 74 glGenOcclusionQueriesNV_ptr( 1, m_uintQuery ); 66 //glGenQueriesARB_ptr(1, &mQueryID ); 67 glGenOcclusionQueriesNV_ptr(1, &mQueryID); 75 68 } 76 69 } 77 78 70 79 71 /** … … 82 74 GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery() 83 75 { 84 if( m _bHWOcclusionSupport )76 if( mHasOcclusionSupport ) 85 77 { 86 glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] ); 78 //glDeleteQueriesARB_ptr(1, &mQueryID); 79 glDeleteOcclusionQueriesNV_ptr(1, &mQueryID); 87 80 } 88 81 } … … 93 86 void GLHardwareOcclusionQuery::beginOcclusionQuery() 94 87 { 95 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 88 // Make it fail silently if hardware occlusion isn't supported 89 if(mHasOcclusionSupport) 96 90 { 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 91 // Counter starts at 0 again at mSkipInterval 92 #ifndef GTP_VISIBILITY_MODIFIED_OGRE 93 if(mSkipCounter == mSkipInterval) 94 #else 95 if (mSkipCounter >= mSkipInterval) // otherwise no query ever issued if mSkipInterval = 0 ! 96 #endif // GTP_VISIBILITY_MODIFIED_OGRE 97 { 98 mSkipCounter = 0; 99 } 100 101 if (mSkipCounter == 0) 99 102 { 100 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 103 //glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, mQueryID); 104 glBeginOcclusionQueryNV_ptr(mQueryID); 101 105 } 102 106 } … … 105 109 void GLHardwareOcclusionQuery::endOcclusionQuery() 106 110 { 107 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 111 // Make it fail silently if hardware occlusion isn't supported 112 if(mHasOcclusionSupport) 108 113 { 109 if( m _SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped114 if( mSkipCounter == 0) 110 115 { 116 //glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 111 117 glEndOcclusionQueryNV_ptr(); 112 118 } 113 m_SkipCounter++;114 }115 }116 119 117 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments) 118 { 119 if( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 120 { 121 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 120 mSkipCounter++; 122 121 } 123 else124 {125 *NumOfFragments = 100000; // Fails quitlly -> every object tested is visable.126 }127 128 m_uintPixelCount = *NumOfFragments;129 130 return true;131 122 } 132 123 133 124 //------------------------------------------------------------------ 134 // OpenGL dosn't use the flag, but to fulfil the abstract interface we need to include this function. 135 // Using this function in OpenGL mode simple works the same way as calling the other function without the flag parameter, 136 // but in DX9 it works differentlly, see notes in the DX9 implementation. 137 //-- 125 // OpenGL dosn't use the flag paramter. 126 //------------------------------------------------------------------ 138 127 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ) 139 128 { 140 if( m _bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported129 if( mHasOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 141 130 { 142 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 131 //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 132 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 143 133 } 144 134 else … … 147 137 } 148 138 149 m _uintPixelCount = *NumOfFragments;139 mPixelCount = *NumOfFragments; 150 140 151 141 return true; 152 142 } 153 143 154 #else // GTP_VISIBILITY_MODIFIED_OGRE 155 156 //------------------------------------------------------------------ 157 GLHardwareOcclusionQuery::GLHardwareOcclusionQuery() 158 { 159 m_uintPixelCount = 0; 160 m_SkipCounter = 0; 161 162 // Check for hardware occlusion support 163 if ( glDeleteOcclusionQueriesNV_ptr != 0 ) // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 164 //if ( glDeleteQueriesARB_ptr != 0 ) 165 { 166 m_bHWOcclusionSupport = true; 167 } 168 else 169 { 170 m_bHWOcclusionSupport = false; 171 } 172 173 if ( m_bHWOcclusionSupport ) 174 { 175 glGenOcclusionQueriesNV_ptr( 1, m_uintQuery ); 176 //glGenQueriesARB_ptr(1, m_uintQuery); 177 } 178 } 179 180 181 //------------------------------------------------------------------ 182 GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery() 183 { 184 if ( m_bHWOcclusionSupport ) 185 { 186 glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] ); 187 //glDeleteQueriesARB_ptr(1, &m_uintQuery[0]); 188 } 189 } 190 191 //------------------------------------------------------------------ 192 void GLHardwareOcclusionQuery::beginOcclusionQuery() 193 { 194 if ( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 195 { 196 // do the actual occlusion query for this node 197 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 198 //glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]); 199 } 200 } 201 202 void GLHardwareOcclusionQuery::endOcclusionQuery() 203 { 204 if ( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 205 { 206 glEndOcclusionQueryNV_ptr(); 207 //glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 208 } 209 } 210 //------------------------------------------------------------------ 211 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult) 144 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 145 //------------------------------------------------------------------ 146 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag) 212 147 { 213 148 unsigned int isAvailable = GL_TRUE; 214 //int isAvailable = GL_TRUE;215 149 216 if( m_bHWOcclusionSupport)150 if (mHasOcclusionSupport) 217 151 { 218 152 if (!waitForResult) 219 153 { 220 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 221 //glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 154 // use nv queries rather that arb because they are faster (no flush) 155 //glGetQueryivARB_ptr(mQueryID, GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 156 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable); 222 157 } 223 158 224 159 if (isAvailable == GL_TRUE) 225 160 { 226 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments);227 //glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments);161 //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 162 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 228 163 } 229 164 } … … 234 169 } 235 170 236 m_uintPixelCount = *NumOfFragments;171 mPixelCount = *NumOfFragments; 237 172 238 173 return isAvailable == GL_TRUE; 239 174 } 240 175 241 //------------------------------------------------------------------ 242 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag ) 243 { 244 return pullOcclusionQuery(NumOfFragments, waitForResult); 176 #endif // GTP_VIBILITY_MODIFIED_OGRE 245 177 } 246 247 #endif // GTP_VISIBILITY_MODIFIED_OGRE248 249 250 }251 252 -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp
r97 r115 58 58 GL_ClientActiveTextureARB_Func glClientActiveTextureARB_ptr; 59 59 GL_SecondaryColorPointerEXT_Func glSecondaryColorPointerEXT_ptr; 60 GL_SecondaryColor3fEXT_Func glSecondaryColor3fEXT_ptr; 60 61 GL_GenBuffersARB_Func glGenBuffersARB_ptr; 61 62 GL_BindBufferARB_Func glBindBufferARB_ptr; … … 97 98 GL_EndOcclusionQueryNV_Func glEndOcclusionQueryNV_ptr; 98 99 GL_GetOcclusionQueryuivNV_Func glGetOcclusionQueryuivNV_ptr; 99 100 #ifdef GTP_VISIBILITY_MODIFIED_OGRE101 100 GL_GenQueriesARB_Func glGenQueriesARB_ptr; 102 101 GL_DeleteQueriesARB_Func glDeleteQueriesARB_ptr; 103 GL_IsQueryARB_Func glIsQueryARB_ptr;104 102 GL_BeginQueryARB_Func glBeginQueryARB_ptr; 105 103 GL_EndQueryARB_Func glEndQueryARB_ptr; 104 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 106 105 GL_GetQueryivARB_Func glGetQueryivARB_ptr; 107 106 GL_GetQueryObjectivARB_Func glGetQueryObjectivARB_ptr; 107 #endif // GTP_VISIBILITY_MODIFIED_OGRE 108 108 GL_GetQueryObjectuivARB_Func glGetQueryObjectuivARB_ptr; 109 #endif // GTP_VISIBILITY_MODIFIED_OGRE110 109 111 110 namespace Ogre { … … 191 190 glClientActiveTextureARB_ptr = 0; 192 191 glSecondaryColorPointerEXT_ptr = 0; 192 glSecondaryColor3fEXT_ptr = 0; 193 193 glGenBuffersARB_ptr = 0; 194 194 glBindBufferARB_ptr = 0; … … 220 220 glEndOcclusionQueryNV_ptr = 0; 221 221 glGetOcclusionQueryuivNV_ptr = 0; 222 223 #ifdef GTP_VISIBILITY_MODIFIED_OGRE224 222 glGenQueriesARB_ptr = 0; 225 223 glDeleteQueriesARB_ptr = 0; 226 glIsQueryARB_ptr = 0;227 224 glBeginQueryARB_ptr = 0; 228 225 glEndQueryARB_ptr = 0; 226 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 229 227 glGetQueryivARB_ptr = 0; 230 228 glGetQueryObjectivARB_ptr = 0; 229 #endif // GTP_VISIBILITY_MODIFIED_OGRE 231 230 glGetQueryObjectuivARB_ptr = 0; 232 #endif // GTP_VISIBILITY_MODIFIED_OGRE233 231 234 232 mCurrentLights = 0; … … 543 541 glSecondaryColorPointerEXT_ptr = 544 542 (GL_SecondaryColorPointerEXT_Func)mGLSupport->getProcAddress("glSecondaryColorPointerEXT"); 543 glSecondaryColor3fEXT_ptr = 544 (GL_SecondaryColor3fEXT_Func)mGLSupport->getProcAddress("glSecondaryColor3fEXT"); 545 545 glGenBuffersARB_ptr = 546 546 (GL_GenBuffersARB_Func)mGLSupport->getProcAddress("glGenBuffersARB"); … … 622 622 glGetOcclusionQueryuivNV_ptr = 623 623 (GL_GetOcclusionQueryuivNV_Func)mGLSupport->getProcAddress("glGetOcclusionQueryuivNV"); 624 glGetQueryObjectivARB_ptr = 625 (GL_GetQueryObjectivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectivARB"); 626 glGetQueryObjectuivARB_ptr = 627 (GL_GetQueryObjectuivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectuivARB"); 628 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 624 629 625 glGenQueriesARB_ptr = 630 626 (GL_GenQueriesARB_Func)mGLSupport->getProcAddress("glGenQueriesARB"); 631 627 glDeleteQueriesARB_ptr = 632 628 (GL_DeleteQueriesARB_Func)mGLSupport->getProcAddress("glDeleteQueriesARB"); 633 glIsQueryARB_ptr =634 (GL_IsQueryARB_Func)mGLSupport->getProcAddress("glIsQueryARB");635 629 glBeginQueryARB_ptr = 636 630 (GL_BeginQueryARB_Func)mGLSupport->getProcAddress("glBeginQueryARB"); 637 631 glEndQueryARB_ptr = 638 632 (GL_EndQueryARB_Func)mGLSupport->getProcAddress("glEndQueryARB"); 633 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 639 634 glGetQueryivARB_ptr = 640 635 (GL_GetQueryivARB_Func)mGLSupport->getProcAddress("glGetQueryivARB"); 641 636 glGetQueryObjectivARB_ptr = 642 637 (GL_GetQueryObjectivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectivARB"); 638 #endif // GTP_VISIBILITY_MODIFIED_OGRE 643 639 glGetQueryObjectuivARB_ptr = 644 640 (GL_GetQueryObjectuivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectuivARB"); 645 #endif // GTP_VISIBILITY_MODIFIED_OGRE646 641 647 642 mCapabilities->log(LogManager::getSingleton().getDefaultLog()); … … 1857 1852 cv1[2] = bm.colourArg1.b; 1858 1853 cv1[3] = bm.colourArg1.a; 1854 mManualBlendColours[stage][0] = bm.colourArg1; 1855 1859 1856 1860 1857 cv2[0] = bm.colourArg2.r; … … 1862 1859 cv2[2] = bm.colourArg2.b; 1863 1860 cv2[3] = bm.colourArg2.a; 1861 mManualBlendColours[stage][1] = bm.colourArg2; 1864 1862 } 1865 1863 1866 1864 if (bm.blendType == LBT_ALPHA) 1867 1865 { 1868 cv1[0] = 0;1869 cv1[1] = 0;1870 cv1[2] = 0;1866 cv1[0] = mManualBlendColours[stage][0].r; 1867 cv1[1] = mManualBlendColours[stage][0].g; 1868 cv1[2] = mManualBlendColours[stage][0].b; 1871 1869 cv1[3] = bm.alphaArg1; 1872 1870 1873 cv2[0] = 0;1874 cv2[1] = 0;1875 cv2[2] = 0;1871 cv2[0] = mManualBlendColours[stage][1].r; 1872 cv2[1] = mManualBlendColours[stage][1].g; 1873 cv2[2] = mManualBlendColours[stage][1].b; 1876 1874 cv2[3] = bm.alphaArg2; 1877 1875 } … … 2249 2247 } 2250 2248 glColor4f(1,1,1,1); 2249 glSecondaryColor3fEXT_ptr(0.0f, 0.0f, 0.0f); 2251 2250 2252 2251 // UnGuard … … 2537 2536 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); 2538 2537 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); 2538 glEnable(GL_COLOR_SUM); 2539 2539 2540 // Check for FSAA 2540 2541 // Enable the extension if it was enabled by the GLSupport
Note: See TracChangeset
for help on using the changeset viewer.