~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/r600/r600_pipe.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the "Software"),
6
 
 * to deal in the Software without restriction, including without limitation
7
 
 * on the rights to use, copy, modify, merge, publish, distribute, sub
8
 
 * license, and/or sell copies of the Software, and to permit persons to whom
9
 
 * the Software is furnished to do so, subject to the following conditions:
10
 
 *
11
 
 * The above copyright notice and this permission notice (including the next
12
 
 * paragraph) shall be included in all copies or substantial portions of the
13
 
 * Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18
 
 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
 
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
 
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22
 
 *
23
 
 * Authors:
24
 
 *      Jerome Glisse
25
 
 */
26
 
#ifndef R600_PIPE_H
27
 
#define R600_PIPE_H
28
 
 
29
 
#include "r600_pipe_common.h"
30
 
#include "r600_cs.h"
31
 
#include "r600_public.h"
32
 
#include "pipe/p_defines.h"
33
 
 
34
 
#include "util/u_suballoc.h"
35
 
#include "util/list.h"
36
 
#include "util/u_transfer.h"
37
 
#include "util/u_memory.h"
38
 
 
39
 
#include "tgsi/tgsi_scan.h"
40
 
 
41
 
#define R600_NUM_ATOMS 56
42
 
 
43
 
#define R600_MAX_IMAGES 8
44
 
/*
45
 
 * ranges reserved for images on evergreen
46
 
 * first set for the immediate buffers,
47
 
 * second for the actual resources for RESQ.
48
 
 */
49
 
#define R600_IMAGE_IMMED_RESOURCE_OFFSET 160
50
 
#define R600_IMAGE_REAL_RESOURCE_OFFSET 168
51
 
 
52
 
/* read caches */
53
 
#define R600_CONTEXT_INV_VERTEX_CACHE           (R600_CONTEXT_PRIVATE_FLAG << 0)
54
 
#define R600_CONTEXT_INV_TEX_CACHE              (R600_CONTEXT_PRIVATE_FLAG << 1)
55
 
#define R600_CONTEXT_INV_CONST_CACHE            (R600_CONTEXT_PRIVATE_FLAG << 2)
56
 
/* read-write caches */
57
 
#define R600_CONTEXT_FLUSH_AND_INV              (R600_CONTEXT_PRIVATE_FLAG << 3)
58
 
#define R600_CONTEXT_FLUSH_AND_INV_CB_META      (R600_CONTEXT_PRIVATE_FLAG << 4)
59
 
#define R600_CONTEXT_FLUSH_AND_INV_DB_META      (R600_CONTEXT_PRIVATE_FLAG << 5)
60
 
#define R600_CONTEXT_FLUSH_AND_INV_DB           (R600_CONTEXT_PRIVATE_FLAG << 6)
61
 
#define R600_CONTEXT_FLUSH_AND_INV_CB           (R600_CONTEXT_PRIVATE_FLAG << 7)
62
 
/* engine synchronization */
63
 
#define R600_CONTEXT_PS_PARTIAL_FLUSH           (R600_CONTEXT_PRIVATE_FLAG << 8)
64
 
#define R600_CONTEXT_WAIT_3D_IDLE               (R600_CONTEXT_PRIVATE_FLAG << 9)
65
 
#define R600_CONTEXT_WAIT_CP_DMA_IDLE           (R600_CONTEXT_PRIVATE_FLAG << 10)
66
 
#define R600_CONTEXT_CS_PARTIAL_FLUSH           (R600_CONTEXT_PRIVATE_FLAG << 11)
67
 
 
68
 
/* the number of CS dwords for flushing and drawing */
69
 
#define R600_MAX_FLUSH_CS_DWORDS        18
70
 
#define R600_MAX_DRAW_CS_DWORDS         58
71
 
#define R600_MAX_PFP_SYNC_ME_DWORDS     16
72
 
 
73
 
#define EG_MAX_ATOMIC_BUFFERS 8
74
 
 
75
 
#define R600_MAX_USER_CONST_BUFFERS 15
76
 
#define R600_MAX_DRIVER_CONST_BUFFERS 3
77
 
#define R600_MAX_CONST_BUFFERS (R600_MAX_USER_CONST_BUFFERS + R600_MAX_DRIVER_CONST_BUFFERS)
78
 
#define R600_MAX_HW_CONST_BUFFERS 16
79
 
 
80
 
/* start driver buffers after user buffers */
81
 
#define R600_BUFFER_INFO_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS)
82
 
#define R600_UCP_SIZE (4*4*8)
83
 
#define R600_CS_BLOCK_GRID_SIZE (8 * 4)
84
 
#define R600_TCS_DEFAULT_LEVELS_SIZE (6 * 4)
85
 
#define R600_BUFFER_INFO_OFFSET (R600_UCP_SIZE)
86
 
 
87
 
/*
88
 
 * We only access this buffer through vtx clauses hence it's fine to exist
89
 
 * at index beyond 15.
90
 
 */
91
 
#define R600_LDS_INFO_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 1)
92
 
/*
93
 
 * Note GS doesn't use a constant buffer binding, just a resource index,
94
 
 * so it's fine to have it exist at index beyond 15. I.e. it's not actually
95
 
 * a const buffer, just a buffer resource.
96
 
 */
97
 
#define R600_GS_RING_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 2)
98
 
/* Currently R600_MAX_CONST_BUFFERS just fits on the hw, which has a limit
99
 
 * of 16 const buffers.
100
 
 * UCP/SAMPLE_POSITIONS are never accessed by same shader stage so they can use the same id.
101
 
 *
102
 
 * In order to support d3d 11 mandated minimum of 15 user const buffers
103
 
 * we'd have to squash all use cases into one driver buffer.
104
 
 */
105
 
#define R600_MAX_CONST_BUFFER_SIZE (4096 * sizeof(float[4]))
106
 
 
107
 
/* HW stages */
108
 
#define R600_HW_STAGE_PS 0
109
 
#define R600_HW_STAGE_VS 1
110
 
#define R600_HW_STAGE_GS 2
111
 
#define R600_HW_STAGE_ES 3
112
 
#define EG_HW_STAGE_LS 4
113
 
#define EG_HW_STAGE_HS 5
114
 
 
115
 
#define R600_NUM_HW_STAGES 4
116
 
#define EG_NUM_HW_STAGES 6
117
 
 
118
 
struct r600_context;
119
 
struct r600_bytecode;
120
 
union  r600_shader_key;
121
 
 
122
 
/* This is an atom containing GPU commands that never change.
123
 
 * This is supposed to be copied directly into the CS. */
124
 
struct r600_command_buffer {
125
 
        uint32_t *buf;
126
 
        unsigned num_dw;
127
 
        unsigned max_num_dw;
128
 
        unsigned pkt_flags;
129
 
};
130
 
 
131
 
struct r600_db_state {
132
 
        struct r600_atom                atom;
133
 
        struct r600_surface             *rsurf;
134
 
};
135
 
 
136
 
