Shader #include + Remved unused Dx11Effect

This commit is contained in:
Simon Lübeß
2022-05-09 18:19:24 +02:00
parent dc235399c8
commit 3c2c37b270
10 changed files with 53 additions and 81 deletions
@@ -1,31 +0,0 @@
#if GE_GRAPHICS_DX11
using System;
using DirectX;
using DirectX.D3D11;
using internal GlitchyEngine.Renderer;
namespace GlitchyEngine.Renderer
{
extension Effect
{
protected override void Compile(String vsPath, String vsEntry, String psPath, String psEntry)
{
Debug.Profiler.ProfileResourceFunction!();
// Todo: macros
VertexShader = new VertexShader(vsPath, vsEntry);
PixelShader = new PixelShader(psPath, psEntry);
Reflect();
}
private void Reflect()
{
}
}
}
#endif
@@ -14,11 +14,11 @@ namespace GlitchyEngine.Renderer
{
internal ID3D11PixelShader* nativeShader ~ _?.Release();
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
public override void CompileFromSource(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
{
Debug.Profiler.ProfileRendererFunction!();
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "ps_5_0", DefaultCompileFlags, out nativeCode);
Shader.PlattformCompileShaderFromSource(code, fileName, macros, entryPoint, "ps_5_0", DefaultCompileFlags, out nativeCode);
{
Debug.Profiler.ProfileResourceScope!("CreateNativePixelShader");
@@ -25,7 +25,7 @@ namespace GlitchyEngine.Renderer
.OptimizationLevel3;
#endif
internal static void PlattformCompileShaderFromSource(String code, ShaderDefine[] macros, String entryPoint, String target, ShaderCompileFlags compileFlags, out ID3DBlob* shaderBlob)
internal static void PlattformCompileShaderFromSource(StringView code, StringView? fileName, ShaderDefine[] macros, String entryPoint, String target, ShaderCompileFlags compileFlags, out ID3DBlob* shaderBlob)
{
Debug.Profiler.ProfileResourceFunction!();
@@ -43,7 +43,7 @@ namespace GlitchyEngine.Renderer
ID3DBlob* errorBlob = null;
shaderBlob = null;
var result = D3DCompiler.D3DCompile(code.CStr(), (.)code.Length, null, nativeMacros, null, entryPoint, target, compileFlags, .None, &shaderBlob, &errorBlob);
var result = D3DCompiler.D3DCompile(code.Ptr, (.)code.Length, fileName?.ToScopeCStr!(), nativeMacros, ID3DInclude.StandardInclude, entryPoint, target, compileFlags, .None, &shaderBlob, &errorBlob);
if(result.Failed)
{
StringView str = StringView((char8*)errorBlob.GetBufferPointer(), (int)errorBlob.GetBufferSize());
@@ -15,11 +15,11 @@ namespace GlitchyEngine.Renderer
{
internal ID3D11VertexShader* nativeShader ~ _?.Release();
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
public override void CompileFromSource(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
{
Debug.Profiler.ProfileResourceFunction!();
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "vs_5_0", DefaultCompileFlags, out nativeCode);
Shader.PlattformCompileShaderFromSource(code, fileName, macros, entryPoint, "vs_5_0", DefaultCompileFlags, out nativeCode);
{
Debug.Profiler.ProfileResourceScope!("CreateNativeVertexShader");