internal static LightId Create(uint GID) { var id = new LightId { Index = m_lights.Allocate() }; m_lights.Data[id.Index] = new MyLightInfo { FlareId = FlareId.NULL }; MyArrayHelpers.Reserve(ref m_pointlights, id.Index + 1); MyArrayHelpers.Reserve(ref m_spotlights, id.Index + 1); var p1 = new MyPointlightInfo { LastBvhUpdatePosition = Vector3.PositiveInfinity, BvhProxyId = -1 }; m_pointlights[id.Index] = p1; var p2 = new MySpotlightInfo { LastBvhUpdatePosition = Vector3.PositiveInfinity, BvhProxyId = -1 }; m_spotlights[id.Index] = p2; m_idIndex[GID] = id; return(id); }
internal static StructuredBufferId CreateStructuredBuffer(BufferDescription description, IntPtr?data, string debugName) { var id = new StructuredBufferId { Index = SBuffers.Allocate() }; MyArrayHelpers.Reserve(ref SBuffersData, id.Index + 1); SBuffers.Data[id.Index] = new MyHwBufferDesc { Description = description, DebugName = debugName }; SBuffersData[id.Index] = new MyStructuredBufferData { }; SbIndices.Add(id); if (!data.HasValue) { InitStructuredBuffer(id); } else { InitStructuredBuffer(id, data.Value); } return(id); }
internal static VertexBufferId CreateVertexBuffer(BufferDescription description, int stride, IntPtr?data, string debugName) { if (description.SizeInBytes == 0) { return(VertexBufferId.NULL); } var id = new VertexBufferId { Index = VBuffers.Allocate() }; MyArrayHelpers.Reserve(ref VBuffersData, id.Index + 1); VBuffers.Data[id.Index] = new MyHwBufferDesc { Description = description, DebugName = debugName }; VBuffersData[id.Index] = new MyVertexBufferData { Stride = stride }; VbIndices.Add(id); if (!data.HasValue) { InitVertexBuffer(id); } else { InitVertexBuffer(id, data.Value); } return(id); }
internal static IndexBufferId CreateIndexBuffer(BufferDescription description, Format format, IntPtr?data, string debugName) { var id = new IndexBufferId { Index = IBuffers.Allocate() }; MyArrayHelpers.Reserve(ref IBuffersData, id.Index + 1); IBuffers.Data[id.Index] = new MyHwBufferDesc { Description = description, DebugName = debugName }; IBuffersData[id.Index] = new MyIndexBufferData { Format = format }; IbIndices.Add(id); if (!data.HasValue) { InitIndexBuffer(id); } else { InitIndexBuffer(id, data.Value); } return(id); }
internal static ConstantsBufferId CreateConstantsBuffer(BufferDescription description, string debugName) { var id = new ConstantsBufferId { Index = CBuffers.Allocate() }; MyArrayHelpers.Reserve(ref CBuffersData, id.Index + 1); CBuffers.Data[id.Index] = new MyHwBufferDesc { Description = description, DebugName = debugName }; CbIndices.Add(id); InitConstantsBuffer(id); return(id); }