(6eeea9b7c) v0.9.10.0.0
This commit is contained in:
@@ -160,21 +160,34 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public static int FileCount => Internal.GetFileCount();
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of filenames synchronized by Steam Cloud
|
||||
/// </summary>
|
||||
public static IEnumerable<string> Files
|
||||
public struct RemoteFile
|
||||
{
|
||||
get
|
||||
public string Filename;
|
||||
public int Size;
|
||||
|
||||
public bool Delete()
|
||||
{
|
||||
int _ = 0;
|
||||
for( int i=0; i<FileCount; i++ )
|
||||
{
|
||||
var filename = Internal.GetFileNameAndSize( i, ref _ );
|
||||
yield return filename;
|
||||
}
|
||||
return Internal.FileDelete(Filename);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of filenames synchronized by Steam Cloud
|
||||
/// </summary>
|
||||
public static List<RemoteFile> Files
|
||||
{
|
||||
get
|
||||
{
|
||||
var ret = new List<RemoteFile>();
|
||||
int count = FileCount;
|
||||
for( int i=0; i<count; i++ )
|
||||
{
|
||||
int size = -1;
|
||||
var filename = Internal.GetFileNameAndSize( i, ref size );
|
||||
ret.Add(new RemoteFile { Filename = filename, Size = size });
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,13 @@ namespace Steamworks.Ugc
|
||||
return this;
|
||||
}
|
||||
|
||||
public bool HasTag( string tag )
|
||||
{
|
||||
if (Tags != null && Tags.Contains(tag)) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<PublishResult> SubmitAsync( IProgress<float> progress = null )
|
||||
{
|
||||
var result = default( PublishResult );
|
||||
|
||||
@@ -664,7 +664,7 @@ namespace FarseerPhysics.Dynamics
|
||||
}
|
||||
}
|
||||
|
||||
if (Enabled)
|
||||
if (Enabled && World != null)
|
||||
{
|
||||
IBroadPhase broadPhase = World.ContactManager.BroadPhase;
|
||||
fixture.DestroyProxies(broadPhase);
|
||||
@@ -677,7 +677,7 @@ namespace FarseerPhysics.Dynamics
|
||||
((PolygonShape)fixture.Shape).Vertices.AttachedToBody = false;
|
||||
#endif
|
||||
|
||||
if (World.FixtureRemoved != null)
|
||||
if (World?.FixtureRemoved != null)
|
||||
World.FixtureRemoved(World, this, fixture);
|
||||
|
||||
ResetMassData();
|
||||
|
||||
+2
-2
@@ -1382,13 +1382,13 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
|
||||
private void PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount)
|
||||
{
|
||||
var indexCount = GetElementCountArray(primitiveType, primitiveCount);
|
||||
|
||||
lock (_d3dContext)
|
||||
{
|
||||
ApplyState(true);
|
||||
|
||||
_d3dContext.InputAssembler.PrimitiveTopology = ToPrimitiveTopology(primitiveType);
|
||||
|
||||
var indexCount = GetElementCountArray(primitiveType, primitiveCount);
|
||||
_d3dContext.DrawIndexed(indexCount, startIndex, baseVertex);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-3
@@ -8,8 +8,18 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
{
|
||||
public sealed partial class SamplerStateCollection
|
||||
{
|
||||
private int _d3dMaxDirty;
|
||||
private int _d3dDirty;
|
||||
|
||||
partial void CalculateMaxDirty()
|
||||
{
|
||||
_d3dMaxDirty = 0;
|
||||
for (var i = 0; i < _actualSamplers.Length; i++)
|
||||
{
|
||||
_d3dMaxDirty |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlatformSetSamplerState(int index)
|
||||
{
|
||||
_d3dDirty |= 1 << index;
|
||||
@@ -17,12 +27,12 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
|
||||
private void PlatformClear()
|
||||
{
|
||||
_d3dDirty = int.MaxValue;
|
||||
_d3dDirty = _d3dMaxDirty;
|
||||
}
|
||||
|
||||
private void PlatformDirty()
|
||||
{
|
||||
_d3dDirty = int.MaxValue;
|
||||
_d3dDirty = _d3dMaxDirty;
|
||||
}
|
||||
|
||||
internal void PlatformSetSamplers(GraphicsDevice device)
|
||||
@@ -60,7 +70,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
break;
|
||||
}
|
||||
|
||||
_d3dDirty = 0;
|
||||
if (_d3dDirty != 0) { throw new System.Exception($"SamplerStateCollection still dirty ({_d3dDirty})"); }
|
||||
//_d3dDirty = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -23,6 +23,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
private readonly SamplerState[] _actualSamplers;
|
||||
private readonly bool _applyToVertexStage;
|
||||
|
||||
partial void CalculateMaxDirty();
|
||||
|
||||
internal SamplerStateCollection(GraphicsDevice device, int maxSamplers, bool applyToVertexStage)
|
||||
{
|
||||
_graphicsDevice = device;
|
||||
@@ -38,7 +40,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
_actualSamplers = new SamplerState[maxSamplers];
|
||||
_applyToVertexStage = applyToVertexStage;
|
||||
|
||||
Clear();
|
||||
CalculateMaxDirty();
|
||||
Clear();
|
||||
}
|
||||
|
||||
public SamplerState this [int index]
|
||||
|
||||
@@ -1258,7 +1258,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
}
|
||||
}
|
||||
}
|
||||
_batcher.Dispose();
|
||||
//_batcher.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
/// batched and will process them into short.MaxValue groups (strided by 6 for the number of vertices
|
||||
/// sent to the GPU).
|
||||
/// </summary>
|
||||
internal class SpriteBatcher : IDisposable
|
||||
{
|
||||
internal class SpriteBatcher
|
||||
{
|
||||
/*
|
||||
* Note that this class is fundamental to high performance for SpriteBatch games. Please exercise
|
||||
* caution when making changes to this class.
|
||||
@@ -41,7 +41,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
/// Index pointer to the next available SpriteBatchItem in _batchItemList.
|
||||
/// </summary>
|
||||
private int _batchItemCount;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The target graphics device.
|
||||
/// </summary>
|
||||
@@ -54,21 +54,18 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
|
||||
private VertexPositionColorTexture[] _vertexArray;
|
||||
|
||||
private VertexBuffer vertexBuffer;
|
||||
private IndexBuffer indexBuffer;
|
||||
|
||||
public SpriteBatcher (GraphicsDevice device)
|
||||
{
|
||||
public SpriteBatcher(GraphicsDevice device)
|
||||
{
|
||||
_device = device;
|
||||
|
||||
_batchItemList = new SpriteBatchItem[InitialBatchSize];
|
||||
_batchItemList = new SpriteBatchItem[InitialBatchSize];
|
||||
_batchItemCount = 0;
|
||||
|
||||
for (int i = 0; i < InitialBatchSize; i++)
|
||||
_batchItemList[i] = new SpriteBatchItem();
|
||||
|
||||
EnsureArrayCapacity(InitialBatchSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reuse a previously allocated SpriteBatchItem from the item pool.
|
||||
@@ -80,11 +77,11 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
if (_batchItemCount >= _batchItemList.Length)
|
||||
{
|
||||
var oldSize = _batchItemList.Length;
|
||||
var newSize = oldSize + oldSize/2; // grow by x1.5
|
||||
var newSize = oldSize + oldSize / 2; // grow by x1.5
|
||||
newSize = (newSize + 63) & (~63); // grow in chunks of 64.
|
||||
Array.Resize(ref _batchItemList, newSize);
|
||||
for(int i=oldSize; i<newSize; i++)
|
||||
_batchItemList[i]=new SpriteBatchItem();
|
||||
for (int i = oldSize; i < newSize; i++)
|
||||
_batchItemList[i] = new SpriteBatchItem();
|
||||
|
||||
EnsureArrayCapacity(Math.Min(newSize, MaxBatchSize));
|
||||
}
|
||||
@@ -139,14 +136,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
_index = newIndex;
|
||||
|
||||
_vertexArray = new VertexPositionColorTexture[4 * numBatchItems];
|
||||
|
||||
indexBuffer?.Dispose();
|
||||
vertexBuffer?.Dispose();
|
||||
indexBuffer = new IndexBuffer(_device, IndexElementSize.SixteenBits, _index.Length, BufferUsage.WriteOnly);
|
||||
indexBuffer.SetData(_index);
|
||||
vertexBuffer = new VertexBuffer(_device, VertexPositionColorTexture.VertexDeclaration, _vertexArray.Length, BufferUsage.WriteOnly);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sorts the batch items and then groups batch drawing into maximal allowed batch sets that do not
|
||||
/// overflow the 16 bit array indices for vertices.
|
||||
@@ -154,36 +145,36 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
/// <param name="sortMode">The type of depth sorting desired for the rendering.</param>
|
||||
/// <param name="effect">The custom effect to apply to the drawn geometry</param>
|
||||
public unsafe void DrawBatch(SpriteSortMode sortMode, Effect effect)
|
||||
{
|
||||
{
|
||||
if (effect != null && effect.IsDisposed)
|
||||
throw new ObjectDisposedException("effect");
|
||||
|
||||
// nothing to do
|
||||
// nothing to do
|
||||
if (_batchItemCount == 0)
|
||||
return;
|
||||
|
||||
// sort the batch items
|
||||
switch ( sortMode )
|
||||
{
|
||||
case SpriteSortMode.Texture :
|
||||
case SpriteSortMode.FrontToBack :
|
||||
case SpriteSortMode.BackToFront :
|
||||
Array.Sort(_batchItemList, 0, _batchItemCount);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
// sort the batch items
|
||||
switch (sortMode)
|
||||
{
|
||||
case SpriteSortMode.Texture:
|
||||
case SpriteSortMode.FrontToBack:
|
||||
case SpriteSortMode.BackToFront:
|
||||
Array.Sort(_batchItemList, 0, _batchItemCount);
|
||||
break;
|
||||
}
|
||||
|
||||
// Determine how many iterations through the drawing code we need to make
|
||||
int batchIndex = 0;
|
||||
int batchCount = _batchItemCount;
|
||||
|
||||
|
||||
|
||||
unchecked
|
||||
{
|
||||
_device._graphicsMetrics._spriteCount += batchCount;
|
||||
}
|
||||
|
||||
// Iterate through the batches, doing short.MaxValue sets of vertices only.
|
||||
while(batchCount > 0)
|
||||
while (batchCount > 0)
|
||||
{
|
||||
// setup the vertexArray array
|
||||
var startIndex = 0;
|
||||
@@ -217,10 +208,10 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
}
|
||||
|
||||
// store the SpriteBatchItem data in our vertexArray
|
||||
*(vertexArrayPtr+0) = item.vertexTL;
|
||||
*(vertexArrayPtr+1) = item.vertexTR;
|
||||
*(vertexArrayPtr+2) = item.vertexBL;
|
||||
*(vertexArrayPtr+3) = item.vertexBR;
|
||||
*(vertexArrayPtr + 0) = item.vertexTL;
|
||||
*(vertexArrayPtr + 1) = item.vertexTR;
|
||||
*(vertexArrayPtr + 2) = item.vertexBL;
|
||||
*(vertexArrayPtr + 3) = item.vertexBR;
|
||||
|
||||
// Release the texture.
|
||||
item.Texture = null;
|
||||
@@ -234,7 +225,6 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
}
|
||||
// return items to the pool.
|
||||
_batchItemCount = 0;
|
||||
_device.Textures[0] = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -251,7 +241,6 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
|
||||
var vertexCount = end - start;
|
||||
|
||||
_device.Indices = indexBuffer;
|
||||
// If the effect is not null, then apply each pass and render the geometry
|
||||
if (effect != null)
|
||||
{
|
||||
@@ -263,27 +252,31 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
// Whatever happens in pass.Apply, make sure the texture being drawn
|
||||
// ends up in Textures[0].
|
||||
_device.Textures[0] = texture;
|
||||
vertexBuffer.SetData(_vertexArray, start, vertexCount);
|
||||
_device.SetVertexBuffer(vertexBuffer);
|
||||
_device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, (vertexCount / 4) * 2);
|
||||
|
||||
_device.DrawUserIndexedPrimitives(
|
||||
PrimitiveType.TriangleList,
|
||||
_vertexArray,
|
||||
0,
|
||||
vertexCount,
|
||||
_index,
|
||||
0,
|
||||
(vertexCount / 4) * 2,
|
||||
VertexPositionColorTexture.VertexDeclaration);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no custom effect is defined, then simply render.
|
||||
vertexBuffer.SetData(_vertexArray, start, vertexCount);
|
||||
_device.SetVertexBuffer(vertexBuffer);
|
||||
_device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, (vertexCount / 4) * 2);
|
||||
_device.DrawUserIndexedPrimitives(
|
||||
PrimitiveType.TriangleList,
|
||||
_vertexArray,
|
||||
0,
|
||||
vertexCount,
|
||||
_index,
|
||||
0,
|
||||
(vertexCount / 4) * 2,
|
||||
VertexPositionColorTexture.VertexDeclaration);
|
||||
}
|
||||
|
||||
_device.Indices = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
indexBuffer?.Dispose();
|
||||
vertexBuffer?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -16,13 +16,15 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
return;
|
||||
|
||||
if (_applyToVertexStage)
|
||||
ClearTargets(targets, device._d3dContext.VertexShader);
|
||||
ClearTargets(targets, device, device._d3dContext.VertexShader);
|
||||
else
|
||||
ClearTargets(targets, device._d3dContext.PixelShader);
|
||||
ClearTargets(targets, device, device._d3dContext.PixelShader);
|
||||
}
|
||||
|
||||
private void ClearTargets(RenderTargetBinding[] targets, SharpDX.Direct3D11.CommonShaderStage shaderStage)
|
||||
private void ClearTargets(RenderTargetBinding[] targets, GraphicsDevice device, SharpDX.Direct3D11.CommonShaderStage shaderStage)
|
||||
{
|
||||
PlatformSetTextures(device);
|
||||
|
||||
// NOTE: We make the assumption here that the caller has
|
||||
// locked the d3dContext for us to use.
|
||||
|
||||
@@ -92,7 +94,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
break;
|
||||
}
|
||||
|
||||
_dirty = 0;
|
||||
if (_dirty != 0) { throw new System.Exception($"TextureCollection still dirty ({_dirty})"); }
|
||||
//_dirty = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,18 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
private readonly Texture[] _textures;
|
||||
private readonly bool _applyToVertexStage;
|
||||
private int _dirty;
|
||||
private int _dirtyMax;
|
||||
|
||||
internal TextureCollection(GraphicsDevice graphicsDevice, int maxTextures, bool applyToVertexStage)
|
||||
{
|
||||
_graphicsDevice = graphicsDevice;
|
||||
_textures = new Texture[maxTextures];
|
||||
_applyToVertexStage = applyToVertexStage;
|
||||
_dirty = int.MaxValue;
|
||||
for (int i=0;i<maxTextures;i++)
|
||||
{
|
||||
_dirtyMax |= 1 << i;
|
||||
}
|
||||
_dirty = _dirtyMax;
|
||||
PlatformInit();
|
||||
}
|
||||
|
||||
@@ -47,7 +52,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
_textures[i] = null;
|
||||
|
||||
PlatformClear();
|
||||
_dirty = int.MaxValue;
|
||||
_dirty = _dirtyMax;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,7 +60,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
/// </summary>
|
||||
internal void Dirty()
|
||||
{
|
||||
_dirty = int.MaxValue;
|
||||
_dirty = _dirtyMax;
|
||||
}
|
||||
|
||||
internal void SetTextures(GraphicsDevice device)
|
||||
|
||||
Reference in New Issue
Block a user