From fb363180c88cbd21b569b7fe8d5a202ce7cfa7db Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 19 Apr 2016 12:03:57 -0700 Subject: [PATCH] Starting to expose the number of changes to the input format --- examples/utilities/render/stats.qml | 5 ++++ libraries/gpu/src/gpu/GLBackendInput.cpp | 31 +++++++++++++++++---- libraries/render/src/render/EngineStats.cpp | 1 + libraries/render/src/render/EngineStats.h | 3 ++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/examples/utilities/render/stats.qml b/examples/utilities/render/stats.qml index 6bea341c98..f13282c93e 100644 --- a/examples/utilities/render/stats.qml +++ b/examples/utilities/render/stats.qml @@ -173,6 +173,11 @@ Item { prop: "frameSetPipelineCount", label: "Pipelines", color: "#E2334D" + }, + { + prop: "frameSetInputFormatCount", + label: "Input Formats", + color: "#1AC567" } ] } diff --git a/libraries/gpu/src/gpu/GLBackendInput.cpp b/libraries/gpu/src/gpu/GLBackendInput.cpp index 75f4be3cbe..09ed625ef6 100755 --- a/libraries/gpu/src/gpu/GLBackendInput.cpp +++ b/libraries/gpu/src/gpu/GLBackendInput.cpp @@ -12,12 +12,33 @@ using namespace gpu; + +GLBackend::GLInputFormat::GLInputFormat() { +} + +GLBackend::GLInputFormat:: ~GLInputFormat() { + +} + +GLBackend::GLInputFormat* GLBackend::syncGPUObject(const Stream::Format& inputFormat) { + GLInputFormat* object = Backend::getGPUObject(inputFormat); + + if (object) { + return object; + } + + object = new GLInputFormat(); + Backend::setGPUObject(inputFormat, object); +} + void GLBackend::do_setInputFormat(Batch& batch, size_t paramOffset) { Stream::FormatPointer format = batch._streamFormats.get(batch._params[paramOffset]._uint); - - if (format != _input._format) { - _input._format = format; - _input._invalidFormat = true; + GLInputFormat* ifo = GLBackend::syncGPUObject(*format); + if (ifo) { + if (format != _input._format) { + _input._format = format; + _input._invalidFormat = true; + } } } @@ -89,7 +110,7 @@ void GLBackend::syncInputStateCache() { // Core 41 doesn't expose the features to really separate the vertex format from the vertex buffers binding // Core 43 does :) // FIXME crashing problem with glVertexBindingDivisor / glVertexAttribFormat -#if 1 || (GPU_INPUT_PROFILE == GPU_CORE_41) +#if(GPU_INPUT_PROFILE == GPU_CORE_41) #define NO_SUPPORT_VERTEX_ATTRIB_FORMAT #else #define SUPPORT_VERTEX_ATTRIB_FORMAT diff --git a/libraries/render/src/render/EngineStats.cpp b/libraries/render/src/render/EngineStats.cpp index a17845134a..39792734ef 100644 --- a/libraries/render/src/render/EngineStats.cpp +++ b/libraries/render/src/render/EngineStats.cpp @@ -50,6 +50,7 @@ void EngineStats::run(const SceneContextPointer& sceneContext, const RenderConte config->frameTextureMemoryUsage = _gpuStats._RSAmountTextureMemoryBounded - gpuStats._RSAmountTextureMemoryBounded; config->frameSetPipelineCount = _gpuStats._PSNumSetPipelines - gpuStats._PSNumSetPipelines; + config->frameSetInputFormatCount = _gpuStats._ISNumFormatChanges - gpuStats._ISNumFormatChanges; config->emitDirty(); } diff --git a/libraries/render/src/render/EngineStats.h b/libraries/render/src/render/EngineStats.h index e777e60a4e..a5ebf88498 100644 --- a/libraries/render/src/render/EngineStats.h +++ b/libraries/render/src/render/EngineStats.h @@ -48,6 +48,7 @@ namespace render { Q_PROPERTY(quint32 frameTextureMemoryUsage MEMBER frameTextureMemoryUsage NOTIFY dirty) Q_PROPERTY(quint32 frameSetPipelineCount MEMBER frameSetPipelineCount NOTIFY dirty) + Q_PROPERTY(quint32 frameSetInputFormatCount MEMBER frameSetInputFormatCount NOTIFY dirty) public: @@ -78,6 +79,8 @@ namespace render { quint32 frameSetPipelineCount{ 0 }; + quint32 frameSetInputFormatCount{ 0 }; + void emitDirty() { emit dirty(); }