struct r600_db_misc_state {
137
 
        struct r600_atom                atom;
138
 
        bool                            occlusion_queries_disabled;
139
 
        bool                            flush_depthstencil_through_cb;
140
 
        bool                            flush_depth_inplace;
141
 
        bool                            flush_stencil_inplace;
142
 
        bool                            copy_depth, copy_stencil;
143
 
        unsigned                        copy_sample;
144
 
        unsigned                        log_samples;
145
 
        unsigned                        db_shader_control;
146
 
        bool                            htile_clear;
147
 
        uint8_t                         ps_conservative_z;
148
 
};
149
 
 
150
 
struct r600_cb_misc_state {
151
 
        struct r600_atom atom;
152
 
        unsigned cb_color_control; /* this comes from blend state */
153
 
        unsigned blend_colormask; /* 8*4 bits for 8 RGBA colorbuffers */
154
 
        unsigned nr_cbufs;
155
 
        unsigned bound_cbufs_target_mask;
156
 
        unsigned nr_ps_color_outputs;
157
 
        unsigned ps_color_export_mask;
158
 
        unsigned image_rat_enabled_mask;
159
 
        unsigned buffer_rat_enabled_mask;
160
 
        bool multiwrite;
161
 
        bool dual_src_blend;
162
 
};
163
 
 
164
 
struct r600_clip_misc_state {
165
 
        struct r600_atom atom;
166
 
        unsigned pa_cl_clip_cntl;   /* from rasterizer    */
167
 
        unsigned pa_cl_vs_out_cntl; /* from vertex shader */
168
 
        unsigned clip_plane_enable; /* from rasterizer    */
169
 
        unsigned cc_dist_mask;      /* from vertex shader */
170
 
        unsigned clip_dist_write;   /* from vertex shader */
171
 
        unsigned cull_dist_write;   /* from vertex shader */
172
 
        boolean clip_disable;       /* from vertex shader */
173
 
        boolean vs_out_viewport;    /* from vertex shader */
174
 
};
175
 
 
176
 
struct r600_alphatest_state {
177
 
        struct r600_atom atom;
178
 
        unsigned sx_alpha_test_control; /* this comes from dsa state */
179
 
        unsigned sx_alpha_ref; /* this comes from dsa state */
180
 
        bool bypass;
181
 
        bool cb0_export_16bpc; /* from set_framebuffer_state */
182
 
};
183
 
 
184
 
struct r600_vgt_state {
185
 
        struct r600_atom atom;
186
 
        uint32_t vgt_multi_prim_ib_reset_en;
187
 
        uint32_t vgt_multi_prim_ib_reset_indx;
188
 
        uint32_t vgt_indx_offset;
189
 
        bool last_draw_was_indirect;
190
 
};
191
 
 
192
 
struct r600_blend_color {
193
 
        struct r600_atom atom;
194
 
        struct pipe_blend_color state;
195
 
};
196
 
 
197
 
struct r600_clip_state {
198
 
        struct r600_atom atom;
199
 
        struct pipe_clip_state state;
200
 
};
201
 
 
202
 
struct r600_cs_shader_state {
203
 
        struct r600_atom atom;
204
 
        unsigned kernel_index;
205
 
        unsigned pc;
206
 
        struct r600_pipe_compute *shader;
207
 
};
208
 
 
209
 
struct r600_framebuffer {
210
 
        struct r600_atom atom;
211
 
        struct pipe_framebuffer_state state;
212
 
        unsigned compressed_cb_mask;
213
 
        unsigned nr_samples;
214
 
        bool export_16bpc;
215
 
        bool cb0_is_integer;
216
 
        bool is_msaa_resolve;
217
 
        bool dual_src_blend;
218
 
        bool do_update_surf_dirtiness;
219
 
};
220
 
 
221
 
struct r600_sample_mask {
222
 
        struct r600_atom atom;
223
 
        uint16_t sample_mask; /* there are only 8 bits on EG, 16 bits on Cayman */
224
 
};
225
 
 
226
 
struct r600_config_state {
227
 
        struct r600_atom atom;
228
 
        unsigned sq_gpr_resource_mgmt_1;
229
 
        unsigned sq_gpr_resource_mgmt_2;
230
 
        unsigned sq_gpr_resource_mgmt_3;
231
 
        bool dyn_gpr_enabled;
232
 
};
233
 
 
234
 
struct r600_stencil_ref
235
 
{
236
 
        ubyte ref_value[2];
237
 
        ubyte valuemask[2];
238
 
        ubyte writemask[2];
239
 
};
240
 
 
241
 
struct r600_stencil_ref_state {
242
 
        struct r600_atom atom;
243
 
        struct r600_stencil_ref state;
244
 
        struct pipe_stencil_ref pipe_state;
245
 
};
246
 
 
247
 
struct r600_shader_stages_state {
248
 
        struct r600_atom atom;
249
 
        unsigned geom_enable;
250
 
};
251
 
 
252
 
struct r600_gs_rings_state {
253
 
        struct r600_atom atom;
254
 
        unsigned enable;
255
 
        struct pipe_constant_buffer esgs_ring;
256
 
        struct pipe_constant_buffer gsvs_ring;
257
 
};
258
 
 
259
 
/* This must start from 16. */
260
 
/* features */
261
 
#define DBG_NO_CP_DMA           (1 << 30)
262
 
/* shader backend */
263
 
#define DBG_NO_SB               (1 << 21)
264
 
#define DBG_SB_DRY_RUN  (1 << 23)
265
 
#define DBG_SB_STAT             (1 << 24)
266
 
#define DBG_SB_DUMP             (1 << 25)
267
 
#define DBG_SB_NO_FALLBACK      (1 << 26)
268
 
#define DBG_SB_DISASM   (1 << 27)
269
 
#define DBG_SB_SAFEMATH (1 << 28)
270
 
#define DBG_NIR_SB      (1 << 28)
271
 
 
272
 
#define DBG_NIR_PREFERRED (DBG_NIR_SB | DBG_NIR)
273
 
 
274
 
struct r600_screen {
275
 
        struct r600_common_screen       b;
276
 
        bool                            has_msaa;
277
 
        bool                            has_compressed_msaa_texturing;
278
 
        bool                            has_atomics;
279
 
 
280
 
        /*for compute global memory binding, we allocate stuff here, instead of
281
 
         * buffers.
282
 
         * XXX: Not sure if this is the best place for global_pool.  Also,
283
 
         * it's not thread safe, so it won't work with multiple contexts. */
284
 
        struct compute_memory_pool *global_pool;
285
 
};
286
 
 
287
 
struct r600_pipe_sampler_view {
288
 
        struct pipe_sampler_view        base;
289
 
        struct list_head                list;
290
 
        struct r600_resource            *tex_resource;
291
 
        uint32_t                        tex_resource_words[8];
292
 
        bool                            skip_mip_address_reloc;
293
 
        bool                            is_stencil_sampler;
294
 
};
295
 
 
296
 
