r600g: fix RSQ of negative value on Cayman
[mesa.git] / src / gallium / drivers / r600 / evergreen_compute_internal.h
1 /*
2 * Permission is hereby granted, free of charge, to any person obtaining a
3 * copy of this software and associated documentation files (the "Software"),
4 * to deal in the Software without restriction, including without limitation
5 * on the rights to use, copy, modify, merge, publish, distribute, sub
6 * license, and/or sell copies of the Software, and to permit persons to whom
7 * the Software is furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice (including the next
10 * paragraph) shall be included in all copies or substantial portions of the
11 * Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19 * USE OR OTHER DEALINGS IN THE SOFTWARE.
20 *
21 * Authors:
22 * Adam Rak <adam.rak@streamnovation.com>
23 */
24
25 #ifndef EVERGREEN_COMPUTE_INTERNAL_H
26 #define EVERGREEN_COMPUTE_INTERNAL_H
27
28 #include "compute_memory_pool.h"
29 #include "r600_asm.h"
30
31 enum evergreen_compute_resources
32 {
33 #define DECL_COMPUTE_RESOURCE(name, n) COMPUTE_RESOURCE_ ## name ,
34 #include "compute_resource.def"
35 #undef DECL_COMPUTE_RESOURCE
36 __COMPUTE_RESOURCE_END__
37 };
38
39 typedef unsigned u32;
40
41 #define COMPUTE_RES_TC_FLUSH 0xF0001
42 #define COMPUTE_RES_VC_FLUSH 0xF0002
43 #define COMPUTE_RES_SH_FLUSH 0xF0004
44 #define COMPUTE_RES_CB_FLUSH(x) (0xF0008 | x << 8)
45 #define COMPUTE_RES_FULL_FLUSH 0xF0010
46
47 struct evergreen_compute_resource {
48 int enabled;
49
50 int do_reloc[256];
51 u32 cs[256];
52 int cs_end;
53
54 struct r600_resource *bo;
55 int coher_bo_size;
56 enum radeon_bo_usage usage;
57 int flags; ///flags for COMPUTE_RES_*_FLUSH
58 };
59
60 struct compute_sampler_state {
61 struct r600_pipe_state base;
62 struct pipe_sampler_state state;
63 };
64
65 struct number_type_and_format {
66 unsigned format;
67 unsigned number_type;
68 unsigned num_format_all;
69 };
70
71 struct r600_kernel {
72 unsigned count;
73 #ifdef HAVE_OPENCL
74 LLVMModuleRef llvm_module;
75 #endif
76 struct r600_resource *code_bo;
77 struct r600_bytecode bc;
78 };
79
80 struct r600_pipe_compute {
81 struct r600_context *ctx;
82
83 unsigned num_kernels;
84 struct r600_kernel *kernels;
85 struct evergreen_compute_resource *resources;
86
87 unsigned local_size;
88 unsigned private_size;
89 unsigned input_size;
90 struct r600_resource *kernel_param;
91 };
92
93 int evergreen_compute_get_gpu_format(struct number_type_and_format* fmt, struct r600_resource *bo); ///get hw format from resource, return 0 on faliure, nonzero on success
94
95
96 void evergreen_emit_raw_reg_set(struct evergreen_compute_resource* res, unsigned index, int num);
97 void evergreen_emit_ctx_reg_set(struct r600_context *ctx, unsigned index, int num);
98 void evergreen_emit_raw_value(struct evergreen_compute_resource* res, unsigned value);
99 void evergreen_emit_ctx_value(struct r600_context *ctx, unsigned value);
100 void evergreen_mult_reg_set_(struct evergreen_compute_resource* res, int index, u32* array, int size);
101 void evergreen_emit_ctx_reloc(struct r600_context *ctx, struct r600_resource *bo, enum radeon_bo_usage usage);
102 void evergreen_reg_set(struct evergreen_compute_resource* res, unsigned index, unsigned value);
103 void evergreen_emit_force_reloc(struct evergreen_compute_resource* res);
104
105 struct evergreen_compute_resource* get_empty_res(struct r600_pipe_compute*, enum evergreen_compute_resources res_code, int index);
106 int get_compute_resource_num(void);
107
108 #define evergreen_mult_reg_set(res, index, array) evergreen_mult_reg_set_(res, index, array, sizeof(array))
109
110 void evergreen_set_rat(struct r600_pipe_compute *pipe, int id, struct r600_resource* bo, int start, int size);
111 void evergreen_set_gds(struct r600_pipe_compute *pipe, uint32_t addr, uint32_t size);
112 void evergreen_set_export(struct r600_pipe_compute *pipe, struct r600_resource* bo, int offset, int size);
113 void evergreen_set_loop_const(struct r600_pipe_compute *pipe, int id, int count, int init, int inc);
114 void evergreen_set_tmp_ring(struct r600_pipe_compute *pipe, struct r600_resource* bo, int offset, int size, int se);
115 void evergreen_set_tex_resource(struct r600_pipe_compute *pipe, struct r600_pipe_sampler_view* view, int id);
116 void evergreen_set_sampler_resource(struct r600_pipe_compute *pipe, struct compute_sampler_state *sampler, int id);
117 void evergreen_set_const_cache(struct r600_pipe_compute *pipe, int cache_id, struct r600_resource* cbo, int size, int offset);
118
119 struct r600_resource* r600_compute_buffer_alloc_vram(struct r600_screen *screen, unsigned size);
120
121 #endif