Added IOcclusionQuery interface and implemented the base OcclusionQuery class and the GL3 implementation.
This commit is contained in:
parent
32af20abf4
commit
28f3010330
@ -193,7 +193,7 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SoundSystems\WaveUtils\WaveUtils.csproj">
|
||||
<ProjectReference Include="..\SoundSystems\WaveUtils\WaveUtils_WindowsMetro.csproj">
|
||||
<Project>{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}</Project>
|
||||
<Name>WaveUtils</Name>
|
||||
</ProjectReference>
|
||||
|
@ -441,6 +441,7 @@
|
||||
<Compile Include="NonXNA\PlatformSystem\INativeMediaLibrary.cs" />
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -441,6 +441,7 @@
|
||||
<Compile Include="NonXNA\PlatformSystem\INativeMediaLibrary.cs" />
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -443,6 +443,7 @@
|
||||
<Compile Include="NonXNA\PlatformSystem\INativeMediaLibrary.cs" />
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -444,6 +444,7 @@
|
||||
<Compile Include="NonXNA\PlatformSystem\INativeMediaLibrary.cs" />
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -1,8 +1,7 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion // Using Statements
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -10,76 +9,92 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace ANX.Framework.Graphics
|
||||
{
|
||||
public class OcclusionQuery : GraphicsResource, IGraphicsResource
|
||||
{
|
||||
private bool hasBegun;
|
||||
private bool completeCallPending;
|
||||
public class OcclusionQuery : GraphicsResource, IGraphicsResource
|
||||
{
|
||||
#region Private
|
||||
private bool hasBegun;
|
||||
private bool completeCallPending;
|
||||
|
||||
public OcclusionQuery(GraphicsDevice graphicsDevice)
|
||||
: base(graphicsDevice)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
private IOcclusionQuery nativeQuery;
|
||||
#endregion
|
||||
|
||||
public void Begin()
|
||||
{
|
||||
if (this.hasBegun)
|
||||
{
|
||||
throw new InvalidOperationException("Begin cannot be called again until End is called.");
|
||||
}
|
||||
#region Public
|
||||
public bool IsComplete
|
||||
{
|
||||
get
|
||||
{
|
||||
return nativeQuery.IsComplete;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.completeCallPending)
|
||||
{
|
||||
throw new InvalidOperationException("Begin may not be called on this query object again before IsComplete is checked.");
|
||||
}
|
||||
public int PixelCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.completeCallPending)
|
||||
throw new InvalidOperationException("The status of the query data is unknown. Use the IsComplete " +
|
||||
"property to determine if the data is available before attempting to retrieve it.");
|
||||
|
||||
this.hasBegun = true;
|
||||
this.completeCallPending = true;
|
||||
return nativeQuery.PixelCount;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#region Constructor
|
||||
public OcclusionQuery(GraphicsDevice graphicsDevice)
|
||||
: base(graphicsDevice)
|
||||
{
|
||||
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||
nativeQuery = creator.CreateOcclusionQuery();
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
if (!this.hasBegun)
|
||||
{
|
||||
throw new InvalidOperationException("Begin must be called before End can be called.");
|
||||
}
|
||||
~OcclusionQuery()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#region Begin
|
||||
public void Begin()
|
||||
{
|
||||
if (hasBegun)
|
||||
throw new InvalidOperationException("Begin cannot be called again until End is called.");
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
if (completeCallPending)
|
||||
throw new InvalidOperationException("Begin may not be called on this query object again before IsComplete " +
|
||||
"is checked.");
|
||||
|
||||
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
hasBegun = true;
|
||||
completeCallPending = true;
|
||||
|
||||
public bool IsComplete
|
||||
{
|
||||
get
|
||||
{
|
||||
this.completeCallPending = false;
|
||||
nativeQuery.Begin();
|
||||
}
|
||||
#endregion
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
#region End
|
||||
public void End()
|
||||
{
|
||||
if (this.hasBegun == false)
|
||||
throw new InvalidOperationException("Begin must be called before End can be called.");
|
||||
|
||||
public int PixelCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.completeCallPending)
|
||||
{
|
||||
throw new InvalidOperationException("The status of the query data is unknown. Use the IsComplete property to determine if the data is available before attempting to retrieve it.");
|
||||
}
|
||||
nativeQuery.End();
|
||||
}
|
||||
#endregion
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Dispose
|
||||
public override void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
|
||||
{
|
||||
if (nativeQuery != null)
|
||||
{
|
||||
nativeQuery.Dispose();
|
||||
nativeQuery = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
17
ANX.Framework/NonXNA/RenderSystem/IOcclusionQuery.cs
Normal file
17
ANX.Framework/NonXNA/RenderSystem/IOcclusionQuery.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
// 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.NonXNA.RenderSystem
|
||||
{
|
||||
public interface IOcclusionQuery : IDisposable
|
||||
{
|
||||
bool IsComplete { get; }
|
||||
int PixelCount { get; }
|
||||
|
||||
void Begin();
|
||||
void End();
|
||||
}
|
||||
}
|
@ -11,33 +11,29 @@ namespace ANX.Framework.NonXNA
|
||||
{
|
||||
public interface IRenderSystemCreator : ICreator
|
||||
{
|
||||
INativeGraphicsDevice CreateGraphicsDevice(
|
||||
PresentationParameters presentationParameters);
|
||||
INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters);
|
||||
|
||||
INativeTexture2D CreateTexture(GraphicsDevice graphics,
|
||||
SurfaceFormat surfaceFormat, int width, int height, int mipCount);
|
||||
INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount);
|
||||
|
||||
INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics,
|
||||
int width, int height, bool mipMap, SurfaceFormat preferredFormat,
|
||||
DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
|
||||
INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap,
|
||||
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
|
||||
RenderTargetUsage usage);
|
||||
|
||||
INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics,
|
||||
IndexBuffer managedBuffer, IndexElementSize size, int indexCount,
|
||||
BufferUsage usage);
|
||||
INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size,
|
||||
int indexCount, BufferUsage usage);
|
||||
|
||||
INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics,
|
||||
VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration,
|
||||
int vertexCount, BufferUsage usage);
|
||||
INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer,
|
||||
VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage);
|
||||
|
||||
#if XNAEXT
|
||||
INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer, BufferUsage usage);
|
||||
#endif
|
||||
|
||||
INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||
Stream byteCode);
|
||||
INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||
Stream vertexShaderByteCode, Stream pixelShaderByteCode);
|
||||
INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode);
|
||||
INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode,
|
||||
Stream pixelShaderByteCode);
|
||||
|
||||
IOcclusionQuery CreateOcclusionQuery();
|
||||
|
||||
bool IsLanguageSupported(EffectSourceLanguage sourceLanguage);
|
||||
|
||||
|
@ -247,5 +247,12 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
return sourceLanguage == EffectSourceLanguage.HLSL_FX || sourceLanguage == EffectSourceLanguage.HLSL;
|
||||
}
|
||||
|
||||
#region CreateOcclusionQuery (TODO)
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
|
@ -56,6 +56,7 @@
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
|
@ -57,6 +57,7 @@
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
|
@ -58,6 +58,7 @@
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
|
@ -323,5 +323,12 @@ namespace ANX.RenderSystem.Windows.GL3
|
||||
return sourceLanguage == EffectSourceLanguage.GLSL_FX || sourceLanguage == EffectSourceLanguage.GLSL;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateOcclusionQuery
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
return new OcclusionQueryGL3();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
73
RenderSystems/ANX.Framework.Windows.GL3/OcclusionQueryGL3.cs
Normal file
73
RenderSystems/ANX.Framework.Windows.GL3/OcclusionQueryGL3.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// 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.Windows.GL3
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public class OcclusionQueryGL3 : IOcclusionQuery
|
||||
{
|
||||
private uint[] handle;
|
||||
|
||||
#region Public
|
||||
public bool IsComplete
|
||||
{
|
||||
get
|
||||
{
|
||||
int state;
|
||||
GL.GetQueryObject(handle[0], GetQueryObjectParam.QueryResultAvailable, out state);
|
||||
return state != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int PixelCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int result;
|
||||
GL.GetQueryObject(handle[0], GetQueryObjectParam.QueryResult, out result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public OcclusionQueryGL3()
|
||||
{
|
||||
handle = new uint[1];
|
||||
GL.GenQueries(1, handle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Begin
|
||||
public void Begin()
|
||||
{
|
||||
//GLCore.ColorMask(false, false, false, false);
|
||||
//GLCore.DepthMask(false);
|
||||
GL.BeginQuery(QueryTarget.SamplesPassed, handle[0]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region End
|
||||
public void End()
|
||||
{
|
||||
GL.EndQuery(QueryTarget.SamplesPassed);
|
||||
//GLCore.DepthMask(true);
|
||||
//GLCore.ColorMask(true, true, true, true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
GL.DeleteQueries(1, handle);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -160,5 +160,11 @@ namespace ANX.RenderSystem.PsVita
|
||||
return false;
|
||||
}
|
||||
|
||||
#region CreateOcclusionQuery (TODO)
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -243,5 +243,11 @@ namespace ANX.RenderSystem.Windows.DX11
|
||||
return sourceLanguage == EffectSourceLanguage.HLSL_FX || sourceLanguage == EffectSourceLanguage.HLSL;
|
||||
}
|
||||
|
||||
#region CreateOcclusionQuery (TODO)
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -262,5 +262,22 @@ namespace ANX.RenderSystem.Windows.Metro
|
||||
preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateOcclusionQuery (TODO)
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IRenderSystemCreator Member
|
||||
|
||||
|
||||
public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WaveUtils\WaveUtils.csproj">
|
||||
<ProjectReference Include="..\WaveUtils\WaveUtils_WindowsMetro.csproj">
|
||||
<Project>{1986B0ED-3D28-4FEE-82D0-BCC39C87C18C}</Project>
|
||||
<Name>WaveUtils</Name>
|
||||
</ProjectReference>
|
||||
|
Loading…
x
Reference in New Issue
Block a user