From 2d9c0aecc4e5f2a2de3d389d3968efbeb488d681 Mon Sep 17 00:00:00 2001 From: Francisco Santos Date: Wed, 29 Apr 2015 13:57:39 +0100 Subject: [PATCH] Upload property buffers when they change. Change-Id: Ibb2f030c6dd001d5b2db3c169e37ae08dd4376c3 --- dali/internal/render/renderers/render-geometry.cpp | 13 +++++++++---- .../renderers/render-renderer-property-buffer.cpp | 2 ++ .../update/common/scene-graph-property-buffer.cpp | 8 +++++--- .../update/common/scene-graph-property-buffer.h | 1 + dali/public-api/shader-effects/shader.h | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/dali/internal/render/renderers/render-geometry.cpp b/dali/internal/render/renderers/render-geometry.cpp index 4240094ed..59879797d 100644 --- a/dali/internal/render/renderers/render-geometry.cpp +++ b/dali/internal/render/renderers/render-geometry.cpp @@ -93,6 +93,15 @@ void RenderGeometry::UploadVertexData( mDataNeedsUploading = false; } + + for( unsigned int i = 0; i < mVertexBuffers.Count(); ++i ) + { + mVertexBuffers[i]->Upload( context, bufferIndex ); + } + if( mIndexBuffer ) + { + mIndexBuffer->Upload( context, bufferIndex ); + } } void RenderGeometry::DoUpload( @@ -114,8 +123,6 @@ void RenderGeometry::DoUpload( GpuBuffer::ARRAY_BUFFER, GpuBuffer::STATIC_DRAW ); // TODO: MESH_REWORK: change this for animated meshes - propertyBuffer->Upload( context, bufferIndex ); - mVertexBuffers.PushBack( propertyBuffer ); } @@ -127,8 +134,6 @@ void RenderGeometry::DoUpload( *indexBuffer, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW ); // TODO: MESH_REWORK: change this for animated meshes - - mIndexBuffer->Upload( context, bufferIndex ); } } diff --git a/dali/internal/render/renderers/render-renderer-property-buffer.cpp b/dali/internal/render/renderers/render-renderer-property-buffer.cpp index 415fdfbe9..aae5f024b 100644 --- a/dali/internal/render/renderers/render-renderer-property-buffer.cpp +++ b/dali/internal/render/renderers/render-renderer-property-buffer.cpp @@ -14,8 +14,10 @@ * limitations under the License. */ +// CLASS HEADERS #include +// INTERNAL INCLUDES #include #include diff --git a/dali/internal/update/common/scene-graph-property-buffer.cpp b/dali/internal/update/common/scene-graph-property-buffer.cpp index b85feded1..97bbd5192 100644 --- a/dali/internal/update/common/scene-graph-property-buffer.cpp +++ b/dali/internal/update/common/scene-graph-property-buffer.cpp @@ -64,6 +64,7 @@ void PropertyBuffer::SetSize( BufferIndex bufferIndex, unsigned int size ) void PropertyBuffer::SetData( BufferIndex bufferIndex, PropertyBufferDataProvider::BufferType* data ) { mBufferData[bufferIndex] = data; + mDataChanged[bufferIndex] = true; } void PropertyBuffer::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex ) @@ -76,9 +77,7 @@ void PropertyBuffer::DisconnectFromSceneGraph( SceneController& sceneController, bool PropertyBuffer::HasDataChanged( BufferIndex bufferIndex ) const { - //TODO: MESH_REWORK fix this - DALI_ASSERT_DEBUG(false && "FIX THIS"); - return true; + return mDataChanged[ bufferIndex ]; } unsigned int PropertyBuffer::GetAttributeCount( BufferIndex bufferIndex ) const @@ -160,6 +159,9 @@ void PropertyBuffer::ResetDefaultProperties( BufferIndex updateBufferIndex ) // Update double buffered value mBufferData.CopyPrevious(updateBufferIndex); + + // The flag should be reset each frame + mDataChanged[updateBufferIndex] = false; } } // namespace SceneGraph diff --git a/dali/internal/update/common/scene-graph-property-buffer.h b/dali/internal/update/common/scene-graph-property-buffer.h index dfc817b7a..b0c1dfb56 100644 --- a/dali/internal/update/common/scene-graph-property-buffer.h +++ b/dali/internal/update/common/scene-graph-property-buffer.h @@ -184,6 +184,7 @@ private: OwnerPointer mFormat; ///< Format of the buffer DoubleBuffered< OwnerPointer > mBufferData; ///< Data + DoubleBuffered< bool > mDataChanged; ///< Flag to know if data has changed in a frame DoubleBufferedProperty mSize; ///< Number of Elements in the buffer }; diff --git a/dali/public-api/shader-effects/shader.h b/dali/public-api/shader-effects/shader.h index 8908fefde..08bf7f40c 100644 --- a/dali/public-api/shader-effects/shader.h +++ b/dali/public-api/shader-effects/shader.h @@ -88,7 +88,7 @@ public: enum { PROGRAM = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "program", type MAP; {"vertex-prefix":"","fragment-prefix":"","vertex":"","fragment":""} - SHADER_HINTS, ///< name "shader-hints", type UNSIGNED_INTEGER; (bitfield) values from enum GeometryHints + SHADER_HINTS, ///< name "shader-hints", type UNSIGNED_INTEGER; (bitfield) values from enum Shader::Hints }; }; -- 2.34.1