Commit Graph

959 Commits

Author SHA1 Message Date
Takahito Tejima
47f79e54fc Merge pull request #528 from davidgyu/memfix
Fixed buffer access into empty container
2015-05-26 14:55:27 -07:00
Takahito Tejima
62b7197389 Merge branch '358' of https://github.com/ielillo/OpenSubdiv into ielillo-358
Conflicts:
	opensubdiv/far/stencilBuilder.cpp
2015-05-26 14:22:36 -07:00
Takahito Tejima
749bbf4271 Fix OpenCL and CUDA EvalPatches kernels. 2015-05-26 11:13:30 -07:00
David G. Yu
8568370630 Fixed buffer access into empty container
Raised as a run-time error by the VS2013 debug STL implementation.
2015-05-26 11:03:21 -07:00
Takahito Tejima
541aeddd3a Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.

with this change, Eval API in the osd layer consists of following parts:

- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
  implements EvalStencils and EvalPatches(*). Both supports derivatives
  (not fully implemented though)

- Interop vertex buffer classes (optional, same as before)
  Note that these classes are not necessary to use Evaluators.
  All evaluators have EvalStencils/Patches which take device-specific
  buffer objects. For example, GLXFBEvaluator can take GLuint directly
  for both stencil tables and input primvars. Although using these
  interop classes makes it easy to integrate osd into relatively
  simple applications.

- device-dependent StencilTable and PatchTable (optional)
  These are also optional, but can be used simply a substitute of
  Far::StencilTable and Far::PatchTable for osd evaluators.

- PatchArray, PatchCoord, PatchParam
  They are tiny structs used for GPU based patch evaluation.

