/// <summary>Resets the instance so the value can be recreated.</summary> /// <param name="factory">The factory method to call when initializing the value.</param> /// <exception cref="ArgumentNullException"><paramref name="factory" /> is <c>null</c>.</exception> /// <exception cref="ObjectDisposedException">The lazy value has been disposed.</exception> public void Reset(Func <T> factory) { ThrowIfDisposedOrDisposing(_state, nameof(ValueLazy <T>)); ThrowIfNull(factory, nameof(factory)); _factory = factory; _ = _state.Transition(to: Initialized); }
/// <summary>Initializes a new instance of the <see cref="Application" /> class.</summary> /// <param name="serviceProvider">The object which provides services for the instance.</param> /// <exception cref="ArgumentNullException"><paramref name="serviceProvider" /> is <c>null</c>.</exception> public Application(ApplicationServiceProvider serviceProvider) { ThrowIfNull(serviceProvider, nameof(serviceProvider)); _parentThread = Thread.CurrentThread; _serviceProvider = serviceProvider; _ = _state.Transition(to: Stopped); }
/// <summary>Initializes a new instance of the <see cref="Application" /> class.</summary> /// <param name="compositionAssemblies">The <see cref="Assembly" /> instances to search for type exports.</param> /// <exception cref="ArgumentNullException"><paramref name="compositionAssemblies" /> is <c>null</c>.</exception> public Application(params Assembly[] compositionAssemblies) { ThrowIfNull(compositionAssemblies, nameof(compositionAssemblies)); _compositionAssemblies = compositionAssemblies; _parentThread = Thread.CurrentThread; _compositionHost = new ValueLazy <CompositionHost>(CreateCompositionHost); _ = _state.Transition(to: Stopped); }
internal VulkanGraphicsFence(VulkanGraphicsDevice device) : base(device) { _vulkanFence = new ValueLazy <VkFence>(CreateVulkanFence); _ = _state.Transition(to: Initialized); }
/// <summary>Initializes a new instance of the <see cref="D3D12GraphicsService" /> class.</summary> public D3D12GraphicsService() { _dxgiFactory = new ValueLazy <Pointer <IDXGIFactory2> >(CreateDxgiFactory); _adapters = new ValueLazy <ImmutableArray <D3D12GraphicsAdapter> >(GetAdapters); _ = _state.Transition(to: Initialized); }
internal VulkanGraphicsPipeline(VulkanGraphicsDevice device, VulkanGraphicsPipelineSignature signature, VulkanGraphicsShader?vertexShader, VulkanGraphicsShader?pixelShader) : base(device, signature, vertexShader, pixelShader) { _vulkanPipeline = new ValueLazy <VkPipeline>(CreateVulkanPipeline); _ = _state.Transition(to: Initialized); }
internal D3D12GraphicsPipelineSignature(D3D12GraphicsDevice device, ReadOnlySpan <GraphicsPipelineInput> inputs, ReadOnlySpan <GraphicsPipelineResource> resources) : base(device, inputs, resources) { _d3d12RootSignature = new ValueLazy <Pointer <ID3D12RootSignature> >(CreateD3D12RootSignature); _ = _state.Transition(to: Initialized); }
public VulkanGraphicsProvider() { if (DebugModeEnabled) { var optionalExtensionNamesData = AppContext.GetData(OptionalExtensionNamesDataName) as string; optionalExtensionNamesData += ";VK_EXT_debug_report"; AppDomain.CurrentDomain.SetData(OptionalExtensionNamesDataName, optionalExtensionNamesData); var optionalLayerNamesData = AppContext.GetData(OptionalLayerNamesDataName) as string; optionalLayerNamesData += ";VK_LAYER_LUNARG_standard_validation"; AppDomain.CurrentDomain.SetData(OptionalLayerNamesDataName, optionalLayerNamesData); } _engineName = GetEngineName(); _requiredExtensionNames = GetNames(RequiredExtensionNamesDataName); _optionalExtensionNames = GetNames(OptionalExtensionNamesDataName); _requiredLayerNames = GetNames(RequiredLayerNamesDataName); _optionalLayerNames = GetNames(OptionalLayerNamesDataName); _vulkanInstance = new ValueLazy <VkInstance>(CreateVulkanInstance); _adapters = new ValueLazy <ImmutableArray <VulkanGraphicsAdapter> >(GetGraphicsAdapters); _ = _state.Transition(to: Initialized);
internal D3D12GraphicsFence(D3D12GraphicsDevice device) : base(device) { _d3d12Fence = new ValueLazy <Pointer <ID3D12Fence> >(CreateD3D12Fence); _d3d12FenceSignalEvent = new ValueLazy <HANDLE>(CreateEventHandle); _ = _state.Transition(to: Initialized); }
internal XlibWindow(XlibWindowService windowService) : base(windowService, Thread.CurrentThread) { _flowDirection = FlowDirection.TopToBottom; _readingDirection = ReadingDirection.LeftToRight; _handle = new ValueLazy <nuint>(CreateWindowHandle); _properties = new ValueLazy <PropertySet>(CreateProperties); _title = typeof(XlibWindow).FullName !; _bounds = new Rectangle(float.NaN, float.NaN, float.NaN, float.NaN); _clientBounds = new Rectangle(float.NaN, float.NaN, float.NaN, float.NaN); _frameExtents = new Rectangle(float.NaN, float.NaN, float.NaN, float.NaN); _isEnabled = true; _ = _state.Transition(to: Initialized); }
internal VulkanGraphicsPipelineSignature(VulkanGraphicsDevice device, ReadOnlySpan <GraphicsPipelineInput> inputs, ReadOnlySpan <GraphicsPipelineResource> resources) : base(device, inputs, resources) { _vulkanDescriptorPool = new ValueLazy <VkDescriptorPool>(CreateVulkanDescriptorPool); _vulkanDescriptorSet = new ValueLazy <VkDescriptorSet>(CreateVulkanDescriptorSet); _vulkanDescriptorSetLayout = new ValueLazy <VkDescriptorSetLayout>(CreateVulkanDescriptorSetLayout); _vulkanPipelineLayout = new ValueLazy <VkPipelineLayout>(CreateVulkanPipelineLayout); _ = _state.Transition(to: Initialized); }
/// <summary>Initializes a new instance of the <see cref="XlibWindowService" /> class.</summary> public XlibWindowService() { var vulkanRequiredExtensionNamesDataName = AppContext.GetData(VulkanRequiredExtensionNamesDataName) as string; vulkanRequiredExtensionNamesDataName += ";VK_KHR_surface;VK_KHR_xlib_surface"; AppDomain.CurrentDomain.SetData(VulkanRequiredExtensionNamesDataName, vulkanRequiredExtensionNamesDataName); _nativeHandle = new ValueLazy <GCHandle>(() => GCHandle.Alloc(this, GCHandleType.Normal)); _windows = new ThreadLocal <Dictionary <nuint, XlibWindow> >(trackAllValues: true); _ = _state.Transition(to: Initialized); }
private XlibDispatchProvider() { _dispatchers = new ConcurrentDictionary <Thread, XlibDispatcher>(); _display = new ValueLazy <IntPtr>(CreateDisplayHandle); _defaultRootWindow = new ValueLazy <nuint>(GetDefaultRootWindow); _defaultScreen = new ValueLazy <Pointer <Screen> >(GetDefaultScreen); _atoms = new ValueLazy <nuint[]>(CreateAtoms); _supportedAtoms = new ValueLazy <nuint[]>(GetSupportedAtoms); _ = _state.Transition(to: Initialized); }
internal D3D12GraphicsAdapter(D3D12GraphicsProvider provider, IDXGIAdapter1 *dxgiAdapter) : base(provider) { ThrowIfNull(dxgiAdapter, nameof(dxgiAdapter)); _dxgiAdapter = dxgiAdapter; _dxgiAdapterDesc = new ValueLazy <DXGI_ADAPTER_DESC1>(GetDxgiAdapterDesc); _name = new ValueLazy <string>(GetName); _ = _state.Transition(to: Initialized); }
/// <summary>Initializes a new instance of the <see cref="PulseAudioService" /> class.</summary> public PulseAudioService() { _mainloop = new Lazy <IntPtr>(CreateMainLoop, isThreadSafe: true); _context = new Lazy <IntPtr>(CreateContext, isThreadSafe: true); _mainLoopMutex = new SemaphoreSlim(initialCount: 1); _ = _state.Transition(to: Initialized); }
internal VulkanGraphicsAdapter(VulkanGraphicsService service, VkPhysicalDevice vulkanPhysicalDevice) : base(service) { AssertNotNull(vulkanPhysicalDevice); _vulkanPhysicalDevice = vulkanPhysicalDevice; _vulkanPhysicalDeviceMemoryProperties = new ValueLazy <VkPhysicalDeviceMemoryProperties>(GetVulkanPhysicalDeviceMemoryProperties); _vulkanPhysicalDeviceProperties = new ValueLazy <VkPhysicalDeviceProperties>(GetVulkanPhysicalDeviceProperties); _name = new ValueLazy <string>(GetName); _ = _state.Transition(to: Initialized); }
internal VulkanGraphicsContext(VulkanGraphicsDevice device, int index) : base(device, index) { _fence = new VulkanGraphicsFence(device); _waitForExecuteCompletionFence = new VulkanGraphicsFence(device); _vulkanCommandBuffer = new ValueLazy <VkCommandBuffer>(CreateVulkanCommandBuffer); _vulkanCommandPool = new ValueLazy <VkCommandPool>(CreateVulkanCommandPool); _vulkanFramebuffer = new ValueLazy <VkFramebuffer>(CreateVulkanFramebuffer); _vulkanSwapChainImageView = new ValueLazy <VkImageView>(CreateVulkanSwapChainImageView); _ = _state.Transition(to: Initialized); }
internal D3D12GraphicsContext(D3D12GraphicsDevice device, int index) : base(device, index) { _fence = new D3D12GraphicsFence(device); _waitForExecuteCompletionFence = new D3D12GraphicsFence(device); _d3d12CommandAllocator = new ValueLazy <Pointer <ID3D12CommandAllocator> >(CreateD3D12CommandAllocator); _d3d12GraphicsCommandList = new ValueLazy <Pointer <ID3D12GraphicsCommandList> >(CreateD3D12GraphicsCommandList); _d3d12RenderTargetView = new ValueLazy <D3D12_CPU_DESCRIPTOR_HANDLE>(CreateD3D12RenderTargetDescriptor); _d3d12RenderTargetResource = new ValueLazy <Pointer <ID3D12Resource> >(CreateD3D12RenderTargetResource); _ = _state.Transition(to: Initialized); }
/// <summary>Initializes a new instance of the <see cref="Win32WindowService" /> class.</summary> public Win32WindowService() { var vulkanRequiredExtensionNamesDataName = AppContext.GetData(VulkanRequiredExtensionNamesDataName) as string; vulkanRequiredExtensionNamesDataName += ";VK_KHR_surface;VK_KHR_win32_surface"; AppDomain.CurrentDomain.SetData(VulkanRequiredExtensionNamesDataName, vulkanRequiredExtensionNamesDataName); _classAtom = new ValueLazy <ushort>(CreateClassAtom); _nativeHandle = new ValueLazy <GCHandle>(CreateNativeHandle); _windows = new ThreadLocal <Dictionary <IntPtr, Win32Window> >(trackAllValues: true); _ = _state.Transition(to: Initialized); }
internal D3D12GraphicsShader(D3D12GraphicsDevice device, GraphicsShaderKind kind, ReadOnlySpan <byte> bytecode, string entryPointName) : base(device, kind, entryPointName) { var bytecodeLength = (nuint)bytecode.Length; _d3d12ShaderBytecode.pShaderBytecode = Allocate(bytecodeLength); _d3d12ShaderBytecode.BytecodeLength = bytecodeLength; var destination = new Span <byte>(_d3d12ShaderBytecode.pShaderBytecode, (int)bytecodeLength); bytecode.CopyTo(destination); _ = _state.Transition(to: Initialized); }
internal VulkanGraphicsShader(VulkanGraphicsDevice device, GraphicsShaderKind kind, ReadOnlySpan <byte> bytecode, string entryPointName) : base(device, kind, entryPointName) { var bytecodeLength = (nuint)bytecode.Length; _vulkanShaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; _vulkanShaderModuleCreateInfo.codeSize = bytecodeLength; _vulkanShaderModuleCreateInfo.pCode = AllocateArray <uint>(AlignUp(bytecodeLength, SizeOf <nuint>())); var destination = new Span <byte>(_vulkanShaderModuleCreateInfo.pCode, (int)bytecodeLength); bytecode.CopyTo(destination); _vulkanShaderModule = new ValueLazy <VkShaderModule>(CreateVulkanShaderModule); _ = _state.Transition(to: Initialized); }
internal Win32Window(Win32WindowService windowService) : base(windowService, Thread.CurrentThread) { _flowDirection = FlowDirection.TopToBottom; _readingDirection = ReadingDirection.LeftToRight; _handle = new ValueLazy <IntPtr>(CreateWindowHandle); _properties = new ValueLazy <PropertySet>(CreateProperties); _title = typeof(Win32Window).FullName !; _bounds = new Rectangle(float.NaN, float.NaN, float.NaN, float.NaN); _clientBounds = new Rectangle(float.NaN, float.NaN, float.NaN, float.NaN); _extendedStyle = WS_EX_OVERLAPPEDWINDOW; _style = WS_OVERLAPPEDWINDOW; _ = _state.Transition(to: Initialized); }
internal D3D12GraphicsDevice(D3D12GraphicsAdapter adapter, IGraphicsSurface surface, int contextCount) : base(adapter, surface) { _idleFence = new D3D12GraphicsFence(this); _d3d12CommandQueue = new ValueLazy <Pointer <ID3D12CommandQueue> >(CreateD3D12CommandQueue); _d3d12Device = new ValueLazy <Pointer <ID3D12Device> >(CreateD3D12Device); _d3d12Options = new ValueLazy <D3D12_FEATURE_DATA_D3D12_OPTIONS>(GetD3D12Options); _d3d12RenderTargetDescriptorHeap = new ValueLazy <Pointer <ID3D12DescriptorHeap> >(CreateD3D12RenderTargetDescriptorHeap); _dxgiSwapChain = new ValueLazy <Pointer <IDXGISwapChain3> >(CreateDxgiSwapChain); _memoryAllocator = new ValueLazy <D3D12GraphicsMemoryAllocator>(CreateMemoryAllocator); _cbvSrvUavDescriptorHandleIncrementSize = new ValueLazy <uint>(GetCbvSrvUavDescriptorHandleIncrementSize); _contexts = CreateContexts(this, contextCount); _ = _state.Transition(to: Initialized); WaitForIdleGraphicsFence.Reset(); surface.SizeChanged += OnGraphicsSurfaceSizeChanged;
internal VulkanGraphicsDevice(VulkanGraphicsAdapter adapter, IGraphicsSurface surface, int contextCount) : base(adapter, surface) { _presentCompletionFence = new VulkanGraphicsFence(this); _vulkanCommandQueue = new ValueLazy <VkQueue>(GetVulkanCommandQueue); _vulkanCommandQueueFamilyIndex = new ValueLazy <uint>(GetVulkanCommandQueueFamilyIndex); _vulkanDevice = new ValueLazy <VkDevice>(CreateVulkanDevice); _vulkanRenderPass = new ValueLazy <VkRenderPass>(CreateVulkanRenderPass); _vulkanSurface = new ValueLazy <VkSurfaceKHR>(CreateVulkanSurface); _vulkanSwapchain = new ValueLazy <VkSwapchainKHR>(CreateVulkanSwapchain); _vulkanSwapchainImages = new ValueLazy <VkImage[]>(GetVulkanSwapchainImages); _memoryAllocator = new ValueLazy <VulkanGraphicsMemoryAllocator>(CreateMemoryAllocator); _contexts = CreateGraphicsContexts(this, contextCount); _ = _state.Transition(to: Initialized); PresentCompletionFence.Reset(); surface.SizeChanged += OnGraphicsSurfaceSizeChanged;
internal D3D12GraphicsPipeline(D3D12GraphicsDevice device, D3D12GraphicsPipelineSignature signature, D3D12GraphicsShader?vertexShader, D3D12GraphicsShader?pixelShader) : base(device, signature, vertexShader, pixelShader) { _d3d12PipelineState = new ValueLazy <Pointer <ID3D12PipelineState> >(CreateD3D12GraphicsPipelineState); _ = _state.Transition(to: Initialized); }
/// <summary>Initializes a new instance of the <see cref="ApplicationServiceProvider" /> class.</summary> protected ApplicationServiceProvider() { _ = _state.Transition(to: Initialized); }