DXGL r538 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r537‎ | r538 | r539 >
Date:00:25, 18 September 2014
Author:admin
Status:new
Tags:
Comment:
Revert pitch related changes from r536.
Modified paths:
  • /ddraw/TextureManager.c (modified) (history)
  • /ddraw/TextureManager.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/TextureManager.c
@@ -55,19 +55,6 @@
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 -}
7259 DWORD CalculateMipLevels(DWORD width, DWORD height)
7360 {
7461 DWORD x, y;
@@ -513,9 +500,6 @@
514501 GLenum error;
515502 texture->width = width;
516503 texture->height = height;
517 - //glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
518 - //glPixelStorei(GL_UNPACK_ALIGNMENT, bufferalign(texture->pitch));
519 - //glPixelStorei(GL_UNPACK_ROW_LENGTH, pixelsfrompitch(texture->pitch, texture->pixelformat.dwRGBBitCount));
520504 if (checkerror)
521505 {
522506 do
@@ -564,14 +548,10 @@
565549 else glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, width, height, texture->format, texture->type, data);
566550 }
567551 }
568 - //glPopClientAttrib();
569552 }
570553
571554 void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data)
572555 {
573 - //glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
574 - //glPixelStorei(GL_PACK_ALIGNMENT, bufferalign(texture->pitch));
575 - //glPixelStorei(GL_PACK_ROW_LENGTH, bufferalign(texture->pixelformat.dwRGBBitCount));
576556 if(This->ext->GLEXT_EXT_direct_state_access) This->ext->glGetTextureImageEXT(texture->id,GL_TEXTURE_2D,level,texture->format,texture->type,data);
577557 else
578558 {
@@ -579,7 +559,6 @@
580560 TextureManager_SetTexture(This, 0,texture);
581561 glGetTexImage(GL_TEXTURE_2D,level,texture->format,texture->type,data);
582562 }
583 - //glPopClientAttrib();
584563 }
585564
586565 void TextureManager_SetActiveTexture(TextureManager *This, int level)
Index: ddraw/TextureManager.h
@@ -33,7 +33,6 @@
3434 GLint wraps;
3535 GLint wrapt;
3636 GLint miplevel;
37 - GLint pitch;
3837 DWORD bordercolor;
3938 GLint internalformats[8];
4039 DWORD colorsizes[4];
Index: ddraw/glDirectDrawSurface.cpp
@@ -72,7 +72,6 @@
7373 glDirectDrawGammaControl_Create(this, (LPDIRECTDRAWGAMMACONTROL*)&gammacontrol);
7474 buffer = gdibuffer = NULL;
7575 bigbuffer = NULL;
76 - bigpitch = 0;
7776 clientbuffer = NULL;
7877 zbuffer = NULL;
7978 this->miplevel = miplevel;
@@ -138,7 +137,6 @@
139138 paltex->pixelformat.dwGBitMask = 0xFF00;
140139 paltex->pixelformat.dwRBitMask = 0xFF;
141140 paltex->pixelformat.dwRGBBitCount = 32;
142 - paltex->pitch = 1024;
143141 glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
144142 }
145143 else paltex = NULL;
@@ -223,11 +221,8 @@
224222 {
225223 case 0:
226224 buffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
227 - if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
228 - {
229 - bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8) * fakey);
230 - bigpitch = NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex) / 8);
231 - }
 225+ if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
 226+ bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex)/8) * fakey);
232227 if(!buffer) *error = DDERR_OUTOFMEMORY;
233228 goto maketex;
234229 break;
@@ -326,7 +321,6 @@
327322 texture->wraps = texture->wrapt = GL_CLAMP_TO_EDGE;
328323 if (ddsd.ddsCaps.dwCaps & DDSCAPS_MIPMAP) texture->miplevel = ddsd.dwMipMapCount;
329324 else texture->miplevel = 1;
330 - texture->pitch = ddsd.lPitch;
331325 glRenderer_MakeTexture(ddInterface->renderer, texture, fakex, fakey);
332326 }
333327 }
@@ -770,7 +764,8 @@
771765 if (pattern->dirty & 1)
772766 glRenderer_UploadTexture(ddInterface->renderer, pattern->buffer, pattern->bigbuffer, pattern->texture,
773767 pattern->ddsd.dwWidth, pattern->ddsd.dwHeight, pattern->fakex, pattern->fakey, pattern->ddsd.lPitch,
774 - pattern->bigpitch, pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
 768+ (NextMultipleOf4((ddInterface->GetBPPMultipleOf8() / 8)*pattern->fakex)),
 769+ pattern->ddsd.ddpfPixelFormat.dwRGBBitCount,pattern->miplevel);
