public void HlslEndToEnd(string vsName, string fsName) { Compilation compilation = TestUtil.GetTestProjectCompilation(); HlslBackend backend = new HlslBackend(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; FxcTool.AssertCompilesCode(vsCode, "vs_5_0", vsFunction.Name); } if (fsName != null) { ShaderFunction fsFunction = shaderModel.GetFunction(fsName); string fsCode = set.FragmentShaderCode; FxcTool.AssertCompilesCode(fsCode, "ps_5_0", fsFunction.Name); } }
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 static void ShaderSetAutoDiscovery() { Compilation compilation = TestUtil.GetTestProjectCompilation(); HlslBackend backend = new HlslBackend(compilation); ShaderGenerator sg = new ShaderGenerator(compilation, new[] { backend }); ShaderGenerationResult result = sg.GenerateShaders(); IReadOnlyList <GeneratedShaderSet> hlslSets = result.GetOutput(backend); Assert.Equal(3, hlslSets.Count); GeneratedShaderSet set = hlslSets[0]; Assert.Equal("VertexAndFragment", set.Name); ShaderModel shaderModel = set.Model; ShaderFunction func = shaderModel.Functions[0]; FxcTool.AssertCompilesCode(set.VertexShaderCode, "vs_5_0", "VS"); FxcTool.AssertCompilesCode(set.FragmentShaderCode, "ps_5_0", "FS"); }
public void PartialFiles() { Compilation compilation = TestUtil.GetTestProjectCompilation(); HlslBackend backend = new HlslBackend(compilation); ShaderGenerator sg = new ShaderGenerator( compilation, "TestShaders.PartialVertex.VertexShaderFunc", null, backend); ShaderGenerationResult genResult = sg.GenerateShaders(); IReadOnlyList <GeneratedShaderSet> sets = genResult.GetOutput(backend); Assert.Equal(1, sets.Count); GeneratedShaderSet set = sets[0]; ShaderModel shaderModel = set.Model; string vsCode = set.VertexShaderCode; FxcTool.AssertCompilesCode(vsCode, "vs_5_0", "VertexShaderFunc"); }