[PATCH 5/5] wined3d: Introduce a debug function for struct wined3d_box.

Henri Verbeet hverbeet at codeweavers.com
Wed Feb 3 15:23:00 CST 2016


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/device.c          | 15 ++++++---------
 dlls/wined3d/resource.c        |  4 ++--
 dlls/wined3d/surface.c         |  8 ++++----
 dlls/wined3d/texture.c         |  2 +-
 dlls/wined3d/utils.c           |  9 +++++++++
 dlls/wined3d/volume.c          | 12 ++++--------
 dlls/wined3d/wined3d_private.h |  1 +
 7 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 16015a4..8f39c3b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3965,9 +3965,9 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
     HRESULT hr;
 
     TRACE("device %p, dst_resource %p, dst_sub_resource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
-            "src_resource %p, src_sub_resource_idx %u, src_box %p.\n",
+            "src_resource %p, src_sub_resource_idx %u, src_box %s.\n",
             device, dst_resource, dst_sub_resource_idx, dst_x, dst_y, dst_z,
-            src_resource, src_sub_resource_idx, src_box);
+            src_resource, src_sub_resource_idx, debug_box(src_box));
 
     if (src_resource == dst_resource && src_sub_resource_idx == dst_sub_resource_idx)
     {
@@ -4017,9 +4017,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
     {
         if (src_box->front >= src_box->back)
         {
-            WARN("Invalid box (%u, %u, %u)->(%u, %u, %u) specified.\n",
-                    src_box->left, src_box->top, src_box->front,
-                    src_box->right, src_box->bottom, src_box->back);
+            WARN("Invalid box %s specified.\n", debug_box(src_box));
             return WINED3DERR_INVALIDCALL;
         }
 
@@ -4060,8 +4058,8 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
     POINT dst_point;
     RECT src_rect;
 
-    TRACE("device %p, resource %p, sub_resource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u.\n",
-            device, resource, sub_resource_idx, box, data, row_pitch, depth_pitch);
+    TRACE("device %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, depth_pitch %u.\n",
+            device, resource, sub_resource_idx, debug_box(box), data, row_pitch, depth_pitch);
 
     if (resource->type == WINED3D_RTYPE_BUFFER)
     {
@@ -4102,8 +4100,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
                 || box->top >= box->bottom || box->bottom > sub_resource->height
                 || box->front >= box->back)
         {
-            WARN("Invalid box (%u, %u, %u)->(%u, %u, %u) specified.\n",
-                    box->left, box->top, box->front, box->right, box->bottom, box->back);
+            WARN("Invalid box %s specified.\n", debug_box(box));
             return;
         }
 
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 73250ec..a4936cf 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -308,8 +308,8 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
 HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
         struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
 {
-    TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %p, flags %#x.\n",
-            resource, sub_resource_idx, map_desc, box, flags);
+    TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
+            resource, sub_resource_idx, map_desc, debug_box(box), flags);
 
     return resource->resource_ops->resource_sub_resource_map(resource, sub_resource_idx, map_desc, box, flags);
 }
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 65827ac..e6c6258 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2460,8 +2460,8 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
     const struct wined3d_gl_info *gl_info;
     BYTE *base_memory;
 
-    TRACE("surface %p, map_desc %p, box %p, flags %#x.\n",
-            surface, map_desc, box, flags);
+    TRACE("surface %p, map_desc %p, box %s, flags %#x.\n",
+            surface, map_desc, debug_box(box), flags);
 
     if (surface->resource.map_count)
     {
@@ -2472,8 +2472,8 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
     if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && box
             && !surface_check_block_align(surface, box))
     {
-        WARN("Map rect %p is misaligned for %ux%u blocks.\n",
-                box, format->block_width, format->block_height);
+        WARN("Map box %s is misaligned for %ux%u blocks.\n",
+                debug_box(box), format->block_width, format->block_height);
 
         if (surface->resource.pool == WINED3D_POOL_DEFAULT)
             return WINED3DERR_INVALIDCALL;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 6f4d88f..88507fa 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -712,7 +712,7 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
 {
     struct wined3d_resource *sub_resource;
 
-    TRACE("texture %p, layer %u, dirty_region %p.\n", texture, layer, dirty_region);
+    TRACE("texture %p, layer %u, dirty_region %s.\n", texture, layer, debug_box(dirty_region));
 
     if (!(sub_resource = wined3d_texture_get_sub_resource(texture, layer * texture->level_count)))
     {
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index be6b32a..923d70a 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2958,6 +2958,15 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
 /*****************************************************************************
  * Trace formatting of useful values
  */
+const char *debug_box(const struct wined3d_box *box)
+{
+    if (!box)
+        return "(null)";
+    return wine_dbg_sprintf("(%u, %u, %u)-(%u, %u, %u)",
+            box->left, box->top, box->front,
+            box->right, box->bottom, box->back);
+}
+
 const char *debug_d3dformat(enum wined3d_format_id format_id)
 {
     switch (format_id)
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index be6fab4..3ac7f98 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -517,8 +517,8 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
     const struct wined3d_format *format = volume->resource.format;
     const unsigned int fmt_flags = volume->container->resource.format_flags;
 
-    TRACE("volume %p, map_desc %p, box %p, flags %#x.\n",
-            volume, map_desc, box, flags);
+    TRACE("volume %p, map_desc %p, box %s, flags %#x.\n",
+            volume, map_desc, debug_box(box), flags);
 
     map_desc->data = NULL;
     if (!(volume->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU))
@@ -538,8 +538,8 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
     }
     if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !volume_check_block_align(volume, box))
     {
-        WARN("Map box is misaligned for %ux%u blocks.\n",
-                format->block_width, format->block_height);
+        WARN("Map box %s is misaligned for %ux%u blocks.\n",
+                debug_box(box), format->block_width, format->block_height);
         return WINED3DERR_INVALIDCALL;
     }
 
@@ -612,14 +612,10 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
 
     if (!box)
     {
-        TRACE("No box supplied - all is ok\n");
         map_desc->data = base_memory;
     }
     else
     {
-        TRACE("Lock Box (%p) = l %u, t %u, r %u, b %u, fr %u, ba %u\n",
-                box, box->left, box->top, box->right, box->bottom, box->front, box->back);
-
         if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
         {
             /* Compressed textures are block based, so calculate the offset of
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 57689e2..6f4dc36 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2936,6 +2936,7 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPE
  */
 
 /* Trace routines */
+const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
 const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
 const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
-- 
2.1.4




More information about the wine-patches mailing list