Commit cf312011 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

wined3d: Use fewer calls to set viewport data.

parent b2061c85
...@@ -4034,13 +4034,21 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine ...@@ -4034,13 +4034,21 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
if (gl_info->supported[ARB_VIEWPORT_ARRAY]) if (gl_info->supported[ARB_VIEWPORT_ARRAY])
{ {
GLdouble depth_ranges[2 * WINED3D_MAX_VIEWPORTS];
GLfloat viewports[4 * WINED3D_MAX_VIEWPORTS];
unsigned int i, reset_count = 0; unsigned int i, reset_count = 0;
get_viewports(context, state, state->viewport_count, vp); get_viewports(context, state, state->viewport_count, vp);
for (i = 0; i < state->viewport_count; ++i) for (i = 0; i < state->viewport_count; ++i)
{ {
GL_EXTCALL(glDepthRangeIndexed(i, vp[i].min_z, vp[i].max_z)); depth_ranges[i * 2] = vp[i].min_z;
GL_EXTCALL(glViewportIndexedf(i, vp[i].x, vp[i].y, vp[i].width, vp[i].height)); depth_ranges[i * 2 + 1] = vp[i].max_z;
viewports[i * 4] = vp[i].x;
viewports[i * 4 + 1] = vp[i].y;
viewports[i * 4 + 2] = vp[i].width;
viewports[i * 4 + 3] = vp[i].height;
} }
if (context->viewport_count > state->viewport_count) if (context->viewport_count > state->viewport_count)
...@@ -4048,12 +4056,12 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine ...@@ -4048,12 +4056,12 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
if (reset_count) if (reset_count)
{ {
static const GLfloat reset[4 * WINED3D_MAX_VIEWPORTS]; memset(&depth_ranges[state->viewport_count * 2], 0, reset_count * 2 * sizeof(*depth_ranges));
static const GLdouble resetd[2 * WINED3D_MAX_VIEWPORTS]; memset(&viewports[state->viewport_count * 4], 0, reset_count * 4 * sizeof(*viewports));
GL_EXTCALL(glDepthRangeArrayv(state->viewport_count, reset_count, resetd));
GL_EXTCALL(glViewportArrayv(state->viewport_count, reset_count, reset));
} }
GL_EXTCALL(glDepthRangeArrayv(0, state->viewport_count + reset_count, depth_ranges));
GL_EXTCALL(glViewportArrayv(0, state->viewport_count + reset_count, viewports));
context->viewport_count = state->viewport_count; context->viewport_count = state->viewport_count;
} }
else else
...@@ -4073,6 +4081,8 @@ static void viewport_miscpart_cc(struct wined3d_context *context, ...@@ -4073,6 +4081,8 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
& WINED3D_PIXEL_CENTER_INTEGER ? 63.0f / 128.0f : -1.0f / 128.0f; & WINED3D_PIXEL_CENTER_INTEGER ? 63.0f / 128.0f : -1.0f / 128.0f;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS]; struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS];
GLdouble depth_ranges[2 * WINED3D_MAX_VIEWPORTS];
GLfloat viewports[4 * WINED3D_MAX_VIEWPORTS];
unsigned int i, reset_count = 0; unsigned int i, reset_count = 0;
get_viewports(context, state, state->viewport_count, vp); get_viewports(context, state, state->viewport_count, vp);
...@@ -4083,8 +4093,14 @@ static void viewport_miscpart_cc(struct wined3d_context *context, ...@@ -4083,8 +4093,14 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
{ {
vp[i].x += pixel_center_offset; vp[i].x += pixel_center_offset;
vp[i].y += pixel_center_offset; vp[i].y += pixel_center_offset;
GL_EXTCALL(glDepthRangeIndexed(i, vp[i].min_z, vp[i].max_z));
GL_EXTCALL(glViewportIndexedf(i, vp[i].x, vp[i].y, vp[i].width, vp[i].height)); depth_ranges[i * 2] = vp[i].min_z;
depth_ranges[i * 2 + 1] = vp[i].max_z;
viewports[i * 4 ] = vp[i].x + pixel_center_offset;
viewports[i * 4 + 1] = vp[i].y + pixel_center_offset;
viewports[i * 4 + 2] = vp[i].width;
viewports[i * 4 + 3] = vp[i].height;
} }
if (context->viewport_count > state->viewport_count) if (context->viewport_count > state->viewport_count)
...@@ -4092,12 +4108,12 @@ static void viewport_miscpart_cc(struct wined3d_context *context, ...@@ -4092,12 +4108,12 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
if (reset_count) if (reset_count)
{ {
static const GLfloat reset[4 * WINED3D_MAX_VIEWPORTS]; memset(&depth_ranges[state->viewport_count * 2], 0, reset_count * 2 * sizeof(*depth_ranges));
static const GLdouble resetd[2 * WINED3D_MAX_VIEWPORTS]; memset(&viewports[state->viewport_count * 4], 0, reset_count * 4 * sizeof(*viewports));
GL_EXTCALL(glDepthRangeArrayv(state->viewport_count, reset_count, resetd));
GL_EXTCALL(glViewportArrayv(state->viewport_count, reset_count, reset));
} }
GL_EXTCALL(glDepthRangeArrayv(0, state->viewport_count + reset_count, depth_ranges));
GL_EXTCALL(glViewportArrayv(0, state->viewport_count + reset_count, viewports));
context->viewport_count = state->viewport_count; context->viewport_count = state->viewport_count;
checkGLcall("setting clip space and viewport"); checkGLcall("setting clip space and viewport");
......
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