Upload property buffers when they change. 87/38887/1
authorFrancisco Santos <f1.santos@samsung.com>
Wed, 29 Apr 2015 12:57:39 +0000 (13:57 +0100)
committerFrancisco Santos <f1.santos@samsung.com>
Wed, 29 Apr 2015 12:57:39 +0000 (13:57 +0100)
Change-Id: Ibb2f030c6dd001d5b2db3c169e37ae08dd4376c3

dali/internal/render/renderers/render-geometry.cpp
dali/internal/render/renderers/render-renderer-property-buffer.cpp
dali/internal/update/common/scene-graph-property-buffer.cpp
dali/internal/update/common/scene-graph-property-buffer.h
dali/public-api/shader-effects/shader.h

index 4240094edb35776291191fa63e17b2dc89593152..59879797d312216934b74bde284b536bd3e3e23f 100644 (file)
@@ -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 );
   }
 }
 
index 415fdfbe955126851b5684ef85e18b96a3219e72..aae5f024b4c652497e28b0dcad4e45dad5e4430c 100644 (file)
  * limitations under the License.
  */
 
+// CLASS HEADERS
 #include <dali/internal/render/renderers/render-renderer-property-buffer.h>
 
+// INTERNAL INCLUDES
 #include <dali/internal/render/gl-resources/gpu-buffer.h>
 #include <dali/internal/render/shaders/program.h>
 
index b85feded1e838b7f6fc3fa0d9872c805f50de7b1..97bbd5192539ec2e9b2caac1f82d413aa4d1b06b 100644 (file)
@@ -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
index dfc817b7a0611c8b3ece3d44dfc6c6f659f775c4..b0c1dfb561ada52349cf591461c09f9edbb6f077 100644 (file)
@@ -184,6 +184,7 @@ private:
   OwnerPointer<PropertyBufferMetadata::Format> mFormat; ///< Format of the buffer
 
   DoubleBuffered< OwnerPointer<PropertyBufferDataProvider::BufferType> > mBufferData; ///< Data
+  DoubleBuffered< bool > mDataChanged; ///< Flag to know if data has changed in a frame
 
   DoubleBufferedProperty<unsigned int>  mSize; ///< Number of Elements in the buffer
 };
index 8908fefde4b72b16bc1c248159090b135ecbea41..08bf7f40cbbdc1c856526b1b0d28ce2f876f0293 100644 (file)
@@ -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
     };
   };