=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Factor out get_viewport() function.
Alexandre Julliard
julliard at winehq.org
Fri Mar 2 12:16:44 CST 2018
Module: wine
Branch: master
Commit: 544a7daaebcdd329517854b32c4f8f42374cde4f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=544a7daaebcdd329517854b32c4f8f42374cde4f
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Thu Mar 1 19:36:53 2018 +0100
wined3d: Factor out get_viewport() function.
No attachment draw calls are always offscreen.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/state.c | 89 +++++++++++++++++++++++-----------------------------
1 file changed, 39 insertions(+), 50 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index fd858c5..e3c39f6 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4651,22 +4651,32 @@ static void vertexdeclaration(struct wined3d_context *context, const struct wine
}
}
-static void viewport_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+static void get_viewport(struct wined3d_context *context, const struct wined3d_state *state,
+ struct wined3d_viewport *viewport)
{
const struct wined3d_rendertarget_view *depth_stencil = state->fb->depth_stencil;
const struct wined3d_rendertarget_view *target = state->fb->render_targets[0];
- const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_viewport vp = state->viewport;
unsigned int width, height;
- float y;
+
+ *viewport = state->viewport;
if (target)
{
- if (vp.width > target->width)
- vp.width = target->width;
- if (vp.height > target->height)
- vp.height = target->height;
+ if (viewport->width > target->width)
+ viewport->width = target->width;
+ if (viewport->height > target->height)
+ viewport->height = target->height;
+ }
+
+ /*
+ * Note: GL requires lower left, DirectX supplies upper left. This is
+ * reversed when using offscreen rendering.
+ */
+ if (context->render_offscreen)
+ return;
+ if (target)
+ {
wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height);
}
else if (depth_stencil)
@@ -4675,67 +4685,46 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
}
else
{
- height = gl_info->limits.framebuffer_height;
+ FIXME("Could not get the height of render targets.\n");
+ return;
}
- gl_info->gl_ops.gl.p_glDepthRange(vp.min_z, vp.max_z);
+ viewport->y = height - (viewport->y + viewport->height);
+}
+
+static void viewport_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ struct wined3d_viewport vp;
- /* Note: GL requires lower left, DirectX supplies upper left. This is
- * reversed when using offscreen rendering. */
- y = context->render_offscreen ? vp.y : height - (vp.y + vp.height);
+ get_viewport(context, state, &vp);
+
+ gl_info->gl_ops.gl.p_glDepthRange(vp.min_z, vp.max_z);
if (gl_info->supported[ARB_VIEWPORT_ARRAY])
- GL_EXTCALL(glViewportIndexedf(0, vp.x, y, vp.width, vp.height));
+ GL_EXTCALL(glViewportIndexedf(0, vp.x, vp.y, vp.width, vp.height));
else
- gl_info->gl_ops.gl.p_glViewport(vp.x, y, vp.width, vp.height);
+ gl_info->gl_ops.gl.p_glViewport(vp.x, vp.y, vp.width, vp.height);
checkGLcall("setting clip space and viewport");
}
static void viewport_miscpart_cc(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id)
{
- const struct wined3d_rendertarget_view *depth_stencil = state->fb->depth_stencil;
- const struct wined3d_rendertarget_view *target = state->fb->render_targets[0];
- /* See get_projection_matrix() in utils.c for a discussion about those
- * values. */
+ /* See get_projection_matrix() in utils.c for a discussion about those values. */
float pixel_center_offset = context->d3d_info->wined3d_creation_flags
& 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 = state->viewport;
- unsigned int width, height;
-
- if (target)
- {
- if (vp.width > target->width)
- vp.width = target->width;
- if (vp.height > target->height)
- vp.height = target->height;
+ struct wined3d_viewport vp;
- wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height);
- }
- else if (depth_stencil)
- {
- height = depth_stencil->height;
- }
- else
- {
- height = gl_info->limits.framebuffer_height;
- }
+ get_viewport(context, state, &vp);
+ vp.x += pixel_center_offset;
+ vp.y += pixel_center_offset;
gl_info->gl_ops.gl.p_glDepthRange(vp.min_z, vp.max_z);
- if (context->render_offscreen)
- {
- GL_EXTCALL(glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE));
- GL_EXTCALL(glViewportIndexedf(0, vp.x + pixel_center_offset, vp.y + pixel_center_offset,
- vp.width, vp.height));
- }
- else
- {
- GL_EXTCALL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE));
- GL_EXTCALL(glViewportIndexedf(0, vp.x + pixel_center_offset,
- (height - (vp.y + vp.height)) + pixel_center_offset, vp.width, vp.height));
- }
+ GL_EXTCALL(glClipControl(context->render_offscreen ? GL_UPPER_LEFT : GL_LOWER_LEFT, GL_ZERO_TO_ONE));
+ GL_EXTCALL(glViewportIndexedf(0, vp.x, vp.y, vp.width, vp.height));
checkGLcall("setting clip space and viewport");
}
More information about the wine-cvs
mailing list