Skip to content

Commit

Permalink
Merge pull request #18525 from GermanAizek/reserve
Browse files Browse the repository at this point in the history
[GPU/GLES] Using reserve if possible
  • Loading branch information
hrydgard committed Dec 12, 2023
2 parents 6040290 + de80cc3 commit 19a427c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion GPU/Common/PostShader.cpp
Expand Up @@ -225,14 +225,15 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
off.settings[i].maxValue = 1.0f;
off.settings[i].step = 0.01f;
}
shaderInfo.insert(shaderInfo.begin(), off);

TextureShaderInfo textureOff{};
textureOff.name = "Off";
textureOff.section = "Off";
textureShaderInfo.insert(textureShaderInfo.begin(), textureOff);

// We always want the not visible ones at the end. Makes menus easier.
shaderInfo.reserve(notVisible.size() + 1);
shaderInfo.insert(shaderInfo.begin(), off);
for (const auto &info : notVisible) {
appendShader(info);
}
Expand Down
2 changes: 2 additions & 0 deletions GPU/Common/ReplacedTexture.cpp
Expand Up @@ -522,6 +522,7 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference
basist::ktx2_transcoder_state transcodeState; // Each thread needs one of these.

transcoder.start_transcoding();
levels_.reserve(numMips);
for (int i = 0; i < numMips; i++) {
std::vector<uint8_t> &out = data_[mipLevel + i];

Expand Down Expand Up @@ -574,6 +575,7 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference
data_.resize(numMips);

// A DDS File can contain multiple mipmaps.
levels_.reserve(numMips);
for (int i = 0; i < numMips; i++) {
std::vector<uint8_t> &out = data_[mipLevel + i];

Expand Down
1 change: 1 addition & 0 deletions GPU/GLES/ShaderManagerGLES.cpp
Expand Up @@ -1141,6 +1141,7 @@ bool ShaderManagerGLES::LoadCache(File::IOFile &f) {
}
}

linkedShaderCache_.reserve(pending.link.size() - pending.linkPos);
for (size_t &i = pending.linkPos; i < pending.link.size(); i++) {
const VShaderID &vsid = pending.link[i].first;
const FShaderID &fsid = pending.link[i].second;
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUCommon.cpp
Expand Up @@ -1606,6 +1606,7 @@ std::vector<GPUDebugOp> GPUCommon::DissassembleOpRange(u32 startpc, u32 endpc) {

// Don't trigger a pause.
u32 prev = Memory::IsValidAddress(startpc - 4) ? Memory::Read_U32(startpc - 4) : 0;
result.reserve((endpc - startpc) / 4);
for (u32 pc = startpc; pc < endpc; pc += 4) {
u32 op = Memory::IsValidAddress(pc) ? Memory::Read_U32(pc) : 0;
GeDisassembleOp(pc, op, prev, buffer, sizeof(buffer));
Expand Down

0 comments on commit 19a427c

Please sign in to comment.