wined3d: Replace D3DCOLORTOGLFLOAT4 with an inline function.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-03-08 15:51:13 +01:00 committed by Alexandre Julliard
parent 09aa6acc0b
commit edb3ea66a0
7 changed files with 51 additions and 49 deletions

View File

@ -5919,7 +5919,7 @@ static void state_texfactor_arbfp(struct wined3d_context *context,
{
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct wined3d_color color;
/* Don't load the parameter if we're using an arbfp pixel shader,
* otherwise we'll overwrite application provided constants. */
@ -5934,9 +5934,9 @@ static void state_texfactor_arbfp(struct wined3d_context *context,
priv->highest_dirty_ps_const = max(priv->highest_dirty_ps_const, ARB_FFP_CONST_TFACTOR + 1);
}
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, col));
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, col)");
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_TEXTUREFACTOR]);
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, &color.r));
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, &color.r)");
}
static void state_arb_specularenable(struct wined3d_context *context,

View File

@ -953,16 +953,16 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES],
static void atifs_tfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
struct wined3d_color color;
if (!ctx_priv->last_shader
|| ctx_priv->last_shader->constants[ATIFS_CONST_TFACTOR - GL_CON_0_ATI] != ATIFS_CONSTANT_TFACTOR)
return;
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, col));
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, col)");
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_TEXTUREFACTOR]);
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, &color.r));
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, &color.r)");
}
static void set_bumpmat(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@ -998,16 +998,16 @@ static void atifs_stage_constant(struct wined3d_context *context, const struct w
{
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
struct wined3d_color color;
if (!ctx_priv->last_shader
|| ctx_priv->last_shader->constants[stage] != ATIFS_CONSTANT_STAGE)
return;
D3DCOLORTOGLFLOAT4(state->texture_states[stage][WINED3D_TSS_CONSTANT], col);
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), col));
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), col)");
wined3d_color_from_d3dcolor(&color, state->texture_states[stage][WINED3D_TSS_CONSTANT]);
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), &color.r));
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), &color.r)");
}
static void set_tex_op_atifs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)

View File

@ -291,13 +291,13 @@ static void drawStridedSlow(const struct wined3d_device *device, struct wined3d_
if (num_untracked_materials)
{
struct wined3d_color color;
unsigned char i;
float color[4];
D3DCOLORTOGLFLOAT4(*(const DWORD *)ptrToCoords, color);
wined3d_color_from_d3dcolor(&color, *(const DWORD *)ptrToCoords);
for (i = 0; i < num_untracked_materials; ++i)
{
gl_info->gl_ops.gl.p_glMaterialfv(GL_FRONT_AND_BACK, context->untracked_materials[i], color);
gl_info->gl_ops.gl.p_glMaterialfv(GL_FRONT_AND_BACK, context->untracked_materials[i], &color.r);
}
}
}

View File

@ -1137,10 +1137,10 @@ static void shader_glsl_ffp_vertex_lightambient_uniform(const struct wined3d_con
const struct wined3d_state *state, struct glsl_shader_prog_link *prog)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct wined3d_color color;
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_AMBIENT], col);
GL_EXTCALL(glUniform3fv(prog->vs.light_ambient_location, 1, col));
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_AMBIENT]);
GL_EXTCALL(glUniform3fv(prog->vs.light_ambient_location, 1, &color.r));
checkGLcall("glUniform3fv");
}
@ -1245,16 +1245,16 @@ static void shader_glsl_load_fog_uniform(const struct wined3d_context *context,
const struct wined3d_state *state, struct glsl_shader_prog_link *prog)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_color color;
float start, end, scale;
union
{
DWORD d;
float f;
} tmpvalue;
float col[4];
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_FOGCOLOR], col);
GL_EXTCALL(glUniform4fv(prog->ps.fog_color_location, 1, col));
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_FOGCOLOR]);
GL_EXTCALL(glUniform4fv(prog->ps.fog_color_location, 1, &color.r));
tmpvalue.d = state->render_states[WINED3D_RS_FOGDENSITY];
GL_EXTCALL(glUniform1f(prog->ps.fog_density_location, tmpvalue.f));
get_fog_start_end(context, state, &start, &end);
@ -1426,12 +1426,12 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (update_mask & WINED3D_SHADER_CONST_FFP_PS)
{
float col[4];
struct wined3d_color color;
if (prog->ps.tex_factor_location != -1)
{
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
GL_EXTCALL(glUniform4fv(prog->ps.tex_factor_location, 1, col));
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_TEXTUREFACTOR]);
GL_EXTCALL(glUniform4fv(prog->ps.tex_factor_location, 1, &color.r));
}
if (state->render_states[WINED3D_RS_SPECULARENABLE])
@ -1444,8 +1444,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (prog->ps.tss_constant_location[i] == -1)
continue;
D3DCOLORTOGLFLOAT4(state->texture_states[i][WINED3D_TSS_CONSTANT], col);
GL_EXTCALL(glUniform4fv(prog->ps.tss_constant_location[i], 1, col));
wined3d_color_from_d3dcolor(&color, state->texture_states[i][WINED3D_TSS_CONSTANT]);
GL_EXTCALL(glUniform4fv(prog->ps.tss_constant_location[i], 1, &color.r));
}
checkGLcall("fixed function uniforms");

