Commit 8eab6d45 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

wined3d: Handle degenerate viewport Z ranges.

parent 9d4eb5ef
......@@ -3565,6 +3565,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
struct lights_settings ls;
unsigned int vertex_size;
BOOL do_clip, lighting;
float min_z, max_z;
unsigned int i;
BYTE *dest_ptr;
HRESULT hr;
......@@ -3648,6 +3649,8 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
init_transformed_lights(&ls, state, device->adapter->d3d_info.wined3d_creation_flags
& WINED3D_LEGACY_FFP_LIGHTING, lighting);
wined3d_viewport_get_z_range(&vp, &min_z, &max_z);
for (i = 0; i < dwCount; ++i)
{
const struct wined3d_stream_info_element *position_element = &stream_info->elements[WINED3D_FFP_POSITION];
......@@ -3720,11 +3723,11 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
x *= vp.width / 2;
y *= vp.height / 2;
z *= vp.max_z - vp.min_z;
z *= max_z - min_z;
x += vp.width / 2 + vp.x;
y += vp.height / 2 + vp.y;
z += vp.min_z;
z += min_z;
rhw = 1 / rhw;
} else {
......
......@@ -4037,6 +4037,7 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
{
const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS];
float min_z, max_z;
if (gl_info->supported[ARB_VIEWPORT_ARRAY])
{
......@@ -4048,8 +4049,9 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
get_viewports(context, state, state->viewport_count, vp);
for (i = 0; i < state->viewport_count; ++i)
{
depth_ranges[i * 2] = vp[i].min_z;
depth_ranges[i * 2 + 1] = vp[i].max_z;
wined3d_viewport_get_z_range(&vp[i], &min_z, &max_z);
depth_ranges[i * 2] = min_z;
depth_ranges[i * 2 + 1] = max_z;
viewports[i * 4] = vp[i].x;
viewports[i * 4 + 1] = vp[i].y;
......@@ -4073,7 +4075,8 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
else
{
get_viewports(context, state, 1, vp);
gl_info->gl_ops.gl.p_glDepthRange(vp[0].min_z, vp[0].max_z);
wined3d_viewport_get_z_range(&vp[0], &min_z, &max_z);
gl_info->gl_ops.gl.p_glDepthRange(min_z, max_z);
gl_info->gl_ops.gl.p_glViewport(vp[0].x, vp[0].y, vp[0].width, vp[0].height);
}
checkGLcall("setting clip space and viewport");
......@@ -4090,6 +4093,7 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
GLdouble depth_ranges[2 * WINED3D_MAX_VIEWPORTS];
GLfloat viewports[4 * WINED3D_MAX_VIEWPORTS];
unsigned int i, reset_count = 0;
float min_z, max_z;
get_viewports(context, state, state->viewport_count, vp);
......@@ -4097,8 +4101,9 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
for (i = 0; i < state->viewport_count; ++i)
{
depth_ranges[i * 2] = vp[i].min_z;
depth_ranges[i * 2 + 1] = vp[i].max_z;
wined3d_viewport_get_z_range(&vp[i], &min_z, &max_z);
depth_ranges[i * 2] = min_z;
depth_ranges[i * 2 + 1] = max_z;
viewports[i * 4] = vp[i].x + pixel_center_offset;
viewports[i * 4 + 1] = vp[i].y + pixel_center_offset;
......
......@@ -5319,6 +5319,14 @@ static inline BOOL wined3d_resource_check_fbo_attached(const struct wined3d_stat
return FALSE;
}
static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
{
*min_z = vp->min_z;
/* The magic constant is derived from tests. */
*max_z = max(vp->max_z, vp->min_z + 0.001f);
}
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
......
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