DXGL r484 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r483‎ | r484 | r485 >
Date:01:46, 11 August 2014
Author:admin
Status:new
Tags:
Comment:
Fix color invert ROP on OpenGL 2 devices.
Remove rgba from BltVertex structure and merge BltVertex and BltTexcoord structures.
Modified paths:
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/ShaderManager.cpp (modified) (history)
  • /ddraw/ShaderManager.h (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/glUtil.h (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen2D.cpp
@@ -479,7 +479,7 @@
480480 "",
481481 "",
482482 "",
483 -"pixel = ivec4(255) - pattern;\n",//0F
 483+"pixel = colorsizedest - pattern;\n",//0F
484484 "",//10
485485 "",
486486 "",
@@ -515,7 +515,7 @@
516516 "",//30
517517 "",
518518 "",
519 -"pixel = ivec4(255) - pixel;\n",// 33 NOTSRCCOPY
 519+"pixel = colorsizedest - pixel;\n",// 33 NOTSRCCOPY
520520 "",
521521 "",
522522 "",
@@ -549,7 +549,7 @@
550550 "",
551551 "",
552552 "",
553 -"pixel = ivec4(255) - dest;\n",//55 DSTINVERT
 553+"pixel = colorsizedest - dest;\n",//55 DSTINVERT
554554 "",
555555 "",
556556 "",
@@ -719,7 +719,7 @@
720720 "",
721721 "",
722722 "",
723 -"pixel = ivec4(255);\n",//FF WHITENESS
 723+"pixel = colorsizedest;\n",//FF WHITENESS
724724 };
725725
726726 DWORD PackROPBits(DWORD rop, DWORD flags)
Index: ddraw/ShaderManager.cpp
@@ -28,13 +28,6 @@
2929 #include "ShaderGen3D.h"
3030 #include "ShaderGen2D.h"
3131
32 -const char frag_Color[] = "\
33 -#version 110\n\
34 -void main() \n\
35 -{ \n\
36 - gl_FragColor = gl_Color; \n\
37 -} ";
38 -
3932 const char frag_Texture[] = "\
4033 #version 110\n\
4134 uniform sampler2D tex0;\n\
@@ -109,7 +102,6 @@
110103 #version 110\n\
111104 uniform vec4 view;\n\
112105 attribute vec2 xy;\n\
113 -attribute vec3 rgb;\n\
114106 attribute vec2 st;\n\
115107 void main()\n\
116108 {\n\
@@ -121,7 +113,6 @@
122114 vec4(-(view[1] + view[0]) / (view[1] - view[0]),\n\
123115 -(view[2] + view[3]) / (view[2] - view[3]), -1 , 1));\n\
124116 gl_Position = proj * xyzw;\n\
125 - gl_FrontColor = vec4(rgb,1.0);\n\
126117 gl_TexCoord[0] = vec4(st,0.0,1.0);\n\
127118 } ";
128119
@@ -131,7 +122,6 @@
132123 const int SHADER_START = __LINE__;
133124 const SHADER shader_template[] =
134125 {
135 - {0,0, vert_ortho, frag_Color, 0,-1,-1,-1},
136126 {0,0, vert_ortho, frag_Texture, 0,-1,-1,-1},
137127 {0,0, vert_ortho, frag_Pal256, 0,-1,-1,-1},
138128 {0,0, vert_ortho, frag_ColorKey, 0,-1,-1,-1},
@@ -172,7 +162,6 @@
173163 }
174164 ext->glLinkProgram(shaders[i].prog);
175165 shaders[i].pos = ext->glGetAttribLocation(shaders[i].prog,"xy");
176 - shaders[i].rgb = ext->glGetAttribLocation(shaders[i].prog,"rgb");
177166 shaders[i].texcoord = ext->glGetAttribLocation(shaders[i].prog,"st");
178167 shaders[i].tex0 = ext->glGetUniformLocation(shaders[i].prog,"tex0");
179168 shaders[i].tex1 = ext->glGetUniformLocation(shaders[i].prog,"tex1");
Index: ddraw/ShaderManager.h
@@ -27,7 +27,6 @@
2828 const char *fsrc;
2929 GLint prog;
3030 GLint pos;
31 - GLint rgb;
3231 GLint texcoord;
3332 GLint tex0;
3433 GLint tex1;
@@ -38,13 +37,12 @@
3938
4039 extern const SHADER shader_template[];
4140
42 -#define PROG_FILL 0
43 -#define PROG_TEXTURE 1
44 -#define PROG_PAL256 2
45 -#define PROG_CKEY 3
46 -#define PROG_CKEYMASK 4
47 -#define PROG_2CKEY 5
48 -#define PROG_CLIPSTENCIL 6
 41+#define PROG_TEXTURE 0
 42+#define PROG_PAL256 1
 43+#define PROG_CKEY 2
 44+#define PROG_CKEYMASK 3
 45+#define PROG_2CKEY 4
 46+#define PROG_CLIPSTENCIL 5
