[PATCH 4/5] wined3d: Reject unsupported pitches in wined3d_surface_update_desc().

Matteo Bruni mbruni at codeweavers.com
Wed Feb 18 07:20:48 CST 2015


I went for a quite large comment here, the reasoning behind the check
seems non-obvious enough.
---
 dlls/wined3d/surface.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a42e907..396bcc9 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2166,6 +2166,19 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
     DWORD valid_location = 0;
     HRESULT hr;
 
+    /* We have no way of supporting a pitch that is not a multiple of the pixel
+     * byte width short of uploading the texture row-by-row.
+     * Fortunately that's not an issue since D3D9Ex doesn't allow a custom pitch
+     * for user-memory textures (it always expects packed data) while DirectDraw
+     * requires a 4-byte aligned pitch and doesn't support texture formats
+     * larger than 4 bytes per pixel nor any format using 3 bytes per pixel.
+     * This check is here to verify that the assumption holds. */
+    if (pitch & (texture_resource->format->byte_count - 1))
+    {
+        WARN("Pitch unsupported, not a multiple of the texture format byte width.\n");
+        return WINED3DERR_INVALIDCALL;
+    }
+
     if (surface->flags & SFLAG_DIBSECTION)
     {
         DeleteDC(surface->hDC);
-- 
2.0.5




More information about the wine-patches mailing list