(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
   There's a technical difficulty for the multi-stream output.
2015-05-25 22:43:43 -07:00
barfowl
85b65bd2ef Moved Vtr classes within internal namespace:
- moved all major Vtr classes within namespace internal
    - updated all Vtr class access with Far
2015-05-25 20:34:50 -07:00
Jeremy Cowles
d335c7249e Merge pull request #522 from barfowl/primvarRefiner
Moved primvar interpolation methods to new Far::PrimvarRefiner class
2015-05-24 22:18:26 -07:00
George ElKoura
670a48fd86 Fix build breakage on MSVC due to implicit downcasting.
Be explicit about the casting from size_t to int in stencilBuilder.cpp.
2015-05-24 01:21:48 -07:00
Jeremy Cowles
15020c2c4c Fix StencilBuilder copyright (2015) 2015-05-23 20:34:59 -07:00
Jeremy Cowles
befbc282db Add stencilTable.cpp, minor cleanup
* Added stencilTable.cpp
 * Fixed the "off" variable shadow warning
 * Moved constructors to cpp file
 * Made LimitStencilTable constructor private
 * other minor clean up.
2015-05-23 20:31:18 -07:00
barfowl
a15edc1f2c Moved primvar interpolation methods to new Far::PrimvarRefiner class
- created new class Far::PrimvarRefiner with interpolation methods
    - removed interpolation and limit methods from Far::TopologyRefiner
    - replaced internal usage in Far::StencilTableFactory
    - replaced usage in regressions, tutorials and examples
2015-05-23 18:56:36 -07:00
Ignacio Lillo
e6733580ba Fixed warning that prevented building the project. 2015-05-23 00:48:58 -03:00
George ElKoura
7a97d7be5d Merge pull request #520 from barfowl/vtr_friends
Removing friends from Vtr classes
2015-05-22 18:49:47 -07:00
jcowles
909757ca9b Faster, simpler stencil table construction.
This is a new implementation of the stencil table construction algorithm found
in protoStencil.h. In local tests with production assets, the new algorithm is
~25% faster and significantly more stable, in terms of average performance

In one asset test, generating stencils for level 10 adaptive refinement of
BuzzLightyear was reduced from 18s to 13s.
2015-05-22 16:36:12 -07:00
barfowl
b64eb5e2e0 Removing friends from Vtr classes and making more accessible internally:
- removed all friend declarations (no more Far declarations with Vtr)
    - all protected methods made public
    - intent is to move these into namespace internal
    - access between Vtr classes is under review
2015-05-22 15:52:47 -07:00
Takahito Tejima
a7c5179ef9 renaming (2/2) PatchTables and StencilTables to PatchTable and StencilTable
replace all occurrences reffering PatchTables, StencilTables, and their factories.
2015-05-22 11:50:01 -07:00
Takahito Tejima
e6f951c010 renaming (1/2) PatchTables and StencilTables to PatchTable and StencilTable
this commit just changes filenames (for better diffs)
2015-05-22 11:02:58 -07:00
Jeremy Cowles
bec60d5500 Merge pull request #512 from takahito-tejima/dev
remove maximum valence limitation in gregory basis and bspline basis end caps.
2015-05-21 23:38:40 -07:00
barfowl
3d80cc56f5 Replaced and removed remaining use of TopologyRefiner level methods:
- replaced all remaining usage internal to far with TopologyLevel
    - removed the obsolete methods from TopologyRefiner
2015-05-21 21:26:41 -07:00
barfowl
ff13665a02 Introduced Far::TopologyLevel methods in place of TopologyRefiner in Osd 2015-05-21 20:20:16 -07:00
David G Yu
2b33de38f8 Merge pull request #513 from takahito-tejima/refactor2
implements Osd::CpuEvaluator::EvalPatches function.
2015-05-21 18:55:09 -07:00
David G Yu
71055dbdd9 Merge pull request #510 from takahito-tejima/refactor
glStencilViewer crash fix
2015-05-21 18:53:45 -07:00
Takahito Tejima
2e26f932e1 implements Osd::CpuEvaluator::EvalPatches function.
- it takes number and pointer for the input PatchCoords.
- add derivative evaluations.
- enhance glEvalLimit example to see the derivative evaluation works.
2015-05-21 17:45:13 -07:00
Takahito Tejima
2008e6ca05 Merge pull request #511 from davidgyu/shadingRefactor
Sync'ed up GLSL and HLSL patch shader source.
2015-05-21 11:51:40 -07:00
Takahito Tejima
b15762204a remove maxvalence limitation in FarGregoryBasis. 2015-05-21 10:59:40 -07:00
David G Yu
f4a8cafe86 Sync'ed up GLSL and HLSL patch shader source.
Cleaned up the Legacy Gregory shader source by accessing buffer
data through helper functions.

Switched to performing tessellation in untransformed (object) space.
2015-05-21 09:56:25 -07:00
Takahito Tejima
743c424e9c Add high-valence evaluation path into gregory basis. 2015-05-21 09:42:26 -07:00
Takahito Tejima
e8ac41dbc8 glStencilViewer crash fix #2
this change fixes a crash when selecting catmark_hole_test1
in glStencilViewer. If there's a hole limit stencils may not
be found for given limit location, resulting invalid stencil
entries.
2015-05-21 09:05:33 -07:00
Takahito Tejima
c9150cfb23 glStencilViewer crash fix #1
use patchtables instead of patchTables (yes, quite confusing...)
patchtables may be created ondemand if patchTables isn't given
as an argument.
2015-05-21 09:03:06 -07:00
barfowl
05e9c48ea9 Raised maximum valence supported by Vtr and included new test shapes:
- changed Vtr::LocalIndex to 16-bit integer from 8-bit
    - added test shapes including valence 360 vertices
    - disabled new shapes in far/regression until improved accuracy accepted
2015-05-20 23:36:45 -07:00
George ElKoura
32e9bb7e29 Merge pull request #508 from davidgyu/dxfix
Fixed HLSL shader compile error.
2015-05-20 22:25:14 -07:00
David G Yu
1bdc69dbfc Merge pull request #506 from c64kernal/dev_patch
Remove need for friending a class in PatchTables.
2015-05-20 21:53:19 -07:00
David G. Yu
d1452a02cf Fixed HLSL shader compile error. 2015-05-20 21:48:52 -07:00
George ElKoura
b53a73f7de Removed unnecessary friendship in ProtoStencil. 2015-05-20 20:10:14 -07:00
George ElKoura
f521c9dde3 Remove need for friending a class in PatchTables.
PatchTables no longer needs to friend EndCapLegacyGregoryPatchFactory.
Instead we now make the patch table factory pass in the data that needs
to be updated directly to EndCapLegacyGregoryPatchFactory.
2015-05-20 19:44:43 -07:00
George ElKoura
a7d9d6a9b4 Merge pull request #504 from davidgyu/cleanup
Comment cleanups discovered while reviewing Far
2015-05-20 19:40:49 -07:00
David G Yu
c82b3d551d Merge pull request #502 from barfowl/patch_eval
Refactor public patch evaluation methods exposed by Far::PatchTables
2015-05-20 19:39:32 -07:00
Takahito Tejima
a1424ae163 Fix gregory patch tesslevel computation
- flipping UV
- using limit position in legacy gregory shader.
2015-05-20 18:27:32 -07:00
David G Yu
7aa6ef8113 Fixed comments and one cut-n-paste typo in Far. 2015-05-20 17:43:13 -07:00
David G Yu
11e987a7d8 Fixed the misspellings of Ignacio Castano's name. 2015-05-20 17:39:06 -07:00
barfowl
be50309752 Fixed missing qualification of IndexArray 2015-05-20 17:21:02 -07:00
Takahito Tejima
109a3f5383 osd layer: Add GLPatchTable and retire DrawContext
In osd layer, we use GLPatchTable (D3D11PatchTable) as a
device-specific representation of FarPatchTables instead of
DrawContext. GLPatchTable may be used not only for drawing
but also for GPU eval APIs (not yet supported though.
We may add CudaPatchTable etc as needed).

The legacy gregory patch drawing buffers are carved out to
the separate class, named GLLegacyGregoryPatchTable.

Also face-varying data are split into client side for now, until
we add new and more robust face-varying drawing structure
(scheduled at 3.1 release)

Tentatively replicate PatchArray structure in GLPatchTables. It will
be revised in the upcoming change.

Shifting hard-coded SRV locations of legacy gregory buffers in HLSL shaders.
2015-05-20 15:55:06 -07:00
barfowl
891772f58b Refactor public patch evalations methods exposed by Far::PatchTables:
- changes completely deprecate AddWithWeight(T, float, float, float)
    - added new EvaluateBasis() method to PatchTables
    - replaced usage of old Evaluate...<T,U>() methods with EvaluateBasis()
    - removed old Evaluate...<T,U>() methods
    - removed now unused Interpolate...<T,U>() functions in far/interpolate.h
    - moved low-level basis code from far/interpolate.* to patchBasis.*
2015-05-20 15:44:29 -07:00
David G. Yu
00ce36433f Fixed handedness flip in Gregory{Basis} shaders
There was an unnecessary double-flip in the shading calculations.
2015-05-20 14:17:31 -07:00
jcowles
d83f063d93 Break friendship between GegoryBasis and Factory 2015-05-20 13:25:19 -07:00
David G Yu
0811046c2f Merge pull request #497 from jcowles/dev-remove-pragma
Remove #pragma once
2015-05-20 12:57:21 -07:00
Takahito Tejima
8d9ae550ff Add a HLSL version of GregoryBasis patch shader.
hlslPatchGregoryBasis.hlsl is an equivalent to glslPatchGregoryBasis.
Update dxViewer to be able to switch among bspline, gregorybasis, legacy
end capping.

also fixes a bug of GLSL legacy gregory shader which had an inconsistent
resource naming with example codes.

It looks like there's still an issue of D3D11 patchParam data fetching.
we'll come back to that bug.
2015-05-20 10:49:45 -07:00
jcowles
392e5e8bed Remove #pragma once
While this may be worth revisiting, we should first quantify the benefits and
identify the compilers that support it. Ultimately, we may never use pragma
once in favor of strictly using standard C++.
2015-05-20 09:59:18 -07:00
barfowl
e3db2c94a6 Minor performance improvements to Sdc limit masks for the regular case:
- simple loop unrolling and branch reduction in Loop and Catmark limits
2015-05-19 15:49:19 -07:00
barfowl
33cbbbc4f8 Move topology queries specific to a level to new Far::topologyLevel class:
- added new class to far/topologyLevel.h
    - updated TopologyRefiner to manage set of TopologyLevels internally
    - added TopologyRefiner method to retrieve TopologyLevel
    - redefined obsolete TopologyRefiner methods in terms of TopologyLevel
2015-05-19 15:06:41 -07:00
Takahito Tejima
6421c52fae Merge pull request #489 from davidgyu/irregularRotate
Fixed varying stencils for end cap patches
2015-05-19 13:19:30 -07:00
Takahito Tejima
2f90e3799a Merge pull request #488 from jcowles/dev-size
Prefix header guards and add pragma once.
2015-05-19 13:18:18 -07:00
David G. Yu
8d33bb8dd9 Fixed varying stencils for end cap patches 2015-05-19 13:00:53 -07:00
jcowles
9d32712ec4 Prefix header guards and add pragma once. 2015-05-19 11:22:37 -07:00
Takahito Tejima
c3aa00e706 remove SupportsAdaptiveTessellation from OsdDrawContext, and example cleanups
As a preparation for retiring DrawContext, move SupportsAdaptiveTessellation
method to examples/common/glUtils, which is renamed and namespaced
from gl_common.{cpp,h} to be consistent to other files.
Same renamings applied to other example files.
2015-05-19 10:30:16 -07:00
jcowles
7b4aa33a1f Change stencils sizes from unsigned char to int. 2015-05-19 10:16:56 -07:00
David G Yu
d97d9941be Removed Interpolate{Boundary,Corner}Patch from Far
Far::GetBSplineWeights() now handles boundary and corner edges.
2015-05-18 15:05:30 -07:00
barfowl
0d7ae5c461 Refactored Far computation of Gregory patch basis functions:
- fixes normalization of (s,t) hidden in Bezier weight computation
    - includes computation of true derivatives for future reference
2015-05-15 18:52:02 -07:00
barfowl
2ec507e107 Removed more usage of alloca() dependent on maximum valence:
- replaced alloca() usage in far/gregoryBasis.cpp with StackBuffer
2015-05-15 17:20:03 -07:00
David G Yu
8716a8eebf Fixed example code use of single crease patches
Also made a couple minor changes to true up the GLSL patch shaders.
2015-05-15 11:52:41 -07:00
David G. Yu
b0dd44dd47 Fixed an alloca buffer overrun error in Far 2015-05-14 13:25:33 -07:00
David G Yu
6ade89c221 Removed an unused local var from interpolate.cpp
Fixes a build warning from clang on OS X.
2015-05-14 12:55:04 -07:00
Takahito Tejima
4a4322983f Osd drawing API refactoring.
Remove DrawRegistry from osd layer and put a simple shader caching
utility into examples/common. osd layer only provides patch shader
snippet and let client configure and compile the code. Clients also
maintain the lifetime of shader object, which is preferable for the
actual application integration.

update all examples to use the new scheme.
2015-05-13 17:35:46 -07:00
David G Yu
fb009f41b2 Removed BOUNDARY and CORNER patch types
These are now redundant since all bspline patches are encoded in
the patch tables consistently using 16 point indices with boundary
and corner edges indicated in the boundary mask of the patch params.
2015-05-13 11:31:02 -07:00
David G Yu
7b69117f02 Fixed evaluation of boundary and corner patches
My earlier change which simplified the categorization of
patch types broke evaluation for boundary and corner patches.

Previously, boundary and corner patches were always rotated
into a canoncial orientation by permuting the point indices
of the patch. This was convenient in some cases, but generally
made things unecessarily complicated, since the parameterization
of the patch had to be counter-rotated to compensate.

Now patches always remain correctly oriented with respect
to the underlying surface topology and evaluation of boundary
and corner patches is accommodated by simply adjusting the
spline weights to account for the missing/invalid patch
points along boundary and corner edges.

There is more to clean up and optimize, but this restores
correct behavior.
2015-05-12 16:13:57 -07:00
David G Yu
1c91945d10 Added stronger guards for OSD_MAX_VALENCE 2015-05-12 11:15:51 -07:00
Takahito Tejima
917974f7d1 fix typo in the include guard. 2015-05-11 18:07:26 -07:00
Takahito Tejima
b66380ee52 Refactor Osd::DrawContext
Since unified shading work already removed subPatch info from
Osd::PatchDescriptor, the difference between Far::PatchDescriptor and
Osd::PatchDescriptor is just maxValence and numElements. They are used
for legacy gregory patch drawing.

Both maxValence and numElements are actually constant within a topology
(drawContext). This change move maxValence to DrawContext and let client
manage numElements, then we can eliminate Osd::PatchDescriptor and simply
use Far::PatchDescritor instead.

This is still an intermediate step toward further DrawRegistry refactoring.
For the time being, adding EffectDesc struct to include maxValence and
numValence to be maintained by the clients. They will be cleaned up later.

The side benefit of this change is we no longer need to recompile regular b-spline
shaders for the different max-valences.
2015-05-11 18:06:46 -07:00
barfowl
60c6f51592 Improvements to patch basis evaluation in far/interpolate.*:
- added Far::GetGregoryWeights() to work directly with 20 weights
    - simplified tensor-product evaluation of Bezier and BSpline (will more
      readily support higher order derivatives in near future)
    - fixed Bezier derivative scaling issue (off by factor of 3.0)
    * noted incorrectness of Gregory derivatives (correction will accompany
      support for higher order derivatives in near future)
2015-05-11 16:18:03 -07:00
Takahito Tejima
94d6eb6491 cleanup remaining ptex specific code in osd layer
- Remove MeshPtexData bit from Osd::MeshBits. It's not used any more
- Rename ptexIndexBuffer in D3D11DrawContext to paramParamBuffer
- Remove Is/SetPtexEnabled from D3D11DrawRegistry
2015-05-11 10:59:16 -07:00
Takahito Tejima
33bfbf699b Refurbish osd layer API.
In OpenSubdiv 2.x, we encapsulated subdivision tables into
compute context in osd layer since those tables are order-dependent
and have to be applied in a certain manner. In 3.0, we adopted stencil
table based refinement. It's more simple and such an encapsulation is
no longer needed. Also 2.0 API has several ownership issues of GPU
kernel caching, and forces unnecessary instantiation of controllers
even though the cpu kernels typically don't need instances unlike GPU ones.

This change completely revisit osd client facing APIs. All contexts and
controllers were replaced with device-specific tables and evaluators.
While we can still use consistent API across various device backends,
unnecessary complexities have been removed. For example, cpu evaluator
is just a set of static functions and also there's no need to replicate
FarStencilTables to ComputeContext.

Also the new API delegates the ownership of compiled GPU kernels
to clients, for the better management of resources especially in multiple
GPU environment.

In addition to integrating ComputeController and EvalStencilController into
a single function Evaluator::EvalStencils(), EvalLimit API is also added
into Evaluator. This is working but still in progress, and we'll make a followup
change for the complete implementation.

-some naming convention changes:
GLSLTransformFeedback to GLXFBEvaluator
GLSLCompute to GLComputeEvaluator

-move LimitLocation struct into examples/glEvalLimit.
We're still discussing patch evaluation interface. Basically we'd like
to tease all ptex-specific parametrization out of far/osd layer.

TODO:
-implments EvalPatches() in the right way
-derivative evaluation API is still interim.
-VertexBufferDescriptor needs a better API to advance its location
-synchronization mechanism is not ideal (too global).
-OsdMesh class is hacky. need to fix it.
2015-05-08 17:31:26 -07:00
Takahito Tejima
1a37da1c26 osd refactor: split the vertex buffer argument into src and dst
Changing all device kernels to take two buffer identifiers for
source and destination separately.
This change is an intermediate step toward upcoming context/controller
refactoring.

Previously we have a limitation that the source and destination
vertex buffer has to be a single buffer, since the subdivision
kernels are iteratively applied by level.
With stencil tables, we don't have such a limitation any more,
so we may want to apply stencils from seprate source buffer to
another.

To specifiy the output location within the destination buffer,
we can use VertexBufferDescriptor.offset. This allows us not only
configuring arbitrary batching scheme, but also relaxing the
limitation that source and destination buffers are in same
interleaved layout. For examples, we could include derivatives only
in the destination buffer, which doesn't need to be allocated in
the source buffer.
2015-05-07 16:11:00 -07:00
Takahito Tejima
8fc0e5db93 Move Ptex code from osd to examples.
we're teasing out ptex specific data from core osd entities,
so there's no reason to keep ptex texturing utilities in core osd.
move them into example libs and let clients assemble shader snippets
as needed.

Also removing older ptex texturing code (without mipmap)
2015-05-07 13:56:48 -07:00
Takahito Tejima
f3aec9eb31 Remove osd/vertex.h
OsdVertex was used in 2.x FarMesh as a placeholder for Hbr template parameter.
We don't need such a class any more.
2015-05-07 12:34:09 -07:00
David G Yu
8b4ef28116 Updated handling of patchParam and patchCoord
Each patch has a corresponding patchParam. This is a set of three values
specifying additional information about the patch:

   faceId    -- topological face identifier (e.g. Ptex FaceId)
   bitfield  -- refinement-level, non-quad, boundary, transition, uv-offset
   sharpness -- crease sharpness for a single-crease patch

These are stored in OsdPatchParamBuffer indexed by the value returned
from OsdGetPatchIndex() which is a function of the current PrimitiveID
along with an optional client provided offset.

Accessors are provided to extract values from a patchParam. These are
all named OsdGetPatch*().

While drawing patches, the patchParam is condensed into a patchCoord which
has four values (u, v, faceLevel, faceId). These patchCoords are treated
as int values during per-prim processing but are converted to float values
during per-vertex processing where the values are interpolated.

Also, cleaned up more of the shader namespace by giving an Osd prefix
to public functions, and consolidated boundary and transition handling
code into the PatchCommon shader files. The functions determining
tessellation levels are now all named OsdGetTessLevel*().
2015-05-06 13:47:33 -07:00
Takahito Tejima
efb010557d Merge pull request #461 from c64kernal/dev_warn
Satisfy compiler warnings about unused parameters.
2015-04-30 21:45:53 -07:00
barfowl
272efb6911 Minor changes to Far::TopologyRefiner:
- now declared non-copyable
    - replaced alloca() usage with StackBuffer (to allow overflow to heap)
    - overloaded Limit() to compute limit tangents (two tangents per vertex)
    - disabled face-varying influence on feature-adaptive selection
2015-04-30 19:37:53 -07:00
George ElKoura
687cc4f8d9 Return *this from operator= in vtr/stackBuffer.h 2015-04-30 19:11:51 -07:00
George ElKoura
12c421e36c Satisfy compiler warnings about unused parameters.
In vtr/stackBuffer.h, removed  unnecessary symbols for parameters to silence
compiler warnings about them not being used.
2015-04-30 18:40:44 -07:00
Takahito Tejima
dcb022e1db Fix DX-OpenCL/CUDA interop.
- resolves DX-CL interop functions in Osd::ClD3D11VertexBuffer.
- enable CL kernels in DX build.
- more cleanup in test harnesses, adding D3D11 initializations into DeviceContext.
- add new defines OPENSUBDIV_HAS_OPENGL and OPENSUBDIV_HAS_DX for convenience.
2015-04-29 11:51:12 -07:00
barfowl
abce99950d Minor improvements to definition and use of Vtr::StackBuffer:
- removed default value for its <SIZE> parameter
    - updated all usage to specify a value for <SIZE>
    - added explicit element destruction missing from destructor
    - corrected comment regarding VLA's being non-standard
2015-04-28 17:31:43 -07:00
Takahito Tejima
82a0513326 cleanup CL/CUDA example harnesses.
refactor CL/CUDA specific initialization stuffs into
examples/common/clDeviceContext and cudaDeviceContext, and
update examples to use those structs.

also
- remove CL/CUDA tests from osd_regression. The tests for those kernels will be covered by glImaging.
- update cuda initialization to use the GL-interoperable device if available.
- remove CL specialization from glShareTopology, following the same pattern as we took in the previous OsdGLMesh refactoring. (still something strange with XFB kernels though)
- fix file permissions.
2015-04-28 15:46:37 -07:00
Takahito Tejima
99f1b57ba5 Merge pull request #448 from davidgyu/patcheval
Fixed gathering of patches near non-manifold topo
2015-04-27 13:34:18 -07:00
David G Yu
46b2cac54b Fixed gathering of patches near non-manifold topo
The previous change to the gathering of patch points went
a bit too far. Near non-manifold features it is important
to be careful when traversing the faces in a level to avoid
assumptions that are valid only for manifold topology.

Also, removed Vtr::Level::gatherQuadRegularPatchPoints().
This method was added in my previous change, but it is
unsafe to use in the presence of non-manifold topology.
2015-04-27 12:40:18 -07:00
Takahito Tejima
de0082ba95 Simplify Osd::MeshInterface.
Removed OpenCL/D3D11 specialization and add DEVICE_CONTEXT as a template
parameter. For the kernels which don't need a context object (e.g.
CPU, OpenGL, cuda) just ignore the context, and for the kernels which
use a context (e.g. OpenCL, DirectX) takes a context or a user-defined
class as which encapsulates device contexts. Note that OpenCL requires
two objects, cl_context and cl_command_queue. The user-defined
class must provide GetContext() and GetCommandQueue() for strongly typed
binding to osd VertexBuffers and ComputeContexts.

