Mesa (master): d3d12: Misc fixes caught by GCC warnings / code inspection

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


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

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

d3d12: Misc fixes caught by GCC warnings / code inspection

* A const-correctness issue
* Some uninitialized variables
* A missing copyright header
* A comment with a /* in it when only * was needed

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_context.cpp  |  2 +-
 src/gallium/drivers/d3d12/d3d12_fence.cpp    | 22 ++++++++++++++++++++++
 src/gallium/drivers/d3d12/d3d12_nir_passes.c |  4 ++--
 src/gallium/drivers/d3d12/d3d12_resource.cpp |  2 ++
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index 39cdcab2cde..cb74b05a176 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -1437,7 +1437,7 @@ d3d12_disable_fake_so_buffers(struct d3d12_context *ctx)
    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;
+      uint64_t filled_size = 0;
       struct pipe_transfer *src_transfer, *dst_transfer;
       uint8_t *src, *dst;
 
diff --git a/src/gallium/drivers/d3d12/d3d12_fence.cpp b/src/gallium/drivers/d3d12/d3d12_fence.cpp
index 7b6f6a64a54..e249a88846e 100644
--- a/src/gallium/drivers/d3d12/d3d12_fence.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_fence.cpp
@@ -1,3 +1,25 @@
+/*
+ * Copyright © Microsoft Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
 
 #include "d3d12_fence.h"
 
diff --git a/src/gallium/drivers/d3d12/d3d12_nir_passes.c b/src/gallium/drivers/d3d12/d3d12_nir_passes.c
index 360f4d1da89..a6ee662cbcf 100644
--- a/src/gallium/drivers/d3d12/d3d12_nir_passes.c
+++ b/src/gallium/drivers/d3d12/d3d12_nir_passes.c
@@ -572,7 +572,7 @@ d3d12_create_bare_samplers(nir_shader *nir)
       const struct glsl_type *type = glsl_without_array(var->type);
       if (glsl_type_is_sampler(type) && glsl_get_sampler_result_type(type) != GLSL_TYPE_VOID) {
          /* Since samplers are already lowered to be accessed by index, all we need to do
-         /* here is create a bare sampler with the same binding */
+          * here is create a bare sampler with the same binding */
          nir_variable *clone = nir_variable_clone(var, nir);
          clone->type = get_bare_samplers_for_type(var->type);
          nir_shader_add_variable(nir, clone);
@@ -792,7 +792,7 @@ lower_load_ubo_packed_filter(const nir_instr *instr,
 
 static nir_ssa_def *
 lower_load_ubo_packed_impl(nir_builder *b, nir_instr *instr,
-                              UNUSED const void *_options) {
+                              UNUSED void *_options) {
    nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
 
    nir_ssa_def *buffer = intr->src[0].ssa;
diff --git a/src/gallium/drivers/d3d12/d3d12_resource.cpp b/src/gallium/drivers/d3d12/d3d12_resource.cpp
index 1917076976b..a41ec322a56 100644
--- a/src/gallium/drivers/d3d12/d3d12_resource.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_resource.cpp
@@ -897,6 +897,8 @@ d3d12_transfer_map(struct pipe_context *pctx,
          ptr = read_zs_surface(ctx, res, box, trans);
       } else if (usage & PIPE_MAP_WRITE){
          ptr = prepare_write_zs_surface(res, box, trans);
+      } else {
+         ptr = nullptr;
       }
    } else {
       ptrans->stride = align(util_format_get_stride(pres->format, box->width),



More information about the mesa-commit mailing list