Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 0d7a5cd
Author: xebra <[email protected]>
Date:   Mon Oct 8 00:29:41 2018 +0900

    GLES: Fix to delete subimage data since hrydgard#11447.

commit 46d30d0
Author: xebra <[email protected]>
Date:   Tue Oct 2 21:13:40 2018 +0900

    [spline/bezier]minor fix

commit eca9386
Author: xebra <[email protected]>
Date:   Mon Oct 1 12:54:14 2018 +0900

    [spline/bezier]Reduce static buffers. Get rid of the spline buffer using half of the vertex buffer.

commit 5f07213
Author: xebra <[email protected]>
Date:   Sun Sep 30 17:10:58 2018 +0900

    [spline/bezier]minor fix

commit 5f9022a
Author: xebra <[email protected]>
Date:   Sun Sep 30 11:07:28 2018 +0900

    [spline/bezier]minor fix

commit 405ead8
Author: xebra <[email protected]>
Date:   Sat Sep 29 18:04:32 2018 +0900

    [spline/bezier]Get rid of duplication call of Flush().

commit ef53195
Author: xebra <[email protected]>
Date:   Sat Sep 29 13:39:02 2018 +0900

    [spline/bezier]Surround with namespace Spline.

commit 1dfb402
Author: xebra <[email protected]>
Date:   Sat Sep 29 01:15:38 2018 +0900

    [spline/bezier]Remove comment.

commit 10afcf2
Author: xebra <[email protected]>
Date:   Thu Sep 27 20:57:30 2018 +0900

    [spline/bezier]Improve basic spline/bezier structures.

commit 8ad38df
Author: xebra <[email protected]>
Date:   Mon Sep 24 20:12:28 2018 +0900

    [spline/bezier]oops

commit c49d9e2
Author: xebra <[email protected]>
Date:   Sun Sep 23 14:24:23 2018 +0900

    [spline/bezier]minor fix(referenced to c1f0e98).

commit 41823f8
Author: xebra <[email protected]>
Date:   Sat Sep 22 22:06:40 2018 +0900

    [spline/bezier]Fix GLES texture resolution of HW tess to real 2D to avoid huge width in FF4CC mist dragon morphing.

commit 89786b9
Author: xebra <[email protected]>
Date:   Sat Sep 22 19:20:30 2018 +0900

    [spline/bezier]Instanced rendering for B-Spline is very slow when using weak GPU, so disabled it and simplify the shaders.
    Add changing the quality of HW tessellation.

commit d98fa06
Author: xebra <[email protected]>
Date:   Fri Aug 31 20:10:02 2018 +0900

    [spline/bezier]Fix to build for Android(clang).

commit 019e276
Author: xebra <[email protected]>
Date:   Thu Aug 9 19:29:19 2018 +0900

    [spline/bezier]Modify ControlPoints and fix VertexPreview.

commit 1c604d5
Author: xebra <[email protected]>
Date:   Tue Jul 31 04:12:12 2018 +0900

    [spline/bezier]Put the control points stuffs all in one structure.

commit 6683351
Author: xebra <[email protected]>
Date:   Mon Jul 30 19:36:41 2018 +0900

    [spline/bezier]Modify the weights cache variables to a template variable.

commit 62aaf63
Author: xebra <[email protected]>
Date:   Mon Jul 23 23:11:58 2018 +0900

    Math3D: Something wrong with hand simd optimization in vec2<float>, so it causes very slow down.
    However, compiler optimization is faster enough, so removed it.

commit c4a8d80
Author: xebra <[email protected]>
Date:   Sun Jul 22 11:22:17 2018 +0900

    [spline/bezier]Put the output buffers all in one structure.

commit a241058
Author: xebra <[email protected]>
Date:   Sun Jul 22 01:11:23 2018 +0900

    [spline/bezier]Improve TemplateParameterDispatcher class macro to a real class.

commit 98ddefb
Author: xebra <[email protected]>
Date:   Sat Jul 21 23:00:28 2018 +0900

    [spline/bezier]Extract an if-check in the hot loops to the template parameter.

commit 3216a83
Author: xebra <[email protected]>
Date:   Sat Jul 21 19:46:14 2018 +0900

    [spline/bezier]Expand loops in the shaders.

commit 8c279c0
Author: xebra <[email protected]>
Date:   Sat Jul 21 17:01:03 2018 +0900

    [spline/bezier]Precalculate weights in the shaders using the outer product.

