mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 07:20:49 +00:00
Implement basic block compression support for OpenGL (without feature checks so far)
This commit is contained in:
parent
7e4dc23bcc
commit
b687f1bba8
@ -387,14 +387,23 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps, bool ski
|
||||
|
||||
// For things to show in RenderDoc, need to split into glTexImage2D(..., nullptr) and glTexSubImage.
|
||||
|
||||
int blockSize = 0;
|
||||
bool bc = Draw::DataFormatIsBlockCompressed(step.texture_image.format, &blockSize);
|
||||
|
||||
GLenum internalFormat, format, type;
|
||||
int alignment;
|
||||
Thin3DFormatToGLFormatAndType(step.texture_image.format, internalFormat, format, type, alignment);
|
||||
if (step.texture_image.depth == 1) {
|
||||
glTexImage2D(tex->target,
|
||||
step.texture_image.level, internalFormat,
|
||||
step.texture_image.width, step.texture_image.height, 0,
|
||||
format, type, step.texture_image.data);
|
||||
if (bc) {
|
||||
int dataSize = ((step.texture_image.width + 3) & ~3) * ((step.texture_image.height + 3) & ~3) * blockSize / 16;
|
||||
glCompressedTexImage2D(tex->target, step.texture_image.level, internalFormat,
|
||||
step.texture_image.width, step.texture_image.height, 0, dataSize, step.texture_image.data);
|
||||
} else {
|
||||
glTexImage2D(tex->target,
|
||||
step.texture_image.level, internalFormat,
|
||||
step.texture_image.width, step.texture_image.height, 0,
|
||||
format, type, step.texture_image.data);
|
||||
}
|
||||
} else {
|
||||
glTexImage3D(tex->target,
|
||||
step.texture_image.level, internalFormat,
|
||||
|
@ -292,20 +292,33 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
|
||||
|
||||
u8 *data = nullptr;
|
||||
int stride = 0;
|
||||
int bpp;
|
||||
int dataSize;
|
||||
|
||||
bool bc = false;
|
||||
|
||||
if (plan.replaceValid) {
|
||||
bpp = (int)Draw::DataFormatSizeInBytes(plan.replaced->Format());
|
||||
int blockSize = 0;
|
||||
if (Draw::DataFormatIsBlockCompressed(plan.replaced->Format(), &blockSize)) {
|
||||
stride = mipWidth * 4;
|
||||
dataSize = plan.replaced->GetLevelDataSize(i);
|
||||
bc = true;
|
||||
} else {
|
||||
int bpp = (int)Draw::DataFormatSizeInBytes(plan.replaced->Format());
|
||||
stride = std::max(mipWidth * bpp, 16);
|
||||
dataSize = stride * mipHeight;
|
||||
}
|
||||
} else {
|
||||
int bpp = 0;
|
||||
if (plan.scaleFactor > 1) {
|
||||
bpp = 4;
|
||||
} else {
|
||||
bpp = (int)Draw::DataFormatSizeInBytes(dstFmt);
|
||||
}
|
||||
stride = std::max(mipWidth * bpp, 16);
|
||||
dataSize = stride * mipHeight;
|
||||
}
|
||||
|
||||
stride = mipWidth * bpp;
|
||||
data = (u8 *)AllocateAlignedMemory(stride * mipHeight, 16);
|
||||
data = (u8 *)AllocateAlignedMemory(dataSize, 16);
|
||||
|
||||
if (!data) {
|
||||
ERROR_LOG(G3D, "Ran out of RAM trying to allocate a temporary texture upload buffer (%dx%d)", mipWidth, mipHeight);
|
||||
|
Loading…
Reference in New Issue
Block a user