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 #ifndef INSTRUCTION_TEX_H
28 #define INSTRUCTION_TEX_H
30 #include "sfn_instruction_base.h"
34 class TexInstruction
: public Instruction
{
38 get_resinfo
= FETCH_OP_GET_TEXTURE_RESINFO
,
39 get_nsampled
= FETCH_OP_GET_NUMBER_OF_SAMPLES
,
40 get_tex_lod
= FETCH_OP_GET_LOD
,
41 get_gradient_h
= FETCH_OP_GET_GRADIENTS_H
,
42 get_gradient_v
= FETCH_OP_GET_GRADIENTS_V
,
43 set_offsets
= FETCH_OP_SET_TEXTURE_OFFSETS
,
44 keep_gradients
= FETCH_OP_KEEP_GRADIENTS
,
45 set_gradient_h
= FETCH_OP_SET_GRADIENTS_H
,
46 set_gradient_v
= FETCH_OP_SET_GRADIENTS_V
,
47 sample
= FETCH_OP_SAMPLE
,
48 sample_l
= FETCH_OP_SAMPLE_L
,
49 sample_lb
= FETCH_OP_SAMPLE_LB
,
50 sample_lz
= FETCH_OP_SAMPLE_LZ
,
51 sample_g
= FETCH_OP_SAMPLE_G
,
52 sample_g_lb
= FETCH_OP_SAMPLE_G_L
,
53 gather4
= FETCH_OP_GATHER4
,
54 gather4_o
= FETCH_OP_GATHER4_O
,
56 sample_c
= FETCH_OP_SAMPLE_C
,
57 sample_c_l
= FETCH_OP_SAMPLE_C_L
,
58 sample_c_lb
= FETCH_OP_SAMPLE_C_LB
,
59 sample_c_lz
= FETCH_OP_SAMPLE_C_LZ
,
60 sample_c_g
= FETCH_OP_SAMPLE_C_G
,
61 sample_c_g_lb
= FETCH_OP_SAMPLE_C_G_L
,
62 gather4_c
= FETCH_OP_GATHER4_C
,
63 gather4_c_o
= FETCH_OP_GATHER4_C_O
,
75 TexInstruction(Opcode op
, const GPRVector
& dest
, const GPRVector
& src
, unsigned sid
,
76 unsigned rid
, PValue sampler_offset
);
78 const GPRVector
& src() const {return m_src
;}
79 const GPRVector
& dst() const {return m_dst
;}
80 unsigned opcode() const {return m_opcode
;}
81 unsigned sampler_id() const {return m_sampler_id
;}
82 unsigned resource_id() const {return m_resource_id
;}
84 void replace_values(const ValueSet
& candiates
, PValue new_value
) override
;
86 void set_offset(unsigned index
, int32_t val
);
87 int get_offset(unsigned index
) const;
89 void set_inst_mode(int inst_mode
) { m_inst_mode
= inst_mode
;}
91 int inst_mode() const { return m_inst_mode
;}
93 void set_flag(Flags flag
) {
97 PValue
sampler_offset() const {
98 return m_sampler_offset
;
101 bool has_flag(Flags flag
) const {
102 return m_flags
.test(flag
);
105 int dest_swizzle(int i
) const {
107 return m_dest_swizzle
[i
];
110 void set_dest_swizzle(const std::array
<int,4>& swz
) {
111 m_dest_swizzle
= swz
;
114 void set_gather_comp(int cmp
);
117 bool is_equal_to(const Instruction
& lhs
) const override
;
118 void do_print(std::ostream
& os
) const override
;
120 static const char *opname(Opcode code
);
125 unsigned m_sampler_id
;
126 unsigned m_resource_id
;
127 std::bitset
<8> m_flags
;
130 std::array
<int,4> m_dest_swizzle
;
131 PValue m_sampler_offset
;
134 bool r600_nir_lower_int_tg4(nir_shader
*nir
);
135 bool r600_nir_lower_txl_txf_array_or_cube(nir_shader
*shader
);
139 #endif // INSTRUCTION_TEX_H