Index: ddraw/glDirectDraw.cpp |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "util.h"
|
21 | 21 | #include "shaders.h"
|
| 22 | +#include <string>
|
| 23 | +using namespace std;
|
22 | 24 | #include "shadergen2d.h"
|
23 | 25 | #include "ddraw.h"
|
24 | 26 | #include "timer.h"
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -898,7 +898,7 @@ |
899 | 899 | if(dest->zbuffer) glClear(GL_DEPTH_BUFFER_BIT);
|
900 | 900 | if(dwFlags & DDBLT_COLORFILL)
|
901 | 901 | {
|
902 | | - SetShader(PROG_FILL,NULL,NULL,true);
|
| 902 | + SetShader(PROG_FILL,NULL,NULL,0);
|
903 | 903 | progtype = PROG_FILL;
|
904 | 904 | switch(ddInterface->GetBPP())
|
905 | 905 | {
|
— | — | @@ -938,7 +938,7 @@ |
939 | 939 | }
|
940 | 940 | if((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
941 | 941 | {
|
942 | | - SetShader(PROG_CKEY,NULL,NULL,true);
|
| 942 | + SetShader(PROG_CKEY,NULL,NULL,0);
|
943 | 943 | progtype = PROG_CKEY;
|
944 | 944 | switch(ddInterface->GetBPP())
|
945 | 945 | {
|
— | — | @@ -969,7 +969,7 @@ |
970 | 970 | }
|
971 | 971 | else if(!(dwFlags & DDBLT_COLORFILL))
|
972 | 972 | {
|
973 | | - SetShader(PROG_TEXTURE,NULL,NULL,true);
|
| 973 | + SetShader(PROG_TEXTURE,NULL,NULL,0);
|
974 | 974 | progtype = PROG_TEXTURE;
|
975 | 975 | glUniform1i(shaders[progtype].tex0,0);
|
976 | 976 | }
|
— | — | @@ -1127,7 +1127,7 @@ |
1128 | 1128 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
1129 | 1129 | if(ddInterface->GetBPP() == 8)
|
1130 | 1130 | {
|
1131 | | - SetShader(PROG_PAL256,NULL,NULL,true);
|
| 1131 | + SetShader(PROG_PAL256,NULL,NULL,0);
|
1132 | 1132 | progtype = PROG_PAL256;
|
1133 | 1133 | ::_UploadTexture(paltex,0,dest->palette->GetPalette(NULL),256,1);
|
1134 | 1134 | glUniform1i(shaders[progtype].tex0,0);
|
— | — | @@ -1137,7 +1137,7 @@ |
1138 | 1138 | if(dxglcfg.scalingfilter)
|
1139 | 1139 | {
|
1140 | 1140 | _DrawBackbuffer(&texture,dest->fakex,dest->fakey,progtype);
|
1141 | | - SetShader(PROG_TEXTURE,NULL,NULL,true);
|
| 1141 | + SetShader(PROG_TEXTURE,NULL,NULL,0);
|
1142 | 1142 | progtype = PROG_TEXTURE;
|
1143 | 1143 | SetTexture(0,texture);
|
1144 | 1144 | glUniform1i(shaders[progtype].tex0,0);
|
— | — | @@ -1150,7 +1150,7 @@ |
1151 | 1151 | }
|
1152 | 1152 | else
|
1153 | 1153 | {
|
1154 | | - SetShader(PROG_TEXTURE,NULL,NULL,true);
|
| 1154 | + SetShader(PROG_TEXTURE,NULL,NULL,0);
|
1155 | 1155 | progtype = PROG_TEXTURE;
|
1156 | 1156 | SetTexture(0,texture);
|
1157 | 1157 | glUniform1i(shaders[progtype].tex0,0);
|
— | — | @@ -1446,7 +1446,7 @@ |
1447 | 1447 | return;
|
1448 | 1448 | }
|
1449 | 1449 | __int64 shader = device->SelectShader(vertices);
|
1450 | | - SetShader(shader,device->texstages,texformats,0);
|
| 1450 | + SetShader(shader,device->texstages,texformats,2);
|
1451 | 1451 | device->SetDepthComp();
|
1452 | 1452 | if(device->renderstate[D3DRENDERSTATE_ZENABLE]) DepthTest(true);
|
1453 | 1453 | else DepthTest(false);
|
Index: ddraw/shadergen.cpp |
— | — | @@ -145,22 +145,25 @@ |
146 | 146 | * Pointer to the texture stage state array, containing 8 64-bit state values
|
147 | 147 | * @param texcoords
|
148 | 148 | * Pointer to number of texture coordinates in each texture stage
|
149 | | - * @param builtin
|
150 | | - * If true, the id parameter is an index to a built-in shader for 2D blitting
|
| 149 | + * @param type
|
| 150 | + * Type of shader:
|
| 151 | + * 0 for builtin
|
| 152 | + * 1 for generated 2D
|
| 153 | + * 2 for generated 3D
|
151 | 154 | */
|
152 | | -void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, bool builtin)
|
| 155 | +void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, int type)
|
153 | 156 | {
|
154 | 157 | int shaderindex = -1;
|
155 | | - if(builtin)
|
| 158 | + switch(type)
|
156 | 159 | {
|
| 160 | + case 0:
|
157 | 161 | if(isbuiltin && (shaders[id].prog == current_shader)) return;
|
158 | 162 | glUseProgram(shaders[id].prog);
|
159 | 163 | current_shader = shaders[id].prog;
|
160 | 164 | isbuiltin=true;
|
161 | 165 | current_genshader = -1;
|
162 | | - }
|
163 | | - else
|
164 | | - {
|
| 166 | + break;
|
| 167 | + case 2:
|
165 | 168 | if(!isbuiltin && (id == current_shader))
|
166 | 169 | {
|
167 | 170 | if(!memcmp(current_texid,texstate,8*sizeof(__int64))) return;
|
Index: ddraw/shadergen.h |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | #define D3DTOP_DXGL_MODULATEMASK 0x102;
|
43 | 43 |
|
44 | 44 | void ClearShaders();
|
45 | | -void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, bool builtin);
|
| 45 | +void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, int type);
|
46 | 46 | GLuint GetProgram();
|
47 | 47 | void ZeroShaderArray();
|
48 | 48 | void CreateShader(int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords);
|
Index: ddraw/shadergen2d.cpp |
— | — | @@ -15,9 +15,16 @@ |
16 | 16 | // License along with this library; if not, write to the Free Software
|
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 | #include "common.h"
|
| 19 | +#include <string>
|
| 20 | +using namespace std;
|
19 | 21 | #include "shadergen2d.h"
|
20 | 22 | #include "../common/version.h"
|
21 | 23 |
|
| 24 | +GenShader2D *genshaders2D = NULL;
|
| 25 | +GLuint current_prog2D;
|
| 26 | +int current_genshader2D;
|
| 27 | +
|
| 28 | +
|
22 | 29 | /* Bits in 2D shader ID:
|
23 | 30 | Bit 0: Use destination alpha (DDBLT_ALPHADEST)
|
24 | 31 | Bit 1: Use dest. alpha constant (DDBLT_ALPHADESTCONSTOVERRIDE)
|
— | — | @@ -159,6 +166,7 @@ |
160 | 167 | static const char var_src[] = "ivec4 src;\n";
|
161 | 168 | static const char var_dest[] = "ivec4 dest;\n";
|
162 | 169 | static const char var_pattern[] = "ivec4 pattern;\n";
|
| 170 | +static const char var_pixel[] = "vec4 pixel;\n";
|
163 | 171 |
|
164 | 172 | // Operations
|
165 | 173 | static const char op_src[] = "src = ivec4(texture2D(src,gl_TexCoord[0].st)*255.5);\n";
|
— | — | @@ -686,4 +694,9 @@ |
687 | 695 | "",
|
688 | 696 | "",
|
689 | 697 | "gl_FragColor = vec4(1.0);\n",//FF WHITENESS
|
690 | | -}; |
\ No newline at end of file |
| 698 | +};
|
| 699 | +
|
| 700 | +void CreateShader2D(int index, DWORD id)
|
| 701 | +{
|
| 702 | + string tmp;
|
| 703 | +} |
\ No newline at end of file |
Index: ddraw/shadergen2d.h |
— | — | @@ -15,6 +15,25 @@ |
16 | 16 | // License along with this library; if not, write to the Free Software
|
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
| 19 | +typedef struct
|
| 20 | +{
|
| 21 | + GLint vs;
|
| 22 | + GLint fs;
|
| 23 | + string *vsrc;
|
| 24 | + string *fsrc;
|
| 25 | + GLint prog;
|
| 26 | + GLint attribs[8];
|
| 27 | + GLint uniforms[16];
|
| 28 | +} _GENSHADER2D;
|
| 29 | +
|
| 30 | +struct GenShader2D
|
| 31 | +{
|
| 32 | + _GENSHADER2D shader;
|
| 33 | + DWORD id;
|
| 34 | +};
|
| 35 | +
|
19 | 36 | extern const DWORD valid_rop_codes[256];
|
20 | 37 | extern const DWORD rop_texture_usage[256];
|
21 | | -extern const DWORD supported_rops[8]; |
\ No newline at end of file |
| 38 | +extern const DWORD supported_rops[8];
|
| 39 | +extern GenShader2D *genshaders2D;
|
| 40 | +extern int current_genshader2D;
|