Mesa (master): d3d12: Fix signed-unsigned comparison warnings

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 1 17:19:59 UTC 2020


Module: Mesa
Branch: master
Commit: 4358af87e77befde471341fb8f8549828fec6a30
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4358af87e77befde471341fb8f8549828fec6a30

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Wed Nov 25 17:02:25 2020 -0800

d3d12: Fix signed-unsigned comparison warnings

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7780>

---

 src/gallium/drivers/d3d12/d3d12_blit.cpp           | 38 +++++++++++-----------
 src/gallium/drivers/d3d12/d3d12_context.cpp        | 16 +++++----
 src/gallium/drivers/d3d12/d3d12_draw.cpp           | 12 +++----
 src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp |  2 +-
 src/gallium/drivers/d3d12/d3d12_query.cpp          |  2 +-
 src/gallium/drivers/d3d12/d3d12_resource.cpp       |  2 +-
 src/microsoft/compiler/dxil_nir.c                  |  4 +--
 7 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_blit.cpp b/src/gallium/drivers/d3d12/d3d12_blit.cpp
index c7be8505091..fbb277b1160 100644
--- a/src/gallium/drivers/d3d12/d3d12_blit.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_blit.cpp
@@ -94,14 +94,14 @@ resolve_supported(const struct pipe_blit_info *info)
       return false;
 
    // can only resolve full subresource
-   if (info->src.box.width != u_minify(info->src.resource->width0,
-                                       info->src.level) ||
-       info->src.box.height != u_minify(info->src.resource->height0,
-                                        info->src.level) ||
-       info->dst.box.width != u_minify(info->dst.resource->width0,
-                                           info->dst.level) ||
-       info->dst.box.height != u_minify(info->dst.resource->height0,
-                                            info->dst.level))
+   if (info->src.box.width != (int)u_minify(info->src.resource->width0,
+                                            info->src.level) ||
+       info->src.box.height != (int)u_minify(info->src.resource->height0,
+                                             info->src.level) ||
+       info->dst.box.width != (int)u_minify(info->dst.resource->width0,
+                                            info->dst.level) ||
+       info->dst.box.height != (int)u_minify(info->dst.resource->height0,
+                                             info->dst.level))
       return false;
 
    return true;
@@ -233,12 +233,12 @@ direct_copy_supported(struct d3d12_screen *screen,
       if (info->src.box.x != 0 ||
           info->src.box.y != 0 ||
           info->src.box.z != 0 ||
-          info->src.box.width != u_minify(info->src.resource->width0,
-                                          info->src.level) ||
-          info->src.box.height != u_minify(info->src.resource->height0,
-                                           info->src.level) ||
-          info->src.box.depth != u_minify(info->src.resource->depth0,
-                                          info->src.level))
+          info->src.box.width != (int)u_minify(info->src.resource->width0,
+                                               info->src.level) ||
+          info->src.box.height != (int)u_minify(info->src.resource->height0,
+                                                info->src.level) ||
+          info->src.box.depth != (int)u_minify(info->src.resource->depth0,
+                                               info->src.level))
          return false;
    }
 
