Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrongfully fails on loop in my kernel #172

Open
liufeicc opened this issue Aug 8, 2023 · 0 comments
Open

wrongfully fails on loop in my kernel #172

liufeicc opened this issue Aug 8, 2023 · 0 comments

Comments

@liufeicc
Copy link

liufeicc commented Aug 8, 2023

ERROR IN Function isHidden

com.aparapi.internal.instruction.ExpressionList
LINE 526:might be mistaken for a do while!

Here are some of my code:
@OverRide
public void run()
{
int triangleIdx = getGlobalId();

	int firstVertex = indexBuffer[triangleIdx * 3 + 2];
	int secondVertex = indexBuffer[triangleIdx * 3 + 1];
	int thirdVertex = indexBuffer[triangleIdx * 3];
	
	setVertex(VIdxN3(triangleIdx, 0), updatedVertices, firstVertex, updatedVertexBuffer);
	setVertex(VIdxN3(triangleIdx, 1), updatedVertices, secondVertex, updatedVertexBuffer);
	setVertex(VIdxN3(triangleIdx, 2), updatedVertices, thirdVertex, updatedVertexBuffer);
	
	vertexLightLevel[N4(triangleIdx, 0)] = vertexLightLevelBuffer[firstVertex];
	vertexLightLevel[N4(triangleIdx, 1)] = vertexLightLevelBuffer[secondVertex];
	vertexLightLevel[N4(triangleIdx, 2)] = vertexLightLevelBuffer[thirdVertex];
	
	if(isHidden(triangleIdx))
	  	return;
	
	if(clipZNearPlane(triangleIdx))
		return;
	
	if(colorRenderType == 2) 
		transformTexture(triangleIdx, firstVertex);
	else if(colorRenderType == 3)
		transformBarycentricTextured(triangleIdx);

	scanTriangle(triangleIdx);
}

private boolean isHidden(int triangleIdx)
{		
	boolean allBehindClippingPlane = true;
	for (int i = 0; i < 3; i++)
	{
		if (ZN33(triangleIdx, i) >= nearClipDistance)
		{
			allBehindClippingPlane = false;
			break;
		}
	}
	if (allBehindClippingPlane)
		return true;

	setVertex(triangleIdx, edge1, VIdxN3(triangleIdx, 1), updatedVertices);
	sub(triangleIdx, edge1, VIdxN3(triangleIdx, 0), updatedVertices);
	setVertex(triangleIdx, edge2, VIdxN3(triangleIdx, 2), updatedVertices);
	sub(triangleIdx, edge2, VIdxN3(triangleIdx, 0), updatedVertices);
	cross(triangleIdx, surfaceNormal, triangleIdx, edge1, triangleIdx, edge2);
	float dotProduct = dot(triangleIdx, surfaceNormal, VIdxN3(triangleIdx, 0), updatedVertices);
	if (dotProduct >= 0)
		return true;

	testBoundary(triangleIdx);

	if (leftMostPosition[triangleIdx] == SCREEN_W 
			|| rightMostPosition[triangleIdx] == -1 
			|| upperMostPosition[triangleIdx] == SCREEN_H
			|| lowerMostPosition[triangleIdx] == -1)
		return true;

	isClippingRightOrLeft[triangleIdx] = false;
	if (leftMostPosition[triangleIdx] < 0 || rightMostPosition[triangleIdx] >= SCREEN_W)
		isClippingRightOrLeft[triangleIdx] = true;

	return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant