DXGL r536 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r535‎ | r536 | r537 >
Date:23:49, 17 September 2014
Author:admin
Status:new
Tags:
Comment:
Set pitch for texture upload and download.
Modified paths:
  • /ddraw/TextureManager.c (modified) (history)
  • /ddraw/TextureManager.h (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/TextureManager.c
@@ -55,6 +55,19 @@
5656 } while (1);
5757 }
5858
 59+int pixelsfrompitch(int pitch, int bpp)
 60+{
 61+ int bytesperpixel = bpp / 8;
 62+ return pitch / bytesperpixel;
 63+}
 64+
 65+int bufferalign(int pitch)
 66+{
 67+ if (pitch & 1) return 1;
 68+ if (pitch & 2) return 2;
 69+ if (pitch & 4) return 4;
 70+ return 8;
 71+}
5972 DWORD CalculateMipLevels(DWORD width, DWORD height)
6073 {
6174 DWORD x, y;
@@ -98,9 +111,9 @@
99112 {
100113 TextureManager_DeleteTexture(This, texture);
101114 }
102 -void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror)
 115+void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc)
103116 {
104 - TextureManager_UploadTextureClassic(This, texture, level, data, width, height, checkerror);
 117+ TextureManager_UploadTextureClassic(This, texture, level, data, width, height, checkerror, realloc);
105118 }
106119 void TextureManager__DownloadTexture(TextureManager *This, TEXTURE *texture, int level, void *data)
107120 {
@@ -495,11 +508,13 @@
496509 ZeroMemory(texture->internalformats, 8 * sizeof(GLint));
497510 }
498511
499 -void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror)
 512+void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc)
500513 {
501514 GLenum error;
502515 texture->width = width;
503516 texture->height = height;
 517+ glPixelStorei(GL_UNPACK_ALIGNMENT, bufferalign(texture->pitch));
 518+ glPixelStorei(GL_UNPACK_ROW_LENGTH, pixelsfrompitch(texture->pitch, texture->pixelformat.dwRGBBitCount));
504519 if (checkerror)
505520 {
506521 do
@@ -507,16 +522,16 @@
508523 ClearError();
509524 if (This->ext->GLEXT_EXT_direct_state_access)
510525 {
511 - This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
512 - //This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
513 - // width, height, 0, texture->format, texture->type, data);
 526+ if (realloc)This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
 527+ width, height, 0, texture->format, texture->type, data);
 528+ else This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
514529 }
515530 else
516531 {
517532 TextureManager_SetActiveTexture(This, 0);
518533 TextureManager_SetTexture(This, 0, texture);
519 - glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
520 - //glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
 534+ if (realloc)glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
 535+ else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
521536 }
522537 error = glGetError();
523538 if (error != GL_NO_ERROR)
@@ -536,16 +551,16 @@
537552 {
538553 if (This->ext->GLEXT_EXT_direct_state_access)
539554 {
540 - This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
541 - //This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
542 - //width, height, 0, texture->format, texture->type, data);
 555+ if (realloc)This->ext->glTextureImage2DEXT(texture->id, GL_TEXTURE_2D, level, texture->internalformats[0],
 556+ width, height, 0, texture->format, texture->type, data);
 557+ else This->ext->glTextureSubImage2DEXT(texture->id, GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
543558 }
544559 else
545560 {
546561 TextureManager_SetActiveTexture(This, 0);
547562 TextureManager_SetTexture(This, 0, texture);
548 - glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
549 - //glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
 563+ if (realloc)glTexImage2D(GL_TEXTURE_2D, level, texture->internalformats[0], width, height, 0, texture->format, texture->type, data);
 564+ else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
550565 }
551566 }
552567 }
@@ -552,6 +567,8 @@
553568
554569 void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data)
555570 {
 571+ glPixelStorei(GL_PACK_ALIGNMENT, bufferalign(texture->pitch));
 572+ glPixelStorei(GL_PACK_ROW_LENGTH, bufferalign(texture->pixelformat.dwRGBBitCount));
556573 if(This->ext->GLEXT_EXT_direct_state_access) This->ext->glGetTextureImageEXT(texture->id,GL_TEXTURE_2D,level,texture->format,texture->type,data);
557574 else
558575 {
Index: ddraw/TextureManager.h
@@ -33,6 +33,7 @@
3434 GLint wraps;
3535 GLint wrapt;
3636 GLint miplevel;
 37+ GLint pitch;
3738 DWORD bordercolor;
3839 GLint internalformats[8];
3940 DWORD colorsizes[4];
@@ -83,11 +84,11 @@
8485 void TextureManager_SetTexture(TextureManager *This, unsigned int level, TEXTURE *texture);
8586 void TextureManager__CreateTexture(TextureManager *This, TEXTURE *texture, int width, int height);
8687 void TextureManager__DeleteTexture(TextureManager *This, TEXTURE *texture);
87 -void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
 88+void TextureManager__UploadTexture(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc);
8889 void TextureManager__DownloadTexture(TextureManager *This, TEXTURE *texture, int level, void *data);
8990 void TextureManager_CreateTextureClassic(TextureManager *This, TEXTURE *texture, int width, int height);
9091 void TextureManager_DeleteTexture(TextureManager *This, TEXTURE *texture);
91 -void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
 92+void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror, BOOL realloc);
9293 void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data);
9394 BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty, GLint level);
9495
Index: ddraw/glDirectDraw.cpp
@@ -1244,9 +1244,9 @@
12451245 ddsdMode.dwWidth = primaryx;
12461246 ddsdMode.dwHeight = primaryy;
12471247 ddsdMode.dwRefreshRate = primaryrefresh;
1248 - if(primarybpp == 15) ddsdMode.lPitch = NextMultipleOfWord(primaryx * 2);
1249 - else if(primarybpp == 4) ddsdMode.lPitch = NextMultipleOfWord(primaryx / 2);
1250 - else ddsdMode.lPitch = NextMultipleOfWord(primaryx * (primarybpp / 8));
 1248+ if(primarybpp == 15) ddsdMode.lPitch = NextMultipleOf4(primaryx * 2);
 1249+ else if(primarybpp == 4) ddsdMode.lPitch = NextMultipleOf4(primaryx / 2);
 1250+ else ddsdMode.lPitch = NextMultipleOf4(primaryx * (primarybpp / 8));
12511251 if(lpDDSurfaceDesc2->dwSize < sizeof(DDSURFACEDESC)) ERR(DDERR_INVALIDPARAMS);
12521252 if(lpDDSurfaceDesc2->dwSize > sizeof(DDSURFACEDESC2))
12531253 lpDDSurfaceDesc2->dwSize = sizeof(DDSURFACEDESC2);
Index: ddraw/glDirectDrawSurface.cpp
@@ -72,6 +72,7 @@
7373 glDirectDrawGammaControl_Create(this, (LPDIRECTDRAWGAMMACONTROL*)&gammacontrol);
7474 buffer = gdibuffer = NULL;
7575 bigbuffer = NULL;
 76+ bigpitch = 0;
7677 zbuffer = NULL;
7778 this->miplevel = miplevel;
7879 DWORD colormasks[3];
@@ -136,6 +137,7 @@
137138 paltex->pixelformat.dwGBitMask = 0xFF00;
138139 paltex->pixelformat.dwRBitMask = 0xFF;
139140 paltex->pixelformat.dwRGBBitCount = 32;
 141+ paltex->pitch = 1024;
140142 glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
141143 }
142144 else paltex = NULL;
@@ -219,9 +221,12 @@
220222 switch(surfacetype)
221223 {
222224 case 0:
223 - buffer = (char *)malloc(NextMultipleOfWord((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
224 - if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
225 - bigbuffer = (char *)malloc(NextMultipleOfWord((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex)/8) * fakey);
 225+ buffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
 226+ if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
 227+ {
 228+ bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8) * fakey);
 229+ bigpitch = NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8);
 230+ }
226231 if(!buffer) *error = DDERR_OUTOFMEMORY;
227232 goto maketex;
228233 break;
@@ -268,7 +273,7 @@
269274 ddsd.ddpfPixelFormat.dwRBitMask = 0;
270275 ddsd.ddpfPixelFormat.dwGBitMask = 0;
271276 ddsd.ddpfPixelFormat.dwBBitMask = 0;
272 - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
 277+ ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth);
273278 break;
274279 case 15:
275280 ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
@@ -275,7 +280,7 @@
276281 ddsd.ddpfPixelFormat.dwRBitMask = 0x7C00;
277282 ddsd.ddpfPixelFormat.dwGBitMask = 0x3E0;
278283 ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
279 - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
 284+ ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*2);
280285 ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
281286 break;
282287 case 16:
@@ -283,7 +288,7 @@
284289 ddsd.ddpfPixelFormat.dwRBitMask = 0xF800;
285290 ddsd.ddpfPixelFormat.dwGBitMask = 0x7E0;
286291 ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
287 - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
 292+ ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*2);
288293 break;
289294 case 24:
290295 ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
@@ -290,7 +295,7 @@
291296 ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
292297 ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
293298 ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
294 - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
 299+ ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*3);
295300 break;
296301 case 32:
297302 ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
@@ -297,7 +302,7 @@
298303 ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
299304 ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
300305 ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
301 - ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
 306+ ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*4);
302307 break;
303308 default:
304309 *error = DDERR_INVALIDPIXELFORMAT;
@@ -306,7 +311,7 @@
307312 return;
308313 }
309314 }
310 - else ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*(ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
 315+ else ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth*(ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
311316 if (!(ddsd.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL))
312317 {
313318 texture->pixelformat = ddsd.ddpfPixelFormat;
@@ -320,6 +325,7 @@
321326 texture->wraps = texture->wrapt = GL_CLAMP_TO_EDGE;
322327 if (ddsd.ddsCaps.dwCaps & DDSCAPS_MIPMAP) texture->miplevel = ddsd.dwMipMapCount;
323328 else texture->miplevel = 1;
 329+ texture->pitch = ddsd.lPitch;
324330 glRenderer_MakeTexture(ddInterface->renderer, texture, fakex, fakey);
325331 }
326332 }
@@ -763,8 +769,7 @@
764770 if (pattern->dirty & 1)
765771 glRenderer_UploadTexture(ddInterface->renderer, pattern->buffer, pattern->bigbuffer, pattern->texture,
766772 pattern->ddsd.dwWidth, pattern->ddsd.dwHeight, pattern->fakex, pattern->fakey, pattern->ddsd.lPitch,
767 - (NextMultipleOf4((ddInterface->GetBPPMultipleOf8() / 8)*pattern->fakex)),
768 - pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
 773+ pattern->bigpitch, pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
769774 }
770775 }
771776 if (dwFlags & DDBLT_KEYSRC)
@@ -777,16 +782,13 @@
778783 if(dirty & 1)
779784 {
780785 glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
781 - fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
782 - ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 786+ fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
783787 dirty &= ~1;
784788 }
785789 if(src && (src->dirty & 1))
786790 {
787791 glRenderer_UploadTexture(ddInterface->renderer,src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
788 - src->fakex,src->fakey,src->ddsd.lPitch,
789 - (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
790 - src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
 792+ src->fakex,src->fakey,src->ddsd.lPitch,src->bigpitch,src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
791793 src->dirty &= ~1;
792794 }
793795 if (clipper)
@@ -806,6 +808,7 @@
807809 stencil->pixelformat.dwRBitMask = 0xF00;
808810 stencil->pixelformat.dwRGBAlphaBitMask = 0xF000;
809811 stencil->pixelformat.dwRGBBitCount = 16;
 812+ stencil->pitch = ddsd.lPitch;
810813 glRenderer_MakeTexture(ddInterface->renderer, stencil, ddsd.dwWidth, ddsd.dwHeight);
811814 }
812815 if (clipper->dirty)
@@ -977,8 +980,7 @@
978981 if(dirty & 1)
979982 {
980983 glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
981 - fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
982 - ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 984+ fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
983985 dirty &= ~1;
984986 }
985987 this->dirty |= 2;
@@ -988,8 +990,7 @@
989991 if(tmp->dirty & 1)
990992 {
991993 glRenderer_UploadTexture(ddInterface->renderer,tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
992 - tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
993 - tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 994+ tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,tmp->bigpitch,tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
994995 tmp->dirty &= ~1;
995996 }
996997 tmp->dirty |= 2;
@@ -1261,7 +1262,7 @@
12621263 case 0:
12631264 if(dirty & 2)
12641265 glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
1265 - (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 1266+ bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
12661267 ddsd.lpSurface = buffer;
12671268 dirty &= ~2;
12681269 break;
@@ -1272,11 +1273,14 @@
12731274 break;
12741275 case 2:
12751276 buffer = (char *)malloc(ddsd.lPitch * ddsd.dwHeight);
1276 - if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
1277 - bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOfWord(fakex) * fakey)/8);
 1277+ if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
 1278+ {
 1279+ bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey) / 8);
 1280+ bigpitch = ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex);
 1281+ }
