graphicsfuzz icon indicating copy to clipboard operation
graphicsfuzz copied to clipboard

gfauto doesn't handle an integer with the minimum possible value properly

Open amakin-siru opened this issue 4 years ago • 1 comments

If an input shader includes an integer variable with the minimum possible value, gfauto doesn't handle it properly.

The reason for this behavior is that the visitUnaryExpr method in StandardVisitor passes the integer without the sign to the LiteralToUniformReductionOpportunity class and the positive value goes out of range.

Here's a stacktrace which is the result of having the value -2147483648 in one of the unit tests:

java.lang.NumberFormatException: For input string: "2147483648"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:587)
	at java.lang.Integer.parseInt(Integer.java:615)
	at com.graphicsfuzz.common.ast.expr.IntConstantExpr.getNumericValue(IntConstantExpr.java:48)
	at com.graphicsfuzz.reducer.reductionopportunities.LiteralToUniformReductionOpportunity.applyReductionImpl(LiteralToUniformReductionOpportunity.java:70)
	at com.graphicsfuzz.reducer.reductionopportunities.AbstractReductionOpportunity.applyReduction(AbstractReductionOpportunity.java:39)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at com.graphicsfuzz.reducer.reductionopportunities.LiteralToUniformReductionOpportunitiesTest.testReplaceSimpleInt(LiteralToUniformReductionOpportunitiesTest.java:80)

amakin-siru avatar Sep 30 '20 10:09 amakin-siru

I will be working on this

sneh19337 avatar Mar 14 '21 00:03 sneh19337