Skip to content

Commit

Permalink
[spline/bezier]Reduce static buffers. Get rid of the spline buffer us…
Browse files Browse the repository at this point in the history
…ing half of the vertex buffer.
  • Loading branch information
xebra committed Oct 1, 2018
1 parent 4c4a0f7 commit 2bde816
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 22 deletions.
2 changes: 0 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,7 +42,6 @@ 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;
Expand Down
4 changes: 0 additions & 4 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 Down Expand Up @@ -170,9 +169,6 @@ 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;
Expand Down
12 changes: 6 additions & 6 deletions GPU/Common/SplineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx);

OutputBuffers output;
output.vertices = (SimpleVertex *)splineBuffer;
output.indices = quadIndices_;
output.vertices = (SimpleVertex *)(decoded + DECODED_VERTEX_BUFFER_SIZE / 2);
output.indices = decIndex;
output.count = 0;

SplineSurface surface;
Expand All @@ -543,7 +543,7 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
surface.num_patches_v = count_v - 3;
surface.primType = prim_type;
surface.patchFacing = patchFacing;
surface.Init(SPLINE_BUFFER_SIZE / vertexSize);
surface.Init(DECODED_VERTEX_BUFFER_SIZE / 2 / vertexSize);

if (CanUseHardwareTessellation(prim_type)) {
HardwareTessellation(output, surface, origVertType, points, tessDataTransfer);
Expand Down Expand Up @@ -618,8 +618,8 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx);

OutputBuffers output;
output.vertices = (SimpleVertex *)splineBuffer;
output.indices = quadIndices_;
output.vertices = (SimpleVertex *)(decoded + DECODED_VERTEX_BUFFER_SIZE / 2);
output.indices = decIndex;
output.count = 0;

BezierSurface surface;
Expand All @@ -631,7 +631,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
surface.num_patches_v = (count_v - 1) / 3;
surface.primType = prim_type;
surface.patchFacing = patchFacing;
surface.Init(SPLINE_BUFFER_SIZE / vertexSize);
surface.Init(DECODED_VERTEX_BUFFER_SIZE / 2 / vertexSize);

if (CanUseHardwareTessellation(prim_type)) {
HardwareTessellation(output, surface, origVertType, points, tessDataTransfer);
Expand Down
2 changes: 0 additions & 2 deletions GPU/D3D11/DrawEngineD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device,
// All this is a LOT of memory, need to see if we can cut down somehow.
decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);

indexGen.Setup(decIndex);

Expand All @@ -104,7 +103,6 @@ DrawEngineD3D11::~DrawEngineD3D11() {
DestroyDeviceObjects();
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);
}

void DrawEngineD3D11::InitDeviceObjects() {
Expand Down
2 changes: 0 additions & 2 deletions GPU/Directx9/DrawEngineDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : vai_(256), vertexDeclMap
// All this is a LOT of memory, need to see if we can cut down somehow.
decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);

indexGen.Setup(decIndex);

Expand All @@ -115,7 +114,6 @@ DrawEngineDX9::~DrawEngineDX9() {
DestroyDeviceObjects();
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);
vertexDeclMap_.Iterate([&](const uint32_t &key, IDirect3DVertexDeclaration9 *decl) {
if (decl) {
decl->Release();
Expand Down
2 changes: 0 additions & 2 deletions GPU/GLES/DrawEngineGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : vai_(256), draw_(draw)
// All this is a LOT of memory, need to see if we can cut down somehow.
decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);

indexGen.Setup(decIndex);

Expand All @@ -95,7 +94,6 @@ DrawEngineGLES::~DrawEngineGLES() {
DestroyDeviceObjects();
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);

delete tessDataTransferGLES;
}
Expand Down
2 changes: 0 additions & 2 deletions GPU/Software/TransformUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ SoftwareDrawEngine::SoftwareDrawEngine() {
// All this is a LOT of memory, need to see if we can cut down somehow. Used for splines.
decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
}

SoftwareDrawEngine::~SoftwareDrawEngine() {
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);
}

void SoftwareDrawEngine::DispatchFlush() {
Expand Down
2 changes: 0 additions & 2 deletions GPU/Vulkan/DrawEngineVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan, Draw::DrawContext *dra
// All this is a LOT of memory, need to see if we can cut down somehow.
decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);

indexGen.Setup(decIndex);

Expand Down Expand Up @@ -184,7 +183,6 @@ void DrawEngineVulkan::InitDeviceObjects() {
DrawEngineVulkan::~DrawEngineVulkan() {
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);

DestroyDeviceObjects();
}
Expand Down

0 comments on commit 2bde816

Please sign in to comment.