mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #9706 from unknownbrackets/softgpu-vdec
SoftGPU: Use vertexjit for submitted primitives
This commit is contained in:
commit
8fbca1d14a
4 changed files with 47 additions and 27 deletions
|
@ -55,23 +55,6 @@ static Draw::SamplerState *samplerLinear = nullptr;
|
||||||
static Draw::Buffer *vdata = nullptr;
|
static Draw::Buffer *vdata = nullptr;
|
||||||
static Draw::Buffer *idata = nullptr;
|
static Draw::Buffer *idata = nullptr;
|
||||||
|
|
||||||
class SoftwareDrawEngine : public DrawEngineCommon {
|
|
||||||
public:
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DispatchFlush() {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DispatchSubmitPrim(void *verts, void *inds, GEPrimitiveType prim, int vertexCount, u32 vertType, int *bytesRead) {
|
|
||||||
TransformUnit::SubmitPrimitive(verts, inds, prim, vertexCount, vertType, bytesRead);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||||
: GPUCommon(gfxCtx, draw)
|
: GPUCommon(gfxCtx, draw)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +104,8 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||||
displayStride_ = 512;
|
displayStride_ = 512;
|
||||||
displayFormat_ = GE_FORMAT_8888;
|
displayFormat_ = GE_FORMAT_8888;
|
||||||
|
|
||||||
drawEngineCommon_ = new SoftwareDrawEngine();
|
drawEngine_ = new SoftwareDrawEngine();
|
||||||
|
drawEngineCommon_ = drawEngine_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftGPU::DeviceLost() {
|
void SoftGPU::DeviceLost() {
|
||||||
|
@ -384,7 +368,7 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff) {
|
||||||
|
|
||||||
cyclesExecuted += EstimatePerVertexCost() * count;
|
cyclesExecuted += EstimatePerVertexCost() * count;
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
TransformUnit::SubmitPrimitive(verts, indices, type, count, gstate.vertType, &bytesRead);
|
TransformUnit::SubmitPrimitive(verts, indices, type, count, gstate.vertType, &bytesRead, drawEngine_);
|
||||||
framebufferDirty_ = true;
|
framebufferDirty_ = true;
|
||||||
|
|
||||||
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
|
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct FormatBuffer {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderManagerGLES;
|
class SoftwareDrawEngine;
|
||||||
|
|
||||||
class SoftGPU : public GPUCommon {
|
class SoftGPU : public GPUCommon {
|
||||||
public:
|
public:
|
||||||
|
@ -103,6 +103,8 @@ private:
|
||||||
u32 displayStride_;
|
u32 displayStride_;
|
||||||
GEBufferFormat displayFormat_;
|
GEBufferFormat displayFormat_;
|
||||||
|
|
||||||
|
SoftwareDrawEngine *drawEngine_ = nullptr;
|
||||||
|
|
||||||
Draw::Texture *fbTex;
|
Draw::Texture *fbTex;
|
||||||
Draw::Pipeline *texColor;
|
Draw::Pipeline *texColor;
|
||||||
std::vector<u32> fbTexBuffer;
|
std::vector<u32> fbTexBuffer;
|
||||||
|
|
|
@ -30,6 +30,31 @@
|
||||||
static u8 buf[65536 * 48]; // yolo
|
static u8 buf[65536 * 48]; // yolo
|
||||||
bool TransformUnit::outside_range_flag = false;
|
bool TransformUnit::outside_range_flag = false;
|
||||||
|
|
||||||
|
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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoftwareDrawEngine::DispatchSubmitPrim(void *verts, void *inds, GEPrimitiveType prim, int vertexCount, u32 vertType, int *bytesRead) {
|
||||||
|
TransformUnit::SubmitPrimitive(verts, inds, prim, vertexCount, vertType, bytesRead, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexDecoder *SoftwareDrawEngine::FindVertexDecoder(u32 vtype) {
|
||||||
|
const u32 vertTypeID = (vtype & 0xFFFFFF) | (gstate.getUVGenMode() << 24);
|
||||||
|
return DrawEngineCommon::GetVertexDecoder(vertTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
WorldCoords TransformUnit::ModelToWorld(const ModelCoords& coords)
|
WorldCoords TransformUnit::ModelToWorld(const ModelCoords& coords)
|
||||||
{
|
{
|
||||||
Mat3x3<float> world_matrix(gstate.worldMatrix);
|
Mat3x3<float> world_matrix(gstate.worldMatrix);
|
||||||
|
@ -216,13 +241,10 @@ struct SplinePatch {
|
||||||
int pad[3];
|
int pad[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead)
|
void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead, SoftwareDrawEngine *drawEngine)
|
||||||
{
|
{
|
||||||
// TODO: Cache VertexDecoder objects
|
VertexDecoder &vdecoder = *drawEngine->FindVertexDecoder(vertex_type);
|
||||||
VertexDecoder vdecoder;
|
const DecVtxFormat &vtxfmt = vdecoder.GetDecVtxFmt();
|
||||||
VertexDecoderOptions options{};
|
|
||||||
vdecoder.SetVertexType(vertex_type, options);
|
|
||||||
const DecVtxFormat& vtxfmt = vdecoder.GetDecVtxFmt();
|
|
||||||
|
|
||||||
if (bytesRead)
|
if (bytesRead)
|
||||||
*bytesRead = vertex_count * vdecoder.VertexSize();
|
*bytesRead = vertex_count * vdecoder.VertexSize();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CommonTypes.h"
|
#include "CommonTypes.h"
|
||||||
|
#include "GPU/Common/DrawEngineCommon.h"
|
||||||
#include "GPU/Common/GPUDebugInterface.h"
|
#include "GPU/Common/GPUDebugInterface.h"
|
||||||
#include "GPU/Math3D.h"
|
#include "GPU/Math3D.h"
|
||||||
|
|
||||||
|
@ -30,6 +31,17 @@ typedef Vec3<float> WorldCoords;
|
||||||
typedef Vec3<float> ViewCoords;
|
typedef Vec3<float> ViewCoords;
|
||||||
typedef Vec4<float> ClipCoords; // Range: -w <= x/y/z <= w
|
typedef Vec4<float> ClipCoords; // Range: -w <= x/y/z <= w
|
||||||
|
|
||||||
|
class SoftwareDrawEngine : public DrawEngineCommon {
|
||||||
|
public:
|
||||||
|
SoftwareDrawEngine();
|
||||||
|
~SoftwareDrawEngine();
|
||||||
|
|
||||||
|
void DispatchFlush() override;
|
||||||
|
void DispatchSubmitPrim(void *verts, void *inds, GEPrimitiveType prim, int vertexCount, u32 vertType, int *bytesRead) override;
|
||||||
|
|
||||||
|
VertexDecoder *FindVertexDecoder(u32 vtype);
|
||||||
|
};
|
||||||
|
|
||||||
struct SplinePatch;
|
struct SplinePatch;
|
||||||
|
|
||||||
struct ScreenCoords
|
struct ScreenCoords
|
||||||
|
@ -126,7 +138,7 @@ public:
|
||||||
static DrawingCoords ScreenToDrawing(const ScreenCoords& coords);
|
static DrawingCoords ScreenToDrawing(const ScreenCoords& coords);
|
||||||
static ScreenCoords DrawingToScreen(const DrawingCoords& coords);
|
static ScreenCoords DrawingToScreen(const DrawingCoords& coords);
|
||||||
|
|
||||||
static void SubmitPrimitive(void* vertices, void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead);
|
static void SubmitPrimitive(void* vertices, void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead, SoftwareDrawEngine *drawEngine);
|
||||||
|
|
||||||
static bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices);
|
static bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices);
|
||||||
static VertexData ReadVertex(VertexReader& vreader);
|
static VertexData ReadVertex(VertexReader& vreader);
|
||||||
|
|
Loading…
Add table
Reference in a new issue