Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

softgpu: Fix self-render detect in Ridge Racer #16086

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions GPU/Software/BinManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ void BinManager::UpdateState(bool throughMode) {
Flush("tex");

// Okay, now update what's pending.
constexpr uint32_t mirrorMask = 0x0FFFFFFF & ~0x00600000;
const uint32_t bpp = state.pixelID.FBFormat() == GE_FORMAT_8888 ? 4 : 2;
pendingWrites_[0].Expand(gstate.getFrameBufAddress() & mirrorMask, bpp, gstate.FrameBufStride(), scissorTL, scissorBR);
if (state.pixelID.depthWrite)
pendingWrites_[1].Expand(gstate.getDepthBufAddress() & mirrorMask, 2, gstate.DepthBufStride(), scissorTL, scissorBR);
MarkPendingWrites(state);

ClearDirty(SoftDirty::BINNER_RANGE);
} else if (pendingOverlap_) {
if (HasTextureWrite(state))
if (HasTextureWrite(state)) {
Flush("tex");

// We need the pending writes set, which flushing cleared. Set them again.
MarkPendingWrites(state);
}
}

if (HasDirty(SoftDirty::BINNER_OVERLAP)) {
Expand Down Expand Up @@ -282,6 +282,17 @@ void BinManager::MarkPendingReads(const Rasterizer::RasterizerState &state) {
}
}

void BinManager::MarkPendingWrites(const Rasterizer::RasterizerState &state) {
DrawingCoords scissorTL(gstate.getScissorX1(), gstate.getScissorY1());
DrawingCoords scissorBR(std::min(gstate.getScissorX2(), gstate.getRegionX2()), std::min(gstate.getScissorY2(), gstate.getRegionY2()));

constexpr uint32_t mirrorMask = 0x0FFFFFFF & ~0x00600000;
const uint32_t bpp = state.pixelID.FBFormat() == GE_FORMAT_8888 ? 4 : 2;
pendingWrites_[0].Expand(gstate.getFrameBufAddress() & mirrorMask, bpp, gstate.FrameBufStride(), scissorTL, scissorBR);
if (state.pixelID.depthWrite)
pendingWrites_[1].Expand(gstate.getDepthBufAddress() & mirrorMask, 2, gstate.DepthBufStride(), scissorTL, scissorBR);
}

inline void BinDirtyRange::Expand(uint32_t newBase, uint32_t bpp, uint32_t stride, DrawingCoords &tl, DrawingCoords &br) {
const uint32_t w = br.x - tl.x + 1;
const uint32_t h = br.y - tl.y + 1;
Expand Down
1 change: 1 addition & 0 deletions GPU/Software/BinManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class BinManager {
int mostThreads_ = 0;

void MarkPendingReads(const Rasterizer::RasterizerState &state);
void MarkPendingWrites(const Rasterizer::RasterizerState &state);
bool HasTextureWrite(const Rasterizer::RasterizerState &state);
BinCoords Scissor(BinCoords range);
BinCoords Range(const VertexData &v0, const VertexData &v1, const VertexData &v2);
Expand Down
10 changes: 5 additions & 5 deletions GPU/Software/SoftGpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@ enum class SoftDirty : uint64_t {
PIXEL_DITHER = 1ULL << 3,
PIXEL_WRITEMASK = 1ULL << 4,
PIXEL_CACHED = 1ULL << 5,
PIXEL_ALL = 63ULL << 0,
PIXEL_ALL = 0b111111ULL << 0,

SAMPLER_BASIC = 1ULL << 6,
SAMPLER_TEXLIST = 1ULL << 7,
SAMPLER_CLUT = 1ULL << 8,
SAMPLER_ALL = 7ULL << 6,
SAMPLER_ALL = 0b111ULL << 6,

RAST_BASIC = 1ULL << 9,
RAST_TEX = 1ULL << 10,
RAST_OFFSET = 1ULL << 11,
RAST_ALL = 7ULL << 9,
RAST_ALL = 0b111ULL << 9,

LIGHT_BASIC = 1ULL << 12,
LIGHT_MATERIAL = 1ULL << 13,
LIGHT_0 = 1ULL << 14,
LIGHT_1 = 1ULL << 15,
LIGHT_2 = 1ULL << 16,
LIGHT_3 = 1ULL << 17,
LIGHT_ALL = 63ULL << 12,
LIGHT_ALL = 0b111111ULL << 12,

TRANSFORM_BASIC = 1ULL << 18,
TRANSFORM_MATRIX = 1ULL << 19,
TRANSFORM_VIEWPORT = 1ULL << 20,
TRANSFORM_FOG = 1ULL << 21,
TRANSFORM_ALL = 31ULL << 18,
TRANSFORM_ALL = 0b1111ULL << 18,

BINNER_RANGE = 1ULL << 22,
BINNER_OVERLAP = 1ULL << 23,
Expand Down