[Mesa-dev] [PATCH 14/19] i965/fs: Add and use an fs_inst copy constructor.

Matt Turner mattst88 at gmail.com
Thu Feb 20 13:41:27 PST 2014


Will get more complicated when fs_reg src becomes a pointer.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp         | 5 +++++
 src/mesa/drivers/dri/i965/brw_fs.h           | 1 +
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 +--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 7dc83ad..77b9f57 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -131,6 +131,11 @@ fs_inst::fs_inst(enum opcode opcode, fs_reg dst,
       assert(src[2].reg_offset >= 0);
 }
 
+fs_inst::fs_inst(const fs_inst &that)
+{
+   memcpy(this, &that, sizeof(that));
+}
+
 #define ALU1(op)                                                        \
    fs_inst *                                                            \
    fs_visitor::op(fs_reg dst, fs_reg src0)                              \
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index fe063e6..054008e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -180,6 +180,7 @@ public:
    fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1);
    fs_inst(enum opcode opcode, fs_reg dst,
            fs_reg src0, fs_reg src1,fs_reg src2);
+   fs_inst(const fs_inst &that);
 
    bool equals(fs_inst *inst);
    bool overwrites_reg(const fs_reg &reg);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index b28d7aa..76f93c9 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2441,8 +2441,7 @@ fs_visitor::emit_untyped_surface_read(unsigned surf_index, fs_reg dst,
 fs_inst *
 fs_visitor::emit(const fs_inst &inst)
 {
-   fs_inst *list_inst = new(mem_ctx) fs_inst;
-   *list_inst = inst;
+   fs_inst *list_inst = new(mem_ctx) fs_inst(inst);
    emit(list_inst);
    return list_inst;
 }
-- 
1.8.3.2



More information about the mesa-dev mailing list