1aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson/*
2aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson *
4aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * Permission is hereby granted, free of charge, to any person obtaining a
5aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * copy of this software and associated documentation files (the "Software"),
6aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * to deal in the Software without restriction, including without limitation
7aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * on the rights to use, copy, modify, merge, publish, distribute, sub
8aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * license, and/or sell copies of the Software, and to permit persons to whom
9aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * the Software is furnished to do so, subject to the following conditions:
10aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson *
11aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * The above copyright notice and this permission notice (including the next
12aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * paragraph) shall be included in all copies or substantial portions of the
13aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * Software.
14aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson *
15aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson
23aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson#ifndef R300_CONTEXT_H
24aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson#define R300_CONTEXT_H
25aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson
26e511110b71a7ea19c531d707080813d9d432341cCorbin Simpson#include "draw/draw_vertex.h"
27a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson
2838a97148bf5df3c32087a5fdd799912d0275267dMarek Olšák#include "util/u_blitter.h"
2938a97148bf5df3c32087a5fdd799912d0275267dMarek Olšák
303b37cb49b821dd0c59fd5361ada6c0df9ac07db8Corbin Simpson#include "pipe/p_context.h"
3128486880ca3ec39419ccee0cb1a3bedc9ef7117cJosé Fonseca#include "util/u_inlines.h"
32287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "util/u_transfer.h"
33028459b0bf2bb778b55493f9b23ab7f2c9b355a0Marek Olšák
34d0d3abd360a0d98302841e62ab9acdebea2ca8c2Marek Olšák#include "r300_defines.h"
3508edbe9f14712f719f838769c61123f83768af76Marek Olšák#include "r300_screen.h"
36d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák#include "../../winsys/radeon/drm/radeon_winsys.h"
3708edbe9f14712f719f838769c61123f83768af76Marek Olšák
3868e58a96e80865878e6881dc4d34fcc3ec24eb19Dave Airliestruct u_upload_mgr;
39d496399156a7d9a683999e41f126232f89375f2bCorbin Simpsonstruct r300_context;
40d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnlestruct r300_fragment_shader;
41188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestruct r300_vertex_shader;
4276034aaf655134c71e1ec619085c46251d037720Marek Olšákstruct r300_stencilref_context;
43188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle
44e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšákenum colormask_swizzle {
45e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_BGRA,
46e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_RGBA,
47e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_RRRR,
48e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_AAAA,
49e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_GRRG,
50e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_ARRA,
51e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    COLORMASK_NUM_SWIZZLES
52e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák};
53e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák
54d496399156a7d9a683999e41f126232f89375f2bCorbin Simpsonstruct r300_atom {
55aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    /* Name, for debugging. */
56aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    const char* name;
57aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    /* Opaque state. */
58d496399156a7d9a683999e41f126232f89375f2bCorbin Simpson    void* state;
59aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    /* Emit the state to the context. */
60841122d0e8025290ff2691e13ade1099d2c3351cMarek Olšák    void (*emit)(struct r300_context*, unsigned, void*);
61aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    /* Upper bound on number of dwords to emit. */
62aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    unsigned size;
63aeb34b248903f98559209db4f095d1096ecb580aCorbin Simpson    /* Whether this atom should be emitted. */
64d496399156a7d9a683999e41f126232f89375f2bCorbin Simpson    boolean dirty;
6595ba021105a2f1a29c8a4f51641c7a0b527226beMarek Olšák    /* Whether this atom may be emitted with state == NULL. */
6695ba021105a2f1a29c8a4f51641c7a0b527226beMarek Olšák    boolean allow_null_state;
67d496399156a7d9a683999e41f126232f89375f2bCorbin Simpson};
68d496399156a7d9a683999e41f126232f89375f2bCorbin Simpson
6969adebf5945d994485c584c183c148fc2c1373edMarek Olšákstruct r300_aa_state {
7069adebf5945d994485c584c183c148fc2c1373edMarek Olšák    struct r300_surface *dest;
7169adebf5945d994485c584c183c148fc2c1373edMarek Olšák
7269adebf5945d994485c584c183c148fc2c1373edMarek Olšák    uint32_t aa_config;
7369adebf5945d994485c584c183c148fc2c1373edMarek Olšák    uint32_t aaresolve_ctl;
7469adebf5945d994485c584c183c148fc2c1373edMarek Olšák};
7569adebf5945d994485c584c183c148fc2c1373edMarek Olšák
7674288078eab1971cc6ce3ae00fa55eb917b5826aCorbin Simpsonstruct r300_blend_state {
774b92c688a45480027390764b06077105298666c3Marek Olšák    struct pipe_blend_state state;
784b92c688a45480027390764b06077105298666c3Marek Olšák
79e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    uint32_t cb_clamp[COLORMASK_NUM_SWIZZLES][8];
8023ccab39cd6b89efd8be238c3061e7ddb3697a55Marek Olšák    uint32_t cb_noclamp[8];
81cd891648d45189555bace1bca6b7cddef5857f02Marek Olšák    uint32_t cb_no_readwrite[8];
8274288078eab1971cc6ce3ae00fa55eb917b5826aCorbin Simpson};
8374288078eab1971cc6ce3ae00fa55eb917b5826aCorbin Simpson
84f3b53a5cb6a04b86ccd75cc38c73c8e3dd117894Corbin Simpsonstruct r300_blend_color_state {
85910bac63dfc5c6d9bf7162388c951784eba534f6Marek Olšák    struct pipe_blend_color state;
869dd50993c6540729fe7c7397b4a947b3068db162Marek Olšák    uint32_t cb[3];
87f3b53a5cb6a04b86ccd75cc38c73c8e3dd117894Corbin Simpson};
88f3b53a5cb6a04b86ccd75cc38c73c8e3dd117894Corbin Simpson
89f8032116293a1faf4dd76f2cbc10a455b8cde6d7Marek Olšákstruct r300_clip_state {
90f8032116293a1faf4dd76f2cbc10a455b8cde6d7Marek Olšák    uint32_t cb[29];
91f8032116293a1faf4dd76f2cbc10a455b8cde6d7Marek Olšák};
92f8032116293a1faf4dd76f2cbc10a455b8cde6d7Marek Olšák
93bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpsonstruct r300_dsa_state {
94371ca689ec5d1d7f301f4a3176c4e0df1c44ec15Marek Olšák    struct pipe_depth_stencil_alpha_state dsa;
95371ca689ec5d1d7f301f4a3176c4e0df1c44ec15Marek Olšák
960a44efaeb91c7cef9b244ae86c4977b019a63c54Marek Olšák    /* This is actually a command buffer with named dwords. */
970a44efaeb91c7cef9b244ae86c4977b019a63c54Marek Olšák    uint32_t cb_begin;
98bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpson    uint32_t alpha_function;    /* R300_FG_ALPHA_FUNC: 0x4bd4 */
990a44efaeb91c7cef9b244ae86c4977b019a63c54Marek Olšák    uint32_t cb_reg_seq;
100bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpson    uint32_t z_buffer_control;  /* R300_ZB_CNTL: 0x4f00 */
101bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpson    uint32_t z_stencil_control; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */
102bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpson    uint32_t stencil_ref_mask;  /* R300_ZB_STENCILREFMASK: 0x4f08 */
1030a44efaeb91c7cef9b244ae86c4977b019a63c54Marek Olšák    uint32_t cb_reg;
1047961974fc28257b293961d35f15c0ce7a85f2669Corbin Simpson    uint32_t stencil_ref_bf;    /* R500_ZB_STENCILREFMASK_BF: 0x4fd4 */
10510a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_reg1;
10610a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t alpha_value;       /* R500_FG_ALPHA_VALUE: 0x4be0 */
10710a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák
10810a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    /* The same, but for FP16 alpha test. */
10910a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_begin_fp16;
11010a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t alpha_function_fp16;    /* R300_FG_ALPHA_FUNC: 0x4bd4 */
11110a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_reg_seq_fp16;
11210a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t z_buffer_control_fp16;  /* R300_ZB_CNTL: 0x4f00 */
11310a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t z_stencil_control_fp16; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */
11410a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t stencil_ref_mask_fp16;  /* R300_ZB_STENCILREFMASK: 0x4f08 */
11510a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_reg_fp16;
11610a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t stencil_ref_bf_fp16;    /* R500_ZB_STENCILREFMASK_BF: 0x4fd4 */
11710a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_reg1_fp16;
11810a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t alpha_value_fp16;       /* R500_FG_ALPHA_VALUE: 0x4be0 */
119a955f86b31304a1a0f35faa0e0861e920354e23bMarek Olšák
1200a44efaeb91c7cef9b244ae86c4977b019a63c54Marek Olšák    /* The second command buffer disables zbuffer reads and writes. */
12110a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_zb_no_readwrite[10];
12210a893106be9dc4c843100468d8575b07ba6c4b9Marek Olšák    uint32_t cb_fp16_zb_no_readwrite[10];
1230a44efaeb91c7cef9b244ae86c4977b019a63c54Marek Olšák
124a955f86b31304a1a0f35faa0e0861e920354e23bMarek Olšák    /* Whether a two-sided stencil is enabled. */
125a955f86b31304a1a0f35faa0e0861e920354e23bMarek Olšák    boolean two_sided;
126a955f86b31304a1a0f35faa0e0861e920354e23bMarek Olšák    /* Whether a fallback should be used for a two-sided stencil ref value. */
12776034aaf655134c71e1ec619085c46251d037720Marek Olšák    boolean two_sided_stencil_ref;
128bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpson};
129bbb1c6f6298fcb1125a8170f22646f326b0ca74cCorbin Simpson
1300a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšákstruct r300_hyperz_state {
1316eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    int flush;
1320a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    /* This is actually a command buffer with named dwords. */
1336eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    uint32_t cb_flush_begin;
1346eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    uint32_t zb_zcache_ctlstat;     /* R300_ZB_CACHE_CNTL */
1350a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    uint32_t cb_begin;
1360a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    uint32_t zb_bw_cntl;            /* R300_ZB_BW_CNTL */
1370a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    uint32_t cb_reg1;
1380a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    uint32_t zb_depthclearvalue;    /* R300_ZB_DEPTHCLEARVALUE */
1390a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    uint32_t cb_reg2;
1400a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák    uint32_t sc_hyperz;             /* R300_SC_HYPERZ */
1416eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    uint32_t cb_reg3;
1426eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    uint32_t gb_z_peq_config;       /* R300_GB_Z_PEQ_CONFIG: 0x4028 */
1430a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák};
1440a19d57b845b269601c862193ed801b19aa4c2f1Marek Olšák
14593bce03b275f66b6b2db410bbef38954de6a617cMarek Olšákstruct r300_gpu_flush {
14693bce03b275f66b6b2db410bbef38954de6a617cMarek Olšák    uint32_t cb_flush_clean[6];
14793bce03b275f66b6b2db410bbef38954de6a617cMarek Olšák};
14893bce03b275f66b6b2db410bbef38954de6a617cMarek Olšák
149dc4c821f0817a3db716f965692fb701079f66340Marek Olšák#define RS_STATE_MAIN_SIZE 27
15081b7de5bf039ecefe104f9892e2bdeaee71e40c6Dave Airlie
151a08a830fd3c22bdbad1ee840e4e56302152375f1Corbin Simpsonstruct r300_rs_state {
15287547ac70ce0f8696d16336177003f881c9ee836Marek Olšák    /* Original rasterizer state. */
1531bb2fb498ee65ba29aa4098983116be3d81cc2daCorbin Simpson    struct pipe_rasterizer_state rs;
15487547ac70ce0f8696d16336177003f881c9ee836Marek Olšák    /* Draw-specific rasterizer state. */
15587547ac70ce0f8696d16336177003f881c9ee836Marek Olšák    struct pipe_rasterizer_state rs_draw;
1561bb2fb498ee65ba29aa4098983116be3d81cc2daCorbin Simpson
1570a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    /* Command buffers. */
15881b7de5bf039ecefe104f9892e2bdeaee71e40c6Dave Airlie    uint32_t cb_main[RS_STATE_MAIN_SIZE];
1590a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    uint32_t cb_poly_offset_zb16[5];
1600a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    uint32_t cb_poly_offset_zb24[5];
1610a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák
1620a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    /* The index to cb_main where the cull_mode register value resides. */
1630a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    unsigned cull_mode_index;
1640a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák
1650a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    /* Whether polygon offset is enabled. */
1660a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    boolean polygon_offset_enable;
1670a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák
1680a9510814e2dfff57f7d73cc68aece0554ad794dMarek Olšák    /* This is emitted in the draw function. */
16917331a77f6480183ad0f43173f77d6c73cc377ffCorbin Simpson    uint32_t color_control;         /* R300_GA_COLOR_CONTROL: 0x4278 */
170a08a830fd3c22bdbad1ee840e4e56302152375f1Corbin Simpson};
171a08a830fd3c22bdbad1ee840e4e56302152375f1Corbin Simpson
172c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpsonstruct r300_rs_block {
17368e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák    uint32_t vap_vtx_state_cntl;  /* R300_VAP_VTX_STATE_CNTL: 0x2180 */
17468e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák    uint32_t vap_vsm_vtx_assm;    /* R300_VAP_VSM_VTX_ASSM: 0x2184 */
17568e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák    uint32_t vap_out_vtx_fmt[2];  /* R300_VAP_OUTPUT_VTX_FMT_[0-1]: 0x2090 */
17681b7de5bf039ecefe104f9892e2bdeaee71e40c6Dave Airlie    uint32_t gb_enable;
17768e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák
178c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpson    uint32_t ip[8]; /* R300_RS_IP_[0-7], R500_RS_IP_[0-7] */
179c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpson    uint32_t count; /* R300_RS_COUNT */
180c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpson    uint32_t inst_count; /* R300_RS_INST_COUNT */
181c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpson    uint32_t inst[8]; /* R300_RS_INST_[0-7] */
182c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpson};
183c28298855bf5d5ef790d28bac2e77700625fa69aCorbin Simpson
18490a96cb2addf48b3b48c039a8dc6de9e53bfb6dfCorbin Simpsonstruct r300_sampler_state {
1856ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák    struct pipe_sampler_state state;
1866ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák
1872f37387786f1d0d6beded5afc29d36f744f1c948Corbin Simpson    uint32_t filter0;      /* R300_TX_FILTER0: 0x4400 */
1882f37387786f1d0d6beded5afc29d36f744f1c948Corbin Simpson    uint32_t filter1;      /* R300_TX_FILTER1: 0x4440 */
189b7078a88119e248b0196f7446abe029c22f1ee28Marek Olšák
190b7078a88119e248b0196f7446abe029c22f1ee28Marek Olšák    /* Min/max LOD must be clamped to [0, last_level], thus
191b7078a88119e248b0196f7446abe029c22f1ee28Marek Olšák     * it's dependent on a currently bound texture */
192b7078a88119e248b0196f7446abe029c22f1ee28Marek Olšák    unsigned min_lod, max_lod;
19390a96cb2addf48b3b48c039a8dc6de9e53bfb6dfCorbin Simpson};
19490a96cb2addf48b3b48c039a8dc6de9e53bfb6dfCorbin Simpson
195d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšákstruct r300_texture_format_state {
1969d9e0815be41fa72ff5df6752b02551b648b33b6Corbin Simpson    uint32_t format0; /* R300_TX_FORMAT0: 0x4480 */
1979d9e0815be41fa72ff5df6752b02551b648b33b6Corbin Simpson    uint32_t format1; /* R300_TX_FORMAT1: 0x44c0 */
1989d9e0815be41fa72ff5df6752b02551b648b33b6Corbin Simpson    uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */
1991c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    uint32_t tile_config; /* R300_TX_OFFSET (subset thereof) */
20010ea8567f49f4daaa654b6e4c365a816f855073bMarek Olšák    uint32_t us_format0;   /* R500_US_FORMAT0_0: 0x4640 (through 15) */
2011c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák};
2021c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák
2031c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšákstruct r300_sampler_view {
2041c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    struct pipe_sampler_view base;
2051c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák
206ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák    /* For resource_copy_region. */
207ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák    unsigned width0_override;
208ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák    unsigned height0_override;
209ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák
21071584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák    /* Swizzles in the UTIL_FORMAT_SWIZZLE_* representation,
21171584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák     * derived from base. */
21271584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák    unsigned char swizzle[4];
21371584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák
2141c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    /* Copy of r300_texture::texture_format_state with format-specific bits
2151c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák     * added. */
2161c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    struct r300_texture_format_state format;
217e8f2adf8e3f381176703bf8bf4e927c8ce6bc891Marek Olšák
218e8f2adf8e3f381176703bf8bf4e927c8ce6bc891Marek Olšák    /* The texture cache region for this texture. */
219e8f2adf8e3f381176703bf8bf4e927c8ce6bc891Marek Olšák    uint32_t texcache_region;
2201a503019d73701ed311b15107f314bc84968bdb7Corbin Simpson};
2211a503019d73701ed311b15107f314bc84968bdb7Corbin Simpson
22271584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšákstruct r300_texture_sampler_state {
22371584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák    struct r300_texture_format_state format;
22471584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák    uint32_t filter0;      /* R300_TX_FILTER0: 0x4400 */
22571584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák    uint32_t filter1;      /* R300_TX_FILTER1: 0x4440 */
22610ea8567f49f4daaa654b6e4c365a816f855073bMarek Olšák    uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */
22771584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák};
22871584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák
229d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšákstruct r300_textures_state {
230d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák    /* Textures. */
2311c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    struct r300_sampler_view *sampler_views[16];
2321c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    int sampler_view_count;
233d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák    /* Sampler states. */
234d2686cdb2354b7cfe0e4eac3c5afab40cb947e0fMarek Olšák    struct r300_sampler_state *sampler_states[16];
2351c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    int sampler_state_count;
236d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák
2371c356ac95b6df0962dbd15311ff7e0ea172e1aeaMarek Olšák    /* This is the merge of the texture and sampler states. */
238d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák    unsigned count;
239d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák    uint32_t tx_enable;         /* R300_TX_ENABLE: 0x4101 */
24071584d0cc75dda3c579a2a0cb6c1ac9591f7d5c9Marek Olšák    struct r300_texture_sampler_state regs[16];
241d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák};
242d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4Marek Olšák
243942762cd973af0df75040de21d3321cd19829e70Marek Olšákstruct r300_vertex_stream_state {
244942762cd973af0df75040de21d3321cd19829e70Marek Olšák    /* R300_VAP_PROG_STREAK_CNTL_[0-7] */
245942762cd973af0df75040de21d3321cd19829e70Marek Olšák    uint32_t vap_prog_stream_cntl[8];
246942762cd973af0df75040de21d3321cd19829e70Marek Olšák    /* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */
247942762cd973af0df75040de21d3321cd19829e70Marek Olšák    uint32_t vap_prog_stream_cntl_ext[8];
248942762cd973af0df75040de21d3321cd19829e70Marek Olšák
249942762cd973af0df75040de21d3321cd19829e70Marek Olšák    unsigned count;
250942762cd973af0df75040de21d3321cd19829e70Marek Olšák};
251942762cd973af0df75040de21d3321cd19829e70Marek Olšák
252bb47d1c26fa000735bd06751ba00a98354c921b7Marek Olšákstruct r300_invariant_state {
253bdb811772fe1b11e32172b211d9935d37093c753Marek Olšák    uint32_t cb[24];
254bb47d1c26fa000735bd06751ba00a98354c921b7Marek Olšák};
255bb47d1c26fa000735bd06751ba00a98354c921b7Marek Olšák
256fcacc6a076ee5bc894eb7f5a7943715ff1ddf9eeMarek Olšákstruct r300_vap_invariant_state {
257952222e4bfa957ec386e85909097c178829b6fd1Marek Olšák    uint32_t cb[11];
258fcacc6a076ee5bc894eb7f5a7943715ff1ddf9eeMarek Olšák};
259fcacc6a076ee5bc894eb7f5a7943715ff1ddf9eeMarek Olšák
2603a648d0cf23c39a139e4638c2194e4ce97c1d983Corbin Simpsonstruct r300_viewport_state {
261db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    float xscale;         /* R300_VAP_VPORT_XSCALE:  0x2098 */
262db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    float xoffset;        /* R300_VAP_VPORT_XOFFSET: 0x209c */
263db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    float yscale;         /* R300_VAP_VPORT_YSCALE:  0x20a0 */
264db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    float yoffset;        /* R300_VAP_VPORT_YOFFSET: 0x20a4 */
265db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    float zscale;         /* R300_VAP_VPORT_ZSCALE:  0x20a8 */
266db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    float zoffset;        /* R300_VAP_VPORT_ZOFFSET: 0x20ac */
267db83ee16474a7d9b23eacd7933366c5b320255a5Corbin Simpson    uint32_t vte_control; /* R300_VAP_VTE_CNTL:      0x20b0 */
2683a648d0cf23c39a139e4638c2194e4ce97c1d983Corbin Simpson};
2693a648d0cf23c39a139e4638c2194e4ce97c1d983Corbin Simpson
270a82fc97c643c4309a10cfefb108c4c0f11a2e55aCorbin Simpsonstruct r300_ztop_state {
271a82fc97c643c4309a10cfefb108c4c0f11a2e55aCorbin Simpson    uint32_t z_buffer_top;      /* R300_ZB_ZTOP: 0x4f14 */
272a82fc97c643c4309a10cfefb108c4c0f11a2e55aCorbin Simpson};
273a82fc97c643c4309a10cfefb108c4c0f11a2e55aCorbin Simpson
274fb8b794c69330924ad15083237b1a8a35eb62e31Corbin Simpson/* The next several objects are not pure Radeon state; they inherit from
275fb8b794c69330924ad15083237b1a8a35eb62e31Corbin Simpson * various Gallium classes. */
276fb8b794c69330924ad15083237b1a8a35eb62e31Corbin Simpson
2771b77138a1effe2e18a9ce9e16c43852ff855a7beCorbin Simpsonstruct r300_constant_buffer {
2781b77138a1effe2e18a9ce9e16c43852ff855a7beCorbin Simpson    /* Buffer of constants */
2793eb557778376bcbbc6f25da88ffbaa269607254cMarek Olšák    uint32_t *ptr;
280abae06ac85349a30996257f29f9c52c3f687d35dMarek Olšák    /* Remapping table. */
281abae06ac85349a30996257f29f9c52c3f687d35dMarek Olšák    unsigned *remap_table;
282c1365606c5b89872af4a0931e20f5cb78875eea6Dave Airlie    /* const buffer base */
283c1365606c5b89872af4a0931e20f5cb78875eea6Dave Airlie    uint32_t buffer_base;
2841b77138a1effe2e18a9ce9e16c43852ff855a7beCorbin Simpson};
2851b77138a1effe2e18a9ce9e16c43852ff855a7beCorbin Simpson
286a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson/* Query object.
287a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson *
288a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson * This is not a subclass of pipe_query because pipe_query is never
289a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson * actually fully defined. So, rather than have it as a member, and do
290a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson * subclass-style casting, we treat pipe_query as an opaque, and just
291a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson * trust that our state tracker does not ever mess up query objects.
292a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson */
293a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpsonstruct r300_query {
294a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson    /* The kind of query. Currently only OQ is supported. */
295a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson    unsigned type;
296cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    /* The number of pipes where query results are stored. */
297cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    unsigned num_pipes;
298cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    /* How many results have been written, in dwords. It's incremented
299cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák     * after end_query and flush. */
300cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    unsigned num_results;
30151d1cf55da6f8b8a215814589a189b6e5e537fe5Dave Airlie    /* if begin has been emitted */
30251d1cf55da6f8b8a215814589a189b6e5e537fe5Dave Airlie    boolean begin_emitted;
303cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák
304cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    /* The buffer where query results are stored. */
305d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct pb_buffer *buf;
306d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct radeon_winsys_cs_handle *cs_buf;
307a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson};
308a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson
3098874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšákstruct r300_surface {
3108874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák    struct pipe_surface base;
3118874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák
3128874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák    /* Winsys buffer backing the texture. */
313d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct pb_buffer *buf;
314d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct radeon_winsys_cs_handle *cs_buf;
3158874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák
31693f4e3cb6c1ca303ee1f5c2a2491a8eff33f2633Marek Olšák    enum radeon_bo_domain domain;
31793f4e3cb6c1ca303ee1f5c2a2491a8eff33f2633Marek Olšák
318f9e8cdc145fc0ba1f6c47e20860add6528387c7cMarek Olšák    uint32_t offset;    /* COLOROFFSET or DEPTHOFFSET. */
3198874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák    uint32_t pitch;     /* COLORPITCH or DEPTHPITCH. */
320d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    uint32_t pitch_zmask; /* ZMASK_PITCH */
321d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    uint32_t pitch_hiz;   /* HIZ_PITCH */
322f9e8cdc145fc0ba1f6c47e20860add6528387c7cMarek Olšák    uint32_t format;    /* US_OUT_FMT or ZB_FORMAT. */
3238c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák
3248c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    /* Parameters dedicated to the CBZB clear. */
3258c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    uint32_t cbzb_width;            /* Aligned width. */
3268c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    uint32_t cbzb_height;           /* Half of the height. */
3278c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    uint32_t cbzb_midpoint_offset;  /* DEPTHOFFSET. */
3288c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    uint32_t cbzb_pitch;            /* DEPTHPITCH. */
3298c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    uint32_t cbzb_format;           /* ZB_FORMAT. */
330d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák
331d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    /* Whether the CBZB clear is allowed on the surface. */
332d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    boolean cbzb_allowed;
333e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák
334e81717e9e7c46eed05f9a29adaaf4c86306a8920Marek Olšák    unsigned colormask_swizzle;
3358874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák};
3368874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák
337d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšákstruct r300_texture_desc {
33813359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák    /* Width, height, and depth.
33913359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák     * Most of the time, these are equal to pipe_texture::width0, height0,
34013359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák     * and depth0. However, NPOT 3D textures must have dimensions aligned
34113359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák     * to POT, and this is the only case when these variables differ from
34213359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák     * pipe_texture. */
34313359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák    unsigned width0, height0, depth0;
34413359e6a4b732335cdd8da48276960d0b176ffe3Marek Olšák
345d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    /* Buffer tiling.
346d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák     * Macrotiling is specified per-level because small mipmaps cannot
347d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák     * be macrotiled. */
348d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    enum radeon_bo_layout microtile;
349d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    enum radeon_bo_layout macrotile[R300_MAX_TEXTURE_LEVELS];
350b6b76cbb20b3d9467011231069e23972b98afa49Marek Olšák
3518e11e0121466efa34cfc14d299b43455a30b198cCorbin Simpson    /* Offsets into the buffer. */
352d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    unsigned offset_in_bytes[R300_MAX_TEXTURE_LEVELS];
3538e11e0121466efa34cfc14d299b43455a30b198cCorbin Simpson
354d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    /* Strides for each mip-level. */
355d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    unsigned stride_in_bytes[R300_MAX_TEXTURE_LEVELS];
35663c9450ae776ff4207422442dd8c3d9d13a05e7aMarek Olšák
357d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    /* Size of one zslice or face or 2D image based on the texture target. */
358d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    unsigned layer_size_in_bytes[R300_MAX_TEXTURE_LEVELS];
3599dd06b8da45aa8100d61a09fc93c1bdfc16e9df8Marek Olšák
360d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    /* Total size of this texture, in bytes,
361d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák     * derived from the texture properties. */
362d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    unsigned size_in_bytes;
363118dfe16887d1ec4d3b96d49b76fffa0d2924132Marek Olšák
3643cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle    /**
3653cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     * If non-zero, override the natural texture layout with
3663cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     * a custom stride (in bytes).
3673cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     *
3683cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     * \note Mipmapping fails for textures with a non-natural layout!
3693cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     *
3703cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     * \sa r300_texture_get_stride
3713cb30e55e48d86aa5f660e670e055d6b258ea54aNicolai Hähnle     */
372d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    unsigned stride_in_bytes_override;
373065e3f7ff2a9b6170e51b0104036088e8d163ea0Marek Olšák
37449330fc5ac13e25cb201e62995329cffaf5046f0Marek Olšák    /* Whether this texture has non-power-of-two dimensions.
37549330fc5ac13e25cb201e62995329cffaf5046f0Marek Olšák     * It can be either a regular texture or a rectangle one. */
37649330fc5ac13e25cb201e62995329cffaf5046f0Marek Olšák    boolean is_npot;
37749330fc5ac13e25cb201e62995329cffaf5046f0Marek Olšák
37849330fc5ac13e25cb201e62995329cffaf5046f0Marek Olšák    /* This flag says that hardware must use the stride for addressing
37949330fc5ac13e25cb201e62995329cffaf5046f0Marek Olšák     * instead of the width. */
380d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    boolean uses_stride_addressing;
381d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák
382d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    /* Whether CBZB fast color clear is allowed on the miplevel. */
383d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák    boolean cbzb_allowed[R300_MAX_TEXTURE_LEVELS];
3842050f2ab96f923112d3475a655b31c8f5145a800Marek Olšák
3852050f2ab96f923112d3475a655b31c8f5145a800Marek Olšák    /* Zbuffer compression info for each miplevel. */
3862050f2ab96f923112d3475a655b31c8f5145a800Marek Olšák    boolean zcomp8x8[R300_MAX_TEXTURE_LEVELS];
387d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    /* If zero, then disable Z compression/HiZ. */
3882050f2ab96f923112d3475a655b31c8f5145a800Marek Olšák    unsigned zmask_dwords[R300_MAX_TEXTURE_LEVELS];
389d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    unsigned hiz_dwords[R300_MAX_TEXTURE_LEVELS];
390d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    /* Zmask/HiZ strides for each miplevel. */
391d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    unsigned zmask_stride_in_pixels[R300_MAX_TEXTURE_LEVELS];
392d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    unsigned hiz_stride_in_pixels[R300_MAX_TEXTURE_LEVELS];
393d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák};
394d779a5d16ae6a17b3fc0c097f4eb477a80e54566Marek Olšák
39556ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšákstruct r300_resource
39656ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák{
397a52b3338c6e51421e3836ae210cd98d9c1ec337bMarek Olšák    struct u_resource b;
39863c9450ae776ff4207422442dd8c3d9d13a05e7aMarek Olšák
39956ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák    /* Winsys buffer backing this resource. */
400d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct pb_buffer *buf;
401d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct radeon_winsys_cs_handle *cs_buf;
40293f4e3cb6c1ca303ee1f5c2a2491a8eff33f2633Marek Olšák    enum radeon_bo_domain domain;
40356ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák
40421b012d3b022c1c55358226f7bcc52fe50078123Marek Olšák    /* Constant buffers and SWTCL vertex and index buffers are in user
40521b012d3b022c1c55358226f7bcc52fe50078123Marek Olšák     * memory. */
40621b012d3b022c1c55358226f7bcc52fe50078123Marek Olšák    uint8_t *malloced_buffer;
40756ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák
40856ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák    /* Texture description (addressing, layout, special features). */
40956ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák    struct r300_texture_desc tex;
4109d9e0815be41fa72ff5df6752b02551b648b33b6Corbin Simpson
4116a34287bb5147a3213e94d88c97db4ec403509aeMarek Olšák    /* This is the level tiling flags were last time set for.
4126a34287bb5147a3213e94d88c97db4ec403509aeMarek Olšák     * It's used to prevent redundant tiling-flags changes from happening.*/
4136a34287bb5147a3213e94d88c97db4ec403509aeMarek Olšák    unsigned surface_level;
4148e11e0121466efa34cfc14d299b43455a30b198cCorbin Simpson};
4158e11e0121466efa34cfc14d299b43455a30b198cCorbin Simpson
416141c7cb0d6078b3a2832c4be03ddcf25e35e596bCorbin Simpsonstruct r300_vertex_element_state {
417e9441e1f88cc07365f4d7d9149ccefe128809645Roland Scheidegger    unsigned count;
4184240987cecdaaaeb2d6188f7c83ff4cb8e670c59Corbin Simpson    struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
419c95bc1224a4b20b9470ddcb37b5f78975991073bMarek Olšák    unsigned format_size[PIPE_MAX_ATTRIBS];
420141c7cb0d6078b3a2832c4be03ddcf25e35e596bCorbin Simpson
421eb7ef433bbbeabda963e74adf0ef61c47883f292Marek Olšák    /* The size of the vertex, in dwords. */
422eb7ef433bbbeabda963e74adf0ef61c47883f292Marek Olšák    unsigned vertex_size_dwords;
423eb7ef433bbbeabda963e74adf0ef61c47883f292Marek Olšák
424141c7cb0d6078b3a2832c4be03ddcf25e35e596bCorbin Simpson    struct r300_vertex_stream_state vertex_stream;
425e9441e1f88cc07365f4d7d9149ccefe128809645Roland Scheidegger};
426e9441e1f88cc07365f4d7d9149ccefe128809645Roland Scheidegger
427ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšákenum r300_hiz_func {
428ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák    HIZ_FUNC_NONE,
429ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák
430ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák    /* The function, when determined, is set in stone
431ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák     * until the next HiZ clear. */
432ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák
433ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák    /* MAX is written to the HiZ buffer.
434ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák     * Used for LESS, LEQUAL. */
435ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák    HIZ_FUNC_MAX,
436ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák
437ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák    /* MIN is written to the HiZ buffer.
438ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák     * Used for GREATER, GEQUAL. */
439ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák    HIZ_FUNC_MIN,
440ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák};
441ebf69f2c508e2cb6df1437ef0e31cbc8b808824dMarek Olšák
4424af3fe857dc07923af8786b434dee32d493b577eMarek Olšák/* For deferred fragment shader state validation. */
4434af3fe857dc07923af8786b434dee32d493b577eMarek Olšákenum r300_fs_validity_status {
4444af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    FRAGMENT_SHADER_VALID,      /* No need to change/validate the FS. */
4454af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    FRAGMENT_SHADER_MAYBE_DIRTY,/* Validate the FS if external state was changed. */
4464af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    FRAGMENT_SHADER_DIRTY       /* Always validate the FS (if the FS was changed) */
4474af3fe857dc07923af8786b434dee32d493b577eMarek Olšák};
4484af3fe857dc07923af8786b434dee32d493b577eMarek Olšák
4493e09a07a265d5ee75b110954d160a73d83793c40Corbin Simpsonstruct r300_context {
4503e09a07a265d5ee75b110954d160a73d83793c40Corbin Simpson    /* Parent class */
4513e09a07a265d5ee75b110954d160a73d83793c40Corbin Simpson    struct pipe_context context;
4523e09a07a265d5ee75b110954d160a73d83793c40Corbin Simpson
453fbeeb6675733f5b2da36d40b0142dadf8cc953b4Corbin Simpson    /* The interface to the windowing system, etc. */
454d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct radeon_winsys *rws;
455fe3caa91d3f637bf9cf9f9e7adb992aa8c7ef8e4Marek Olšák    /* The command stream. */
456d35aeff4bb0b03450b2c3c08bd7f84db5bf43283Marek Olšák    struct radeon_winsys_cs *cs;
457b71bfc4400e1d7c15a2bebbbd3b26a8770fbf546Marek Olšák    /* Screen. */
458b71bfc4400e1d7c15a2bebbbd3b26a8770fbf546Marek Olšák    struct r300_screen *screen;
4590392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák
460fbeeb6675733f5b2da36d40b0142dadf8cc953b4Corbin Simpson    /* Draw module. Used mostly for SW TCL. */
4613e09a07a265d5ee75b110954d160a73d83793c40Corbin Simpson    struct draw_context* draw;
4620392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák    /* Vertex buffer for SW TCL. */
4630392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák    struct pipe_resource* vbo;
4640392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák    /* Offset and size into the SW TCL VBO. */
4650392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák    size_t draw_vbo_offset;
466eb430b0e948caf02b9f4095d0e1435880073c2aaDave Airlie    size_t draw_vbo_size;
4670392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák    /* Whether the VBO must not be flushed. */
4680392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák    boolean draw_vbo_locked;
469d4b2de13bc652cd134826801ada48d0bb88a8258Marek Olšák    boolean draw_first_emitted;
4700392e48867c27f2aa445c5c9b35f4a52ecef2f2dMarek Olšák
47138a97148bf5df3c32087a5fdd799912d0275267dMarek Olšák    /* Accelerated blit support. */
47238a97148bf5df3c32087a5fdd799912d0275267dMarek Olšák    struct blitter_context* blitter;
47376034aaf655134c71e1ec619085c46251d037720Marek Olšák    /* Stencil two-sided reference value fallback. */
47476034aaf655134c71e1ec619085c46251d037720Marek Olšák    struct r300_stencilref_context *stencilref_fallback;
47574288078eab1971cc6ce3ae00fa55eb917b5826aCorbin Simpson
476d82f6253331abf09ca714b844b1a9179ed8050b3Marek Olšák    /* The KIL opcode needs the first texture unit to be enabled
477d82f6253331abf09ca714b844b1a9179ed8050b3Marek Olšák     * on r3xx-r4xx. In order to calm down the CS checker, we bind this
478d82f6253331abf09ca714b844b1a9179ed8050b3Marek Olšák     * dummy texture there. */
479d82f6253331abf09ca714b844b1a9179ed8050b3Marek Olšák    struct r300_sampler_view *texkill_sampler;
4804816764777485b46f360eb6f86dea243d1809221Corbin Simpson
481ffb732d8bd51f0a40379590a6485de2a56a2a306Marek Olšák    /* When no vertex buffer is set, this one is used instead to prevent
482ffb732d8bd51f0a40379590a6485de2a56a2a306Marek Olšák     * hardlocks. */
4832d03d4f4a365d7af5f4dac20700009152eba1682Marek Olšák    struct pipe_vertex_buffer dummy_vb;
484ffb732d8bd51f0a40379590a6485de2a56a2a306Marek Olšák
485cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    /* The currently active query. */
48647791697ab6eb6965f0ba8ba3f20373b3753ca2aDave Airlie    struct r300_query *query_current;
487cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    /* The saved query for blitter operations. */
488cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    struct r300_query *blitter_saved_query;
489cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák    /* Query list. */
490c1bee7bdea470b6b5dcebef9aacc8fe4feca687cDave Airlie    struct r300_query query_list;
491a381ee82663f10ff3cdcfad331258d03d4188894Corbin Simpson
49274288078eab1971cc6ce3ae00fa55eb917b5826aCorbin Simpson    /* Various CSO state objects. */
49366d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák
49466d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Each atom is emitted in the order it appears here, which can affect
49566d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák     * performance and stability if not handled with care. */
49666d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* GPU flush. */
49766d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom gpu_flush;
49869adebf5945d994485c584c183c148fc2c1373edMarek Olšák    /* Anti-aliasing (MSAA) state. */
49969adebf5945d994485c584c183c148fc2c1373edMarek Olšák    struct r300_atom aa_state;
50066d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Framebuffer state. */
50166d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom fb_state;
50266d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* HyperZ state (various SC/ZB bits). */
50366d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom hyperz_state;
50466d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* ZTOP state. */
50566d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom ztop_state;
50666d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Depth, stencil, and alpha state. */
50766d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom dsa_state;
50874288078eab1971cc6ce3ae00fa55eb917b5826aCorbin Simpson    /* Blend state. */
509d496399156a7d9a683999e41f126232f89375f2bCorbin Simpson    struct r300_atom blend_state;
510f3b53a5cb6a04b86ccd75cc38c73c8e3dd117894Corbin Simpson    /* Blend color state. */
5119d3db601c782805113e60ee7f6976184f2786427Corbin Simpson    struct r300_atom blend_color_state;
51266d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Scissor state. */
51366d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom scissor_state;
51466d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Invariant state. This must be emitted to get the engine started. */
51566d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom invariant_state;
51666d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Viewport state. */
51766d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom viewport_state;
51866d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* PVS flush. */
51966d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom pvs_flush;
52066d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* VAP invariant state. */
52166d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom vap_invariant_state;
52266d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Vertex stream formatting state. */
52366d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom vertex_stream_state;
52466d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Vertex shader. */
52566d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom vs_state;
5261a359d983512b39783ce9f4eb842d3ea4ec012a6Corbin Simpson    /* User clip planes. */
527249374b85346663417fc09e4c1ad3c6fb908067bCorbin Simpson    struct r300_atom clip_state;
52866d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* RS block state + VAP (vertex shader) output mapping state. */
52966d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom rs_block_state;
53066d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Rasterizer state. */
53166d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom rs_state;
53266d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Framebuffer state (pipelined regs). */
53366d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom fb_state_pipelined;
534fb8b794c69330924ad15083237b1a8a35eb62e31Corbin Simpson    /* Fragment shader. */
53534092c55d63e24a4f326bd9bb90765ea4ec7e17eMarek Olšák    struct r300_atom fs;
5365633392966f56a75cb2a675ef9594e987c4591b9Marek Olšák    /* Fragment shader RC_CONSTANT_STATE variables. */
5375633392966f56a75cb2a675ef9594e987c4591b9Marek Olšák    struct r300_atom fs_rc_constant_state;
538136bd184a29945ab7ae0636ecef65e9db97f8e4dMarek Olšák    /* Fragment shader constant buffer. */
539136bd184a29945ab7ae0636ecef65e9db97f8e4dMarek Olšák    struct r300_atom fs_constants;
5403da70606b3af1e907d56666d199957b6da0c73feMarek Olšák    /* Vertex shader constant buffer. */
5413da70606b3af1e907d56666d199957b6da0c73feMarek Olšák    struct r300_atom vs_constants;
542279715e76e5385afaad2834191e8578cf3a5d233Marek Olšák    /* Texture cache invalidate. */
543279715e76e5385afaad2834191e8578cf3a5d233Marek Olšák    struct r300_atom texture_cache_inval;
54466d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Textures state. */
54566d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom textures_state;
5466eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    /* HiZ clear */
5476eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    struct r300_atom hiz_clear;
5486eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    /* zmask clear */
5496eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie    struct r300_atom zmask_clear;
55066d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* Occlusion query. */
55166d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom query_start;
552a82fc97c643c4309a10cfefb108c4c0f11a2e55aCorbin Simpson
55366d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    /* The pointers to the first and the last atom. */
55466d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    struct r300_atom *first_dirty, *last_dirty;
555fcbd285e421903ee0a65f19f5d633b25b5923c24Corbin Simpson
5563445f476977ae403cef9ca15661fa0f96ff50ecaMaciej Cencora    /* Vertex elements for Gallium. */
557141c7cb0d6078b3a2832c4be03ddcf25e35e596bCorbin Simpson    struct r300_vertex_element_state *velems;
5583445f476977ae403cef9ca15661fa0f96ff50ecaMaciej Cencora
559942762cd973af0df75040de21d3321cd19829e70Marek Olšák    /* Vertex info for Draw. */
560942762cd973af0df75040de21d3321cd19829e70Marek Olšák    struct vertex_info vertex_info;
5613445f476977ae403cef9ca15661fa0f96ff50ecaMaciej Cencora
562bf4b0773c570017c1c3ec80da769bf5c39a685b2Roland Scheidegger    struct pipe_stencil_ref stencil_ref;
563b42455c4f48076eec34e383d5b9cc4670f2d048fMichal Krol    struct pipe_viewport_state viewport;
564b42455c4f48076eec34e383d5b9cc4670f2d048fMichal Krol
56568e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák    /* Stream locations for SWTCL. */
56668e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák    int stream_loc_notcl[16];
56768e720e12d51cf6d5237467a74af8c56b021acb7Marek Olšák
5682e09845277ce75fa7d29020c5b119ad749522592Corbin Simpson    /* Flag indicating whether or not the HW is dirty. */
5692e09845277ce75fa7d29020c5b119ad749522592Corbin Simpson    uint32_t dirty_hw;
570673ae6266ebf66145bf2bd7d37965f3fe60371d5Marek Olšák    /* Whether polygon offset is enabled. */
571673ae6266ebf66145bf2bd7d37965f3fe60371d5Marek Olšák    boolean polygon_offset_enabled;
572673ae6266ebf66145bf2bd7d37965f3fe60371d5Marek Olšák    /* Z buffer bit depth. */
573673ae6266ebf66145bf2bd7d37965f3fe60371d5Marek Olšák    uint32_t zbuffer_bpp;
574655fe281556679669699052f37412a6243771619Marek Olšák    /* Whether rendering is conditional and should be skipped. */
575655fe281556679669699052f37412a6243771619Marek Olšák    boolean skip_rendering;
57676056510bcd35b6b5607b572c0c0ff47b5c5e7e2Marek Olšák    /* The flag above saved by blitter. */
57776056510bcd35b6b5607b572c0c0ff47b5c5e7e2Marek Olšák    unsigned char blitter_saved_skip_rendering;
578745c4b568573fd5353e0f790251af64098742b1aMarek Olšák    /* Point sprites texcoord index,  1 bit per texcoord */
579745c4b568573fd5353e0f790251af64098742b1aMarek Olšák    int sprite_coord_enable;
580d044ecbe7625af1118655bcc9dba7ed00342534fMarek Olšák    /* Whether two-sided color selection is enabled (AKA light_twoside). */
581d044ecbe7625af1118655bcc9dba7ed00342534fMarek Olšák    boolean two_sided_color;
582d99ec708afbb785ce05031661222b38c9447059fMarek Olšák    /* Whether fast color clear is enabled. */
5838c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    boolean cbzb_clear;
5844af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    /* Whether fragment shader needs to be validated. */
5854af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    enum r300_fs_validity_status fs_status;
5864af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    /* Framebuffer multi-write. */
5874af3fe857dc07923af8786b434dee32d493b577eMarek Olšák    boolean fb_multiwrite;
588db299a9f8244d53d9041fcdbd396a77ebe1f9e3eMarek Olšák
589db299a9f8244d53d9041fcdbd396a77ebe1f9e3eMarek Olšák    void *dsa_decompress_zmask;
5906eb2a7fbafd49e75b6cbbee57f23dda63eff73efDave Airlie
59131714ea4d5a20285f398286fe45b53d0609926ddMarek Olšák    struct pipe_index_buffer index_buffer;
5922d03d4f4a365d7af5f4dac20700009152eba1682Marek Olšák    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
5932d03d4f4a365d7af5f4dac20700009152eba1682Marek Olšák    unsigned nr_vertex_buffers;
594e54cc2c070b30dd9b14bf9aedf93138b660c867fMarek Olšák    struct u_upload_mgr *uploader;
595c95bc1224a4b20b9470ddcb37b5f78975991073bMarek Olšák
59680f24c1575688e9cd4a5a811137f43b7e0a661bbMarek Olšák    struct util_slab_mempool pool_transfers;
5977b31b235d069ab4154bfc4b1eacde6368852aaeeMarek Olšák
598b02f1c86f5bf8b1169776975491c7df929e94e2cCorbin Simpson    /* Stat counter. */
599b02f1c86f5bf8b1169776975491c7df929e94e2cCorbin Simpson    uint64_t flush_counter;
600c1365606c5b89872af4a0931e20f5cb78875eea6Dave Airlie
601c1365606c5b89872af4a0931e20f5cb78875eea6Dave Airlie    /* const tracking for VS */
602c1365606c5b89872af4a0931e20f5cb78875eea6Dave Airlie    int vs_const_base;
60378068a5fbfc21fb52b289a81142b4211628f845cMarek Olšák
6045a6ba08c21f24b14458a2084a170ddfbe8f5d793Marek Olšák    /* Vertex array state info */
60533e0b726e8837a3456e224d169170ead25ee2fc5Marek Olšák    boolean vertex_arrays_dirty;
6065a6ba08c21f24b14458a2084a170ddfbe8f5d793Marek Olšák    boolean vertex_arrays_indexed;
6075a6ba08c21f24b14458a2084a170ddfbe8f5d793Marek Olšák    int vertex_arrays_offset;
60865482f2c2b1c3456d0ca58a38d82c02a5d6d362cMarek Olšák    int vertex_arrays_instance_id;
60965482f2c2b1c3456d0ca58a38d82c02a5d6d362cMarek Olšák    boolean instancing_enabled;
610fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák
611fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    /* Hyper-Z stats. */
612fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    boolean hyperz_enabled;     /* Whether it owns Hyper-Z access. */
613fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    int64_t hyperz_time_of_last_flush; /* Time of the last flush with Z clear. */
614fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    unsigned num_z_clears;      /* Since the last flush. */
615fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák
616fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    /* ZMask state. */
617fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    boolean zmask_in_use;       /* Whether ZMASK is enabled. */
618fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    boolean zmask_decompress;   /* Whether ZMASK is being decompressed. */
619fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    struct pipe_surface *locked_zbuffer; /* Unbound zbuffer which still has data in ZMASK. */
620fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák
621fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    /* HiZ state. */
622fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    boolean hiz_in_use;         /* Whether HIZ is enabled. */
623fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    enum r300_hiz_func hiz_func; /* HiZ function. Can be either MIN or MAX. */
624fdd37af3f76ea3ac32f21e9a9c41979a9b33cc5cMarek Olšák    uint32_t hiz_clear_value;   /* HiZ clear value. */
6253b37cb49b821dd0c59fd5361ada6c0df9ac07db8Corbin Simpson};
6263e09a07a265d5ee75b110954d160a73d83793c40Corbin Simpson
62766d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák#define foreach_atom(r300, atom) \
62866d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    for (atom = &r300->gpu_flush; atom != (&r300->query_start)+1; atom++)
62966d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák
63066d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák#define foreach_dirty_atom(r300, atom) \
63166d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák    for (atom = r300->first_dirty; atom != r300->last_dirty; atom++)
63266d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák
63373ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšák/* Convenience cast wrappers. */
63473ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšákstatic INLINE struct r300_query* r300_query(struct pipe_query* q)
63573ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšák{
63673ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšák    return (struct r300_query*)q;
63773ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšák}
63873ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšák
6398874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšákstatic INLINE struct r300_surface* r300_surface(struct pipe_surface* surf)
6408874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák{
6418874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák    return (struct r300_surface*)surf;
6428874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák}
6438874c9d7a3e59789843fa1b857e5318af17d146fMarek Olšák
64456ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšákstatic INLINE struct r300_resource* r300_resource(struct pipe_resource* tex)
645a1f85cf689b6f9ccf6b7310485460f84c8d78cadMarek Olšák{
64656ba7e913fef0ea2b1bead582108f9ab3ab8263dMarek Olšák    return (struct r300_resource*)tex;
647a1f85cf689b6f9ccf6b7310485460f84c8d78cadMarek Olšák}
648a1f85cf689b6f9ccf6b7310485460f84c8d78cadMarek Olšák
64959155f70e701bc0b4fb816da991d6921f53b3bc7Nicolai Hähnlestatic INLINE struct r300_context* r300_context(struct pipe_context* context)
65059155f70e701bc0b4fb816da991d6921f53b3bc7Nicolai Hähnle{
6513b37cb49b821dd0c59fd5361ada6c0df9ac07db8Corbin Simpson    return (struct r300_context*)context;
652aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson}
653aa96874c7abffa3fa9eef47ea36ab473ad2d2272Corbin Simpson
65434092c55d63e24a4f326bd9bb90765ea4ec7e17eMarek Olšákstatic INLINE struct r300_fragment_shader *r300_fs(struct r300_context *r300)
65534092c55d63e24a4f326bd9bb90765ea4ec7e17eMarek Olšák{
65634092c55d63e24a4f326bd9bb90765ea4ec7e17eMarek Olšák    return (struct r300_fragment_shader*)r300->fs.state;
65734092c55d63e24a4f326bd9bb90765ea4ec7e17eMarek Olšák}
6587f41f5447c8f9113c8956901e1c5fff6081ecd94Keith Whitwell
6593332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšákstatic INLINE void r300_mark_atom_dirty(struct r300_context *r300,
6603332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák                                        struct r300_atom *atom)
6613332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák{
6623332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák    atom->dirty = TRUE;
6633332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák
6643332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák    if (!r300->first_dirty) {
6653332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák        r300->first_dirty = atom;
6663332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák        r300->last_dirty = atom+1;
6673332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák    } else {
6683332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák        if (atom < r300->first_dirty)
6693332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák            r300->first_dirty = atom;
6703332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák        else if (atom+1 > r300->last_dirty)
6713332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák            r300->last_dirty = atom+1;
6723332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák    }
6733332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák}
6743332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák
6757f41f5447c8f9113c8956901e1c5fff6081ecd94Keith Whitwellstruct pipe_context* r300_create_context(struct pipe_screen* screen,
6767f41f5447c8f9113c8956901e1c5fff6081ecd94Keith Whitwell                                         void *priv);
6777f41f5447c8f9113c8956901e1c5fff6081ecd94Keith Whitwell
6784aaaecbfa6fa810899ef04de44f9f79ec4d8134fCorbin Simpson/* Context initialization. */
6795c50218d009a4c8276aa561bd1483742cf6aa20eCorbin Simpsonstruct draw_stage* r300_draw_stage(struct r300_context* r300);
68085eede1b2f93333529d26a8f1e70eeac3bce76e1Marek Olšákvoid r300_init_blit_functions(struct r300_context *r300);
681d1dac360048e5eace88b93f88a4a4e23d2cec582Marek Olšákvoid r300_init_flush_functions(struct r300_context* r300);
68273ee4e7eb254fa26e275917d358554bbe1e6c974Marek Olšákvoid r300_init_query_functions(struct r300_context* r300);
683e1c117d87bd1c77c6093a7a77b7994a8313b084eMarek Olšákvoid r300_init_render_functions(struct r300_context *r300);
68421a5a133fff3ab1a068a11a32144dcb63f1d5020Corbin Simpsonvoid r300_init_state_functions(struct r300_context* r300);
685287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid r300_init_resource_functions(struct r300_context* r300);
6864aaaecbfa6fa810899ef04de44f9f79ec4d8134fCorbin Simpson
6874f5e51068bce4e32a9561b4b4d6f3feca33642bfMarek Olšák/* r300_blit.c */
688db299a9f8244d53d9041fcdbd396a77ebe1f9e3eMarek Olšákvoid r300_decompress_zmask(struct r300_context *r300);
689db299a9f8244d53d9041fcdbd396a77ebe1f9e3eMarek Olšákvoid r300_decompress_zmask_locked_unsafe(struct r300_context *r300);
690db299a9f8244d53d9041fcdbd396a77ebe1f9e3eMarek Olšákvoid r300_decompress_zmask_locked(struct r300_context *r300);
691ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšákbool r300_is_blit_supported(enum pipe_format format);
6924f5e51068bce4e32a9561b4b4d6f3feca33642bfMarek Olšák
6935650a719f0c69c00954e47bd7a7b3e9433cb551dMarek Olšák/* r300_flush.c */
6945650a719f0c69c00954e47bd7a7b3e9433cb551dMarek Olšákvoid r300_flush(struct pipe_context *pipe,
6955650a719f0c69c00954e47bd7a7b3e9433cb551dMarek Olšák                unsigned flags,
6965650a719f0c69c00954e47bd7a7b3e9433cb551dMarek Olšák                struct pipe_fence_handle **fence);
6975650a719f0c69c00954e47bd7a7b3e9433cb551dMarek Olšák
698d99ec708afbb785ce05031661222b38c9447059fMarek Olšák/* r300_hyperz.c */
699d99ec708afbb785ce05031661222b38c9447059fMarek Olšákvoid r300_update_hyperz_state(struct r300_context* r300);
700d99ec708afbb785ce05031661222b38c9447059fMarek Olšák
701cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák/* r300_query.c */
702cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšákvoid r300_resume_query(struct r300_context *r300,
703cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák                       struct r300_query *query);
704cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšákvoid r300_stop_query(struct r300_context *r300);
705cf3778bae03460325960d2aec0cd4cdf325299ebMarek Olšák
706aa5422327d6f49d8940c2b933c2342ad8968032cMarek Olšák/* r300_render_translate.c */
707aa5422327d6f49d8940c2b933c2342ad8968032cMarek Olšákvoid r300_translate_index_buffer(struct r300_context *r300,
708bf469f4edc60bd1c5fd770cb231b8d5ab801427fMarek Olšák                                 struct pipe_index_buffer *ib,
709bf469f4edc60bd1c5fd770cb231b8d5ab801427fMarek Olšák                                 struct pipe_resource **out_index_buffer,
710aa5422327d6f49d8940c2b933c2342ad8968032cMarek Olšák                                 unsigned *index_size, unsigned index_offset,
711aa5422327d6f49d8940c2b933c2342ad8968032cMarek Olšák                                 unsigned *start, unsigned count);
712028459b0bf2bb778b55493f9b23ab7f2c9b355a0Marek Olšák
713cb17f5ee752d07d82e9b079c6bda9d89e51c7108Marek Olšák/* r300_render_stencilref.c */
714cb17f5ee752d07d82e9b079c6bda9d89e51c7108Marek Olšákvoid r300_plug_in_stencil_ref_fallback(struct r300_context *r300);
715cb17f5ee752d07d82e9b079c6bda9d89e51c7108Marek Olšák
716cb925970eeade17016f59497d2123e4e8a447164Marek Olšák/* r300_render.c */
717eb430b0e948caf02b9f4095d0e1435880073c2aaDave Airlievoid r300_draw_flush_vbuf(struct r300_context *r300);
718cb925970eeade17016f59497d2123e4e8a447164Marek Olšákvoid r500_emit_index_bias(struct r300_context *r300, int index_bias);
7196bede55241d8f672ba3d845e2ce1c00c7d65837eMarek Olšákvoid r300_blitter_draw_rectangle(struct blitter_context *blitter,
7206bede55241d8f672ba3d845e2ce1c00c7d65837eMarek Olšák                                 unsigned x1, unsigned y1,
7216bede55241d8f672ba3d845e2ce1c00c7d65837eMarek Olšák                                 unsigned x2, unsigned y2,
7226bede55241d8f672ba3d845e2ce1c00c7d65837eMarek Olšák                                 float depth,
7236bede55241d8f672ba3d845e2ce1c00c7d65837eMarek Olšák                                 enum blitter_attrib_type type,
7246bede55241d8f672ba3d845e2ce1c00c7d65837eMarek Olšák                                 const union pipe_color_union *attrib);
725eb430b0e948caf02b9f4095d0e1435880073c2aaDave Airlie
726ea0ec0b48e5adc0b71e52cd298fd71193ffd4a54Marek Olšák/* r300_state.c */
72762c631b20576ddee9a3c3d53709ca2932b0fbf9fMarek Olšákenum r300_fb_state_change {
7288c836f7f740c6f74511c727c7bed0680ddba9974Marek Olšák    R300_CHANGED_FB_STATE = 0,
729db299a9f8244d53d9041fcdbd396a77ebe1f9e3eMarek Olšák    R300_CHANGED_HYPERZ_FLAG,
7304e52e8f746e3565bf3fe9ba8e4e3744ce0302478Dave Airlie    R300_CHANGED_MULTIWRITE
73162c631b20576ddee9a3c3d53709ca2932b0fbf9fMarek Olšák};
73262c631b20576ddee9a3c3d53709ca2932b0fbf9fMarek Olšák
73362c631b20576ddee9a3c3d53709ca2932b0fbf9fMarek Olšákvoid r300_mark_fb_state_dirty(struct r300_context *r300,
73462c631b20576ddee9a3c3d53709ca2932b0fbf9fMarek Olšák                              enum r300_fb_state_change change);
735ea0ec0b48e5adc0b71e52cd298fd71193ffd4a54Marek Olšákvoid r300_mark_fs_code_dirty(struct r300_context *r300);
736ea0ec0b48e5adc0b71e52cd298fd71193ffd4a54Marek Olšák
737ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšákstruct pipe_sampler_view *
738ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšákr300_create_sampler_view_custom(struct pipe_context *pipe,
739ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák                         struct pipe_resource *texture,
740ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák                         const struct pipe_sampler_view *templ,
741ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák                         unsigned width0_override,
742ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák                         unsigned height0_override);
743ce9d61fec64138ebf8d0bec2511e66593297b7d5Marek Olšák
7443332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšák/* r300_state_derived.c */
7453332229b3ba7a183a9f120ae4bbf9865e96df110Marek Olšákvoid r300_update_derived_state(struct r300_context* r300);
74666d45567b4e2c6f2585789b68667e6c00b7567e1Marek Olšák
747ea0ec0b48e5adc0b71e52cd298fd71193ffd4a54Marek Olšák/* r300_debug.c */
74898630a900e78ec7ee598679c27c25923c1ffb929Marek Olšákvoid r500_dump_rs_block(struct r300_rs_block *rs);
74998630a900e78ec7ee598679c27c25923c1ffb929Marek Olšák
750ea0ec0b48e5adc0b71e52cd298fd71193ffd4a54Marek Olšák
75108edbe9f14712f719f838769c61123f83768af76Marek Olšákstatic INLINE boolean CTX_DBG_ON(struct r300_context * ctx, unsigned flags)
7524b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle{
753b71bfc4400e1d7c15a2bebbbd3b26a8770fbf546Marek Olšák    return SCREEN_DBG_ON(ctx->screen, flags);
7544b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle}
7554b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle
75608edbe9f14712f719f838769c61123f83768af76Marek Olšákstatic INLINE void CTX_DBG(struct r300_context * ctx, unsigned flags,
75708edbe9f14712f719f838769c61123f83768af76Marek Olšák                       const char * fmt, ...)
7584b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle{
75908edbe9f14712f719f838769c61123f83768af76Marek Olšák    if (CTX_DBG_ON(ctx, flags)) {
7604b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle        va_list va;
7614b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle        va_start(va, fmt);
7621c2912ee7a47170bbaa8a71d4af729d0caf17f04Marek Olšák        vfprintf(stderr, fmt, va);
7634b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle        va_end(va);
7644b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle    }
7654b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle}
7664b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle
76708edbe9f14712f719f838769c61123f83768af76Marek Olšák#define DBG_ON  CTX_DBG_ON
76808edbe9f14712f719f838769c61123f83768af76Marek Olšák#define DBG     CTX_DBG
7694b01e6f614052e48971f2b2ff474fb66afc4f752Nicolai Hähnle
7704ce81294943177eed99d7418f1a2f88573b578feCorbin Simpson#endif /* R300_CONTEXT_H */
771