1 // SwiftShader Software Renderer
3 // Copyright(c) 2005-2013 TransGaming Inc.
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
6 // transcribed, stored in a retrieval system, translated into any human or computer
7 // language by any means, or disclosed to third parties without the explicit written
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
9 // or implied, including but not limited to any patent rights, are granted to you.
14 #include "../libEGL/Texture.hpp"
15 #include "../common/debug.h"
16 #include "Common/Thread.hpp"
18 #define GL_GLEXT_PROTOTYPES
19 #include <GLES/glext.h>
20 #include <GLES2/gl2ext.h>
21 #include <GLES3/gl3.h>
37 LuminanceAlphaHalfFloat,
53 template<DataType dataType>
54 void LoadImageRow(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
60 void LoadImageRow<Alpha>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
62 memcpy(dest + xoffset, source, width);
66 void LoadImageRow<AlphaFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
68 const float *sourceF = reinterpret_cast<const float*>(source);
69 float *destF = reinterpret_cast<float*>(dest + (xoffset * 16));
71 for(int x = 0; x < width; x++)
76 destF[4 * x + 3] = sourceF[x];
81 void LoadImageRow<AlphaHalfFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
83 const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
84 unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
86 for(int x = 0; x < width; x++)
91 destH[4 * x + 3] = sourceH[x];
96 void LoadImageRow<Luminance>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
98 memcpy(dest + xoffset, source, width);
102 void LoadImageRow<LuminanceFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
104 const float *sourceF = reinterpret_cast<const float*>(source);
105 float *destF = reinterpret_cast<float*>(dest + xoffset * 16);
107 for(int x = 0; x < width; x++)
109 destF[4 * x + 0] = sourceF[x];
110 destF[4 * x + 1] = sourceF[x];
111 destF[4 * x + 2] = sourceF[x];
112 destF[4 * x + 3] = 1.0f;
117 void LoadImageRow<LuminanceHalfFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
119 const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
120 unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
122 for(int x = 0; x < width; x++)
124 destH[4 * x + 0] = sourceH[x];
125 destH[4 * x + 1] = sourceH[x];
126 destH[4 * x + 2] = sourceH[x];
127 destH[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
132 void LoadImageRow<LuminanceAlpha>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
134 memcpy(dest + xoffset * 2, source, width * 2);
138 void LoadImageRow<LuminanceAlphaFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
140 const float *sourceF = reinterpret_cast<const float*>(source);
141 float *destF = reinterpret_cast<float*>(dest + xoffset * 16);
143 for(int x = 0; x < width; x++)
145 destF[4 * x + 0] = sourceF[2 * x + 0];
146 destF[4 * x + 1] = sourceF[2 * x + 0];
147 destF[4 * x + 2] = sourceF[2 * x + 0];
148 destF[4 * x + 3] = sourceF[2 * x + 1];
153 void LoadImageRow<LuminanceAlphaHalfFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
155 const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
156 unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
158 for(int x = 0; x < width; x++)
160 destH[4 * x + 0] = sourceH[2 * x + 0];
161 destH[4 * x + 1] = sourceH[2 * x + 0];
162 destH[4 * x + 2] = sourceH[2 * x + 0];
163 destH[4 * x + 3] = sourceH[2 * x + 1];
168 void LoadImageRow<UByteRGB>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
170 unsigned char *destB = dest + xoffset * 4;
172 for(int x = 0; x < width; x++)
174 destB[4 * x + 0] = source[x * 3 + 0];
175 destB[4 * x + 1] = source[x * 3 + 1];
176 destB[4 * x + 2] = source[x * 3 + 2];
177 destB[4 * x + 3] = 0xFF;
182 void LoadImageRow<RGB565>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
184 const unsigned short *source565 = reinterpret_cast<const unsigned short*>(source);
185 unsigned char *dest565 = dest + xoffset * 4;
187 for(int x = 0; x < width; x++)
189 unsigned short rgba = source565[x];
190 dest565[4 * x + 0] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2);
191 dest565[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9);
192 dest565[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
193 dest565[4 * x + 3] = 0xFF;
198 void LoadImageRow<FloatRGB>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
200 const float *sourceF = reinterpret_cast<const float*>(source);
201 float *destF = reinterpret_cast<float*>(dest + xoffset * 16);
203 for(int x = 0; x < width; x++)
205 destF[4 * x + 0] = sourceF[x * 3 + 0];
206 destF[4 * x + 1] = sourceF[x * 3 + 1];
207 destF[4 * x + 2] = sourceF[x * 3 + 2];
208 destF[4 * x + 3] = 1.0f;
213 void LoadImageRow<HalfFloatRGB>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
215 const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
216 unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
218 for(int x = 0; x < width; x++)
220 destH[4 * x + 0] = sourceH[x * 3 + 0];
221 destH[4 * x + 1] = sourceH[x * 3 + 1];
222 destH[4 * x + 2] = sourceH[x * 3 + 2];
223 destH[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
228 void LoadImageRow<UByte4>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
230 memcpy(dest + xoffset * 4, source, width * 4);
234 void LoadImageRow<RGBA4444>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
236 const unsigned short *source4444 = reinterpret_cast<const unsigned short*>(source);
237 unsigned char *dest4444 = dest + xoffset * 4;
239 for(int x = 0; x < width; x++)
241 unsigned short rgba = source4444[x];
242 dest4444[4 * x + 0] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4);
243 dest4444[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8);
244 dest4444[4 * x + 2] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12);
245 dest4444[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0);
250 void LoadImageRow<RGBA5551>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
252 const unsigned short *source5551 = reinterpret_cast<const unsigned short*>(source);
253 unsigned char *dest5551 = dest + xoffset * 4;
255 for(int x = 0; x < width; x++)
257 unsigned short rgba = source5551[x];
258 dest5551[4 * x + 0] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3);
259 dest5551[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8);
260 dest5551[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
261 dest5551[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0;
266 void LoadImageRow<Float4>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
268 memcpy(dest + xoffset * 16, source, width * 16);
272 void LoadImageRow<HalfFloat4>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
274 memcpy(dest + xoffset * 8, source, width * 8);
278 void LoadImageRow<D16>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
280 const unsigned short *sourceD16 = reinterpret_cast<const unsigned short*>(source);
281 float *destF = reinterpret_cast<float*>(dest + xoffset * 4);
283 for(int x = 0; x < width; x++)
285 destF[x] = (float)sourceD16[x] / 0xFFFF;
290 void LoadImageRow<D24>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
292 const unsigned int *sourceD24 = reinterpret_cast<const unsigned int*>(source);
293 float *destF = reinterpret_cast<float*>(dest + xoffset * 4);
295 for(int x = 0; x < width; x++)
297 destF[x] = (float)(sourceD24[x] & 0xFFFFFF00) / 0xFFFFFF00;
302 void LoadImageRow<D32>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
304 const unsigned int *sourceD32 = reinterpret_cast<const unsigned int*>(source);
305 float *destF = reinterpret_cast<float*>(dest + xoffset * 4);
307 for(int x = 0; x < width; x++)
309 destF[x] = (float)sourceD32[x] / 0xFFFFFFFF;
314 void LoadImageRow<S8>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
316 const unsigned int *sourceI = reinterpret_cast<const unsigned int*>(source);
317 unsigned char *destI = dest + xoffset;
319 for(int x = 0; x < width; x++)
321 destI[x] = static_cast<unsigned char>(sourceI[x] & 0x000000FF); // FIXME: Quad layout
325 template<DataType dataType>
326 void LoadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, int inputPitch, int inputHeight, int destPitch, GLsizei destHeight, const void *input, void *buffer)
328 for(int z = 0; z < depth; ++z)
330 const unsigned char *inputStart = static_cast<const unsigned char*>(input) + (z * inputPitch * inputHeight);
331 unsigned char *destStart = static_cast<unsigned char*>(buffer) + ((zoffset + z) * destPitch * destHeight);
332 for(int y = 0; y < height; ++y)
334 const unsigned char *source = inputStart + y * inputPitch;
335 unsigned char *dest = destStart + (y + yoffset) * destPitch;
337 LoadImageRow<dataType>(source, dest, xoffset, width);
345 // Returns the size, in bytes, of a single texel in an Image
346 int ComputePixelSize(GLenum format, GLenum type)
350 case GL_UNSIGNED_BYTE:
353 case GL_ALPHA: return sizeof(unsigned char);
354 case GL_LUMINANCE: return sizeof(unsigned char);
355 case GL_LUMINANCE_ALPHA: return sizeof(unsigned char) * 2;
356 case GL_RGB: return sizeof(unsigned char) * 3;
357 case GL_RGBA: return sizeof(unsigned char) * 4;
358 case GL_BGRA_EXT: return sizeof(unsigned char) * 4;
359 default: UNREACHABLE();
362 case GL_UNSIGNED_SHORT_4_4_4_4:
363 case GL_UNSIGNED_SHORT_5_5_5_1:
364 case GL_UNSIGNED_SHORT_5_6_5:
365 case GL_UNSIGNED_SHORT:
366 return sizeof(unsigned short);
367 case GL_UNSIGNED_INT:
368 case GL_UNSIGNED_INT_24_8_OES:
369 return sizeof(unsigned int);
373 case GL_ALPHA: return sizeof(float);
374 case GL_LUMINANCE: return sizeof(float);
375 case GL_LUMINANCE_ALPHA: return sizeof(float) * 2;
376 case GL_RGB: return sizeof(float) * 3;
377 case GL_RGBA: return sizeof(float) * 4;
378 default: UNREACHABLE();
381 case GL_HALF_FLOAT_OES:
384 case GL_ALPHA: return sizeof(unsigned short);
385 case GL_LUMINANCE: return sizeof(unsigned short);
386 case GL_LUMINANCE_ALPHA: return sizeof(unsigned short) * 2;
387 case GL_RGB: return sizeof(unsigned short) * 3;
388 case GL_RGBA: return sizeof(unsigned short) * 4;
389 default: UNREACHABLE();
392 default: UNREACHABLE();
398 GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment)
400 ASSERT(alignment > 0 && sw::isPow2(alignment));
402 GLsizei rawPitch = ComputePixelSize(format, type) * width;
403 return (rawPitch + alignment - 1) & ~(alignment - 1);
407 GLsizei ComputeCompressedPitch(GLsizei width, GLenum format)
409 return ComputeCompressedSize(width, 1, format);
412 GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format)
416 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
417 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
418 case GL_ETC1_RGB8_OES:
419 case GL_COMPRESSED_R11_EAC:
420 case GL_COMPRESSED_SIGNED_R11_EAC:
421 case GL_COMPRESSED_RGB8_ETC2:
422 case GL_COMPRESSED_SRGB8_ETC2:
423 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
424 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
425 return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
426 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
427 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
428 case GL_COMPRESSED_RG11_EAC:
429 case GL_COMPRESSED_SIGNED_RG11_EAC:
430 case GL_COMPRESSED_RGBA8_ETC2_EAC:
431 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
432 return 16 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
440 ASSERT(referenceCount == 0);
447 return parentTexture->addRef();
449 int newCount = sw::atomicIncrement(&referenceCount);
450 LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
453 void Image::release()
457 return parentTexture->release();
460 int newCount = sw::atomicDecrement(&referenceCount);
461 LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
464 ASSERT(!shared); // Should still hold a reference if eglDestroyImage hasn't been called
469 void Image::unbind(const egl::Texture *parent)
471 if(parentTexture == parent)
479 sw::Format Image::selectInternalFormat(GLenum format, GLenum type)
481 if(format == GL_ETC1_RGB8_OES)
483 return sw::FORMAT_ETC1;
487 if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
488 format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
490 return sw::FORMAT_DXT1;
492 else if(format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE)
494 return sw::FORMAT_DXT3;
496 else if(format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
498 return sw::FORMAT_DXT5;
504 return sw::FORMAT_A32B32G32R32F;
506 else if(type == GL_HALF_FLOAT_OES)
508 return sw::FORMAT_A16B16G16R16F;
510 else if(type == GL_UNSIGNED_BYTE)
512 if(format == GL_LUMINANCE)
514 return sw::FORMAT_L8;
516 else if(format == GL_LUMINANCE_ALPHA)
518 return sw::FORMAT_A8L8;
520 else if(format == GL_RGBA)
522 return sw::FORMAT_A8B8G8R8;
524 else if(format == GL_BGRA_EXT)
526 return sw::FORMAT_A8R8G8B8;
528 else if(format == GL_RGB)
530 return sw::FORMAT_X8B8G8R8;
532 else if(format == GL_ALPHA)
534 return sw::FORMAT_A8;
538 else if(type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT)
540 if(format == GL_DEPTH_COMPONENT)
542 return sw::FORMAT_D32FS8_TEXTURE;
546 else if(type == GL_UNSIGNED_INT_24_8_OES)
548 if(format == GL_DEPTH_STENCIL_OES)
550 return sw::FORMAT_D32FS8_TEXTURE;
554 else if(type == GL_UNSIGNED_SHORT_4_4_4_4)
556 return sw::FORMAT_A8R8G8B8;
558 else if(type == GL_UNSIGNED_SHORT_5_5_5_1)
560 return sw::FORMAT_A8R8G8B8;
562 else if(type == GL_UNSIGNED_SHORT_5_6_5)
564 return sw::FORMAT_X8R8G8B8;
568 return sw::FORMAT_A8B8G8R8;
571 void Image::loadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const UnpackInfo& unpackInfo, const void *input)
573 GLsizei inputPitch = (unpackInfo.rowLength == 0) ? ComputePitch(width, format, type, unpackInfo.alignment) : unpackInfo.rowLength;
574 GLsizei inputHeight = (unpackInfo.imageHeight == 0) ? height : unpackInfo.imageHeight;
575 input = ((char*)input) + (unpackInfo.skipImages * inputHeight + unpackInfo.skipRows) * inputPitch + unpackInfo.skipPixels;
576 void *buffer = lock(0, 0, sw::LOCK_WRITEONLY);
582 case GL_UNSIGNED_BYTE:
586 LoadImageData<Alpha>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
589 LoadImageData<Luminance>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
591 case GL_LUMINANCE_ALPHA:
592 LoadImageData<LuminanceAlpha>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
595 LoadImageData<UByteRGB>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
599 LoadImageData<UByte4>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
601 default: UNREACHABLE();
604 case GL_UNSIGNED_SHORT_5_6_5:
608 LoadImageData<RGB565>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
610 default: UNREACHABLE();
613 case GL_UNSIGNED_SHORT_4_4_4_4:
617 LoadImageData<RGBA4444>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
619 default: UNREACHABLE();
622 case GL_UNSIGNED_SHORT_5_5_5_1:
626 LoadImageData<RGBA5551>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
628 default: UNREACHABLE();
634 // float textures are converted to RGBA, not BGRA
636 LoadImageData<AlphaFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
639 LoadImageData<LuminanceFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
641 case GL_LUMINANCE_ALPHA:
642 LoadImageData<LuminanceAlphaFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
645 LoadImageData<FloatRGB>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
648 LoadImageData<Float4>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
650 default: UNREACHABLE();
653 case GL_HALF_FLOAT_OES:
657 LoadImageData<AlphaHalfFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
660 LoadImageData<LuminanceHalfFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
662 case GL_LUMINANCE_ALPHA:
663 LoadImageData<LuminanceAlphaHalfFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
666 LoadImageData<HalfFloatRGB>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
669 LoadImageData<HalfFloat4>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
671 default: UNREACHABLE();
674 case GL_UNSIGNED_SHORT:
675 LoadImageData<D16>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
677 case GL_UNSIGNED_INT:
678 LoadImageData<D32>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
680 case GL_UNSIGNED_INT_24_8_OES:
681 loadD24S8ImageData(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, input, buffer);
683 default: UNREACHABLE();
690 void Image::loadD24S8ImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, int inputPitch, int inputHeight, const void *input, void *buffer)
692 LoadImageData<D24>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
694 unsigned char *stencil = reinterpret_cast<unsigned char*>(lockStencil(0, sw::PUBLIC));
698 LoadImageData<S8>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getStencilPitchB(), getHeight(), input, stencil);
704 void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
706 if(zoffset != 0 || depth != 1)
708 UNIMPLEMENTED(); // FIXME
711 int inputPitch = ComputeCompressedPitch(width, format);
712 int rows = imageSize / inputPitch;
713 void *buffer = lock(xoffset, yoffset, sw::LOCK_WRITEONLY);
717 for(int i = 0; i < rows; i++)
719 memcpy((void*)((GLbyte*)buffer + i * getPitch()), (void*)((GLbyte*)pixels + i * inputPitch), inputPitch);