Osd::Mesh and MeshInterface have been used as a handy harness to host
multiple GPU kernels and graphics APIs. However it has CL/DirectX
specializations and duplicates large amount of plubming code. With this
change, glMesh.h and d3d11Mesh.h become just typedefs and all logic is
put into mesh.h without specializations.

Also cleaned up unused header files and code formatting.
2015-04-27 11:27:05 -07:00
George ElKoura
ce0cdf1a90 Fix an out-of-bounds read.
Fixed a bad read from a std::vector.  It's normally harmless, but at least makes
debug runtimes cry.
2015-04-26 20:32:34 -07:00
barfowl
ce223949f2 Introduced StackBuffer class to replace/extend usage of alloca():
- add Vtr::StackBuffer to allocate from heap beyond local arena size
    - replaced usage of alloca() with Vtr
2015-04-26 17:04:18 -07:00
Takahito Tejima
1fab11b2b4 Merge pull request #441 from davidgyu/patch-drawing
Fixed orientation of boundary and corner patches
2015-04-24 23:00:51 -07:00
Takahito Tejima
4d0bd75067 Merge pull request #440 from asluk/dev
retain vertex 0 for lefthanded meshes
2015-04-24 22:27:36 -07:00
George ElKoura
63dd4f7f40 Fix ptex indices computations for loop.
The only method not yet implemented for loop in PtexIndices is GetAdjacency(), fix code accordingly.
2015-04-24 16:08:37 -07:00
David G Yu
f19a41105d Fixed orientation of boundary and corner patches
Now a boundary and corner patch remains
aligned with its underlying parametric
orientation. This simplifies both the
gathering of patch vertices and downstream
evaluation of patches.

