[opengtl-commits] [209] * implement pixelToMem (and watch it crash...

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 209
Author:   cyrille
Date:     2008-06-21 01:12:37 +0200 (Sat, 21 Jun 2008)

Log Message:
-----------
* implement pixelToMem (and watch it crash... :( )
* generate a full pixel structure in case that all channels are of the same type

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp	2008-06-20 22:55:45 UTC (rev 208)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp	2008-06-20 23:12:37 UTC (rev 209)
@@ -116,8 +116,13 @@
   return _currentBlock;
 }
 
-llvm::BasicBlock* CodeGenerator::pixelToMem( GTLCore::GenerationContext& /*_gc*/, llvm::BasicBlock* _currentBlock, llvm::Value* /*_pixel*/, llvm::Value* /*_dataPointer*/, int /*_size*/ )
+llvm::BasicBlock* CodeGenerator::pixelToMem( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _pixel, llvm::Value* _dataPointer, int _size )
 {
+  // Access to the data pointer for the _pixel
+  llvm::Value* _pointerToPixelVectorU8 = accessPixelData( _gc, _currentBlock, _pixel );
+  // Call llvm.memcpy.i32
+  callMemcpy( _gc, _currentBlock, _dataPointer, _pointerToPixelVectorU8,  GTLCore::CodeGenerator::integerToConstant( _size ) );
+
   return _currentBlock;
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp	2008-06-20 22:55:45 UTC (rev 208)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp	2008-06-20 23:12:37 UTC (rev 209)
@@ -68,13 +68,24 @@
 
 void Wrapper::createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, const GTLCore::PixelDescription& _pixelDescription)
 {
-  SHIVA_ASSERT(_pixelDescription.bitsSize() % 8 == 0);
-  std::vector<GTLCore::Type::StructDataMember> pixelDataMembers;
-  createPixelType(_module, _typeManager, "", pixelDataMembers, _pixelDescription.bitsSize() / 8 );
+  if( _pixelDescription.sameTypeChannels() )
+  {
+    createPixelType(_module, _typeManager, "", _pixelDescription.channels(), _pixelDescription.channelTypes()[0]);
+  } else {
+    SHIVA_ASSERT(_pixelDescription.bitsSize() % 8 == 0);
+    std::vector<GTLCore::Type::StructDataMember> pixelDataMembers;
+    createPixelType(_module, _typeManager, "", pixelDataMembers, _pixelDescription.bitsSize() / 8 );
+    SHIVA_ABORT("Unimplemented");
+  }
 }
 
 void Wrapper::createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, int _channels, const GTLCore::Type* _referenceDepth )
 {
+  createPixelType( _module, _typeManager, GTLCore::String::number( _channels ), _channels, _referenceDepth );
+}
+
+void Wrapper::createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, const GTLCore::String& _suffix, int _channels, const GTLCore::Type* _referenceDepth )
+{
   SHIVA_ASSERT(_referenceDepth->bitsSize() % 8 == 0);
   std::vector<GTLCore::Type::StructDataMember> pixelDataMembers;
   // Compute the size of the vector
@@ -85,7 +96,7 @@
   }
   pixelDataMembers.push_back( GTLCore::Type::StructDataMember( "data", _typeManager->getVector( _referenceDepth, _channels) ) );
   // Create the generic part of the pixel type
-  createPixelType(_module, _typeManager, GTLCore::String::number( _channels ), pixelDataMembers, _channels * _referenceDepth->bitsSize() / 8 );
+  createPixelType(_module, _typeManager, _suffix, pixelDataMembers, _channels * _referenceDepth->bitsSize() / 8 );
 }
 
 void Wrapper::createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, const GTLCore::String& _suffix, std::vector<GTLCore::Type::StructDataMember> _pixelDataMembers, int _pixelSize )

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h	2008-06-20 22:55:45 UTC (rev 208)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h	2008-06-20 23:12:37 UTC (rev 209)
@@ -54,6 +54,7 @@
       struct Private;
     private:
       static void createRegionType( llvm::Module* _module, GTLCore::TypeManager* _typeManager );
+      static void createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, const GTLCore::String& _suffix, int _channels, const GTLCore::Type* _referenceDepth );
       static void createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, int _channels, const GTLCore::Type* _referenceDepth );
       static void createPixelType( llvm::Module* _module, GTLCore::TypeManager* _typeManager, const GTLCore::PixelDescription& _pixelDescription);
       /**


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/