Updated StockShaderCodeGenerator and EffectProcessor to support DX11 stock shaders (wrong profile was used while compiling).
This commit is contained in:
parent
ef4cb698e4
commit
786934191d
@ -48,21 +48,21 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
{
|
{
|
||||||
byte[] effectCompiledCode = null;
|
byte[] effectCompiledCode = null;
|
||||||
|
|
||||||
if (input.SourceLanguage == NonXNA.EffectSourceLanguage.HLSL_FX)
|
switch (input.SourceLanguage)
|
||||||
{
|
{
|
||||||
HLSLCompiler compiler = hlslCompilerFactory.Compilers.Last<HLSLCompiler>();
|
case NonXNA.EffectSourceLanguage.HLSL_FX:
|
||||||
effectCompiledCode = compiler.Compile(input.EffectCode, DebugMode, TargetProfile);
|
HLSLCompiler compiler = hlslCompilerFactory.Compilers.Last<HLSLCompiler>();
|
||||||
}
|
effectCompiledCode = compiler.Compile(input.EffectCode, DebugMode, TargetProfile);
|
||||||
else if (input.SourceLanguage == NonXNA.EffectSourceLanguage.GLSL_FX)
|
break;
|
||||||
{
|
case NonXNA.EffectSourceLanguage.GLSL_FX:
|
||||||
//TODO: parse and split the effect code and save two effect globs
|
//TODO: parse and split the effect code and save two effect globs
|
||||||
// if we do it this way, we don't need to parse the glsl source at runtime when loading it.
|
// if we do it this way, we don't need to parse the glsl source at runtime when loading it.
|
||||||
|
|
||||||
effectCompiledCode = ShaderHelper.SaveShaderCode(input.EffectCode);
|
effectCompiledCode = ShaderHelper.SaveShaderCode(input.EffectCode);
|
||||||
}
|
break;
|
||||||
else
|
default:
|
||||||
{
|
throw new InvalidContentException("EffectProcessor is unable to process content with format '" + input.SourceLanguage.ToString() + "'");
|
||||||
throw new InvalidContentException("EffectProcessor is unable to process content with format '" + input.SourceLanguage.ToString() + "'");
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CompiledEffectContent(effectCompiledCode)
|
return new CompiledEffectContent(effectCompiledCode)
|
||||||
|
@ -72,7 +72,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
{
|
{
|
||||||
NativeEffect = new Dx11.Effect(device, GetByteCode(effectStream));
|
NativeEffect = new Dx11.Effect(device, GetByteCode(effectStream));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (SharpDX.SharpDXException ex)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debugger.Break();
|
System.Diagnostics.Debugger.Break();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -71,9 +71,9 @@
|
|||||||
<Project>{068eb2e9-963c-4e1b-8831-e25011f11ffe}</Project>
|
<Project>{068eb2e9-963c-4e1b-8831-e25011f11ffe}</Project>
|
||||||
<Name>ANX.PlatformSystem.Windows</Name>
|
<Name>ANX.PlatformSystem.Windows</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
|
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX11\ANX.RenderSystem.Windows.DX11.csproj">
|
||||||
<Project>{5be49183-2f6f-4527-ac90-d816911fcf90}</Project>
|
<Project>{b30de9c2-0926-46b6-8351-9af276c472d5}</Project>
|
||||||
<Name>ANX.RenderSystem.Windows.DX10</Name>
|
<Name>ANX.RenderSystem.Windows.DX11</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio.csproj">
|
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio.csproj">
|
||||||
<Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project>
|
<Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project>
|
||||||
|
@ -65,11 +65,11 @@ namespace StockShaderCodeGenerator
|
|||||||
switch (RenderSystem)
|
switch (RenderSystem)
|
||||||
{
|
{
|
||||||
case "ANX.RenderSystem.Windows.DX10":
|
case "ANX.RenderSystem.Windows.DX10":
|
||||||
byteCode = CompileDXEffect(sourceCode, directory);
|
byteCode = CompileDXEffect(sourceCode, directory, EffectSourceLanguage.HLSL_FX ,"fx_4_0");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ANX.RenderSystem.Windows.DX11":
|
case "ANX.RenderSystem.Windows.DX11":
|
||||||
byteCode = CompileDXEffect(sourceCode, directory);
|
byteCode = CompileDXEffect(sourceCode, directory, EffectSourceLanguage.HLSL_FX, "fx_5_0");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ANX.RenderSystem.Windows.Metro":
|
case "ANX.RenderSystem.Windows.Metro":
|
||||||
@ -89,17 +89,18 @@ namespace StockShaderCodeGenerator
|
|||||||
return byteCode;
|
return byteCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] CompileDXEffect(string sourceCode, string directory)
|
private static byte[] CompileDXEffect(string sourceCode, string directory, EffectSourceLanguage sourceLanguage, String targetProfile)
|
||||||
{
|
{
|
||||||
EffectContent effectContent = new EffectContent()
|
EffectContent effectContent = new EffectContent()
|
||||||
{
|
{
|
||||||
EffectCode = sourceCode,
|
EffectCode = sourceCode,
|
||||||
Identity = new ContentIdentity(null, "StockShaderCodeGenerator", null),
|
Identity = new ContentIdentity(null, "StockShaderCodeGenerator", null),
|
||||||
SourceLanguage = EffectSourceLanguage.HLSL_FX,
|
SourceLanguage = sourceLanguage,
|
||||||
};
|
};
|
||||||
|
|
||||||
BuildContent buildContentTask = new BuildContent();
|
BuildContent buildContentTask = new BuildContent();
|
||||||
IContentProcessor instance = buildContentTask.ProcessorManager.GetInstance("EffectProcessor");
|
IContentProcessor instance = buildContentTask.ProcessorManager.GetInstance("EffectProcessor");
|
||||||
|
((EffectProcessor)instance).TargetProfile = targetProfile;
|
||||||
CompiledEffectContent effect = instance.Process(effectContent, null) as CompiledEffectContent;
|
CompiledEffectContent effect = instance.Process(effectContent, null) as CompiledEffectContent;
|
||||||
|
|
||||||
return effect.GetEffectCode();
|
return effect.GetEffectCode();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user