-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Rework shader generation in Java (#173)
Shader generation is now written in Java, rather than Python, reducing the extent to which Python is a dependency and making testing of shader generation simpler as it can be done in JUnit. Fixed an issue where do ... while loops were generated in WebGL 1.0 shaders. Fixed an infinite loop issue in the generator, where if no available transformation could make progress the transformations would be applied forever. Added a workaround for a memory exhaustion issue in shader translator. Added tests for shader family generation. Changed generation top-level script so that - is used instead of _ to separate arguments, in line with the way glsl-reduce works. Changed the order of arguments to glsl-generate so that the references are specified before the donors. Removed the need for the user to explicitly make the output directory for shaders. Replaced --avoid-long-loops with an opposite option, --allow-long-loops, so that long loops are disabled by default. Replaced --multi-pass with an opposite --single-pass option, so that multi-pass is default. Made --max-bytes default to 500000, which has been found to work well. Updated glsl-fuzz walkthrough to reflect these changes.
- Loading branch information
1 parent
ab3c44b
commit 2c443e8
Showing
33 changed files
with
1,237 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...main/java/com/graphicsfuzz/common/util/ShaderTranslatorShadingLanguageVersionSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
/* | |||
* Copyright 2018 The GraphicsFuzz Project Authors | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* https://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package com.graphicsfuzz.common.util; | |||
|
|||
import com.graphicsfuzz.common.glslversion.ShadingLanguageVersion; | |||
import java.util.Arrays; | |||
|
|||
public final class ShaderTranslatorShadingLanguageVersionSupport { | |||
|
|||
private ShaderTranslatorShadingLanguageVersionSupport() { | |||
// Utility class | |||
} | |||
|
|||
public static boolean isVersionSupported(ShadingLanguageVersion shadingLanguageVersion) { | |||
// Shader translator does have a -s=e31 option, but it is still marked as "in development". | |||
return Arrays.asList(ShadingLanguageVersion.WEBGL_SL, | |||
ShadingLanguageVersion.WEBGL2_SL, | |||
ShadingLanguageVersion.ESSL_100, | |||
ShadingLanguageVersion.ESSL_300).contains(shadingLanguageVersion); | |||
} | |||
|
|||
public static String getShaderTranslatorArgument(ShadingLanguageVersion shadingLanguageVersion) { | |||
if (!isVersionSupported(shadingLanguageVersion)) { | |||
throw new IllegalArgumentException("Shader translator does not support the given shading" | |||
+ " language version."); | |||
} | |||
if (shadingLanguageVersion == ShadingLanguageVersion.WEBGL_SL) { | |||
return "-s=w"; | |||
} else if (shadingLanguageVersion == ShadingLanguageVersion.WEBGL2_SL) { | |||
return "-s=w2"; | |||
} else if (shadingLanguageVersion == ShadingLanguageVersion.ESSL_100) { | |||
return "-s=e2"; | |||
} | |||
assert shadingLanguageVersion == ShadingLanguageVersion.ESSL_300; | |||
return "-s=e3"; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.