[Bf-blender-cvs] [2ad5131f77c] master: OpenSubdiv: Cleanyp, remove old GPU code

Sergey Sharybin noreply at git.blender.org
Mon May 18 17:16:06 CEST 2020


Commit: 2ad5131f77c76576cfb3def7218aa893d8783337
Author: Sergey Sharybin
Date:   Mon May 18 16:45:14 2020 +0200
Branches: master
https://developer.blender.org/rB2ad5131f77c76576cfb3def7218aa893d8783337

OpenSubdiv: Cleanyp, remove old GPU code

All parts of drawing (shaders, GL mesh descriptor, material partitioner
and so on) needs to be redone for the draw manager and new OpenSubdiv
library.

Removing untested code which is doomed to be replaced to make localized
refactoring easier.

===================================================================

M	intern/opensubdiv/CMakeLists.txt
M	intern/opensubdiv/internal/opensubdiv.cc
D	intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
D	intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
D	intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h
D	intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
D	intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
D	intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc
D	intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h
D	intern/opensubdiv/opensubdiv_gl_mesh_capi.h
D	intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl
D	intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl
D	intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl
D	intern/opensubdiv/stub/opensubdiv_gl_mesh_stub.cc

===================================================================

diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index d68013b3e07..ffebdd93492 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -31,7 +31,6 @@ set(SRC
   opensubdiv_capi_type.h
   opensubdiv_converter_capi.h
   opensubdiv_evaluator_capi.h
-  opensubdiv_gl_mesh_capi.h
   opensubdiv_topology_refiner_capi.h
 )
 
@@ -58,10 +57,6 @@ if(WITH_OPENSUBDIV)
     internal/opensubdiv_device_context_opencl.cc
     internal/opensubdiv_evaluator.cc
     internal/opensubdiv_evaluator_internal.cc
-    internal/opensubdiv_gl_mesh.cc
-    internal/opensubdiv_gl_mesh_draw.cc
-    internal/opensubdiv_gl_mesh_fvar.cc
-    internal/opensubdiv_gl_mesh_internal.cc
     internal/opensubdiv_topology_refiner.cc
     internal/opensubdiv_topology_refiner_internal.cc
     internal/opensubdiv_util.cc
@@ -72,9 +67,6 @@ if(WITH_OPENSUBDIV)
     internal/opensubdiv_device_context_opencl.h
     internal/opensubdiv_edge_map.h
     internal/opensubdiv_evaluator_internal.h
-    internal/opensubdiv_gl_mesh_draw.h
-    internal/opensubdiv_gl_mesh_fvar.h
-    internal/opensubdiv_gl_mesh_internal.h
     internal/opensubdiv_internal.h
     internal/opensubdiv_topology_refiner_internal.h
     internal/opensubdiv_util.h
@@ -98,10 +90,6 @@ if(WITH_OPENSUBDIV)
   OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
   OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE)
 
-  data_to_c_simple(shader/gpu_shader_opensubdiv_vertex.glsl SRC)
-  data_to_c_simple(shader/gpu_shader_opensubdiv_geometry.glsl SRC)
-  data_to_c_simple(shader/gpu_shader_opensubdiv_fragment.glsl SRC)
-
   add_definitions(-DGLEW_STATIC)
   add_definitions(-DOSD_USES_GLEW)
 
@@ -128,7 +116,6 @@ else()
   list(APPEND SRC
     stub/opensubdiv_stub.cc
     stub/opensubdiv_evaluator_stub.cc
-    stub/opensubdiv_gl_mesh_stub.cc
     stub/opensubdiv_topology_refiner_stub.cc
   )
 endif()
diff --git a/intern/opensubdiv/internal/opensubdiv.cc b/intern/opensubdiv/internal/opensubdiv.cc
index 74b81b13351..b09e3a54328 100644
--- a/intern/opensubdiv/internal/opensubdiv.cc
+++ b/intern/opensubdiv/internal/opensubdiv.cc
@@ -24,7 +24,6 @@
 
 #include "opensubdiv_device_context_cuda.h"
 #include "opensubdiv_device_context_opencl.h"
