3 * Copyright (c) 2019 Collabora LTD
5 * Author: Gert Wollny <gert.wollny@collabora.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * on the rights to use, copy, modify, merge, publish, distribute, sub
11 * license, and/or sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "sfn_emitinstruction.h"
29 #include "sfn_shader_base.h"
33 EmitInstruction::EmitInstruction(ShaderFromNirProcessor
& processor
):
39 EmitInstruction::~EmitInstruction()
43 bool EmitInstruction::emit(nir_instr
* instr
)
45 return do_emit(instr
);
48 PValue
EmitInstruction::from_nir(const nir_src
& v
, unsigned component
, unsigned swizzled
)
50 return m_proc
.from_nir(v
, component
, swizzled
);
53 PValue
EmitInstruction::from_nir(const nir_alu_src
& v
, unsigned component
)
55 return m_proc
.from_nir(v
, component
);
58 PValue
EmitInstruction::from_nir(const nir_tex_src
& v
, unsigned component
)
60 return m_proc
.from_nir(v
, component
);
63 PValue
EmitInstruction::from_nir(const nir_alu_dest
& v
, unsigned component
)
65 return m_proc
.from_nir(v
, component
);
68 PValue
EmitInstruction::from_nir(const nir_dest
& v
, unsigned component
)
70 return m_proc
.from_nir(v
, component
);
73 PValue
EmitInstruction::from_nir(const nir_src
& v
, unsigned component
)
75 return m_proc
.from_nir(v
, component
);
78 void EmitInstruction::emit_instruction(Instruction
*ir
)
80 return m_proc
.emit_instruction(ir
);
83 bool EmitInstruction::emit_instruction(EAluOp opcode
, PValue dest
,
84 std::vector
<PValue
> src0
,
85 const std::set
<AluModifiers
>& m_flags
)
87 return m_proc
.emit_instruction(opcode
, dest
,src0
, m_flags
);
91 EmitInstruction::get_deref_location(const nir_src
& v
) const
93 return m_proc
.get_deref_location(v
);
96 PValue
EmitInstruction::from_nir_with_fetch_constant(const nir_src
& src
, unsigned component
)
98 return m_proc
.from_nir_with_fetch_constant(src
, component
);
101 GPRVector
*EmitInstruction::vec_from_nir_with_fetch_constant(const nir_src
& src
, unsigned mask
,
102 const GPRVector::Swizzle
& swizzle
)
104 return m_proc
.vec_from_nir_with_fetch_constant(src
, mask
, swizzle
);
107 void EmitInstruction::load_uniform(const nir_alu_src
& src
)
109 m_proc
.load_uniform(src
);
112 int EmitInstruction::lookup_register_index(const nir_src
& src
) const
114 return m_proc
.lookup_register_index(src
);
117 int EmitInstruction::allocate_temp_register()
119 return m_proc
.allocate_temp_register();
122 int EmitInstruction::lookup_register_index(const nir_dest
& dst
)
124 return m_proc
.lookup_register_index(dst
);
127 const nir_load_const_instr
*
128 EmitInstruction::get_literal_register(const nir_src
& src
) const
131 return m_proc
.get_literal_constant(src
.ssa
->index
);
136 PValue
EmitInstruction::get_temp_register()
138 return m_proc
.get_temp_register();
141 GPRVector
EmitInstruction::get_temp_vec4()
143 return m_proc
.get_temp_vec4();
146 PValue
EmitInstruction::create_register_from_nir_src(const nir_src
& src
, unsigned swizzle
)
148 return m_proc
.create_register_from_nir_src(src
, swizzle
);
151 const std::set
<AluModifiers
> EmitInstruction::empty
= {};
152 const std::set
<AluModifiers
> EmitInstruction::write
= {alu_write
};
153 const std::set
<AluModifiers
> EmitInstruction::last_write
= {alu_write
, alu_last_instr
};
154 const std::set
<AluModifiers
> EmitInstruction::last
= {alu_last_instr
};