/*public override DbgPrim Instantiate(string newName, Transform newLocation, Color? newNameColor = null) * { * var newPrim = new DbgPrimGizmo(); * newPrim.Indices = Indices; * newPrim.GeometryBuffer = GeometryBuffer; * newPrim.Vertices = Vertices; * newPrim.NeedToRecreateGeomBuffer = NeedToRecreateGeomBuffer; * * newPrim.Transform = newLocation; * * newPrim.Name = newName; * * newPrim.NameColor = newNameColor ?? NameColor; * * return newPrim; * }*/ public void CreateDeviceObjects(Veldrid.GraphicsDevice gd, CommandList cl, SceneRenderPipeline sp) { /*var factory = gd.ResourceFactory; * WorldBuffer = Renderer.UniformBufferAllocator.Allocate(128, 128); * var identity = System.Numerics.Matrix4x4.Identity; * WorldBuffer.FillBuffer(cl, ref identity); * * ResourceLayout projViewCombinedLayout = StaticResourceCache.GetResourceLayout( * gd.ResourceFactory, * new ResourceLayoutDescription( * new ResourceLayoutElementDescription("ViewProjection", ResourceKind.UniformBuffer, ShaderStages.Vertex))); * * ResourceLayout worldLayout = StaticResourceCache.GetResourceLayout(gd.ResourceFactory, new ResourceLayoutDescription( * new ResourceLayoutElementDescription("World", ResourceKind.UniformBuffer, ShaderStages.Vertex, ResourceLayoutElementOptions.DynamicBinding))); * * VertexLayoutDescription[] mainVertexLayouts = new VertexLayoutDescription[] * { * new VertexLayoutDescription( * new VertexElementDescription("position", VertexElementSemantic.TextureCoordinate, Veldrid.VertexElementFormat.Float3), * new VertexElementDescription("color", VertexElementSemantic.TextureCoordinate, Veldrid.VertexElementFormat.Byte4), * new VertexElementDescription("normal", VertexElementSemantic.TextureCoordinate, Veldrid.VertexElementFormat.Float3)) * }; * * //Shaders = factory.CreateFromSpirv(vertexShaderDesc, fragmentShaderDesc); * var res = StaticResourceCache.GetShaders(gd, gd.ResourceFactory, "DebugWire").ToTuple(); * Shaders = new Shader[] { res.Item1, res.Item2 }; * * ResourceLayout mainPerObjectLayout = StaticResourceCache.GetResourceLayout(gd.ResourceFactory, new ResourceLayoutDescription( * new ResourceLayoutElementDescription("WorldBuffer", ResourceKind.StructuredBufferReadWrite, ShaderStages.Vertex | ShaderStages.Fragment, ResourceLayoutElementOptions.None))); * * PerObjRS = StaticResourceCache.GetResourceSet(factory, new ResourceSetDescription(mainPerObjectLayout, * Renderer.UniformBufferAllocator._backingBuffer)); * * GraphicsPipelineDescription pipelineDescription = new GraphicsPipelineDescription(); * pipelineDescription.BlendState = BlendStateDescription.SingleOverrideBlend; * pipelineDescription.DepthStencilState = new DepthStencilStateDescription( * depthTestEnabled: true, * depthWriteEnabled: true, * comparisonKind: ComparisonKind.GreaterEqual); * pipelineDescription.RasterizerState = new RasterizerStateDescription( * cullMode: FaceCullMode.None, * fillMode: PolygonFillMode.Solid, * frontFace: FrontFace.CounterClockwise, * depthClipEnabled: true, * scissorTestEnabled: false); * pipelineDescription.PrimitiveTopology = PrimitiveTopology.TriangleList; * pipelineDescription.ShaderSet = new ShaderSetDescription( * vertexLayouts: mainVertexLayouts, * shaders: Shaders); * pipelineDescription.ResourceLayouts = new ResourceLayout[] { StaticResourceCache.GetResourceLayout( * gd.ResourceFactory, * StaticResourceCache.SceneParamLayoutDescription), mainPerObjectLayout, Renderer.GlobalTexturePool.GetLayout(), Renderer.GlobalCubeTexturePool.GetLayout(), Renderer.MaterialBufferAllocator.GetLayout(), SamplerSet.SamplersLayout }; * pipelineDescription.Outputs = gd.SwapchainFramebuffer.OutputDescription; * RenderPipeline = StaticResourceCache.GetPipeline(factory, ref pipelineDescription);*/ }
/// <summary> /// Returns whether the specified Graphics API is supported /// </summary> /// <param name="api"></param> /// <returns></returns> public static bool IsGraphicsAPISupported(GraphicsAPI api) { if (api == GraphicsAPI.Default) { return(true); } else { return(VGDevice.IsBackendSupported((GraphicsBackend)api)); } }
//public void DrawIndexed(int indexCount, uint instanceCount, uint indexStart, int vertexOffset, uint instanceStart) //{ // Issue a Draw command for a single instance with 4 indices. //veldridCommandList.DrawIndexed(Convert.ToUInt32(indexCount), instanceCount, indexStart, vertexOffset, instanceStart); //} #endregion #region Internal API /// <summary> /// Initialises the GraphicsDevice /// </summary> /// <param name="graphicsAPI"></param> internal void Initialise(VesselWindow window, ApplicationConfig config) { GraphicsAPI = config.GraphicsAPI; GraphicsDeviceOptions options = new GraphicsDeviceOptions { PreferStandardClipSpaceYDirection = true, PreferDepthRangeZeroToOne = true, SyncToVerticalBlank = config.VSync, Debug = config.DebugMode, }; DefaultGraphicsAPI = (GraphicsAPI)VeldridStartup.GetPlatformDefaultBackend(); if (config.GraphicsAPI == GraphicsAPI.Default) { veldridGraphicsDevice = VeldridStartup.CreateGraphicsDevice(window.WindowInternal, options, (GraphicsBackend)DefaultGraphicsAPI); } else { veldridGraphicsDevice = VeldridStartup.CreateGraphicsDevice(window.WindowInternal, options, (GraphicsBackend)config.GraphicsAPI); } //Create the Graphics Resources ResourceFactory factory = veldridGraphicsDevice.ResourceFactory; //TODO: Replace with ResourceFactory.Load("ShaderTest0"); //shader = new ShaderTechnique(this, //System.IO.File.ReadAllBytes(@"E:\Data\Projects\Vessel\VesselSharp\VesselSharp\ShaderTests\ShaderTest0.vert.spv"), //System.IO.File.ReadAllBytes(@"E:\Data\Projects\Vessel\VesselSharp\VesselSharp\ShaderTests\ShaderTest0.frag.spv"), //"ShaderTest0"); // TODO: Move pipeline to Shader class // TODO: Shader => ShaderTechnique; ComputeShader // TODO: Assets can be compiled (i.e. banks) or directories (i.e. folder of compiled assets (eg shader.shd), assets aren't packaged into an archive though) - for use during dev cuz packaging archives will probably be time consuming as f**k and decimate workflows // Create pipeline /* * pipelineDescription = new GraphicsPipelineDescription(); * pipelineDescription.BlendState = BlendStateDescription.SingleOverrideBlend; * pipelineDescription.DepthStencilState = new DepthStencilStateDescription( * depthTestEnabled: true, * depthWriteEnabled: true, * comparisonKind: ComparisonKind.LessEqual); * * pipelineDescription.RasterizerState = new RasterizerStateDescription( * cullMode: FaceCullMode.Back, * fillMode: PolygonFillMode.Solid, * frontFace: FrontFace.Clockwise, * depthClipEnabled: true, * scissorTestEnabled: false); * * pipelineDescription.PrimitiveTopology = PrimitiveTopology.TriangleStrip; * pipelineDescription.ResourceLayouts = System.Array.Empty<ResourceLayout>(); * pipelineDescription.ShaderSet = new ShaderSetDescription( * vertexLayouts: new VertexLayoutDescription[] * { * VertexPositionColor.VertexLayout, * }, * shaders: shader.Programs); * pipelineDescription.Outputs = veldridGraphicsDevice.SwapchainFramebuffer.OutputDescription; * * veldridPipeline = factory.CreateGraphicsPipeline(pipelineDescription); */ veldridCommandList = factory.CreateCommandList(); }
public void CreateDeviceObjects(Veldrid.GraphicsDevice gd, CommandList cl, SceneRenderPipeline sp) { throw new NotImplementedException(); }