3 * Copyright (c) 2018-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 #ifndef SFN_INSTRUCTION_FETCH_H
28 #define SFN_INSTRUCTION_FETCH_H
30 #include "sfn_instruction_base.h"
34 class FetchInstruction
: public Instruction
{
37 FetchInstruction(EVFetchInstr vc_opcode
,
38 EVFetchType fetch_type
,
39 EVTXDataFormat data_format
,
40 EVFetchNumFormat num_format
,
41 EVFetchEndianSwap endian_swap
,
46 uint32_t mega_fetch_count
,
50 EBufferIndexMode buffer_index_mode
,
57 const std::array
<int, 4>& dest_swizzle
);
59 FetchInstruction(EVFetchInstr op
,
62 PValue src
, int offset
,
63 int buffer_id
, PValue buffer_offset
,
64 EBufferIndexMode cp_rel
,
65 bool use_const_field
= false);
67 FetchInstruction(GPRVector dst
,
71 EVTXDataFormat format
,
72 EVFetchNumFormat num_format
);
74 FetchInstruction(GPRVector dst
,
77 EBufferIndexMode cp_rel
);
79 FetchInstruction(GPRVector dst
, PValue src
, int scratch_size
);
81 void replace_values(const ValueSet
& candiates
, PValue new_value
) override
;
82 EVFetchInstr
vc_opcode() const { return m_vc_opcode
;}
83 EVFetchType
fetch_type() const { return m_fetch_type
;}
85 EVTXDataFormat
data_format() const { return m_data_format
;}
86 EVFetchNumFormat
num_format() const { return m_num_format
;}
87 EVFetchEndianSwap
endian_swap() const { return m_endian_swap
;}
89 const Value
& src() const { return *m_src
;}
90 const GPRVector
& dst() const { return m_dst
;}
91 uint32_t offset() const { return m_offset
;}
93 bool is_mega_fetchconst() { return m_is_mega_fetch
;}
94 uint32_t mega_fetch_count() const { return m_mega_fetch_count
;}
96 uint32_t buffer_id() const { return m_buffer_id
;}
97 uint32_t semantic_id() const { return m_semantic_id
;}
98 EBufferIndexMode
buffer_index_mode() const{ return m_buffer_index_mode
;}
100 bool is_signed() const { return m_flags
.test(vtx_format_comp_signed
);}
101 bool use_const_fields() const { return m_flags
.test(vtx_use_const_field
);}
103 bool srf_mode_no_zero() const { return m_flags
.test(vtx_srf_mode
);}
105 void set_flag(EVFetchFlagShift flag
) {m_flags
.set(flag
);}
107 bool uncached() const {return m_uncached
; }
108 bool indexed() const {return m_indexed
; }
109 int array_base()const {return m_array_base
; }
110 int array_size() const {return m_array_size
; }
111 int elm_size() const {return m_elm_size
; }
113 void set_buffer_offset(PValue buffer_offset
) {
114 m_buffer_offset
= buffer_offset
;
115 add_remappable_src_value(&m_buffer_offset
);
117 PValue
buffer_offset() const { return m_buffer_offset
; }
119 void set_dest_swizzle(const std::array
<int,4>& swz
);
120 void set_format(EVTXDataFormat fmt
);
122 int swz(int idx
) const { return m_dest_swizzle
[idx
];}
124 bool use_tc() const {return m_flags
.test(vtx_use_tc
);}
126 bool use_vpm() const {return m_flags
.test(vtx_vpm
);}
128 void prelude_append(Instruction
*instr
);
130 const std::vector
<PInstruction
>& prelude() const;
132 bool has_prelude() const {return !m_prelude
.empty();}
135 bool is_equal_to(const Instruction
& lhs
) const override
;
136 void do_print(std::ostream
& os
) const override
;
138 EVFetchInstr m_vc_opcode
;
139 EVFetchType m_fetch_type
;
141 EVTXDataFormat m_data_format
;
142 EVFetchNumFormat m_num_format
;
143 EVFetchEndianSwap m_endian_swap
;
149 bool m_is_mega_fetch
;
150 uint32_t m_mega_fetch_count
;
152 uint32_t m_buffer_id
;
153 uint32_t m_semantic_id
;
155 EBufferIndexMode m_buffer_index_mode
;
156 std::bitset
<16> m_flags
;
162 PValue m_buffer_offset
;
163 std::array
<int, 4> m_dest_swizzle
;
164 std::vector
<PInstruction
> m_prelude
;
167 class LoadFromScratch
: public FetchInstruction
{
169 LoadFromScratch(GPRVector dst
, PValue src
, int scratch_size
);
172 class FetchGDSOpResult
: public FetchInstruction
{
174 FetchGDSOpResult(const GPRVector dst
, const PValue src
);
177 class FetchTCSIOParam
: public FetchInstruction
{
179 FetchTCSIOParam(GPRVector dst
, PValue src
, int offset
);
184 #endif // SFN_INSTRUCTION_FETCH_H