diff options
author | Julian Eisel <julian@blender.org> | 2022-07-20 18:25:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-07-20 18:25:31 +0300 |
commit | 9dbcefb10e53cc809eb2e99333376b2a881c0863 (patch) | |
tree | 9ea058c2877c472aba82650e24e5927e3f03eded /intern/opensubdiv/internal | |
parent | e1ced645fa208b3b77e07c99cb289cf7fa659ad3 (diff) | |
parent | 85f0b2ef5d5bfb67c245da0a52aeec44e63445fa (diff) |
Merge branch 'asset-browser-grid-view' into file-browser-grid-view
Diffstat (limited to 'intern/opensubdiv/internal')
20 files changed, 57 insertions, 477 deletions
diff --git a/intern/opensubdiv/internal/base/opensubdiv_capi.cc b/intern/opensubdiv/internal/base/opensubdiv_capi.cc index 85f8120c76b..40d820836b9 100644 --- a/intern/opensubdiv/internal/base/opensubdiv_capi.cc +++ b/intern/opensubdiv/internal/base/opensubdiv_capi.cc @@ -21,55 +21,15 @@ #endif #include "internal/base/util.h" -#include "internal/device/device_context_cuda.h" -#include "internal/device/device_context_glsl_compute.h" -#include "internal/device/device_context_glsl_transform_feedback.h" -#include "internal/device/device_context_opencl.h" -#include "internal/device/device_context_openmp.h" - -using blender::opensubdiv::CUDADeviceContext; -using blender::opensubdiv::GLSLComputeDeviceContext; -using blender::opensubdiv::GLSLTransformFeedbackDeviceContext; -using blender::opensubdiv::OpenCLDeviceContext; -using blender::opensubdiv::OpenMPDeviceContext; void openSubdiv_init() { - // Ensure all OpenGL strings are cached. - openSubdiv_getAvailableEvaluators(); } void openSubdiv_cleanup() { } -int openSubdiv_getAvailableEvaluators() -{ - int flags = OPENSUBDIV_EVALUATOR_CPU; - - if (OpenMPDeviceContext::isSupported()) { - flags |= OPENSUBDIV_EVALUATOR_OPENMP; - } - - if (OpenCLDeviceContext::isSupported()) { - flags |= OPENSUBDIV_EVALUATOR_OPENCL; - } - - if (CUDADeviceContext::isSupported()) { - flags |= OPENSUBDIV_EVALUATOR_CUDA; - } - - if (GLSLTransformFeedbackDeviceContext::isSupported()) { - flags |= OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK; - } - - if (GLSLComputeDeviceContext::isSupported()) { - flags |= OPENSUBDIV_EVALUATOR_GLSL_COMPUTE; - } - - return flags; -} - int openSubdiv_getVersionHex() { #if defined(OPENSUBDIV_VERSION_NUMBER) diff --git a/intern/opensubdiv/internal/device/device_context_cuda.cc b/intern/opensubdiv/internal/device/device_context_cuda.cc deleted file mode 100644 index cd4336265a5..00000000000 --- a/intern/opensubdiv/internal/device/device_context_cuda.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 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 deleted file mode 100644 index d1bfb15fbcb..00000000000 --- a/intern/opensubdiv/internal/device/device_context_cuda.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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 deleted file mode 100644 index 7b416976099..00000000000 --- a/intern/opensubdiv/internal/device/device_context_glsl_compute.cc +++ /dev/null @@ -1,40 +0,0 @@ -// 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 deleted file mode 100644 index f64c7d1954b..00000000000 --- a/intern/opensubdiv/internal/device/device_context_glsl_compute.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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 deleted file mode 100644 index ef897608b6e..00000000000 --- a/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.cc +++ /dev/null @@ -1,40 +0,0 @@ -// 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 deleted file mode 100644 index 7bbbba1380f..00000000000 --- a/intern/opensubdiv/internal/device/device_context_glsl_transform_feedback.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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 deleted file mode 100644 index 1670ea3c9d0..00000000000 --- a/intern/opensubdiv/internal/device/device_context_opencl.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 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 deleted file mode 100644 index 57ec6ed3bb6..00000000000 --- a/intern/opensubdiv/internal/device/device_context_opencl.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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 deleted file mode 100644 index e01312fefaf..00000000000 --- a/intern/opensubdiv/internal/device/device_context_openmp.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 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 deleted file mode 100644 index 2bebbdf40bc..00000000000 --- a/intern/opensubdiv/internal/device/device_context_openmp.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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_ diff --git a/intern/opensubdiv/internal/evaluator/eval_output.h b/intern/opensubdiv/internal/evaluator/eval_output.h index c0da108edca..e8480e8d816 100644 --- a/intern/opensubdiv/internal/evaluator/eval_output.h +++ b/intern/opensubdiv/internal/evaluator/eval_output.h @@ -27,6 +27,8 @@ #include "internal/base/type.h" #include "internal/evaluator/evaluator_impl.h" +#include "opensubdiv_evaluator_capi.h" + using OpenSubdiv::Far::PatchTable; using OpenSubdiv::Far::StencilTable; using OpenSubdiv::Osd::BufferDescriptor; @@ -42,6 +44,8 @@ class EvalOutputAPI::EvalOutput { public: virtual ~EvalOutput() = default; + virtual void updateSettings(const OpenSubdiv_EvaluatorSettings *settings) = 0; + virtual void updateData(const float *src, int start_vertex, int num_vertices) = 0; virtual void updateVaryingData(const float *src, int start_vertex, int num_vertices) = 0; @@ -347,13 +351,13 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput { const StencilTable *varying_stencils, const vector<const StencilTable *> &all_face_varying_stencils, const int face_varying_width, - const int vertex_data_width, const PatchTable *patch_table, EvaluatorCache *evaluator_cache = NULL, DEVICE_CONTEXT *device_context = NULL) - : src_desc_(0, 3, 3), + : src_vertex_data_(NULL), + src_desc_(0, 3, 3), src_varying_desc_(0, 3, 3), - src_vertex_data_desc_(0, vertex_data_width, vertex_data_width), + src_vertex_data_desc_(0, 0, 0), face_varying_width_(face_varying_width), evaluator_cache_(evaluator_cache), device_context_(device_context) @@ -371,15 +375,6 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput { varying_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(varying_stencils, device_context_); - // Optionally allocate additional data to be subdivided like vertex coordinates. - if (vertex_data_width > 0) { - src_vertex_data_ = SRC_VERTEX_BUFFER::Create( - vertex_data_width, num_total_vertices, device_context_); - } - else { - src_vertex_data_ = NULL; - } - // Create evaluators for every face varying channel. face_varying_evaluators_.reserve(all_face_varying_stencils.size()); int face_varying_channel = 0; @@ -407,6 +402,23 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput { } } + void updateSettings(const OpenSubdiv_EvaluatorSettings *settings) override + { + // Optionally allocate additional data to be subdivided like vertex coordinates. + if (settings->num_vertex_data != src_vertex_data_desc_.length) { + delete src_vertex_data_; + if (settings->num_vertex_data > 0) { + src_vertex_data_ = SRC_VERTEX_BUFFER::Create( + settings->num_vertex_data, src_data_->GetNumVertices(), device_context_); + } + else { + src_vertex_data_ = NULL; + } + src_vertex_data_desc_ = BufferDescriptor( + 0, settings->num_vertex_data, settings->num_vertex_data); + } + } + // TODO(sergey): Implement binding API. void updateData(const float *src, int start_vertex, int num_vertices) override diff --git a/intern/opensubdiv/internal/evaluator/eval_output_cpu.h b/intern/opensubdiv/internal/evaluator/eval_output_cpu.h index 35fd03f6158..42aa052863a 100644 --- a/intern/opensubdiv/internal/evaluator/eval_output_cpu.h +++ b/intern/opensubdiv/internal/evaluator/eval_output_cpu.h @@ -44,7 +44,6 @@ class CpuEvalOutput : public VolatileEvalOutput<CpuVertexBuffer, const StencilTable *varying_stencils, const vector<const StencilTable *> &all_face_varying_stencils, const int face_varying_width, - const int vertex_data_width, const PatchTable *patch_table, EvaluatorCache *evaluator_cache = NULL) : VolatileEvalOutput<CpuVertexBuffer, @@ -55,7 +54,6 @@ class CpuEvalOutput : public VolatileEvalOutput<CpuVertexBuffer, varying_stencils, all_face_varying_stencils, face_varying_width, - vertex_data_width, patch_table, evaluator_cache) { diff --git a/intern/opensubdiv/internal/evaluator/eval_output_gpu.cc b/intern/opensubdiv/internal/evaluator/eval_output_gpu.cc index 274772b2c37..b85272008e6 100644 --- a/intern/opensubdiv/internal/evaluator/eval_output_gpu.cc +++ b/intern/opensubdiv/internal/evaluator/eval_output_gpu.cc @@ -45,7 +45,6 @@ GpuEvalOutput::GpuEvalOutput(const StencilTable *vertex_stencils, const StencilTable *varying_stencils, const vector<const StencilTable *> &all_face_varying_stencils, const int face_varying_width, - const int vertex_data_width, const PatchTable *patch_table, VolatileEvalOutput::EvaluatorCache *evaluator_cache) : VolatileEvalOutput<GLVertexBuffer, @@ -56,7 +55,6 @@ GpuEvalOutput::GpuEvalOutput(const StencilTable *vertex_stencils, varying_stencils, all_face_varying_stencils, face_varying_width, - vertex_data_width, patch_table, evaluator_cache) { diff --git a/intern/opensubdiv/internal/evaluator/eval_output_gpu.h b/intern/opensubdiv/internal/evaluator/eval_output_gpu.h index 8a4950dd3bc..e65bd51cac0 100644 --- a/intern/opensubdiv/internal/evaluator/eval_output_gpu.h +++ b/intern/opensubdiv/internal/evaluator/eval_output_gpu.h @@ -40,7 +40,6 @@ class GpuEvalOutput : public VolatileEvalOutput<GLVertexBuffer, const StencilTable *varying_stencils, const vector<const StencilTable *> &all_face_varying_stencils, const int face_varying_width, - const int vertex_data_width, const PatchTable *patch_table, EvaluatorCache *evaluator_cache = NULL); diff --git a/intern/opensubdiv/internal/evaluator/evaluator_cache_impl.cc b/intern/opensubdiv/internal/evaluator/evaluator_cache_impl.cc index 2fffcefa460..efac0926fef 100644 --- a/intern/opensubdiv/internal/evaluator/evaluator_cache_impl.cc +++ b/intern/opensubdiv/internal/evaluator/evaluator_cache_impl.cc @@ -30,7 +30,7 @@ OpenSubdiv_EvaluatorCacheImpl::~OpenSubdiv_EvaluatorCacheImpl() OpenSubdiv_EvaluatorCacheImpl *openSubdiv_createEvaluatorCacheInternal( eOpenSubdivEvaluator evaluator_type) { - if (evaluator_type != eOpenSubdivEvaluator::OPENSUBDIV_EVALUATOR_GLSL_COMPUTE) { + if (evaluator_type != eOpenSubdivEvaluator::OPENSUBDIV_EVALUATOR_GPU) { return nullptr; } OpenSubdiv_EvaluatorCacheImpl *evaluator_cache; diff --git a/intern/opensubdiv/internal/evaluator/evaluator_capi.cc b/intern/opensubdiv/internal/evaluator/evaluator_capi.cc index 5a3a2ff131c..7f30e0e5660 100644 --- a/intern/opensubdiv/internal/evaluator/evaluator_capi.cc +++ b/intern/opensubdiv/internal/evaluator/evaluator_capi.cc @@ -28,6 +28,12 @@ namespace { +void setSettings(struct OpenSubdiv_Evaluator *evaluator, + const OpenSubdiv_EvaluatorSettings *settings) +{ + evaluator->impl->eval_output->setSettings(settings); +} + void setCoarsePositions(OpenSubdiv_Evaluator *evaluator, const float *positions, const int start_vertex_index, @@ -233,6 +239,8 @@ bool hasVertexData(struct OpenSubdiv_Evaluator *evaluator) void assignFunctionPointers(OpenSubdiv_Evaluator *evaluator) { + evaluator->setSettings = setSettings; + evaluator->setCoarsePositions = setCoarsePositions; evaluator->setVertexData = setVertexData; evaluator->setVaryingData = setVaryingData; @@ -272,16 +280,12 @@ void assignFunctionPointers(OpenSubdiv_Evaluator *evaluator) OpenSubdiv_Evaluator *openSubdiv_createEvaluatorFromTopologyRefiner( OpenSubdiv_TopologyRefiner *topology_refiner, eOpenSubdivEvaluator evaluator_type, - OpenSubdiv_EvaluatorCache *evaluator_cache, - const OpenSubdiv_EvaluatorSettings *settings) + OpenSubdiv_EvaluatorCache *evaluator_cache) { OpenSubdiv_Evaluator *evaluator = MEM_new<OpenSubdiv_Evaluator>(__func__); assignFunctionPointers(evaluator); - evaluator->impl = openSubdiv_createEvaluatorInternal(topology_refiner, - evaluator_type, - evaluator_cache ? evaluator_cache->impl : - nullptr, - settings); + evaluator->impl = openSubdiv_createEvaluatorInternal( + topology_refiner, evaluator_type, evaluator_cache ? evaluator_cache->impl : nullptr); evaluator->type = evaluator->impl ? evaluator_type : static_cast<eOpenSubdivEvaluator>(0); return evaluator; } diff --git a/intern/opensubdiv/internal/evaluator/evaluator_impl.cc b/intern/opensubdiv/internal/evaluator/evaluator_impl.cc index a5273cad13a..262b418169d 100644 --- a/intern/opensubdiv/internal/evaluator/evaluator_impl.cc +++ b/intern/opensubdiv/internal/evaluator/evaluator_impl.cc @@ -166,6 +166,11 @@ EvalOutputAPI::~EvalOutputAPI() delete implementation_; } +void EvalOutputAPI::setSettings(const OpenSubdiv_EvaluatorSettings *settings) +{ + implementation_->updateSettings(settings); +} + void EvalOutputAPI::setCoarsePositions(const float *positions, const int start_vertex_index, const int num_vertices) @@ -435,14 +440,8 @@ OpenSubdiv_EvaluatorImpl::~OpenSubdiv_EvaluatorImpl() OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( OpenSubdiv_TopologyRefiner *topology_refiner, eOpenSubdivEvaluator evaluator_type, - OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr, - const OpenSubdiv_EvaluatorSettings *settings) + OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr) { - // Only CPU and GLCompute are implemented at the moment. - if (evaluator_type != OPENSUBDIV_EVALUATOR_CPU && - evaluator_type != OPENSUBDIV_EVALUATOR_GLSL_COMPUTE) { - return NULL; - } using blender::opensubdiv::vector; TopologyRefiner *refiner = topology_refiner->impl->topology_refiner; if (refiner == NULL) { @@ -455,7 +454,6 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( const bool has_face_varying_data = (num_face_varying_channels != 0); const int level = topology_refiner->getSubdivisionLevel(topology_refiner); const bool is_adaptive = topology_refiner->getIsAdaptive(topology_refiner); - const int vertex_data_width = settings->num_vertex_data; // Common settings for stencils and patches. const bool stencil_generate_intermediate_levels = is_adaptive; const bool stencil_generate_offsets = true; @@ -548,8 +546,8 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( // Create OpenSubdiv's CPU side evaluator. blender::opensubdiv::EvalOutputAPI::EvalOutput *eval_output = nullptr; - const bool use_gl_evaluator = evaluator_type == OPENSUBDIV_EVALUATOR_GLSL_COMPUTE; - if (use_gl_evaluator) { + const bool use_gpu_evaluator = evaluator_type == OPENSUBDIV_EVALUATOR_GPU; + if (use_gpu_evaluator) { blender::opensubdiv::GpuEvalOutput::EvaluatorCache *evaluator_cache = nullptr; if (evaluator_cache_descr) { evaluator_cache = static_cast<blender::opensubdiv::GpuEvalOutput::EvaluatorCache *>( @@ -560,17 +558,12 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( varying_stencils, all_face_varying_stencils, 2, - vertex_data_width, patch_table, evaluator_cache); } else { - eval_output = new blender::opensubdiv::CpuEvalOutput(vertex_stencils, - varying_stencils, - all_face_varying_stencils, - 2, - vertex_data_width, - patch_table); + eval_output = new blender::opensubdiv::CpuEvalOutput( + vertex_stencils, varying_stencils, all_face_varying_stencils, 2, patch_table); } blender::opensubdiv::PatchMap *patch_map = new blender::opensubdiv::PatchMap(*patch_table); @@ -581,7 +574,7 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( evaluator_descr->eval_output = new blender::opensubdiv::EvalOutputAPI(eval_output, patch_map); evaluator_descr->patch_map = patch_map; evaluator_descr->patch_table = patch_table; - // TOOD(sergey): Look into whether we've got duplicated stencils arrays. + // TODO(sergey): Look into whether we've got duplicated stencils arrays. delete vertex_stencils; delete varying_stencils; for (const StencilTable *table : all_face_varying_stencils) { diff --git a/intern/opensubdiv/internal/evaluator/evaluator_impl.h b/intern/opensubdiv/internal/evaluator/evaluator_impl.h index df8ef70cc01..a7e3d5dff59 100644 --- a/intern/opensubdiv/internal/evaluator/evaluator_impl.h +++ b/intern/opensubdiv/internal/evaluator/evaluator_impl.h @@ -57,6 +57,9 @@ class EvalOutputAPI { ~EvalOutputAPI(); + // Set settings for data buffers. + void setSettings(const OpenSubdiv_EvaluatorSettings *settings); + // Set coarse positions from a continuous array of coordinates. void setCoarsePositions(const float *positions, const int start_vertex_index, @@ -210,8 +213,7 @@ struct OpenSubdiv_EvaluatorImpl { OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( struct OpenSubdiv_TopologyRefiner *topology_refiner, eOpenSubdivEvaluator evaluator_type, - OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr, - const OpenSubdiv_EvaluatorSettings *settings); + OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr); void openSubdiv_deleteEvaluatorInternal(OpenSubdiv_EvaluatorImpl *evaluator); diff --git a/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc b/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc index acf628c7035..c2ab2a522d2 100644 --- a/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc +++ b/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc @@ -396,6 +396,8 @@ bool GLComputeEvaluator::EvalStencils(GLuint srcBuffer, if (dvvWeightsBuffer) glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 15, dvvWeightsBuffer); + GLint activeProgram; + glGetIntegerv(GL_CURRENT_PROGRAM, &activeProgram); glUseProgram(_stencilKernel.program); glUniform1i(_stencilKernel.uniformStart, start); @@ -420,7 +422,7 @@ bool GLComputeEvaluator::EvalStencils(GLuint srcBuffer, DispatchCompute(count); - glUseProgram(0); + glUseProgram(activeProgram); glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT); for (int i = 0; i < 16; ++i) { @@ -501,6 +503,8 @@ bool GLComputeEvaluator::EvalPatches(GLuint srcBuffer, glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, patchIndexBuffer); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, patchParamsBuffer); + GLint activeProgram; + glGetIntegerv(GL_CURRENT_PROGRAM, &activeProgram); glUseProgram(_patchKernel.program); glUniform1i(_patchKernel.uniformSrcOffset, srcDesc.offset); @@ -534,7 +538,7 @@ bool GLComputeEvaluator::EvalPatches(GLuint srcBuffer, DispatchCompute(numPatchCoords); - glUseProgram(0); + glUseProgram(activeProgram); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0); |