Commit 705aec5a authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- 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
parent 8f554aa4
......@@ -4601,10 +4601,10 @@ HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Count, CONS
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! */
......
......@@ -1416,30 +1416,30 @@ static void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd
/* 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"));
......
......@@ -887,10 +887,70 @@ inline static BOOL vshader_is_comment_token(DWORD token) {
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 @@ inline static void vshader_program_add_param(const DWORD param, int input, char
}
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");
}
}
} 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);
vshader_program_add_output_param_swizzle(param, is_color, hwLine);
} 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 @@ inline static VOID IWineD3DVertexShaderImpl_GenerateProgramArbHW(IWineD3DVertexS
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 @@ inline static VOID IWineD3DVertexShaderImpl_GenerateProgramArbHW(IWineD3DVertexS
}
}
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;
}
}
......
......@@ -161,6 +161,11 @@ extern int num_lock;
#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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment