Commit Graph

42 Commits

Author SHA1 Message Date
Sergey Sharybin
8da3c5c1b9 Fix T46159: OpenSubdiv does not always give same results as Blender own subsurf code with crease edges 2015-09-21 17:53:21 +05:00
Sergey Sharybin
89de6e9eac OpenSubdiv: Fix crash caused by accessing OpenGL vendor from non-main thread 2015-09-16 22:25:13 +05:00
Sergey Sharybin
cf4711bdf9 OpenSubdiv: Attempt to solve crash in background mode 2015-09-16 20:33:16 +05:00
Sergey Sharybin
0f19e6d1a7 Code cleanup, whitespace 2015-09-16 20:26:58 +05:00
Sergey Sharybin
7b3491f2c6 OpenSubdiv: Fix for missing caching of vendor string parsing result 2015-09-16 20:23:32 +05:00
Sergey Sharybin
19d17c8d90 Fllowup to previous commit, remove unused code 2015-09-16 20:20:16 +05:00
Sergey Sharybin
3f05d72a98 Fix T45708: OpenSubdiv crashes on Windows with Intel cards
Disable Intel cards for until we'll go to the root of the issue of the crash.
This will take a bit, so being so close to the release we go safe and disable
unstable GPU, so blender at least doesn't crash.

This could be bypassed by setting OPENSUBDIV_ALLOW_INTEL environment variable.
2015-09-16 19:28:40 +05:00
Sergey Sharybin
145617c5eb OpenSubdiv: More graceful handling of shader compile/linking errors 2015-09-09 17:27:08 +05:00
Sergey Sharybin
a560122c4b OpenSubdiv: Remove some dead code 2015-08-28 12:46:52 +02:00
Sergey Sharybin
5908340f79 OpenSubdiv: Attempt to solve crash on certain GPUs/drivers 2015-08-27 11:05:23 +02:00
Antony Riakiotakis
a8be746609 OpenSubdiv: Fix error found by PerfectionCat,
Use glew, not gl constants to detect presence of extensions.
glProgramParameterEXTi is part of GLEW_EXT_geometry_shader4
2015-08-27 10:05:58 +03:00
Sergey Sharybin
6ca12d157f Fix T45909: Garbage output in Viewport with OpenSubdiv device set to GLSL Compute
This isn't a Blender issue and the same bug happens with official OpenSubdiv
examples. For until it's either worked around from OpenSubdiv side or fixed
in the driver we'll force disable GLSL Compute for AMD hardware.
2015-08-26 12:10:24 +02:00
Sergey Sharybin
bcc0d2fb1d OpenSubdiv: Fix/workaround bad shading on AMD devices
Uniform block data layout was different on CPU and GPU which caused wrong
data being used from shader.

In theory using layout(std140) is what we need to do, but for some reason
such layout specifier is being ignored. This is probably caused by the way
how we exploit extensions from older version of glsl.

For until we've upgraded our glsl pipeline used different approach which
is basically about removing unused fields form the struct manual in hope
that it'll keep memory layout consistent for both CPU and GPU.

This seems to work so far for both NVidia GTX580 and AMD FirePro W8000
here in the studio.
2015-08-26 12:07:38 +02:00
Sergey Sharybin
df9f4c2e4f OpenSubdiv: Add extra checks whether GPU compute available or not 2015-08-26 09:16:35 +02:00
Sergey Sharybin
669f2f0088 OpenSubdiv: Remove partitioned mesh interface
It's hopefully no longer needed, at least not needed for as long as
single ptex face corresponds to a single patch which should be always
correct for uniform subdivisions as far as i know.
2015-08-25 15:12:12 +02:00
Sergey Sharybin
f1e68474e0 OpenSubdiv: Support for multiple materials in solid shading mode
Implementation is less optimal compared to non-opensubdiv drawing but
it is now as good as we can do it without affecting on how patches are
being created by OpenSubdiv.
2015-08-25 15:11:56 +02:00
Sergey Sharybin
5cf519ac51 OpenSubdiv: Better approximation of vertex normals
Use vertex varying data which gives better approximation of normals.
Still not ideal but should be closer for higher poly meshes to correct
normal.

The only way to have proper smooth normals seems to be to implement
patch evaluation in tessellation shader, but that's a bit PITA with
current GLSL usage in our draw code.
2015-08-25 13:16:55 +02:00
Antony Riakiotakis
10edaff5c1 Fix ATI part of T45708, crash when enabling opensubdiv.
In fact exit was getting called because we
had an error in shader compilation:

Uniform buffer objects are in fact required.

Since it looks like original intent was to
write the shader against older GLSL version,
I will be adding an extension here instead
of a version.

Thanks to Anshu Arya for letting me borrow his machine through
VPN to do the debugging :)
2015-08-20 16:23:33 +03:00
Sergey Sharybin
fa4172c28c OpenSubdiv: Make sure faces are exported with consistent normal
This is currently a requirement of OpenSudiv and original orientation code
was depending on this quite a lot.

This makes mesh conversion and comparison slower but solves some crashes.
With some trickery it could be optimized and become closer to original
performance.

Probably Campbell has some nice ideas here as well :)
2015-08-06 09:49:13 +02:00
Sergey Sharybin
868d3605ee Fix T45693: Fix for using 4-component vector as 3 component in osd shader 2015-08-05 21:35:38 +02:00
Sergey Sharybin
ea40df582f OpenSubdiv: Fix for missing OpenMP device when building with SCons 2015-08-04 18:25:34 +02:00
Sergey Sharybin
16b619b77d OpenSubdiv: Correction for compute devices detection in SCons
SCons was still using file names from 2.x branch.
2015-08-04 18:18:21 +02:00
Sergey Sharybin
b50916d172 OpenSubdiv: forgot this in the previous commit
Need to find better approach for dealing with shadeless materials.
2015-08-04 11:04:27 +02:00
Sergey Sharybin
abb976ae88 OpenSubdiv: Optimize drawing shader
The idea is to cut as much code as possible and use compile-time
ifdefs rather than runtime if() statements.

Gives about 2x speedup on catmark_car model from OpenSubdiv repository
making our FPS much closer to what glViewer is capable of.
2015-08-04 10:52:50 +02:00
Sergey Sharybin
0951ea2c6d OpenSubdiv: Support shadeless shading 2015-08-03 20:18:33 +02:00
Sergey Sharybin
3aa2dd74b5 OpenSubdiv: Correction to vert edge/face orientation code
non-manifold case didn't start ordering from the correct edge.
2015-08-03 14:27:34 +02:00
Sergey Sharybin
60c8cdf763 OpenSubdiv: Switch CPU evaluator to use uniform refinement
This way the result matches GPU viewport and becomes really close to out
legacy subsurf code.
2015-08-03 14:27:31 +02:00
Sergey Sharybin
4bf26fda97 OpenSubdiv: Mark non-manifold verts as sharp 2015-08-03 14:27:31 +02:00
Sergey Sharybin
11ad18c82a OpenSubdiv: Disable topology check happening from OpenSubdiv side
This check doesn't handle multiple non-manifolds cases which is rather
really annoying currently.
2015-08-03 14:27:31 +02:00
Sergey Sharybin
dd1e7f16ca OpenSubdiv: Work on better vert edge/face orientation code
Previous version of code didn't handle cases like hourglass connectivity
with loose edge. The new code is supposed to handle all this cases.
2015-08-03 14:27:31 +02:00
Sergey Sharybin
820d191626 OpenSubdiv: Add CMake option to enable -Werror in subsurf code 2015-07-30 10:31:22 +02:00
Sergey Sharybin
5c7cdfcb42 OpenSubdiv: Remove debug-only leftover 2015-07-30 10:22:31 +02:00
Sergey Sharybin
7380166db2 OpenSubdiv: Workaround for vertices which are adjacent to several manifold islands 2015-07-29 18:41:05 +02:00
Sergey Sharybin
26c1ae81be OpenSubdiv: Proper detection of crease changes 2015-07-29 18:05:29 +02:00
Sergey Sharybin
48c2f7b288 OpenSubdiv: Some debug-only code sneaked into previous commit 2015-07-29 17:43:43 +02:00
Sergey Sharybin
51c1927ccb OpenSubdiv: Make topology orientation optional 2015-07-29 17:41:57 +02:00
Sergey Sharybin
717a303a18 OpenSubdiv: Fixes for crease in non-manifold meshes
Basically non-manifold edges are expected to be sharp by OpenSubdiv.

There\s still some work required, see the inlined comment.
2015-07-29 17:38:06 +02:00
Sergey Sharybin
b8e2b8ae8a OpenSubdiv: Rework vert-edge and vert-face ordering
Now the code survives multiple non-manifolds happening on the vert.

Still not totally optimal but at least gives much better mesh support.
2015-07-29 17:13:15 +02:00
Sergey Sharybin
af6bbab5b4 OpenSubdiv: Fix for weirdly ordered lines 2015-07-29 17:13:15 +02:00
Sergey Sharybin
8e9534a850 OpenSubdiv: Make empty meshes supported and not crashing 2015-07-29 13:10:19 +02:00
Sergey Sharybin
3d36489672 OpenSubdiv: Commit of OpenSubdiv integration into Blender
This commit contains all the remained parts needed for initial integration of
OpenSubdiv into Blender's subdivision surface code. Includes both GPU and CPU
backends which works in the following way:

- When SubSurf modifier is the last in the modifiers stack then GPU pipeline
  of OpenSubdiv is used, making viewport performance as fast as possible.

  This also requires graphscard with GLSL 1.5 support. If this requirement is
  not met, then no GPU pipeline is used at all.

- If SubSurf is not a last modifier or if DerivesMesh is being evaluated for
  rendering then CPU limit evaluation API from OpenSubdiv is used. This only
  replaces the legacy evaluation code from CCGSubSurf_legacy, but keeps CCG
  structures exactly the same as they used to be for ages now.

This integration is fully covered with ifdef and not enabled by default
because there are several TODOs to be solved first:

- Face varying data interpolation is not really cleanly implemented for GPU
  in OpenSubdiv 3.0. It is also not implemented for limit evaluation API.

  This basically means we'll have really hard time supporting UVs.

- Limit evaluation only works with adaptivly subdivided meshes so far, which
  basically means all the points of CCG are pushed to the limit. This gives
  different result from old code.

- There are some serious optimizations possible on the topology refiner
  creation, which would speed up initial OpenSubdiv mesh creation.

- There are some hardcoded asumptions in the GPU and DerivedMesh areas which
  could be generalized.

  That's something where Antony and Campbell can help, making it so the code
  is structured in a way which is reusable by all planned viewport projects.

- There are also some workarounds in the dependency graph to make sure OpenGL
  buffers are only freed from the main thread.

Those who'll be wanting to make experiments with this code should grab dev
branch (NOT master) from

  https://github.com/Nazg-Gul/OpenSubdiv/tree/dev

There are some patches applied in there which we're working on on getting
into upstream.
2015-07-20 22:29:26 +02:00
Sergey Sharybin
a040157e5d OpenSubdiv: Add new OpenSubdiv related files
This includes C-API bindings in intern/opensubdiv and CMAke module
which finds the OpenSubdiv library. This filea are not in use so
far, making it a separate commit to make actual integration commit
more clear.
2015-07-20 22:29:25 +02:00