4947
5048 struct TEXTURESTAGE;
5149 class ShaderGen3D;
Index: ddraw/glDirectDrawClipper.cpp
@@ -235,8 +235,6 @@
236236 }
237237 for(int i = 0; i < (4*lpClipList->rdh.nCount); i++)
238238 {
239 - This->vertices[i].r = 255;
240 - This->vertices[i].g = This->vertices[i].b = This->vertices[i].a = 0;
241239 This->vertices[i].s = This->vertices[i].t = 0.0f;
242240 }
243241 }
Index: ddraw/glRenderer.cpp
@@ -1144,10 +1144,10 @@
11451145 This->bltvertices[2].t = This->bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
11461146 if(dwFlags & 0x10000000)
11471147 {
1148 - This->blttexcoords[1].stencils = This->blttexcoords[3].stencils = This->bltvertices[1].x / (GLfloat)dest->fakex;
1149 - This->blttexcoords[0].stencils = This->blttexcoords[2].stencils = This->bltvertices[0].x / (GLfloat)dest->fakex;
1150 - This->blttexcoords[0].stencilt = This->blttexcoords[1].stencilt = This->bltvertices[0].y / (GLfloat)dest->fakey;
1151 - This->blttexcoords[2].stencilt = This->blttexcoords[3].stencilt = This->bltvertices[2].y / (GLfloat)dest->fakey;
 1148+ This->bltvertices[1].stencils = This->bltvertices[3].stencils = This->bltvertices[1].x / (GLfloat)dest->fakex;
 1149+ This->bltvertices[0].stencils = This->bltvertices[2].stencils = This->bltvertices[0].x / (GLfloat)dest->fakex;
 1150+ This->bltvertices[0].stencilt = This->bltvertices[1].stencilt = This->bltvertices[0].y / (GLfloat)dest->fakey;
 1151+ This->bltvertices[2].stencilt = This->bltvertices[3].stencilt = This->bltvertices[2].y / (GLfloat)dest->fakey;
11521152 }
11531153 if(dest->zbuffer) glClear(GL_DEPTH_BUFFER_BIT);
11541154 if (dwFlags & DDBLT_COLORFILL) SetColorFillUniform(lpDDBltFx->dwFillColor, dest->texture->colorsizes,
@@ -1176,7 +1176,7 @@
11771177 TextureManager_SetTexture(This->texman, 3, dest->stencil);
11781178 This->ext->glUniform1i(shader->shader.uniforms[4],3);
11791179 This->util->EnableArray(shader->shader.attribs[5],true);
1180 - This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, false, sizeof(BltTexcoord), &This->blttexcoords[0].stencils);
 1180+ This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, false, sizeof(BltVertex), &This->bltvertices[0].stencils);
11811181 }
11821182 if(src)
11831183 {
@@ -1197,11 +1197,6 @@
11981198 dest->dirty |= 2;
11991199 This->util->EnableArray(shader->shader.attribs[0],true);
12001200 This->ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
1201 - if(shader->shader.attribs[1] != -1)
1202 - {
1203 - This->util->EnableArray(shader->shader.attribs[1],true);
1204 - This->ext->glVertexAttribPointer(shader->shader.attribs[1],3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&This->bltvertices[0].r);
1205 - }
12061201 if(!(dwFlags & DDBLT_COLORFILL))
12071202 {
12081203 This->util->EnableArray(shader->shader.attribs[3],true);
@@ -1452,11 +1447,6 @@
14531448 This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
14541449 This->util->EnableArray(This->shaders->shaders[progtype].texcoord,true);
14551450 This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
1456 - if(This->shaders->shaders[progtype].rgb != -1)
1457 - {
1458 - This->util->EnableArray(This->shaders->shaders[progtype].rgb,true);
1459 - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].rgb,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&This->bltvertices[0].r);
1460 - }
14611451 This->util->SetCull(D3DCULL_NONE);
14621452 This->util->SetPolyMode(D3DFILL_SOLID);
14631453 This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
Index: ddraw/glRenderer.h
@@ -112,7 +112,6 @@
113113 GLfloat fogend;
114114 GLfloat fogdensity;
115115 BltVertex bltvertices[4];
116 - BltTexcoord blttexcoords[4];
117116 int oldswap;
118117 TextureManager *texman;
119118 glUtil *util;
Index: ddraw/glUtil.h
@@ -31,17 +31,11 @@
3232 typedef struct
3333 {
3434 GLfloat x, y;
35 - GLubyte r, g, b, a;
3635 GLfloat s, t;
3736 GLfloat dests, destt;
38 - GLfloat padding;
 37+ GLfloat stencils, stencilt;
3938 } BltVertex;
4039
41 -typedef struct
42 -{
43 - GLfloat stencils, stencilt;
44 -} BltTexcoord;
45 -
4640 class glDirectDrawSurface7;
4741
4842 class glUtil