Added a method to Vtr::Level which gathers
the 16 patch points for a B-spline patch
even if the patch has boundary or corner
edges.  The undefined patch vertex index
values along boundary and corner edges are
assigned Vtr::INDEX_INVALID.

In order to simplifiy the process of drawing
B-spline patches with boundary or corner
edges, the Far::PatchTablesFactory will
replace any invalid vertex indices with
a known good value, i.e. the index of the
first patch face vertex.

Single-crease patches are still a slightly
special case, which will be resolved later.
2015-04-24 15:33:04 -07:00
barfowl
0608230c7b Completed general limit tangent masks for Catmark:
- added general formulae for both Smooth and Crease tangent masks
    - further documented expectations of tangent masks in sdc/scheme.h
2015-04-24 14:36:38 -07:00
asluk
4e22fe0f69 Fix new off-by-one error in facevarying channels for lefthanded meshes. 2015-04-24 11:42:58 -07:00
asluk
ed07ed6a8f Merge remote-tracking branch 'upstream/dev' into dev 2015-04-23 21:23:29 -07:00
Takahito Tejima
74b78b3d17 Refactor again FarPatchTableFactory.
- rename "Regular end cap" to "BSplineBasis end cap"
- revert templating and add EndCapType into PatchTablesFactory::Options.
- make EndCapFactories internal in PatchTablesFactory.
- move end cap stencils into PatchTables, keep them relative to the max level.
- add a utility StencilTablesFactory::AppendEndCapStencilTables to splice and factorize endcap stencil tables.
2015-04-23 16:58:56 -07:00
asluk
c813d4b3a9 Retain initial vertex when reversing winding order for lefthanded meshes.
Add lefthanded mesh to vtr regression suite.
2015-04-23 12:01:15 -07:00
George ElKoura
0371a3aa5f Renamed methods on Far::PtexIndices.
GetNumPtexFaces() became GetNumFaces()
GetPtexIndex() became GetFaceId()
GetPtexAdjacency() became GetAdjacency()
2015-04-21 22:23:22 -07:00
George ElKoura
bded4cb075 Small clean up to how we validate the refiner when we build a PtexIndices. 2015-04-21 22:08:26 -07:00
George ElKoura
fcc1971767 Added an informative error check when passing in a refiner with an incompatible scheme to build PtexIndices. Also fixed an assert to not check for an explicit scheme type, and use traits instead. 2015-04-21 21:06:52 -07:00
George ElKoura
1ea3ec7958 Fixing comments. 2015-04-21 17:46:55 -07:00
George ElKoura
420473b45b Experiment separating out Ptex from TopologyRefiner.
Remove the ptex-specific code from the Far::TopologyRefiner and instead provide it in a separate class Far::PtexIndices.  Clients who need to use the Ptex API need to first build a Far::PtexIndices object by providing it with a refiner.

