Allow Downsizing Textures
For some reason, this leads to a huge performance benefit on mobile devices, especially when using MegaSurface
This commit is contained in:
		
							parent
							
								
									eaf4bd5e66
								
							
						
					
					
						commit
						35c19792f8
					
				
					 2 changed files with 18 additions and 44 deletions
				
			
		| 
						 | 
				
			
			@ -263,39 +263,26 @@ void SharedState::bindTex()
 | 
			
		|||
 | 
			
		||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
			
		||||
{
 | 
			
		||||
	if (minW > p->globalTexW)
 | 
			
		||||
	minW = findNextPow2(minW); minH = findNextPow2(minH);
 | 
			
		||||
	
 | 
			
		||||
	if (minW != p->globalTexW || minH != p->globalTexH)
 | 
			
		||||
	{
 | 
			
		||||
		p->globalTexW = minW;
 | 
			
		||||
		p->globalTexH = minH;
 | 
			
		||||
		p->globalTexDirty = true;
 | 
			
		||||
		p->globalTexW = findNextPow2(minW);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (minH > p->globalTexH)
 | 
			
		||||
	{
 | 
			
		||||
		p->globalTexDirty = true;
 | 
			
		||||
		p->globalTexH = findNextPow2(minH);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
 | 
			
		||||
{
 | 
			
		||||
	bool needResize = false;
 | 
			
		||||
 | 
			
		||||
	if (minW > p->gpTexFBO.width)
 | 
			
		||||
	{
 | 
			
		||||
		p->gpTexFBO.width = findNextPow2(minW);
 | 
			
		||||
		needResize = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (minH > p->gpTexFBO.height)
 | 
			
		||||
	{
 | 
			
		||||
		p->gpTexFBO.height = findNextPow2(minH);
 | 
			
		||||
		needResize = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (needResize)
 | 
			
		||||
	minW = findNextPow2(minW); minH = findNextPow2(minH);
 | 
			
		||||
	
 | 
			
		||||
	if (minW != p->gpTexFBO.width || minH != p->gpTexFBO.height)
 | 
			
		||||
	{
 | 
			
		||||
		p->gpTexFBO.width = minW;
 | 
			
		||||
		p->gpTexFBO.height = minH;
 | 
			
		||||
		TEX::bind(p->gpTexFBO.tex);
 | 
			
		||||
		TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -388,29 +388,16 @@ struct WindowPrivate
 | 
			
		|||
 | 
			
		||||
	void ensureBaseTexReady()
 | 
			
		||||
	{
 | 
			
		||||
		/* Make sure texture is big enough */
 | 
			
		||||
		int newW = baseTex.width;
 | 
			
		||||
		int newH = baseTex.height;
 | 
			
		||||
		bool resizeNeeded = false;
 | 
			
		||||
		/* Make sure texture is properly sized */
 | 
			
		||||
		int newW = findNextPow2(size.x);
 | 
			
		||||
		int newH = findNextPow2(size.y);
 | 
			
		||||
 | 
			
		||||
		if (size.x > baseTex.width)
 | 
			
		||||
		if (newW != baseTex.width || newH != baseTex.height)
 | 
			
		||||
		{
 | 
			
		||||
			newW = findNextPow2(size.x);
 | 
			
		||||
			resizeNeeded = true;
 | 
			
		||||
			shState->texPool().release(baseTex);
 | 
			
		||||
			baseTex = shState->texPool().request(newW, newH);
 | 
			
		||||
			baseTexDirty = true;
 | 
			
		||||
		}
 | 
			
		||||
		if (size.y > baseTex.height)
 | 
			
		||||
		{
 | 
			
		||||
			newH = findNextPow2(size.y);
 | 
			
		||||
			resizeNeeded = true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!resizeNeeded)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		shState->texPool().release(baseTex);
 | 
			
		||||
		baseTex = shState->texPool().request(newW, newH);
 | 
			
		||||
 | 
			
		||||
		baseTexDirty = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void redrawBaseTex()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue