From 354cbbc92749b056e22ce3e8e4953799aebc0e78 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 31 Aug 2016 19:14:35 -0700 Subject: [PATCH] Investigate why the disable depth Bclamp doesn't work --- .../gpu-gl/src/gpu/gl/GLBackendQuery.cpp | 11 ++++++-- libraries/gpu-gl/src/gpu/gl/GLQuery.h | 1 + libraries/gpu/src/gpu/Query.cpp | 10 ++++--- libraries/gpu/src/gpu/Query.h | 9 +++++-- .../src/AmbientOcclusionEffect.cpp | 10 ++++--- .../render-utils/src/AmbientOcclusionEffect.h | 3 ++- .../src/DeferredLightingEffect.cpp | 21 +++++++++------ .../render-utils/src/DeferredLightingEffect.h | 2 +- .../render-utils/src/RenderDeferredTask.cpp | 14 +++++----- .../render-utils/src/RenderDeferredTask.h | 6 ++--- .../render-utils/src/SurfaceGeometryPass.cpp | 26 ++++++++++++------- .../render-utils/src/SurfaceGeometryPass.h | 4 +-- libraries/render-utils/src/spot_light.slf | 9 +++++-- libraries/shared/src/shared/NsightHelpers.cpp | 22 ++++++++++++++-- libraries/shared/src/shared/NsightHelpers.h | 12 +++++++++ tests/render-perf/src/main.cpp | 2 +- 16 files changed, 115 insertions(+), 47 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp index 19d008da2c..5fd1c4c6a3 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp @@ -25,7 +25,10 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) { auto query = batch._queries.get(batch._params[paramOffset]._uint); GLQuery* glquery = syncGPUObject(*query); if (glquery) { - glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime); + PROFILE_RANGE_BEGIN(glquery->_profileRangeId, query->getName().c_str(), 0xFFFF7F00); + + //glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime); + glquery->_batchElapsedTime = usecTimestampNow() * 1000; if (timeElapsed) { glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo); } else { @@ -45,9 +48,13 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) { glQueryCounter(glquery->_endqo, GL_TIMESTAMP); } GLint64 now; - glGetInteger64v(GL_TIMESTAMP, &now); + //glGetInteger64v(GL_TIMESTAMP, &now); + now = usecTimestampNow() * 1000; + glquery->_batchElapsedTime = now - glquery->_batchElapsedTime; + PROFILE_RANGE_END(glquery->_profileRangeId); + (void)CHECK_GL_ERROR(); } } diff --git a/libraries/gpu-gl/src/gpu/gl/GLQuery.h b/libraries/gpu-gl/src/gpu/gl/GLQuery.h index bf10d002e6..1189891967 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLQuery.h +++ b/libraries/gpu-gl/src/gpu/gl/GLQuery.h @@ -49,6 +49,7 @@ public: const GLuint _beginqo = { 0 }; GLuint64 _result { (GLuint64)-1 }; GLuint64 _batchElapsedTime { (GLuint64) 0 }; + uint64_t _profileRangeId { 0 }; protected: GLQuery(const std::weak_ptr& backend, const Query& query, GLuint endId, GLuint beginId) : Parent(backend, query, endId), _beginqo(beginId) {} diff --git a/libraries/gpu/src/gpu/Query.cpp b/libraries/gpu/src/gpu/Query.cpp index 1056193215..38a9d6db8c 100644 --- a/libraries/gpu/src/gpu/Query.cpp +++ b/libraries/gpu/src/gpu/Query.cpp @@ -15,8 +15,9 @@ using namespace gpu; -Query::Query(const Handler& returnHandler) : - _returnHandler(returnHandler) +Query::Query(const Handler& returnHandler, const std::string& name) : + _returnHandler(returnHandler), + _name(name) { } @@ -41,14 +42,15 @@ void Query::triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime } -RangeTimer::RangeTimer() { +RangeTimer::RangeTimer(const std::string& name) : + _name(name) { for (int i = 0; i < QUERY_QUEUE_SIZE; i++) { _timerQueries.push_back(std::make_shared([&, i] (const Query& query) { _tailIndex ++; _movingAverageGPU.addSample(query.getGPUElapsedTime()); _movingAverageBatch.addSample(query.getBatchElapsedTime()); - })); + }, _name)); } } diff --git a/libraries/gpu/src/gpu/Query.h b/libraries/gpu/src/gpu/Query.h index 13b660fc2c..26553d67b3 100644 --- a/libraries/gpu/src/gpu/Query.h +++ b/libraries/gpu/src/gpu/Query.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "Format.h" @@ -27,18 +28,21 @@ namespace gpu { public: using Handler = std::function; - Query(const Handler& returnHandler); + Query(const Handler& returnHandler, const std::string& name = "gpu::query"); ~Query(); double getGPUElapsedTime() const; double getBatchElapsedTime() const; + const std::string& getName() const { return _name; } + // Only for gpu::Context const GPUObjectPointer gpuObject {}; void triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime); protected: Handler _returnHandler; + std::string _name; uint64_t _queryResult { 0 }; uint64_t _usecBatchElapsedTime { 0 }; }; @@ -52,7 +56,7 @@ namespace gpu { // The result is always a late average of the time spent for that same task a few cycles ago. class RangeTimer { public: - RangeTimer(); + RangeTimer(const std::string& name); void begin(gpu::Batch& batch); void end(gpu::Batch& batch); @@ -63,6 +67,7 @@ namespace gpu { static const int QUERY_QUEUE_SIZE { 4 }; + std::string _name; gpu::Queries _timerQueries; int _headIndex = -1; int _tailIndex = -1; diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp index 3bf887e1b6..61a8c1f994 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -351,6 +351,10 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext auto sourceViewport = args->_viewport; auto occlusionViewport = sourceViewport; + if (!_gpuTimer) { + _gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__); + } + if (!_framebuffer) { _framebuffer = std::make_shared(); } @@ -384,7 +388,7 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); - _gpuTimer.begin(batch); + _gpuTimer->begin(batch); batch.setViewportTransform(occlusionViewport); batch.setProjectionTransform(glm::mat4()); @@ -428,12 +432,12 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext batch.setResourceTexture(AmbientOcclusionEffect_LinearDepthMapSlot, nullptr); batch.setResourceTexture(AmbientOcclusionEffect_OcclusionMapSlot, nullptr); - _gpuTimer.end(batch); + _gpuTimer->end(batch); }); // Update the timer auto config = std::static_pointer_cast(renderContext->jobConfig); - config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); + config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.h b/libraries/render-utils/src/AmbientOcclusionEffect.h index 1a828cb2c0..80904c80a3 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.h +++ b/libraries/render-utils/src/AmbientOcclusionEffect.h @@ -12,6 +12,7 @@ #ifndef hifi_AmbientOcclusionEffect_h #define hifi_AmbientOcclusionEffect_h +#include #include #include "render/DrawTask.h" @@ -188,7 +189,7 @@ private: AmbientOcclusionFramebufferPointer _framebuffer; - gpu::RangeTimer _gpuTimer; + gpu::RangeTimerPointer _gpuTimer; friend class DebugAmbientOcclusion; }; diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index c158d6c180..0f09d7ee4f 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -219,8 +219,9 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo if (lightVolume) { state->setCullMode(gpu::State::CULL_BACK); - state->setDepthTest(true, false, gpu::LESS_EQUAL); + state->setDepthTest(true, true, gpu::LESS_EQUAL); + state->setDepthClampEnable(true); // TODO: We should use DepthClamp and avoid changing geometry for inside /outside cases // additive blending state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE); @@ -598,11 +599,11 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext, // TODO: We shouldn;t have to do that test and use a different volume geometry for when inside the vlight volume, // we should be able to draw thre same geometry use DepthClamp but for unknown reason it's s not working... - if (glm::distance(eyePoint, glm::vec3(light->getPosition())) < expandedRadius + nearRadius) { + /* if (glm::distance(eyePoint, glm::vec3(light->getPosition())) < expandedRadius + nearRadius) { sphereParam.w = 0.0f; batch._glUniform4fv(deferredLightingEffect->_pointLightLocations->sphereParam, 1, reinterpret_cast< const float* >(&sphereParam)); batch.draw(gpu::TRIANGLE_STRIP, 4); - } else { + } else*/ { sphereParam.w = 1.0f; batch._glUniform4fv(deferredLightingEffect->_pointLightLocations->sphereParam, 1, reinterpret_cast< const float* >(&sphereParam)); @@ -647,12 +648,12 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext, // TODO: We shouldn;t have to do that test and use a different volume geometry for when inside the vlight volume, // we should be able to draw thre same geometry use DepthClamp but for unknown reason it's s not working... const float OVER_CONSERVATIVE_SCALE = 1.1f; - if ((eyeHalfPlaneDistance > -nearRadius) && + /* if ((eyeHalfPlaneDistance > -nearRadius) && (glm::distance(eyePoint, glm::vec3(light->getPosition())) < (expandedRadius * OVER_CONSERVATIVE_SCALE) + nearRadius)) { coneParam.w = 0.0f; batch._glUniform4fv(deferredLightingEffect->_spotLightLocations->coneParam, 1, reinterpret_cast< const float* >(&coneParam)); batch.draw(gpu::TRIANGLE_STRIP, 4); - } else { + } else*/ { coneParam.w = 1.0f; batch._glUniform4fv(deferredLightingEffect->_spotLightLocations->coneParam, 1, reinterpret_cast< const float* >(&coneParam)); @@ -720,8 +721,12 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo auto subsurfaceScatteringResource = inputs.get5(); auto args = renderContext->args; + if (!_gpuTimer) { + _gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__); + } + gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { - _gpuTimer.begin(batch); + _gpuTimer->begin(batch); }); setupJob.run(sceneContext, renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource); @@ -731,9 +736,9 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo cleanupJob.run(sceneContext, renderContext); gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { - _gpuTimer.end(batch); + _gpuTimer->end(batch); }); auto config = std::static_pointer_cast(renderContext->jobConfig); - config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); + config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index e4f3f455fa..ff0db1330f 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -183,7 +183,7 @@ public: RenderDeferredCleanup cleanupJob; protected: - gpu::RangeTimer _gpuTimer; + gpu::RangeTimerPointer _gpuTimer; }; #endif // hifi_DeferredLightingEffect_h diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 1e63cba8da..32aa2b6e16 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -101,7 +101,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { const auto primaryFramebuffer = addJob("PreparePrimaryBuffer"); // const auto fullFrameRangeTimer = addJob("BeginRangeTimer"); - const auto opaqueRangeTimer = addJob("BeginOpaqueRangeTimer"); + const auto opaqueRangeTimer = addJob("BeginOpaqueRangeTimer", "DrawOpaques"); const auto prepareDeferredInputs = PrepareDeferred::Inputs(primaryFramebuffer, lightingModel).hasVarying(); const auto prepareDeferredOutputs = addJob("PrepareDeferred", prepareDeferredInputs); @@ -146,8 +146,8 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { addJob("DrawLight", lights); const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, - surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource).hasVarying(); - + surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource).hasVarying(); + // DeferredBuffer is complete, now let's shade it into the LightingBuffer addJob("RenderDeferred", deferredLightingInputs); @@ -159,7 +159,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).hasVarying(); addJob("DrawTransparentDeferred", transparentsInputs, shapePlumber); - const auto toneAndPostRangeTimer = addJob("BeginToneAndPostRangeTimer"); + const auto toneAndPostRangeTimer = addJob("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); // Lighting Buffer ready for tone mapping const auto toneMappingInputs = render::Varying(ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer)); @@ -174,9 +174,9 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { // Debugging stages { - // Debugging Deferred buffer job - const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer)); - addJob("DebugDeferredBuffer", debugFramebuffers); + // Debugging Deferred buffer job + const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer)); + addJob("DebugDeferredBuffer", debugFramebuffers); addJob("DebugScattering", deferredLightingInputs); diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index e379e42445..fb15e34569 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -21,7 +21,7 @@ class BeginGPURangeTimer { public: using JobModel = render::Job::ModelO; - BeginGPURangeTimer() : _gpuTimer(std::make_shared()) {} + BeginGPURangeTimer(const std::string& name) : _gpuTimer(std::make_shared(name)) {} void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer); @@ -146,7 +146,7 @@ public: void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Inputs& inputs); protected: - gpu::RangeTimer _gpuTimer; + gpu::RangeTimerPointer _gpuTimer; }; class DrawOverlay3DConfig : public render::Job::Config { @@ -205,7 +205,7 @@ public: using JobModel = Model; protected: - gpu::RangeTimer _gpuTimer; + gpu::RangeTimerPointer _gpuTimer; }; #endif // hifi_RenderDeferredTask_h diff --git a/libraries/render-utils/src/SurfaceGeometryPass.cpp b/libraries/render-utils/src/SurfaceGeometryPass.cpp index 1957f8456a..70ada8b4a0 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.cpp +++ b/libraries/render-utils/src/SurfaceGeometryPass.cpp @@ -61,9 +61,9 @@ void LinearDepthFramebuffer::updatePrimaryDepth(const gpu::TexturePointer& depth void LinearDepthFramebuffer::clear() { _linearDepthFramebuffer.reset(); _linearDepthTexture.reset(); - _downsampleFramebuffer.reset(); - _halfLinearDepthTexture.reset(); - _halfNormalTexture.reset(); + _downsampleFramebuffer.reset(); + _halfLinearDepthTexture.reset(); + _halfNormalTexture.reset(); } void LinearDepthFramebuffer::allocate() { @@ -142,6 +142,10 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const const auto frameTransform = inputs.get0(); const auto deferredFramebuffer = inputs.get1(); + if (!_gpuTimer) { + _gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__); + } + if (!_linearDepthFramebuffer) { _linearDepthFramebuffer = std::make_shared(); } @@ -171,7 +175,7 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const float clearLinearDepth = args->getViewFrustum().getFarClip() * 2.0f; gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { - _gpuTimer.begin(batch); + _gpuTimer->begin(batch); batch.enableStereo(false); batch.setViewportTransform(depthViewport); @@ -197,11 +201,11 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const batch.setPipeline(downsamplePipeline); batch.draw(gpu::TRIANGLE_STRIP, 4); - _gpuTimer.end(batch); + _gpuTimer->end(batch); }); auto config = std::static_pointer_cast(renderContext->jobConfig); - config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); + config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } @@ -406,6 +410,10 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c RenderArgs* args = renderContext->args; + if (!_gpuTimer) { + _gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__); + } + const auto frameTransform = inputs.get0(); const auto deferredFramebuffer = inputs.get1(); const auto linearDepthFramebuffer = inputs.get2(); @@ -458,7 +466,7 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { - _gpuTimer.begin(batch); + _gpuTimer->begin(batch); batch.enableStereo(false); batch.setProjectionTransform(glm::mat4()); @@ -519,12 +527,12 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c batch.setResourceTexture(BlurTask_DepthSlot, nullptr); batch.setUniformBuffer(BlurTask_ParamsSlot, nullptr); - _gpuTimer.end(batch); + _gpuTimer->end(batch); }); auto config = std::static_pointer_cast(renderContext->jobConfig); - config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); + config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } diff --git a/libraries/render-utils/src/SurfaceGeometryPass.h b/libraries/render-utils/src/SurfaceGeometryPass.h index 3bc6b45c7c..6d830f9a28 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.h +++ b/libraries/render-utils/src/SurfaceGeometryPass.h @@ -87,7 +87,7 @@ private: const gpu::PipelinePointer& getDownsamplePipeline(); gpu::PipelinePointer _downsamplePipeline; - gpu::RangeTimer _gpuTimer; + gpu::RangeTimerPointer _gpuTimer; }; @@ -202,7 +202,7 @@ private: render::BlurGaussianDepthAware _diffusePass; - gpu::RangeTimer _gpuTimer; + gpu::RangeTimerPointer _gpuTimer; }; #endif // hifi_SurfaceGeometryPass_h diff --git a/libraries/render-utils/src/spot_light.slf b/libraries/render-utils/src/spot_light.slf index 4d4ad71413..0aa56947f7 100644 --- a/libraries/render-utils/src/spot_light.slf +++ b/libraries/render-utils/src/spot_light.slf @@ -31,14 +31,14 @@ in vec4 _texCoord0; out vec4 _fragColor; void main(void) { - + _fragColor = vec4(1.0, 0.0, 0.0, 1.0);// + return; DeferredFrameTransform deferredTransform = getDeferredFrameTransform(); // Grab the fragment data from the uv vec2 texCoord = _texCoord0.st / _texCoord0.q; texCoord *= texcoordFrameTransform.zw; texCoord += texcoordFrameTransform.xy; - DeferredFragment frag = unpackDeferredFragment(deferredTransform, texCoord); if (frag.mode == FRAG_MODE_UNLIT) { @@ -66,6 +66,11 @@ void main(void) { discard; } + + + + + // Frag to eye vec vec4 fragEyeVector = invViewMat * vec4(-frag.position.xyz, 0.0); vec3 fragEyeDir = normalize(fragEyeVector.xyz); diff --git a/libraries/shared/src/shared/NsightHelpers.cpp b/libraries/shared/src/shared/NsightHelpers.cpp index 9720edd820..fa853029be 100644 --- a/libraries/shared/src/shared/NsightHelpers.cpp +++ b/libraries/shared/src/shared/NsightHelpers.cpp @@ -21,8 +21,26 @@ bool nsightActive() { return nsightLaunched; } + +uint64_t ProfileRange::beginRange(const char* name, uint32_t argbColor) { + nvtxEventAttributes_t eventAttrib = { 0 }; + eventAttrib.version = NVTX_VERSION; + eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; + eventAttrib.colorType = NVTX_COLOR_ARGB; + eventAttrib.color = argbColor; + eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; + eventAttrib.message.ascii = name; + return nvtxRangeStartEx(&eventAttrib); + // return nvtxRangePushEx(&eventAttrib); +} + +void ProfileRange::endRange(uint64_t rangeId) { + nvtxRangeEnd(rangeId); + // nvtxRangePop(); +} + ProfileRange::ProfileRange(const char *name) { - //_rangeId = nvtxRangeStart(name); + // _rangeId = nvtxRangeStart(name); _rangeId = nvtxRangePush(name); } @@ -42,7 +60,7 @@ ProfileRange::ProfileRange(const char *name, uint32_t argbColor, uint64_t payloa } ProfileRange::~ProfileRange() { - // nvtxRangeEnd(_rangeId); + // nvtxRangeEnd(_rangeId); nvtxRangePop(); } diff --git a/libraries/shared/src/shared/NsightHelpers.h b/libraries/shared/src/shared/NsightHelpers.h index 94cb8d5263..294ffe0f7d 100644 --- a/libraries/shared/src/shared/NsightHelpers.h +++ b/libraries/shared/src/shared/NsightHelpers.h @@ -19,15 +19,27 @@ public: ProfileRange(const char *name); ProfileRange(const char *name, uint32_t argbColor, uint64_t payload); ~ProfileRange(); + + static uint64_t beginRange(const char* name, uint32_t argbColor); + static void endRange(uint64_t rangeId); private: uint64_t _rangeId{ 0 }; }; #define PROFILE_RANGE(name) ProfileRange profileRangeThis(name); #define PROFILE_RANGE_EX(name, argbColor, payload) ProfileRange profileRangeThis(name, argbColor, (uint64_t)payload); + +#define PROFILE_RANGE_BEGIN(rangeId, name, argbColor) rangeId = ProfileRange::beginRange(name, argbColor) +#define PROFILE_RANGE_END(rangeId) ProfileRange::endRange(rangeId) + #else #define PROFILE_RANGE(name) #define PROFILE_RANGE_EX(name, argbColor, payload) + + +#define PROFILE_RANGE_BEGIN(rangeId, name, argbColor) +#define PROFILE_RANGE_END(rangeId) + #endif #endif diff --git a/tests/render-perf/src/main.cpp b/tests/render-perf/src/main.cpp index c6cca74c69..030a39a1cd 100644 --- a/tests/render-perf/src/main.cpp +++ b/tests/render-perf/src/main.cpp @@ -526,7 +526,7 @@ public: _octree->init(); // Prevent web entities from rendering REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory); - REGISTER_ENTITY_TYPE_WITH_FACTORY(Light, LightEntityItem::factory); +// REGISTER_ENTITY_TYPE_WITH_FACTORY(Light, LightEntityItem::factory); DependencyManager::set(_octree->getTree()); getEntities()->setViewFrustum(_viewFrustum);