Just a very minor optimization

This commit is contained in:
Henrik Rydgård 2022-12-18 18:05:20 +01:00
parent 2daba57c79
commit 61eaa4ea2d
2 changed files with 9 additions and 3 deletions

View File

@ -410,6 +410,11 @@ std::string GeometryShaderDesc(const GShaderID &id) {
void ComputeGeometryShaderID(GShaderID *id_out, const Draw::Bugs &bugs, int prim) {
GShaderID id;
// Early out.
if (!gstate_c.Use(GPU_USE_GS_CULLING)) {
*id_out = id;
return;
}
bool isModeThrough = gstate.isModeThrough();
bool isCurve = gstate_c.submitType != SubmitType::DRAW;
@ -418,9 +423,8 @@ void ComputeGeometryShaderID(GShaderID *id_out, const Draw::Bugs &bugs, int prim
bool vertexRangeCulling = !isCurve;
bool clipClampedDepth = gstate_c.Use(GPU_USE_DEPTH_CLAMP) && !gstate_c.Use(GPU_USE_CLIP_DISTANCE);
// If we're not using GS culling, return a zero ID.
// Also, only use this for triangle primitives.
if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle || !gstate_c.Use(GPU_USE_GS_CULLING)) {
// Only use this for triangle primitives, and if we actually need it.
if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle) {
*id_out = id;
return;
}

View File

@ -166,10 +166,12 @@ struct ShaderID {
return d[word];
}
// Note: This is a binary copy to string-as-bytes, not a human-readable representation.
void ToString(std::string *dest) const {
dest->resize(sizeof(d));
memcpy(&(*dest)[0], d, sizeof(d));
}
// Note: This is a binary copy from string-as-bytes, not a human-readable representation.
void FromString(std::string src) {
memcpy(d, &(src)[0], sizeof(d));
}