public static ExecResult runValidatorOnShader(ExecHelper.RedirectType redirectType, File file) throws IOException, InterruptedException { return new ExecHelper().exec( redirectType, null, false, ToolPaths.glslangValidator(), file.toString()); }
public static ExecResult runShaderTranslatorOnShader(ExecHelper.RedirectType redirectType, File file, String arg) throws IOException, InterruptedException { return new ExecHelper().exec( redirectType, null, false, ToolPaths.shaderTranslator(), arg, file.toString()); }
public static String getShadersDirectory() { File jarDir = getJarDirectory(); if (isRunningFromIde(jarDir)) { return Paths.get( getSourceRoot(jarDir), "shaders", "src", "main", "glsl").toString(); } return Paths.get(getInstallDirectory(), "shaders").toString(); }
public static ExecResult runSwiftshaderOnShader( ExecHelper.RedirectType redirectType, File fragmentShader, File imageOutput, boolean skipRender, int width, int height) throws IOException, InterruptedException { List<String> command = new ArrayList<>(Arrays.asList( ToolPaths.getImageEglSwiftshader(), fragmentShader.toString(), "--output", imageOutput.toString(), "--resolution", String.valueOf(width), String.valueOf(height))); if (skipRender) { command.add("--exit-linking"); } return new ExecHelper().exec( redirectType, null, false, command.toArray(new String[]{})); }
@Override public boolean isInteresting(File shaderJobFile, File shaderResultFileOutput) throws FileJudgeException { try { final ExecResult execResult = new ExecHelper().exec( ExecHelper.RedirectType.TO_BUFFER, directory, true, judgeScript.getAbsolutePath(), shaderJobFile.getAbsolutePath(), shaderResultFileOutput.getAbsolutePath()); LOGGER.info("Custom file judge stdout: " + execResult.stdout); LOGGER.info("Custom file judge stderr: " + execResult.stderr); LOGGER.info("Custom file judge result: " + execResult.res); return execResult.res == 0; } catch (IOException | InterruptedException exception) { throw new FileJudgeException(exception); } } }
public static ExecResult runGenerateImageOnShader(ExecHelper.RedirectType redirectType, File fragmentShader, File imageOutput, boolean skipRender) throws IOException, InterruptedException { List<String> command = new ArrayList<>(Arrays.asList( ToolPaths.getImageGlfw(), fragmentShader.toString(), "--output", imageOutput.toString())); if (skipRender) { command.add("--exit-linking"); } return new ExecHelper().exec( redirectType, null, false, command.toArray(new String[]{})); }
@Override public CommandResult executeCommand(String name, List<String> command) throws TException { try { ExecResult res = new ExecHelper(ToolPaths.getPythonDriversDir()).exec( RedirectType.TO_BUFFER, null, true, command.toArray(new String[0]) ); return new CommandResult().setOutput(res.stdout.toString()) .setError(res.stderr.toString()) .setExitCode(res.res); } catch (Exception ex) { throw new TException(ex); } }
public static String getInstallDirectory() { File jarDir = getJarDirectory(); if (isRunningFromIde(jarDir)) { return Paths.get( getSourceRoot(jarDir), "graphicsfuzz", "target", "graphicsfuzz").toString(); } return jarDir.getParentFile().toString(); }
public static String getStaticDir() { return Paths.get(ToolPaths.getInstallDirectory(), "server-static").toString(); }
public static String getImageEglSwiftshader() { return Paths.get(ToolPaths.getBinDir(), "swiftshader", "get_image_egl").toString(); }
public static String getPythonDriversDir() { return Paths.get(getPythonDir(), "drivers").toString(); }
public static String getSourceRoot(File jarDir) { if (!isRunningFromIde(jarDir)) { throw new IllegalStateException(); } return jarDir.getParentFile().getParentFile().toString(); }
public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = br.readLine()) != null) { handleLine(line); } } catch (IOException exception) { LOGGER.error("Exception while gobbling stream", exception); } }
private boolean shaderIsValid( File shaderFile, boolean throwExceptionOnValidationError) throws IOException, InterruptedException { return checkValidationResult(ToolHelper.runValidatorOnShader(ExecHelper.RedirectType.TO_BUFFER, shaderFile), shaderFile.getName(), throwExceptionOnValidationError); }
public static void main(String[] args) throws IOException, ParseTimeoutException, InterruptedException { final File shader = new File(args[0]); final String licenseFilename = args[1]; ExecResult execResult = new ExecHelper().exec( RedirectType.TO_BUFFER, null, false, "cpp", "-P", args[0]); ShaderJobFileOperations fileOps = new ShaderJobFileOperations(); ShaderJob shaderJob = fileOps.readShaderJobFile( new File(args[0]) ); // TODO: Reimplement obfuscator if needed. throw new RuntimeException("Obfuscator command-line tool no longer implemented."); }
public static String getBinDir() { String osName = System.getProperty("os.name").split(" ")[0]; File jarDir = getJarDirectory(); if (isRunningFromIde(jarDir)) { return Paths.get( getSourceRoot(jarDir), "assembly-binaries", "target", "assembly-binaries-1.0", "bin", osName).toString(); } return Paths.get(getInstallDirectory(), "bin", osName).toString(); }
public static String getPythonDir() { return Paths.get(ToolPaths.getInstallDirectory(), "python").toString(); }
public static String glslangValidator() { return Paths.get(getBinDir(), "glslangValidator").toString(); }
public static String shaderTranslator() { return Paths.get(getBinDir(), "shader_translator").toString(); }
public static String getImageGlfw() { return Paths.get(ToolPaths.getBinDir(), "get_image_glfw").toString(); }