diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-05-18 19:16:10 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-05-27 13:07:15 +0300 |
commit | 7c0bea0d656eb4838ae2b5ebfed53cd1dae6cb12 (patch) | |
tree | a9b58585fc24289fd06c69e71ee5e36ad16dd3ac /intern/opensubdiv/internal/device | |
parent | e490dc4346dba5f29dada59ef421dfff499d65a9 (diff) |
OpenSubdiv: Refactor, move device specific code to own files
Also, move all device files to own folder.
Makes it so checks for device availability are done in a localized
place.
Diffstat (limited to 'intern/opensubdiv/internal/device')
10 files changed, 390 insertions, 0 deletions
diff --git a/intern/opensubdiv/internal/device/device_context_cuda.cc b/intern/opensubdiv/internal/device/device_context_cuda.cc new file mode 100644 index 00000000000..cd4336265a5 --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_cuda.cc @@ -0,0 +1,39 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/device/device_context_cuda.h" + +namespace blender { +namespace opensubdiv { + +bool CUDADeviceContext::isSupported() +{ + // TODO(sergey): Add CUDA device support, using CUDA-RT API. + return false; +} + +CUDADeviceContext::CUDADeviceContext() +{ +} + +CUDADeviceContext::~CUDADeviceContext() +{ +} + +} // namespace opensubdiv +} // namespace blender diff --git a/intern/opensubdiv/internal/device/device_context_cuda.h b/intern/opensubdiv/internal/device/device_context_cuda.h new file mode 100644 index 00000000000..d1bfb15fbcb --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_cuda.h @@ -0,0 +1,38 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_ + +namespace blender { +namespace opensubdiv { + +class CUDADeviceContext { + public: + // Stateless check to see whether CUDA functionality is available on this + // platform. + static bool isSupported(); + + CUDADeviceContext(); + ~CUDADeviceContext(); +}; + +} // namespace opensubdiv +} // namespace blender + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_ diff --git a/intern/opensubdiv/internal/device/device_context_glsl_compute.cc b/intern/opensubdiv/internal/device/device_context_glsl_compute.cc new file mode 100644 index 00000000000..7b416976099 --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_glsl_compute.cc @@ -0,0 +1,40 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/device/device_context_glsl_compute.h" + +#include <GL/glew.h> + +namespace blender { +namespace opensubdiv { + +bool GLSLComputeDeviceContext::isSupported() +{ + return GLEW_VERSION_4_3 || GLEW_ARB_compute_shader; +} + +GLSLComputeDeviceContext::GLSLComputeDeviceContext() +{ +} + +GLSLComputeDeviceContext::~GLSLComputeDeviceContext() +{ +} + +} // namespace opensubdiv +} // namespace blender diff --git a/intern/opensubdiv/internal/device/device_context_glsl_compute.h b/intern/opensubdiv/internal/device/device_context_glsl_compute.h new file mode 100644 index 00000000000..f64c7d1954b --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_glsl_compute.h @@ -0,0 +1,38 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_GLSL_COMPUTE_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_GLSL_COMPUTE_H_ + +namespace blender { +namespace opensubdiv { + +class GLSLComputeDeviceContext { + public: + // Stateless check to see whether GLSL compute functionality is + // available on this platform. + static bool isSupported(); + + GLSLComputeDeviceContext(); + ~GLSLComputeDeviceContext(); +}; + +} // namespace opensubdiv +} // namespace blender + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_GLSL_COMPUTE_H_ diff --git a/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.cc b/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.cc new file mode 100644 index 00000000000..ef897608b6e --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.cc @@ -0,0 +1,40 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/device/device_context_glsl_transform_feedback.h" + +#include <GL/glew.h> + +namespace blender { +namespace opensubdiv { + +bool GLSLTransformFeedbackDeviceContext::isSupported() +{ + return GLEW_VERSION_4_1; +} + +GLSLTransformFeedbackDeviceContext::GLSLTransformFeedbackDeviceContext() +{ +} + +GLSLTransformFeedbackDeviceContext::~GLSLTransformFeedbackDeviceContext() +{ +} + +} // namespace opensubdiv +} // namespace blender diff --git a/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.h b/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.h new file mode 100644 index 00000000000..7bbbba1380f --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.h @@ -0,0 +1,38 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_GLSL_TRANSFORM_FEEDBACK_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_GLSL_TRANSFORM_FEEDBACK_H_ + +namespace blender { +namespace opensubdiv { + +class GLSLTransformFeedbackDeviceContext { + public: + // Stateless check to see whether GLSL transform feedback functionality is + // available on this platform. + static bool isSupported(); + + GLSLTransformFeedbackDeviceContext(); + ~GLSLTransformFeedbackDeviceContext(); +}; + +} // namespace opensubdiv +} // namespace blender + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_GLSL_TRANSFORM_FEEDBACK_H_ diff --git a/intern/opensubdiv/internal/device/device_context_opencl.cc b/intern/opensubdiv/internal/device/device_context_opencl.cc new file mode 100644 index 00000000000..1670ea3c9d0 --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_opencl.cc @@ -0,0 +1,39 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/device/device_context_opencl.h" + +namespace blender { +namespace opensubdiv { + +bool OpenCLDeviceContext::isSupported() +{ + // TODO(sergey): Add support of OpenCL devices. + return false; +} + +OpenCLDeviceContext::OpenCLDeviceContext() +{ +} + +OpenCLDeviceContext::~OpenCLDeviceContext() +{ +} + +} // namespace opensubdiv +} // namespace blender diff --git a/intern/opensubdiv/internal/device/device_context_opencl.h b/intern/opensubdiv/internal/device/device_context_opencl.h new file mode 100644 index 00000000000..57ec6ed3bb6 --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_opencl.h @@ -0,0 +1,38 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_ + +namespace blender { +namespace opensubdiv { + +class OpenCLDeviceContext { + public: + // Stateless check to see whether OpenCL functionality is available on this + // platform. + static bool isSupported(); + + OpenCLDeviceContext(); + ~OpenCLDeviceContext(); +}; + +} // namespace opensubdiv +} // namespace blender + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_ diff --git a/intern/opensubdiv/internal/device/device_context_openmp.cc b/intern/opensubdiv/internal/device/device_context_openmp.cc new file mode 100644 index 00000000000..e01312fefaf --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_openmp.cc @@ -0,0 +1,42 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/device/device_context_openmp.h" + +namespace blender { +namespace opensubdiv { + +bool OpenMPDeviceContext::isSupported() +{ +#ifdef OPENSUBDIV_HAS_OPENMP + return true; +#else + return false; +#endif +} + +OpenMPDeviceContext::OpenMPDeviceContext() +{ +} + +OpenMPDeviceContext::~OpenMPDeviceContext() +{ +} + +} // namespace opensubdiv +} // namespace blender diff --git a/intern/opensubdiv/internal/device/device_context_openmp.h b/intern/opensubdiv/internal/device/device_context_openmp.h new file mode 100644 index 00000000000..2bebbdf40bc --- /dev/null +++ b/intern/opensubdiv/internal/device/device_context_openmp.h @@ -0,0 +1,38 @@ +// Copyright 2020 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_OPENMP_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_OPENMP_H_ + +namespace blender { +namespace opensubdiv { + +class OpenMPDeviceContext { + public: + // Stateless check to see whether OpenMP functionality is available on this + // platform. + static bool isSupported(); + + OpenMPDeviceContext(); + ~OpenMPDeviceContext(); +}; + +} // namespace opensubdiv +} // namespace blender + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_OPENMP_H_ |