DXGL r703 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r702‎ | r703 | r704 >
Date:19:26, 20 May 2017
Author:admin
Status:new
Tags:
Comment:
Make first scale filtering work.
Increase sampler object count to 12.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/glUtil.cpp (modified) (history)
  • /ddraw/struct.h (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -3210,7 +3210,7 @@
32113211 glTexture__FinishCreate(texture);
32123212 }
32133213
3214 -void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype, BOOL paletted)
 3214+void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype, BOOL paletted, BOOL firstpass)
32153215 {
32163216 GLfloat view[4];
32173217 DDSURFACEDESC2 ddsd;
@@ -3217,7 +3217,7 @@
32183218 DWORD x2, y2;
32193219 x2 = x * This->firstscalex;
32203220 y2 = y * This->firstscaley;
3221 - glUtil_SetActiveTexture(This->util,0);
 3221+ glUtil_SetActiveTexture(This->util,8);
32223222 if(!This->backbuffer)
32233223 {
32243224 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
@@ -3242,12 +3242,11 @@
32433243 view[3] = (GLfloat)y2;
32443244 glUtil_SetViewport(This->util,0,0,x2,y2);
32453245 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
3246 - glUtil_SetTexture(This->util,0,*texture);
 3246+ glUtil_SetTexture(This->util,8,*texture);
32473247 *texture = This->backbuffer;
3248 - if (!paletted && dxglcfg.firstscalefilter == 1)
3249 - glTexture__SetFilter(*texture, 0, GL_LINEAR, GL_LINEAR, This);
3250 - else glTexture__SetFilter(*texture, 0, GL_NEAREST, GL_NEAREST, This);
3251 - if(This->ext->GLEXT_ARB_sampler_objects) glTexture__SetFilter(NULL,0,GL_LINEAR,GL_LINEAR, This);
 3248+ if (!paletted && firstpass && (dxglcfg.firstscalefilter == 1))
 3249+ glTexture__SetFilter(*texture, 8, GL_LINEAR, GL_LINEAR, This);
 3250+ else glTexture__SetFilter(*texture, 8, GL_NEAREST, GL_NEAREST, This);
32523251 This->ext->glUniform4f(This->shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
32533252 This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
32543253 This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
@@ -3386,25 +3385,20 @@
33873386 glUtil_SetTexture(This->util,9,paltex);
33883387 if(dxglcfg.scalingfilter || (This->firstscalex != 1.0f) || (This->firstscaley != 1.0f))
33893388 {
3390 - glRenderer__DrawBackbuffer(This,&texture,texture->bigwidth,texture->bigheight,progtype,TRUE);
 3389+ glRenderer__DrawBackbuffer(This,&texture,texture->bigwidth,texture->bigheight,progtype,TRUE,TRUE);
33913390 ShaderManager_SetShader(This->shaders,PROG_TEXTURE,NULL,0);
33923391 progtype = PROG_TEXTURE;
33933392 glUtil_SetTexture(This->util,8,texture);
33943393 This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,8);
33953394 }
3396 - if(This->ext->GLEXT_ARB_sampler_objects)
3397 - {
3398 - glTexture__SetFilter(NULL, 8, GL_NEAREST, GL_NEAREST, This);
3399 - glTexture__SetFilter(NULL, 9, GL_NEAREST, GL_NEAREST, This);
3400 - }
34013395 }
34023396 else
34033397 {
34043398 if ((This->firstscalex != 1.0f) || (This->firstscaley != 1.0f))
34053399 {
3406 - glRenderer__DrawBackbuffer(This, &texture, texture->bigwidth, texture->bigheight, progtype, FALSE);
 3400+ progtype = PROG_TEXTURE;
34073401 ShaderManager_SetShader(This->shaders, PROG_TEXTURE, NULL, 0);
3408 - progtype = PROG_TEXTURE;
 3402+ glRenderer__DrawBackbuffer(This, &texture, texture->bigwidth, texture->bigheight, progtype, FALSE, TRUE);
34093403 glUtil_SetTexture(This->util, 8, texture);
34103404 This->ext->glUniform1i(This->shaders->shaders[progtype].tex0, 0);
34113405 }
@@ -3413,10 +3407,8 @@
34143408 glUtil_SetTexture(This->util,8,texture);
34153409 This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,8);
34163410 }
3417 - if (dxglcfg.scalingfilter && This->ext->GLEXT_ARB_sampler_objects)
3418 - glTexture__SetFilter(NULL, 0, GL_LINEAR, GL_LINEAR, This);
3419 - else if (This->ext->GLEXT_ARB_sampler_objects)
3420 - glTexture__SetFilter(NULL, 0, GL_NEAREST, GL_NEAREST, This);
 3411+ if (dxglcfg.scalingfilter) glTexture__SetFilter(texture, 8, GL_LINEAR, GL_LINEAR, This);
 3412+ else glTexture__SetFilter(texture, 8, GL_NEAREST, GL_NEAREST, This);
34213413 glUtil_SetViewport(This->util,viewport[0],viewport[1],viewport[2],viewport[3]);
34223414 This->ext->glUniform4f(This->shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
34233415 if(This->ddInterface->GetFullscreen())
Index: ddraw/glRenderer.h
@@ -207,7 +207,7 @@
208208 void glRenderer__MakeTexture(glRenderer *This, glTexture *texture);
209209 void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous, BOOL setsync);
210210 void glRenderer__DeleteTexture(glRenderer *This, glTexture *texture);
211 -void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype, BOOL paletted);
 211+void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype, BOOL paletted, BOOL firstpass);
212212 void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, int progtype);
213213 void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y);
214214 void glRenderer__Clear(glRenderer *This, ClearCommand *cmd);
Index: ddraw/glUtil.cpp
@@ -74,8 +74,8 @@
7575 int i;
7676 if (glext->GLEXT_ARB_sampler_objects)
7777 {
78 - memset(util->samplers, 0, 8 * sizeof(SAMPLER));
79 - for (i = 0; i < 8; i++)
 78+ memset(util->samplers, 0, 12 * sizeof(SAMPLER));
 79+ for (i = 0; i < 12; i++)
8080 {
8181 glext->glGenSamplers(1, &util->samplers[i].id);
8282 glext->glBindSampler(i, util->samplers[i].id);
@@ -102,7 +102,7 @@
103103 int i;
104104 if (This->ext->GLEXT_ARB_sampler_objects)
105105 {
106 - for (i = 0; i < 8; i++)
 106+ for (i = 0; i < 12; i++)
107107 {
108108 This->ext->glBindSampler(i, 0);
109109 This->ext->glDeleteSamplers(1, &This->samplers[i].id);
Index: ddraw/struct.h
@@ -249,7 +249,7 @@
250250 D3DFILLMODE polymode;
251251 D3DSHADEMODE shademode;
252252 BufferObject *LastBoundBuffer;
253 - SAMPLER samplers[8];
 253+ SAMPLER samplers[16];
254254 GLint texlevel;
255255 GLuint textures[16];
256256 } glUtil;