12781282 else bigbuffer = NULL;
12791283 glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
1280 - (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 1284+ bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
12811285 dirty &= ~2;
12821286 surfacetype = 0;
12831287 goto retry;
Index: ddraw/glDirectDrawSurface.h
@@ -161,6 +161,7 @@
162162 glDirectDrawSurface7 *zbuffer;
163163 glDirectDrawSurface7 *miptexture;
164164 glDirectDrawSurface7 *backbuffer;
 165+ int bigpitch;
165166 private:
166167 int swapinterval;
167168 ULONG refcount7, refcount4, refcount3, refcount2, refcount1;
@@ -178,6 +179,7 @@
179180 bool overlay;
180181 IUnknown *zbuffer_iface;
181182 int version;
 183+ bool clientmem;
182184 };
183185
184186 // Legacy DDRAW Interfaces
Index: ddraw/glRenderer.cpp
@@ -107,7 +107,7 @@
108108 if(bpp == 15) bpp = 16;
109109 if((x == bigx && y == bigy) || !bigbuffer)
110110 {
111 - TextureManager__UploadTexture(This->texman, texture, miplevel, buffer, x, y, FALSE);
 111+ TextureManager__UploadTexture(This->texman, texture, miplevel, buffer, x, y, FALSE, FALSE);
112112 }
113113 else
114114 {
@@ -127,7 +127,7 @@
128128 break;
129129 break;
130130 }
131 - TextureManager__UploadTexture(This->texman, texture, miplevel, bigbuffer, bigx, bigy, FALSE);
 131+ TextureManager__UploadTexture(This->texman, texture, miplevel, bigbuffer, bigx, bigy, FALSE, FALSE);
132132 }
133133 }
134134
@@ -1348,6 +1348,7 @@
13491349 This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
13501350 This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
13511351 This->backbuffer->pixelformat.dwRGBBitCount = 32;
 1352+ This->backbuffer->pitch = (4 * x);
13521353 TextureManager__CreateTexture(This->texman,This->backbuffer,x,y);
13531354 This->backx = x;
13541355 This->backy = y;
@@ -1354,7 +1355,8 @@
13551356 }
13561357 if((This->backx != x) || (This->backy != y))
13571358 {
1358 - TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE);
 1359+ This->backbuffer->pitch = (4 * x);
 1360+ TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE, TRUE);
13591361 This->backx = x;
13601362 This->backy = y;
13611363 }
@@ -1400,6 +1402,7 @@
14011403 This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
14021404 This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
14031405 This->backbuffer->pixelformat.dwRGBBitCount = 32;
 1406+ This->backbuffer->pitch = (4 * x);
14041407 TextureManager__CreateTexture(This->texman, This->backbuffer, x, y);
14051408 This->backx = x;
14061409 This->backy = y;
@@ -1408,7 +1411,8 @@
14091412 {
14101413 if (This->backx > x) x = This->backx;
14111414 if (This->backx > y) y = This->backx;
1412 - TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE);
 1415+ This->backbuffer->pitch = (4 * x);
 1416+ TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE, TRUE);
14131417 This->backx = x;
14141418 This->backy = y;
14151419 }
@@ -1505,7 +1509,7 @@
15061510 {
15071511 ShaderManager_SetShader(This->shaders,PROG_PAL256,NULL,NULL,0);
15081512 progtype = PROG_PAL256;
1509 - TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1,FALSE);
 1513+ TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1,FALSE,FALSE);
15101514 This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
15111515 This->ext->glUniform1i(This->shaders->shaders[progtype].pal,1);
15121516 TextureManager_SetTexture(This->texman,0,texture);
@@ -2070,12 +2074,13 @@
20712075 surface->stencil->pixelformat.dwRBitMask = 0xF00;
20722076 surface->stencil->pixelformat.dwZBitMask = 0xF000;
20732077 surface->stencil->pixelformat.dwRGBBitCount = 16;
 2078+ surface->stencil->pitch = NextMultipleOf4(2 * surface->ddsd.dwWidth);
20742079 TextureManager__CreateTexture(This->texman, surface->stencil, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
20752080 }
20762081 if ((surface->ddsd.dwWidth != surface->stencil->width) ||
20772082 (surface->ddsd.dwHeight != surface->stencil->height))
20782083 TextureManager__UploadTexture(This->texman, surface->stencil, 0, NULL,
2079 - surface->ddsd.dwWidth, surface->ddsd.dwHeight, FALSE);
 2084+ surface->ddsd.dwWidth, surface->ddsd.dwHeight, FALSE, TRUE);
20802085 This->util->SetFBO(&surface->stencilfbo, surface->stencil, 0, false);
20812086 view[0] = view[2] = 0;
20822087 view[1] = (GLfloat)surface->ddsd.dwWidth;

Follow-up revisions

RevisionCommit summaryAuthorDate
r537Partially revert r536....admin00:11, 18 September 2014
r538Revert pitch related changes from r536.admin00:25, 18 September 2014