- some work on Texture2DWriter (not finished yet)
- fixed issue #1021 (RenderTarget issue with SpriteBatch)
This commit is contained in:
parent
4c4b999b9c
commit
61ba3497f2
@ -149,6 +149,7 @@
|
|||||||
<Compile Include="Serialization\Compiler\GenericContentTypeWriter.cs" />
|
<Compile Include="Serialization\Compiler\GenericContentTypeWriter.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Serialization\Compiler\GraphicTypeWriters\EffectWriter.cs" />
|
<Compile Include="Serialization\Compiler\GraphicTypeWriters\EffectWriter.cs" />
|
||||||
|
<Compile Include="Serialization\Compiler\GraphicTypeWriters\Texture2DWriter.cs" />
|
||||||
<Compile Include="Serialization\Compiler\GraphicTypeWriters\SpriteFontWriter.cs" />
|
<Compile Include="Serialization\Compiler\GraphicTypeWriters\SpriteFontWriter.cs" />
|
||||||
<Compile Include="Serialization\Compiler\GraphicTypeWriters\TextureWriter.cs" />
|
<Compile Include="Serialization\Compiler\GraphicTypeWriters\TextureWriter.cs" />
|
||||||
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingBoxWriter.cs" />
|
<Compile Include="Serialization\Compiler\MathTypeWriters\BoundingBoxWriter.cs" />
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#region Using Statements
|
#region Using Statements
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -34,12 +36,26 @@ namespace ANX.Framework.Content.Pipeline.Graphics
|
|||||||
|
|
||||||
public override byte[] GetPixelData()
|
public override byte[] GetPixelData()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
int rowSize = Marshal.SizeOf(typeof(T)) * base.Width;
|
||||||
|
byte[] array = new byte[rowSize * base.Height];
|
||||||
|
for (int i = 0; i < base.Height; i++)
|
||||||
|
{
|
||||||
|
T[] row = GetRow(i);
|
||||||
|
|
||||||
|
BitCopier.Copy<T, byte>(this.GetRow(i), 0, PixelBitmapContent<T>.pixelSize, array, i * num, PixelBitmapContent<T>.pixelSize, PixelBitmapContent<T>.pixelSize, base.Width);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T[] GetRow(int y)
|
public T[] GetRow(int y)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
T[] row = new T[Width];
|
||||||
|
for (int col = 0; col < Width; col++)
|
||||||
|
{
|
||||||
|
row[col] = pixels[col, y];
|
||||||
|
}
|
||||||
|
|
||||||
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPixel(int x, int y, T value)
|
public void SetPixel(int x, int y, T value)
|
||||||
@ -67,9 +83,65 @@ namespace ANX.Framework.Content.Pipeline.Graphics
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryGetFormat(out Framework.Graphics.SurfaceFormat format)
|
public override bool TryGetFormat(out SurfaceFormat format)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
string type = typeof(T).Name.ToLowerInvariant();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case "float":
|
||||||
|
format = SurfaceFormat.Single;
|
||||||
|
return true;
|
||||||
|
case "vector2":
|
||||||
|
format = SurfaceFormat.Single;
|
||||||
|
return true;
|
||||||
|
case "vector4":
|
||||||
|
format = SurfaceFormat.Vector4;
|
||||||
|
return true;
|
||||||
|
case "halfsingle":
|
||||||
|
format = SurfaceFormat.HalfVector2;
|
||||||
|
return true;
|
||||||
|
case "halfvector2":
|
||||||
|
format = SurfaceFormat.HalfVector2;
|
||||||
|
return true;
|
||||||
|
case "halfvector4":
|
||||||
|
format = SurfaceFormat.HalfVector4;
|
||||||
|
return true;
|
||||||
|
case "bgra5551":
|
||||||
|
format = SurfaceFormat.Bgra5551;
|
||||||
|
return true;
|
||||||
|
case "bgr565":
|
||||||
|
format = SurfaceFormat.Bgr565;
|
||||||
|
return true;
|
||||||
|
case "bgra4444":
|
||||||
|
format = SurfaceFormat.Bgra4444;
|
||||||
|
return true;
|
||||||
|
case "color":
|
||||||
|
format = SurfaceFormat.Color;
|
||||||
|
return true;
|
||||||
|
case "rg32":
|
||||||
|
format = SurfaceFormat.Rg32;
|
||||||
|
return true;
|
||||||
|
case "rgba64":
|
||||||
|
format = SurfaceFormat.Rgba64;
|
||||||
|
return true;
|
||||||
|
case "rgba1010102":
|
||||||
|
format = SurfaceFormat.Rgba1010102;
|
||||||
|
return true;
|
||||||
|
case "alpha8":
|
||||||
|
format = SurfaceFormat.Alpha8;
|
||||||
|
return true;
|
||||||
|
case "normalizedbyte2":
|
||||||
|
format = SurfaceFormat.NormalizedByte2;
|
||||||
|
return true;
|
||||||
|
case "normalizedbyte4":
|
||||||
|
format = SurfaceFormat.NormalizedByte4;
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
format = Framework.Graphics.SurfaceFormat.Color;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
#region Using Statements
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using ANX.Framework.Content.Pipeline.Graphics;
|
||||||
|
using System.Reflection;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// This file is part of the ANX.Framework created by the
|
||||||
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||||
|
// For details see: http://anxframework.codeplex.com/license
|
||||||
|
|
||||||
|
namespace ANX.Framework.Content.Pipeline.Serialization.Compiler
|
||||||
|
{
|
||||||
|
[ContentTypeWriter]
|
||||||
|
internal class Texture2DWriter : BuiltinTypeWriter<Texture2DContent>
|
||||||
|
{
|
||||||
|
protected override Assembly RuntimeAssembly
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return typeof(Texture).Assembly;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected internal override void Write(ContentWriter output, Texture2DContent value)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
|
||||||
|
BitmapContent bitmapContent = value.Faces[0][0];
|
||||||
|
SurfaceFormat format;
|
||||||
|
if (!bitmapContent.TryGetFormat(out format))
|
||||||
|
{
|
||||||
|
throw new InvalidContentException("bad texture type");
|
||||||
|
}
|
||||||
|
|
||||||
|
// write header
|
||||||
|
output.Write((int)format);
|
||||||
|
output.Write(bitmapContent.Width);
|
||||||
|
output.Write(bitmapContent.Height);
|
||||||
|
output.Write(value.Faces[0].Count);
|
||||||
|
|
||||||
|
foreach (MipmapChain current in value.Faces)
|
||||||
|
{
|
||||||
|
foreach (BitmapContent currentFace in current)
|
||||||
|
{
|
||||||
|
byte[] pixelData = currentFace.GetPixelData();
|
||||||
|
output.Write(pixelData.Length);
|
||||||
|
output.Write(pixelData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetRuntimeType(TargetPlatform targetPlatform)
|
||||||
|
{
|
||||||
|
return ContentTypeWriter.GetStrongTypeName(typeof(Texture2D), targetPlatform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,13 +12,6 @@ namespace ANX.Framework.Content
|
|||||||
{
|
{
|
||||||
protected internal override Texture2D Read(ContentReader input, Texture2D existingInstance)
|
protected internal override Texture2D Read(ContentReader input, Texture2D existingInstance)
|
||||||
{
|
{
|
||||||
//IServiceProvider service = input.ContentManager.ServiceProvider;
|
|
||||||
//var renderSystem = service.GetService(typeof(IRenderSystemCreator)) as IRenderSystemCreator;
|
|
||||||
//if (renderSystem == null)
|
|
||||||
// throw new ContentLoadException("Service not found IRenderSystemCreator");
|
|
||||||
|
|
||||||
//GraphicsDevice graphics = input.ResolveGraphicsDevice();
|
|
||||||
|
|
||||||
SurfaceFormat surfaceFormat = (SurfaceFormat)input.ReadInt32();
|
SurfaceFormat surfaceFormat = (SurfaceFormat)input.ReadInt32();
|
||||||
int width = input.ReadInt32();
|
int width = input.ReadInt32();
|
||||||
int height = input.ReadInt32();
|
int height = input.ReadInt32();
|
||||||
|
@ -87,7 +87,15 @@ namespace ANX.Framework.Graphics
|
|||||||
[MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
|
[MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
|
||||||
: base(graphicsDevice)
|
: base(graphicsDevice)
|
||||||
{
|
{
|
||||||
this.depthStencilFormat = DepthFormat.None;
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
OneOverWidth = 1f / width;
|
||||||
|
OneOverHeight = 1f / height;
|
||||||
|
|
||||||
|
base.levelCount = 1;
|
||||||
|
base.format = preferredFormat;
|
||||||
|
|
||||||
|
this.depthStencilFormat = preferredDepthFormat;
|
||||||
this.multiSampleCount = 0;
|
this.multiSampleCount = 0;
|
||||||
this.usage = RenderTargetUsage.DiscardContents;
|
this.usage = RenderTargetUsage.DiscardContents;
|
||||||
|
|
||||||
@ -102,6 +110,14 @@ namespace ANX.Framework.Graphics
|
|||||||
int preferredMultiSampleCount, RenderTargetUsage usage)
|
int preferredMultiSampleCount, RenderTargetUsage usage)
|
||||||
: base(graphicsDevice)
|
: base(graphicsDevice)
|
||||||
{
|
{
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
OneOverWidth = 1f / width;
|
||||||
|
OneOverHeight = 1f / height;
|
||||||
|
|
||||||
|
base.levelCount = 1;
|
||||||
|
base.format = preferredFormat;
|
||||||
|
|
||||||
this.depthStencilFormat = preferredDepthFormat;
|
this.depthStencilFormat = preferredDepthFormat;
|
||||||
this.multiSampleCount = preferredMultiSampleCount;
|
this.multiSampleCount = preferredMultiSampleCount;
|
||||||
this.usage = usage;
|
this.usage = usage;
|
||||||
|
@ -583,8 +583,8 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
cachedTransformMatrix = new Matrix()
|
cachedTransformMatrix = new Matrix()
|
||||||
{
|
{
|
||||||
M11 = 2f * (this.viewportWidth > 0 ? 1f / (float)this.viewportWidth : 0f),
|
M11 = 2f * (this.viewportWidth > 0 ? 1f / ((float)this.viewportWidth - 1f) : 0f),
|
||||||
M22 = 2f * (this.viewportHeight > 0 ? -1f / (float)this.viewportHeight : 0f),
|
M22 = 2f * (this.viewportHeight > 0 ? -1f / ((float)this.viewportHeight - 1f) : 0f),
|
||||||
M33 = 1f,
|
M33 = 1f,
|
||||||
M44 = 1f,
|
M44 = 1f,
|
||||||
M41 = -1f,
|
M41 = -1f,
|
||||||
|
@ -58,6 +58,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
|||||||
{
|
{
|
||||||
backBuffer = Dx10.Texture2D.FromSwapChain<Dx10.Texture2D>(swapChain, 0);
|
backBuffer = Dx10.Texture2D.FromSwapChain<Dx10.Texture2D>(swapChain, 0);
|
||||||
renderView = new Dx10.RenderTargetView(nativeDevice, backBuffer);
|
renderView = new Dx10.RenderTargetView(nativeDevice, backBuffer);
|
||||||
|
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -112,6 +113,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
|||||||
this.depthStencilBuffer = new Dx10.Texture2D(nativeDevice, depthStencilTextureDesc);
|
this.depthStencilBuffer = new Dx10.Texture2D(nativeDevice, depthStencilTextureDesc);
|
||||||
|
|
||||||
this.depthStencilView = new Dx10.DepthStencilView(nativeDevice, this.depthStencilBuffer);
|
this.depthStencilView = new Dx10.DepthStencilView(nativeDevice, this.depthStencilBuffer);
|
||||||
|
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
// this workaround is working but maybe not the best solution to issue #472
|
// this workaround is working but maybe not the best solution to issue #472
|
||||||
Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0);
|
Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0);
|
||||||
@ -207,7 +209,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
|||||||
|
|
||||||
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
||||||
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
||||||
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
if (indexBuffer != null)
|
if (indexBuffer != null)
|
||||||
{
|
{
|
||||||
@ -233,7 +235,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
|||||||
|
|
||||||
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
||||||
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
||||||
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
for (int i = 0; i < technique.Description.PassCount; ++i)
|
for (int i = 0; i < technique.Description.PassCount; ++i)
|
||||||
{
|
{
|
||||||
@ -255,7 +257,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
|||||||
|
|
||||||
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
||||||
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
||||||
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
if (indexBuffer != null)
|
if (indexBuffer != null)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
|
|||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.7.21.*")]
|
[assembly: AssemblyVersion("0.7.22.*")]
|
||||||
[assembly: AssemblyFileVersion("0.7.21.0")]
|
[assembly: AssemblyFileVersion("0.7.22.0")]
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]
|
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]
|
||||||
|
@ -63,6 +63,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
{
|
{
|
||||||
backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain<SharpDX.Direct3D11.Texture2D>(swapChain, 0);
|
backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain<SharpDX.Direct3D11.Texture2D>(swapChain, 0);
|
||||||
renderView = new RenderTargetView(nativeDevice.Device, backBuffer);
|
renderView = new RenderTargetView(nativeDevice.Device, backBuffer);
|
||||||
|
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -117,6 +118,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
this.depthStencilBuffer = new SharpDX.Direct3D11.Texture2D(nativeDevice.Device, depthStencilTextureDesc);
|
this.depthStencilBuffer = new SharpDX.Direct3D11.Texture2D(nativeDevice.Device, depthStencilTextureDesc);
|
||||||
|
|
||||||
this.depthStencilView = new DepthStencilView(nativeDevice.Device, this.depthStencilBuffer);
|
this.depthStencilView = new DepthStencilView(nativeDevice.Device, this.depthStencilBuffer);
|
||||||
|
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, ANX.Framework.Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472
|
Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, ANX.Framework.Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472
|
||||||
}
|
}
|
||||||
@ -210,7 +212,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
|
|
||||||
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
||||||
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
||||||
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
if (indexBuffer != null)
|
if (indexBuffer != null)
|
||||||
{
|
{
|
||||||
@ -240,7 +242,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
||||||
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
||||||
|
|
||||||
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
for (int i = 0; i < technique.Description.PassCount; ++i)
|
for (int i = 0; i < technique.Description.PassCount; ++i)
|
||||||
{
|
{
|
||||||
@ -261,7 +263,7 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
|
|
||||||
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
|
||||||
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
nativeDevice.Rasterizer.SetViewports(currentViewport);
|
||||||
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
|
||||||
|
|
||||||
if (indexBuffer != null)
|
if (indexBuffer != null)
|
||||||
{
|
{
|
||||||
|
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Buildnummer
|
// Buildnummer
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("0.7.13.*")]
|
[assembly: AssemblyVersion("0.7.14.*")]
|
||||||
[assembly: AssemblyFileVersion("0.7.13.0")]
|
[assembly: AssemblyFileVersion("0.7.14.0")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user