struct r600_rasterizer_state {
297
 
        struct r600_command_buffer      buffer;
298
 
        boolean                         flatshade;
299
 
        boolean                         two_side;
300
 
        unsigned                        sprite_coord_enable;
301
 
        unsigned                        clip_plane_enable;
302
 
        unsigned                        pa_sc_line_stipple;
303
 
        unsigned                        pa_cl_clip_cntl;
304
 
        unsigned                        pa_su_sc_mode_cntl;
305
 
        float                           offset_units;
306
 
        float                           offset_scale;
307
 
        bool                            offset_enable;
308
 
        bool                            offset_units_unscaled;
309
 
        bool                            scissor_enable;
310
 
        bool                            multisample_enable;
311
 
        bool                            clip_halfz;
312
 
        bool                            rasterizer_discard;
313
 
};
314
 
 
315
 
struct r600_poly_offset_state {
316
 
        struct r600_atom                atom;
317
 
        enum pipe_format                zs_format;
318
 
        float                           offset_units;
319
 
        float                           offset_scale;
320
 
        bool                            offset_units_unscaled;
321
 
};
322
 
 
323
 
struct r600_blend_state {
324
 
        struct r600_command_buffer      buffer;
325
 
        struct r600_command_buffer      buffer_no_blend;
326
 
        unsigned                        cb_target_mask;
327
 
        unsigned                        cb_color_control;
328
 
        unsigned                        cb_color_control_no_blend;
329
 
        bool                            dual_src_blend;
330
 
        bool                            alpha_to_one;
331
 
};
332
 
 
333
 
struct r600_dsa_state {
334
 
        struct r600_command_buffer      buffer;
335
 
        unsigned                        alpha_ref;
336
 
        ubyte                           valuemask[2];
337
 
        ubyte                           writemask[2];
338
 
        unsigned                        zwritemask;
339
 
        unsigned                        sx_alpha_test_control;
340
 
};
341
 
 
342
 
struct r600_pipe_shader;
343
 
 
344
 
struct r600_pipe_shader_selector {
345
 
        struct r600_pipe_shader *current;
346
 
 
347
 
        struct tgsi_token       *tokens;
348
 
        struct nir_shader       *nir;
349
 
        struct pipe_stream_output_info  so;
350
 
        struct tgsi_shader_info         info;
351
 
 
352
 
        unsigned        num_shaders;
353
 
 
354
 
        enum pipe_shader_type   type;
355
 
        enum pipe_shader_ir ir_type;
356
 
 
357
 
        /* geometry shader properties */
358
 
        enum pipe_prim_type     gs_output_prim;
359
 
        unsigned                gs_max_out_vertices;
360
 
        unsigned                gs_num_invocations;
361
 
 
362
 
        /* TCS/VS */
363
 
        uint64_t        lds_patch_outputs_written_mask;
364
 
        uint64_t        lds_outputs_written_mask;
365
 
};
366
 
 
367
 
struct r600_pipe_sampler_state {
368
 
        uint32_t                        tex_sampler_words[3];
369
 
        union pipe_color_union          border_color;
370
 
        bool                            border_color_use;
371
 
        bool                            seamless_cube_map;
372
 
};
373
 
 
374
 
/* needed for blitter save */
375
 
#define NUM_TEX_UNITS 16
376
 
 
377
 
struct r600_seamless_cube_map {
378
 
        struct r600_atom                atom;
379
 
        bool                            enabled;
380
 
};
381
 
 
382
 
struct r600_samplerview_state {
383
 
        struct r600_atom                atom;
384
 
        struct r600_pipe_sampler_view   *views[NUM_TEX_UNITS];
385
 
        uint32_t                        enabled_mask;
386
 
        uint32_t                        dirty_mask;
387
 
        uint32_t                        compressed_depthtex_mask; /* which textures are depth */
388
 
        uint32_t                        compressed_colortex_mask;
389
 
        boolean                         dirty_buffer_constants;
390
 
};
391
 
 
392
 
struct r600_sampler_states {
393
 
        struct r600_atom                atom;
394
 
        struct r600_pipe_sampler_state  *states[NUM_TEX_UNITS];
395
 
        uint32_t                        enabled_mask;
396
 
        uint32_t                        dirty_mask;
397
 
        uint32_t                        has_bordercolor_mask; /* which states contain the border color */
398
 
};
399
 
 
400
 
struct r600_textures_info {
401
 
        struct r600_samplerview_state   views;
402
 
        struct r600_sampler_states      states;
403
 
        bool                            is_array_sampler[NUM_TEX_UNITS];
404
 
};
405
 
 
406
 
struct r600_shader_driver_constants_info {
407
 
        /* currently 128 bytes for UCP/samplepos + sampler buffer constants */
408
 
        uint32_t                        *constants;
409
 
        uint32_t                        alloc_size;
410
 
        bool                            texture_const_dirty;
411
 
        bool                            vs_ucp_dirty;
412
 
        bool                            ps_sample_pos_dirty;
413
 
        bool                            cs_block_grid_size_dirty;
414
 
        bool                            tcs_default_levels_dirty;
415
 
};
416
 
 
417
 
struct r600_constbuf_state
418
 
{
419
 
        struct r600_atom                atom;
420
 
        struct pipe_constant_buffer     cb[PIPE_MAX_CONSTANT_BUFFERS];
421
 
        uint32_t                        enabled_mask;
422
 
        uint32_t                        dirty_mask;
423
 
};
424
 
 
425
 
struct r600_vertexbuf_state
426
 
{
427
 
        struct r600_atom                atom;
428
 
        struct pipe_vertex_buffer       vb[PIPE_MAX_ATTRIBS];
429
 
        uint32_t                        enabled_mask; /* non-NULL buffers */
430
 
        uint32_t                        dirty_mask;
431
 
};
432
 
 
433
 
/* CSO (constant state object, in other words, immutable state). */
434
 
struct r600_cso_state
435
 
{
436
 
        struct r600_atom atom;
437
 
        void *cso; /* e.g. r600_blend_state */
438
 
        struct r600_command_buffer *cb;
439
 
};
440
 
 
441
 
struct r600_fetch_shader {
442
 
        struct r600_resource            *buffer;
443
 
        unsigned                        offset;
444
 
};
445
 
 
446
 
struct r600_shader_state {
447
 
        struct r600_atom                atom;
448
 
        struct r600_pipe_shader *shader;
449
 
};
450
 
 
451
 
struct r600_atomic_buffer_state {
452
 
        struct pipe_shader_buffer buffer[EG_MAX_ATOMIC_BUFFERS];
453
 
};
454
 
 
455
 
struct r600_image_view {
456
 
        struct pipe_image_view base;
457
 
        uint32_t cb_color_base;
458
 
        uint32_t cb_color_pitch;
459
 
        uint32_t cb_color_slice;
460
 
        uint32_t cb_color_view;
461
 
        uint32_t cb_color_info;
462
 