@@ -323,9 +323,9 @@ copy_subregion_no_barriers(struct d3d12_context *ctx,
       dst_loc.pResource = d3d12_resource_resource(dst);
 
       if (psrc_box->x == 0 && psrc_box->y == 0 && psrc_box->z == 0 &&
-          psrc_box->width == u_minify(src->base.width0, src_level) &&
-          psrc_box->height == u_minify(src->base.height0, src_level) &&
-          psrc_box->depth == u_minify(src->base.depth0, src_level)) {
+          psrc_box->width == (int)u_minify(src->base.width0, src_level) &&
+          psrc_box->height == (int)u_minify(src->base.height0, src_level) &&
+          psrc_box->depth == (int)u_minify(src->base.depth0, src_level)) {
 
          assert((dstx == 0 && dsty == 0 && dstz == 0) ||
                 screen->opts2.ProgrammableSamplePositionsTier !=
@@ -341,9 +341,9 @@ copy_subregion_no_barriers(struct d3d12_context *ctx,
       } else {
          D3D12_BOX src_box;
          src_box.left = psrc_box->x;
-         src_box.right = MIN2(psrc_box->x + psrc_box->width, u_minify(src->base.width0, src_level));
+         src_box.right = MIN2(psrc_box->x + psrc_box->width, (int)u_minify(src->base.width0, src_level));
          src_box.top = psrc_box->y;
-         src_box.bottom = MIN2(psrc_box->y + psrc_box->height, u_minify(src->base.height0, src_level));
+         src_box.bottom = MIN2(psrc_box->y + psrc_box->height, (int)u_minify(src->base.height0, src_level));
          src_box.front = src_z;
          src_box.back = src_z + psrc_box->depth;
 
diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index 341c8c0a951..ecfaa41139c 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -62,7 +62,7 @@ d3d12_context_destroy(struct pipe_context *pctx)
 
    util_blitter_destroy(ctx->blitter);
    d3d12_end_batch(ctx, d3d12_current_batch(ctx));
-   for (int i = 0; i < ARRAY_SIZE(ctx->batches); ++i)
+   for (unsigned i = 0; i < ARRAY_SIZE(ctx->batches); ++i)
       d3d12_destroy_batch(ctx, &ctx->batches[i]);
    ctx->cmdlist->Release();
    ctx->cmdqueue_fence->Release();
@@ -1432,7 +1432,7 @@ d3d12_disable_fake_so_buffers(struct d3d12_context *ctx)
 
    d3d12_flush_cmdlist_and_wait(ctx);
 
-   for (int i = 0; i < ctx->gfx_pipeline_state.num_so_targets; ++i) {
+   for (unsigned i = 0; i < ctx->gfx_pipeline_state.num_so_targets; ++i) {
       struct d3d12_stream_output_target *target = (struct d3d12_stream_output_target *)ctx->so_targets[i];
       struct d3d12_stream_output_target *fake_target = (struct d3d12_stream_output_target *)ctx->fake_so_targets[i];
       uint64_t filled_size;
@@ -1471,7 +1471,7 @@ d3d12_disable_fake_so_buffers(struct d3d12_context *ctx)
       ctx->fake_so_buffer_views[i].SizeInBytes = 0;
 
       /* Make sure the buffer is not copied twice */
-      for (int j = i + 1; j <= ctx->gfx_pipeline_state.num_so_targets; ++j) {
+      for (unsigned j = i + 1; j <= ctx->gfx_pipeline_state.num_so_targets; ++j) {
          if (ctx->so_targets[j] && ctx->so_targets[j]->buffer == target->base.buffer)
             pipe_so_target_reference(&ctx->fake_so_targets[j], NULL);
       }
@@ -1577,7 +1577,9 @@ d3d12_clear_render_target(struct pipe_context *pctx,
          clear_color[c] = color->f[c];
    }
 
-   D3D12_RECT rect = { dstx, dsty, dstx + width, dsty + height };
+   D3D12_RECT rect = { (int)dstx, (int)dsty,
+                       (int)dstx + (int)width,
+                       (int)dsty + (int)height };
    ctx->cmdlist->ClearRenderTargetView(surf->desc_handle.cpu_handle,
                                        color->f, 1, &rect);
 
@@ -1616,7 +1618,9 @@ d3d12_clear_depth_stencil(struct pipe_context *pctx,
                                    D3D12_RESOURCE_STATE_DEPTH_WRITE);
    d3d12_apply_resource_states(ctx);
 
-   D3D12_RECT rect = { dstx, dsty, dstx + width, dsty + height };
+   D3D12_RECT rect = { (int)dstx, (int)dsty,
+                       (int)dstx + (int)width,
+                       (int)dsty + (int)height };
    ctx->cmdlist->ClearDepthStencilView(surf->desc_handle.cpu_handle, flags,
                                        depth, stencil, 1, &rect);
 
@@ -1943,7 +1947,7 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
       return NULL;
    }
 
-   for (int i = 0; i < ARRAY_SIZE(ctx->batches); ++i) {
+   for (unsigned i = 0; i < ARRAY_SIZE(ctx->batches); ++i) {
       if (!d3d12_init_batch(ctx, &ctx->batches[i])) {
          FREE(ctx);
          return NULL;
diff --git a/src/gallium/drivers/d3d12/d3d12_draw.cpp b/src/gallium/drivers/d3d12/d3d12_draw.cpp
index 139c9352580..dbbbd25605b 100644
--- a/src/gallium/drivers/d3d12/d3d12_draw.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_draw.cpp
@@ -89,11 +89,11 @@ fill_srv_descriptors(struct d3d12_context *ctx,
 
    d2d12_descriptor_heap_get_next_handle(batch->view_heap, &table_start);
 
-   for (int i = 0; i < shader->num_srv_bindings; i++)
+   for (unsigned i = 0; i < shader->num_srv_bindings; i++)
    {
       struct d3d12_sampler_view *view;
 
-      if (shader->srv_bindings[i].binding == shader->pstipple_binding) {
+      if ((unsigned)shader->srv_bindings[i].binding == shader->pstipple_binding) {
          view = (struct d3d12_sampler_view*)ctx->pstipple.sampler_view;
       } else {
          int index = shader->srv_bindings[i].index;
@@ -140,11 +140,11 @@ fill_sampler_descriptors(struct d3d12_context *ctx,
 
    d2d12_descriptor_heap_get_next_handle(batch->sampler_heap, &table_start);
 
-   for (int i = 0; i < shader->num_srv_bindings; i++)
+   for (unsigned i = 0; i < shader->num_srv_bindings; i++)
    {
       struct d3d12_sampler_state *sampler;
 
-      if (shader->srv_bindings[i].binding == shader->pstipple_binding) {
+      if ((unsigned)shader->srv_bindings[i].binding == shader->pstipple_binding) {
          sampler = ctx->pstipple.sampler_cso;
       } else {
          int index = shader->srv_bindings[i].index;
@@ -577,7 +577,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
    if (ctx->cmdlist_dirty & D3D12_DIRTY_VIEWPORT) {
       if (ctx->need_zero_one_depth_range) {
          D3D12_VIEWPORT viewports[PIPE_MAX_VIEWPORTS];
-         for (int i = 0; i < ctx->num_viewports; ++i) {
+         for (unsigned i = 0; i < ctx->num_viewports; ++i) {
             viewports[i] = ctx->viewports[i];
             viewports[i].MinDepth = 0.0f;
             viewports[i].MaxDepth = 1.0f;
@@ -664,7 +664,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
                                                                               : ctx->so_targets;
    D3D12_STREAM_OUTPUT_BUFFER_VIEW *so_buffer_views = ctx->fake_so_buffer_factor ? ctx->fake_so_buffer_views
                                                                                  : ctx->so_buffer_views;
-   for (int i = 0; i < ctx->gfx_pipeline_state.num_so_targets; ++i) {
+   for (unsigned i = 0; i < ctx->gfx_pipeline_state.num_so_targets; ++i) {
       struct d3d12_stream_output_target *target = (struct d3d12_stream_output_target *)so_targets[i];
 
       if (!target)
diff --git a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp
index f8b27334b3e..0308a2e75d7 100644
--- a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp
@@ -261,7 +261,7 @@ create_gfx_pipeline_state(struct d3d12_context *ctx)
    pso_desc.PrimitiveTopologyType = topology_type(reduced_prim);
 
    pso_desc.NumRenderTargets = state->num_cbufs;
-   for (int i = 0; i < state->num_cbufs; ++i)
+   for (unsigned i = 0; i < state->num_cbufs; ++i)
       pso_desc.RTVFormats[i] = d3d12_rtv_format(ctx, i);
    pso_desc.DSVFormat = state->dsv_format;
 
diff --git a/src/gallium/drivers/d3d12/d3d12_query.cpp b/src/gallium/drivers/d3d12/d3d12_query.cpp
index ecdc9703f3b..a02a8a01ab8 100644
--- a/src/gallium/drivers/d3d12/d3d12_query.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_query.cpp
@@ -186,7 +186,7 @@ accumulate_result(struct d3d12_context *ctx, struct d3d12_query *q,
    D3D12_QUERY_DATA_SO_STATISTICS *results_so = (D3D12_QUERY_DATA_SO_STATISTICS *)results;
 
    util_query_clear_result(result, q->type);
-   for (int i = 0; i < q->curr_query; ++i) {
+   for (unsigned i = 0; i < q->curr_query; ++i) {
       switch (q->type) {
       case PIPE_QUERY_OCCLUSION_PREDICATE:
       case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
diff --git a/src/gallium/drivers/d3d12/d3d12_resource.cpp b/src/gallium/drivers/d3d12/d3d12_resource.cpp
index c9b0ec5770f..2dd9787a470 100644
--- a/src/gallium/drivers/d3d12/d3d12_resource.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_resource.cpp
@@ -73,7 +73,7 @@ resource_is_busy(struct d3d12_context *ctx,
 {
    bool busy = false;
 
-   for (int i = 0; i < ARRAY_SIZE(ctx->batches); i++)
+   for (unsigned i = 0; i < ARRAY_SIZE(ctx->batches); i++)
       busy |= d3d12_batch_has_references(&ctx->batches[i], res->bo);
 
    return busy;
diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c
index 4a354608e6e..8c59fe8edc7 100644
--- a/src/microsoft/compiler/dxil_nir.c
+++ b/src/microsoft/compiler/dxil_nir.c
@@ -283,7 +283,7 @@ lower_load_ssbo(nir_builder *b, nir_intrinsic_instr *intr)
    b->cursor = nir_before_instr(&intr->instr);
 
    nir_ssa_def *buffer = intr->src[0].ssa;
-   nir_ssa_def *offset = nir_iand(b, intr->src[1].ssa, nir_imm_int(b, ~3UL));
+   nir_ssa_def *offset = nir_iand(b, intr->src[1].ssa, nir_imm_int(b, ~3));
    unsigned bit_size = nir_dest_bit_size(intr->dest);
    unsigned num_components = nir_dest_num_components(intr->dest);
    unsigned num_bits = num_components * bit_size;
@@ -349,7 +349,7 @@ lower_store_ssbo(nir_builder *b, nir_intrinsic_instr *intr)
 
    nir_ssa_def *val = intr->src[0].ssa;
    nir_ssa_def *buffer = intr->src[1].ssa;
-   nir_ssa_def *offset = nir_iand(b, intr->src[2].ssa, nir_imm_int(b, ~3UL));
+   nir_ssa_def *offset = nir_iand(b, intr->src[2].ssa, nir_imm_int(b, ~3));
 
    unsigned bit_size = val->bit_size;
    unsigned num_components = val->num_components;



More information about the mesa-commit mailing list