commit 03b9492
Author: xebra <[email protected]>
Date:   Sat Jul 21 00:18:34 2018 +0900

    [spline/bezier]Sharing textures to avoid heavily textures creation/deletion in one frame. At least, it occurs about 1000 and very slow down in Pursuit Force.

commit 453e274
Author: xebra <[email protected]>
Date:   Wed Jul 18 00:52:20 2018 +0900

    [spline/bezier]Fix around vertex type flags.

commit d4a6673
Author: xebra <[email protected]>
Date:   Sat Jul 14 09:40:13 2018 +0900

    [spline/bezier]Improve shader uniforms a bit.

commit de5975f
Author: xebra <[email protected]>
Date:   Sat Jul 14 06:40:50 2018 +0900

    [spline/bezier]Reduce multiplications in the shaders from 16 to 4.

commit 103d180
Author: xebra <[email protected]>
Date:   Sat Jul 14 00:14:19 2018 +0900

    [spline/bezier]Get rid of wasted if-checks at Graphics Processors.

commit 41d6c3c
Author: xebra <[email protected]>
Date:   Fri Jul 13 23:36:36 2018 +0900

    [spline/bezier]Move whole tessellation logic in the shaders into a subroutine.

commit 3d07bca
Author: xebra <[email protected]>
Date:   Mon Feb 12 00:50:21 2018 +0900

    [spline/bezier]Fix spline weights calculation and get rid of using next patch position in hwtess.

    # Conflicts:
    #	GPU/Directx9/VertexShaderGeneratorDX9.cpp
    #	GPU/GLES/VertexShaderGeneratorGLES.cpp
    #	GPU/Vulkan/VertexShaderGeneratorVulkan.cpp

commit a48a5b3
Author: xebra <[email protected]>
Date:   Fri Jul 13 18:35:44 2018 +0900

    [spline/bezier]Unify hardware tessellation of bezier and spline.

commit 3c0fb44
Author: xebra <[email protected]>
Date:   Wed Jul 11 01:09:20 2018 +0900

    [spline/bezier]Improve hwtess to use cached weights.

commit e5976f5
Author: xebra <[email protected]>
Date:   Mon Feb 5 01:47:58 2018 +0900

    [spline/bezier]Unify software tessellation of bezier and spline.

    # Conflicts:
    #	GPU/Common/SplineCommon.cpp

commit 1b076f8
Author: xebra <[email protected]>
Date:   Sat Jun 30 00:21:30 2018 +0900

    [spline/bezier]Improve HW tess on Opengl to combine 3 textures into a single texture and use it.

commit 3add123
Author: xebra <[email protected]>
Date:   Fri Jun 29 23:50:07 2018 +0900

    thin3d: Add support for texture subimage to GLRender.

commit 0cb6331
Author: xebra <[email protected]>
Date:   Fri Jun 29 00:51:31 2018 +0900

    [spline/bezier]Fix to build for GE debugger.

commit 7d45078
Author: xebra <[email protected]>
Date:   Fri Jun 29 00:26:23 2018 +0900

    [spline/bezier]minor cleanup

commit 24123e6
Author: xebra <[email protected]>
Date:   Fri Feb 2 17:36:02 2018 +0900

    [spline/bezier]Fix about quality.

commit da1176f
Author: xebra <[email protected]>
Date:   Thu Feb 1 20:33:17 2018 +0900

    [spline/bezier]Improve template parameter dispatch method.

    # Conflicts:
    #	GPU/Common/SplineCommon.h

commit f7ac708
Author: xebra <[email protected]>
Date:   Thu Feb 1 15:09:41 2018 +0900

    [spline/bezier]Improve spline tessellation using same as bezier tessellation method.(performance improvements, at least 10 FPS or more)

commit b11f9e6
Author: xebra <[email protected]>
Date:   Thu Feb 1 14:09:02 2018 +0900

    [spline/bezier]Fix normal generation flag and some minor stuffs.

commit ca4e246
Author: xebra <[email protected]>
Date:   Thu Feb 1 13:37:53 2018 +0900

    [spline/bezier]Improve tessellator more generic.

commit 07888d7
Author: xebra <[email protected]>
Date:   Thu Feb 1 12:27:29 2018 +0900

    [spline/bezier]Improve bezier tesselator more.

commit f12d796
Author: xebra <[email protected]>
Date:   Thu Feb 1 12:02:03 2018 +0900

    [spline/bezier]minor cleanup