        uint32_t cb_color_attrib;
463
 
        uint32_t cb_color_dim;
464
 
        uint32_t cb_color_fmask;
465
 
        uint32_t cb_color_fmask_slice;
466
 
        uint32_t immed_resource_words[8];
467
 
        uint32_t resource_words[8];
468
 
        bool skip_mip_address_reloc;
469
 
        uint32_t buf_size;
470
 
};
471
 
 
472
 
struct r600_image_state {
473
 
        struct r600_atom atom;
474
 
        uint32_t                        enabled_mask;
475
 
        uint32_t                        dirty_mask;
476
 
        uint32_t                        compressed_depthtex_mask;
477
 
        uint32_t                        compressed_colortex_mask;
478
 
        boolean                         dirty_buffer_constants;
479
 
        struct r600_image_view views[R600_MAX_IMAGES];
480
 
};
481
 
 
482
 
/* Used to spill shader temps */
483
 
struct r600_scratch_buffer {
484
 
        struct r600_resource            *buffer;
485
 
        boolean                                 dirty;
486
 
        unsigned                                size;
487
 
        unsigned                                item_size;
488
 
};
489
 
 
490
 
struct r600_context {
491
 
        struct r600_common_context      b;
492
 
        struct r600_screen              *screen;
493
 
        struct blitter_context          *blitter;
494
 
        struct u_suballocator           allocator_fetch_shader;
495
 
 
496
 
        /* Hardware info. */
497
 
        boolean                         has_vertex_cache;
498
 
        unsigned                        default_gprs[EG_NUM_HW_STAGES];
499
 
        unsigned                        current_gprs[EG_NUM_HW_STAGES];
500
 
        unsigned                        r6xx_num_clause_temp_gprs;
501
 
 
502
 
        /* Miscellaneous state objects. */
503
 
        void                            *custom_dsa_flush;
504
 
        void                            *custom_blend_resolve;
505
 
        void                            *custom_blend_decompress;
506
 
        void                            *custom_blend_fastclear;
507
 
        /* With rasterizer discard, there doesn't have to be a pixel shader.
508
 
         * In that case, we bind this one: */
509
 
        void                            *dummy_pixel_shader;
510
 
        /* These dummy CMASK and FMASK buffers are used to get around the R6xx hardware
511
 
         * bug where valid CMASK and FMASK are required to be present to avoid
512
 
         * a hardlock in certain operations but aren't actually used
513
 
         * for anything useful. */
514
 
        struct r600_resource            *dummy_fmask;
515
 
        struct r600_resource            *dummy_cmask;
516
 
 
517
 
        /* State binding slots are here. */
518
 
        struct r600_atom                *atoms[R600_NUM_ATOMS];
519
 
        /* Dirty atom bitmask for fast tests */
520
 
        uint64_t                        dirty_atoms;
521
 
        /* States for CS initialization. */
522
 
        struct r600_command_buffer      start_cs_cmd; /* invariant state mostly */
523
 
        /** Compute specific registers initializations.  The start_cs_cmd atom
524
 
         *  must be emitted before start_compute_cs_cmd. */
525
 
        struct r600_command_buffer      start_compute_cs_cmd;
526
 
        /* Register states. */
527
 
        struct r600_alphatest_state     alphatest_state;
528
 
        struct r600_cso_state           blend_state;
529
 
        struct r600_blend_color         blend_color;
530
 
        struct r600_cb_misc_state       cb_misc_state;
531
 
        struct r600_clip_misc_state     clip_misc_state;
532
 
        struct r600_clip_state          clip_state;
533
 
        struct r600_db_misc_state       db_misc_state;
534
 
        struct r600_db_state            db_state;
535
 
        struct r600_cso_state           dsa_state;
536
 
        struct r600_framebuffer         framebuffer;
537
 
        struct r600_poly_offset_state   poly_offset_state;
538
 
        struct r600_cso_state           rasterizer_state;
539
 
        struct r600_sample_mask         sample_mask;
540
 
        struct r600_seamless_cube_map   seamless_cube_map;
541
 
        struct r600_config_state        config_state;
542
 
        struct r600_stencil_ref_state   stencil_ref;
543
 
        struct r600_vgt_state           vgt_state;
544
 
        struct r600_atomic_buffer_state atomic_buffer_state;
545
 
        /* only have images on fragment shader */
546
 
        struct r600_image_state         fragment_images;
547
 
        struct r600_image_state         compute_images;
548
 
        struct r600_image_state         fragment_buffers;
549
 
        struct r600_image_state         compute_buffers;
550
 
        /* Shaders and shader resources. */
551
 
        struct r600_cso_state           vertex_fetch_shader;
552
 
        struct r600_shader_state        hw_shader_stages[EG_NUM_HW_STAGES];
553
 
        struct r600_cs_shader_state     cs_shader_state;
554
 
        struct r600_shader_stages_state shader_stages;
555
 
        struct r600_gs_rings_state      gs_rings;
556
 
        struct r600_constbuf_state      constbuf_state[PIPE_SHADER_TYPES];
557
 
        struct r600_textures_info       samplers[PIPE_SHADER_TYPES];
558
 
 
559
 
        struct r600_shader_driver_constants_info driver_consts[PIPE_SHADER_TYPES];
560
 
 
561
 
        /** Vertex buffers for fetch shaders */
562
 
        struct r600_vertexbuf_state     vertex_buffer_state;
563
 
        /** Vertex buffers for compute shaders */
564
 
        struct r600_vertexbuf_state     cs_vertex_buffer_state;
565
 
 
566
 
        /* Additional context states. */
567
 
        unsigned                        compute_cb_target_mask;
568
 
        struct r600_pipe_shader_selector *ps_shader;
569
 
        struct r600_pipe_shader_selector *vs_shader;
570
 
        struct r600_pipe_shader_selector *gs_shader;
571
 
 
572
 
        struct r600_pipe_shader_selector *tcs_shader;
573
 
        struct r600_pipe_shader_selector *tes_shader;
574
 
 
575
 
        struct r600_pipe_shader_selector *fixed_func_tcs_shader;
576
 
 
577
 
        struct r600_rasterizer_state    *rasterizer;
578
 
        bool                            alpha_to_one;
579
 
        bool                            force_blend_disable;
580
 
        bool                            gs_tri_strip_adj_fix;
581
 
        boolean                         dual_src_blend;
582
 
        unsigned                        zwritemask;
583
 
        unsigned                        ps_iter_samples;
584
 
 
585
 
        /* The list of all texture buffer objects in this context.
586
 
         * This list is walked when a buffer is invalidated/reallocated and
587
 
         * the GPU addresses are updated. */
588
 
        struct list_head                texture_buffers;
589
 
 
590
 
        /* Last draw state (-1 = unset). */
591
 
        enum pipe_prim_type             last_primitive_type; /* Last primitive type used in draw_vbo. */
592
 
        enum pipe_prim_type             current_rast_prim; /* primitive type after TES, GS */
593
 
