From e500cf7d973f002cab7d7a08e01803425b7473e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 10 Apr 2017 12:27:42 +0200 Subject: [PATCH] wined3d: Attach render target texture views to FBO. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d10core/tests/device.c | 6 ++++-- dlls/d3d11/tests/d3d11.c | 2 +- dlls/wined3d/context.c | 38 ++++++++++++++++++++++------------ dlls/wined3d/wined3d_private.h | 13 ++++++------ 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index b0bc8f9ca40..566529016b2 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -8457,7 +8457,9 @@ static void test_clear_render_target_view(void) check_texture_color(texture, expected_color, 1); } else - win_skip("D3D11 is not available, skipping test.\n"); + { + win_skip("D3D11 is not available.\n"); + } ID3D10Device_ClearRenderTargetView(device, srgb_rtv, color); check_texture_color(srgb_texture, expected_srgb_color, 1); @@ -8494,7 +8496,7 @@ static void test_clear_render_target_view(void) { BOOL broken_device = is_warp_device(device) || is_nvidia_device(device); DWORD color = get_readback_color(&rb, 80 + i * 160, 60 + j * 120); - todo_wine ok(compare_color(color, expected_srgb_color, 1) + ok(compare_color(color, expected_srgb_color, 1) || broken(compare_color(color, expected_color, 1) && broken_device), "Got unexpected color 0x%08x.\n", color); } diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 94fd367ea6b..897a929d5fb 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -8958,7 +8958,7 @@ static void test_clear_render_target_view(void) { BOOL broken_device = is_warp_device(device) || is_nvidia_device(device); DWORD color = get_readback_color(&rb, 80 + i * 160, 60 + j * 120); - todo_wine ok(compare_color(color, expected_srgb_color, 1) + ok(compare_color(color, expected_srgb_color, 1) || broken(compare_color(color, expected_color, 1) && broken_device), "Got unexpected color 0x%08x.\n", color); } diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 7c090d432a8..aaf9ab0beb9 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -34,6 +34,7 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); WINE_DECLARE_DEBUG_CHANNEL(d3d_synchronous); #define WINED3D_MAX_FBO_ENTRIES 64 +#define WINED3D_ALL_LAYERS (~0u) static DWORD wined3d_context_tls_idx; @@ -127,6 +128,17 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context, { gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment, GL_TEXTURE_2D, 0, 0); } + else if (resource->layer == WINED3D_ALL_LAYERS) + { + if (!gl_info->fbo_ops.glFramebufferTexture) + { + FIXME("OpenGL implementation doesn't support glFramebufferTexture().\n"); + return; + } + + gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment, + resource->object, resource->level); + } else if (resource->target == GL_TEXTURE_2D_ARRAY) { if (!gl_info->fbo_ops.glFramebufferTextureLayer) @@ -138,17 +150,6 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context, gl_info->fbo_ops.glFramebufferTextureLayer(fbo_target, attachment, resource->object, resource->level, resource->layer); } - else if (resource->target == GL_TEXTURE_3D) - { - if (!gl_info->fbo_ops.glFramebufferTexture) - { - FIXME("OpenGL implementation doesn't support glFramebufferTexture().\n"); - return; - } - - gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment, - resource->object, resource->level); - } else { gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment, @@ -401,6 +402,15 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co return; } + if (render_target->gl_view.name) + { + key->objects[idx].object = render_target->gl_view.name; + key->objects[idx].target = render_target->gl_view.target; + key->objects[idx].level = 0; + key->objects[idx].layer = WINED3D_ALL_LAYERS; + return; + } + texture = wined3d_texture_from_resource(resource); if (resource->type == WINED3D_RTYPE_TEXTURE_2D) { @@ -423,7 +433,7 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co { key->objects[idx].target = texture->target; key->objects[idx].level = sub_resource_idx % texture->level_count; - key->objects[idx].layer = 0; + key->objects[idx].layer = WINED3D_ALL_LAYERS; } switch (location) @@ -457,7 +467,7 @@ static void context_generate_fbo_key(const struct wined3d_context *context, struct wined3d_surface *depth_stencil_surface, DWORD color_location, DWORD ds_location) { - struct wined3d_rendertarget_info depth_stencil = {0}; + struct wined3d_rendertarget_info depth_stencil = {{0}}; unsigned int i; key->rb_namespace = 0; @@ -2732,6 +2742,7 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win { if (rts[i]) { + context->blit_targets[i].gl_view = rts[i]->gl_view; context->blit_targets[i].resource = rts[i]->resource; context->blit_targets[i].sub_resource_idx = rts[i]->sub_resource_idx; } @@ -2865,6 +2876,7 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat { if (fb->render_targets[i]) { + context->blit_targets[i].gl_view = fb->render_targets[i]->gl_view; context->blit_targets[i].resource = fb->render_targets[i]->resource; context->blit_targets[i].sub_resource_idx = fb->render_targets[i]->sub_resource_idx; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index a2f6e1ce8cb..5050ab48ffb 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1632,8 +1632,15 @@ struct wined3d_timestamp_query void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN; void context_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN; +struct wined3d_gl_view +{ + GLenum target; + GLuint name; +}; + struct wined3d_rendertarget_info { + struct wined3d_gl_view gl_view; struct wined3d_resource *resource; unsigned int sub_resource_idx; }; @@ -3375,12 +3382,6 @@ HRESULT wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_ void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN; -struct wined3d_gl_view -{ - GLenum target; - GLuint name; -}; - struct wined3d_rendertarget_view { LONG refcount;