From 522c14df0a966ab5ceccf09cc60075f2de85d759 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Mon, 17 Jan 2022 19:13:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E2=80=9CTrackerEngi?= =?UTF-8?q?ne=E2=80=9D=E3=80=81=E2=80=9CRenderDevices=E2=80=9D=E3=80=81?= =?UTF-8?q?=E2=80=9CNative=E2=80=9D=E4=B8=89=E4=B8=AA=E7=B1=BB=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E2=80=9COpenCL=E2=80=9D=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ examples/print.php | 16 ++++------- src/scene/Native.php | 22 +++++++++++++++ src/scene/OpenCL.php | 56 +++++++++++++++++++++++++++---------- src/scene/RenderDevices.php | 46 ++++++++++++++++++++++++++++++ src/scene/TrackerEngine.php | 34 ++++++++++++++++++++++ 6 files changed, 152 insertions(+), 24 deletions(-) create mode 100644 src/scene/Native.php create mode 100644 src/scene/RenderDevices.php create mode 100644 src/scene/TrackerEngine.php diff --git a/.gitignore b/.gitignore index 80cb2c7..c268805 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ phpunit.phar /.vagrant vendor.zip /vagrant + +composer.lock diff --git a/examples/print.php b/examples/print.php index 91ea267..61d5100 100644 --- a/examples/print.php +++ b/examples/print.php @@ -4,18 +4,14 @@ namespace Blobt\Luxcore\scene; include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; +$temp = new Native(); -$opencl = new OpenCL(); -$opencl->useGpu(); +//$temp->usePidir(); -echo $opencl; +echo $temp; -$pathDepth = new PathDepth([ - "total" => 12 -]); -$depth = new Path([ - "pathdepth" => $pathDepth -]); -echo $depth; + + +?> diff --git a/src/scene/Native.php b/src/scene/Native.php new file mode 100644 index 0000000..a6e0727 --- /dev/null +++ b/src/scene/Native.php @@ -0,0 +1,22 @@ +threadsCount = $threadsCount; + } + +} diff --git a/src/scene/OpenCL.php b/src/scene/OpenCL.php index 3c945b6..f030d4f 100644 --- a/src/scene/OpenCL.php +++ b/src/scene/OpenCL.php @@ -2,36 +2,64 @@ namespace Blobt\Luxcore\scene; +use ParentIterator; + class OpenCL extends BaseCfg { - //打开或关闭 - const OPEN = 1; - const CLOSE = 0; - /** * @var integral 是否使用cpu渲染,默认是 */ - private $cpuUse = self::OPEN; + private static $cpuUse; /** * @var integral 是否使用gpu渲染,默认否 */ - private $gpuUse = self::CLOSE; + private static $gpuUse; + + /** + * @var string 在GPU渲染模式下,使用哪些GPU设备 + */ + public $devicesSelect = '10'; + + /** + * @var integer 在GPU渲染模式下,CPU是否渲染,并以多少线程渲染 + */ + private $nativeThreadsCount = 4; + + + + /** + * 以 RenderDevices类 的两个静态属性初始化变量 “$cpuUse”和“$gpuUse” + */ + public function __construct() + { + self::$cpuUse = RenderDevices::$cpuSwitch; + self::$gpuUse = RenderDevices::$gpuSwitch; + } + + public static function refreshConfig() + { + self::$cpuUse = RenderDevices::$cpuSwitch; + self::$gpuUse = RenderDevices::$gpuSwitch; + } /** - * 使用cpu渲染 + * 在GPU渲染模式下,设置使用哪些GPU设备 + * @var string $devicesSelect 传入一个控制使用哪些GPU设备的字符串 */ - public function useCpu(){ - $this->cpuUse = self::OPEN; - $this->gpuUse = self::CLOSE; + public function selectDevices($devicesSelect = '10') + { + $this->devicesSelect = $devicesSelect; } /** - * 使用gpu渲染 + * 在GPU渲染模式下,设置CPU是否渲染,并以多少线程渲染 + * @var integer $nativeThreadsCount 传入一个控制CPU是否渲染,并以多少线程渲染的整数 */ - public function useGpu(){ - $this->cpuUse = self::CLOSE; - $this->gpuUse = self::OPEN; + public function setNativeThreadsCount($nativeThreadsCount = 4) + { + $this->nativeThreadsCount = $nativeThreadsCount; } + } diff --git a/src/scene/RenderDevices.php b/src/scene/RenderDevices.php new file mode 100644 index 0000000..60d8659 --- /dev/null +++ b/src/scene/RenderDevices.php @@ -0,0 +1,46 @@ +