        enum pipe_prim_type             last_rast_prim;
594
 
        unsigned                        last_start_instance;
595
 
 
596
 
        void                            *sb_context;
597
 
        struct r600_isa         *isa;
598
 
        float sample_positions[4 * 16];
599
 
        float tess_state[8];
600
 
        uint32_t cs_block_grid_sizes[8]; /* 3 for grid + 1 pad, 3 for block  + 1 pad*/
601
 
        struct r600_pipe_shader_selector *last_ls;
602
 
        struct r600_pipe_shader_selector *last_tcs;
603
 
        unsigned last_num_tcs_input_cp;
604
 
        unsigned lds_alloc;
605
 
 
606
 
        struct r600_scratch_buffer scratch_buffers[MAX2(R600_NUM_HW_STAGES, EG_NUM_HW_STAGES)];
607
 
 
608
 
        /* Debug state. */
609
 
        bool                    is_debug;
610
 
        struct radeon_saved_cs  last_gfx;
611
 
        struct r600_resource    *last_trace_buf;
612
 
        struct r600_resource    *trace_buf;
613
 
        unsigned                trace_id;
614
 
 
615
 
        uint8_t patch_vertices;
616
 
        bool cmd_buf_is_compute;
617
 
        struct pipe_resource *append_fence;
618
 
        uint32_t append_fence_id;
619
 
};
620
 
 
621
 
static inline void r600_emit_command_buffer(struct radeon_cmdbuf *cs,
622
 
                                            struct r600_command_buffer *cb)
623
 
{
624
 
        assert(cs->current.cdw + cb->num_dw <= cs->current.max_dw);
625
 
        memcpy(cs->current.buf + cs->current.cdw, cb->buf, 4 * cb->num_dw);
626
 
        cs->current.cdw += cb->num_dw;
627
 
}
628
 
 
629
 
static inline void r600_set_atom_dirty(struct r600_context *rctx,
630
 
                                       struct r600_atom *atom,
631
 
                                       bool dirty)
632
 
{
633
 
        uint64_t mask;
634
 
 
635
 
        assert(atom->id != 0);
636
 
        assert(atom->id < sizeof(mask) * 8);
637
 
        mask = 1ull << atom->id;
638
 
        if (dirty)
639
 
                rctx->dirty_atoms |= mask;
640
 
        else
641
 
                rctx->dirty_atoms &= ~mask;
642
 
}
643
 
 
644
 
static inline void r600_mark_atom_dirty(struct r600_context *rctx,
645
 
                                        struct r600_atom *atom)
646
 
{
647
 
        r600_set_atom_dirty(rctx, atom, true);
648
 
}
649
 
 
650
 
static inline void r600_emit_atom(struct r600_context *rctx, struct r600_atom *atom)
651
 
{
652
 
        atom->emit(&rctx->b, atom);
653
 
        r600_set_atom_dirty(rctx, atom, false);
654
 
}
655
 
 
656
 
static inline void r600_set_cso_state(struct r600_context *rctx,
657
 
                                      struct r600_cso_state *state, void *cso)
658
 
{
659
 
        state->cso = cso;
660
 
        r600_set_atom_dirty(rctx, &state->atom, cso != NULL);
661
 
}
662
 
 
663
 
static inline void r600_set_cso_state_with_cb(struct r600_context *rctx,
664
 
                                              struct r600_cso_state *state, void *cso,
665
 
                                              struct r600_command_buffer *cb)
666
 
{
667
 
        state->cb = cb;
668
 
        state->atom.num_dw = cb ? cb->num_dw : 0;
669
 
        r600_set_cso_state(rctx, state, cso);
670
 
}
671
 
 
672
 
/* compute_memory_pool.c */
673
 
struct compute_memory_pool;
674
 
void compute_memory_pool_delete(struct compute_memory_pool* pool);
675
 
struct compute_memory_pool* compute_memory_pool_new(
676
 
        struct r600_screen *rscreen);
677
 
 
678
 
/* evergreen_state.c */
679
 
struct pipe_sampler_view *
680
 
evergreen_create_sampler_view_custom(struct pipe_context *ctx,
681
 
                                     struct pipe_resource *texture,
682
 
                                     const struct pipe_sampler_view *state,
683
 
                                     unsigned width0, unsigned height0,
684
 
                                     unsigned force_level);
685
 
void evergreen_init_common_regs(struct r600_context *ctx,
686
 
                                struct r600_command_buffer *cb,
687
 
                                enum chip_class ctx_chip_class,
688
 
                                enum radeon_family ctx_family,
689
 
                                int ctx_drm_minor);
690
 
void cayman_init_common_regs(struct r600_command_buffer *cb,
691
 
                             enum chip_class ctx_chip_class,
692
 
                             enum radeon_family ctx_family,
693
 
                             int ctx_drm_minor);
694
 
 
695
 
void evergreen_init_state_functions(struct r600_context *rctx);
696
 
void evergreen_init_atom_start_cs(struct r600_context *rctx);
697
 
void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
698
 
void evergreen_update_es_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
699
 
void evergreen_update_gs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
700
 
void evergreen_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
701
 
void evergreen_update_ls_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
702
 
void evergreen_update_hs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
703
 
void *evergreen_create_db_flush_dsa(struct r600_context *rctx);
704
 
void *evergreen_create_resolve_blend(struct r600_context *rctx);
705
 
void *evergreen_create_decompress_blend(struct r600_context *rctx);
706
 
void *evergreen_create_fastclear_blend(struct r600_context *rctx);
707
 
bool evergreen_is_format_supported(struct pipe_screen *screen,
708
 
                                   enum pipe_format format,
709
 
                                   enum pipe_texture_target target,
710
 
                                   unsigned sample_count,
711
 
                                   unsigned storage_sample_count,
712
 
                                   unsigned usage);
713
 
void evergreen_init_color_surface(struct r600_context *rctx,
714
 
                                  struct r600_surface *surf);
715
 
void evergreen_init_color_surface_rat(struct r600_context *rctx,
716
 
                                        struct r600_surface *surf);
717
 
void evergreen_update_db_shader_control(struct r600_context * rctx);
718
 
bool evergreen_adjust_gprs(struct r600_context *rctx);
719
 
void evergreen_setup_scratch_buffers(struct r600_context *rctx);
720
 
uint32_t evergreen_construct_rat_mask(struct r600_context *rctx, struct r600_cb_misc_state *a,
721
 
                                      unsigned nr_cbufs);
722
 
/* r600_blit.c */
723
 
void r600_init_blit_functions(struct r600_context *rctx);
724
 
void r600_decompress_depth_textures(struct r600_context *rctx,
725
 
                                    struct r600_samplerview_state *textures);
726
 
void r600_decompress_depth_images(struct r600_context *rctx,
727
 
                                  struct r600_image_state *images);
728
 
void r600_decompress_color_textures(struct r600_context *rctx,
729
 
                                    struct r600_samplerview_state *textures);
730
 
