[Beignet] [PATCH 1/2] Silent compilation warning in sampler functions.

Yang, Rong R rong.r.yang at intel.com
Tue Feb 11 00:44:30 PST 2014


This patchset LGTM, thanks.

-----Original Message-----
From: beignet-bounces at lists.freedesktop.org [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Saturday, February 08, 2014 2:12 PM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH 1/2] Silent compilation warning in sampler functions.

Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
 backend/src/ir/sampler.cpp |   21 +++++++++------------
 backend/src/ir/sampler.hpp |    9 ++-------
 src/cl_sampler.c           |    4 ++--
 3 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/backend/src/ir/sampler.cpp b/backend/src/ir/sampler.cpp index 462fab7..b67c1b7 100644
--- a/backend/src/ir/sampler.cpp
+++ b/backend/src/ir/sampler.cpp
@@ -28,17 +28,16 @@ namespace gbe {
 namespace ir {
 
   uint8_t SamplerSet::appendReg(uint32_t key, Context *ctx) {
-    struct SamplerRegSlot samplerSlot;
-    samplerSlot.slot = samplerMap.size();
+    uint8_t samplerSlot = samplerMap.size();
     samplerMap.insert(std::make_pair(key, samplerSlot));
-    return samplerSlot.slot;
+    return samplerSlot;
   }
 
   uint8_t SamplerSet::append(uint32_t samplerValue, Context *ctx)
   {
     auto it = samplerMap.find(samplerValue);
     if (it != samplerMap.end())
-        return it->second.slot;
+        return it->second;
     // This register is just used as a key.
     return appendReg(samplerValue, ctx);
   }
@@ -58,7 +57,7 @@ namespace ir {
 
     auto it = samplerMap.find(SAMPLER_ID(id));
     if (it != samplerMap.end()) {
-      return it->second.slot;
+      return it->second;
     }
     return appendReg(SAMPLER_ID(id), ctx);
   }
@@ -75,8 +74,7 @@ namespace ir {
     OUT_UPDATE_SZ(samplerMap.size());
     for (auto iter : samplerMap) {
       OUT_UPDATE_SZ(iter.first);
-      OUT_UPDATE_SZ(iter.second.reg);
-      OUT_UPDATE_SZ(iter.second.slot);
+      OUT_UPDATE_SZ(iter.second);
     }
 
     OUT_UPDATE_SZ(magic_end);
@@ -97,12 +95,11 @@ namespace ir {
     IN_UPDATE_SZ(sampler_map_sz);
     for (size_t i = 0; i < sampler_map_sz; i++) {
       uint32_t key;
-      ir::SamplerRegSlot reg_slot;
+      uint32_t slot;
 
       IN_UPDATE_SZ(key);
-      IN_UPDATE_SZ(reg_slot.reg);
-      IN_UPDATE_SZ(reg_slot.slot);
-      samplerMap.insert(std::make_pair(key, reg_slot));
+      IN_UPDATE_SZ(slot);
+      samplerMap.insert(std::make_pair(key, slot));
     }
 
     IN_UPDATE_SZ(magic);
@@ -129,7 +126,7 @@ namespace ir {
 
     for (auto iter : samplerMap) {
       outs << spaces_nl <<  "     [" << iter.first << ", "
-           << iter.second.reg << ", " << iter.second.slot << "]\n";
+           << iter.second << "]\n";
     }
 
     outs << spaces << "------------- End SamplerSet -------------" << "\n"; diff --git a/backend/src/ir/sampler.hpp b/backend/src/ir/sampler.hpp index e6706b9..dd1f3b6 100644
--- a/backend/src/ir/sampler.hpp
+++ b/backend/src/ir/sampler.hpp
@@ -36,11 +36,6 @@ namespace ir {
    */
   class Context;
 
-  struct SamplerRegSlot {
-    Register reg;
-    uint32_t slot;
-  };
-
   class SamplerSet : public Serializable
   {
   public:
@@ -54,7 +49,7 @@ namespace ir {
     size_t getDataSize(void) const { return samplerMap.size(); }
     void getData(uint32_t *samplers) const {
       for(auto &it : samplerMap)
-        samplers[it.second.slot] = it.first;
+        samplers[it.second] = it.first;
     }
 
     void operator = (const SamplerSet& other) { @@ -88,7 +83,7 @@ namespace ir {
 
   private:
     uint8_t appendReg(uint32_t key, Context *ctx);
-    map<uint32_t, SamplerRegSlot> samplerMap;
+    map<uint32_t, uint32_t> samplerMap;
     GBE_CLASS(SamplerSet);
   };
 } /* namespace ir */
diff --git a/src/cl_sampler.c b/src/cl_sampler.c index 3e88128..d718256 100644
--- a/src/cl_sampler.c
+++ b/src/cl_sampler.c
@@ -30,8 +30,8 @@ uint32_t cl_to_clk(cl_bool normalized_coords,
                    cl_addressing_mode address,
                    cl_filter_mode filter)  {
-  int clk_address;
-  int clk_filter;
+  int clk_address = CLK_ADDRESS_NONE;
+  int clk_filter = CLK_FILTER_NEAREST;
   switch (address) {
   case CL_ADDRESS_NONE: clk_address = CLK_ADDRESS_NONE; break;
   case CL_ADDRESS_CLAMP: clk_address = CLK_ADDRESS_CLAMP; break;
--
1.7.9.5

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list