Further work on the PsVita RenderSystem
This commit is contained in:
parent
9cfc4d256d
commit
5ad7547cbb
@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyTitle("ANX.PlatformSystem.PsVita")]
|
[assembly: AssemblyTitle("ANX.PlatformSystem.PsVita")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("ANX Developer Team")]
|
||||||
[assembly: AssemblyProduct("ANX.PlatformSystem.PsVita")]
|
[assembly: AssemblyProduct("ANX.PlatformSystem.PsVita")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2012")]
|
[assembly: AssemblyCopyright("Copyright © ANX Developer Team 2012")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -38,8 +38,17 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
<Compile Include="DatatypesMapping.cs" />
|
||||||
|
<Compile Include="PsVitaBlendState.cs" />
|
||||||
|
<Compile Include="PsVitaDepthStencilState.cs" />
|
||||||
|
<Compile Include="PsVitaEffect.cs" />
|
||||||
|
<Compile Include="PsVitaIndexBuffer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="PsVitaGraphicsDevice.cs" />
|
<Compile Include="PsVitaGraphicsDevice.cs" />
|
||||||
|
<Compile Include="PsVitaRasterizerState.cs" />
|
||||||
|
<Compile Include="PsVitaRenderTarget2D.cs" />
|
||||||
|
<Compile Include="PsVitaTexture2D.cs" />
|
||||||
|
<Compile Include="PsVitaSamplerState.cs" />
|
||||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||||
<Compile Include="PsVitaVertexBuffer.cs" />
|
<Compile Include="PsVitaVertexBuffer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -38,8 +38,17 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
<Compile Include="DatatypesMapping.cs" />
|
||||||
|
<Compile Include="PsVitaBlendState.cs" />
|
||||||
|
<Compile Include="PsVitaDepthStencilState.cs" />
|
||||||
|
<Compile Include="PsVitaEffect.cs" />
|
||||||
|
<Compile Include="PsVitaIndexBuffer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="PsVitaGraphicsDevice.cs" />
|
<Compile Include="PsVitaGraphicsDevice.cs" />
|
||||||
|
<Compile Include="PsVitaRasterizerState.cs" />
|
||||||
|
<Compile Include="PsVitaRenderTarget2D.cs" />
|
||||||
|
<Compile Include="PsVitaTexture2D.cs" />
|
||||||
|
<Compile Include="PsVitaSamplerState.cs" />
|
||||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||||
<Compile Include="PsVitaVertexBuffer.cs" />
|
<Compile Include="PsVitaVertexBuffer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -38,8 +38,17 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
<Compile Include="DatatypesMapping.cs" />
|
||||||
|
<Compile Include="PsVitaBlendState.cs" />
|
||||||
|
<Compile Include="PsVitaDepthStencilState.cs" />
|
||||||
|
<Compile Include="PsVitaEffect.cs" />
|
||||||
|
<Compile Include="PsVitaIndexBuffer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="PsVitaGraphicsDevice.cs" />
|
<Compile Include="PsVitaGraphicsDevice.cs" />
|
||||||
|
<Compile Include="PsVitaRasterizerState.cs" />
|
||||||
|
<Compile Include="PsVitaRenderTarget2D.cs" />
|
||||||
|
<Compile Include="PsVitaTexture2D.cs" />
|
||||||
|
<Compile Include="PsVitaSamplerState.cs" />
|
||||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||||
<Compile Include="PsVitaVertexBuffer.cs" />
|
<Compile Include="PsVitaVertexBuffer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -40,8 +40,17 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
<Compile Include="DatatypesMapping.cs" />
|
||||||
|
<Compile Include="PsVitaBlendState.cs" />
|
||||||
|
<Compile Include="PsVitaDepthStencilState.cs" />
|
||||||
|
<Compile Include="PsVitaEffect.cs" />
|
||||||
|
<Compile Include="PsVitaIndexBuffer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="PsVitaGraphicsDevice.cs" />
|
<Compile Include="PsVitaGraphicsDevice.cs" />
|
||||||
|
<Compile Include="PsVitaRasterizerState.cs" />
|
||||||
|
<Compile Include="PsVitaRenderTarget2D.cs" />
|
||||||
|
<Compile Include="PsVitaTexture2D.cs" />
|
||||||
|
<Compile Include="PsVitaSamplerState.cs" />
|
||||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||||
<Compile Include="PsVitaVertexBuffer.cs" />
|
<Compile Include="PsVitaVertexBuffer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -13,6 +13,7 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
{
|
{
|
||||||
public class Creator : IRenderSystemCreator
|
public class Creator : IRenderSystemCreator
|
||||||
{
|
{
|
||||||
|
#region Public
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -36,6 +37,7 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
return OSInformation.GetName() == PlatformName.PSVita;
|
return OSInformation.GetName() == PlatformName.PSVita;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region RegisterCreator
|
#region RegisterCreator
|
||||||
public void RegisterCreator(AddInSystemFactory factory)
|
public void RegisterCreator(AddInSystemFactory factory)
|
||||||
@ -44,73 +46,93 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IRenderSystemCreator Member
|
#region CreateGraphicsDevice
|
||||||
|
|
||||||
public INativeGraphicsDevice CreateGraphicsDevice(
|
public INativeGraphicsDevice CreateGraphicsDevice(
|
||||||
PresentationParameters presentationParameters)
|
PresentationParameters presentationParameters)
|
||||||
{
|
{
|
||||||
return new PsVitaGraphicsDevice(presentationParameters);
|
return new PsVitaGraphicsDevice(presentationParameters);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateIndexBuffer
|
||||||
|
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics,
|
||||||
|
IndexBuffer managedBuffer, IndexElementSize size, int indexCount,
|
||||||
|
BufferUsage usage)
|
||||||
|
{
|
||||||
|
return new PsVitaIndexBuffer(managedBuffer, size, indexCount, usage);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateVertexBuffer
|
||||||
|
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics,
|
||||||
|
VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration,
|
||||||
|
int vertexCount, BufferUsage usage)
|
||||||
|
{
|
||||||
|
return new PsVitaVertexBuffer(managedBuffer, vertexDeclaration,
|
||||||
|
vertexCount, usage);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateTexture
|
||||||
public INativeTexture2D CreateTexture(GraphicsDevice graphics,
|
public INativeTexture2D CreateTexture(GraphicsDevice graphics,
|
||||||
SurfaceFormat surfaceFormat, int width, int height, int mipCount)
|
SurfaceFormat surfaceFormat, int width, int height, int mipCount)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaTexture2D(surfaceFormat, width, height, mipCount);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateRenderTarget
|
||||||
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics,
|
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics,
|
||||||
int width, int height, bool mipMap, SurfaceFormat preferredFormat,
|
int width, int height, bool mipMap, SurfaceFormat preferredFormat,
|
||||||
DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
|
DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
|
||||||
RenderTargetUsage usage)
|
RenderTargetUsage usage)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaRenderTarget2D();
|
||||||
}
|
|
||||||
|
|
||||||
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics,
|
|
||||||
IndexBuffer managedBuffer, IndexElementSize size, int indexCount,
|
|
||||||
BufferUsage usage)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics,
|
|
||||||
VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration,
|
|
||||||
int vertexCount, BufferUsage usage)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateEffect
|
||||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||||
Stream byteCode)
|
Stream byteCode)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaEffect(managedEffect, byteCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||||
Stream vertexShaderByteCode, Stream pixelShaderByteCode)
|
Stream vertexShaderByteCode, Stream pixelShaderByteCode)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaEffect(managedEffect, vertexShaderByteCode,
|
||||||
|
pixelShaderByteCode);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateBlendState
|
||||||
public INativeBlendState CreateBlendState()
|
public INativeBlendState CreateBlendState()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaBlendState();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateRasterizerState
|
||||||
public INativeRasterizerState CreateRasterizerState()
|
public INativeRasterizerState CreateRasterizerState()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaRasterizerState();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateDepthStencilState
|
||||||
public INativeDepthStencilState CreateDepthStencilState()
|
public INativeDepthStencilState CreateDepthStencilState()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaDepthStencilState();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateSamplerState
|
||||||
public INativeSamplerState CreateSamplerState()
|
public INativeSamplerState CreateSamplerState()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new PsVitaSamplerState();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public byte[] GetShaderByteCode(PreDefinedShader type)
|
public byte[] GetShaderByteCode(PreDefinedShader type)
|
||||||
{
|
{
|
||||||
@ -121,7 +143,5 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
RenderSystems/ANX.RenderSystem.PsVita/DatatypesMapping.cs
Normal file
37
RenderSystems/ANX.RenderSystem.PsVita/DatatypesMapping.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using Sce.PlayStation.Core.Graphics;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
internal static class DatatypesMapping
|
||||||
|
{
|
||||||
|
#region SurfaceFormatToVitaPixelFormat
|
||||||
|
public static PixelFormat SurfaceFormatToVitaPixelFormat(SurfaceFormat format)
|
||||||
|
{
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case SurfaceFormat.Color:
|
||||||
|
return PixelFormat.Rgba;
|
||||||
|
|
||||||
|
case SurfaceFormat.Bgra4444:
|
||||||
|
return PixelFormat.Rgba4444;
|
||||||
|
|
||||||
|
case SurfaceFormat.Bgr565:
|
||||||
|
return PixelFormat.Rgb565;
|
||||||
|
|
||||||
|
case SurfaceFormat.Bgra5551:
|
||||||
|
return PixelFormat.Rgba5551;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Exception("Can't convert surface format '" + format +
|
||||||
|
"' to psvita pixel format!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
231
RenderSystems/ANX.RenderSystem.PsVita/PsVitaBlendState.cs
Normal file
231
RenderSystems/ANX.RenderSystem.PsVita/PsVitaBlendState.cs
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
using System;
|
||||||
|
using ANX.Framework;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
using SceGraphics = Sce.PlayStation.Core.Graphics;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaBlendState : INativeBlendState
|
||||||
|
{
|
||||||
|
#region Public
|
||||||
|
public bool IsBound
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlendFunction AlphaBlendFunction
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlendFunction ColorBlendFunction
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blend AlphaSourceBlend
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blend AlphaDestinationBlend
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blend ColorSourceBlend
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blend ColorDestinationBlend
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorWriteChannels ColorWriteChannels
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorWriteChannels ColorWriteChannels1
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorWriteChannels ColorWriteChannels2
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorWriteChannels ColorWriteChannels3
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color BlendFactor
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MultiSampleMask
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
internal PsVitaBlendState()
|
||||||
|
{
|
||||||
|
IsBound = false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Apply (TODO)
|
||||||
|
public void Apply(GraphicsDevice graphicsDevice)
|
||||||
|
{
|
||||||
|
IsBound = true;
|
||||||
|
|
||||||
|
var context = PsVitaGraphicsDevice.Current.NativeContext;
|
||||||
|
context.Enable(SceGraphics.EnableMode.Blend);
|
||||||
|
|
||||||
|
context.SetBlendFuncRgb(TranslateBlendFunction(ColorBlendFunction),
|
||||||
|
TranslateBlend(ColorSourceBlend), TranslateBlend(ColorDestinationBlend));
|
||||||
|
|
||||||
|
context.SetBlendFuncAlpha(TranslateBlendFunction(AlphaBlendFunction),
|
||||||
|
TranslateBlend(AlphaSourceBlend), TranslateBlend(AlphaDestinationBlend));
|
||||||
|
|
||||||
|
SetColorWriteChannel(context, ColorWriteChannels);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
//SetColorWriteChannel(context, ColorWriteChannels1);
|
||||||
|
//SetColorWriteChannel(context, ColorWriteChannels2);
|
||||||
|
//SetColorWriteChannel(context, ColorWriteChannels3);
|
||||||
|
|
||||||
|
//GL.BlendColor(BlendFactor.R * DatatypesMapping.ColorMultiplier,
|
||||||
|
// BlendFactor.G * DatatypesMapping.ColorMultiplier,
|
||||||
|
// BlendFactor.B * DatatypesMapping.ColorMultiplier,
|
||||||
|
// BlendFactor.A * DatatypesMapping.ColorMultiplier);
|
||||||
|
//ErrorHelper.Check("BlendColor");
|
||||||
|
|
||||||
|
// TODO: multi sample mask
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Release
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
IsBound = false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SetColorWriteChannel
|
||||||
|
private void SetColorWriteChannel(SceGraphics.GraphicsContext context,
|
||||||
|
ColorWriteChannels channels)
|
||||||
|
{
|
||||||
|
var mask = SceGraphics.ColorMask.None;
|
||||||
|
if((channels & ColorWriteChannels.Red) != 0)
|
||||||
|
{
|
||||||
|
mask |= SceGraphics.ColorMask.R;
|
||||||
|
}
|
||||||
|
if((channels & ColorWriteChannels.Green) != 0)
|
||||||
|
{
|
||||||
|
mask |= SceGraphics.ColorMask.G;
|
||||||
|
}
|
||||||
|
if((channels & ColorWriteChannels.Blue) != 0)
|
||||||
|
{
|
||||||
|
mask |= SceGraphics.ColorMask.B;
|
||||||
|
}
|
||||||
|
if((channels & ColorWriteChannels.Alpha) != 0)
|
||||||
|
{
|
||||||
|
mask |= SceGraphics.ColorMask.A;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.SetColorMask(mask);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TranslateBlend
|
||||||
|
private SceGraphics.BlendFuncFactor TranslateBlend(Blend blending)
|
||||||
|
{
|
||||||
|
switch (blending)
|
||||||
|
{
|
||||||
|
case Blend.SourceAlpha:
|
||||||
|
return SceGraphics.BlendFuncFactor.SrcAlpha;
|
||||||
|
|
||||||
|
case Blend.DestinationAlpha:
|
||||||
|
return SceGraphics.BlendFuncFactor.DstAlpha;
|
||||||
|
|
||||||
|
case Blend.DestinationColor:
|
||||||
|
return SceGraphics.BlendFuncFactor.DstColor;
|
||||||
|
|
||||||
|
case Blend.InverseDestinationAlpha:
|
||||||
|
return SceGraphics.BlendFuncFactor.OneMinusDstAlpha;
|
||||||
|
|
||||||
|
case Blend.InverseDestinationColor:
|
||||||
|
return SceGraphics.BlendFuncFactor.OneMinusDstColor;
|
||||||
|
|
||||||
|
case Blend.InverseSourceAlpha:
|
||||||
|
return SceGraphics.BlendFuncFactor.OneMinusSrcAlpha;
|
||||||
|
|
||||||
|
case Blend.One:
|
||||||
|
return SceGraphics.BlendFuncFactor.One;
|
||||||
|
|
||||||
|
case Blend.SourceAlphaSaturation:
|
||||||
|
return SceGraphics.BlendFuncFactor.SrcAlphaSaturate;
|
||||||
|
|
||||||
|
case Blend.Zero:
|
||||||
|
return SceGraphics.BlendFuncFactor.Zero;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("Unable to translate SourceBlend '" +
|
||||||
|
blending + "' to PsVita BlendFuncFactor.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TranslateBlendFunction
|
||||||
|
private SceGraphics.BlendFuncMode TranslateBlendFunction(BlendFunction func)
|
||||||
|
{
|
||||||
|
switch (func)
|
||||||
|
{
|
||||||
|
case BlendFunction.Add:
|
||||||
|
return SceGraphics.BlendFuncMode.Add;
|
||||||
|
|
||||||
|
case BlendFunction.Subtract:
|
||||||
|
return SceGraphics.BlendFuncMode.Subtract;
|
||||||
|
|
||||||
|
case BlendFunction.ReverseSubtract:
|
||||||
|
return SceGraphics.BlendFuncMode.ReverseSubtract;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("Unable to translate BlendFunction '" +
|
||||||
|
func + "' to PsVita BlendFuncMode.");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
298
RenderSystems/ANX.RenderSystem.PsVita/PsVitaDepthStencilState.cs
Normal file
298
RenderSystems/ANX.RenderSystem.PsVita/PsVitaDepthStencilState.cs
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
using System;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
using SceGraphics = Sce.PlayStation.Core.Graphics;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaDepthStencilState : INativeDepthStencilState
|
||||||
|
{
|
||||||
|
#region Public
|
||||||
|
public bool IsBound
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DepthBufferEnable
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompareFunction DepthBufferFunction
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DepthBufferWriteEnable
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StencilEnable
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompareFunction StencilFunction
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int StencilMask
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StencilOperation StencilDepthBufferFail
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StencilOperation StencilFail
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StencilOperation StencilPass
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StencilOperation CounterClockwiseStencilDepthBufferFail
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StencilOperation CounterClockwiseStencilFail
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompareFunction CounterClockwiseStencilFunction
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StencilOperation CounterClockwiseStencilPass
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TwoSidedStencilMode
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReferenceStencil
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int StencilWriteMask
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
private get;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
internal PsVitaDepthStencilState()
|
||||||
|
{
|
||||||
|
IsBound = false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Apply
|
||||||
|
public void Apply(GraphicsDevice graphicsDevice)
|
||||||
|
{
|
||||||
|
IsBound = true;
|
||||||
|
var context = PsVitaGraphicsDevice.Current.NativeContext;
|
||||||
|
|
||||||
|
#region Depth
|
||||||
|
if (DepthBufferEnable)
|
||||||
|
{
|
||||||
|
context.Enable(SceGraphics.EnableMode.DepthTest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Disable(SceGraphics.EnableMode.DepthTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.SetDepthFunc(TranslateDepthFunction(DepthBufferFunction),
|
||||||
|
DepthBufferWriteEnable);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Stencil
|
||||||
|
if (StencilEnable)
|
||||||
|
{
|
||||||
|
context.Enable(SceGraphics.EnableMode.StencilTest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Disable(SceGraphics.EnableMode.StencilTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TwoSidedStencilMode)
|
||||||
|
{
|
||||||
|
context.SetStencilOpFront(TranslateStencilOp(StencilFail),
|
||||||
|
TranslateStencilOp(StencilDepthBufferFail),
|
||||||
|
TranslateStencilOp(StencilPass));
|
||||||
|
|
||||||
|
context.SetStencilOpBack(TranslateStencilOp(CounterClockwiseStencilFail),
|
||||||
|
TranslateStencilOp(CounterClockwiseStencilDepthBufferFail),
|
||||||
|
TranslateStencilOp(CounterClockwiseStencilPass));
|
||||||
|
|
||||||
|
context.SetStencilFuncFront(
|
||||||
|
TranslateStencilFunction(StencilFunction),
|
||||||
|
ReferenceStencil, StencilMask, StencilWriteMask);
|
||||||
|
|
||||||
|
context.SetStencilFuncBack(
|
||||||
|
TranslateStencilFunction(CounterClockwiseStencilFunction),
|
||||||
|
ReferenceStencil, StencilMask, StencilWriteMask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.SetStencilOp(TranslateStencilOp(StencilFail),
|
||||||
|
TranslateStencilOp(StencilDepthBufferFail),
|
||||||
|
TranslateStencilOp(StencilPass));
|
||||||
|
|
||||||
|
context.SetStencilFunc(TranslateStencilFunction(StencilFunction),
|
||||||
|
ReferenceStencil, StencilMask, StencilWriteMask);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TranslateStencilOp
|
||||||
|
private SceGraphics.StencilOpMode TranslateStencilOp(StencilOperation operation)
|
||||||
|
{
|
||||||
|
switch (operation)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case StencilOperation.Decrement:
|
||||||
|
return SceGraphics.StencilOpMode.Decr;
|
||||||
|
|
||||||
|
case StencilOperation.DecrementSaturation:
|
||||||
|
return SceGraphics.StencilOpMode.DecrWrap;
|
||||||
|
|
||||||
|
case StencilOperation.Increment:
|
||||||
|
return SceGraphics.StencilOpMode.Incr;
|
||||||
|
|
||||||
|
case StencilOperation.IncrementSaturation:
|
||||||
|
return SceGraphics.StencilOpMode.IncrWrap;
|
||||||
|
|
||||||
|
case StencilOperation.Invert:
|
||||||
|
return SceGraphics.StencilOpMode.Invert;
|
||||||
|
|
||||||
|
case StencilOperation.Keep:
|
||||||
|
return SceGraphics.StencilOpMode.Keep;
|
||||||
|
|
||||||
|
case StencilOperation.Replace:
|
||||||
|
return SceGraphics.StencilOpMode.Replace;
|
||||||
|
|
||||||
|
case StencilOperation.Zero:
|
||||||
|
return SceGraphics.StencilOpMode.Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TranslateDepthFunction
|
||||||
|
private SceGraphics.DepthFuncMode TranslateDepthFunction(CompareFunction func)
|
||||||
|
{
|
||||||
|
switch (func)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case CompareFunction.Always:
|
||||||
|
return SceGraphics.DepthFuncMode.Always;
|
||||||
|
|
||||||
|
case CompareFunction.Equal:
|
||||||
|
return SceGraphics.DepthFuncMode.Equal;
|
||||||
|
|
||||||
|
case CompareFunction.Greater:
|
||||||
|
return SceGraphics.DepthFuncMode.Greater;
|
||||||
|
|
||||||
|
case CompareFunction.GreaterEqual:
|
||||||
|
return SceGraphics.DepthFuncMode.GEqual;
|
||||||
|
|
||||||
|
case CompareFunction.Less:
|
||||||
|
return SceGraphics.DepthFuncMode.Less;
|
||||||
|
|
||||||
|
case CompareFunction.LessEqual:
|
||||||
|
return SceGraphics.DepthFuncMode.LEqual;
|
||||||
|
|
||||||
|
case CompareFunction.Never:
|
||||||
|
return SceGraphics.DepthFuncMode.Never;
|
||||||
|
|
||||||
|
case CompareFunction.NotEqual:
|
||||||
|
return SceGraphics.DepthFuncMode.NotEequal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TranslateStencilFunction
|
||||||
|
private SceGraphics.StencilFuncMode TranslateStencilFunction(CompareFunction func)
|
||||||
|
{
|
||||||
|
switch (func)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case CompareFunction.Always:
|
||||||
|
return SceGraphics.StencilFuncMode.Always;
|
||||||
|
|
||||||
|
case CompareFunction.Equal:
|
||||||
|
return SceGraphics.StencilFuncMode.Equal;
|
||||||
|
|
||||||
|
case CompareFunction.Greater:
|
||||||
|
return SceGraphics.StencilFuncMode.Greater;
|
||||||
|
|
||||||
|
case CompareFunction.GreaterEqual:
|
||||||
|
return SceGraphics.StencilFuncMode.GEqual;
|
||||||
|
|
||||||
|
case CompareFunction.Less:
|
||||||
|
return SceGraphics.StencilFuncMode.Less;
|
||||||
|
|
||||||
|
case CompareFunction.LessEqual:
|
||||||
|
return SceGraphics.StencilFuncMode.LEqual;
|
||||||
|
|
||||||
|
case CompareFunction.Never:
|
||||||
|
return SceGraphics.StencilFuncMode.Never;
|
||||||
|
|
||||||
|
case CompareFunction.NotEqual:
|
||||||
|
return SceGraphics.StencilFuncMode.NotEequal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Release
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
IsBound = false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
82
RenderSystems/ANX.RenderSystem.PsVita/PsVitaEffect.cs
Normal file
82
RenderSystems/ANX.RenderSystem.PsVita/PsVitaEffect.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
using Sce.PlayStation.Core.Graphics;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaEffect : INativeEffect
|
||||||
|
{
|
||||||
|
#region Private
|
||||||
|
private ShaderProgram nativeShader;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public
|
||||||
|
public IEnumerable<EffectTechnique> Techniques
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EffectParameter> Parameters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public PsVitaEffect(Effect managedEffect, Stream shaderByteStream)
|
||||||
|
{
|
||||||
|
int length = (int)(shaderByteStream.Length - shaderByteStream.Position);
|
||||||
|
byte[] shaderByteData = new byte[length];
|
||||||
|
shaderByteStream.Read(shaderByteData, 0, length);
|
||||||
|
nativeShader = new ShaderProgram(shaderByteData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PsVitaEffect(Effect managedEffect, Stream vertexShaderByteStream,
|
||||||
|
Stream pixelShaderByteStream)
|
||||||
|
{
|
||||||
|
int vertexBytesLength = (int)(vertexShaderByteStream.Length -
|
||||||
|
vertexShaderByteStream.Position);
|
||||||
|
byte[] vertexShaderByteData = new byte[vertexBytesLength];
|
||||||
|
vertexShaderByteStream.Read(vertexShaderByteData, 0, vertexBytesLength);
|
||||||
|
|
||||||
|
int fragmentBytesLength = (int)(pixelShaderByteStream.Length -
|
||||||
|
pixelShaderByteStream.Position);
|
||||||
|
byte[] fragmentShaderByteData = new byte[fragmentBytesLength];
|
||||||
|
pixelShaderByteStream.Read(fragmentShaderByteData, 0, fragmentBytesLength);
|
||||||
|
|
||||||
|
nativeShader = new ShaderProgram(vertexShaderByteData, fragmentShaderByteData);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Apply
|
||||||
|
public void Apply(GraphicsDevice graphicsDevice)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (nativeShader != null)
|
||||||
|
{
|
||||||
|
nativeShader.Dispose();
|
||||||
|
nativeShader = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -4,13 +4,28 @@ using ANX.Framework.Graphics;
|
|||||||
using ANX.Framework.NonXNA;
|
using ANX.Framework.NonXNA;
|
||||||
using Sce.PlayStation.Core.Graphics;
|
using Sce.PlayStation.Core.Graphics;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
namespace ANX.RenderSystem.PsVita
|
||||||
{
|
{
|
||||||
public class PsVitaGraphicsDevice : INativeGraphicsDevice
|
public class PsVitaGraphicsDevice : INativeGraphicsDevice
|
||||||
{
|
{
|
||||||
private GraphicsContext context;
|
internal static PsVitaGraphicsDevice Current
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
private uint? lastClearColor;
|
private uint? lastClearColor;
|
||||||
|
|
||||||
|
internal GraphicsContext NativeContext
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public bool VSync
|
public bool VSync
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -25,8 +40,9 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
|
|
||||||
public PsVitaGraphicsDevice(PresentationParameters presentationParameters)
|
public PsVitaGraphicsDevice(PresentationParameters presentationParameters)
|
||||||
{
|
{
|
||||||
|
Current = this;
|
||||||
// TODO
|
// TODO
|
||||||
context = new GraphicsContext(presentationParameters.BackBufferWidth,
|
NativeContext = new GraphicsContext(presentationParameters.BackBufferWidth,
|
||||||
presentationParameters.BackBufferHeight, PixelFormat.Rgba,
|
presentationParameters.BackBufferHeight, PixelFormat.Rgba,
|
||||||
PixelFormat.Depth24Stencil8, MultiSampleMode.None);
|
PixelFormat.Depth24Stencil8, MultiSampleMode.None);
|
||||||
}
|
}
|
||||||
@ -41,15 +57,15 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
lastClearColor != newClearColor)
|
lastClearColor != newClearColor)
|
||||||
{
|
{
|
||||||
lastClearColor = newClearColor;
|
lastClearColor = newClearColor;
|
||||||
context.SetClearColor(color.R, color.G, color.B, color.A);
|
NativeContext.SetClearColor(color.R, color.G, color.B, color.A);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Clear(ClearMask.Color | ClearMask.Depth);
|
NativeContext.Clear(ClearMask.Color | ClearMask.Depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
|
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
|
||||||
{
|
{
|
||||||
context.SetClearColor(color.X, color.Y, color.Z, color.W);
|
NativeContext.SetClearColor(color.X, color.Y, color.Z, color.W);
|
||||||
|
|
||||||
ClearMask mask = ClearMask.None;
|
ClearMask mask = ClearMask.None;
|
||||||
if ((options | ClearOptions.Target) == options)
|
if ((options | ClearOptions.Target) == options)
|
||||||
@ -65,16 +81,16 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
mask |= ClearMask.Depth;
|
mask |= ClearMask.Depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.SetClearDepth(depth);
|
NativeContext.SetClearDepth(depth);
|
||||||
context.SetClearStencil(stencil);
|
NativeContext.SetClearStencil(stencil);
|
||||||
context.Clear(mask);
|
NativeContext.Clear(mask);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Present
|
#region Present
|
||||||
public void Present()
|
public void Present()
|
||||||
{
|
{
|
||||||
context.SwapBuffers();
|
NativeContext.SwapBuffers();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -126,7 +142,7 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
#region SetViewport
|
#region SetViewport
|
||||||
public void SetViewport(Viewport viewport)
|
public void SetViewport(Viewport viewport)
|
||||||
{
|
{
|
||||||
context.SetViewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
|
NativeContext.SetViewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -161,8 +177,8 @@ namespace ANX.RenderSystem.PsVita
|
|||||||
#region Dispose
|
#region Dispose
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
context.Dispose();
|
NativeContext.Dispose();
|
||||||
context = null;
|
NativeContext = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
169
RenderSystems/ANX.RenderSystem.PsVita/PsVitaIndexBuffer.cs
Normal file
169
RenderSystems/ANX.RenderSystem.PsVita/PsVitaIndexBuffer.cs
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
using System;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA.RenderSystem;
|
||||||
|
using VitaIndexBuffer = Sce.PlayStation.Core.Graphics.VertexBuffer;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaIndexBuffer : INativeIndexBuffer
|
||||||
|
{
|
||||||
|
#region Private
|
||||||
|
private IndexBuffer managedBuffer;
|
||||||
|
private VitaIndexBuffer nativeBuffer;
|
||||||
|
|
||||||
|
private int indexCount;
|
||||||
|
|
||||||
|
internal IndexElementSize elementSize;
|
||||||
|
|
||||||
|
internal bool IsDisposed;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
internal PsVitaIndexBuffer(IndexBuffer setManagedBuffer,
|
||||||
|
IndexElementSize setElementSize, int setIndexCount, BufferUsage setUsage)
|
||||||
|
{
|
||||||
|
managedBuffer = setManagedBuffer;
|
||||||
|
indexCount = setIndexCount;
|
||||||
|
elementSize = setElementSize;
|
||||||
|
|
||||||
|
CreateBuffer();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateBuffer
|
||||||
|
private void CreateBuffer()
|
||||||
|
{
|
||||||
|
nativeBuffer = new VitaIndexBuffer(0, indexCount);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region RecreateData
|
||||||
|
internal void RecreateData()
|
||||||
|
{
|
||||||
|
CreateBuffer();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SetData
|
||||||
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data)
|
||||||
|
where T : struct
|
||||||
|
{
|
||||||
|
BufferData(data, 0);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SetData
|
||||||
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,
|
||||||
|
int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
if (startIndex != 0 ||
|
||||||
|
elementCount != data.Length)
|
||||||
|
{
|
||||||
|
T[] subArray = new T[elementCount];
|
||||||
|
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||||
|
BufferData(subArray, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BufferData(data, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SetData
|
||||||
|
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
||||||
|
T[] data, int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
if (startIndex != 0 ||
|
||||||
|
elementCount != data.Length)
|
||||||
|
{
|
||||||
|
T[] subArray = new T[elementCount];
|
||||||
|
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||||
|
BufferData(subArray, offsetInBytes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BufferData(data, offsetInBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region BufferData (private helper)
|
||||||
|
private void BufferData<T>(T[] data, int offset) where T : struct
|
||||||
|
{
|
||||||
|
if(data is uint == false &&
|
||||||
|
data is ushort == false)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"The index buffer data can only be uint or ushort!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data is ushort)
|
||||||
|
{
|
||||||
|
nativeBuffer.SetIndices(data as ushort[], offset, 0, data.Length);
|
||||||
|
}
|
||||||
|
else if (data is uint)
|
||||||
|
{
|
||||||
|
uint[] convertData = data as uint[];
|
||||||
|
ushort[] newIndices = new ushort[convertData.Length];
|
||||||
|
for (int index = 0; index < convertData.Length; index++)
|
||||||
|
{
|
||||||
|
newIndices[index] = (ushort)convertData[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeBuffer.SetIndices(newIndices, offset, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GetData
|
||||||
|
public void GetData<T>(T[] data) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GetData
|
||||||
|
public void GetData<T>(T[] data, int startIndex, int elementCount)
|
||||||
|
where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GetData
|
||||||
|
public void GetData<T>(int offsetInBytes, T[] data, int startIndex,
|
||||||
|
int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose the native index buffer data.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (IsDisposed == false)
|
||||||
|
{
|
||||||
|
IsDisposed = true;
|
||||||
|
DisposeResource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DisposeResource()
|
||||||
|
{
|
||||||
|
if (nativeBuffer != null)
|
||||||
|
{
|
||||||
|
nativeBuffer.Dispose();
|
||||||
|
nativeBuffer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaRasterizerState : INativeRasterizerState
|
||||||
|
{
|
||||||
|
#region INativeRasterizerState Member
|
||||||
|
|
||||||
|
public void Apply(Framework.Graphics.GraphicsDevice graphicsDevice)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsBound
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.CullMode CullMode
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public float DepthBias
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.FillMode FillMode
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MultiSampleAntiAlias
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ScissorTestEnable
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public float SlopeScaleDepthBias
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Member
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using ANX.Framework.NonXNA.RenderSystem;
|
||||||
|
using VitaRenderTarget = Sce.PlayStation.Core.Graphics.RenderTarget;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaRenderTarget2D : PsVitaTexture2D, INativeRenderTarget2D
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
public PsVitaRenderTarget2D()
|
||||||
|
: base(Framework.Graphics.SurfaceFormat.Color, 100, 100, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
RenderSystems/ANX.RenderSystem.PsVita/PsVitaSamplerState.cs
Normal file
75
RenderSystems/ANX.RenderSystem.PsVita/PsVitaSamplerState.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaSamplerState : INativeSamplerState
|
||||||
|
{
|
||||||
|
#region INativeSamplerState Member
|
||||||
|
|
||||||
|
public void Apply(Framework.Graphics.GraphicsDevice graphicsDevice, int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsBound
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.TextureAddressMode AddressU
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.TextureAddressMode AddressV
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.TextureAddressMode AddressW
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.TextureFilter Filter
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MaxAnisotropy
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MaxMipLevel
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public float MipMapLevelOfDetailBias
|
||||||
|
{
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Member
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
113
RenderSystems/ANX.RenderSystem.PsVita/PsVitaTexture2D.cs
Normal file
113
RenderSystems/ANX.RenderSystem.PsVita/PsVitaTexture2D.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using ANX.Framework;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA.RenderSystem;
|
||||||
|
using VitaTexture2D = Sce.PlayStation.Core.Graphics.Texture2D;
|
||||||
|
|
||||||
|
// 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.RenderSystem.PsVita
|
||||||
|
{
|
||||||
|
public class PsVitaTexture2D : INativeTexture2D
|
||||||
|
{
|
||||||
|
#region Private
|
||||||
|
private VitaTexture2D nativeTexture;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public PsVitaTexture2D(SurfaceFormat surfaceFormat, int width, int height,
|
||||||
|
int mipCount)
|
||||||
|
{
|
||||||
|
nativeTexture = new VitaTexture2D(width, height, mipCount > 0,
|
||||||
|
DatatypesMapping.SurfaceFormatToVitaPixelFormat(surfaceFormat));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SaveAsJpeg
|
||||||
|
public void SaveAsJpeg(Stream stream, int width, int height)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SaveAsPng
|
||||||
|
public void SaveAsPng(Stream stream, int width, int height)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GetData
|
||||||
|
public void GetData<T>(int level, Rectangle? rect, T[] data, int startIndex,
|
||||||
|
int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetData<T>(T[] data) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SetData
|
||||||
|
public void SetData<T>(int level, Framework.Rectangle? rect, T[] data,
|
||||||
|
int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
T[] subArray = new T[elementCount];
|
||||||
|
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||||
|
|
||||||
|
if(rect.HasValue)
|
||||||
|
{
|
||||||
|
nativeTexture.SetPixels(level, subArray, rect.Value.X, rect.Value.Y,
|
||||||
|
rect.Value.Width, rect.Value.Height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nativeTexture.SetPixels(level, subArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||||
|
{
|
||||||
|
nativeTexture.SetPixels(0, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,
|
||||||
|
int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
T[] subArray = new T[elementCount];
|
||||||
|
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||||
|
nativeTexture.SetPixels(0, subArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
||||||
|
T[] data, int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
T[] subArray = new T[elementCount];
|
||||||
|
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||||
|
// TODO: is 0 okay for pitch?
|
||||||
|
nativeTexture.SetPixels(0, subArray, offsetInBytes, 0);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
public virtual void Dispose()
|
||||||
|
{
|
||||||
|
if (nativeTexture != null)
|
||||||
|
{
|
||||||
|
nativeTexture.Dispose();
|
||||||
|
nativeTexture = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user