Skip to content

Commit

Permalink
Allow tessellation with less than a 4 factor.
Browse files Browse the repository at this point in the history
Per tests on real hardware, this is allowed.  It works fine without the
clamping and matches the result on hardware.
  • Loading branch information
unknownbrackets committed Apr 10, 2016
1 parent 277b76e commit 808c807
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions GPU/Common/SplineCommon.cpp
Expand Up @@ -880,6 +880,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
DispatchFlush();

// Real hardware seems to draw nothing when given < 4 either U or V.
// This would result in num_patches_u / num_patches_v being 0.
if (count_u < 4 || count_v < 4)
return;

Expand Down Expand Up @@ -911,7 +912,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
// Bezier patches share less control points than spline patches. Otherwise they are pretty much the same (except bezier don't support the open/close thing)
int num_patches_u = (count_u - 1) / 3;
int num_patches_v = (count_v - 1) / 3;
BezierPatch* patches = new BezierPatch[num_patches_u * num_patches_v];
BezierPatch *patches = new BezierPatch[num_patches_u * num_patches_v];
for (int patch_u = 0; patch_u < num_patches_u; patch_u++) {
for (int patch_v = 0; patch_v < num_patches_v; patch_v++) {
BezierPatch& patch = patches[patch_u + patch_v * num_patches_u];
Expand Down Expand Up @@ -943,18 +944,13 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
int count = 0;
u8 *dest = splineBuffer;

// Simple approximation of the real tesselation factor.
// We shouldn't really split up into separate 4x4 patches, instead we should do something that works
// like the splines, so we subdivide across the whole "mega-patch".
if (num_patches_u == 0) num_patches_u = 1;
if (num_patches_v == 0) num_patches_v = 1;
if (tess_u < 4) tess_u = 4;
if (tess_v < 4) tess_v = 4;

u16 *inds = quadIndices_;
int maxVertices = SPLINE_BUFFER_SIZE / vertexSize;
for (int patch_idx = 0; patch_idx < num_patches_u*num_patches_v; ++patch_idx) {
BezierPatch& patch = patches[patch_idx];
const BezierPatch &patch = patches[patch_idx];
TesselateBezierPatch(dest, inds, count, tess_u, tess_v, patch, origVertType, maxVertices);
}
delete[] patches;
Expand Down

0 comments on commit 808c807

Please sign in to comment.