-#include "opensubdiv_gl_mesh_capi.h"
 
 void openSubdiv_init(void)
 {
@@ -34,7 +33,6 @@ void openSubdiv_init(void)
 
 void openSubdiv_cleanup(void)
 {
-  openSubdiv_deinitGLMeshDrawingResources();
 }
 
 int openSubdiv_getAvailableEvaluators(void)
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
deleted file mode 100644
index 6afd763a63e..00000000000
--- a/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
+++ /dev/null
@@ -1,260 +0,0 @@
-// Copyright 2013 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.
-
-#include "opensubdiv_gl_mesh_capi.h"
-
-#ifdef _MSC_VER
-#  include <iso646.h>
-#endif
-
-#include <opensubdiv/far/stencilTable.h>
-#include <opensubdiv/osd/glMesh.h>
-#include <opensubdiv/osd/glPatchTable.h>
-
-using OpenSubdiv::Far::StencilTable;
-using OpenSubdiv::Osd::GLMeshInterface;
-using OpenSubdiv::Osd::GLPatchTable;
-using OpenSubdiv::Osd::Mesh;
-using OpenSubdiv::Osd::MeshBitset;
-
-// CPU backend.
-#include <opensubdiv/osd/cpuEvaluator.h>
-#include <opensubdiv/osd/cpuGLVertexBuffer.h>
-using OpenSubdiv::Osd::CpuEvaluator;
-using OpenSubdiv::Osd::CpuGLVertexBuffer;
-typedef Mesh<CpuGLVertexBuffer, StencilTable, CpuEvaluator, GLPatchTable> OsdCpuMesh;
-// OpenMP backend.
-#ifdef OPENSUBDIV_HAS_OPENMP
-#  include <opensubdiv/osd/ompEvaluator.h>
-using OpenSubdiv::Osd::OmpEvaluator;
-typedef Mesh<CpuGLVertexBuffer, StencilTable, OmpEvaluator, GLPatchTable> OsdOmpMesh;
-#endif
-// OpenCL backend.
-#ifdef OPENSUBDIV_HAS_OPENCL
-#  include "opensubdiv_device_context_opencl.h"
-#  include <opensubdiv/osd/clEvaluator.h>
-#  include <opensubdiv/osd/clGLVertexBuffer.h>
-using OpenSubdiv::Osd::CLEvaluator;
-using OpenSubdiv::Osd::CLGLVertexBuffer;
-using OpenSubdiv::Osd::CLStencilTable;
-/* TODO(sergey): Use CLDeviceContext similar to OSD examples? */
-typedef Mesh<CLGLVertexBuffer, CLStencilTable, CLEvaluator, GLPatchTable, CLDeviceContext>
-    OsdCLMesh;
-static CLDeviceContext g_cl_device_context;
-#endif
-// CUDA backend.
-#ifdef OPENSUBDIV_HAS_CUDA
-#  include "opensubdiv_device_context_cuda.h"
-#  include <opensubdiv/osd/cudaEvaluator.h>
-#  include <opensubdiv/osd/cudaGLVertexBuffer.h>
-using OpenSubdiv::Osd::CudaEvaluator;
-using OpenSubdiv::Osd::CudaGLVertexBuffer;
-using OpenSubdiv::Osd::CudaStencilTable;
-typedef Mesh<CudaGLVertexBuffer, CudaStencilTable, CudaEvaluator, GLPatchTable> OsdCudaMesh;
-static CudaDeviceContext g_cuda_device_context;
-#endif
-// Transform feedback backend.
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
-#  include <opensubdiv/osd/glVertexBuffer.h>
-#  include <opensubdiv/osd/glXFBEvaluator.h>
-using OpenSubdiv::Osd::GLStencilTableTBO;
-using OpenSubdiv::Osd::GLVertexBuffer;
-using OpenSubdiv::Osd::GLXFBEvaluator;
-typedef Mesh<GLVertexBuffer, GLStencilTableTBO, GLXFBEvaluator, GLPatchTable>
-    OsdGLSLTransformFeedbackMesh;
-#endif
-// GLSL compute backend.
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
-#  include <opensubdiv/osd/glComputeEvaluator.h>
-#  include <opensubdiv/osd/glVertexBuffer.h>
-using OpenSubdiv::Osd::GLComputeEvaluator;
-using OpenSubdiv::Osd::GLStencilTableSSBO;
-using OpenSubdiv::Osd::GLVertexBuffer;
-typedef Mesh<GLVertexBuffer, GLStencilTableSSBO, GLComputeEvaluator, GLPatchTable>
-    OsdGLSLComputeMesh;
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "internal/opensubdiv_gl_mesh_draw.h"
-#include "internal/opensubdiv_gl_mesh_fvar.h"
-#include "internal/opensubdiv_gl_mesh_internal.h"
-#include "internal/opensubdiv_topology_refiner_internal.h"
-#include "internal/opensubdiv_util.h"
-#include "opensubdiv_topology_refiner_capi.h"
-
-using opensubdiv_capi::vector;
-
-namespace {
-
-GLMeshInterface *createGLMeshInterface(OpenSubdiv::Far::TopologyRefiner *topology_refiner,
-                                       const MeshBitset &bits,
-                                       const int num_vertex_elements,
-                                       const int num_varying_elements,
-                                       const int level,
-                                       eOpenSubdivEvaluator evaluator_type)
-{
-  GLMeshInterface *mesh = NULL;
-  switch (evaluator_type) {
-#define CHECK_EVALUATOR_TYPE(type, class) \
-  case OPENSUBDIV_EVALUATOR_##type: \
-    mesh = new class(topology_refiner, num_vertex_elements, num_varying_elements, level, bits); \
-    break;
-
-#define CHECK_EVALUATOR_TYPE_STUB(type) \
-  case OPENSUBDIV_EVALUATOR_##type: \
-    mesh = NULL; \
-    break;
-
-    CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh)
-#ifdef OPENSUBDIV_HAS_OPENMP
-    CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh)
-#else
-    CHECK_EVALUATOR_TYPE_STUB(OPENMP)
-#endif
-#ifdef OPENSUBDIV_HAS_OPENCL
-    CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh)
-#else
-    CHECK_EVALUATOR_TYPE_STUB(OPENCL)
-#endif
-#ifdef OPENSUBDIV_HAS_CUDA
-    CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh)
-#else
-    CHECK_EVALUATOR_TYPE_STUB(CUDA)
-#endif
-#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
-    CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK, OsdGLSLTransformFeedbackMesh)
-#else
-    CHECK_EVALUATOR_TYPE_STUB(GLSL_TRANSFORM_FEEDBACK)
-#endif
-#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
-    CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh)
-#else
-    CHECK_EVALUATOR_TYPE_STUB(GLSL_COMPUTE)
-#endif
-
-#undef CHECK_EVALUATOR_TYPE
-#undef CHECK_EVALUATOR_TYPE_STUB
-  }
-  return mesh;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// GLMesh structure "methods".
-
-opensubdiv_capi::GLMeshFVarData *createFVarData(OpenSubdiv::Far::TopologyRefiner *topology_refiner,
-                                                GLMeshInterface *mesh,
-                                                const float *fvar_src_buffer)
-{
-  using opensubdiv_capi::GLMeshFVarData;
-  GLMeshFVarData *fvar_data = new GLMeshFVarData();
-  fvar_data->create(topology_refiner, mesh->GetFarPatchTable(), 2, fvar_src_buffer);
-  return fvar_data;
-}
-
-unsigned int getPatchIndexBuffer(OpenSubdiv_GLMesh *gl_mesh)
-{
-  return gl_mesh->internal->mesh_interface->GetPatchTable()->GetPatchIndexBuffer();
-}
-
-void bindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh)
-{
-  gl_mesh->internal->mesh_interface->BindVertexBuffer();
-}
-
-void setCoarsePositions(OpenSubdiv_GLMesh *gl_mesh,
-                        const float *positions,
-                        const int start_vertex,
-                        const int num_vertices)
-{
-  gl_mesh->internal->mesh_interface->UpdateVertexBuffer(positions, start_vertex, num_vertices);
-}
-
-void refine(OpenSubdiv_GLMesh *gl_mesh)
-{
-  gl_mesh->internal->mesh_interface->Refine();
-}
-
-void synchronize(struct OpenSubdiv_GLMesh *gl_mesh)
-{
-  gl_mesh->internal->mesh_interface->Synchronize();
-}
-
-void assignFunctionPointers(OpenSubdiv_GLMesh *gl_mesh)
-{
-  gl_mesh->getPatchIndexBuffer = getPatchIndexBuffer;
-  gl_mesh->bindVertexBuffer = bindVertexBuffer;
-  gl_mesh->setCoarsePositions = setCoarsePositions;
-  gl_mesh->refine = refine;
-  gl_mesh->synchronize = synchronize;
-
-  gl_mesh->prepareDraw = opensubdiv_capi::GLMeshDisplayPrepare;
-  gl_mesh->drawPatches = opensubdiv_capi::GLMeshDisplayDrawPatches;
-}
-
-}  // namespace
-
-struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
-    OpenS

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list