diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index e09c6fd2a43..8c083105cb4 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2418,6 +2418,8 @@ static void context_set_render_offscreen(struct wined3d_context *context, BOOL o context_invalidate_state(context, STATE_VIEWPORT); context_invalidate_state(context, STATE_SCISSORRECT); context_invalidate_state(context, STATE_FRONTFACE); + if (context->gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) + context_invalidate_state(context, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); context->render_offscreen = offscreen; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 55cbdcfe211..72740af3245 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2194,9 +2194,23 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont } if (reg_maps->vpos || reg_maps->usesdsy) { - ++extra_constants_needed; - shader_addline(buffer, "uniform vec4 ycorrection;\n"); - shader_addline(buffer, "vec4 vpos;\n"); + if (reg_maps->usesdsy || !gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) + { + ++extra_constants_needed; + shader_addline(buffer, "uniform vec4 ycorrection;\n"); + } + if (reg_maps->vpos) + { + if (gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) + { + if (shader->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER) + shader_addline(buffer, "layout(%spixel_center_integer) in vec4 gl_FragCoord;\n", + ps_args->render_offscreen ? "" : "origin_upper_left, "); + else if (!ps_args->render_offscreen) + shader_addline(buffer, "layout(origin_upper_left) in vec4 gl_FragCoord;\n"); + } + shader_addline(buffer, "vec4 vpos;\n"); + } } if (ps_args->alpha_test_func + 1 != WINED3D_CMP_ALWAYS) @@ -5899,6 +5913,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context shader_glsl_enable_extensions(buffer, gl_info); if (gl_info->supported[ARB_DERIVATIVE_CONTROL]) shader_addline(buffer, "#extension GL_ARB_derivative_control : enable\n"); + if (gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) + shader_addline(buffer, "#extension GL_ARB_fragment_coord_conventions : enable\n"); if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); /* The spec says that it doesn't have to be explicitly enabled, but the @@ -5929,7 +5945,9 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context * on drivers that returns integer values. */ if (reg_maps->vpos) { - if (shader->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER) + if (gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) + shader_addline(buffer, "vpos = gl_FragCoord;\n"); + else if (shader->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER) shader_addline(buffer, "vpos = floor(vec4(0, ycorrection[0], 0, 0) + gl_FragCoord * vec4(1, ycorrection[1], 1, 1));\n"); else diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 1c48589c2c4..594520c8eba 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3279,6 +3279,8 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 if (d3d_info->emulated_flatshading) args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT; + + args->render_offscreen = gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS] ? context->render_offscreen : 0; } static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_device *device, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index a968bda6698..851c9149752 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1107,7 +1107,8 @@ struct ps_compile_args { DWORD pointsprite : 1; DWORD flatshading : 1; DWORD alpha_test_func : 3; - DWORD padding : 27; + DWORD render_offscreen : 1; + DWORD padding : 26; }; enum fog_src_type {