Commit 0985606b authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Flat shading emulation for core contexts.

parent 36800e52
......@@ -4596,7 +4596,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
int i;
WORD int_skip;
find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super);
find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super, d3d_info);
args->clip.boolclip_compare = 0;
if (use_ps(state))
......@@ -6879,6 +6879,7 @@ static const struct StateEntryTemplate arbfp_fragmentstate_template[] =
{STATE_TEXTURESTAGE(6,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_SPECULARENABLE), { STATE_RENDER(WINED3D_RS_SPECULARENABLE), state_arb_specularenable}, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_SHADEMODE), { STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
......
......@@ -1114,6 +1114,7 @@ static const struct StateEntryTemplate atifs_fragmentstate_template[] = {
{STATE_RENDER(WINED3D_RS_FOGEND), { STATE_RENDER(WINED3D_RS_FOGSTART), NULL }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), atifs_srgbwriteenable }, WINED3D_GL_EXT_NONE },
{STATE_COLOR_KEY, { STATE_COLOR_KEY, state_nop }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_SHADEMODE), { STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
......
......@@ -3725,6 +3725,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
adapter->d3d_info.xyzrhw = vertex_caps.xyzrhw;
adapter->d3d_info.ffp_generic_attributes = vertex_caps.ffp_generic_attributes;
adapter->d3d_info.limits.ffp_vertex_blend_matrices = vertex_caps.max_vertex_blend_matrices;
adapter->d3d_info.emulated_flatshading = vertex_caps.emulated_flatshading;
adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
adapter->d3d_info.limits.ffp_blend_stages = fragment_caps.MaxTextureBlendStages;
......
......@@ -899,6 +899,7 @@ static const struct StateEntryTemplate nvrc_fragmentstate_template[] =
{ STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), { STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_FOGSTART), { STATE_RENDER(WINED3D_RS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_FOGEND), { STATE_RENDER(WINED3D_RS_FOGSTART), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_SHADEMODE), { STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), nvts_texdim }, NV_TEXTURE_SHADER2 },
......
......@@ -2209,7 +2209,7 @@ HRESULT CDECL wined3d_shader_set_local_constants_float(struct wined3d_shader *sh
}
void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
WORD swizzle_map, struct vs_compile_args *args)
WORD swizzle_map, struct vs_compile_args *args, const struct wined3d_d3d_info *d3d_info)
{
args->fog_src = state->render_states[WINED3D_RS_FOGTABLEMODE]
== WINED3D_FOG_NONE ? VS_FOG_COORD : VS_FOG_Z;
......@@ -2218,6 +2218,10 @@ void find_vs_compile_args(const struct wined3d_state *state, const struct wined3
args->point_size = state->gl_primitive_type == GL_POINTS;
args->per_vertex_point_size = shader->reg_maps.point_size;
args->swizzle_map = swizzle_map;
if (d3d_info->emulated_flatshading)
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
else
args->flatshading = FALSE;
}
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2)
......@@ -2405,6 +2409,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
BOOL position_transformed, struct ps_compile_args *args, const struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
const struct wined3d_texture *texture;
UINT i;
......@@ -2608,6 +2613,9 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
&& state->gl_primitive_type == GL_POINTS;
if (d3d_info->emulated_flatshading)
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
}
static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
......
......@@ -165,7 +165,7 @@ static void state_cullmode(struct wined3d_context *context, const struct wined3d
}
}
static void state_shademode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
void state_shademode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
......@@ -4941,7 +4941,6 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_WRAPU), { STATE_RENDER(WINED3D_RS_WRAPU), state_wrapu }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_WRAPV), { STATE_RENDER(WINED3D_RS_WRAPV), state_wrapv }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_FILLMODE), { STATE_RENDER(WINED3D_RS_FILLMODE), state_fillmode }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_SHADEMODE), { STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_LINEPATTERN), { STATE_RENDER(WINED3D_RS_LINEPATTERN), state_linepattern }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_MONOENABLE), { STATE_RENDER(WINED3D_RS_MONOENABLE), state_monoenable }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ROP2), { STATE_RENDER(WINED3D_RS_ROP2), state_rop2 }, WINED3D_GL_EXT_NONE },
......@@ -5549,6 +5548,7 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
{ STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), { STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_FOGSTART), { STATE_RENDER(WINED3D_RS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_FOGEND), { STATE_RENDER(WINED3D_RS_FOGSTART), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_SHADEMODE), { STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, WINED3D_GL_EXT_NONE },
......
......@@ -4602,6 +4602,11 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d
settings->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
&& state->gl_primitive_type == GL_POINTS;
if (d3d_info->emulated_flatshading)
settings->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
else
settings->flatshading = FALSE;
}
const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
......@@ -4792,6 +4797,12 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
}
if (d3d_info->limits.varying_count >= wined3d_max_compat_varyings(gl_info))
settings->texcoords = (1u << MAX_TEXTURES) - 1;
if (d3d_info->emulated_flatshading)
settings->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
else
settings->flatshading = FALSE;
return;
}
......@@ -4872,6 +4883,11 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
else
settings->fog_mode = WINED3D_FFP_VS_FOG_DEPTH;
if (d3d_info->emulated_flatshading)
settings->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
else
settings->flatshading = FALSE;
settings->padding = 0;
}
......
......@@ -849,6 +849,7 @@ struct ps_compile_args {
WORD shadow; /* MAX_FRAGMENT_SAMPLERS, 16 */
WORD texcoords_initialized; /* MAX_TEXTURES, 8 */
BOOL pointsprite;
BOOL flatshading;
};
enum fog_src_type {
......@@ -862,7 +863,8 @@ struct vs_compile_args
BYTE clip_enabled : 1;
BYTE point_size : 1;
BYTE per_vertex_point_size : 1;
BYTE padding : 5;
BYTE flatshading : 1;
BYTE padding : 4;
WORD swizzle_map; /* MAX_ATTRIBS, 16 */
};
......@@ -1317,6 +1319,7 @@ struct fragment_pipeline
struct wined3d_vertex_caps
{
BOOL xyzrhw;
BOOL emulated_flatshading;
BOOL ffp_generic_attributes;
DWORD max_active_lights;
DWORD max_vertex_blend_matrices;
......@@ -1785,6 +1788,7 @@ struct wined3d_d3d_info
struct wined3d_d3d_limits limits;
struct wined3d_ffp_attrib_ops ffp_attrib_ops;
BOOL xyzrhw;
BOOL emulated_flatshading;
BOOL ffp_generic_attributes;
BOOL vs_clipping;
BOOL shader_color_key;
......@@ -1880,7 +1884,8 @@ struct ffp_frag_settings
unsigned char texcoords_initialized;
unsigned char color_key_enabled : 1;
unsigned char pointsprite : 1;
unsigned char padding : 6;
unsigned char flatshading : 1;
unsigned char padding : 5;
};
struct ffp_frag_desc
......@@ -1939,7 +1944,8 @@ struct wined3d_ffp_vs_settings
DWORD fog_mode : 2;
DWORD texcoords : 8; /* MAX_TEXTURES */
DWORD ortho_fog : 1;
DWORD padding : 11;
DWORD flatshading : 1;
DWORD padding : 10;
DWORD texgen[MAX_TEXTURES];
};
......@@ -2902,6 +2908,8 @@ void state_pointsprite_w(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
void state_pointsprite(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
void state_shademode(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
......@@ -3024,7 +3032,8 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
const struct wined3d_context *context) DECLSPEC_HIDDEN;
void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
WORD swizzle_map, struct vs_compile_args *args) DECLSPEC_HIDDEN;
WORD swizzle_map, struct vs_compile_args *args,
const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
......
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