Fix some memory leaks

This commit is contained in:
Henrik Rydgård 2018-02-04 13:38:44 +01:00
parent d6e888a39b
commit 8438defb24
3 changed files with 14 additions and 3 deletions

View File

@ -336,17 +336,25 @@ bool DrawContext::CreatePresets() {
return vsPresets_[VS_TEXTURE_COLOR_2D] && vsPresets_[VS_COLOR_2D] && fsPresets_[FS_TEXTURE_COLOR_2D] && fsPresets_[FS_COLOR_2D];
}
DrawContext::~DrawContext() {
void DrawContext::DestroyPresets() {
for (int i = 0; i < VS_MAX_PRESET; i++) {
if (vsPresets_[i])
if (vsPresets_[i]) {
vsPresets_[i]->Release();
vsPresets_[i] = nullptr;
}
}
for (int i = 0; i < FS_MAX_PRESET; i++) {
if (fsPresets_[i])
if (fsPresets_[i]) {
fsPresets_[i]->Release();
fsPresets_[i] = nullptr;
}
}
}
DrawContext::~DrawContext() {
DestroyPresets();
}
// TODO: SSE/NEON
// Could also make C fake-simd for 64-bit, two 8888 pixels fit in a register :)
void ConvertFromRGBA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format) {

View File

@ -543,6 +543,7 @@ class DrawContext {
public:
virtual ~DrawContext();
bool CreatePresets();
void DestroyPresets();
virtual const DeviceCaps &GetDeviceCaps() const = 0;
virtual uint32_t GetDataFormatSupport(DataFormat fmt) const = 0;

View File

@ -527,6 +527,7 @@ OpenGLContext::OpenGLContext() {
}
OpenGLContext::~OpenGLContext() {
DestroyPresets();
for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) {
renderManager_.UnregisterPushBuffer(i, frameData_[i].push);
frameData_[i].push->Destroy();
@ -1031,6 +1032,7 @@ DrawContext *T3DCreateGLContext() {
}
OpenGLInputLayout::~OpenGLInputLayout() {
render_->DeleteInputLayout(inputLayout_);
}
void OpenGLInputLayout::Compile(const InputLayoutDesc &desc) {