From 2b53f50c462a7c9299c20d355e58816db9f20330 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Tue, 24 Sep 2019 19:39:23 +0100 Subject: [PATCH] Add some copy safety and remove some print statements --- GL/private.h | 3 +++ GL/texture.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/GL/private.h b/GL/private.h index 5ce6a3e..c33a1a1 100644 --- a/GL/private.h +++ b/GL/private.h @@ -12,6 +12,9 @@ #include "../containers/aligned_vector.h" #include "../containers/named_array.h" +#define FASTCPY(dst, src, bytes) \ + (bytes % 32 == 0) ? sq_cpy(dst, src, bytes) : memcpy(dst, src, bytes); + #define TRACE_ENABLED 0 #define TRACE() if(TRACE_ENABLED) {fprintf(stderr, "%s\n", __func__);} diff --git a/GL/texture.c b/GL/texture.c index 223ffa7..23413b3 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -860,11 +860,9 @@ void _glAllocateSpaceForMipmaps(TextureObject* active) { /* Figure out how much room to allocate for mipmaps */ GLuint bytes = _glGetMipmapDataSize(active); - fprintf(stderr, "Allocating %d PVR bytes\n", bytes); active->data = pvr_mem_malloc(bytes); /* If there was existing data, then copy it where it should go */ - fprintf(stderr, "Copying data\n"); memcpy(_glGetMipmapLocation(active, 0), temp, size); /* Set the data offset depending on whether or not this is a @@ -1054,7 +1052,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, assert(bytes); /* No conversion? Just copy the data, and the pvr_format is correct */ - sq_cpy(targetData, data, bytes); + FASTCPY(targetData, data, bytes); return; } else if(needsConversion) { TextureConversionFunc convert = _determineConversion( @@ -1114,7 +1112,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, // We've already converted the data and we // don't need to twiddle it! - sq_cpy(targetData, conversionBuffer, bytes); + FASTCPY(targetData, conversionBuffer, bytes); } if(conversionBuffer) {