Skip to content

Commit

Permalink
softgpu: Use vertType prim override for flags.
Browse files Browse the repository at this point in the history
These parameters are a real shame, was so clean before...
  • Loading branch information
unknownbrackets committed Sep 7, 2022
1 parent 5093f6c commit 764b7e7
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions GPU/Common/VertexDecoderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "GPU/ge_constants.h"
#include "GPU/Common/ShaderCommon.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"

#if PPSSPP_ARCH(ARM)
#include "Common/ArmEmitter.h"
Expand Down Expand Up @@ -299,6 +300,8 @@ class VertexReader {
bool hasNormal() const { return decFmt_.nrmfmt != 0; }
bool hasUV() const { return decFmt_.uvfmt != 0; }
bool isThrough() const { return (vtype_ & GE_VTYPE_THROUGH) != 0; }
bool skinningEnabled() const { return vertTypeIsSkinningEnabled(vtype_); }
int numBoneWeights() const { return vertTypeGetNumBoneWeights(vtype_); }
void Goto(int index) {
data_ = base_ + index * decFmt_.stride;
}
Expand Down
4 changes: 2 additions & 2 deletions GPU/Software/BinManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ BinManager::~BinManager() {
}
}

void BinManager::UpdateState() {
void BinManager::UpdateState(bool throughMode) {
PROFILE_THIS_SCOPE("bin_state");
if (HasDirty(SoftDirty::PIXEL_ALL | SoftDirty::SAMPLER_ALL | SoftDirty::RAST_ALL)) {
if (states_.Full())
Flush("states");
stateIndex_ = (int)states_.Push(RasterizerState());
ComputeRasterizerState(&states_[stateIndex_]);
ComputeRasterizerState(&states_[stateIndex_], throughMode);
states_[stateIndex_].samplerID.cached.clut = cluts_[clutIndex_].readable;

ClearDirty(SoftDirty::PIXEL_ALL | SoftDirty::SAMPLER_ALL | SoftDirty::RAST_ALL);
Expand Down
2 changes: 1 addition & 1 deletion GPU/Software/BinManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class BinManager {
BinManager();
~BinManager();

void UpdateState();
void UpdateState(bool throughMode);
void UpdateClut(const void *src);

const Rasterizer::RasterizerState &State() {
Expand Down
6 changes: 3 additions & 3 deletions GPU/Software/Clipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static inline bool CheckOutsideZ(ClipCoords p, int &pos, int &neg) {
}

void ProcessRect(const VertexData &v0, const VertexData &v1, BinManager &binner) {
if (!gstate.isModeThrough()) {
if (!binner.State().throughMode) {
// We may discard the entire rect based on depth values.
int outsidePos = 0, outsideNeg = 0;
CheckOutsideZ(v0.clippos, outsidePos, outsideNeg);
Expand Down Expand Up @@ -181,7 +181,7 @@ void ProcessPoint(const VertexData &v0, BinManager &binner) {
}

void ProcessLine(const VertexData &v0, const VertexData &v1, BinManager &binner) {
if (gstate.isModeThrough()) {
if (binner.State().throughMode) {
// Actually, should clip this one too so we don't need to do bounds checks in the rasterizer.
binner.AddLine(v0, v1);
return;
Expand Down Expand Up @@ -221,7 +221,7 @@ void ProcessLine(const VertexData &v0, const VertexData &v1, BinManager &binner)

void ProcessTriangle(const VertexData &v0, const VertexData &v1, const VertexData &v2, const VertexData &provoking, BinManager &binner) {
int mask = 0;
if (!gstate.isModeThrough()) {
if (!binner.State().throughMode) {
mask |= CalcClipMask(v0.clippos);
mask |= CalcClipMask(v1.clippos);
mask |= CalcClipMask(v2.clippos);
Expand Down
6 changes: 3 additions & 3 deletions GPU/Software/FuncId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ static inline PixelBlendFactor OptimizeAlphaFactor(uint32_t color) {
return PixelBlendFactor::FIX;
}

void ComputePixelFuncID(PixelFuncID *id) {
void ComputePixelFuncID(PixelFuncID *id, bool throughMode) {
id->fullKey = 0;

// TODO: Could this be minz > 0x0000 || maxz < 0xFFFF? Maybe unsafe, depending on verts...
id->applyDepthRange = !gstate.isModeThrough();
id->applyDepthRange = !throughMode;
// Dither happens even in clear mode.
id->dithering = gstate.isDitherEnabled();
id->fbFormat = gstate.FrameBufFormat();
Expand Down Expand Up @@ -162,7 +162,7 @@ void ComputePixelFuncID(PixelFuncID *id) {
}

id->applyLogicOp = gstate.isLogicOpEnabled() && gstate.getLogicOp() != GE_LOGIC_COPY;
id->applyFog = gstate.isFogEnabled() && !gstate.isModeThrough();
id->applyFog = gstate.isFogEnabled() && !throughMode;
}

// Cache some values for later convenience.
Expand Down
2 changes: 1 addition & 1 deletion GPU/Software/FuncId.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ struct hash<SamplerID> {

};

void ComputePixelFuncID(PixelFuncID *id);
void ComputePixelFuncID(PixelFuncID *id, bool throughMode);
std::string DescribePixelFuncID(const PixelFuncID &id);

void ComputeSamplerID(SamplerID *id);
Expand Down
6 changes: 3 additions & 3 deletions GPU/Software/Rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ static inline Vec4<float> Interpolate(const float &c0, const float &c1, const fl
return Interpolate(c0, c1, c2, w0.Cast<float>(), w1.Cast<float>(), w2.Cast<float>(), wsum_recip);
}

void ComputeRasterizerState(RasterizerState *state) {
ComputePixelFuncID(&state->pixelID);
void ComputeRasterizerState(RasterizerState *state, bool throughMode) {
ComputePixelFuncID(&state->pixelID, throughMode);
state->drawPixel = Rasterizer::GetSingleFunc(state->pixelID);

state->enableTextures = gstate.isTextureMapEnabled() && !state->pixelID.clearMode;
Expand Down Expand Up @@ -140,7 +140,7 @@ void ComputeRasterizerState(RasterizerState *state) {
}

state->shadeGouraud = gstate.getShadeMode() == GE_SHADE_GOURAUD;
state->throughMode = gstate.isModeThrough();
state->throughMode = throughMode;
state->antialiasLines = gstate.isAntiAliasEnabled();

state->screenOffsetX = gstate.getOffsetX16();
Expand Down
2 changes: 1 addition & 1 deletion GPU/Software/Rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct RasterizerState {
}
};

void ComputeRasterizerState(RasterizerState *state);
void ComputeRasterizerState(RasterizerState *state, bool throughMode);

// Draws a triangle if its vertices are specified in counter-clockwise order
void DrawTriangle(const VertexData &v0, const VertexData &v1, const VertexData &v2, const BinCoords &range, const RasterizerState &state);
Expand Down
10 changes: 5 additions & 5 deletions GPU/Software/TransformUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ struct TransformState {
};

void ComputeTransformState(TransformState *state, const VertexReader &vreader) {
state->enableTransform = !gstate.isModeThrough();
state->enableTransform = !vreader.isThrough();
state->enableLighting = gstate.isLightingEnabled();
state->enableFog = gstate.isFogEnabled();
state->readUV = !gstate.isModeClear() && gstate.isTextureMapEnabled() && vreader.hasUV();
state->readWeights = vertTypeIsSkinningEnabled(gstate.vertType) && state->enableTransform;
state->readWeights = vreader.skinningEnabled() && state->enableTransform;
state->negateNormals = gstate.areNormalsReversed();

state->uvGenMode = gstate.getUVGenMode();
Expand Down Expand Up @@ -302,7 +302,7 @@ VertexData TransformUnit::ReadVertex(VertexReader &vreader, const TransformState
Vec3<float> tmppos(0.f, 0.f, 0.f);
Vec3<float> tmpnrm(0.f, 0.f, 0.f);

for (int i = 0; i < vertTypeGetNumBoneWeights(gstate.vertType); ++i) {
for (int i = 0; i < vreader.numBoneWeights(); ++i) {
Vec3<float> step = Vec3ByMatrix43(pos, gstate.boneMatrix + i * 12);
tmppos += step * W[i];
if (vreader.hasNormal()) {
Expand Down Expand Up @@ -506,7 +506,7 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G
// TODO: Do this in two passes - first process the vertices (before indexing/stripping),
// then resolve the indices. This lets us avoid transforming shared vertices twice.

binner_->UpdateState();
binner_->UpdateState(vreader.isThrough());

static TransformState transformState;
if (binner_->HasDirty(SoftDirty::LIGHT_ALL | SoftDirty::TRANSFORM_ALL)) {
Expand Down Expand Up @@ -595,7 +595,7 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G
}
}

if (data_index == 4 && gstate.isModeThrough() && cullType == CullType::OFF) {
if (data_index == 4 && vreader.isThrough() && cullType == CullType::OFF) {
if (Rasterizer::DetectRectangleThroughModeSlices(binner_->State(), data)) {
data[1] = data[3];
data_index = 2;
Expand Down

0 comments on commit 764b7e7

Please sign in to comment.