Merged in SL-16027_Tracy_OpenGL (pull request #697)

SL-16027: Add Tracy OpenGL support

Approved-by: Euclid Linden
Approved-by: Dave Parks
meow-7.2.2
Michael Pohoreski 2021-09-22 00:47:17 +00:00
commit b1c32db37f
10 changed files with 49 additions and 5 deletions

View File

@ -28,7 +28,7 @@
#define LL_LINDEN_COMMON_H
#include "llprofiler.h"
#if (TRACY_ENABLE) // hooks for memory profiling
#if TRACY_ENABLE && !defined(LL_PROFILER_ENABLE_TRACY_OPENGL) // hooks for memory profiling
void *tracy_aligned_malloc(size_t size, size_t alignment);
void tracy_aligned_free(void *memblock);
#define _aligned_malloc(X, Y) tracy_aligned_malloc((X), (Y))
@ -68,6 +68,4 @@ void tracy_aligned_free(void *memblock);
#include "llerror.h"
#include "llfile.h"
#include "llprofiler.h" // must be before fast timer; needed due to LLThreads potentially needing access to tracy
#endif

View File

@ -45,6 +45,9 @@
// #define TRACY_ONLY_LOCALHOST 1
#define TRACY_ONLY_IPV4 1
#include "Tracy.hpp"
// Mutually exclusive with detailed memory tracing
#define LL_PROFILER_ENABLE_TRACY_OPENGL 0
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY

View File

@ -812,4 +812,23 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
#endif
#if defined(TRACY_ENABLE) && LL_PROFILER_ENABLE_TRACY_OPENGL
// Tracy uses the following:
// glGenQueries
// glGetQueryiv
// glGetQueryObjectiv
#define glGenQueries glGenQueriesARB
#define glGetQueryiv glGetQueryivARB
#define glGetQueryObjectiv glGetQueryObjectivARB
#include <tracy/TracyOpenGL.hpp>
#define LL_PROFILER_GPU_ZONEC(name,color) TracyGpuZoneC(name,color);
#define LL_PROFILER_GPU_COLLECT TracyGpuCollect
#define LL_PROFILER_GPU_CONTEXT TracyGpuContext
#else
#define LL_PROFILER_GPU_ZONEC(name,color) (void)name;(void)color;
#define LL_PROFILER_GPU_COLLECT
#define LL_PROFILER_GPU_CONTEXT
#endif
#endif // LL_LLGLHEADERS_H

View File

@ -437,11 +437,13 @@ void LLRenderTarget::bindTarget()
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
GL_COLOR_ATTACHMENT3};
LL_PROFILER_GPU_ZONEC( "gl.DrawBuffersARB", 0x4000FF )
glDrawBuffersARB(mTex.size(), drawbuffers);
}
if (mTex.empty())
{ //no color buffer to draw to
LL_PROFILER_GPU_ZONEC( "gl.DrawBuffer", 0x0000FF )
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
}

View File

@ -615,6 +615,7 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con
glNormalPointer(GL_FLOAT, 0, norm[0].mV);
}
LLGLSLShader::startProfile();
LL_PROFILER_GPU_ZONEC( "gl.DrawArrays", 0xFF0000 )
glDrawArrays(sGLMode[mode], 0, count);
LLGLSLShader::stopProfile(count, mode);
}
@ -654,6 +655,7 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto
}
LLGLSLShader::startProfile();
LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0x80FF80 )
glDrawElements(sGLMode[mode], num_indices, GL_UNSIGNED_SHORT, indicesp);
LLGLSLShader::stopProfile(num_indices, mode);
}
@ -763,6 +765,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
stop_glerror();
LLGLSLShader::startProfile();
LL_PROFILER_GPU_ZONEC( "gl.DrawRangeElements", 0xFFFF00 )
glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT,
idx);
LLGLSLShader::stopProfile(count, mode);
@ -814,6 +817,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
stop_glerror();
LLGLSLShader::startProfile();
LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0xA0FFA0 )
glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT,
((U16*) getIndicesPointer()) + indices_offset);
LLGLSLShader::stopProfile(count, mode);
@ -861,6 +865,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
stop_glerror();
LLGLSLShader::startProfile();
stop_glerror();
LL_PROFILER_GPU_ZONEC( "gl.DrawArrays", 0xFF4040 )
glDrawArrays(sGLMode[mode], first, count);
stop_glerror();
LLGLSLShader::stopProfile(count, mode);

View File

@ -1748,6 +1748,8 @@ const S32 max_format = (S32)num_formats - 1;
return FALSE;
}
LL_PROFILER_GPU_CONTEXT
if (!gGLManager.initGL())
{
close();
@ -3474,6 +3476,8 @@ BOOL LLWindowWin32::resetDisplayResolution()
void LLWindowWin32::swapBuffers()
{
SwapBuffers(mhDC);
LL_PROFILER_GPU_COLLECT
}

View File

@ -323,6 +323,10 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
PWSTR pCmdLine,
int nCmdShow)
{
// Call Tracy first thing to have it allocate memory
// https://github.com/wolfpld/tracy/issues/196
LL_PROFILER_FRAME_END
const S32 MAX_HEAPS = 255;
DWORD heap_enable_lfh_error[MAX_HEAPS];
S32 num_heaps = 0;

View File

@ -585,6 +585,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)
glTexCoordPointer(2, GL_FLOAT, 8, vol_face.mTexCoords);
}
gGL.syncMatrices();
LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0x00FF00 );
glDrawElements(GL_TRIANGLES, vol_face.mNumIndices, GL_UNSIGNED_SHORT, vol_face.mIndices);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

View File

@ -2700,11 +2700,17 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
glVertexPointer(3, GL_FLOAT, 16, phys_volume->mHullPoints);
gGL.diffuseColor4fv(line_color.mV);
gGL.syncMatrices();
glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices);
{
LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0x20FF20 )
glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices);
}
gGL.diffuseColor4fv(color.mV);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices);
{
LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0x40FF40 )
glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices);
}
}
else
{
@ -3222,6 +3228,7 @@ void renderRaycast(LLDrawable* drawablep)
gGL.diffuseColor4f(0,1,1,0.5f);
glVertexPointer(3, GL_FLOAT, sizeof(LLVector4a), face.mPositions);
gGL.syncMatrices();
LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0x60FF60 );
glDrawElements(GL_TRIANGLES, face.mNumIndices, GL_UNSIGNED_SHORT, face.mIndices);
}

View File

@ -11146,6 +11146,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
if (LLPipeline::sRenderDeferred)
{
GLuint buff = GL_COLOR_ATTACHMENT0;
LL_PROFILER_GPU_ZONEC( "gl.DrawBuffersARB", 0x8000FF );
glDrawBuffersARB(1, &buff);
}