Commit 1c2392dd authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Only write gl_PointSize for point primitives in shader_glsl_generate_ffp_vertex_shader().

parent 2014141a
......@@ -3981,10 +3981,17 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device,
enum wined3d_primitive_type primitive_type)
{
GLenum gl_primitive_type, prev;
TRACE("device %p, primitive_type %s\n", device, debug_d3dprimitivetype(primitive_type));
device->updateStateBlock->changed.primitive_type = TRUE;
device->updateStateBlock->state.gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
prev = device->updateStateBlock->state.gl_primitive_type;
device->updateStateBlock->state.gl_primitive_type = gl_primitive_type;
if (!device->isRecordingState && gl_primitive_type != prev
&& (gl_primitive_type == GL_POINTS || prev == GL_POINTS))
device_invalidate_state(device, STATE_POINT_SIZE_ENABLE);
}
void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device,
......
......@@ -5007,10 +5007,13 @@ static GLhandleARB shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_
break;
}
shader_addline(buffer, "gl_PointSize = gl_Point.size / sqrt(gl_Point.distanceConstantAttenuation"
" + gl_Point.distanceLinearAttenuation * length(ec_pos.xyz)"
" + gl_Point.distanceQuadraticAttenuation * dot(ec_pos.xyz, ec_pos.xyz));\n");
shader_addline(buffer, "gl_PointSize = clamp(gl_PointSize, gl_Point.sizeMin, gl_Point.sizeMax);\n");
if (settings->point_size)
{
shader_addline(buffer, "gl_PointSize = gl_Point.size / sqrt(gl_Point.distanceConstantAttenuation"
" + gl_Point.distanceLinearAttenuation * length(ec_pos.xyz)"
" + gl_Point.distanceQuadraticAttenuation * dot(ec_pos.xyz, ec_pos.xyz));\n");
shader_addline(buffer, "gl_PointSize = clamp(gl_PointSize, gl_Point.sizeMin, gl_Point.sizeMax);\n");
}
shader_addline(buffer, "}\n");
......@@ -6871,6 +6874,7 @@ static const struct StateEntryTemplate glsl_vertex_pipe_vp_states[] =
{STATE_SAMPLER(7), {0, NULL }, ARB_TEXTURE_NON_POWER_OF_TWO },
{STATE_SAMPLER(7), {0, NULL }, WINED3D_GL_NORMALIZED_TEXRECT},
{STATE_SAMPLER(7), {STATE_SAMPLER(7), sampler_texmatrix }, WINED3D_GL_EXT_NONE },
{STATE_POINT_SIZE_ENABLE, {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, {0, NULL }, WINED3D_GL_EXT_NONE },
};
......
......@@ -5526,6 +5526,7 @@ const struct StateEntryTemplate vp_ffp_states[] =
{ STATE_SAMPLER(7), { 0, NULL }, ARB_TEXTURE_NON_POWER_OF_TWO },
{ STATE_SAMPLER(7), { 0, NULL }, WINED3D_GL_NORMALIZED_TEXRECT },
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix }, WINED3D_GL_EXT_NONE },
{ STATE_POINT_SIZE_ENABLE, { STATE_POINT_SIZE_ENABLE, state_nop }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
......@@ -5869,7 +5870,8 @@ static void validate_state_table(struct StateEntry *state_table)
STATE_FRONTFACE,
STATE_POINTSPRITECOORDORIGIN,
STATE_BASEVERTEXINDEX,
STATE_FRAMEBUFFER
STATE_FRAMEBUFFER,
STATE_POINT_SIZE_ENABLE,
};
unsigned int i, current;
......
......@@ -1073,8 +1073,14 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
if (stateblock->changed.primitive_type)
{
stateblock->device->updateStateBlock->changed.primitive_type = TRUE;
stateblock->device->updateStateBlock->state.gl_primitive_type = stateblock->state.gl_primitive_type;
GLenum gl_primitive_type, prev;
device->updateStateBlock->changed.primitive_type = TRUE;
gl_primitive_type = stateblock->state.gl_primitive_type;
prev = device->updateStateBlock->state.gl_primitive_type;
device->updateStateBlock->state.gl_primitive_type = gl_primitive_type;
if (gl_primitive_type != prev && (gl_primitive_type == GL_POINTS || prev == GL_POINTS))
device_invalidate_state(device, STATE_POINT_SIZE_ENABLE);
}
if (stateblock->changed.indices)
......
......@@ -2588,6 +2588,8 @@ const char *debug_d3dstate(DWORD state)
return "STATE_BASEVERTEXINDEX";
if (STATE_IS_FRAMEBUFFER(state))
return "STATE_FRAMEBUFFER";
if (STATE_IS_POINT_SIZE_ENABLE(state))
return "STATE_POINT_SIZE_ENABLE";
return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
}
......@@ -3530,6 +3532,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
{
memset(settings, 0, sizeof(*settings));
settings->point_size = state->gl_primitive_type == GL_POINTS;
if (!state->render_states[WINED3D_RS_FOGENABLE])
settings->fog_mode = WINED3D_FFP_VS_FOG_OFF;
else if (state->render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE)
......@@ -3552,6 +3555,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
settings->normalize = settings->normal && state->render_states[WINED3D_RS_NORMALIZENORMALS];
settings->lighting = !!state->render_states[WINED3D_RS_LIGHTING];
settings->localviewer = !!state->render_states[WINED3D_RS_LOCALVIEWER];
settings->point_size = state->gl_primitive_type == GL_POINTS;
if (state->render_states[WINED3D_RS_COLORVERTEX] && (si->use_map & (1 << WINED3D_FFP_DIFFUSE)))
{
......
......@@ -1007,7 +1007,10 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC
#define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
#define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
#define STATE_HIGHEST (STATE_FRAMEBUFFER)
#define STATE_POINT_SIZE_ENABLE (STATE_FRAMEBUFFER + 1)
#define STATE_IS_POINT_SIZE_ENABLE(a) ((a) == STATE_POINT_SIZE_ENABLE)
#define STATE_HIGHEST (STATE_POINT_SIZE_ENABLE)
enum fogsource {
FOGSOURCE_FFP,
......@@ -1717,9 +1720,10 @@ struct wined3d_ffp_vs_settings
DWORD normalize : 1;
DWORD lighting : 1;
DWORD localviewer : 1;
DWORD point_size : 1;
DWORD fog_mode : 2;
DWORD texcoords : 8; /* MAX_TEXTURES */
DWORD padding : 18;
DWORD padding : 17;
BYTE texgen[MAX_TEXTURES];
};
......
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