wined3d: Use fewer calls to set viewport data.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-04-27 13:58:00 +03:00 committed by Alexandre Julliard
parent b2061c8589
commit cf312011c0
1 changed files with 30 additions and 14 deletions

View File

@ -4034,13 +4034,21 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
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;
get_viewports(context, state, state->viewport_count, vp);
for (i = 0; i < state->viewport_count; ++i)
{
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;
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)
@ -4048,12 +4056,12 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
if (reset_count)
{
static const GLfloat reset[4 * WINED3D_MAX_VIEWPORTS];
static const GLdouble resetd[2 * WINED3D_MAX_VIEWPORTS];
GL_EXTCALL(glDepthRangeArrayv(state->viewport_count, reset_count, resetd));
GL_EXTCALL(glViewportArrayv(state->viewport_count, reset_count, reset));
memset(&depth_ranges[state->viewport_count * 2], 0, reset_count * 2 * sizeof(*depth_ranges));
memset(&viewports[state->viewport_count * 4], 0, reset_count * 4 * sizeof(*viewports));
}
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;
}
else
@ -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;
const struct wined3d_gl_info *gl_info = context->gl_info;
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;
get_viewports(context, state, state->viewport_count, vp);
@ -4083,8 +4093,14 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
{
vp[i].x += 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)
@ -4092,12 +4108,12 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
if (reset_count)
{
static const GLfloat reset[4 * WINED3D_MAX_VIEWPORTS];
static const GLdouble resetd[2 * WINED3D_MAX_VIEWPORTS];
GL_EXTCALL(glDepthRangeArrayv(state->viewport_count, reset_count, resetd));
GL_EXTCALL(glViewportArrayv(state->viewport_count, reset_count, reset));
memset(&depth_ranges[state->viewport_count * 2], 0, reset_count * 2 * sizeof(*depth_ranges));
memset(&viewports[state->viewport_count * 4], 0, reset_count * 4 * sizeof(*viewports));
}
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;
checkGLcall("setting clip space and viewport");