7fd406650ee6acb2f25717cbb3b8ce1f9379f12f
2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
3 * Copyright © 2018 Google, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Rob Clark <robclark@freedesktop.org>
28 #ifndef FD6_CONTEXT_H_
29 #define FD6_CONTEXT_H_
31 #include "util/u_upload_mgr.h"
33 #include "freedreno_drmif.h"
35 #include "freedreno_context.h"
37 #include "ir3_shader.h"
42 struct fd_context base
;
44 struct fd_bo
*vs_pvt_mem
, *fs_pvt_mem
;
46 /* This only needs to be 4 * num_of_pipes bytes (ie. 32 bytes). We
47 * could combine it with another allocation.
49 struct fd_bo
*vsc_size_mem
;
51 /* TODO not sure what this is for.. probably similar to
52 * CACHE_FLUSH_TS on kernel side, where value gets written
53 * to this address synchronized w/ 3d (ie. a way to
54 * synchronize when the CP is running far ahead)
56 struct fd_bo
*blit_mem
;
58 struct u_upload_mgr
*border_color_uploader
;
59 struct pipe_resource
*border_color_buf
;
61 /* if *any* of bits are set in {v,f}saturate_{s,t,r} */
62 bool vsaturate
, fsaturate
;
64 /* bitmask of sampler which needs coords clamped for vertex
67 uint16_t vsaturate_s
, vsaturate_t
, vsaturate_r
;
69 /* bitmask of sampler which needs coords clamped for frag
72 uint16_t fsaturate_s
, fsaturate_t
, fsaturate_r
;
74 /* bitmask of samplers which need astc srgb workaround: */
75 uint16_t vastc_srgb
, fastc_srgb
;
77 /* some state changes require a different shader variant. Keep
78 * track of this so we know when we need to re-emit shader state
79 * due to variant change. See fixup_shader_state()
81 struct ir3_shader_key last_key
;
83 /* number of active samples-passed queries: */
84 int samples_passed_queries
;
86 /* cached state about current emitted shader program (3d): */
90 static inline struct fd6_context
*
91 fd6_context(struct fd_context
*ctx
)
93 return (struct fd6_context
*)ctx
;
97 fd6_context_create(struct pipe_screen
*pscreen
, void *priv
, unsigned flags
);
99 /* helper for places where we need to stall CP to wait for previous draws: */
101 fd6_emit_flush(struct fd_context
*ctx
, struct fd_ringbuffer
*ring
)
103 OUT_PKT7(ring
, CP_EVENT_WRITE
, 4);
104 OUT_RING(ring
, CACHE_FLUSH_TS
);
105 OUT_RELOCW(ring
, fd6_context(ctx
)->blit_mem
, 0, 0, 0); /* ADDR_LO/HI */
106 OUT_RING(ring
, 0x00000000);
112 emit_marker6(struct fd_ringbuffer
*ring
, int scratch_idx
)
114 extern unsigned marker_cnt
;
115 unsigned reg
= REG_A6XX_CP_SCRATCH_REG(scratch_idx
);
116 OUT_PKT4(ring
, reg
, 1);
117 OUT_RING(ring
, ++marker_cnt
);
120 #endif /* FD6_CONTEXT_H_ */