commit 3069153
Author: xebra <[email protected]>
Date:   Thu Feb 1 11:51:58 2018 +0900

    [spline/bezier]Fix bezier texcoord generation.

commit 4c6098d
Author: xebra <[email protected]>
Date:   Thu Feb 1 11:46:46 2018 +0900

    [spline/bezier]Improve bezier tessellator more.

commit 068cc37
Author: xebra <[email protected]>
Date:   Thu Feb 1 11:21:58 2018 +0900

    [spline/bezier]Improve bezier tessellator.

commit 1e84a62
Author: xebra <[email protected]>
Date:   Wed Jan 31 21:42:39 2018 +0900

    [spline/bezier]Implement weights cache system.

commit 15b409a
Author: xebra <[email protected]>
Date:   Wed Jan 31 20:59:41 2018 +0900

    [spline/bezier]Make a spline weights calculation class and precalculate all spline weights at the beginning.

commit 0c96804
Author: xebra <[email protected]>
Date:   Wed Jan 31 20:25:07 2018 +0900

    [spline/bezier]minor fix

commit 1b9af84
Author: xebra <[email protected]>
Date:   Wed Jan 31 20:24:00 2018 +0900

    [spline/bezier]minor fix

commit 2a3210a
Author: xebra <[email protected]>
Date:   Wed Jan 31 20:18:47 2018 +0900

    [spline/bezier]Make a bezier weights calculation class and precalculate all bezier weights at the beginning.

commit 3aeb320
Author: xebra <[email protected]>
Date:   Wed Jan 31 19:25:43 2018 +0900

    [spline/bezier]Improve bezier weights calculation.

commit a340390
Author: xebra <[email protected]>
Date:   Wed Jan 31 18:39:43 2018 +0900

    [spline/bezier]Move bezier patch loops into the function and pre-convert control-points.

commit d0682d7
Author: xebra <[email protected]>
Date:   Wed Jan 31 16:38:11 2018 +0900

    [spline/bezier]Move SIMD optimization of vector operations to Math3D.h.
    Needs rebuild to avoid a dialog confirmation on Visual Studio.

commit c8e45ae
Author: xebra <[email protected]>
Date:   Wed Jan 31 12:44:05 2018 +0900

    [spline/bezier]Use real tessellation in low-quality with "fixed to 2" tessellation factor.

    # Conflicts:
    #	GPU/Common/SplineCommon.cpp

commit 36ed61d
Author: xebra <[email protected]>
Date:   Wed Jan 31 11:34:37 2018 +0900

    [spline/bezier]Pre-convert control-points for the accumulation of SIMD optimization, and avoid conversion in hot loops.

    # Conflicts:
    #	GPU/Common/SplineCommon.cpp
    #	GPU/Common/SplineCommon.h

commit 62ad5fe
Author: xebra <[email protected]>
Date:   Wed Jan 31 09:03:13 2018 +0900

    Fix namespace Vec2f.

commit 15a11d5
Author: xebra <[email protected]>
Date:   Tue Jan 30 18:17:54 2018 +0900

    Modify IndexConverter class to functor.

commit d8ccc1c
Author: xebra <[email protected]>
Date:   Tue Jan 30 18:10:11 2018 +0900

    [spline/bezier]minor fix

commit 30c3c87
Author: xebra <[email protected]>
Date:   Tue Jan 30 17:42:41 2018 +0900

    [spline/bezier]Make a function to build indices.

commit 7cbc97f
Author: xebra <[email protected]>
Date:   Tue Jan 30 16:24:42 2018 +0900

    [spline/bezier]minor cleanup

commit 966ff32
Author: xebra <[email protected]>
Date:   Thu Jun 28 01:41:16 2018 +0900

    [spline/bezier]Improve the logic of copying control-points.

commit 485260c
Author: xebra <[email protected]>
Date:   Tue Jan 30 16:16:25 2018 +0900

    [spline/bezier]Make a function to copy control points.

commit b1289cd
Author: xebra <[email protected]>
Date:   Wed Jun 27 23:37:21 2018 +0900

    [spline/bezier]minor fix

commit 3c2837b
Author: xebra <[email protected]>
Date:   Tue Jan 30 14:56:21 2018 +0900

    [spline/bezier]minor fix

commit a7754c4
Author: xebra <[email protected]>
Date:   Tue Jan 30 14:53:03 2018 +0900

    [spline/bezier]minor fix

    # Conflicts:
    #	GPU/Common/SplineCommon.cpp