775770 }
776771 }
777772 if (dwFlags & DDBLT_KEYSRC)
@@ -783,13 +778,16 @@
784779 if(dirty & 1)
785780 {
786781 glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
787 - fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 782+ fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
 783+ ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
788784 dirty &= ~1;
789785 }
790786 if(src && (src->dirty & 1))
791787 {
792788 glRenderer_UploadTexture(ddInterface->renderer,src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
793 - src->fakex,src->fakey,src->ddsd.lPitch,src->bigpitch,src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
 789+ src->fakex,src->fakey,src->ddsd.lPitch,
 790+ (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
 791+ src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
794792 src->dirty &= ~1;
795793 }
796794 if (clipper)
@@ -809,7 +807,6 @@
810808 stencil->pixelformat.dwRBitMask = 0xF00;
811809 stencil->pixelformat.dwRGBAlphaBitMask = 0xF000;
812810 stencil->pixelformat.dwRGBBitCount = 16;
813 - stencil->pitch = ddsd.lPitch;
814811 glRenderer_MakeTexture(ddInterface->renderer, stencil, ddsd.dwWidth, ddsd.dwHeight);
815812 }
816813 if (clipper->dirty)
@@ -981,7 +978,8 @@
982979 if(dirty & 1)
983980 {
984981 glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
985 - fakex,fakey,ddsd.lPitch,bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 982+ fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
 983+ ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
986984 dirty &= ~1;
987985 }
988986 this->dirty |= 2;
@@ -991,7 +989,8 @@
992990 if(tmp->dirty & 1)
993991 {
994992 glRenderer_UploadTexture(ddInterface->renderer,tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
995 - tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,tmp->bigpitch,tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 993+ tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
 994+ tmp->ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
996995 tmp->dirty &= ~1;
997996 }
998997 tmp->dirty |= 2;
@@ -1263,7 +1262,7 @@
12641263 case 0:
12651264 if(dirty & 2)
12661265 glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
1267 - bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 1266+ (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
12681267 ddsd.lpSurface = buffer;
12691268 dirty &= ~2;
12701269 break;
@@ -1274,14 +1273,11 @@
12751274 break;
12761275 case 2:
12771276 buffer = (char *)malloc(ddsd.lPitch * ddsd.dwHeight);
1278 - if ((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
1279 - {
1280 - bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey) / 8);
1281 - bigpitch = ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex);
1282 - }
 1277+ if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
 1278+ bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey)/8);
12831279 else bigbuffer = NULL;
12841280 glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
1285 - bigpitch,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
 1281+ (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
12861282 dirty &= ~2;
12871283 surfacetype = 0;
12881284 goto retry;
Index: ddraw/glDirectDrawSurface.h
@@ -161,7 +161,6 @@
162162 glDirectDrawSurface7 *zbuffer;
163163 glDirectDrawSurface7 *miptexture;
164164 glDirectDrawSurface7 *backbuffer;
165 - int bigpitch;
166165 private:
167166 int swapinterval;
168167 ULONG refcount7, refcount4, refcount3, refcount2, refcount1;
Index: ddraw/glRenderer.cpp
@@ -1348,7 +1348,6 @@
13491349 This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
13501350 This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
13511351 This->backbuffer->pixelformat.dwRGBBitCount = 32;
1352 - This->backbuffer->pitch = (4 * x);
13531352 TextureManager__CreateTexture(This->texman,This->backbuffer,x,y);
13541353 This->backx = x;
13551354 This->backy = y;
@@ -1355,7 +1354,6 @@
13561355 }
13571356 if((This->backx != x) || (This->backy != y))
13581357 {
1359 - This->backbuffer->pitch = (4 * x);
13601358 TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y, FALSE, TRUE);
13611359 This->backx = x;
13621360 This->backy = y;
@@ -1402,7 +1400,6 @@
14031401 This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
14041402 This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
14051403 This->backbuffer->pixelformat.dwRGBBitCount = 32;
1406 - This->backbuffer->pitch = (4 * x);
14071404 TextureManager__CreateTexture(This->texman, This->backbuffer, x, y);
14081405 This->backx = x;
14091406 This->backy = y;
@@ -1411,7 +1408,6 @@
14121409 {
14131410 if (This->backx > x) x = This->backx;
14141411 if (This->backx > y) y = This->backx;
1415 - This->backbuffer->pitch = (4 * x);
14161412 TextureManager__UploadTexture(This->texman, This->backbuffer, 0, NULL, x, y, FALSE, TRUE);
14171413 This->backx = x;
14181414 This->backy = y;
@@ -2074,7 +2070,6 @@
20752071 surface->stencil->pixelformat.dwRBitMask = 0xF00;
20762072 surface->stencil->pixelformat.dwZBitMask = 0xF000;
20772073 surface->stencil->pixelformat.dwRGBBitCount = 16;
2078 - surface->stencil->pitch = NextMultipleOf4(2 * surface->ddsd.dwWidth);
20792074 TextureManager__CreateTexture(This->texman, surface->stencil, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
20802075 }
20812076 if ((surface->ddsd.dwWidth != surface->stencil->width) ||

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r536Set pitch for texture upload and download.admin23:49, 17 September 2014