This has the advantage of keeping the API on the TopologyRefiner a little cleaner.  The ptex methods were const but were mutating state with const_casts.  The new mechanism still achieves the same lazy initialization behavior by forcing clients to instantiate them exactly when needed.

A disadvantage of this approach is that the PatchTablesFactory creates its own PtexIndices and throws it out after the patch tables are created.  This is great if you're never going to need the ptex indices again, but not so great if you will need them again.
2015-04-21 17:34:02 -07:00
David G Yu
7d9dcf8c03 Added a new screen-space adaptive tessellation metric which
computes edge lengths using limit surface points. Made this
the default screen-space metric so that we avoid cracks when
using Gregory Basis or Regular B-spline end caps.

The alternative method which computes edge lengths using the
distance between B-spline control points is still available.

Added a diagram and comments to explain how the control
points and limit points are organized.
2015-04-21 14:17:29 -07:00
Takahito Tejima
43aa2500c4 Refactor far factories.
This change moves all gregory patch generation from Far::PatchTablesFactory
so that we can construct patch tables without stencil tables as well as client
can chose any end patch strategies (we have 3 options for now: legacy 2.x style
gregory patch, gregory basis patch and experimental regular patch approximation).

Also Far::EndCapGregoryBasisPatchFactory provides index mapping from patch index
to vtr face index, which can be used for single gregory patch evaluation on top
of refined points, without involving heavier stencil tables generation.
2015-04-20 18:59:07 -07:00
Jeremy Cowles
2c3f519092 Merge pull request #425 from asluk/dev
Fixed off-by-1 error for lefthanded meshes in facevarying channels.
2015-04-18 21:43:27 -07:00
David G. Yu
9f1da077e8 Updated HLSL shaders for unified patch drawing 2015-04-18 14:08:53 -07:00
David G. Yu
cb689194ab Fixed windows build errors. 2015-04-17 18:29:56 -07:00
asluk
d164fb4650 Fixed off-by-1 error for lefthanded meshes in facevarying channels. 2015-04-17 18:14:59 -07:00
Takahito Tejima
c58e63c8d5 Refactor single crease patch to be in unfined shader. 2015-04-17 16:26:57 -07:00
Takahito Tejima
3d66bd449d Fixed boundary patch rotation flag 2015-04-17 15:43:33 -07:00
Takahito Tejima
aec1f61fb0 Merge pull request #422 from davidgyu/patch-drawing
Unified adaptive patch drawing
2015-04-17 15:39:37 -07:00
David G Yu
336fbb6748 Removed some more obsolete transition patch state
Temporarily disabled fractional tessellation for Gregory patches.
2015-04-17 15:24:48 -07:00
David G Yu
759513d2dc Fixed adaptive tessellation and removed debug code 2015-04-17 12:04:21 -07:00
David G Yu
010a31efc4 Checkpoint changes to unify adaptive patch drawing. 2015-04-17 07:42:53 -07:00
Jeremy Cowles
6efe3e0bce Merge pull request #418 from asluk/dev
osd3 support for lefthanded meshes
2015-04-16 16:59:05 -07:00
George ElKoura
bca5adacc6 Fix incorrect padding of manifold ring
We were incorrectly padding manifoldRing for end boundary vertices.
2015-04-16 12:41:31 -07:00
asluk
df3c856b51 Changed lefthanded flag to isLeftHanded. 2015-04-15 16:15:19 -07:00
asluk
4752bcdd69 Add support for lefthanded meshes. 2015-04-15 16:13:43 -07:00
George ElKoura
b2c77f234c Appease gcc warning about multi-line comments. 2015-04-10 23:21:50 -07:00
Takahito Tejima
0232ff5543 Fixes limit stencil evaluation on gregory basis patch. 2015-04-10 17:45:00 -07:00
Takahito Tejima
3b748e3b8d Fixes a gregory basis evaluation bug. 2015-04-10 17:44:33 -07:00
Takahito Tejima
7b37eb8cd6 #version 410 for XFB kernel and then OSX can run the XFB kernel. 2015-04-10 15:42:25 -07:00
Takahito Tejima
1e9ca564b0 remove subroutines from GLSL kernels. 2015-04-10 15:34:04 -07:00
barfowl
6ba910cd95 Added more functionality missing from stubs for Sdc limit masks:
- modified main LimitMask queries to include subdivision Rule
    - split internal mask assignments into corner, crease and smooth cases
    - adapted all three schemes to the new structure
    - completed limit tangents for Loop
    - update TopologyRefiner Limit methods to pass newly required Rule
