[PATCH v3 4/9] wined3d: Stub creation of WINED3D_RTYPE_TEXTURE_1D textures.

Sven Hesse shesse at codeweavers.com
Wed Feb 7 09:35:04 CST 2018


Signed-off-by: Sven Hesse <shesse at codeweavers.com>
---
 dlls/wined3d/texture.c | 90 +++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 70 insertions(+), 20 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index ed1ca21117..99bcfdf888 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1629,6 +1629,41 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
             context, box, data, row_pitch, slice_pitch);
 }
 
+/* This call just uploads data, the caller is responsible for binding the
+ * correct texture. */
+/* Context activation is done by the caller. */
+static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+        const struct wined3d_context *context, const struct wined3d_box *box,
+        const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
+{
+    FIXME("Not implemented.\n");
+}
+
+/* Context activation is done by the caller. */
+static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+        struct wined3d_context *context, DWORD location)
+{
+    FIXME("Not implemented.\n");
+    return FALSE;
+}
+
+static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
+{
+    FIXME("Not implemented.\n");
+}
+
+static void texture1d_cleanup_sub_resources(struct wined3d_texture *texture)
+{
+}
+
+static const struct wined3d_texture_ops texture1d_ops =
+{
+    texture1d_upload_data,
+    texture1d_load_location,
+    texture1d_prepare_texture,
+    texture1d_cleanup_sub_resources,
+};
+
 static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
         const struct wined3d_context *context, const struct wined3d_box *box,
         const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
@@ -2050,6 +2085,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
 {
     struct wined3d_device_parent *device_parent = device->device_parent;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+    const struct wined3d_texture_ops *texture_ops;
     struct wined3d_surface *surfaces;
     UINT pow2_width, pow2_height;
     unsigned int i, j;
@@ -2160,40 +2196,53 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
         }
     }
 
-    if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, layer_count, level_count, desc,
+    texture_ops = (desc->resource_type == WINED3D_RTYPE_TEXTURE_1D) ? &texture1d_ops : &texture2d_ops;
+    if (FAILED(hr = wined3d_texture_init(texture, texture_ops, layer_count, level_count, desc,
             flags, device, parent, parent_ops, &texture_resource_ops)))
     {
         WARN("Failed to initialize texture, returning %#x.\n", hr);
         return hr;
     }
 
-    /* Precalculated scaling for 'faked' non power of two texture coords. */
-    if (texture->resource.gl_type == WINED3D_GL_RES_TYPE_TEX_RECT)
+    if (desc->resource_type == WINED3D_RTYPE_TEXTURE_1D)
     {
-        texture->pow2_matrix[0] = (float)desc->width;
-        texture->pow2_matrix[5] = (float)desc->height;
-        texture->flags &= ~(WINED3D_TEXTURE_POW2_MAT_IDENT | WINED3D_TEXTURE_NORMALIZED_COORDS);
-        texture->target = GL_TEXTURE_RECTANGLE_ARB;
+        texture->pow2_matrix[0] = 1.0f;
+        texture->pow2_matrix[5] = 1.0f;
+        if (layer_count > 1)
+            texture->target = GL_TEXTURE_1D_ARRAY;
+        else
+            texture->target = GL_TEXTURE_1D;
     }
-    else
+    else if (desc->resource_type == WINED3D_RTYPE_TEXTURE_2D)
     {
-        if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+        /* Precalculated scaling for 'faked' non power of two texture coords. */
+        if (texture->resource.gl_type == WINED3D_GL_RES_TYPE_TEX_RECT)
         {
-            texture->pow2_matrix[0] = (((float)desc->width) / ((float)pow2_width));
-            texture->pow2_matrix[5] = (((float)desc->height) / ((float)pow2_height));
-            texture->flags &= ~WINED3D_TEXTURE_POW2_MAT_IDENT;
+            texture->pow2_matrix[0] = (float)desc->width;
+            texture->pow2_matrix[5] = (float)desc->height;
+            texture->flags &= ~(WINED3D_TEXTURE_POW2_MAT_IDENT | WINED3D_TEXTURE_NORMALIZED_COORDS);
+            texture->target = GL_TEXTURE_RECTANGLE_ARB;
         }
         else
         {
-            texture->pow2_matrix[0] = 1.0f;
-            texture->pow2_matrix[5] = 1.0f;
+            if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+            {
+                texture->pow2_matrix[0] = (((float)desc->width) / ((float)pow2_width));
+                texture->pow2_matrix[5] = (((float)desc->height) / ((float)pow2_height));
+                texture->flags &= ~WINED3D_TEXTURE_POW2_MAT_IDENT;
+            }
+            else
+            {
+                texture->pow2_matrix[0] = 1.0f;
+                texture->pow2_matrix[5] = 1.0f;
+            }
+            if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
+                texture->target = GL_TEXTURE_CUBE_MAP_ARB;
+            else if (layer_count > 1)
+                texture->target = GL_TEXTURE_2D_ARRAY;
+            else
+                texture->target = GL_TEXTURE_2D;
         }
-        if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
-            texture->target = GL_TEXTURE_CUBE_MAP_ARB;
-        else if (layer_count > 1)
-            texture->target = GL_TEXTURE_2D_ARRAY;
-        else
-            texture->target = GL_TEXTURE_2D;
     }
     texture->pow2_matrix[10] = 1.0f;
     texture->pow2_matrix[15] = 1.0f;
@@ -2974,6 +3023,7 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
 
     switch (desc->resource_type)
     {
+        case WINED3D_RTYPE_TEXTURE_1D:
         case WINED3D_RTYPE_TEXTURE_2D:
             hr = texture_init(object, desc, layer_count, level_count, flags, device, parent, parent_ops);
             break;
-- 
2.16.1




More information about the wine-devel mailing list