private void startQuery() { if (queryObject == -1) { queryObject = GL.GenQuery(); } GL.BeginQuery(QueryTarget.SamplesPassed, queryObject); }
private void PlatformBegin() { #if GLES GL.BeginQuery(QueryTarget.AnySamplesPassed, glQueryId); #else GL.BeginQuery(QueryTarget.SamplesPassed, glQueryId); #endif GraphicsExtensions.CheckGLError(); }
// ------------------------------------------------------- public void BeginBenchmark(BxCmUiParam param) { if (param.BenchmarkStarted == false) { return; } GL.GenQueries(1, out fBenchmarkID); GL.BeginQuery(QueryTarget.TimeElapsed, fBenchmarkID); }
public void Restart() { if (!_hasArbTimer) { _simpleWatch.Restart(); } else { GL.BeginQuery((QueryTarget)(0x88BF), _query); } }
public static void BeginQuery(QueryTarget target, int id) { if (RenderSettings.CoreQuerySupported) { GL.BeginQuery(target, id); } else { GL.Arb.BeginQuery((ArbOcclusionQuery)(int)target, id); } }
public virtual void Begin() { using (Context.Lock()) if (Indexed) { GL.BeginQueryIndexed(Target, Index, Id); } else { GL.BeginQuery(Target, Id); } }
public void Begin() { #if OPENGL #if GLES GL.BeginQuery(QueryTarget.AnySamplesPassed, glQueryId); #else GL.BeginQuery(QueryTarget.SamplesPassed, glQueryId); #endif GraphicsExtensions.CheckGLError(); #elif DIRECTX #endif }
public void Start() { if (tstamp_id == -1) { tstamp_id = GL.GenQuery(); } GL.QueryCounter(tstamp_id, QueryCounterTarget.Timestamp); if (id == -1) { id = GL.GenQuery(); } GL.BeginQuery((QueryTarget)queryType, id); }
public void Initialize() { for (int index = 0; index < _queryObjects.Length; index++) { int handle = GL.GenQuery(); _queryObjects[index] = handle; CounterType type = (CounterType)index; GL.BeginQuery(GetTarget(type), handle); } }
public override void Render(SSRenderConfig renderConfig) { if (Mesh != null) { GL.BeginQuery(QueryTarget.SamplesPassed, _gl_query_id); base.Render(renderConfig); GL.EndQuery(QueryTarget.SamplesPassed); GL.GetQueryObject(_gl_query_id, GetQueryObjectParam.QueryResult, out _result); } else { _result = 0; } }
private void UpdateAccumulatedCounter(CounterType type) { int handle = _queryObjects[(int)type]; QueryTarget target = GetTarget(type); GL.EndQuery(target); GL.GetQueryObject(handle, GetQueryObjectParam.QueryResult, out long result); _accumulatedCounters[(int)type] += (ulong)result; GL.BeginQuery(target, handle); }
public void Begin() { if (UseGPU) { if (activeTimer != null) { throw new System.Exception("!"); } activeTimer = this; if (RenderStack.Graphics.Configuration.canUseTimerQuery && (Configuration.AMDGPUPerf == false)) { //System.Console.WriteLine("GL.BeginQuery(QueryTarget.TimeElapsed, " + queryObjects[index] + ");"); GL.BeginQuery(QueryTarget.TimeElapsed, queryObjects[index]); active.Add(this); beginQuery[index] = true; usedGPUThisFrame = true; lastIndex = index; } } stopwatch.Start(); }
//------------------------------------------------------ // Timers //------------------------------------------------------ public static void time_function(string label, int timer, Action action) { int query = 0; GL.GenQueries(1, out query); GL.BeginQuery(QueryTarget.TimeElapsed, query); Stopwatch sw = Stopwatch.StartNew(); action(); sw.Stop(); GL.EndQuery(QueryTarget.TimeElapsed); float csharp_time = (float)sw.Elapsed.TotalMilliseconds; int opengl_time = 0; GL.GetQueryObject(query, GetQueryObjectParam.QueryResult, out opengl_time); float total_time = (opengl_time / 1000.0f / 1000.0f) + csharp_time; switch (timer) { case 1: _timer_1.time = total_time; _timer_1.name = label; break; case 2: _timer_2.time = total_time; _timer_2.name = label; break; case 3: _timer_3.time = total_time; _timer_3.name = label; break; } }
public void RunOcclusionQuery() { uint ready = 0; bool restart = false; if (QueryId != -1) { GL.GetQueryObject((uint)QueryId, GetQueryObjectParam.QueryResultAvailable, out ready); if (ready > 0) { GL.GetQueryObject((uint)QueryId, GetQueryObjectParam.QueryResult, out SamplesPassed); } //Console.WriteLine("ready " + ready); //Console.WriteLine("samples " + SamplesPassed); } if (QueryId == -1) { QueryId = GL.GenQuery(); restart = true; } if (ready > 0 || restart) { GL.BeginQuery(QueryTarget.SamplesPassed, QueryId); GL.DepthMask(false); GL.ColorMask(false, false, false, false); GL.Disable(EnableCap.CullFace); for (int i = 0; i < LodLevels.Count; i++) { LodLevels[i].DrawBoundingBoxes(this, Instances.Count); } GL.Enable(EnableCap.CullFace); GL.DepthMask(true); GL.ColorMask(true, true, true, true); GL.EndQuery(QueryTarget.SamplesPassed); } }
public override void Render(SSRenderConfig renderConfig) { if (Mesh != null) { base.Render(renderConfig); Matrix4 modelView = this.worldMat * renderConfig.invCameraViewMatrix; modelView = OpenTKHelper.BillboardMatrix(ref modelView); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelView); if (isOcclusionQueueryEnabled) { GL.BeginQuery(QueryTarget.SamplesPassed, GL_query_id); } Mesh.renderMesh(renderConfig); if (isOcclusionQueueryEnabled) { GL.EndQuery(QueryTarget.SamplesPassed); } } }
protected void DrawOcclusionBox(List <MeshRenderer> rds) { colorShader.UseShader(); AAnimator.BindIdentity(1); colorShader.SetParameter(colorShader.loc_color, new Color4(0.0f, 0.0f, 0.0f, 0.0f)); GL.Disable(EnableCap.CullFace); GL.DepthMask(false); foreach (var mr in rds) { var m = MatrixHelper.CreateTransform(mr.Mesh.Bounds.Center, Vector3.Zero, mr.Mesh.Bounds.Extents); m *= mr.GameObject.Transform.WorldTransform; m *= ViewProjection; colorShader.SetParameter(colorShader.loc_mvp, ref m, false); GL.BeginQuery(QueryTarget.SamplesPassed, mr.query); Drawer.DrawSubMesh(boundsMesh.subMeshes[0]); GL.EndQuery(QueryTarget.SamplesPassed); } GL.DepthMask(true); GL.Enable(EnableCap.CullFace); colorShader.UnuseShader(); }
public void begin() { GL.BeginQuery(_target, _index); }
private void PlatformBegin() { GL.BeginQuery(QueryTarget.SamplesPassed, glQueryId); GraphicsExtensions.CheckGLError(); }
public void Begin() { GL.BeginQuery(QueryTarget.SamplesPassed, this.glQueryId); }
/// <summary> /// Activates the specified target. /// </summary> /// <param name="target">The target.</param> public void Activate(QueryTarget target) { Target = target; GL.BeginQuery(target, id); }
public void Begin() { GL.BeginQuery(_type, Query); }
public void Reset() { GL.EndQuery(_type); GL.BeginQuery(_type, Query); }
private void RenderView(Matrix4 worldViewMatrix, Matrix4 projMatrix, RenderableMesh mesh, int occlusionQueryHandle) { // Setup VBO state GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.IndexArray); GL.Enable(EnableCap.StencilTest); GL.StencilFunc(StencilFunction.Always, 1, 1); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace); GL.PushAttrib(AttribMask.ViewportBit); GL.Viewport(0, 0, m_pixelWidth, m_pixelHeight); GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, m_fboHandle); // since there's only 1 Color buffer attached this is not explicitly required GL.DrawBuffer((DrawBufferMode)FramebufferAttachment.ColorAttachment0Ext); GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, m_colorTextureHandle, 0); GL.Ext.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt, FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt, m_renderbufferHandle); GL.Ext.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt, FramebufferAttachment.StencilAttachmentExt, RenderbufferTarget.RenderbufferExt, m_renderbufferHandle); GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); GL.PushMatrix(); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref worldViewMatrix); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projMatrix); GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.CullFace); var effect = new Material(); effect.ShaderHandle = 0; effect.ShowLines = false; GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); mesh.Render(effect); GL.PopMatrix(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // Render a quad with stencil test turned on, this will give me an accurate number of pixels rendered for // the object. GL.StencilFunc(StencilFunction.Equal, 1, 1); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); GL.Ortho(0, 1, 1, 0, -1, 1); GL.Disable(EnableCap.DepthTest); GL.BeginQuery(QueryTarget.SamplesPassed, occlusionQueryHandle); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); GL.Begin(BeginMode.Quads); GL.TexCoord2(0f, 1f); GL.Vertex2(0f, 0f); GL.TexCoord2(1f, 1f); GL.Vertex2(1f, 0f); GL.TexCoord2(1f, 0f); GL.Vertex2(1f, 1f); GL.TexCoord2(0f, 0f); GL.Vertex2(0f, 1f); GL.End(); GL.EndQuery(QueryTarget.SamplesPassed); GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.StencilTest); GL.PopAttrib(); }
private void PlatformBegin() { GL.BeginQuery(QueryTarget.SamplesPassed, _glQuery); GL.CheckError(); }