Ejemplo n.º 1
0
        private bool disposedValue = false; // To detect redundant calls

        void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    buffer = null;
                    // TODO: dispose managed state (managed objects).
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Ejemplo n.º 2
0
        public void UploadToBuffer(IBufferProxy buffer, DeviceContextProxy context)
        {
            if (buffer.StructureSize == SizeInBytes)
            {
                context.MapSubresource(buffer.Buffer, 0, MapMode.WriteDiscard, MapFlags.None, out DataStream stream);
                using (stream)
                {
                    stream.WriteRange(Lights, 0, Lights.Length);
                    stream.Write(AmbientLight);
                    stream.Write(LightCount);
                }
                context.UnmapSubresource(buffer.Buffer, 0);
            }
            else
            {
#if DEBUG
                throw new ArgumentException("Buffer type or size do not match the model requirement");
#endif
            }
        }
Ejemplo n.º 3
0
 public void UploadToBuffer(IBufferProxy buffer, DeviceContext context)
 {
     if (buffer.StructureSize == SizeInBytes)
     {
         if (buffer.Buffer.Description.Usage == ResourceUsage.Dynamic)
         {
             DataStream stream;
             context.MapSubresource(buffer.Buffer, 0, MapMode.WriteDiscard, MapFlags.None, out stream);
             using (stream)
             {
                 stream.WriteRange(Lights, 0, Lights.Length);
                 stream.Write(AmbientLight);
                 stream.Write(LightCount);
                 context.UnmapSubresource(buffer.Buffer, 0);
             }
         }
     }
     else
     {
         throw new ArgumentException("Buffer type or size do not match the model requirement");
     }
 }
Ejemplo n.º 4
0
            public void UploadToBuffer(IBufferProxy buffer, DeviceContextProxy context)
            {
                if (buffer.StructureSize == SizeInBytes)
                {
                    var dataBox = context.MapSubresource(buffer.Buffer, 0, MapMode.WriteDiscard, MapFlags.None);
                    if (dataBox.IsEmpty)
                    {
                        return;
                    }
                    var ptr = UnsafeHelper.Write(dataBox.DataPointer, Lights, 0, Lights.Length);
                    ptr = UnsafeHelper.Write(ptr, AmbientLight);
                    ptr = UnsafeHelper.Write(ptr, LightCount);
                    ptr = UnsafeHelper.Write(ptr, HasEnvironmentMap ? 1 : 0);
                    ptr = UnsafeHelper.Write(ptr, EnvironmentMapMipLevels);
                    context.UnmapSubresource(buffer.Buffer, 0);
                }
                else
                {
#if DEBUG
                    throw new ArgumentException("Buffer type or size do not match the model requirement");
#endif
                }
            }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 public Light3DSceneShared(IConstantBufferPool pool)
 {
     buffer = pool.Register(DefaultBufferNames.LightCB, LightsBufferModel.SizeInBytes);
 }