mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
softgpu: Use cached state for screen offset.
This commit is contained in:
parent
edb79d968f
commit
6896a7a64e
5 changed files with 29 additions and 26 deletions
|
@ -140,6 +140,9 @@ void ComputeRasterizerState(RasterizerState *state) {
|
|||
state->magFilt = gstate.isMagnifyFilteringEnabled();
|
||||
state->antialiasLines = gstate.isAntiAliasEnabled();
|
||||
|
||||
state->screenOffsetX = gstate.getOffsetX16();
|
||||
state->screenOffsetY = gstate.getOffsetY16();
|
||||
|
||||
#if defined(SOFTGPU_MEMORY_TAGGING_DETAILED) || defined(SOFTGPU_MEMORY_TAGGING_BASIC)
|
||||
DisplayList currentList{};
|
||||
if (gpuDebug)
|
||||
|
@ -717,7 +720,7 @@ void DrawTriangleSlice(
|
|||
Vec4<int> w1 = w1_base;
|
||||
Vec4<int> w2 = w2_base;
|
||||
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(ScreenCoords(minX, curY, 0));
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(minX, curY, state.screenOffsetX, state.screenOffsetY);
|
||||
|
||||
int64_t rowMinX = minX, rowMaxX = maxX;
|
||||
e0.NarrowMinMaxX(w0, minX, rowMinX, rowMaxX);
|
||||
|
@ -844,8 +847,8 @@ void DrawTriangleSlice(
|
|||
|
||||
#if !defined(SOFTGPU_MEMORY_TAGGING_DETAILED) && defined(SOFTGPU_MEMORY_TAGGING_BASIC)
|
||||
for (int y = minY; y <= maxY; y += 16) {
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(ScreenCoords(minX, y, 0));
|
||||
DrawingCoords pend = TransformUnit::ScreenToDrawing(ScreenCoords(maxX, y, 0));
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(minX, y, state.screenOffsetX, state.screenOffsetY);
|
||||
DrawingCoords pend = TransformUnit::ScreenToDrawing(maxX, y, state.screenOffsetX, state.screenOffsetY);
|
||||
uint32_t row = gstate.getFrameBufAddress() + p.y * pixelID.cached.framebufStride * bpp;
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, row + p.x * bpp, (pend.x - p.x) * bpp, tag.c_str(), tag.size());
|
||||
|
||||
|
@ -898,7 +901,7 @@ void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerSta
|
|||
if (!pixelID.clearMode)
|
||||
prim_color += Vec4<int>(sec_color, 0);
|
||||
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(pos);
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(pos, state.screenOffsetX, state.screenOffsetY);
|
||||
u16 z = pos.z;
|
||||
|
||||
u8 fog = 255;
|
||||
|
@ -925,8 +928,8 @@ void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerSta
|
|||
}
|
||||
|
||||
void ClearRectangle(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state) {
|
||||
DrawingCoords pprime = TransformUnit::ScreenToDrawing(ScreenCoords(range.x1, range.y1, 0));
|
||||
DrawingCoords pend = TransformUnit::ScreenToDrawing(ScreenCoords(range.x2, range.y2, 0));
|
||||
DrawingCoords pprime = TransformUnit::ScreenToDrawing(range.x1, range.y1, state.screenOffsetX, state.screenOffsetY);
|
||||
DrawingCoords pend = TransformUnit::ScreenToDrawing(range.x2, range.y2, state.screenOffsetX, state.screenOffsetY);
|
||||
auto &pixelID = state.pixelID;
|
||||
auto &samplerID = state.samplerID;
|
||||
|
||||
|
@ -1190,8 +1193,8 @@ void DrawLine(const VertexData &v0, const VertexData &v1, const BinCoords &range
|
|||
CalculateSamplingParams(ds, dt, state, texLevel, texLevelFrac, texBilinear);
|
||||
|
||||
if (state.antialiasLines) {
|
||||
// TODO: This is a niave and wrong implementation.
|
||||
DrawingCoords p0 = TransformUnit::ScreenToDrawing(ScreenCoords((int)x, (int)y, (int)z));
|
||||
// TODO: This is a naive and wrong implementation.
|
||||
DrawingCoords p0 = TransformUnit::ScreenToDrawing(x, y, state.screenOffsetX, state.screenOffsetY);
|
||||
s = ((float)p0.x + xinc / 32.0f) / 512.0f;
|
||||
t = ((float)p0.y + yinc / 32.0f) / 512.0f;
|
||||
|
||||
|
@ -1205,10 +1208,8 @@ void DrawLine(const VertexData &v0, const VertexData &v1, const BinCoords &range
|
|||
if (!pixelID.clearMode)
|
||||
prim_color += Vec4<int>(sec_color, 0);
|
||||
|
||||
ScreenCoords pprime = ScreenCoords((int)x, (int)y, (int)z);
|
||||
|
||||
PROFILE_THIS_SCOPE("draw_px");
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(pprime);
|
||||
DrawingCoords p = TransformUnit::ScreenToDrawing(x, y, state.screenOffsetX, state.screenOffsetY);
|
||||
state.drawPixel(p.x, p.y, z, fog, ToVec4IntArg(prim_color), pixelID);
|
||||
|
||||
#if defined(SOFTGPU_MEMORY_TAGGING_DETAILED) || defined(SOFTGPU_MEMORY_TAGGING_BASIC)
|
||||
|
|
|
@ -42,6 +42,8 @@ struct RasterizerState {
|
|||
int texbufw[8]{};
|
||||
u8 *texptr[8]{};
|
||||
float textureLodSlope;
|
||||
int screenOffsetX;
|
||||
int screenOffsetY;
|
||||
|
||||
struct {
|
||||
uint8_t maxTexLevel : 3;
|
||||
|
|
|
@ -87,12 +87,12 @@ void DrawSprite(const VertexData &v0, const VertexData &v1, const BinCoords &ran
|
|||
auto &pixelID = state.pixelID;
|
||||
auto &samplerID = state.samplerID;
|
||||
|
||||
DrawingCoords pos0 = TransformUnit::ScreenToDrawing(v0.screenpos);
|
||||
DrawingCoords pos0 = TransformUnit::ScreenToDrawing(v0.screenpos, state.screenOffsetX, state.screenOffsetY);
|
||||
// Include the ending pixel based on its center, not start.
|
||||
DrawingCoords pos1 = TransformUnit::ScreenToDrawing(v1.screenpos + ScreenCoords(7, 7, 0));
|
||||
DrawingCoords pos1 = TransformUnit::ScreenToDrawing(v1.screenpos + ScreenCoords(7, 7, 0), state.screenOffsetX, state.screenOffsetY);
|
||||
|
||||
DrawingCoords scissorTL = TransformUnit::ScreenToDrawing(ScreenCoords(range.x1, range.y1, 0));
|
||||
DrawingCoords scissorBR = TransformUnit::ScreenToDrawing(ScreenCoords(range.x2, range.y2, 0));
|
||||
DrawingCoords scissorTL = TransformUnit::ScreenToDrawing(range.x1, range.y1, state.screenOffsetX, state.screenOffsetY);
|
||||
DrawingCoords scissorBR = TransformUnit::ScreenToDrawing(range.x2, range.y2, state.screenOffsetX, state.screenOffsetY);
|
||||
|
||||
int z = v1.screenpos.z;
|
||||
int fog = 255;
|
||||
|
|
|
@ -133,15 +133,6 @@ ScreenCoords TransformUnit::ClipToScreen(const ClipCoords& coords)
|
|||
return ClipToScreenInternal(coords, nullptr);
|
||||
}
|
||||
|
||||
DrawingCoords TransformUnit::ScreenToDrawing(const ScreenCoords& coords)
|
||||
{
|
||||
DrawingCoords ret;
|
||||
// TODO: What to do when offset > coord?
|
||||
ret.x = ((s32)coords.x - gstate.getOffsetX16()) / 16;
|
||||
ret.y = ((s32)coords.y - gstate.getOffsetY16()) / 16;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ScreenCoords TransformUnit::DrawingToScreen(const DrawingCoords &coords, u16 z) {
|
||||
ScreenCoords ret;
|
||||
ret.x = (u32)coords.x * 16 + gstate.getOffsetX16();
|
||||
|
@ -706,7 +697,7 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVert
|
|||
float clipPos[4];
|
||||
Vec3ByMatrix44(clipPos, vert.pos.AsArray(), worldviewproj);
|
||||
ScreenCoords screenPos = ClipToScreen(clipPos);
|
||||
DrawingCoords drawPos = ScreenToDrawing(screenPos);
|
||||
DrawingCoords drawPos = ScreenToDrawing(screenPos, gstate.getOffsetX16(), gstate.getOffsetY16());
|
||||
|
||||
if (gstate.vertType & GE_VTYPE_TC_MASK) {
|
||||
vertices[i].u = vert.uv[0] * (float)gstate.getTextureWidth(0);
|
||||
|
|
|
@ -102,7 +102,16 @@ public:
|
|||
static ViewCoords WorldToView(const WorldCoords& coords);
|
||||
static ClipCoords ViewToClip(const ViewCoords& coords);
|
||||
static ScreenCoords ClipToScreen(const ClipCoords& coords);
|
||||
static DrawingCoords ScreenToDrawing(const ScreenCoords &coords);
|
||||
static inline DrawingCoords ScreenToDrawing(int x, int y, int offsetX, int offsetY) {
|
||||
DrawingCoords ret;
|
||||
// When offset > coord, it correctly goes negative and force-scissors.
|
||||
ret.x = (x - offsetX) / 16;
|
||||
ret.y = (y - offsetY) / 16;
|
||||
return ret;
|
||||
}
|
||||
static inline DrawingCoords ScreenToDrawing(const ScreenCoords &coords, int offsetX, int offsetY) {
|
||||
return ScreenToDrawing(coords.x, coords.y, offsetX, offsetY);
|
||||
}
|
||||
static ScreenCoords DrawingToScreen(const DrawingCoords &coords, u16 z);
|
||||
|
||||
void SubmitPrimitive(void* vertices, void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead, SoftwareDrawEngine *drawEngine);
|
||||
|
|
Loading…
Add table
Reference in a new issue