public void Recreate(GraphicsAdapter adapter, GraphicsProfile[] profile, DeviceCreationFlags deviceCreationFlags, WindowHandle windowHandle) { if (adapter == null) { throw new ArgumentNullException("adapter"); } if (profile == null) { throw new ArgumentNullException("profile"); } Adapter = adapter; IsDebugMode = (deviceCreationFlags & DeviceCreationFlags.Debug) != 0; // Initialize this instance InitializePlatformDevice(profile, deviceCreationFlags, windowHandle); // Create a new graphics device Features = new GraphicsDeviceFeatures(this); SamplerStates = new SamplerStateFactory(this); var defaultPipelineStateDescription = new PipelineStateDescription(); defaultPipelineStateDescription.SetDefaults(); AdjustDefaultPipelineStateDescription(ref defaultPipelineStateDescription); DefaultPipelineState = PipelineState.New(this, ref defaultPipelineStateDescription); InitializePostFeatures(); }
/// <summary> /// Determine and updates <see cref="CurrentState"/> from <see cref="State"/>. /// </summary> public void Update() { // Hash current state var hashedState = new PipelineStateDescriptionWithHash(State); // Find existing PipelineState object PipelineState pipelineState; // TODO GRAPHICS REFACTOR We could avoid lock by adding them to a ThreadLocal (or RenderContext) and merge at end of frame lock (cache) { if (!cache.TryGetValue(hashedState, out pipelineState)) { // Otherwise, instantiate it // First, make an copy hashedState = new PipelineStateDescriptionWithHash(State.Clone()); cache.Add(hashedState, pipelineState = PipelineState.New(graphicsDevice, ref State)); } } CurrentState = pipelineState; }
public void Recreate(GraphicsAdapter adapter, GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, WindowHandle windowHandle) { if (adapter == null) { throw new ArgumentNullException("adapter"); } if (graphicsProfiles == null) { throw new ArgumentNullException("graphicsProfiles"); } Adapter = adapter; IsDebugMode = (deviceCreationFlags & DeviceCreationFlags.Debug) != 0; // Default fallback if (graphicsProfiles.Length == 0) { graphicsProfiles = new[] { GraphicsProfile.Level_11_0, GraphicsProfile.Level_10_1, GraphicsProfile.Level_10_0, GraphicsProfile.Level_9_3, GraphicsProfile.Level_9_2, GraphicsProfile.Level_9_1 } } ; // Initialize this instance InitializePlatformDevice(graphicsProfiles, deviceCreationFlags, windowHandle); // Create a new graphics device Features = new GraphicsDeviceFeatures(this); SamplerStates = new SamplerStateFactory(this); var defaultPipelineStateDescription = new PipelineStateDescription(); defaultPipelineStateDescription.SetDefaults(); AdjustDefaultPipelineStateDescription(ref defaultPipelineStateDescription); DefaultPipelineState = PipelineState.New(this, ref defaultPipelineStateDescription); InitializePostFeatures(); }