Esempio n. 1
0
        public unsafe override void Initialize(Size outputSize, IOutputOwner output)
        {
            var debug = new DebugLayerConfiguration()
                        .WithDebugFlags(DebugFlags.DebugLayer)
                        .WithDredFlags(DredFlags.All)
                        .WithBreakpointLogLevel(LogLevel.None);

            _device = GraphicsDevice.Create(FeatureLevel.GraphicsLevel11_0, null, debug);
            _output = Output.Create(OutputConfiguration.Default, _device, output);

            OnResize(outputSize);

            ReadOnlySpan <Vertex> vertices = stackalloc Vertex[3]
            {
                new Vertex {
                    Position = new Vector3(+0.25f, -0.25f, +0.0f), Color = (Vector4)Rgba128.Blue
                },
                new Vertex {
                    Position = new Vector3(-0.25f, -0.25f, +0.0f), Color = (Vector4)Rgba128.Green
                },
                new Vertex {
                    Position = new Vector3(+0.0f, +0.25f, +0.0f), Color = (Vector4)Rgba128.Red
                },
            };

            // Allocate the vertices, using the overload which takes some initial data
            _vertices = _device.Allocator.AllocateUploadBuffer(vertices);
            _indirect = _device.Allocator.AllocateUploadBuffer <IndirectDrawArguments>();

            // The pipeline description. We compile shaders at runtime here, which is simpler but less efficient
            var psoDesc = new GraphicsPipelineDesc
            {
                Topology            = TopologyClass.Triangle,
                VertexShader        = ShaderManager.CompileShader("HelloTriangle/Shader.hlsl", ShaderType.Vertex, entrypoint: "VertexMain"),
                PixelShader         = ShaderManager.CompileShader("HelloTriangle/Shader.hlsl", ShaderType.Pixel, entrypoint: "PixelMain"),
                RenderTargetFormats = _output.Configuration.BackBufferFormat,
                DepthStencil        = DepthStencilDesc.DisableDepthStencil,
                Inputs = InputLayout.FromType <Vertex>(),
            };

            _pso = _device.PipelineManager.CreatePipelineStateObject(psoDesc, nameof(_pso));
        }
Esempio n. 2
0
        public DebugLayer(ComputeDevice device, DebugLayerConfiguration?config)
        {
            IsActive = config is not null;
            _config  = config !;

            if (config is null)
            {
                return;
            }

            _device = device;

            if (!_config.DebugFlags.HasFlag(DebugFlags.DebugLayer) && _config.DebugFlags.HasFlag(DebugFlags.GpuBasedValidation))
            {
                ThrowHelper.ThrowArgumentException("Cannot have GPU based validation enabled unless graphics layer validation is enabled");
            }

            if (_config.DebugFlags.HasFlag(DebugFlags.DebugLayer))
            {
                InitializeD3D12();
            }
        }