Permalink
Browse files

[spline/bezier]Reduce static buffers. Get rid of the spline buffer us…

…ing half of the vertex buffer.
  • Loading branch information...
xebra committed Oct 1, 2018
1 parent 5f07213 commit eca9386c0583d3fa1eccd37ce0e6014758ae1150
@@ -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);
@@ -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;
@@ -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.
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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);
@@ -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);
@@ -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() {
@@ -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);
@@ -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();
@@ -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);
@@ -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;
}
@@ -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() {
@@ -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);
@@ -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();
}

0 comments on commit eca9386

Please sign in to comment.