From d9fa6bb6c239aeba48a781ef0526156584032042 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B3zef=20Kucia?= Date: Thu, 15 Feb 2018 13:49:35 +0100 Subject: [PATCH] wined3d: Create dummy textures for multisample texture targets. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/context.c | 17 ++++++++++++++++- dlls/wined3d/device.c | 31 +++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 8c2ea866113..7eeb8c41938 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1756,7 +1756,15 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_textures.tex_buffer); - checkGLcall("Bind dummy textures"); + if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, + device->dummy_textures.tex_2d_ms); + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, + device->dummy_textures.tex_2d_ms_array); + } + + checkGLcall("bind dummy textures"); } } @@ -2759,6 +2767,13 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_textures.tex_buffer); checkGLcall("glBindTexture"); break; + case GL_TEXTURE_2D_MULTISAMPLE: + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, device->dummy_textures.tex_2d_ms); + break; + case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, + device->dummy_textures.tex_2d_ms_array); + break; default: ERR("Unexpected texture target %#x.\n", old_texture_type); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 89083fca30a..83ba2b6d5a3 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -727,6 +727,31 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_ checkGLcall("glDeleteBuffers"); } + if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d_ms); + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, device->dummy_textures.tex_2d_ms); + GL_EXTCALL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, GL_TRUE)); + + gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d_ms_array); + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, device->dummy_textures.tex_2d_ms_array); + GL_EXTCALL(glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, GL_RGBA8, 1, 1, 1, GL_TRUE)); + + if (gl_info->supported[ARB_CLEAR_TEXTURE]) + { + GL_EXTCALL(glClearTexImage(device->dummy_textures.tex_2d_ms, + 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color)); + GL_EXTCALL(glClearTexImage(device->dummy_textures.tex_2d_ms_array, + 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color)); + } + else + { + WARN("ARB_clear_texture is currently required to clear dummy multisample textures.\n"); + } + + checkGLcall("create dummy multisample textures"); + } + context_bind_dummy_textures(device, context); } @@ -735,6 +760,12 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d { const struct wined3d_gl_info *gl_info = context->gl_info; + if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d_ms); + gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d_ms_array); + } + if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_buffer); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 02f471b9c44..7cf5fc3fbfa 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2942,6 +2942,8 @@ struct wined3d_device GLuint tex_cube_array; GLuint tex_2d_array; GLuint tex_buffer; + GLuint tex_2d_ms; + GLuint tex_2d_ms_array; } dummy_textures; /* Default sampler used to emulate the direct resource access without using wined3d_sampler */ -- 2.11.4.GIT