Module: wine Branch: master Commit: b02a166cc84a1c61db9e91e26e6b8e0a8662fd19 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b02a166cc84a1c61db9e91e26e...
Author: Matteo Bruni mbruni@codeweavers.com Date: Fri Jun 5 00:37:32 2015 +0200
wined3d: Introduce a get_fog_start_end() function.
---
dlls/wined3d/state.c | 41 +------------------------------------- dlls/wined3d/utils.c | 45 ++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 917d155..b7d7f92 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1006,47 +1006,8 @@ void state_fogstartend(struct wined3d_context *context, const struct wined3d_sta { const struct wined3d_gl_info *gl_info = context->gl_info; float fogstart, fogend; - union { - DWORD d; - float f; - } tmpvalue; - - switch(context->fog_source) { - case FOGSOURCE_VS: - fogstart = 1.0f; - fogend = 0.0f; - break; - - case FOGSOURCE_COORD: - fogstart = 255.0f; - fogend = 0.0f; - break;
- case FOGSOURCE_FFP: - tmpvalue.d = state->render_states[WINED3D_RS_FOGSTART]; - fogstart = tmpvalue.f; - tmpvalue.d = state->render_states[WINED3D_RS_FOGEND]; - fogend = tmpvalue.f; - /* Special handling for fogstart == fogend. In d3d with vertex - * fog, everything is fogged. With table fog, everything with - * fog_coord < fog_start is unfogged, and fog_coord > fog_start - * is fogged. Windows drivers disagree when fog_coord == fog_start. */ - if (state->render_states[WINED3D_RS_FOGTABLEMODE] == WINED3D_FOG_NONE - && fogstart == fogend) - { - fogstart = -INFINITY; - fogend = 0.0f; - } - break; - - default: - /* This should not happen.context->fog_source is set in wined3d, not the app. - * Still this is needed to make the compiler happy - */ - ERR("Unexpected fog coordinate source\n"); - fogstart = 0.0f; - fogend = 0.0f; - } + get_fog_start_end(context, state, &fogstart, &fogend);
gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, fogstart); checkGLcall("glFogf(GL_FOG_START, fogstart)"); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 2a4ac83..ed4262a 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -3654,6 +3654,51 @@ void get_pointsize(const struct wined3d_context *context, const struct wined3d_s *out_pointsize = pointsize.f; }
+void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state, + float *start, float *end) +{ + union + { + DWORD d; + float f; + } tmpvalue; + + switch (context->fog_source) + { + case FOGSOURCE_VS: + *start = 1.0f; + *end = 0.0f; + break; + + case FOGSOURCE_COORD: + *start = 255.0f; + *end = 0.0f; + break; + + case FOGSOURCE_FFP: + tmpvalue.d = state->render_states[WINED3D_RS_FOGSTART]; + *start = tmpvalue.f; + tmpvalue.d = state->render_states[WINED3D_RS_FOGEND]; + *end = tmpvalue.f; + /* Special handling for fog_start == fog_end. In d3d with vertex + * fog, everything is fogged. With table fog, everything with + * fog_coord < fog_start is unfogged, and fog_coord > fog_start + * is fogged. Windows drivers disagree when fog_coord == fog_start. */ + if (state->render_states[WINED3D_RS_FOGTABLEMODE] == WINED3D_FOG_NONE && *start == *end) + { + *start = -INFINITY; + *end = 0.0f; + } + break; + + default: + /* This should not happen, context->fog_source is set in wined3d, not the app. */ + ERR("Unexpected fog coordinate source.\n"); + *start = 0.0f; + *end = 0.0f; + } +} + /* This small helper function is used to convert a bitmask into the number of masked bits */ unsigned int count_bits(unsigned int mask) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d9de679..93cfd9e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3074,6 +3074,8 @@ void get_pointsize_minmax(const struct wined3d_context *context, const struct wi float *out_min, float *out_max) DECLSPEC_HIDDEN; void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state, float *out_pointsize, float *out_att) DECLSPEC_HIDDEN; +void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state, + float *start, float *end) DECLSPEC_HIDDEN;
/* Using additional shader constants (uniforms in GLSL / program environment * or local parameters in ARB) is costly: