Fix some texture memory bugs (yeah need to make copies..)

This commit is contained in:
Henrik Rydgård 2017-12-14 16:36:05 +01:00
parent 9094410fd1
commit d5c6786ead
4 changed files with 15 additions and 7 deletions

View file

@ -93,7 +93,9 @@ GLRTexture *DepalShaderCacheGLES::GetClutTexture(GEPaletteFormat clutFormat, con
GLuint components = dstFmt == GL_UNSIGNED_SHORT_5_6_5 ? GL_RGB : GL_RGBA;
GLuint components2 = components;
render_->TextureImage(tex->texture, 0, texturePixels, 1, components, components2, dstFmt, (uint8_t *)rawClut, false);
uint8_t *clutCopy = new uint8_t[1024];
memcpy(clutCopy, rawClut, 1024);
render_->TextureImage(tex->texture, 0, texturePixels, 1, components, components2, dstFmt, clutCopy, false);
tex->lastFrame = gpuStats.numFlips;
texCache_[clutId] = tex;

View file

@ -564,7 +564,15 @@ void DrawEngineGLES::DoFlush() {
vai->lastFrame = gpuStats.numFlips;
} else {
DecodeVertsToPushBuffer(frameData.pushVertex, &vertexBufferOffset, &vertexBuffer);
if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) {
// If software skinning, we've already predecoded into "decoded". So push that content.
size_t size = decodedVerts_ * dec_->GetDecVtxFmt().stride;
u8 *dest = (u8 *)frameData.pushVertex->Push(size, &vertexBufferOffset, &vertexBuffer);
memcpy(dest, decoded, size);
} else {
// Decode directly into the pushbuffer
DecodeVertsToPushBuffer(frameData.pushVertex, &vertexBufferOffset, &vertexBuffer);
}
rotateVBO:
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();

View file

@ -29,12 +29,10 @@ static const int FRAGTEST_DECIMATION_INTERVAL = 113;
FragmentTestCacheGLES::FragmentTestCacheGLES(Draw::DrawContext *draw) {
render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
scratchpad_ = new u8[256 * 4];
}
FragmentTestCacheGLES::~FragmentTestCacheGLES() {
Clear();
delete [] scratchpad_;
}
void FragmentTestCacheGLES::BindTestTexture(int slot) {
@ -100,6 +98,7 @@ FragmentTestID FragmentTestCacheGLES::GenerateTestID() const {
}
GLRTexture *FragmentTestCacheGLES::CreateTestTexture(const GEComparison funcs[4], const u8 refs[4], const u8 masks[4], const bool valid[4]) {
u8 *data = new u8[256 * 4];
// TODO: Might it be better to use GL_ALPHA for simple textures?
// TODO: Experiment with 4-bit/etc. textures.
@ -135,12 +134,12 @@ GLRTexture *FragmentTestCacheGLES::CreateTestTexture(const GEComparison funcs[4]
break;
}
}
scratchpad_[color * 4 + i] = res ? 0xFF : 0;
data[color * 4 + i] = res ? 0xFF : 0;
}
}
GLRTexture *tex = render_->CreateTexture(GL_TEXTURE_2D);
render_->TextureImage(tex, 0, 256, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, scratchpad_);
render_->TextureImage(tex, 0, 256, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, data);
return tex;
}

View file

@ -79,7 +79,6 @@ private:
TextureCacheGLES *textureCache_;
std::map<FragmentTestID, FragmentTestTexture> cache_;
u8 *scratchpad_ = nullptr;
GLRTexture *lastTexture_ = nullptr;
int decimationCounter_ = 0;
};