Merge branch 'spline/bezier'

This commit is contained in:
xebra 2014-11-26 16:37:18 +09:00
commit 3c1f4b5cb7
5 changed files with 21 additions and 31 deletions

View File

@ -266,7 +266,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr,
if (!g_Config.bSoftwareSkinning && (vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE) {
int numBoneWeights = vertTypeGetNumBoneWeights(vertType);
for (int i = lowerBound; i <= upperBound; i++) {
reader.Goto(i);
reader.Goto(i - lowerBound);
SimpleVertex &sv = sverts[i];
if (vertType & GE_VTYPE_TC_MASK) {
reader.ReadUV(sv.uv);
@ -313,7 +313,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr,
}
} else {
for (int i = lowerBound; i <= upperBound; i++) {
reader.Goto(i);
reader.Goto(i - lowerBound);
SimpleVertex &sv = sverts[i];
if (vertType & GE_VTYPE_TC_MASK) {
reader.ReadUV(sv.uv);

View File

@ -162,7 +162,7 @@ void _SplinePatchLowQuality(u8 *&dest, int &count, const SplinePatchLocal &spatc
}
void _SplinePatchFullQuality(u8 *&dest, int &count, const SplinePatchLocal &spatch, u32 origVertType, int patch_cap) {
void _SplinePatchFullQuality(u8 *&dest, int &count, const SplinePatchLocal &spatch, u32 origVertType, int quality) {
// Full (mostly) correct tessellation of spline patches.
// Not very fast.
@ -177,16 +177,12 @@ void _SplinePatchFullQuality(u8 *&dest, int &count, const SplinePatchLocal &spa
// Increase tesselation based on the size. Should be approximately right?
// JPCSP is wrong at least because their method results in square loco roco.
int patch_div_s = (spatch.count_u - 3) * gstate.getPatchDivisionU() / 3;
int patch_div_t = (spatch.count_v - 3) * gstate.getPatchDivisionV() / 3;
int patch_div_s = (spatch.count_u - 3) * gstate.getPatchDivisionU() / quality;
int patch_div_t = (spatch.count_v - 3) * gstate.getPatchDivisionV() / quality;
if (patch_div_s <= 0) patch_div_s = 1;
if (patch_div_t <= 0) patch_div_t = 1;
// TODO: Remove this cap when spline_s has been optimized.
if (patch_div_s > patch_cap) patch_div_s = patch_cap;
if (patch_div_t > patch_cap) patch_div_t = patch_cap;
// First compute all the vertices and put them in an array
SimpleVertex *vertices = new SimpleVertex[(patch_div_s + 1) * (patch_div_t + 1)];
@ -320,10 +316,10 @@ void TesselateSplinePatch(u8 *&dest, int &count, const SplinePatchLocal &spatch,
_SplinePatchLowQuality(dest, count, spatch, origVertType);
break;
case MEDIUM_QUALITY:
_SplinePatchFullQuality(dest, count, spatch, origVertType, 8);
_SplinePatchFullQuality(dest, count, spatch, origVertType, 2);
break;
case HIGH_QUALITY:
_SplinePatchFullQuality(dest, count, spatch, origVertType, 64);
_SplinePatchFullQuality(dest, count, spatch, origVertType, 1);
break;
}
}
@ -479,6 +475,8 @@ void TesselateBezierPatch(u8 *&dest, int &count, int tess_u, int tess_v, const B
_BezierPatchLowQuality(dest, count, tess_u, tess_v, patch, origVertType);
break;
case MEDIUM_QUALITY:
_BezierPatchHighQuality(dest, count, tess_u / 2, tess_v / 2, patch, origVertType);
break;
case HIGH_QUALITY:
_BezierPatchHighQuality(dest, count, tess_u, tess_v, patch, origVertType);
break;

View File

@ -877,7 +877,7 @@ void GLES_GPU::Execute_Bezier(u32 op, u32 diff) {
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
if (gstate.getPatchPrimitiveType() != GE_PATCHPRIM_TRIANGLES) {
if (gstate.getPatchPrimitiveType() == GE_PATCHPRIM_UNKNOWN) {
ERROR_LOG_REPORT(G3D, "Unsupported patch primitive %x", gstate.getPatchPrimitiveType());
return;
}
@ -918,7 +918,7 @@ void GLES_GPU::Execute_Spline(u32 op, u32 diff) {
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
if (gstate.getPatchPrimitiveType() != GE_PATCHPRIM_TRIANGLES) {
if (gstate.getPatchPrimitiveType() == GE_PATCHPRIM_UNKNOWN) {
ERROR_LOG_REPORT(G3D, "Unsupported patch primitive %x", gstate.getPatchPrimitiveType());
return;
}

View File

@ -31,14 +31,11 @@ u32 TransformDrawEngine::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inP
return DrawEngineCommon::NormalizeVertices(outPtr, bufPtr, inPtr, dec, lowerBound, upperBound, vertType);
}
const GEPrimitiveType primType[] = { GE_PRIM_TRIANGLES, GE_PRIM_LINES, GE_PRIM_POINTS };
void TransformDrawEngine::SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertType) {
Flush();
if (prim_type != GE_PATCHPRIM_TRIANGLES) {
// Only triangles supported!
return;
}
u16 index_lower_bound = 0;
u16 index_upper_bound = count_u * count_v - 1;
bool indices_16bit = (vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT;
@ -101,7 +98,7 @@ void TransformDrawEngine::SubmitSpline(void* control_points, void* indices, int
gstate_c.uv.vOff = 0;
}
int bytesRead;
SubmitPrim(decoded2, quadIndices_, GE_PRIM_TRIANGLES, count, vertTypeWithIndex16, &bytesRead);
SubmitPrim(decoded2, quadIndices_, primType[prim_type], count, vertTypeWithIndex16, &bytesRead);
Flush();
@ -113,11 +110,6 @@ void TransformDrawEngine::SubmitSpline(void* control_points, void* indices, int
void TransformDrawEngine::SubmitBezier(void* control_points, void* indices, int count_u, int count_v, GEPatchPrimType prim_type, u32 vertType) {
Flush();
if (prim_type != GE_PATCHPRIM_TRIANGLES) {
// Only triangles supported!
return;
}
u16 index_lower_bound = 0;
u16 index_upper_bound = count_u * count_v - 1;
bool indices_16bit = (vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT;
@ -170,8 +162,8 @@ void TransformDrawEngine::SubmitBezier(void* control_points, void* indices, int
// 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;
int tess_u = gstate.getPatchDivisionU() / num_patches_u;
int tess_v = gstate.getPatchDivisionV() / num_patches_v;
int tess_u = gstate.getPatchDivisionU();
int tess_v = gstate.getPatchDivisionV();
if (tess_u < 4) tess_u = 4;
if (tess_v < 4) tess_v = 4;
@ -194,7 +186,7 @@ void TransformDrawEngine::SubmitBezier(void* control_points, void* indices, int
}
int bytesRead;
SubmitPrim(decoded2, quadIndices_, GE_PRIM_TRIANGLES, count, vertTypeWithIndex16, &bytesRead);
SubmitPrim(decoded2, quadIndices_, primType[prim_type], count, vertTypeWithIndex16, &bytesRead);
Flush();
if (g_Config.bPrescaleUV) {

View File

@ -145,12 +145,12 @@ TransformDrawEngine::TransformDrawEngine()
quadIndices_ = new u16[6 * QUAD_INDICES_MAX];
for (int i = 0; i < QUAD_INDICES_MAX; i++) {
quadIndices_[i * 6 + 0] = i * 4;
quadIndices_[i * 6 + 0] = i * 4 + 0;
quadIndices_[i * 6 + 1] = i * 4 + 2;
quadIndices_[i * 6 + 2] = i * 4 + 1;
quadIndices_[i * 6 + 3] = i * 4 + 1;
quadIndices_[i * 6 + 4] = i * 4 + 2;
quadIndices_[i * 6 + 5] = i * 4 + 3;
quadIndices_[i * 6 + 3] = i * 4 + 3;
quadIndices_[i * 6 + 4] = i * 4 + 1;
quadIndices_[i * 6 + 5] = i * 4 + 2;
}
if (g_Config.bPrescaleUV) {