2015-04-10 12:29:23 -07:00
Takahito Tejima
1ec0b2b1f2 add includes 2015-04-10 11:09:14 -07:00
Takahito Tejima
24a435da01 avoid lauching stencil kernel and not to allocate device tables if the stencil table is empty. 2015-04-10 11:08:51 -07:00
Takahito Tejima
214e62e67a add a constructor to FarStencilTables to initialze members. 2015-04-10 11:08:41 -07:00
Takahito Tejima
8da827336d Removes FarKernelBatch.
This is the first step to tease off Osd compute controller/contexts
from Far API.
Currently FarStencilTable only creates a kernelbatch for the entire range,
so we can use [0, numStencils) for all cases instead of KernelBatch.
This might not be true if we apply non-factorized level-wise stencils,
then we'll add another modular utility to serve those cases.
2015-04-10 11:08:24 -07:00
David G Yu
ecb824af10 Fixed topologyRefiner.cpp to include error.h 2015-04-10 09:19:08 -07:00
barfowl
bb3552c441 Added error messages to Far::TopologyRefiners main refinment methods 2015-04-09 21:08:26 -07:00
takahito-tejima
f52915227f Fix windows build 2015-04-08 21:10:00 -07:00
Takahito Tejima
24f9dc154b Enable GregoryBasis patch.
PatchTablesFactory fills 20 indices topology into patchtable, and use it for eval and draw.