void r600_decompress_color_images(struct r600_context *rctx,
731
 
                                  struct r600_image_state *images);
732
 
void r600_resource_copy_region(struct pipe_context *ctx,
733
 
                               struct pipe_resource *dst,
734
 
                               unsigned dst_level,
735
 
                               unsigned dstx, unsigned dsty, unsigned dstz,
736
 
                               struct pipe_resource *src,
737
 
                               unsigned src_level,
738
 
                               const struct pipe_box *src_box);
739
 
 
740
 
/* r600_shader.c */
741
 
int r600_pipe_shader_create(struct pipe_context *ctx,
742
 
                            struct r600_pipe_shader *shader,
743
 
                            union r600_shader_key key);
744
 
 
745
 
void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader);
746
 
 
747
 
/* r600_state.c */
748
 
struct pipe_sampler_view *
749
 
r600_create_sampler_view_custom(struct pipe_context *ctx,
750
 
                                struct pipe_resource *texture,
751
 
                                const struct pipe_sampler_view *state,
752
 
                                unsigned width_first_level, unsigned height_first_level);
753
 
void r600_init_state_functions(struct r600_context *rctx);
754
 
void r600_init_atom_start_cs(struct r600_context *rctx);
755
 
void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
756
 
void r600_update_es_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
757
 
void r600_update_gs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
758
 
void r600_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
759
 
void *r600_create_db_flush_dsa(struct r600_context *rctx);
760
 
void *r600_create_resolve_blend(struct r600_context *rctx);
761
 
void *r700_create_resolve_blend(struct r600_context *rctx);
762
 
void *r600_create_decompress_blend(struct r600_context *rctx);
763
 
bool r600_adjust_gprs(struct r600_context *rctx);
764
 
bool r600_is_format_supported(struct pipe_screen *screen,
765
 
                              enum pipe_format format,
766
 
                              enum pipe_texture_target target,
767
 
                              unsigned sample_count,
768
 
                              unsigned storage_sample_count,
769
 
                              unsigned usage);
770
 
void r600_update_db_shader_control(struct r600_context * rctx);
771
 
void r600_setup_scratch_buffers(struct r600_context *rctx);
772
 
 
773
 
/* r600_hw_context.c */
774
 
void r600_context_gfx_flush(void *context, unsigned flags,
775
 
                            struct pipe_fence_handle **fence);
776
 
void r600_begin_new_cs(struct r600_context *ctx);
777
 
void r600_flush_emit(struct r600_context *ctx);
778
 
void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw, boolean count_draw_in, unsigned num_atomics);
779
 
void r600_emit_pfp_sync_me(struct r600_context *rctx);
780
 
void r600_cp_dma_copy_buffer(struct r600_context *rctx,
781
 
                             struct pipe_resource *dst, uint64_t dst_offset,
782
 
                             struct pipe_resource *src, uint64_t src_offset,
783
 
                             unsigned size);
784
 
void evergreen_cp_dma_clear_buffer(struct r600_context *rctx,
785
 
                                   struct pipe_resource *dst, uint64_t offset,
786
 
                                   unsigned size, uint32_t clear_value,
787
 
                                   enum r600_coherency coher);
788
 
void r600_dma_copy_buffer(struct r600_context *rctx,
789
 
                          struct pipe_resource *dst,
790
 
                          struct pipe_resource *src,
791
 
                          uint64_t dst_offset,
792
 
                          uint64_t src_offset,
793
 
                          uint64_t size);
794
 
 
795
 
/*
796
 
 * evergreen_hw_context.c
797
 
 */
798
 
void evergreen_dma_copy_buffer(struct r600_context *rctx,
799
 
                               struct pipe_resource *dst,
800
 
                               struct pipe_resource *src,
801
 
                               uint64_t dst_offset,
802
 
                               uint64_t src_offset,
803
 
                               uint64_t size);
804
 
void evergreen_setup_tess_constants(struct r600_context *rctx,
805
 
                                    const struct pipe_draw_info *info,
806
 
                                    unsigned *num_patches);
807
 
uint32_t evergreen_get_ls_hs_config(struct r600_context *rctx,
808
 
                                    const struct pipe_draw_info *info,
809
 
                                    unsigned num_patches);
810
 
void evergreen_set_ls_hs_config(struct r600_context *rctx,
811
 
                                struct radeon_cmdbuf *cs,
812
 
                                uint32_t ls_hs_config);
813
 
void evergreen_set_lds_alloc(struct r600_context *rctx,
814
 
                             struct radeon_cmdbuf *cs,
815
 
                             uint32_t lds_alloc);
816
 
 
817
 
/* r600_state_common.c */
818
 
void r600_init_common_state_functions(struct r600_context *rctx);
819
 
void r600_emit_cso_state(struct r600_context *rctx, struct r600_atom *atom);
820
 
void r600_emit_alphatest_state(struct r600_context *rctx, struct r600_atom *atom);
821
 
void r600_emit_blend_color(struct r600_context *rctx, struct r600_atom *atom);
822
 
void r600_emit_vgt_state(struct r600_context *rctx, struct r600_atom *atom);
823
 
void r600_emit_clip_misc_state(struct r600_context *rctx, struct r600_atom *atom);
824
 
void r600_emit_stencil_ref(struct r600_context *rctx, struct r600_atom *atom);
825
 
void r600_emit_shader(struct r600_context *rctx, struct r600_atom *a);
826
 
void r600_add_atom(struct r600_context *rctx, struct r600_atom *atom, unsigned id);
827
 
void r600_init_atom(struct r600_context *rctx, struct r600_atom *atom, unsigned id,
828
 
                    void (*emit)(struct r600_context *ctx, struct r600_atom *state),
829
 
                    unsigned num_dw);
830
 
void r600_vertex_buffers_dirty(struct r600_context *rctx);
831
 
void r600_sampler_views_dirty(struct r600_context *rctx,
832
 
                              struct r600_samplerview_state *state);
833
 
void r600_sampler_states_dirty(struct r600_context *rctx,
834
 
                               struct r600_sampler_states *state);
835
 
void r600_constant_buffers_dirty(struct r600_context *rctx, struct r600_constbuf_state *state);
836
 
void r600_set_sample_locations_constant_buffer(struct r600_context *rctx);
837
 
void r600_setup_scratch_area_for_shader(struct r600_context *rctx,
838
 
        struct r600_pipe_shader *shader, struct r600_scratch_buffer *scratch,
839
 
        unsigned ring_base_reg, unsigned item_size_reg, unsigned ring_size_reg);
840
 
uint32_t r600_translate_stencil_op(int s_op);
841
 
uint32_t r600_translate_fill(uint32_t func);
842
 
unsigned r600_tex_wrap(unsigned wrap);
843
 
unsigned r600_tex_mipfilter(unsigned filter);
844
 
unsigned r600_tex_compare(unsigned compare);
845
 
bool sampler_state_needs_border_color(const struct pipe_sampler_state *state);
846
 
unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format,
847
 
                                   const unsigned char *swizzle_view,
848
 
                                   boolean vtx);
849
 
uint32_t r600_translate_texformat(struct pipe_screen *screen, enum pipe_format format,
850
 
                                  const unsigned char *swizzle_view,
851
 
                                  uint32_t *word4_p, uint32_t *yuv_format_p,
852
 
                                  bool do_endian_swap);
853
 
uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format format,
854
 
                                  bool do_endian_swap);
855
 
uint32_t r600_colorformat_endian_swap(uint32_t colorformat, bool do_endian_swap);
856
 
 
857
 
/* r600_uvd.c */
858
 
struct pipe_video_codec *r600_uvd_create_decoder(struct pipe_context *context,
859
 
                                                   const struct pipe_video_codec *decoder);
860
 
 
861
 
struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
862
 
                                                   const struct pipe_video_buffer *tmpl);
863
 
 
864
 
/*
865
 
 * Helpers for building command buffers
866
 
 */
867
 
 
868
 
#define PKT3_SET_CONFIG_REG     0x68
869
 
#define PKT3_SET_CONTEXT_REG    0x69
870
 
#define PKT3_SET_CTL_CONST      0x6F
871
 
#define PKT3_SET_LOOP_CONST                    0x6C
872
 
 
873
 
#define R600_CONFIG_REG_OFFSET  0x08000
874
 
#define R600_CONTEXT_REG_OFFSET 0x28000
875
 
#define R600_CTL_CONST_OFFSET   0x3CFF0
876
 
#define R600_LOOP_CONST_OFFSET                 0X0003E200
877
 
#define EG_LOOP_CONST_OFFSET               0x0003A200
878
 
 
879
 
#define PKT_TYPE_S(x)                   (((unsigned)(x) & 0x3) << 30)
880
 
#define PKT_COUNT_S(x)                  (((unsigned)(x) & 0x3FFF) << 16)
881
 
#define PKT3_IT_OPCODE_S(x)             (((unsigned)(x) & 0xFF) << 8)
882
 
#define PKT3_PREDICATE(x)               (((x) >> 0) & 0x1)
883
 
#define PKT3(op, count, predicate) (PKT_TYPE_S(3) | PKT_COUNT_S(count) | PKT3_IT_OPCODE_S(op) | PKT3_PREDICATE(predicate))
884
 
 
885
 
#define RADEON_CP_PACKET3_COMPUTE_MODE 0x00000002
886
 
 
887
 
/*Evergreen Compute packet3*/
888
 
#define PKT3C(op, count, predicate) (PKT_TYPE_S(3) | PKT3_IT_OPCODE_S(op) | PKT_COUNT_S(count) | PKT3_PREDICATE(predicate) | RADEON_CP_PACKET3_COMPUTE_MODE)
889
 
 
890
 
static inline void r600_store_value(struct r600_command_buffer *cb, unsigned value)
891
 
{
892
 
        cb->buf[cb->num_dw++] = value;
893
 
}
894
 
 
895
 
static inline void r600_store_array(struct r600_command_buffer *cb, unsigned num, unsigned *ptr)
896
 
{
897
 
        assert(cb->num_dw+num <= cb->max_num_dw);
898
 
        memcpy(&cb->buf[cb->num_dw], ptr, num * sizeof(ptr[0]));
899
 
        cb->num_dw += num;
900
 
}
901
 
 
902
 
static inline void r600_store_config_reg_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
903
 
{
904
 
        assert(reg < R600_CONTEXT_REG_OFFSET);
905
 
        assert(cb->num_dw+2+num <= cb->max_num_dw);
906
 
        cb->buf[cb->num_dw++] = PKT3(PKT3_SET_CONFIG_REG, num, 0);
907
 
        cb->buf[cb->num_dw++] = (reg - R600_CONFIG_REG_OFFSET) >> 2;
908
 
}
909
 
 
910
 
/**
911
 
 * Needs cb->pkt_flags set to  RADEON_CP_PACKET3_COMPUTE_MODE for compute
912
 
 * shaders.
913
 
 */
914
 
static inline void r600_store_context_reg_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
915
 
{
916
 
        assert(reg >= R600_CONTEXT_REG_OFFSET && reg < R600_CTL_CONST_OFFSET);
917
 
        assert(cb->num_dw+2+num <= cb->max_num_dw);
918
 
        cb->buf[cb->num_dw++] = PKT3(PKT3_SET_CONTEXT_REG, num, 0) | cb->pkt_flags;
919
 
        cb->buf[cb->num_dw++] = (reg - R600_CONTEXT_REG_OFFSET) >> 2;
920
 
}
921
 
 
922
 
/**
923
 
 * Needs cb->pkt_flags set to  RADEON_CP_PACKET3_COMPUTE_MODE for compute
924
 
 * shaders.
925
 
 */
926
 
static inline void r600_store_ctl_const_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
927
 
{
928
 
        assert(reg >= R600_CTL_CONST_OFFSET);
929
 
        assert(cb->num_dw+2+num <= cb->max_num_dw);
930
 
        cb->buf[cb->num_dw++] = PKT3(PKT3_SET_CTL_CONST, num, 0) | cb->pkt_flags;
931
 
        cb->buf[cb->num_dw++] = (reg - R600_CTL_CONST_OFFSET) >> 2;
932
 
}
933
 
 
934
 
static inline void r600_store_loop_const_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
935
 
{
936
 
        assert(reg >= R600_LOOP_CONST_OFFSET);
937
 
        assert(cb->num_dw+2+num <= cb->max_num_dw);
938
 
        cb->buf[cb->num_dw++] = PKT3(PKT3_SET_LOOP_CONST, num, 0);
939
 
        cb->buf[cb->num_dw++] = (reg - R600_LOOP_CONST_OFFSET) >> 2;
940
 
}
941
 
 
942
 
/**
943
 
 * Needs cb->pkt_flags set to  RADEON_CP_PACKET3_COMPUTE_MODE for compute
944
 
 * shaders.
945
 
 */
946
 
static inline void eg_store_loop_const_seq(struct r600_command_buffer *cb, unsigned reg, unsigned num)
947
 
{
948
 
        assert(reg >= EG_LOOP_CONST_OFFSET);
949
 
        assert(cb->num_dw+2+num <= cb->max_num_dw);
950
 
        cb->buf[cb->num_dw++] = PKT3(PKT3_SET_LOOP_CONST, num, 0) | cb->pkt_flags;
951
 
        cb->buf[cb->num_dw++] = (reg - EG_LOOP_CONST_OFFSET) >> 2;
952
 
}
953
 
 
954
 
static inline void r600_store_config_reg(struct r600_command_buffer *cb, unsigned reg, unsigned value)
955
 
{
956
 
        r600_store_config_reg_seq(cb, reg, 1);
957
 
        r600_store_value(cb, value);
958
 
}
959
 
 
960
 
static inline void r600_store_context_reg(struct r600_command_buffer *cb, unsigned reg, unsigned value)
961
 
