89c8922d3fedd84322e4b5eac10c6973abba2f0e
[mesa.git] / src / amd / addrlib / gfx9 / rbmap.h
1 /*
2 * Copyright © 2017 Advanced Micro Devices, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
17 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 */
26
27 // This class RB_MAP contains the top-level calculation functions which are used to generate rb id map based rb id equations
28
29 #ifndef __RB_MAP_H
30 #define __RB_MAP_H
31
32 #include "coord.h"
33
34 class RB_MAP
35 {
36 public:
37
38 enum MAX_VALUES {
39 MAX_SES_LOG2 = 3,
40 MAX_RBS_LOG2 = 2
41 };
42
43 enum COMPRESSED_DATABLOCKS_IN_METABLOCK_PER_RB_LOG2 {
44 COMPRESSED_DATABLOCKS_IN_METABLOCK_PER_RB_LOG2_2D = 10,
45 COMPRESSED_DATABLOCKS_IN_METABLOCK_PER_RB_LOG2_3D = 18
46 };
47
48 RB_MAP(void);
49
50 void Get_Comp_Block_Screen_Space( CoordEq& addr, int bytes_log2, int* w, int* h, int* d = NULL);
51
52 void Get_Meta_Block_Screen_Space( int num_comp_blocks_log2, bool is_thick, bool y_biased,
53 int comp_block_width_log2, int comp_block_height_log2, int comp_block_depth_log2,
54 int& meta_block_width_log2, int& meta_block_height_log2, int& meta_block_depth_log2 );
55 void cap_pipe( int xmode, bool is_thick, int& num_ses_log2, int bpp_log2, int num_samples_log2, int pipe_interleave_log2,
56 int& block_size_log2, int& num_pipes_log2 );
57
58 void Get_Data_Offset_Equation( CoordEq& data_eq, int data_type, int bpp_log2, int num_samples_log2, int block_size_log2 );
59
60 void Get_RB_Equation( CoordEq& rb_equation, int num_ses_log2, int num_rbs_log2 );
61
62 void Get_Pipe_Equation( CoordEq& pipe_equation, CoordEq& addr,
63 int pipe_interleave_log2,
64 int num_pipes_log2,
65 int block_size_log2,
66 int num_samples_log2,
67 int xmode, int data_type
68 );
69
70 void get_meta_miptail_coord( int& x, int& y, int& z, int mip_in_tail, int blk_width_log2, int blk_height_log2, int blk_depth_log2 );
71
72 void get_mip_coord( int& x, int& y, int& z, int mip,
73 int meta_blk_width_log2, int meta_blk_height_log2, int meta_blk_depth_log2,
74 int data_blk_width_log2, int data_blk_height_log2,
75 int& surf_width, int& surf_height, int& surf_depth, int epitch, int max_mip,
76 int data_type, int bpp_log2, bool meta_linear );
77
78 void get_mip_coord_linear( int& x, int& y, int& z, int mip, int data_blk_width_log2, int data_blk_height_log2,
79 int& surf_width, int& surf_height, int& surf_depth, int epitch, int max_mip, int data_type, int bpp_log2 );
80
81 void get_mip_coord_nonlinear( int& x, int& y, int& z, int mip, int meta_blk_width_log2, int meta_blk_height_log2, int meta_blk_depth_log2,
82 int& surf_width, int& surf_height, int& surf_depth, int epitch, int max_mip, int data_type );
83
84 void get_meta_eq( CoordEq& metaaddr, int max_mip, int num_ses_log2, int num_rbs_log2, int &num_pipes_log2,
85 int block_size_log2, int bpp_log2, int num_samples_log2, int max_comp_frag_log2,
86 int pipe_interleave_log2, int xmode, int data_type, int meta_alignment, bool meta_linear);
87
88 #if 0
89 long get_meta_addr( int x, int y, int z, int s, int mip,
90 int surf_width, int surf_height, int surf_depth, int epitch,
91 long surf_base, int pipe_xor, int max_mip,
92 int num_ses_log2, int num_rbs_log2, int num_pipes_log2,
93 int block_size_log2, int bpp_log2, int num_samples_log2, int max_comp_frag_log2,
94 int pipe_interleave_log2, int xmode, int data_type, int meta_alignment, bool meta_linear);
95 #endif
96
97 long get_meta_addr_calc( int x, int y, int z, int s,
98 long surf_base, int element_bytes_log2, int num_samples_log2, int max_comp_frag_log2,
99 long pitch, long slice,
100 int max_mip,
101 //int swizzle_mode,
102 int xmode, int pipe_xor, int block_size_log2,
103 /*int num_banks_log2,*/ int num_pipes_log2,
104 int pipe_interleave_log2, int meta_alignment, int dim_type, int x_mip_org, int y_mip_org,
105 int z_mip_org, int num_ses_log2, int num_rbs_log2, /*bool se_affinity_enable,*/ int data_type,
106 int l2_metablk_w, int l2_metablk_h, int l2_metablk_d, bool meta_linear);
107
108 void Initialize(void);
109
110 public:
111 enum XOR_RANGE {
112 NONE = 0,
113 XOR = 1,
114 PRT = 2
115 };
116
117
118 enum DATA_TYPE_ENUM {
119 DATA_COLOR1D,
120 DATA_COLOR2D,
121 DATA_COLOR3D_S,
122 DATA_COLOR3D_Z,
123 DATA_Z_STENCIL,
124 DATA_FMASK,
125 DATA_COLOR2D_LINEAR,
126 DATA_COLOR3D_D_NOT_USED // should not be used; use COLOR2D instead
127 };
128
129 enum META_ALIGNMENT {
130 META_ALIGN_NONE,
131 META_ALIGN_PIPE,
132 META_ALIGN_RB,
133 META_ALIGN_PIPE_RB
134 };
135
136 CoordEq rb_equation[MAX_SES_LOG2+1][MAX_RBS_LOG2+1];
137 CoordEq zaddr [4][4];
138 CoordEq caddr [5][4];
139 CoordEq c3addr[5][2];
140 };
141
142 #endif