note: currently screen-space adaptive tessellation of gregory basis patches is
broken and cracks appear around them.
2015-04-08 17:07:10 -07:00
barfowl
36c86b0b68 Correction to previous commit regarding Far vertex ordering options. 2015-04-01 21:00:29 -07:00
barfowl
898d68ae79 Minor additions and revisions to TopologyRefiner interface:
- new Options for Refine() methods for base face and vertex ordering
    - removed ignored/unused "full topology" choice from AdaptiveOptions
    - added base face and vertex ordering logic to Refinement
    - addition of TopologyRefiner members for component counts and max valence
    - refactoring of Level additions to update all new member totals
    - addition of GetMaxValence() to TopologyRefiner
    - updated PatchTablesFactory to user new GetMaxValence() method
    - renaming of "Hole" methods for TopologyRefiner and Vtr::Level
2015-04-01 20:44:33 -07:00
barfowl
9222c9e169 Removed use of "full topology" flag with Far::AdaptiveOptions:
- it was always ignored as full topology is required for PatchTables
    - it will soon be removed from AdaptiveOptions entirely
2015-04-01 14:57:28 -07:00
barfowl
068ea4c7fa Face-varying fixes to support non-manifold features:
- updated original FVar inspection to deal witn non-manifold vertices
    - updated FVar refinement to handle > 2 faces per edge
    - couple of fixes to use parent topology when child not present
