Skip to content

Commit

Permalink
Echochrome lines: Remove UV offsets, avoid reading the destination (m…
Browse files Browse the repository at this point in the history
…uch better codegen)
  • Loading branch information
hrydgard committed Jun 11, 2022
1 parent c82d8a0 commit 751afde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
30 changes: 7 additions & 23 deletions GPU/Common/SoftwareTransformCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,33 +786,17 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds,
float vertical = transVtx2.y - transVtx1.y;
Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized();

// bottom right
trans[0] = transVtx2;
trans[0].x += addWidth.x * dx;
trans[0].y += addWidth.y * dy;
trans[0].u += addWidth.x * du;
trans[0].v += addWidth.y * dv;
float xoff = addWidth.x * dx;
float yoff = addWidth.y * dy;

// bottom right
trans[0].CopyFromWithOffset(transVtx2, xoff, yoff);
// top right
trans[1] = transVtx1;
trans[1].x += addWidth.x * dx;
trans[1].y += addWidth.y * dy;
trans[1].u += addWidth.x * du;
trans[1].v += addWidth.y * dv;

trans[1].CopyFromWithOffset(transVtx1, xoff, yoff);
// top left
trans[2] = transVtx1;
trans[2].x -= addWidth.x * dx;
trans[2].y -= addWidth.y * dy;
trans[2].u -= addWidth.x * du;
trans[2].v -= addWidth.y * dv;

trans[2].CopyFromWithOffset(transVtx1, -xoff, -yoff);
// bottom left
trans[3] = transVtx2;
trans[3].x -= addWidth.x * dx;
trans[3].y -= addWidth.y * dy;
trans[3].u -= addWidth.x * du;
trans[3].v -= addWidth.y * dv;
trans[3].CopyFromWithOffset(transVtx2, -xoff, -yoff);

// Triangle: BR-TR-TL
indsOut[0] = i * 2 + 0;
Expand Down
7 changes: 7 additions & 0 deletions GPU/GPUCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ struct TransformedVertex {
u8 color1[4]; // prelit
u32 color1_32;
};


void CopyFromWithOffset(const TransformedVertex &other, float xoff, float yoff) {
this->x = other.x + xoff;
this->y = other.y + yoff;
memcpy(&this->z, &other.z, sizeof(*this) - sizeof(float) * 2);
}
};

class GPUCommon : public GPUInterface, public GPUDebugInterface {
Expand Down

0 comments on commit 751afde

Please sign in to comment.