commit 1d4e8cc
Author: xebra <[email protected]>
Date:   Tue Jan 30 14:41:39 2018 +0900

    [spline/bezier]minor fix

commit 28a5005
Author: xebra <[email protected]>
Date:   Tue Jan 30 11:26:32 2018 +0900

    [spline/bezier]minor fix

commit a4860b6
Author: xebra <[email protected]>
Date:   Tue Jan 30 10:31:48 2018 +0900

    [spline/bezier]Managing buffer allocation.

    # Conflicts:
    #	GPU/Common/SplineCommon.cpp

commit a9ac860
Author: xebra <[email protected]>
Date:   Mon Jan 29 19:24:42 2018 +0900

    [spline/bezier]Add spline derivative calculation for normal generation.

commit 5c7284f
Author: xebra <[email protected]>
Date:   Mon Jan 29 18:25:38 2018 +0900

    [spline/bezier]Get rid of divisions in spline weights calculation.

# Conflicts:
#	UI/GameSettingsScreen.cpp
  • Loading branch information
LunaMoo committed Nov 2, 2018
1 parent ab2de48 commit db2aea4
Show file tree
Hide file tree
Showing 32 changed files with 1,492 additions and 1,789 deletions.
25 changes: 23 additions & 2 deletions GPU/Common/DrawEngineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ enum {
};

DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) {
quadIndices_ = new u16[6 * QUAD_INDICES_MAX];
decJitCache_ = new VertexDecoderJitCache();
transformed = (TransformedVertex *)AllocateMemoryPages(TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
transformedExpanded = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
Expand All @@ -43,11 +42,11 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) {
DrawEngineCommon::~DrawEngineCommon() {
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
delete[] quadIndices_;
delete decJitCache_;
decoderMap_.Iterate([&](const uint32_t vtype, VertexDecoder *decoder) {
delete decoder;
});
ClearSplineBezierWeights();
}

VertexDecoder *DrawEngineCommon::GetVertexDecoder(u32 vtype) {
Expand Down Expand Up @@ -739,3 +738,25 @@ void DrawEngineCommon::SubmitPrim(void *verts, void *inds, GEPrimitiveType prim,
}
}
}

void TessellationDataTransfer::CopyControlPoints(float *pos, float *tex, float *col, int posStride, int texStride, int colStride, const SimpleVertex *const *points, int size, u32 vertType) {
bool hasColor = (vertType & GE_VTYPE_COL_MASK) != 0;
bool hasTexCoord = (vertType & GE_VTYPE_TC_MASK) != 0;

for (int i = 0; i < size; ++i) {
memcpy(pos, points[i]->pos.AsArray(), 3 * sizeof(float));
pos += posStride;
}
if (hasTexCoord) {
for (int i = 0; i < size; ++i) {
memcpy(tex, points[i]->uv, 2 * sizeof(float));
tex += texStride;
}
}
if (hasColor) {
for (int i = 0; i < size; ++i) {
memcpy(col, Vec4f::FromRGBA(points[i]->color_32).AsArray(), 4 * sizeof(float));
col += colStride;
}
}
}
32 changes: 10 additions & 22 deletions GPU/Common/DrawEngineCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ enum {
VERTEX_BUFFER_MAX = 65536,
DECODED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 64,
DECODED_INDEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 16,
SPLINE_BUFFER_SIZE = VERTEX_BUFFER_MAX * 26, // At least, this buffer needs greater than 1679616 bytes for Mist Dragon morphing in FF4CC.
};

// Avoiding the full include of TextureDecoder.h.
Expand All @@ -50,6 +49,15 @@ inline uint32_t GetVertTypeID(uint32_t vertType, int uvGenMode) {
return (vertType & 0xFFFFFF) | (uvGenMode << 24);
}

struct SimpleVertex;
namespace Spline { struct Weight2D; }

class TessellationDataTransfer {
public:
void CopyControlPoints(float *pos, float *tex, float *col, int posStride, int texStride, int colStride, const SimpleVertex *const *points, int size, u32 vertType);
virtual void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) = 0;
};

