[PATCH 2/7] wined3d: Create dummy buffer textures.

Józef Kucia jkucia at codeweavers.com
Thu Mar 24 07:54:38 CDT 2016


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/wined3d/context.c         | 12 +++++++++++-
 dlls/wined3d/device.c          | 30 ++++++++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |  9 +++++----
 3 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 31fd22a..8ae3e32 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1490,6 +1490,12 @@ static void bind_dummy_textures(const struct wined3d_device *device, const struc
             gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, device->dummy_texture_cube[i]);
             checkGLcall("glBindTexture");
         }
+
+        if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
+        {
+            gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_texture_buffer[i]);
+            checkGLcall("glBindTexture");
+        }
     }
 }
 
@@ -2362,8 +2368,12 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint
                 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, device->dummy_texture_3d[unit]);
                 checkGLcall("glBindTexture");
                 break;
+            case GL_TEXTURE_BUFFER:
+                gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_texture_buffer[unit]);
+                checkGLcall("glBindTexture");
+                break;
             default:
-                ERR("Unexpected texture target %#x\n", old_texture_type);
+                ERR("Unexpected texture target %#x.\n", old_texture_type);
         }
 
         context->texture_type[unit] = target;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5a523d3..dd33238 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -677,6 +677,7 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
     count = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers);
     for (i = 0; i < count; ++i)
     {
+        static const DWORD d3d10_color = 0x00000000;
         static const DWORD color = 0x000000ff;
 
         /* Make appropriate texture active */
@@ -736,6 +737,29 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
                 checkGLcall("glTexImage2D");
             }
         }
+
+        if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
+        {
+            GLuint buffer;
+
+            GL_EXTCALL(glGenBuffers(1, &buffer));
+            GL_EXTCALL(glBindBuffer(GL_TEXTURE_BUFFER, buffer));
+            GL_EXTCALL(glBufferData(GL_TEXTURE_BUFFER, sizeof(d3d10_color), &d3d10_color, GL_STATIC_DRAW));
+            GL_EXTCALL(glBindBuffer(GL_TEXTURE_BUFFER, 0));
+            checkGLcall("create buffer object");
+
+            gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_texture_buffer[i]);
+            checkGLcall("glGenTextures");
+            TRACE("Dummy buffer texture %u given name %u.\n", i, device->dummy_texture_buffer[i]);
+
+            gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_texture_buffer[i]);
+            checkGLcall("glBindTexture");
+            GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, buffer));
+            checkGLcall("glTexBuffer");
+
+            GL_EXTCALL(glDeleteBuffers(1, &buffer));
+            checkGLcall("glDeleteBuffers");
+        }
     }
 }
 
@@ -744,6 +768,12 @@ static void destroy_dummy_textures(struct wined3d_device *device, const struct w
 {
     unsigned int count = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers);
 
+    if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
+    {
+        gl_info->gl_ops.gl.p_glDeleteTextures(count, device->dummy_texture_buffer);
+        checkGLcall("glDeleteTextures(count, device->dummy_texture_buffer)");
+    }
+
     if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
     {
         gl_info->gl_ops.gl.p_glDeleteTextures(count, device->dummy_texture_cube);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9e83e6ad..dc4330f 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2220,10 +2220,11 @@ struct wined3d_device
     struct wined3d_texture *logo_texture;
 
     /* Textures for when no other textures are mapped */
-    UINT dummy_texture_2d[MAX_COMBINED_SAMPLERS];
-    UINT dummy_texture_rect[MAX_COMBINED_SAMPLERS];
-    UINT dummy_texture_3d[MAX_COMBINED_SAMPLERS];
-    UINT dummy_texture_cube[MAX_COMBINED_SAMPLERS];
+    GLuint dummy_texture_2d[MAX_COMBINED_SAMPLERS];
+    GLuint dummy_texture_rect[MAX_COMBINED_SAMPLERS];
+    GLuint dummy_texture_3d[MAX_COMBINED_SAMPLERS];
+    GLuint dummy_texture_cube[MAX_COMBINED_SAMPLERS];
+    GLuint dummy_texture_buffer[MAX_COMBINED_SAMPLERS];
 
     /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
     GLuint default_sampler;
-- 
2.4.10




More information about the wine-patches mailing list