mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
First working effects with new pipeline
This commit is contained in:
@@ -11,6 +11,18 @@ using GlitchyEngine.Content;
|
||||
using System.Collections;
|
||||
|
||||
using internal GlitchyEngine.Renderer;
|
||||
using internal GlitchyEngine.Platform.DX11;
|
||||
|
||||
using System;
|
||||
using GlitchyEngine.Renderer;
|
||||
using DirectX.D3D11;
|
||||
using DirectX.D3DCompiler;
|
||||
using GlitchyEngine.Platform.DX11;
|
||||
using GlitchyEngine.Content;
|
||||
using DirectX.Common;
|
||||
|
||||
using internal GlitchyEngine.Renderer;
|
||||
using internal GlitchyEngine.Platform.DX11;
|
||||
|
||||
namespace GlitchyEngine.Renderer
|
||||
{
|
||||
@@ -115,6 +127,40 @@ namespace GlitchyEngine.Renderer
|
||||
*/
|
||||
internal ID3DBlob* nativeCode ~ _?.Release();
|
||||
|
||||
protected override Result<void> InternalCreateFromBlob(Span<uint8> blob)
|
||||
{
|
||||
HResult shaderCreationResult = HResult.S_FALSE;
|
||||
|
||||
// TODO Temporary, because we need to generate the vertex layout from it!
|
||||
D3DCompiler.D3DCreateBlob((.)blob.Length, &nativeCode);
|
||||
Internal.MemCpy(nativeCode.GetBufferPointer(), blob.Ptr, blob.Length);
|
||||
|
||||
switch (_shaderType)
|
||||
{
|
||||
case .Vertex:
|
||||
shaderCreationResult = NativeDevice.CreateVertexShader(blob.Ptr, (uint)blob.Length, null, (ID3D11VertexShader**)&nativeShader);
|
||||
case .Pixel:
|
||||
shaderCreationResult = NativeDevice.CreatePixelShader(blob.Ptr, (uint)blob.Length, null, (ID3D11PixelShader**)&nativeShader);
|
||||
default:
|
||||
Log.EngineLogger.Error($"Can't create native shader of type {_shaderType}.");
|
||||
return .Err;
|
||||
}
|
||||
|
||||
if(shaderCreationResult.Failed)
|
||||
{
|
||||
Log.EngineLogger.Error($"Failed to create native shader from blob: {shaderCreationResult} ({(int)shaderCreationResult})");
|
||||
|
||||
if (nativeShader != null)
|
||||
{
|
||||
nativeShader.Release();
|
||||
}
|
||||
|
||||
return .Err;
|
||||
}
|
||||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
protected const ShaderCompileFlags DefaultCompileFlags = .EnableStrictness |
|
||||
#if DEBUG
|
||||
.Debug;
|
||||
|
||||
@@ -29,5 +29,7 @@ namespace GlitchyEngine.Renderer
|
||||
_nativeShaderResourceView?.Release();
|
||||
_nativeSamplerState?.Release();
|
||||
}
|
||||
|
||||
public static override TextureViewBinding CreateDefault() => .(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace GlitchyEngine.Renderer
|
||||
output[i] = .(input[i].SemanticName, input[i].SemanticIndex, (.)input[i].Format, input[i].InputSlot, input[i].AlignedByteOffset, (.)input[i].InputSlotClass, input[i].InstanceDataStepRate);
|
||||
}
|
||||
|
||||
/// This should happen during shader compilation!
|
||||
/// Validates or gets the validated input layout for the given vertexshader.
|
||||
internal ID3D11InputLayout* GetNativeVertexLayout(ID3DBlob* vertexShaderCode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user