mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Moved pixel-/vertex shader to own files
This commit is contained in:
@@ -8,33 +8,6 @@ using internal GlitchyEngine.Renderer;
|
||||
|
||||
namespace GlitchyEngine.Renderer
|
||||
{
|
||||
extension Shader
|
||||
{
|
||||
internal static void PlattformCompileShaderFromSource(String code, ShaderDefine[] macros, String entryPoint, String target, ShaderCompileFlags compileFlags, out ID3DBlob* shaderBlob)
|
||||
{
|
||||
ShaderMacro* nativeMacros = macros == null ? null : new:ScopedAlloc! ShaderMacro[macros.Count]*;
|
||||
|
||||
for(int i < macros?.Count ?? 0)
|
||||
{
|
||||
nativeMacros[i].Name = macros[i].Name.ToScopedNativeWChar!();
|
||||
nativeMacros[i].Definition = macros[i].Definition.ToScopedNativeWChar!();
|
||||
}
|
||||
|
||||
// Todo: sourceName, includes,
|
||||
// Todo: variable shader target?
|
||||
|
||||
ID3DBlob* errorBlob = null;
|
||||
|
||||
shaderBlob = null;
|
||||
var result = D3DCompiler.D3DCompile(code.CStr(), (.)code.Length, null, nativeMacros, null, entryPoint, target, compileFlags, .None, &shaderBlob, &errorBlob);
|
||||
if(result.Failed)
|
||||
{
|
||||
StringView str = StringView((char8*)errorBlob.GetBufferPointer(), errorBlob.GetBufferSize());
|
||||
Log.EngineLogger.Error($"Failed to compile Shader: Error Code({(int)result}): {result} | Error Message: {str}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PixelShader
|
||||
{
|
||||
internal ID3D11PixelShader* nativeShader ~ _?.Release();
|
||||
@@ -82,32 +55,4 @@ namespace GlitchyEngine.Renderer
|
||||
reflection.Release();
|
||||
}
|
||||
}
|
||||
|
||||
extension VertexShader
|
||||
{
|
||||
internal ID3D11VertexShader* nativeShader ~ _?.Release();
|
||||
|
||||
internal ID3DBlob* nativeCode ~ _?.Release();
|
||||
|
||||
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
|
||||
{
|
||||
ShaderCompileFlags flags = .Default;
|
||||
|
||||
#if DEBUG
|
||||
flags |= .Debug;
|
||||
#else
|
||||
flags |= .OptimizationLevel3;
|
||||
#endif
|
||||
|
||||
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "vs_5_0", flags, out nativeCode);
|
||||
|
||||
var result = _context.nativeDevice.CreateVertexShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
||||
if(result.Failed)
|
||||
{
|
||||
Log.EngineLogger.Error($"Failed to create vertex shader: Message ({(int)result}): {result}");
|
||||
}
|
||||
|
||||
//int i = nativeCode?.Release() ?? (uint32)-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user