2015-03-31 11:50:58 -07:00
George ElKoura
d38d683d0a Make sure to update the _maxEdgeFaces in the child from the parent
level before we do any further population from the parent as that may
further modify the child's _maxEdgeFaces.  When _maxEdgeFaces is incorrect
we may end up with stack corruption problems when
Far::TopologyRefiner::interpolateChildVertsFromEdges() goes to use this data
to allocate some stack space.
2015-03-30 18:49:26 -07:00
barfowl
72e2f8eb2b Added support for patches around non-manifold features:
- regular patches now generated for faces with non-manifold vertices
    - non-manifold features treated as boundary edges and vertices
    - other minor cleanup/improvement in patch identification method
    - commented on approx of smooth x-ordinary corner with regular sharp patch
2015-03-26 10:42:32 -07:00
barfowl
7ebb04bdcb Fixed bugs arising from degenerate edges and triangles:
- avoid repeated edges within the same face on construction
    - corrected degenerate edge detection in tri-split refinement
2015-03-24 17:37:37 -07:00
George ElKoura
9461201b52 Updated usage line for stringify. 2015-03-23 23:53:12 -07:00
barfowl
e583b80271 Completed support for non-manifold topology (degenerate, reversed edges, etc.):
- added edge-face local-indices to Vtr::Level members
    - added internal and public access to edge-face local-indices
    - updated refinement methods to use and populate edge-face local-indices
    - updated refinement methods to be sensitive to degenerate edges
    - added Vtr::VALENCE_LIMIT constant for internal use
    - updated Vtr::Level topology completion to fail on valence overflow
    - simplfied non-manifold edge handling in Vtr::Level topology completion
    - updated warnings for all topology construction failures
    - added detection and warning when passing non-triangles for Loop
2015-03-15 20:22:00 -07:00
jcowles
9529bf45bf Remove internal URL from topologyRefiner header 2015-03-13 23:46:22 -07:00
barfowl
9a41cf59c4 Minor revisions to recent promotion regarding smooth UV's in Far:
- changed return type of Vtr array empty() to bool
    - renamed and adjusted arguments to Vtr gather methods for consistency
    - removed lone Vtr gather method that took an explicit offset
    - updated usage of revised Vtr gather methods in Far
    - fixed warnings redeclaring names of local variables already in use
2015-03-05 13:09:27 -08:00
manuelk
9e25b193ff Fix Win build 2015-02-27 15:52:12 -08:00
manuelk
d0a624f373 Add "smooth UVs" to Far
- extend Far::PatchTables data structures & interfaces to store requisite
  information for channels of face-varying bi-cubic patches
- implement gather function in Far::PatchTablesFactory to populate face-varying
  channels with adaptive patches
- extend accessor interface in Vtr::Level
- propagate code fall-out throughout OpenSubdiv code base, examples & tutorials
- extend vtrViewer code to visualize tessellated bi-cubic face-varying patches
2015-02-26 13:57:47 -08:00
barfowl
4ced1b1461 Revised Level::VTags for semi-sharpness and added corner tag:
- added new tag for sharp corner, now used in isolation
    - split single semi-sharp tag in two for vertex and edge sharpness
    - updated tag propagation and all tests of previous semi-sharp tag
    - added clear() methods for all tags and simplified initialization
2015-02-25 20:02:10 -08:00
barfowl
6cb77507ec Fixed isolation bug with FVar data -- avoid false match with a regular patch. 2015-02-25 17:35:48 -08:00
barfowl
2213d86a59 Fixed bug retrieving and merging tags for FVar values:
- added Vtr::FVarLevel method to resolve correct index in level 0 case
    - updated tag retrieval methods that used face-value array as input
    - changed signatures to accept face-verts when needed and updated usage
2015-02-25 11:02:53 -08:00
barfowl
588c3060b3 Added Vtr::FVarLevel method to merge FVar edge tags with Vtr::Level::Etags 2015-02-17 14:16:35 -08:00
barfowl
7152b1b1bf More support for feature-adaptive consideration of face-varying topology:
- added methods to FVarLevel to combine FVar tags with vertex tags
    - use composite of combined tag to find FVar features needing isolation
    - added more tagging related to the "linear borders" interpolation case
2015-02-11 20:51:00 -08:00
manuelk
b1933194aa Fix data race on static global variable in Far::PatchDescriptor
- statically initialize valid patch descriptor tables
- return a Vtr::Array instead of std::vector
- fix dependencies in Far::PatchTables

fixes #394
2015-02-11 14:25:44 -08:00