mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 00:04:49 +02:00
GLES: Use aligned memory for textures.
We use SSE on them, and they used to be aligned, and must be aligned in PSP RAM, so keep them aligned. This only really affects 32-bit, since allocs will typically be aligned on 64-bit anyway. Fixes #10601.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "Common/MemoryUtil.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "GLQueueRunner.h"
|
||||
#include "GLRenderManager.h"
|
||||
@@ -241,7 +242,11 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
|
||||
// For things to show in RenderDoc, need to split into glTexImage2D(..., nullptr) and glTexSubImage.
|
||||
glTexImage2D(tex->target, step.texture_image.level, step.texture_image.internalFormat, step.texture_image.width, step.texture_image.height, 0, step.texture_image.format, step.texture_image.type, step.texture_image.data);
|
||||
allocatedTextures = true;
|
||||
delete[] step.texture_image.data;
|
||||
if (step.texture_image.allocType == GLRAllocType::ALIGNED) {
|
||||
FreeAlignedMemory(step.texture_image.data);
|
||||
} else {
|
||||
delete[] step.texture_image.data;
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
tex->wrapS = GL_CLAMP_TO_EDGE;
|
||||
tex->wrapT = GL_CLAMP_TO_EDGE;
|
||||
|
||||
@@ -19,6 +19,10 @@ struct GLOffset2D {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
enum class GLRAllocType {
|
||||
NEW,
|
||||
ALIGNED,
|
||||
};
|
||||
|
||||
class GLRShader;
|
||||
class GLRTexture;
|
||||
@@ -242,6 +246,7 @@ struct GLRInitStep {
|
||||
int level;
|
||||
int width;
|
||||
int height;
|
||||
GLRAllocType allocType;
|
||||
bool linearFilter;
|
||||
uint8_t *data; // owned, delete[]-d
|
||||
} texture_image;
|
||||
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
}
|
||||
|
||||
// Takes ownership over the data pointer and delete[]-s it.
|
||||
void TextureImage(GLRTexture *texture, int level, int width, int height, GLenum internalFormat, GLenum format, GLenum type, uint8_t *data, bool linearFilter = false) {
|
||||
void TextureImage(GLRTexture *texture, int level, int width, int height, GLenum internalFormat, GLenum format, GLenum type, uint8_t *data, GLRAllocType allocType = GLRAllocType::NEW, bool linearFilter = false) {
|
||||
GLRInitStep step{ GLRInitStepType::TEXTURE_IMAGE };
|
||||
step.texture_image.texture = texture;
|
||||
step.texture_image.data = data;
|
||||
@@ -347,6 +347,7 @@ public:
|
||||
step.texture_image.level = level;
|
||||
step.texture_image.width = width;
|
||||
step.texture_image.height = height;
|
||||
step.texture_image.allocType = allocType;
|
||||
step.texture_image.linearFilter = linearFilter;
|
||||
initSteps_.push_back(step);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user