[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59396] branches/soc-2013-vse/source/ blender/sequencer: Updating Engine and Player.
Alexander Kuznetsov
kuzsasha at gmail.com
Fri Aug 23 07:04:08 CEST 2013
Revision: 59396
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59396
Author: alexk
Date: 2013-08-23 05:04:08 +0000 (Fri, 23 Aug 2013)
Log Message:
-----------
Updating Engine and Player. Extension of functionality and encapsulation. We now support only one engine and player. We can add multiple players for different scenes and time.
Modified Paths:
--------------
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.cpp
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.h
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.cpp
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.h
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.cpp
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.h
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqPlayer.cpp
branches/soc-2013-vse/source/blender/sequencer/sequencer_seqPlayer.h
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.cpp
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.cpp 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.cpp 2013-08-23 05:04:08 UTC (rev 59396)
@@ -9,8 +9,6 @@
cldm_p(NULL),
cl_this_context(0)
{
- refcount = 0;
- memset(programs, 0, sizeof(*programs));
}
@@ -25,7 +23,7 @@
cl_device_id *devices;
cldm_p = p;
- refcount = 0;
+ Retain();
num_devices = cldm_p->num_devices;
devices = new cl_device_id [num_devices];
@@ -48,8 +46,8 @@
for(j = 0; j < NUM_SEQ_VS_TYPES; j++)
{
- const char *cl_source[2] = {seq_vs_types[j], datatoc_kernel_main_cl};
- programs[j].cl_program_pointer = clCreateProgramWithSource(cl_this_context, 2, cl_source, 0, &err);
+ const char *cl_source[3] = {seq_vs_types[j], datatoc_common_stuctures_h, datatoc_kernel_main_cl};
+ programs[j].cl_program_pointer = clCreateProgramWithSource(cl_this_context, 3, cl_source, 0, &err);
if(err == CL_SUCCESS)
{
@@ -104,15 +102,8 @@
seqCLPlatform::~seqCLPlatform()
{
-
int j;
- if(refcount>0)
- {
- printf("Deleting platform with existing devices");
-
- }
-
for(j = 0; j < NUM_SEQ_VS_TYPES; j++)
{
if(programs[j].status &
@@ -124,8 +115,6 @@
}
-
-
clReleaseContext(cl_this_context);
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.h
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.h 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLPlatform.h 2013-08-23 05:04:08 UTC (rev 59396)
@@ -4,17 +4,21 @@
#include "sequencer_seqCLProgram.h"
#include "sequencer_include.h"
#include "CLDM_init.h"
+#include "sequencer_SimpleRef.h"
#define NUMOFELEM(a) (sizeof(a)/sizeof(*a))
extern char datatoc_kernel_main_cl[];
extern char datatoc_include_type_float_cl[];
+extern char datatoc_common_stuctures_h[];
extern char *seq_vs_types[];
#define NUM_SEQ_VS_TYPES (1)
-class seqCLPlatform
+seqCLPlatform *create_seqCLPlatform(seqEngine *engine, cldm_platform *p);
+
+class seqCLPlatform : public SimpleRef
{
public:
struct seqCLPlatform *next, *prev;
@@ -26,10 +30,8 @@
seqCLProgram programs [NUM_SEQ_VS_TYPES];
- int refcount;
-
seqCLPlatform(seqEngine *engine);
- ~seqCLPlatform();
+ virtual ~seqCLPlatform();
bool init(cldm_platform *p);
};
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.cpp
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.cpp 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.cpp 2013-08-23 05:04:08 UTC (rev 59396)
@@ -1 +1,3 @@
-
+#include "sequencer_seqCLPlatform.h"
+
+
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.h
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.h 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqCLProgram.h 2013-08-23 05:04:08 UTC (rev 59396)
@@ -10,15 +10,14 @@
#define SEQ_CL_KERNEL_STATUS_COMPILED (1<<0)
-typedef struct seqCLProgram
+class seqCLProgram
{
- cl_program cl_program_pointer;
- unsigned char status;
+ public:
+ cl_program cl_program_pointer;
+ unsigned char status;
+};
-} seqCLProgram;
-
-
#endif /* __SEQUENCER_SEQCLPLATFORM_H__ */
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.cpp
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.cpp 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.cpp 2013-08-23 05:04:08 UTC (rev 59396)
@@ -1 +1,180 @@
-
+#include "sequencer_seqEngine.h"
+
+#include "sequencer_seqBucket.h"
+#include "sequencer_seqCLPlatform.h"
+
+void seq_device_bucket_add(seqDevice *devg, seqBucket * bucket);
+
+void seqEngine::dispatch()
+{
+ /* make smarter one */
+
+ seqBucket *cb;
+
+ std::list<seqBucket*>::iterator icb;
+ std::list<seqBucket*>::iterator inb;
+
+
+ /* lock???? */
+
+ for(icb = list_buckets_todo.begin(); icb!= list_buckets_todo.end(); icb = inb)
+ {
+ inb = icb;
+ inb++;
+ cb = *icb;
+ list_buckets_todo.erase(icb);
+
+
+ uint device_mask = cb->get_implementation();
+
+ if(device_mask & SEQ_BUCKET_DEVT_GPU)
+ {
+ /* only one gpu for now */
+ devicelist.front()->add_bucket(cb);
+ }
+ else if(device_mask & SEQ_BUCKET_DEVT_CPU)
+ {
+ /*TODO: implement better smarter assigment */
+ seqDevice * dev;
+ if(rand()%2)
+ {
+ dev = devicelist.back();
+
+ } else
+ {
+ std::list<seqDevice*>::iterator it = devicelist.end();
+ it--;
+ dev = (*it);
+ }
+
+ dev->add_bucket(cb);
+ }
+ else
+ {
+ BLI_assert(0);
+ }
+
+
+ }
+}
+
+
+void seqEngine::add_buckets_list(std::vector<seqBucket *>&buckets)
+{
+ uint i = 0;
+
+ omutex.lock();
+
+
+ for(i = 0; i < buckets.size(); i++)
+ {
+
+
+ seqBucket *b = buckets[i];
+ list_buckets_todo.push_back(buckets[i]);
+ b++;
+ };
+
+ omutex.unlock();
+
+
+}
+
+extern seqPlayer mainplayseq;
+
+void seqEngine::start()
+{
+
+ seqDevice *dev;
+
+ if(this->init)
+ return;
+
+ add_Player(&mainplayseq);
+
+ //for()
+ {
+ dev = (seqDevice*)SEQ_create_device_cl(this, main_cl_device, 0);
+ dev->start();
+ devicelist.push_back(dev);
+ }
+
+ dev = new seqDeviceCPU(this);
+ dev->start();
+ devicelist.push_back(dev);
+
+ dev = new seqDeviceCPU(this);
+ dev->start();
+ devicelist.push_back(dev);
+
+ init = 1;
+}
+
+
+void seqEngine::terminate()
+{
+ if(!init)
+ return;
+
+
+ for(std::list<seqDevice*>::iterator it = devicelist.begin(); it != devicelist.end(); it++)
+ {
+ seqDevice *dev = *it;
+
+ dev->terminate();
+ delete dev;
+ }
+ devicelist.clear();
+
+ for(std::list<seqPlayer*>::iterator it = list_player.begin(); it != list_player.end(); it++)
+ {
+ seqPlayer *player = *it;
+ player->stop();
+ }
+ list_player.clear();
+
+ for(std::vector<seqCLPlatform*>::iterator it = clplatformlist.begin(); it !=clplatformlist.end(); it++)
+ {
+ seqCLPlatform *clplatform = *it;
+ clplatform->Release();
+
+ }
+ clplatformlist.clear();
+
+
+}
+
+
+seqCLPlatform *seqEngine::find_CLPlatform(cldm_platform *plat)
+{
+ seqCLPlatform *cp = NULL;
+
+ for(std::vector<seqCLPlatform*>::iterator icb = clplatformlist.begin();
+ icb != clplatformlist.end(); ++icb)
+ {
+ seqCLPlatform *clp = *icb;
+ if(clp->cldm_p == plat)
+ {
+ cp = clp;
+ break;
+ }
+ }
+
+ if(cp == NULL)
+ {
+ cp = new seqCLPlatform(this);
+
+ if(cp->init(plat))
+ {
+ clplatformlist.push_back(cp);
+ }
+ else
+ {
+ delete cp;
+ return NULL;
+ }
+ }
+
+ return cp;
+
+}
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.h
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.h 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqEngine.h 2013-08-23 05:04:08 UTC (rev 59396)
@@ -16,26 +16,29 @@
#include "sequencer_seqDevice.h"
#include "sequencer_include.h"
#include "sequencer_seqViewHandle.h"
+#include "sequencer_seqPlayer.h"
void seqRegisterEffects(void);
class seqEngine
{
+private:
+ std::list<seqBucket*> list_buckets_todo;
+ std::list<seqDevice*> devicelist;
+ // must be list as we use pointers,
+ //move to views to the player
+ std::list<seqViewHandle> list_views;
+ std::list<seqPlayer*> list_player;
+ std::vector<seqCLPlatform*> clplatformlist;
-public:
int init;
- std::list<seqDevice*> devicelist;
- std::vector<seqCLPlatform*> clplatformlist;
- std::list<seqBucket*> list_buckets_todo;
+public:
- // must be list as we use pointers
- std::list<seqViewHandle> list_views;
-
scond buckets_notification;
smutex omutex;
@@ -47,6 +50,17 @@
}
+ void dispatch();
+ void add_buckets_list(std::vector<seqBucket *>&buckets);
+
+ void add_Player(seqPlayer *player)
+ {
+ list_player.push_back(player);
+ }
+
+ void start();
+ void terminate();
+
seqViewHandle *view_add(seqViewHandle *n)
{
list_views.push_back(*n);
@@ -68,8 +82,10 @@
}
+ seqCLPlatform *find_CLPlatform(cldm_platform *plat);
+
void NotifyBucketChange()
{
buckets_notification.lock();
Modified: branches/soc-2013-vse/source/blender/sequencer/sequencer_seqPlayer.cpp
===================================================================
--- branches/soc-2013-vse/source/blender/sequencer/sequencer_seqPlayer.cpp 2013-08-23 04:22:07 UTC (rev 59395)
+++ branches/soc-2013-vse/source/blender/sequencer/sequencer_seqPlayer.cpp 2013-08-23 05:04:08 UTC (rev 59396)
@@ -1 +1,92 @@
-
+#include "sequencer_seqPlayer.h"
+#include "sequencer_seqFrame.h"
+#include "sequencer_seqEngine.h"
+
+seqFrame* seqPlayer::CreateNextFrame(Scene *scene, int nframe)
+{
+ seqFrame *newframe = new seqFrame(se, scene, nframe);
+ frames_list.push_back(newframe);
+ return newframe;
+}
+
+
+void seqPlayer::ManageFrames(Scene *scene, int cframe)
+{
+
+ int frame_have;
+ curframe = 0;
+
+ this->frame_current = cframe;
+ this->frame_last = this->frame_current+3; /* should be changenable */
+
+ for(std::list<seqFrame*>::iterator nt, it = this->frames_list.begin();
+ it!=this->frames_list.end(); it = nt)
+ {
+ seqFrame *selframe = *it;
+ nt =it;
+ nt++;
+
+ if(selframe->time < this->frame_current || selframe->time >= this->frame_last)
+ {
+
+ this->frames_list.erase(it);
+ selframe->mark_done();
+ selframe->Release();
+
+ } else
+ if(selframe->time == this->frame_current)
+ {
+ curframe = selframe;
+ }
+
+ }
+
+
+ if(curframe == NULL)
+ {
+ curframe = this->CreateNextFrame(scene, cframe);
+ }
+
+ frame_have = ((seqFrame *)this->frames_list.back())->time;
+
+ for(frame_have = this->frame_current; frame_have < this->frame_last; frame_have++)
+ {
+ seqFrame *sframe = NULL;
+ seqFrame *iframe;
+ for(std::list<seqFrame*>::iterator it = this->frames_list.begin();
+ it != this->frames_list.end(); it++)
+ {
+ iframe = *it;
+ if(iframe->time == frame_have)
+ {
+ sframe = iframe;
+ break;
+ }
+ }
+
+
+ if(sframe == NULL)
+ this->CreateNextFrame(scene, frame_have);
+
+
+ }
+
+ se->dispatch();
+
+}
+
+
+void seqPlayer::stop()
+{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list