Jump to content
  • Advertisement
Sign in to follow this  
AxeGuywithanAxe

Nested for loops hlsl(SOLVED)

This topic is 947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, so I've been having this issue with compiling my compute shader code for SM5 A* path finding, and by issue I mean my D3D11CompileFromFile has been running for roughly 8 hours. Below is the essence of my code. I wanted to know if anyone has anyways to help me fix the issue, I've done as much as I possibly can to remove branches and for loops, but it still won't compile in a reasonable timespan. The search for the lowest F - Value compiles in about two minutes, but once I add the code for the neighbor search, it is stuck compiling. I have gone through many iterations of the neighbor for loop, from linear searching of data, to instant access through cpu side knowledge of grid layout, from if statements to switch statements, and I still can't seem to fix the issue. a Thank you.






#define MAX_NAV_NODE_SEARCH_COUNT (80)

[numthreads(THREADGROUP_SIZEX,THREADGROUP_SIZEY,1)]
void FindPathCS(in uint3 DispatchThreadId : SV_DispatchThreadID)
{


	int OpenListCount = 0;
	
	//add the start node to the search open list 
	.....
	OpenListCount++;
	
	for(int nodeCheckIndex = 0; (nodeCheckIndex < MAX_NAV_NODE_SEARCH_COUNT && OpenListCount >0); nodeCheckIndex++)
	{
		//find the lowest F value 
		....
		for(int i = 0; i < MAX_NAV_NODE_COUNT; i++)
		{
			if(g_NavigationPathNodesScratch[i].m_FTotal < CurrentFTotal)
			{
				CurrentFTotal = g_NavigationPathNodesScratch[i];
				...
			}
		}
		
		//traverse the neighbors
		for(i = 0; i < CurrAreaData.NeighborCount; i++)
		{
			//get neighbor data from Structured Buffer 
			//no a walkable neighbor, continue 
			if(!NeighborStaticData.IsWalkable)
			{
				continue;
			}
			
			//check what state the neighbor is in 
			switch(g_NavigationPathNodesScratch[Neighbor].m_Flags)
			{
				//it is in the closed list so ignore it 
				case NAVPATH_CLOSED:
				{
					break;
				}
				//is is in the open list, so update it's nav data 
				case NAVPATH_OPEN:
				{
					....
				}
				//it hasn't been reached yet, so add it to the open list 
				case NAVPATH_INVALID:
				{
					....
				}
			}
		}
	
	}


}
Edited by AThompson

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!