Commit 92fbe333 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Handle point sprites with PS 3.0.

parent bbcfa6b4
......@@ -3404,7 +3404,7 @@ void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device,
if (device->recording)
device->recording->changed.primitive_type = TRUE;
else if (gl_primitive_type != prev && (gl_primitive_type == GL_POINTS || prev == GL_POINTS))
device_invalidate_state(device, STATE_POINT_SIZE_ENABLE);
device_invalidate_state(device, STATE_POINT_ENABLE);
}
void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device,
......
......@@ -4712,7 +4712,7 @@ static void shader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
const struct wined3d_shader_signature *input_signature,
const struct wined3d_shader_reg_maps *reg_maps,
enum vertexprocessing_mode vertexprocessing)
const struct ps_compile_args *args)
{
unsigned int i;
......@@ -4731,11 +4731,13 @@ static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct w
semantic_idx = input->semantic_idx;
shader_glsl_write_mask_to_str(input->mask, reg_mask);
if (vertexprocessing == vertexshader)
if (args->vp_mode == vertexshader)
{
if (input->sysval_semantic == WINED3D_SV_POSITION)
shader_addline(buffer, "ps_in[%u]%s = vpos%s;\n",
shader->u.ps.input_reg_map[input->register_idx], reg_mask, reg_mask);
else if (args->pointsprite && shader_match_semantic(semantic_name, WINED3D_DECL_USAGE_TEXCOORD))
shader_addline(buffer, "ps_in[%u] = vec4(gl_PointCoord.xy, 0.0, 0.0);\n", input->register_idx);
else
shader_addline(buffer, "ps_in[%u]%s = ps_link[%u]%s;\n",
shader->u.ps.input_reg_map[input->register_idx], reg_mask,
......@@ -4743,7 +4745,7 @@ static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct w
}
else if (shader_match_semantic(semantic_name, WINED3D_DECL_USAGE_TEXCOORD))
{
if (semantic_idx < 8 && vertexprocessing == pretransformed)
if (semantic_idx < 8 && args->vp_mode == pretransformed)
shader_addline(buffer, "ps_in[%u]%s = gl_TexCoord[%u]%s;\n",
shader->u.ps.input_reg_map[input->register_idx], reg_mask, semantic_idx, reg_mask);
else
......@@ -5125,7 +5127,7 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
/* Pack 3.0 inputs */
if (reg_maps->shader_version.major >= 3)
shader_glsl_input_pack(shader, buffer, &shader->input_signature, reg_maps, args->vp_mode);
shader_glsl_input_pack(shader, buffer, &shader->input_signature, reg_maps, args);
/* Base Shader Body */
shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
......@@ -8036,7 +8038,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), glsl_vertex_pipe_texmatrix}, WINED3D_GL_EXT_NONE },
{STATE_POINT_SIZE_ENABLE, {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
{STATE_POINT_ENABLE, {STATE_POINT_ENABLE, glsl_vertex_pipe_shader}, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, {0, NULL }, WINED3D_GL_EXT_NONE },
};
......@@ -8342,6 +8344,7 @@ static const struct StateEntryTemplate glsl_fragment_pipe_state_template[] =
{STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_FOGCOLOR), {STATE_RENDER(WINED3D_RS_FOGCOLOR), state_fogcolor }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_FOGDENSITY), {STATE_RENDER(WINED3D_RS_FOGDENSITY), state_fogdensity }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), glsl_fragment_pipe_shader }, ARB_POINT_SPRITE },
{STATE_TEXTURESTAGE(0,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE },
......@@ -8359,6 +8362,7 @@ static const struct StateEntryTemplate glsl_fragment_pipe_state_template[] =
{STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT), {STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3D_RS_SPECULARENABLE), {STATE_RENDER(WINED3D_RS_SPECULARENABLE), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE },
{STATE_POINT_ENABLE, {STATE_POINT_ENABLE, glsl_fragment_pipe_shader }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, {0, 0 }, WINED3D_GL_EXT_NONE },
};
......
......@@ -2576,6 +2576,9 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
args->fog = WINED3D_FFP_PS_FOG_OFF;
}
}
args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
&& state->gl_primitive_type == GL_POINTS;
}
static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
......
......@@ -5487,7 +5487,7 @@ static 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 },
{ STATE_POINT_ENABLE, { STATE_POINT_ENABLE, state_nop }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
......@@ -5854,7 +5854,7 @@ static void validate_state_table(struct StateEntry *state_table)
STATE_POINTSPRITECOORDORIGIN,
STATE_BASEVERTEXINDEX,
STATE_FRAMEBUFFER,
STATE_POINT_SIZE_ENABLE,
STATE_POINT_ENABLE,
STATE_COLOR_KEY,
};
unsigned int i, current;
......
......@@ -1049,7 +1049,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
prev = device->update_state->gl_primitive_type;
device->update_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);
device_invalidate_state(device, STATE_POINT_ENABLE);
}
if (stateblock->changed.indices)
......
......@@ -3234,8 +3234,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";
if (STATE_IS_POINT_ENABLE(state))
return "STATE_POINT_ENABLE";
if (STATE_IS_COLOR_KEY(state))
return "STATE_COLOR_KEY";
......
......@@ -835,6 +835,7 @@ struct ps_compile_args {
D3D9 has a limit of 16 samplers and the fixup is superfluous
in D3D10 (unconditional NP2 support mandatory). */
WORD shadow; /* MAX_FRAGMENT_SAMPLERS, 16 */
BOOL pointsprite;
};
enum fog_src_type {
......@@ -1075,10 +1076,10 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
#define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
#define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
#define STATE_POINT_SIZE_ENABLE (STATE_FRAMEBUFFER + 1)
#define STATE_IS_POINT_SIZE_ENABLE(a) ((a) == STATE_POINT_SIZE_ENABLE)
#define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
#define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
#define STATE_COLOR_KEY (STATE_POINT_SIZE_ENABLE + 1)
#define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
#define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
#define STATE_HIGHEST (STATE_COLOR_KEY)
......
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