Commit Graph

554 Commits

Author SHA1 Message Date
David G Yu
5db3b63faa Fixed OSD_REAL_CAST of some float constants
This avoids compile errors with some GLSL compilers.

Fixes #1285
2023-06-30 15:45:45 -07:00
David G Yu
76841aefa3 Removed 'centroid' qualifier from GLSL struct
This is not valid (See GLSLang Spec, Sec 4.3) and raises shader
compile time errors with some recent drivers.
2022-09-15 08:29:14 -07:00
Barry Fowler
0e574f7204 Fix more internal GCC warnings with -Wconversion 2022-09-14 14:52:01 -07:00
David G Yu
4f5b15ca26
Merge pull request #1244 from diekev/dev-ogl-program-cache
OpenGL Compute Evaluator: cache active program
2022-08-30 14:40:18 -07:00
Barry Fowler
810d7f671b Fix GCC warnings with current default flags:
- default flags include warnings enabled by -Wall and -Wextra
    - suppressed newer warnings in public headers and internal files
      (-Wclass-memaccess, -Wcast-function-type, -Wdeprecated-copy)
    - suppressed -Wunused-function from internal source files
2022-08-30 12:13:44 -07:00
Barry Fowler
647309a7d7 Improved mixed partial at Gregory patch corners:
- normalized the rational weights for pairs of interior points
    - fixed sign swap error in mixed partial of bilinear patches
    - applied changes to both far/patchBasis and osd/patchBasisCommon
2022-08-25 18:40:33 -07:00
Kévin Dietrich
38fe09c701 OpenGL Compute Evaluator: cache active program
Client applications may keep track of the active shader program so as to
not unnecessarily bind and unbind the same shader consecutively as
switching shaders is costly.

The current behavior of the OpenGL compute evaluator is to set the
active shader to 0 (zero) after running its program(s) which might
interfere with the aforemoentioned client applications' behavior,
leading to bugs.

Instead of unsetting any previously set shader program, cache the
current program before using the evaluator program, and reset the active
program to the previous one when done.

In Blender, this lead to some rendering artifacts. See https://
developer.blender.org/D15064 for more details on it.
2022-06-26 18:08:38 +02:00
David G Yu
a91707bae8 Fixed subobject initialization warnings
Fixed a few code sites where subobject initializers were missing braces.
2021-10-20 14:55:59 -07:00
David G Yu
82988d04ad Updated EXT to ARB for GL direct_state_access
The ARB_direct_state_access API is more consistent with
the 4.5 and 4.6 core API and is also more widely supported.
2020-03-06 11:37:55 -08:00
David G Yu
f3f28995a5 Enabled internal GL API loader as GLEW alternative
At build time, the preprocessor symbols: OSD_USES_GLEW or
OSD_USES_INTERNAL_GLAPILOADER determine the GL API loader
that will be used by the OSD library.
2020-03-06 11:37:55 -08:00
David G Yu
28f2574bc5 Moved GLEW dependencies to glLoader wrapper
This introduces an internal glLoader library which allows
most of the implementation to be agnostic about the
implementation of the GL loading library.  Specifically,
this removes references to the GLEW headers and libraries
from the rest of the source code and build system.
2020-03-03 17:10:30 -08:00
George ElKoura
92341f7c1e Prefix OpenSubdiv CMake macros
This fixes issue #1157 by adding "osd" as a prefix to public macros.
2019-08-17 16:44:30 -07:00
David G Yu
5c8cdf9121 Fixed regression in MTLComputeEvaluator
Fixed the initialization of patchArray and patchParam
in the implementation of the MTLComputeEvaluator::EvalPatches()
compute kernel.
2019-06-24 16:47:56 -07:00
David G Yu
f881c49a5b Minor revisions to some Osd deprecation notes
Several of the methods in osd/patchBasisCommon.h were
never intended as public API, and several have been
deprecated in favor of the newer OsdEvaluatePatchBasis()
and OsdEvaluatePatchBasisNormalized() methods. These
obsolete methods have now all be marked as deprecated.

Also, fixed a minor spelling typo in glslPatchBasisCommon.glsl
2019-06-10 15:29:03 -07:00
David G Yu
67cc2a3810 Irregular patch shader transition edges
Updated the Gregory patch tessellation shaders to account for
transition edges.

Changed the implementation of OsdGetTessParameterizationTriangle()
to take the input parametric location as a 3-component value. This
allows the edge parameterization to be more numerically robust and
consistent.

Also, corrected some minor discrepancies between the various
tessellation shader configurations.
2019-06-03 15:34:40 -07:00
David G Yu
2e175ff52b Mtl implementation mtlViewer organization
Refactored computation and drawing code used
for tessellated patches to improve readability
and extensibility.

- Updated mtlViewer.metal computation kernel to express
  data indexing using familiar semantic concepts: i.e.
  primitiveID, vertexID, etc. instead of threadgroup
  semantics.
- Updated mtlViewer.mm to consolidate patch type
  dispatch. Now, the configuration and execution
  of the compute and drawing passes is controlled
  by a PipelineConfig descriptor.
2019-05-30 10:00:55 -07:00
David G Yu
232d50c231 Mtl implementation cleanup thread dispatch
Moved some of the boiler-plate code related to
thread group dispatching and configuration from
the osd shader source to the example shader source.
2019-05-30 00:47:50 -07:00
David G Yu
cc6c9da070 Mtl implementation drawing triangle patches
Updated Metal shaders to add support for drawing triangle
patches. This matches the current GLSL implementation.

- BoxSplineTriangle and GregoryTriangle patch shaders
- tess factor and tess evalutation for triangle patches
- improved adaptive tessellation code organization and function names
- quartic Bezier triangle patch evaluation
- OsdGetPatchIsTriangleRotated() function added
- OsdInterpolatePatchCoordTriangle() function added
2019-05-30 00:47:50 -07:00
David G Yu
ebf2917dc7 Mtl implementation fixed example fvar interp
Refactored the Metal viewer's implementation of
smooth face-varying uv interpolation so that the
face-varying patch basis is correctly determined
by inspecting the face-varying patch array type
descriptors.
2019-05-30 00:47:45 -07:00
David G Yu
8912b3f3d3 Mtl implementation screenspace fvar interp
Fixed smooth face-varying interpolation for the Metal viewer
when using screen-space tessellation. The location to evaluate
the face-varying value needs to match the computed tess location
instead of the intrinsic position_in_patch.
2019-05-28 10:02:08 -07:00
David G Yu
11bcf82632 Mtl implementation common tess shader source
Moved Metal shader code which computes tessellation factors and
tessellation parameterization into a separate source file.
2019-05-28 10:02:04 -07:00
David G Yu
9cc0cb2c01 Mtl implementation fixed typo in shader source
Fixed a misspelling in a macro: BOUNDRY -> BOUNDARY which was
preventing the Metal legacy gregory shader source from being
compiled correctly.
2019-05-24 12:39:20 -07:00
David G Yu
770c8a45e2 Mtl implementation legacy gregory shader
This migrates a fix from the legacy GLSL shader code
to improve consistency between the implementions.
2019-05-24 12:36:52 -07:00
David G Yu
1ae203ed20 Mtl implementation legacy shader code
Moved Metal shader code used for evaluation of legacy gregory patches
to a separate source file.

These methods should not be used for new development, but are provided
for backward compatibility.
2019-05-22 18:40:58 -07:00
David G Yu
291eff0bed Mtl implementation whitespace fixes
Fixed numerous whitespace inconsistencies and violations
in the core osd metal implementation and examples.
2019-05-22 18:00:36 -07:00
David G Yu
556d1dda79 Added HLSL support for drawing triangle patches
This matches the current GLSL implementation:

- BoxSplineTriangle and GregoryTriangle patch shaders
- tess factor and tess evalutation for triangle patches
- improved adaptive tessellation code organization and function names
- quartic Bezier triangle patch evaluation
- OsdGetPatchIsTriangleRotated() function added
- OsdInterpolatePatchCoordTriangle() function added
2019-04-26 11:07:56 -07:00
David G Yu
aa0def2b95 Moved HLSL tess factor code to separate file
Moved shader code which computes tessellation factors and
tessellation parameterization into a separate source file.
2019-04-26 10:58:02 -07:00
David G Yu
fda4ded404 Fixed HLSL legacy gregory shader valence limit
THis migrates a fix from the legacy GLSL shader code
to improve consistency between the implementions.
2019-04-26 10:58:02 -07:00
David G Yu
08997ef2b2 Moved HLSL legacy shader code to separate file
Moved shader code used for evaluation of legacy gregory patches.

These methods should not be used for new development, but are provided
for backward compatibility.
2019-04-26 10:57:56 -07:00
George ElKoura
c34cc0a7fe A few minor fixes for Gregory Patches in DirectX
- Make sure to initialize all structs properly when using gregory
patches

- Rename a loop variable to avoid shader compiler warning.
2019-04-01 00:22:11 -07:00
barry
1cdbb7246a Minor improvement to degenerate normals in GLSL Bezier triangle:
- negate derivative terms when evaluating points on edge where u + v = 1
2019-02-11 18:05:08 -08:00
barry
479a297bc6 Correction to recent changes to boundary weights of box-spline triangles:
- fixed corner vertex cases (two boundary edges) in both Far and Osd
2019-02-06 18:30:26 -08:00
David G Yu
abb8af32c5 Minor changes to BoxSplineTri boundary computation
The computation to adjust patch evaluation weights
for box spline triangle patches to account for boundaries
has been updated to use simple conditional logic instead
of index indirection tables. This results in better register
resource usage for some shader compiler implementations.
Previously, these methods could fail to compile on some
systems.
2019-02-05 12:57:41 -08:00
David G Yu
e4375aea9e
Merge pull request #1048 from barfowl/glsl_adaptive_tess_levels
Minor refactoring of GLSL functions to compute adaptive tess levels
2019-01-31 00:54:06 -08:00
Barry Fowler
cbbfc5b64b
Merge pull request #1049 from davidgyu/glsl_gregory_tri_varying_fix 2019-01-30 20:10:11 -08:00
barry
e8fdec9f88 Made use of newer GLSL adaptive tess functions in patch shaders:
- replaced use of "LimitPoints" functions in all patch shaders
    - removed the unreleased "LimitPointsTriangle" functions
    - added internal tess functions for processing patch boundaries
    - updated Bezier quad and tri tess evaluation to use boundary functions
2019-01-30 10:25:04 -08:00
barry
e8859cac85 Added GLSL adaptive tess functions to reflect associated patch types:
- renamed core "LimitPoints" functions to reflect the patch type (Bezier)
    - overloaded new functions with the additionally computed tess level
    - preserved stubs of all "LimitPoints" functions for compatibility
2019-01-30 10:12:15 -08:00
barry
73f4ab5db7 Added normal derivatives to GLSL Bezier triangle evaluation:
- added alternate intermediate calculations for normal derivatives
    - use normal derivates to resolve a degenerate normal
2019-01-28 10:20:31 -08:00
David G Yu
0545056271 Fixed varying interp for gregory triangle patches
The point indices used to interpolate varying data should
be the points at the outer corners of the patch.
2019-01-25 19:15:45 -08:00
barry
a0e72d80c3 Changed Gregory triangle from cubic/quartic hyrid to full quartic:
- changed Far::PatchDescriptor size for GREGORY_TRIANGLE to 18
    - modified Far::LoopPatchBuilder to construct full quartic Gregory patch
    - fixed Far::LoopPatchBuilder bug related to face points near boundaries
    - updated Far patch basis evaluation for Gregory and Bezier triangles
    - updated Osd patch basis evaluation to match Far
    - updated Osd GLSL patch size for Gregory triangle to 18
    - modified Osd GLSL Gregory triangle eval and tess settings for quartic
2019-01-24 12:56:09 -08:00
barry
7ab065a0c4 Changed GLSL conversion of regular Loop patch to quartic Bezier:
- updated sizes for the Box-spline triangle shader to generate 15 points
    - updated conversion of Box-spline from hybrid Bezier to fully quartic
    - added resolution of degenerate normal to Bezier triangle evaluation
    - updated hybrid Gregory triangle conversion to quartic Bezier
    - updated adaptive tessellation of Bezier triangle for quartic boundaries
2019-01-22 09:48:19 -08:00
David G Yu
83486cddae Added GLSL support for drawing triangle patches
- Added GLSL patch shaders for BoxSplineTriangle and GregoryTriangle
  patches. These both convert to a hybrid Bezier patch for drawing
  similar to the basis conversion done for quad patches.
- Added evaluation of hybrid Bezier triangle patches and
  GregoryTriangle patches to the common shader source.
- Added OsdGetPatchIsTriangleRotated() to detect rotated triangles.
- Added OsdInterpolatePatchCoordTriangle() for eval of triangle patches.
- Added boundary point extrapolation for BoxSplineTriangle patches.
- Fixed boundary point extrapolation for unisolated BSpline patches.
- Added tess factor and tess evaluation location computation for
  triangle patches.
- Limit surface edge mid points for both quad and triangle patches
  are now computed directly.
2019-01-18 18:18:45 -08:00
David G Yu
494f45605f Moved GLSL tess factor code to separate file
Moved shader code which computes tessellation factors and
tessellation parameterization into a separate source file.
2019-01-18 18:17:38 -08:00
David G Yu
2ccd70fec3 Moved GLSL legacy shader code to separate file
Moved shader code used for evaluation of legacy gregory patches
to a separate source file along with macros which implement
simple linear face-varying interpolation.

These should not be used for new development, but are provided
for backward compatibility.
2019-01-18 18:15:43 -08:00
David G Yu
d855643b80 Fixed osd patch basis typos and macros 2019-01-18 18:14:00 -08:00
David G Yu
ff34c514f5 Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.

This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.

Changes:
    - Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
    - Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
    - exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
    - Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
    - Updated glFVarViewer
2018-11-15 17:11:50 -08:00
barry
484c2746d1 Minor refactoring of internal functions in far/patchBasis.*:
- individual basis functions now purely normalized with no PatchParam
    - two new higher level functions deal with patch type and PatchParam
    - updated Far::PatchTable and Osd evaluators that used old methods
2018-11-06 13:29:16 -08:00
David G Yu
c5c9704b90
Merge pull request #1003 from barfowl/tri_patch_support
Added low-level support in Far for triangular patches
2018-10-03 17:44:01 -07:00
barry
d6572ab226 Updated Osd evaluators to deal with changes to PatchParam boundary:
- updated evaluators to extract the extended 5-bit mask from PatchParam
2018-09-27 20:13:01 -07:00
barry
89c4ce78b7 Corrected initialization of patch arrays in Osd::CpuPatchTable
- assigned appropriate patch count and base offsets to varying arrays
    - assigned appropriate patch count and base offsets to face-varying arrays
    - fixed append to face-varying PatchParam buffer for each array
2018-09-25 15:13:55 -07:00