View File

@ -647,10 +647,10 @@ static void nvts_bumpenvmat(struct wined3d_context *context, const struct wined3
static void nvrc_texfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct wined3d_color color;
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_TEXTUREFACTOR]);
GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &color.r));
}
/* Context activation is done by the caller. */

View File

@ -260,11 +260,11 @@ static void state_zfunc(struct wined3d_context *context, const struct wined3d_st
static void state_ambient(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct wined3d_color color;
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_AMBIENT], col);
TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
gl_info->gl_ops.gl.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_AMBIENT]);
TRACE("Setting ambient to {%.8e, %.8e, %.8e, %.8e}.\n", color.r, color.g, color.b, color.a);
gl_info->gl_ops.gl.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &color.r);
checkGLcall("glLightModel for MODEL_AMBIENT");
}
@ -497,12 +497,12 @@ static void state_blendfactor_w(struct wined3d_context *context, const struct wi
static void state_blendfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct wined3d_color color;
TRACE("Setting blend factor to %#x.\n", state->render_states[WINED3D_RS_BLENDFACTOR]);
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_BLENDFACTOR], col);
GL_EXTCALL(glBlendColor(col[0], col[1], col[2], col[3]));
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_BLENDFACTOR]);
GL_EXTCALL(glBlendColor(color.r, color.g, color.b, color.a));
checkGLcall("glBlendColor");
}
@ -736,12 +736,12 @@ static void state_specularenable(struct wined3d_context *context, const struct w
static void state_texfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_color color;
unsigned int i;
/* Note the texture color applies to all textures whereas
* GL_TEXTURE_ENV_COLOR applies to active only. */
float col[4];
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col);
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_TEXTUREFACTOR]);
/* And now the default texture color as well */
for (i = 0; i < context->d3d_info->limits.ffp_blend_stages; ++i)
@ -750,7 +750,7 @@ static void state_texfactor(struct wined3d_context *context, const struct wined3
* per texture, so apply it now ready to be used! */
context_active_texture(context, gl_info, i);
gl_info->gl_ops.gl.p_glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
gl_info->gl_ops.gl.p_glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &color.r);
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
}
}
@ -1179,10 +1179,10 @@ void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_st
void state_fogcolor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
struct wined3d_color color;
D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_FOGCOLOR], col);
gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, col);
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_FOGCOLOR]);
gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, &color.r);
checkGLcall("glFog GL_FOG_COLOR");
}
@ -3488,7 +3488,8 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
desc->address_u = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_U]);
desc->address_v = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_V]);
desc->address_w = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_W]);
D3DCOLORTOGLFLOAT4(sampler_states[WINED3D_SAMP_BORDER_COLOR], desc->border_color);
wined3d_color_from_d3dcolor((struct wined3d_color *)desc->border_color,
sampler_states[WINED3D_SAMP_BORDER_COLOR]);
if (sampler_states[WINED3D_SAMP_MAG_FILTER] > WINED3D_TEXF_ANISOTROPIC)
FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
sampler_states[WINED3D_SAMP_MAG_FILTER]);

View File

@ -989,12 +989,13 @@ extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDD
#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
#define D3DCOLORTOGLFLOAT4(dw, vec) do { \
(vec)[0] = D3DCOLOR_B_R(dw) / 255.0f; \
(vec)[1] = D3DCOLOR_B_G(dw) / 255.0f; \
(vec)[2] = D3DCOLOR_B_B(dw) / 255.0f; \
(vec)[3] = D3DCOLOR_B_A(dw) / 255.0f; \
} while(0)
static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
{
wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
}
#define HIGHEST_TRANSFORMSTATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */