Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        static void InitializeWindowEvent()
        {
            GameSystems.EngineWindow.OnKeyBoardEvent += (object sender, KeyBoardEventArg eventArg) =>
            {
                LogEmitter.Apply(LogLevel.Information, "[KeyBoardEvent] [KeyCode = {0}] [State = {1}]",
                                 eventArg.KeyCode, eventArg.IsDown);
            };

            GameSystems.EngineWindow.OnMouseMoveEvent += (object sender, MouseMoveEventArg eventArg) =>
            {
                LogEmitter.Apply(LogLevel.Information, "[MouseMoveEvent] [X = {0}] [Y = {1}]", eventArg.Position.X, eventArg.Position.Y);
            };

            GameSystems.EngineWindow.OnMouseClickEvent += (object sender, MouseClickEventArg eventArg) =>
            {
                LogEmitter.Apply(LogLevel.Information, "[MouseClickEvent] [Button = {0}] [State = {1}]", eventArg.Button, eventArg.IsDown);
            };

            GameSystems.EngineWindow.OnMouseWhellEvent += (object sender, MouseWheelEventArg eventArg) =>
            {
                LogEmitter.Apply(LogLevel.Information, "[MouseWheelEvent] [Offset = {0}]", eventArg.Offset);
            };

            GameSystems.EngineWindow.OnSizeChangeEvent += (object sender, SizeChangeEvent eventArg) =>
            {
                LogEmitter.Apply(LogLevel.Information, "[SizeChangeEvent] [Width = {0}] [Height = {1}]",
                                 eventArg.After.Width, eventArg.After.Height);
            };
        }
Esempio n. 3
0
        public GpuDevice(GpuAdapter adapter)
        {
            //set member to null
            mVertexShader = null;
            mPixelShader  = null;
            mInputLayout  = null;

            //set the adapter
            Adapter = adapter;

#if DEBUG
            //creation flag, we use debug flag
            var creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.Debug;
#else
            var creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.None;
#endif
            //fetuares level: 11_0, 12_0
            var fetuares = new SharpDX.Direct3D.FeatureLevel[2]
            {
                SharpDX.Direct3D.FeatureLevel.Level_11_0,
                SharpDX.Direct3D.FeatureLevel.Level_12_0
            };

            //create device with current adapter
            mDevice           = new SharpDX.Direct3D11.Device(Adapter.Adapter, creationFlags, fetuares);
            mImmediateContext = Device.ImmediateContext;

            LogEmitter.Apply(LogLevel.Information, "[Initialize Graphics Device with {0}]", adapter.Description);
            LogEmitter.Apply(LogLevel.Information, "[Graphics Device Feature Level = {0}]", Device.FeatureLevel);
        }
Esempio n. 4
0
        public static List <GpuAdapter> EnumerateGraphicsAdapter()
        {
            List <GpuAdapter> graphicsAdapters = new List <GpuAdapter>();

            LogEmitter.Apply(LogLevel.Information, "[Start Enumerate GraphicsAdapter]");

            using (var factory = new SharpDX.DXGI.Factory1())
            {
                foreach (var adapter in factory.Adapters)
                {
                    graphicsAdapters.Add(new GpuAdapter(adapter.Description.Description, adapter));

                    LogEmitter.Apply(LogLevel.Information, "[Enumerate GraphicsAdapter] [{0}]", adapter.Description.Description);
                }
            }

            LogEmitter.Apply(LogLevel.Information, "[End Enumerate GraphicsAdapter]");

            return(graphicsAdapters);
        }