class DrawEngineCommon {
public:
DrawEngineCommon();
Expand All @@ -75,6 +83,7 @@ class DrawEngineCommon {
void SubmitPrim(void *verts, void *inds, GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead);
void SubmitSpline(const void *control_points, const void *indices, int tess_u, int tess_v, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, bool computeNormals, bool patchFacing, u32 vertType, int *bytesRead);
void SubmitBezier(const void *control_points, const void *indices, int tess_u, int tess_v, int count_u, int count_v, GEPatchPrimType prim_type, bool computeNormals, bool patchFacing, u32 vertType, int *bytesRead);
void ClearSplineBezierWeights();

std::vector<std::string> DebugGetVertexLoaderIDs();
std::string DebugGetVertexLoaderString(std::string id, DebugShaderStringType stringType);
Expand Down Expand Up @@ -160,31 +169,10 @@ class DrawEngineCommon {
int decodedVerts_ = 0;
GEPrimitiveType prevPrim_ = GE_PRIM_INVALID;

// Fixed index buffer for easy quad generation from spline/bezier
u16 *quadIndices_ = nullptr;

// Shader blending state
bool fboTexNeedBind_ = false;
bool fboTexBound_ = false;

// Hardware tessellation
int numPatches;
class TessellationDataTransfer {
protected:
// TODO: These aren't used by all backends.
int prevSize;
int prevSizeTex;
int prevSizeCol;
public:
virtual ~TessellationDataTransfer() {}
// Send spline/bezier's control points to vertex shader through floating point texture.
virtual void PrepareBuffers(float *&pos, float *&tex, float *&col, int &posStride, int &texStride, int &colStride, int size, bool hasColor, bool hasTexCoords) {
posStride = 4;
texStride = 4;
colStride = 4;
}
virtual void SendDataToShader(const float *pos, const float *tex, const float *col, int size, bool hasColor, bool hasTexCoords) = 0;
virtual void EndFrame() {}
};
TessellationDataTransfer *tessDataTransfer;
};
3 changes: 3 additions & 0 deletions GPU/Common/ShaderId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ std::string VertexShaderDesc(const ShaderID &id) {
if (id.Bit(VS_BIT_SPLINE)) desc << "Spline ";
if (id.Bit(VS_BIT_HAS_COLOR_TESS)) desc << "TessC ";
if (id.Bit(VS_BIT_HAS_TEXCOORD_TESS)) desc << "TessT ";
if (id.Bit(VS_BIT_HAS_NORMAL_TESS)) desc << "TessN ";
if (id.Bit(VS_BIT_NORM_REVERSE_TESS)) desc << "TessRevN ";

return desc.str();
Expand All @@ -73,6 +74,7 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)
bool doSpline = gstate_c.spline;
bool hasColorTess = (gstate.vertType & GE_VTYPE_COL_MASK) != 0 && (doBezier || doSpline);
bool hasTexcoordTess = (gstate.vertType & GE_VTYPE_TC_MASK) != 0 && (doBezier || doSpline);
bool hasNormalTess = (gstate.vertType & GE_VTYPE_NRM_MASK) != 0 && (doBezier || doSpline);

bool enableFog = gstate.isFogEnabled() && !isModeThrough && !gstate.isModeClear();
bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough;
Expand Down Expand Up @@ -139,6 +141,7 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)
id.SetBit(VS_BIT_SPLINE, doSpline);
id.SetBit(VS_BIT_HAS_COLOR_TESS, hasColorTess);
id.SetBit(VS_BIT_HAS_TEXCOORD_TESS, hasTexcoordTess);
id.SetBit(VS_BIT_HAS_NORMAL_TESS, hasNormalTess);
id.SetBit(VS_BIT_NORM_REVERSE_TESS, gstate.isPatchNormalsReversed());
}
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/ShaderId.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum {
VS_BIT_HAS_COLOR_TESS = 12, // 1 bit
VS_BIT_HAS_TEXCOORD_TESS = 13, // 1 bit
VS_BIT_NORM_REVERSE_TESS = 14, // 1 bit
// 15 is free.
VS_BIT_HAS_NORMAL_TESS = 15, // 1 bit
VS_BIT_UVGEN_MODE = 16,
VS_BIT_UVPROJ_MODE = 18, // 2, can overlap with LS0
VS_BIT_LS0 = 18, // 2
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/ShaderUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
}

if (dirtyUniforms & DIRTY_BEZIERSPLINE) {
ub->spline_counts = BytesToUint32(gstate_c.spline_count_u, gstate_c.spline_count_v, gstate_c.spline_type_u, gstate_c.spline_type_v);
ub->spline_counts = gstate_c.spline_num_points_u;
}

if (dirtyUniforms & DIRTY_DEPAL) {
Expand Down
Loading

0 comments on commit db2aea4

Please sign in to comment.