Commit Graph

43 Commits

Author SHA1 Message Date
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
984aedf842 Changed default draw modes for dxViewer
This restores the previous defaults and works around an
apparent runtime error on some platforms which is triggered
in the legacy gregory patch drawing code when patch culling
is disabled.
2015-05-14 12:48:36 -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
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
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
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
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
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
6ac11ae63b Fixed a bug in the display of the dxViewer cursor
Make sure to initialize the cursor of the window class in dxViewer as required.
2015-04-18 00:45:02 -07:00
David G. Yu
acedb6c710 Fixed windows build regressions. 2015-04-17 18:28:38 -07:00
manuelk
866b88b7c9 Add support for single-crease patches to D3D draw context & controller
- also updated the dxViewer code example

note: dxPtexViewer still needs to be updated
2015-02-08 17:31:55 -08:00
barfowl
9bb98a94fd Renaming of a few Sdc types and constants:
- renamed Sdc::Type to SchemeType and TypeTraits to SchemeTypeTraits
    - renamed TYPE_ prefix to SCHEME_
    - updated all usage within core library
    - updated all usage in examples, tutorials, etc.
2015-01-06 17:40:11 -08:00
barfowl
865fe5591f Modified Far::TopologyRefinerFactory<>::Create() take new Options as argument
- update examples, tutorials, regressions, etc. accordingly
2015-01-06 00:03:21 -08:00
manuelk
48cf4b6528 Refactor Vtr::Array for better "const" safety
Const' declared instances of Vtr::Array do not protect the pointer held
privately by the class properly. In order to force the compiler to
protect this pointer, we removed all non-const accessors from Vtr::Array
(now renamed Vtr::ConstArray) and moved them to a child class (Vtr::Array),
which requires const_cast<> operators internally to allow access.

The change & renaming is then propagated to all internal dependencies.
2014-12-15 10:23:13 -08:00
manuelk
cc6c0925a3 Refactor error reporting system
- change error codes from situational to general (fatal / coding / run-time...)
- pull error functions from Osd into Far
- add a templated topology validation reporting system to Far::TopologyRefinerFactory
- fix fallout on rest of code-base
2014-12-03 17:19:07 -08:00
manuelk
538c13f394 Fix Windows build 2014-11-25 14:14:59 -08:00
David G. Yu
cc71c8e741 Fixed Osd namespace use in DX examples. 2014-10-23 13:48:55 -07:00
manuelk
c399655dcc Landing 3.0.0.alpha
Sync'ing the 'dev' branch with the 'feature_3.0dev' branch at commit 68c6d11fc36761ae1a5e6cdc3457be16f2e9704a

The branch 'feature_3.0dev' is now locked and preserved for historical purposes.
2014-09-05 15:07:46 -07:00
Sergey Sharybin
6ef232c95a Integrate CLEW into osd library and examples
If the system has CLEW installed (which is detected by recently
added FindCLEW routines) then OpenSubduv would be compiled against
this library.

It makes binaries and libraries more portable across the systems,
so it's possible to run the same binary on systems with and without
OpenCL SDK installed.

The most annoying part of the change is updating examples to load
OpenCL libraries, but ideally code around controllers and interface
creation is to be de-duplicated anyway.

Based on the pull request #303 from Martijn Berger
2014-05-22 09:10:59 +02:00
Nathan Litke
2a463b5c83 Draw contexts do not fully initialize patch arrays #281
* added the numVertexElements argument to Osd*DrawContext::Create, which is used to initialize the patch arrays when calling OsdDrawContext::ConvertPatchArrays
* removed the unused level argument from Osd*DrawContext::_initialize
* maintenance work on CL/D3D11 bindings to get them to compile
2014-04-17 18:55:07 -07:00
manuelk
0bda8963e9 Adding the ability to read obj files to the dxViewer example
(passed from command line!)
2014-01-22 15:36:08 -08:00
manuelk
8918173fda Improve stringification of shaders & kernels in build.
- added a _stringify function to top CMakeLists
- switched all stringification tasks to use the macro
- all suffixes are now .gen.h instead of .inc (to help cmake track dependencies)
2014-01-03 16:59:26 -08:00
Takahito Tejima
f7f2ca2581 Move uniform block definitions out of osd common shader into client shader.
Important notice: all client shader code must have following functions and compose them to osd intrinsic shaders (vertex/tessEval/tessControl)

mat4 OsdModelViewMatrix()
mat4 OsdProjectionMatrix()
mat4 OsdModelViewProjectionMatrix()
float OsdTessLevel()
int OsdGreogryQuadOffsetBase()
int OsdPrimitiveIdBase()

We probably should write a utility class for basic binding of them, to make client code simpler.
2013-12-03 15:59:38 -08:00
manuelk
3ae50d1c50 Amending Apache license language & file headers.
New text:

     Copyright 2013 Pixar

     Licensed under the Apache License, Version 2.0 (the "Apache License")
     with the following modification; you may not use this file except in
     compliance with the Apache License and the following modification to it:
     Section 6. Trademarks. is deleted and replaced with:

     6. Trademarks. This License does not grant permission to use the trade
        names, trademarks, service marks, or product names of the Licensor
        and its affiliates, except as required to comply with Section 4(c) of
        the License and to reproduce the content of the NOTICE file.

     You may obtain a copy of the Apache License at

         http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the Apache License with the above modification is
     distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied. See the Apache License for the specific
     language governing permissions and limitations under the Apache License.
2013-09-26 12:04:57 -07:00
David G Yu
fb2a519d52 Added cmdline obj loading to the DX11 viewer 2013-08-17 13:33:52 -07:00
Takahito Tejima
51a45b598d Updating EULA 2013-07-18 14:19:50 -07:00
Takahito Tejima
a13c0565e4 Renamed texture buffers and uniforms
g_VertexBuffer -> OsdVertexBuffer
g_ValenceBuffer -> OsdValenceBuffer
g_QuadOffsetBuffer -> OsdQuadOffsetBuffer
g_ptexIndicesBuffer -> OsdPatchParamBuffer
g_uvFVarBuffer -> OsdFVarDataBuffer
LevelBase -> PrimitiveIdBase
2013-07-18 12:57:26 -07:00
David G Yu
c6eff9860a Fixed dxviewer clear color to be in sRGB space 2013-07-02 10:09:45 -07:00
David G Yu
c94c928fe9 Fixed file execute permissions 2013-06-28 17:02:16 -07:00
Takahito Tejima
e030157f73 Add varying buffer handling to OsdMesh.
Fix a bug that breaks varying interpolation on cuda kernel
Clean up glViewer with some new functions : varying color, screen space lod, patch culling
2013-06-27 12:57:21 -07:00
Takahito Tejima
b16272d6a5 more msvc fixes. make dxViewer working. 2013-05-14 10:48:48 -07:00
David G Yu
2a12b21ab2 Removed mutex implementation.
We added this to support earlier versions
of hbr, but it is no longer needed.
2013-05-07 11:27:14 -07:00
manuelk
e6e7c96a52 We need to leverage our per-patch ptex indexing scheme in the EvalLimit API.
- replace ptex indexing with the FarPtexCoord structure as a way to pass per-patch
  ptex data to the shaders.

  We are replacing a vector<int> arranged as :
  int[0] : ptex face index
  int[1] : (u,v) as 16 bits encoding the log2 coordinate of the top left corner

  Instead we are now using a struct arranged as :
  int[0] : ptex face index
  int[1] : is a bit-field containing u,v, rotation, depth and non-quad

  The u,v coordinates have been reduced to 10 bits instead of 16, which still
  gives us a lot of margin.

- Replace OsdVertexBufferDescriptor with something more adequate for general
  primvar representation (this name will probably eventually change...)

- Improve OsdPatchDescriptor
    - add a "loop" boolean (true if the patch is of loop type)
    - add a GetPatchSize() accessor

- OsdPatchArray :
    - remove some redundant elements (still more to do there)

- Fix all shader / examples / regressions & stuff to make this all work.

fixes #143
2013-03-22 18:20:50 -07:00
David G Yu
036ec2e189 Updated DX11 viewer to use std::string shapes. 2013-03-19 15:38:44 -07:00
Takahito Tejima
291debd4a9 change access permissions on files 2013-03-08 08:57:42 -08:00
Takahito Tejima
8efecb0fca Batching stuffs: generalized kernel batches, table/dispatcher refactoring, multiMeshFactory, drawContext, etc.
2 client APIs are changed.
- VertexBuffer::UpdateData() takes start vertex offset
- ComputeController::Refine() takes FarKernelBatchVector

Also, ComputeContext no longer holds farmesh.
Client can free farmesh after OsdComputeContext is created.
(but still need FarKernelBatchVector to apply subdivision kernels)
2013-03-07 17:50:15 -08:00
David G Yu
452b30f72f OsdMesh no longer owns its ComputeController
Now a ComputeController is passed as an
argument to OsdMesh::Create(). This is
a better match to the underlying object
model and can be much more efficient for
compute controllers that have expensive
resources, e.g. compiled shader kernels.

Fixes #103
2013-02-19 17:33:32 -08:00
manuelk
2baa3c82c1 removing some crusty tabs & other minor formatting 2013-01-10 11:14:41 -08:00
David G Yu
950fa35180 Exposed DirectCompute by default in the DX11Viewer 2012-12-17 09:50:21 -08:00
David G Yu
7ca59fab69 Fixed default display modes in example viewers
Now the GL and DX11 viewers display surface+wire by default and display the correct keep-alive animation status.
2012-12-13 10:23:33 -08:00
manuelk
10c687ecd5 Release Candidate 1.0 :
- [Feature Adaptive GPU Rendering of Catmull-Clark Surfaces](http://research.microsoft.com/en-us/um/people/cloop/tog2012.pdf).

- New API architecture : we are planning to lock on to this new framework as the basis for backward compatibility, which we will enforce from Release 1.0 onward. Subsequent releases of OpenSubdiv should not break client code.

- DirectX 11 support

- and much more...
2012-12-10 17:15:13 -08:00