public static byte[] Compile(byte[] byteCode, string entryPoint = "main") { LogEmitter.Apply(LogLevel.Information, "[Start Compile Vertex Shader]"); var result = SharpDX.D3DCompiler.ShaderBytecode.Compile(byteCode, entryPoint, "vs_5_0", ShaderFlags); if (result.Message != null) { var messages = result.Message.Split('\n'); foreach (var message in messages) { if (message == "") { continue; } LogEmitter.Apply(LogLevel.Warning, "[Vertex Shader Message = {0}]", message); } } LogEmitter.Apply(LogLevel.Information, "[Finish Compile Vertex Shader]"); LogEmitter.Assert(result.HasErrors == false, LogLevel.Error, "[Compile Vertex Shader Failed]"); return(result); }
public GpuSwapChain( IntPtr handle, Size <int> size, GpuPixelFormat pixelFormat, GpuDevice device) { //size property Size = size; PixelFormat = pixelFormat; GpuDevice = device; //get factory using (var factory = GpuDevice.Adapter.Adapter.GetParent <SharpDX.DXGI.Factory>()) { //set swapchain desc var swapChainDesc = new SharpDX.DXGI.SwapChainDescription() { BufferCount = 1, Flags = SharpDX.DXGI.SwapChainFlags.None, IsWindowed = true, ModeDescription = new SharpDX.DXGI.ModeDescription() { Format = GpuConvert.ToPixelFormat(PixelFormat), Height = Size.Height, Width = Size.Width, RefreshRate = new SharpDX.DXGI.Rational(60, 1), Scaling = SharpDX.DXGI.DisplayModeScaling.Unspecified, ScanlineOrdering = SharpDX.DXGI.DisplayModeScanlineOrder.Unspecified }, OutputHandle = handle, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), SwapEffect = SharpDX.DXGI.SwapEffect.Discard, Usage = SharpDX.DXGI.Usage.RenderTargetOutput }; mSwapChain = new SharpDX.DXGI.SwapChain(factory, GpuDevice.Device, swapChainDesc); //report error, if create swapchain failed LogEmitter.Assert(mSwapChain != null, LogLevel.Error, "[Create SwapChain Failed] [Width = {0}] [Height = {1}] [Format = {2}]", Size.Width, Size.Height, PixelFormat); RenderTarget = new GpuRenderTarget(GpuDevice, this); } }