{
962
 
        r600_store_context_reg_seq(cb, reg, 1);
963
 
        r600_store_value(cb, value);
964
 
}
965
 
 
966
 
static inline void r600_store_ctl_const(struct r600_command_buffer *cb, unsigned reg, unsigned value)
967
 
{
968
 
        r600_store_ctl_const_seq(cb, reg, 1);
969
 
        r600_store_value(cb, value);
970
 
}
971
 
 
972
 
static inline void r600_store_loop_const(struct r600_command_buffer *cb, unsigned reg, unsigned value)
973
 
{
974
 
        r600_store_loop_const_seq(cb, reg, 1);
975
 
        r600_store_value(cb, value);
976
 
}
977
 
 
978
 
static inline void eg_store_loop_const(struct r600_command_buffer *cb, unsigned reg, unsigned value)
979
 
{
980
 
        eg_store_loop_const_seq(cb, reg, 1);
981
 
        r600_store_value(cb, value);
982
 
}
983
 
 
984
 
void r600_init_command_buffer(struct r600_command_buffer *cb, unsigned num_dw);
985
 
void r600_release_command_buffer(struct r600_command_buffer *cb);
986
 
 
987
 
static inline void radeon_compute_set_context_reg_seq(struct radeon_cmdbuf *cs, unsigned reg, unsigned num)
988
 
{
989
 
        radeon_set_context_reg_seq(cs, reg, num);
990
 
        /* Set the compute bit on the packet header */
991
 
        cs->current.buf[cs->current.cdw - 2] |= RADEON_CP_PACKET3_COMPUTE_MODE;
992
 
}
993
 
 
994
 
static inline void radeon_set_ctl_const_seq(struct radeon_cmdbuf *cs, unsigned reg, unsigned num)
995
 
{
996
 
        assert(reg >= R600_CTL_CONST_OFFSET);
997
 
        assert(cs->current.cdw + 2 + num <= cs->current.max_dw);
998
 
        radeon_emit(cs, PKT3(PKT3_SET_CTL_CONST, num, 0));
999
 
        radeon_emit(cs, (reg - R600_CTL_CONST_OFFSET) >> 2);
1000
 
}
1001
 
 
1002
 
static inline void radeon_compute_set_context_reg(struct radeon_cmdbuf *cs, unsigned reg, unsigned value)
1003
 
{
1004
 
        radeon_compute_set_context_reg_seq(cs, reg, 1);
1005
 
        radeon_emit(cs, value);
1006
 
}
1007
 
 
1008
 
static inline void radeon_set_context_reg_flag(struct radeon_cmdbuf *cs, unsigned reg, unsigned value, unsigned flag)
1009
 
{
1010
 
        if (flag & RADEON_CP_PACKET3_COMPUTE_MODE) {
1011
 
                radeon_compute_set_context_reg(cs, reg, value);
1012
 
        } else {
1013
 
                radeon_set_context_reg(cs, reg, value);
1014
 
        }
1015
 
}
1016
 
 
1017
 
static inline void radeon_set_ctl_const(struct radeon_cmdbuf *cs, unsigned reg, unsigned value)
1018
 
{
1019
 
        radeon_set_ctl_const_seq(cs, reg, 1);
1020
 
        radeon_emit(cs, value);
1021
 
}
1022
 
 
1023
 
/*
1024
 
 * common helpers
1025
 
 */
1026
 
 
1027
 
/* 12.4 fixed-point */
1028
 
static inline unsigned r600_pack_float_12p4(float x)
1029
 
{
1030
 
        return x <= 0    ? 0 :
1031
 
               x >= 4096 ? 0xffff : x * 16;
1032
 
}
1033
 
 
1034
 
static inline unsigned r600_get_flush_flags(enum r600_coherency coher)
1035
 
{
1036
 
        switch (coher) {
1037
 
        default:
1038
 
        case R600_COHERENCY_NONE:
1039
 
                return 0;
1040
 
        case R600_COHERENCY_SHADER:
1041
 
                return R600_CONTEXT_INV_CONST_CACHE |
1042
 
                       R600_CONTEXT_INV_VERTEX_CACHE |
1043
 
                       R600_CONTEXT_INV_TEX_CACHE |
1044
 
                       R600_CONTEXT_STREAMOUT_FLUSH;
1045
 
        case R600_COHERENCY_CB_META:
1046
 
                return R600_CONTEXT_FLUSH_AND_INV_CB |
1047
 
                       R600_CONTEXT_FLUSH_AND_INV_CB_META;
1048
 
        }
1049
 
}
1050
 
 
1051
 
#define     V_028A6C_OUTPRIM_TYPE_POINTLIST            0
1052
 
#define     V_028A6C_OUTPRIM_TYPE_LINESTRIP            1
1053
 
#define     V_028A6C_OUTPRIM_TYPE_TRISTRIP             2
1054
 
 
1055
 
unsigned r600_conv_prim_to_gs_out(unsigned mode);
1056
 
 
1057
 
void eg_trace_emit(struct r600_context *rctx);
1058
 
void eg_dump_debug_state(struct pipe_context *ctx, FILE *f,
1059
 
                         unsigned flags);
1060
 
 
1061
 
struct r600_pipe_shader_selector *r600_create_shader_state_tokens(struct pipe_context *ctx,
1062
 
                                                                  const void *tokens,
1063
 
                                                                  enum pipe_shader_ir,
1064
 
                                                                  unsigned pipe_shader_type);
1065
 
int r600_shader_select(struct pipe_context *ctx,
1066
 
                       struct r600_pipe_shader_selector* sel,
1067
 
                       bool *dirty, bool precompile);
1068
 
 
1069
 
void r600_delete_shader_selector(struct pipe_context *ctx,
1070
 
                                 struct r600_pipe_shader_selector *sel);
1071
 
 
1072
 
struct r600_shader_atomic;
1073
 
void evergreen_emit_atomic_buffer_setup_count(struct r600_context *rctx,
1074
 
                                              struct r600_pipe_shader *cs_shader,
1075
 
                                              struct r600_shader_atomic *combined_atomics,
1076
 
                                              uint8_t *atomic_used_mask_p);
1077
 
void evergreen_emit_atomic_buffer_setup(struct r600_context *rctx,
1078
 
                                        bool is_compute,
1079
 
                                        struct r600_shader_atomic *combined_atomics,
1080
 
                                        uint8_t atomic_used_mask);
1081
 
void evergreen_emit_atomic_buffer_save(struct r600_context *rctx,
1082
 
                                       bool is_compute,
1083
 
                                       struct r600_shader_atomic *combined_atomics,
1084
 
                                       uint8_t *atomic_used_mask_p);
1085
 
void r600_update_compressed_resource_state(struct r600_context *rctx, bool compute_only);
1086
 
 
1087
 
void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type);
1088
 
void r600_update_driver_const_buffers(struct r600_context *rctx, bool compute_only);
1089
 
#endif