DXGL r236 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r235‎ | r236 | r237 >
Date:17:32, 11 August 2012
Author:admin
Status:new
Tags:
Comment:
Add D3DTOP_BLENDDIFFUSEALPHA, D3DTOP_BLENDTEXTUREALPHA, D3DTOP_BLENDTEXTUREALPHAPM, and D3DTOP_BLENDCURRENTALPHA.
Also added D3DTOP_BLENDFACTORALPHA but the parameter is not yet in the fragment shader.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -88,7 +88,8 @@
8989 D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 | D3DTEXOPCAPS_MODULATE |
9090 D3DTEXOPCAPS_MODULATE2X | D3DTEXOPCAPS_MODULATE4X | D3DTEXOPCAPS_ADD |
9191 D3DTEXOPCAPS_ADDSIGNED | D3DTEXOPCAPS_ADDSIGNED2X | D3DTEXOPCAPS_SUBTRACT |
92 - D3DTEXOPCAPS_ADDSMOOTH, //dwTextureOpCaps
 92+ D3DTEXOPCAPS_ADDSMOOTH | D3DTEXOPCAPS_BLENDDIFFUSEALPHA | D3DTEXOPCAPS_BLENDTEXTUREALPHA |
 93+ D3DTEXOPCAPS_BLENDTEXTUREALPHAPM | D3DTEXOPCAPS_BLENDCURRENTALPHA, //dwTextureOpCaps
9394 8, //wMaxTextureBlendStages
9495 8, //wMaxSimultaneousTextures
9596 8, //dwMaxActiveLights
Index: ddraw/shadergen.cpp
@@ -603,6 +603,7 @@
604604 fsrc->append(mainstart);
605605 fsrc->append(op_colorfragin);
606606 string arg1,arg2;
 607+ string texarg;
607608 int args[4];
608609 bool texfail;
609610 const string blendargs[] = {"color","gl_Color","texture2DProj(texX,gl_TexCoord[Y])",
@@ -707,6 +708,28 @@
708709 case D3DTOP_ADDSMOOTH:
709710 fsrc->append("color.rgb = " + arg1 + " + " + arg2 + " - " + arg1 + " * " + arg2 + ";\n");
710711 break;
 712+ case D3DTOP_BLENDDIFFUSEALPHA:
 713+ fsrc->append("color.rgb = " + arg1 + " * gl_Color.a + " + arg2 + " * (1.0-gl_Color.a);\n");
 714+ break;
 715+ case D3DTOP_BLENDTEXTUREALPHA:
 716+ texarg = blendargs[2];
 717+ texarg.replace(17,1,_itoa(i,idstring,10));
 718+ texarg.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
 719+ fsrc->append("color.rgb = " + arg1 + " * " + texarg + ".a + " + arg2 + " * (1.0-"
 720+ + texarg + ".a);\n");
 721+ break;
 722+ case D3DTOP_BLENDFACTORALPHA:
 723+ fsrc->append("color.rgb = " + arg1 + " * texfactor.a + " + arg2 + " * (1.0-texfactor.a);\n");
 724+ break;
 725+ case D3DTOP_BLENDTEXTUREALPHAPM:
 726+ texarg = blendargs[2];
 727+ texarg.replace(17,1,_itoa(i,idstring,10));
 728+ texarg.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
 729+ fsrc->append("color.rgb = " + arg1 + " + " + arg2 + " * (1.0-" + texarg + ".a);\n");
 730+ break;
 731+ case D3DTOP_BLENDCURRENTALPHA:
 732+ fsrc->append("color.rgb = " + arg1 + " * color.a + " + arg2 + " * (1.0-color.a);\n");
 733+ break;
711734 }
712735 if(((texstate[i].shaderid>>17) & 31) == D3DTOP_DISABLE)break;
713736 // Alpha stage
@@ -804,6 +827,28 @@
805828 case D3DTOP_ADDSMOOTH:
806829 fsrc->append("color.a = " + arg1 + " + " + arg2 + " - " + arg1 + " * " + arg2 + ";\n");
807830 break;
 831+ case D3DTOP_BLENDDIFFUSEALPHA:
 832+ fsrc->append("color.a = " + arg1 + " * gl_Color.a + " + arg2 + " * (1.0-gl_Color.a);\n");
 833+ break;
 834+ case D3DTOP_BLENDTEXTUREALPHA:
 835+ texarg = blendargs[2];
 836+ texarg.replace(17,1,_itoa(i,idstring,10));
 837+ texarg.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
 838+ fsrc->append("color.a = " + arg1 + " * " + texarg + ".a + " + arg2 + " * (1.0-"
 839+ + texarg + ".a);\n");
 840+ break;
 841+ case D3DTOP_BLENDFACTORALPHA:
 842+ fsrc->append("color.a = " + arg1 + " * texfactor.a + " + arg2 + " * (1.0-texfactor.a);\n");
 843+ break;
 844+ case D3DTOP_BLENDTEXTUREALPHAPM:
 845+ texarg = blendargs[2];
 846+ texarg.replace(17,1,_itoa(i,idstring,10));
 847+ texarg.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
 848+ fsrc->append("color.a = " + arg1 + " + " + arg2 + " * (1.0-" + texarg + ".a);\n");
 849+ break;
 850+ case D3DTOP_BLENDCURRENTALPHA:
 851+ fsrc->append("color.a = " + arg1 + " * color.a + " + arg2 + " * (1.0-color.a);\n");
 852+ break;
808853 }
809854 }
810855 fsrc->append(op_colorfragout);