--- Oliver Stieber oliver_stieber@yahoo.co.uk wrote:
--- Raphael fenix@club-internet.fr wrote:
Hi,
Changelog:
- defined D3DCOLOR_B macros to access byte values of D3DCOLOR
- use D3DCOLOR macros instead of using shift + masks
- fix a bug where diffuse.lpData checked instead of specular.lpData
- implement color fixup on ARB VShader compilation code: -> on input parameters using swizzle -> add is_color parameter on vshader_program_add_param
The input swizzel needs to be an output swizzel because it should be possible to use anything to generate a colour for output and not just the input colours, that should also get around the is_colour problem.
Having thought about it again the swizell need to be on the input, it shouldn't be too hard to work out which inputs need to be swizelled in the parser first pass.
Todo:
- check shader declaration while compiling VShader to value is_color
parameter (Oliver have you an idea how to do that ?)
- implement a fixup code for drawPrimitiveSlow and VBO unlock
I've got some fixup code to go in so that drawStridedSlow doesn't have to be used. Oliver.
Regards, Raphael
? wined3d.dll.dbg.c
? wined3d.spec.def Index: device.c =================================================================== RCS file: /home/wine/wine/dlls/wined3d/device.c,v retrieving revision 1.91 diff -u -r1.91 device.c --- device.c 2 Nov 2005 20:01:54 -0000 1.91 +++ device.c 2 Nov 2005 23:11:55 -0000 @@ -4598,10 +4598,10 @@ if (Flags & D3DCLEAR_TARGET) { TRACE("Clearing screen with glClear to color %lx\n", Color); glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
glClearColor(((Color >> 16) & 0xFF) / 255.0f,
((Color >> 8) & 0xFF) / 255.0f,
((Color >> 0) & 0xFF) / 255.0f,
((Color >> 24) & 0xFF) / 255.0f);
glClearColor(D3DCOLOR_R(Color),
D3DCOLOR_G(Color),
D3DCOLOR_B(Color),
D3DCOLOR_A(Color)); checkGLcall("glClearColor"); /* Clear ALL colors! */
Index: drawprim.c
RCS file: /home/wine/wine/dlls/wined3d/drawprim.c,v retrieving revision 1.31 diff -u -r1.31 drawprim.c --- drawprim.c 11 Oct 2005 20:27:54 -0000 1.31 +++ drawprim.c 2 Nov 2005 23:11:56 -0000 @@ -1410,30 +1410,30 @@
/* Diffuse -------------------------------- */ if (sd->u.s.diffuse.lpData != NULL) {
glColor4ub((diffuseColor >> 16) & 0xFF,
(diffuseColor >> 8) & 0xFF,
(diffuseColor >> 0) & 0xFF,
(diffuseColor >> 24) & 0xFF);
VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n",
((diffuseColor >> 16) & 0xFF) / 255.0f,
((diffuseColor >> 8) & 0xFF) / 255.0f,
((diffuseColor >> 0) & 0xFF) / 255.0f,
((diffuseColor >> 24) & 0xFF) / 255.0f));
glColor4ub(D3DCOLOR_B_R(diffuseColor),
D3DCOLOR_B_G(diffuseColor),
D3DCOLOR_B_B(diffuseColor),
D3DCOLOR_B_A(diffuseColor));
VTRACE(("glColor4ub: r,g,b,a=%u,%u,%u,%u\n",
D3DCOLOR_B_R(diffuseColor),
D3DCOLOR_B_G(diffuseColor),
D3DCOLOR_B_B(diffuseColor),
D3DCOLOR_B_A(diffuseColor))); } else { if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } /* Specular ------------------------------- */
if (sd->u.s.diffuse.lpData != NULL) {
VTRACE(("glSecondaryColor4ub: r,g,b=%f,%f,%f\n",
((specularColor >> 16) & 0xFF) / 255.0f,
((specularColor >> 8) & 0xFF) / 255.0f,
((specularColor >> 0) & 0xFF) / 255.0f));
if (sd->u.s.specular.lpData != NULL) {
VTRACE(("glSecondaryColor4ub: r,g,b=%u,%u,%u\n",
D3DCOLOR_B_R(specularColor),
D3DCOLOR_B_G(specularColor),
D3DCOLOR_B_B(specularColor))); if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { GL_EXTCALL(glSecondaryColor3ubEXT)(
(specularColor >> 16) & 0xFF,
(specularColor >> 8) & 0xFF,
(specularColor >> 0) & 0xFF);
D3DCOLOR_B_R(specularColor),
D3DCOLOR_B_G(specularColor),
D3DCOLOR_B_B(specularColor)); } else { /* Do not worry if specular colour missing and disable request */ VTRACE(("Specular color extensions not supplied\n"));
Index: vertexshader.c
RCS file: /home/wine/wine/dlls/wined3d/vertexshader.c,v retrieving revision 1.14 diff -u -r1.14 vertexshader.c --- vertexshader.c 27 Oct 2005 10:23:53 -0000 1.14 +++ vertexshader.c 2 Nov 2005 23:11:57 -0000 @@ -887,10 +887,70 @@ return D3DSIO_COMMENT == (token & D3DSI_OPCODE_MASK); }
-inline static void vshader_program_add_param(const DWORD param, int input, char *hwLine, BOOL namedArrays, CHAR constantsUsedBitmap[]) { +inline static void vshader_program_add_output_param_swizzle(const DWORD param, int is_color, char *hwLine) {
- /** operand output */
- if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) {
strcat(hwLine, ".");
if (param & D3DSP_WRITEMASK_0) { strcat(hwLine, "x"); }
if (param & D3DSP_WRITEMASK_1) { strcat(hwLine, "y"); }
if (param & D3DSP_WRITEMASK_2) { strcat(hwLine, "z"); }
if (param & D3DSP_WRITEMASK_3) { strcat(hwLine, "w"); }
- }
+}
+inline static void vshader_program_add_input_param_swizzle(const DWORD param, int is_color, char *hwLine) {
- static const char swizzle_reg_chars_color_fix[] = "zyxw";
- static const char swizzle_reg_chars[] = "xyzw";
- const char* swizzle_regs = NULL;
- char tmpReg[255];
- /** operand input */
- DWORD swizzle = (param & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
- DWORD swizzle_x = swizzle & 0x03;
- DWORD swizzle_y = (swizzle >> 2) & 0x03;
- DWORD swizzle_z = (swizzle >> 4) & 0x03;
- DWORD swizzle_w = (swizzle >> 6) & 0x03;
- if (is_color) {
swizzle_regs = swizzle_reg_chars_color_fix;
- } else {
swizzle_regs = swizzle_reg_chars;
- }
- /**
* swizzle bits fields:
* WWZZYYXX
*/
- if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) { /* D3DVS_NOSWIZZLE == 0xE4 <<
D3DVS_SWIZZLE_SHIFT */
if (is_color) {
- sprintf(tmpReg, ".%c%c%c%c",
swizzle_regs[swizzle_x],
swizzle_regs[swizzle_y],
swizzle_regs[swizzle_z],
swizzle_regs[swizzle_w]);
- strcat(hwLine, tmpReg);
}
return ;
- }
- if (swizzle_x == swizzle_y &&
- swizzle_x == swizzle_z &&
- swizzle_x == swizzle_w)
- {
sprintf(tmpReg, ".%c", swizzle_regs[swizzle_x]);
strcat(hwLine, tmpReg);
- } else {
sprintf(tmpReg, ".%c%c%c%c",
swizzle_regs[swizzle_x],
swizzle_regs[swizzle_y],
swizzle_regs[swizzle_z],
swizzle_regs[swizzle_w]);
strcat(hwLine, tmpReg);
- }
+}
+inline static void vshader_program_add_param(const DWORD param, int input, int is_color, char *hwLine, BOOL namedArrays, CHAR constantsUsedBitmap[]) { /*static const char* rastout_reg_names[] = { "oPos", "oFog", "oPts" }; */ static const char* hwrastout_reg_names[] = { "result.position", "result.fogcoord", "result.pointsize" };
static const char swizzle_reg_chars[] = "xyzw";
DWORD reg = param & 0x00001FFF; DWORD regtype = ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT);
@@ -954,49 +1014,9 @@ }
if (!input) {
- /** operand output */
- if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) {
strcat(hwLine, ".");
if (param & D3DSP_WRITEMASK_0) {
strcat(hwLine, "x");
}
if (param & D3DSP_WRITEMASK_1) {
strcat(hwLine, "y");
}
if (param & D3DSP_WRITEMASK_2) {
strcat(hwLine, "z");
}
if (param & D3DSP_WRITEMASK_3) {
strcat(hwLine, "w");
}
- }
- vshader_program_add_output_param_swizzle(param, is_color, hwLine); } else {
- /** operand input */
- DWORD swizzle = (param & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
- DWORD swizzle_x = swizzle & 0x03;
- DWORD swizzle_y = (swizzle >> 2) & 0x03;
- DWORD swizzle_z = (swizzle >> 4) & 0x03;
- DWORD swizzle_w = (swizzle >> 6) & 0x03;
- /**
* swizzle bits fields:
* WWZZYYXX
*/
- if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) != swizzle) { /* ! D3DVS_NOSWIZZLE == 0xE4
<<
D3DVS_SWIZZLE_SHIFT */
if (swizzle_x == swizzle_y &&
swizzle_x == swizzle_z &&
swizzle_x == swizzle_w)
{
sprintf(tmpReg, ".%c", swizzle_reg_chars[swizzle_x]);
strcat(hwLine, tmpReg);
} else {
sprintf(tmpReg, ".%c%c%c%c",
swizzle_reg_chars[swizzle_x],
swizzle_reg_chars[swizzle_y],
swizzle_reg_chars[swizzle_z],
swizzle_reg_chars[swizzle_w]);
strcat(hwLine, tmpReg);
}
- }
- vshader_program_add_input_param_swizzle(param, is_color, hwLine); }
}
@@ -1540,7 +1560,7 @@ char tmpChar[80]; ++pToken; sprintf(tmpLine, "ATTRIB ");
vshader_program_add_param(*pToken, 0, tmpLine, This->namedArrays,
This->constantsUsedBitmap);
vshader_program_add_param(*pToken, 0, 0, tmpLine, This->namedArrays,
This->constantsUsedBitmap); sprintf(tmpChar," = %s", attribName); strcat(tmpLine, tmpChar); strcat(tmpLine,";\n"); @@ -1592,12 +1612,12 @@ } } if (curOpcode->num_params > 0) {
vshader_program_add_param(*pToken, 0, tmpLine, This->namedArrays,
This->constantsUsedBitmap);
vshader_program_add_param(*pToken, 0, 0, tmpLine, This->namedArrays,
This->constantsUsedBitmap);
++pToken; for (i = 1; i < curOpcode->num_params; ++i) { strcat(tmpLine, ",");
vshader_program_add_param(*pToken, 1, tmpLine, This->namedArrays,
This->constantsUsedBitmap);
vshader_program_add_param(*pToken, 1, 0, tmpLine, This->namedArrays,
This->constantsUsedBitmap); ++pToken; } } Index: wined3d_private.h =================================================================== RCS file: /home/wine/wine/dlls/wined3d/wined3d_private.h,v retrieving revision 1.67 diff -u -r1.67 wined3d_private.h --- wined3d_private.h 29 Oct 2005 10:30:36 -0000 1.67 +++ wined3d_private.h 2 Nov 2005 23:11:57 -0000 @@ -161,6 +161,11 @@ #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName) #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE
:
FALSE)
+#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF) +#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF) +#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF) +#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f) #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f) #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
Hi,
Changelog:
- defined D3DCOLOR_B macros to access byte values of D3DCOLOR
- use D3DCOLOR macros instead of using shift + masks
- fix a bug where diffuse.lpData checked instead of specular.lpData
- implement color fixup on ARB VShader compilation code: -> on input parameters using swizzle -> add is_color parameter on vshader_program_add_param
The input swizzel needs to be an output swizzel because it should be possible to use anything to generate a colour for output and not just the input colours, that should also get around the is_colour problem.
Having thought about it again the swizell need to be on the input, it shouldn't be too hard to work out which inputs need to be swizelled in the parser first pass.
i think the same :) anyway i have added is_color on output_param if you want to try ... :p (i think only a few few few games may have problems with that this sizzle on input params)
Regards, Raphael
--- Raphael fenix@club-internet.fr wrote:
Hi,
Changelog:
- defined D3DCOLOR_B macros to access byte values of D3DCOLOR
- use D3DCOLOR macros instead of using shift + masks
- fix a bug where diffuse.lpData checked instead of specular.lpData
- implement color fixup on ARB VShader compilation code: -> on input parameters using swizzle -> add is_color parameter on vshader_program_add_param
The input swizzel needs to be an output swizzel because it should be possible to use anything to generate a colour for output and not just the input colours, that should also get around the is_colour problem.
Having thought about it again the swizell need to be on the input, it shouldn't be too hard to work out which inputs need to be swizelled in the parser first pass.
i think the same :) anyway i have added is_color on output_param if you want to try ... :p (i think only a few few few games may have problems with that this sizzle on input params)
Having slept on the problem I don't think many games (if any) are going to use ARGB colours for anything other than the diffuse and specular colour inputs, all the textures will be in the correct order and so are the shader constants. If a game does use any unexpected colours inputs the shader can always be compiled with those inputs swizzled too.
Oliver
Regards, Raphael
___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com