public void Glsl450EndToEnd(string vsName, string fsName) { Compilation compilation = TestUtil.GetTestProjectCompilation(); LanguageBackend backend = new Glsl450Backend(compilation); ShaderGenerator sg = new ShaderGenerator( compilation, vsName, fsName, backend); ShaderGenerationResult result = sg.GenerateShaders(); IReadOnlyList <GeneratedShaderSet> sets = result.GetOutput(backend); Assert.Equal(1, sets.Count); GeneratedShaderSet set = sets[0]; ShaderModel shaderModel = set.Model; if (vsName != null) { ShaderFunction vsFunction = shaderModel.GetFunction(vsName); string vsCode = set.VertexShaderCode; GlsLangValidatorTool.AssertCompilesCode(vsCode, "vert", true); } if (fsName != null) { ShaderFunction fsFunction = shaderModel.GetFunction(fsName); string fsCode = set.FragmentShaderCode; GlsLangValidatorTool.AssertCompilesCode(fsCode, "frag", true); } }
public void AllSetsAllLanguagesEndToEnd() { Compilation compilation = TestUtil.GetTestProjectCompilation(); LanguageBackend[] backends = new LanguageBackend[] { new HlslBackend(compilation), new Glsl330Backend(compilation), new Glsl450Backend(compilation), }; ShaderGenerator sg = new ShaderGenerator(compilation, backends); ShaderGenerationResult result = sg.GenerateShaders(); foreach (LanguageBackend backend in backends) { IReadOnlyList <GeneratedShaderSet> sets = result.GetOutput(backend); foreach (GeneratedShaderSet set in sets) { if (set.VertexShaderCode != null) { if (backend is HlslBackend) { FxcTool.AssertCompilesCode(set.VertexShaderCode, "vs_5_0", set.VertexFunction.Name); } else { bool is450 = backend is Glsl450Backend; GlsLangValidatorTool.AssertCompilesCode(set.VertexShaderCode, "vert", is450); } } if (set.FragmentFunction != null) { if (backend is HlslBackend) { FxcTool.AssertCompilesCode(set.FragmentShaderCode, "ps_5_0", set.FragmentFunction.Name); } else { bool is450 = backend is Glsl450Backend; GlsLangValidatorTool.AssertCompilesCode(set.FragmentShaderCode, "frag", is450); } } if (set.ComputeFunction != null) { if (backend is HlslBackend) { FxcTool.AssertCompilesCode(set.ComputeShaderCode, "cs_5_0", set.ComputeFunction.Name); } else { bool is450 = backend is Glsl450Backend; GlsLangValidatorTool.AssertCompilesCode(set.ComputeShaderCode, "comp", is450); } } } } }
public void DummyTest() { string vsName = "TestShaders.VeldridShaders.VertexAndFragment.VS"; string fsName = "TestShaders.VeldridShaders.VertexAndFragment.FS"; Compilation compilation = TestUtil.GetTestProjectCompilation(); using (TempFile fp = new TempFile()) { Microsoft.CodeAnalysis.Emit.EmitResult emitResult = compilation.Emit(fp); Assert.True(emitResult.Success); } LanguageBackend backend = new Glsl450Backend(compilation); ShaderGenerator sg = new ShaderGenerator( compilation, vsName, fsName, backend); ShaderGenerationResult result = sg.GenerateShaders(); IReadOnlyList <GeneratedShaderSet> sets = result.GetOutput(backend); Assert.Equal(1, sets.Count); GeneratedShaderSet set = sets[0]; ShaderModel shaderModel = set.Model; if (vsName != null) { ShaderFunction vsFunction = shaderModel.GetFunction(vsName); string vsCode = set.VertexShaderCode; File.WriteAllText(@"C:\Users\raver\Documents\forward-vertex.glsl", vsCode); GlsLangValidatorTool.AssertCompilesCode(vsCode, "vert", true); } if (fsName != null) { ShaderFunction fsFunction = shaderModel.GetFunction(fsName); string fsCode = set.FragmentShaderCode; File.WriteAllText(@"C:\Users\raver\Documents\forward-frag.glsl", fsCode); GlsLangValidatorTool.AssertCompilesCode(fsCode, "frag", true); } }