[PATCH 1/6] wined3d: Prepare GL resources before looking for an FBO entry.
Stefan Dösinger
stefan at codeweavers.com
Thu Oct 22 16:38:39 CDT 2015
It is a bit unfortunate that we have to do this every draw now...
Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
---
dlls/wined3d/context.c | 55 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 48 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e324875..a40f126 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -141,8 +141,6 @@ static void context_attach_depth_stencil_fbo(struct wined3d_context *context,
{
case WINED3D_LOCATION_TEXTURE_RGB:
case WINED3D_LOCATION_TEXTURE_SRGB:
- wined3d_texture_prepare_texture(depth_stencil->container, context, FALSE);
-
if (format_flags & WINED3DFMT_FLAG_DEPTH)
{
gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_DEPTH_ATTACHMENT,
@@ -161,13 +159,11 @@ static void context_attach_depth_stencil_fbo(struct wined3d_context *context,
break;
case WINED3D_LOCATION_RB_MULTISAMPLE:
- surface_prepare_rb(depth_stencil, gl_info, TRUE);
context_attach_depth_stencil_rb(gl_info, fbo_target,
format_flags, depth_stencil->rb_multisample);
break;
case WINED3D_LOCATION_RB_RESOLVED:
- surface_prepare_rb(depth_stencil, gl_info, FALSE);
context_attach_depth_stencil_rb(gl_info, fbo_target,
format_flags, depth_stencil->rb_resolved);
break;
@@ -217,7 +213,6 @@ static void context_attach_surface_fbo(struct wined3d_context *context,
case WINED3D_LOCATION_TEXTURE_RGB:
case WINED3D_LOCATION_TEXTURE_SRGB:
srgb = location == WINED3D_LOCATION_TEXTURE_SRGB;
- wined3d_texture_prepare_texture(surface->container, context, srgb);
gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
surface->texture_target, surface_get_texture_name(surface, gl_info, srgb),
surface->texture_level);
@@ -225,14 +220,12 @@ static void context_attach_surface_fbo(struct wined3d_context *context,
break;
case WINED3D_LOCATION_RB_MULTISAMPLE:
- surface_prepare_rb(surface, gl_info, TRUE);
gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
GL_RENDERBUFFER, surface->rb_multisample);
checkGLcall("glFramebufferRenderbuffer()");
break;
case WINED3D_LOCATION_RB_RESOLVED:
- surface_prepare_rb(surface, gl_info, FALSE);
gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
GL_RENDERBUFFER, surface->rb_resolved);
checkGLcall("glFramebufferRenderbuffer()");
@@ -476,6 +469,7 @@ static void context_apply_fbo_state(struct wined3d_context *context, GLenum targ
DWORD color_location, DWORD ds_location)
{
struct fbo_entry *entry, *entry2;
+ unsigned int i;
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
{
@@ -495,6 +489,53 @@ static void context_apply_fbo_state(struct wined3d_context *context, GLenum targ
}
else
{
+ if (depth_stencil)
+ {
+ switch (ds_location)
+ {
+ case WINED3D_LOCATION_TEXTURE_RGB:
+ case WINED3D_LOCATION_TEXTURE_SRGB:
+ wined3d_texture_prepare_texture(depth_stencil->container, context, FALSE);
+ break;
+
+ case WINED3D_LOCATION_RB_MULTISAMPLE:
+ surface_prepare_rb(depth_stencil, context->gl_info, TRUE);
+ break;
+
+ case WINED3D_LOCATION_RB_RESOLVED:
+ surface_prepare_rb(depth_stencil, context->gl_info, FALSE);
+ break;
+ }
+ }
+
+ if (render_targets)
+ {
+ for (i = 0; i < context->gl_info->limits.buffers; ++i)
+ {
+ if (!render_targets[i] || render_targets[i]->resource.format->id == WINED3DFMT_NULL)
+ continue;
+
+ switch (color_location)
+ {
+ case WINED3D_LOCATION_TEXTURE_RGB:
+ wined3d_texture_prepare_texture(render_targets[i]->container, context, FALSE);
+ break;
+
+ case WINED3D_LOCATION_TEXTURE_SRGB:
+ wined3d_texture_prepare_texture(render_targets[i]->container, context, TRUE);
+ break;
+
+ case WINED3D_LOCATION_RB_MULTISAMPLE:
+ surface_prepare_rb(render_targets[i], context->gl_info, TRUE);
+ break;
+
+ case WINED3D_LOCATION_RB_RESOLVED:
+ surface_prepare_rb(render_targets[i], context->gl_info, FALSE);
+ break;
+ }
+ }
+ }
+
context->current_fbo = context_find_fbo_entry(context, target, render_targets, depth_stencil,
color_location, ds_location);
context_apply_fbo_entry(context, target, context->current_fbo);
--
2.4.10
More information about the wine-patches
mailing list