SharedState: Don't reallocate global tex on every bind
This commit is contained in:
		
							parent
							
								
									ee17bb2137
								
							
						
					
					
						commit
						b963c67339
					
				
					 1 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
					@ -88,6 +88,7 @@ struct SharedStatePrivate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TEX::ID globalTex;
 | 
						TEX::ID globalTex;
 | 
				
			||||||
	int globalTexW, globalTexH;
 | 
						int globalTexW, globalTexH;
 | 
				
			||||||
 | 
						bool globalTexDirty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TEXFBO gpTexFBO;
 | 
						TEXFBO gpTexFBO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,6 +145,7 @@ struct SharedStatePrivate
 | 
				
			||||||
		TEX::setRepeat(false);
 | 
							TEX::setRepeat(false);
 | 
				
			||||||
		TEX::setSmooth(false);
 | 
							TEX::setSmooth(false);
 | 
				
			||||||
		TEX::allocEmpty(globalTexW, globalTexH);
 | 
							TEX::allocEmpty(globalTexW, globalTexH);
 | 
				
			||||||
 | 
							globalTexDirty = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		TEXFBO::init(gpTexFBO);
 | 
							TEXFBO::init(gpTexFBO);
 | 
				
			||||||
		/* Reuse starting values */
 | 
							/* Reuse starting values */
 | 
				
			||||||
| 
						 | 
					@ -251,16 +253,27 @@ GlobalIBO &SharedState::globalIBO()
 | 
				
			||||||
void SharedState::bindTex()
 | 
					void SharedState::bindTex()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	TEX::bind(p->globalTex);
 | 
						TEX::bind(p->globalTex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (p->globalTexDirty)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		TEX::allocEmpty(p->globalTexW, p->globalTexH);
 | 
							TEX::allocEmpty(p->globalTexW, p->globalTexH);
 | 
				
			||||||
 | 
							p->globalTexDirty = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
					void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (minW > p->globalTexW)
 | 
						if (minW > p->globalTexW)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							p->globalTexDirty = true;
 | 
				
			||||||
		p->globalTexW = findNextPow2(minW);
 | 
							p->globalTexW = findNextPow2(minW);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (minH > p->globalTexH)
 | 
						if (minH > p->globalTexH)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							p->globalTexDirty = true;
 | 
				
			||||||
		p->globalTexH = findNextPow2(minH);
 | 
							p->globalTexH = findNextPow2(minH);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
 | 
						currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue