1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2014-2017 Broadcom 3bf215546Sopenharmony_ci * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org> 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22bf215546Sopenharmony_ci * IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci#ifndef V3D_CONTEXT_H 26bf215546Sopenharmony_ci#define V3D_CONTEXT_H 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#ifdef V3D_VERSION 29bf215546Sopenharmony_ci#include "broadcom/common/v3d_macros.h" 30bf215546Sopenharmony_ci#endif 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include <stdio.h> 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include "pipe/p_context.h" 35bf215546Sopenharmony_ci#include "pipe/p_state.h" 36bf215546Sopenharmony_ci#include "util/bitset.h" 37bf215546Sopenharmony_ci#include "util/slab.h" 38bf215546Sopenharmony_ci#include "xf86drm.h" 39bf215546Sopenharmony_ci#include "drm-uapi/v3d_drm.h" 40bf215546Sopenharmony_ci#include "v3d_screen.h" 41bf215546Sopenharmony_ci#include "broadcom/common/v3d_limits.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci#include "broadcom/simulator/v3d_simulator.h" 44bf215546Sopenharmony_ci#include "broadcom/compiler/v3d_compiler.h" 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_cistruct v3d_job; 47bf215546Sopenharmony_cistruct v3d_bo; 48bf215546Sopenharmony_civoid v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo); 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci#include "v3d_bufmgr.h" 51bf215546Sopenharmony_ci#include "v3d_resource.h" 52bf215546Sopenharmony_ci#include "v3d_cl.h" 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci#ifdef USE_V3D_SIMULATOR 55bf215546Sopenharmony_ci#define using_v3d_simulator true 56bf215546Sopenharmony_ci#else 57bf215546Sopenharmony_ci#define using_v3d_simulator false 58bf215546Sopenharmony_ci#endif 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci#define V3D_DIRTY_BLEND (1ull << 0) 61bf215546Sopenharmony_ci#define V3D_DIRTY_RASTERIZER (1ull << 1) 62bf215546Sopenharmony_ci#define V3D_DIRTY_ZSA (1ull << 2) 63bf215546Sopenharmony_ci#define V3D_DIRTY_COMPTEX (1ull << 3) 64bf215546Sopenharmony_ci#define V3D_DIRTY_VERTTEX (1ull << 4) 65bf215546Sopenharmony_ci#define V3D_DIRTY_GEOMTEX (1ull << 5) 66bf215546Sopenharmony_ci#define V3D_DIRTY_FRAGTEX (1ull << 6) 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci#define V3D_DIRTY_SHADER_IMAGE (1ull << 9) 69bf215546Sopenharmony_ci#define V3D_DIRTY_BLEND_COLOR (1ull << 10) 70bf215546Sopenharmony_ci#define V3D_DIRTY_STENCIL_REF (1ull << 11) 71bf215546Sopenharmony_ci#define V3D_DIRTY_SAMPLE_STATE (1ull << 12) 72bf215546Sopenharmony_ci#define V3D_DIRTY_FRAMEBUFFER (1ull << 13) 73bf215546Sopenharmony_ci#define V3D_DIRTY_STIPPLE (1ull << 14) 74bf215546Sopenharmony_ci#define V3D_DIRTY_VIEWPORT (1ull << 15) 75bf215546Sopenharmony_ci#define V3D_DIRTY_CONSTBUF (1ull << 16) 76bf215546Sopenharmony_ci#define V3D_DIRTY_VTXSTATE (1ull << 17) 77bf215546Sopenharmony_ci#define V3D_DIRTY_VTXBUF (1ull << 18) 78bf215546Sopenharmony_ci#define V3D_DIRTY_SCISSOR (1ull << 19) 79bf215546Sopenharmony_ci#define V3D_DIRTY_FLAT_SHADE_FLAGS (1ull << 20) 80bf215546Sopenharmony_ci#define V3D_DIRTY_PRIM_MODE (1ull << 21) 81bf215546Sopenharmony_ci#define V3D_DIRTY_CLIP (1ull << 22) 82bf215546Sopenharmony_ci#define V3D_DIRTY_UNCOMPILED_CS (1ull << 23) 83bf215546Sopenharmony_ci#define V3D_DIRTY_UNCOMPILED_VS (1ull << 24) 84bf215546Sopenharmony_ci#define V3D_DIRTY_UNCOMPILED_GS (1ull << 25) 85bf215546Sopenharmony_ci#define V3D_DIRTY_UNCOMPILED_FS (1ull << 26) 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_ci#define V3D_DIRTY_COMPILED_CS (1ull << 29) 88bf215546Sopenharmony_ci#define V3D_DIRTY_COMPILED_VS (1ull << 30) 89bf215546Sopenharmony_ci#define V3D_DIRTY_COMPILED_GS_BIN (1ULL << 31) 90bf215546Sopenharmony_ci#define V3D_DIRTY_COMPILED_GS (1ULL << 32) 91bf215546Sopenharmony_ci#define V3D_DIRTY_COMPILED_FS (1ull << 33) 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ci#define V3D_DIRTY_FS_INPUTS (1ull << 38) 94bf215546Sopenharmony_ci#define V3D_DIRTY_GS_INPUTS (1ull << 39) 95bf215546Sopenharmony_ci#define V3D_DIRTY_STREAMOUT (1ull << 40) 96bf215546Sopenharmony_ci#define V3D_DIRTY_OQ (1ull << 41) 97bf215546Sopenharmony_ci#define V3D_DIRTY_CENTROID_FLAGS (1ull << 42) 98bf215546Sopenharmony_ci#define V3D_DIRTY_NOPERSPECTIVE_FLAGS (1ull << 43) 99bf215546Sopenharmony_ci#define V3D_DIRTY_SSBO (1ull << 44) 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci#define V3D_MAX_FS_INPUTS 64 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci#define MAX_JOB_SCISSORS 16 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_cienum v3d_sampler_state_variant { 106bf215546Sopenharmony_ci V3D_SAMPLER_STATE_BORDER_0000, 107bf215546Sopenharmony_ci V3D_SAMPLER_STATE_BORDER_0001, 108bf215546Sopenharmony_ci V3D_SAMPLER_STATE_BORDER_1111, 109bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16, 110bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_UNORM, 111bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_SNORM, 112bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_BGRA, 113bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_BGRA_UNORM, 114bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_BGRA_SNORM, 115bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_A, 116bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_A_SNORM, 117bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_A_UNORM, 118bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_LA, 119bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_LA_UNORM, 120bf215546Sopenharmony_ci V3D_SAMPLER_STATE_F16_LA_SNORM, 121bf215546Sopenharmony_ci V3D_SAMPLER_STATE_32, 122bf215546Sopenharmony_ci V3D_SAMPLER_STATE_32_UNORM, 123bf215546Sopenharmony_ci V3D_SAMPLER_STATE_32_SNORM, 124bf215546Sopenharmony_ci V3D_SAMPLER_STATE_32_A, 125bf215546Sopenharmony_ci V3D_SAMPLER_STATE_32_A_UNORM, 126bf215546Sopenharmony_ci V3D_SAMPLER_STATE_32_A_SNORM, 127bf215546Sopenharmony_ci V3D_SAMPLER_STATE_1010102U, 128bf215546Sopenharmony_ci V3D_SAMPLER_STATE_16U, 129bf215546Sopenharmony_ci V3D_SAMPLER_STATE_16I, 130bf215546Sopenharmony_ci V3D_SAMPLER_STATE_8I, 131bf215546Sopenharmony_ci V3D_SAMPLER_STATE_8U, 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_ci V3D_SAMPLER_STATE_VARIANT_COUNT, 134bf215546Sopenharmony_ci}; 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_cienum v3d_flush_cond { 137bf215546Sopenharmony_ci /* Flush job unless we are flushing for transform feedback, where we 138bf215546Sopenharmony_ci * handle flushing in the driver via the 'Wait for TF' packet. 139bf215546Sopenharmony_ci */ 140bf215546Sopenharmony_ci V3D_FLUSH_DEFAULT, 141bf215546Sopenharmony_ci /* Always flush the job, even for cases where we would normally not 142bf215546Sopenharmony_ci * do it, such as transform feedback. 143bf215546Sopenharmony_ci */ 144bf215546Sopenharmony_ci V3D_FLUSH_ALWAYS, 145bf215546Sopenharmony_ci /* Flush job if it is not the current FBO job. This is intended to 146bf215546Sopenharmony_ci * skip automatic flushes of the current job for resources that we 147bf215546Sopenharmony_ci * expect to be externally synchronized by the application using 148bf215546Sopenharmony_ci * glMemoryBarrier(), such as SSBOs and shader images. 149bf215546Sopenharmony_ci */ 150bf215546Sopenharmony_ci V3D_FLUSH_NOT_CURRENT_JOB, 151bf215546Sopenharmony_ci}; 152bf215546Sopenharmony_ci 153bf215546Sopenharmony_cistruct v3d_sampler_view { 154bf215546Sopenharmony_ci struct pipe_sampler_view base; 155bf215546Sopenharmony_ci uint32_t p0; 156bf215546Sopenharmony_ci uint32_t p1; 157bf215546Sopenharmony_ci /* Precomputed swizzles to pass in to the shader key. */ 158bf215546Sopenharmony_ci uint8_t swizzle[4]; 159bf215546Sopenharmony_ci 160bf215546Sopenharmony_ci uint8_t texture_shader_state[32]; 161bf215546Sopenharmony_ci /* V3D 4.x: Texture state struct. */ 162bf215546Sopenharmony_ci struct v3d_bo *bo; 163bf215546Sopenharmony_ci 164bf215546Sopenharmony_ci enum v3d_sampler_state_variant sampler_variant; 165bf215546Sopenharmony_ci 166bf215546Sopenharmony_ci /* Actual texture to be read by this sampler view. May be different 167bf215546Sopenharmony_ci * from base.texture in the case of having a shadow tiled copy of a 168bf215546Sopenharmony_ci * raster texture. 169bf215546Sopenharmony_ci */ 170bf215546Sopenharmony_ci struct pipe_resource *texture; 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_ci /* A serial ID used to identify cases where a new BO has been created 173bf215546Sopenharmony_ci * and we need to rebind a sampler view that was created against the 174bf215546Sopenharmony_ci * previous BO to to point to the new one. 175bf215546Sopenharmony_ci */ 176bf215546Sopenharmony_ci uint32_t serial_id; 177bf215546Sopenharmony_ci}; 178bf215546Sopenharmony_ci 179bf215546Sopenharmony_cistruct v3d_sampler_state { 180bf215546Sopenharmony_ci struct pipe_sampler_state base; 181bf215546Sopenharmony_ci uint32_t p0; 182bf215546Sopenharmony_ci uint32_t p1; 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci /* V3D 3.x: Packed texture state. */ 185bf215546Sopenharmony_ci uint8_t texture_shader_state[32]; 186bf215546Sopenharmony_ci /* V3D 4.x: Sampler state struct. */ 187bf215546Sopenharmony_ci struct pipe_resource *sampler_state; 188bf215546Sopenharmony_ci uint32_t sampler_state_offset[V3D_SAMPLER_STATE_VARIANT_COUNT]; 189bf215546Sopenharmony_ci 190bf215546Sopenharmony_ci bool border_color_variants; 191bf215546Sopenharmony_ci}; 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_cistruct v3d_texture_stateobj { 194bf215546Sopenharmony_ci struct pipe_sampler_view *textures[V3D_MAX_TEXTURE_SAMPLERS]; 195bf215546Sopenharmony_ci unsigned num_textures; 196bf215546Sopenharmony_ci struct pipe_sampler_state *samplers[V3D_MAX_TEXTURE_SAMPLERS]; 197bf215546Sopenharmony_ci unsigned num_samplers; 198bf215546Sopenharmony_ci struct v3d_cl_reloc texture_state[V3D_MAX_TEXTURE_SAMPLERS]; 199bf215546Sopenharmony_ci}; 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_cistruct v3d_shader_uniform_info { 202bf215546Sopenharmony_ci enum quniform_contents *contents; 203bf215546Sopenharmony_ci uint32_t *data; 204bf215546Sopenharmony_ci uint32_t count; 205bf215546Sopenharmony_ci}; 206bf215546Sopenharmony_ci 207bf215546Sopenharmony_cistruct v3d_uncompiled_shader { 208bf215546Sopenharmony_ci /** A name for this program, so you can track it in shader-db output. */ 209bf215546Sopenharmony_ci uint32_t program_id; 210bf215546Sopenharmony_ci /** How many variants of this program were compiled, for shader-db. */ 211bf215546Sopenharmony_ci uint32_t compiled_variant_count; 212bf215546Sopenharmony_ci struct pipe_shader_state base; 213bf215546Sopenharmony_ci uint32_t num_tf_outputs; 214bf215546Sopenharmony_ci struct v3d_varying_slot *tf_outputs; 215bf215546Sopenharmony_ci uint16_t tf_specs[16]; 216bf215546Sopenharmony_ci uint16_t tf_specs_psiz[16]; 217bf215546Sopenharmony_ci uint32_t num_tf_specs; 218bf215546Sopenharmony_ci}; 219bf215546Sopenharmony_ci 220bf215546Sopenharmony_cistruct v3d_compiled_shader { 221bf215546Sopenharmony_ci struct pipe_resource *resource; 222bf215546Sopenharmony_ci uint32_t offset; 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_ci union { 225bf215546Sopenharmony_ci struct v3d_prog_data *base; 226bf215546Sopenharmony_ci struct v3d_vs_prog_data *vs; 227bf215546Sopenharmony_ci struct v3d_gs_prog_data *gs; 228bf215546Sopenharmony_ci struct v3d_fs_prog_data *fs; 229bf215546Sopenharmony_ci struct v3d_compute_prog_data *compute; 230bf215546Sopenharmony_ci } prog_data; 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ci /** 233bf215546Sopenharmony_ci * V3D_DIRTY_* flags that, when set in v3d->dirty, mean that the 234bf215546Sopenharmony_ci * uniforms have to be rewritten (and therefore the shader state 235bf215546Sopenharmony_ci * reemitted). 236bf215546Sopenharmony_ci */ 237bf215546Sopenharmony_ci uint64_t uniform_dirty_bits; 238bf215546Sopenharmony_ci}; 239bf215546Sopenharmony_ci 240bf215546Sopenharmony_cistruct v3d_program_stateobj { 241bf215546Sopenharmony_ci struct v3d_uncompiled_shader *bind_vs, *bind_gs, *bind_fs, *bind_compute; 242bf215546Sopenharmony_ci struct v3d_compiled_shader *cs, *vs, *gs_bin, *gs, *fs, *compute; 243bf215546Sopenharmony_ci 244bf215546Sopenharmony_ci struct hash_table *cache[MESA_SHADER_STAGES]; 245bf215546Sopenharmony_ci 246bf215546Sopenharmony_ci struct v3d_bo *spill_bo; 247bf215546Sopenharmony_ci int spill_size_per_thread; 248bf215546Sopenharmony_ci}; 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_cistruct v3d_constbuf_stateobj { 251bf215546Sopenharmony_ci struct pipe_constant_buffer cb[PIPE_MAX_CONSTANT_BUFFERS]; 252bf215546Sopenharmony_ci uint32_t enabled_mask; 253bf215546Sopenharmony_ci uint32_t dirty_mask; 254bf215546Sopenharmony_ci}; 255bf215546Sopenharmony_ci 256bf215546Sopenharmony_cistruct v3d_vertexbuf_stateobj { 257bf215546Sopenharmony_ci struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS]; 258bf215546Sopenharmony_ci unsigned count; 259bf215546Sopenharmony_ci uint32_t enabled_mask; 260bf215546Sopenharmony_ci uint32_t dirty_mask; 261bf215546Sopenharmony_ci}; 262bf215546Sopenharmony_ci 263bf215546Sopenharmony_cistruct v3d_vertex_stateobj { 264bf215546Sopenharmony_ci struct pipe_vertex_element pipe[V3D_MAX_VS_INPUTS / 4]; 265bf215546Sopenharmony_ci unsigned num_elements; 266bf215546Sopenharmony_ci 267bf215546Sopenharmony_ci uint8_t attrs[16 * (V3D_MAX_VS_INPUTS / 4)]; 268bf215546Sopenharmony_ci struct pipe_resource *defaults; 269bf215546Sopenharmony_ci uint32_t defaults_offset; 270bf215546Sopenharmony_ci}; 271bf215546Sopenharmony_ci 272bf215546Sopenharmony_cistruct v3d_stream_output_target { 273bf215546Sopenharmony_ci struct pipe_stream_output_target base; 274bf215546Sopenharmony_ci /* Number of transform feedback vertices written to this target */ 275bf215546Sopenharmony_ci uint32_t recorded_vertex_count; 276bf215546Sopenharmony_ci}; 277bf215546Sopenharmony_ci 278bf215546Sopenharmony_cistruct v3d_streamout_stateobj { 279bf215546Sopenharmony_ci struct pipe_stream_output_target *targets[PIPE_MAX_SO_BUFFERS]; 280bf215546Sopenharmony_ci /* Number of vertices we've written into the buffer so far. */ 281bf215546Sopenharmony_ci uint32_t offsets[PIPE_MAX_SO_BUFFERS]; 282bf215546Sopenharmony_ci unsigned num_targets; 283bf215546Sopenharmony_ci}; 284bf215546Sopenharmony_ci 285bf215546Sopenharmony_cistruct v3d_ssbo_stateobj { 286bf215546Sopenharmony_ci struct pipe_shader_buffer sb[PIPE_MAX_SHADER_BUFFERS]; 287bf215546Sopenharmony_ci uint32_t enabled_mask; 288bf215546Sopenharmony_ci}; 289bf215546Sopenharmony_ci 290bf215546Sopenharmony_ci/* Hash table key for v3d->jobs */ 291bf215546Sopenharmony_cistruct v3d_job_key { 292bf215546Sopenharmony_ci struct pipe_surface *cbufs[V3D_MAX_DRAW_BUFFERS]; 293bf215546Sopenharmony_ci struct pipe_surface *zsbuf; 294bf215546Sopenharmony_ci struct pipe_surface *bbuf; 295bf215546Sopenharmony_ci}; 296bf215546Sopenharmony_ci 297bf215546Sopenharmony_cienum v3d_ez_state { 298bf215546Sopenharmony_ci V3D_EZ_UNDECIDED = 0, 299bf215546Sopenharmony_ci V3D_EZ_GT_GE, 300bf215546Sopenharmony_ci V3D_EZ_LT_LE, 301bf215546Sopenharmony_ci V3D_EZ_DISABLED, 302bf215546Sopenharmony_ci}; 303bf215546Sopenharmony_ci 304bf215546Sopenharmony_cistruct v3d_image_view { 305bf215546Sopenharmony_ci struct pipe_image_view base; 306bf215546Sopenharmony_ci /* V3D 4.x texture shader state struct */ 307bf215546Sopenharmony_ci struct pipe_resource *tex_state; 308bf215546Sopenharmony_ci uint32_t tex_state_offset; 309bf215546Sopenharmony_ci}; 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_cistruct v3d_shaderimg_stateobj { 312bf215546Sopenharmony_ci struct v3d_image_view si[PIPE_MAX_SHADER_IMAGES]; 313bf215546Sopenharmony_ci uint32_t enabled_mask; 314bf215546Sopenharmony_ci}; 315bf215546Sopenharmony_ci 316bf215546Sopenharmony_cistruct v3d_perfmon_state { 317bf215546Sopenharmony_ci /* The kernel perfmon id */ 318bf215546Sopenharmony_ci uint32_t kperfmon_id; 319bf215546Sopenharmony_ci /* True if at least one job was submitted with this perfmon. */ 320bf215546Sopenharmony_ci bool job_submitted; 321bf215546Sopenharmony_ci /* Fence to be signaled when the last job submitted with this perfmon 322bf215546Sopenharmony_ci * is executed by the GPU. 323bf215546Sopenharmony_ci */ 324bf215546Sopenharmony_ci struct v3d_fence *last_job_fence; 325bf215546Sopenharmony_ci uint8_t counters[DRM_V3D_MAX_PERF_COUNTERS]; 326bf215546Sopenharmony_ci uint64_t values[DRM_V3D_MAX_PERF_COUNTERS]; 327bf215546Sopenharmony_ci}; 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_ci/** 330bf215546Sopenharmony_ci * A complete bin/render job. 331bf215546Sopenharmony_ci * 332bf215546Sopenharmony_ci * This is all of the state necessary to submit a bin/render to the kernel. 333bf215546Sopenharmony_ci * We want to be able to have multiple in progress at a time, so that we don't 334bf215546Sopenharmony_ci * need to flush an existing CL just to switch to rendering to a new render 335bf215546Sopenharmony_ci * target (which would mean reading back from the old render target when 336bf215546Sopenharmony_ci * starting to render to it again). 337bf215546Sopenharmony_ci */ 338bf215546Sopenharmony_cistruct v3d_job { 339bf215546Sopenharmony_ci struct v3d_context *v3d; 340bf215546Sopenharmony_ci struct v3d_cl bcl; 341bf215546Sopenharmony_ci struct v3d_cl rcl; 342bf215546Sopenharmony_ci struct v3d_cl indirect; 343bf215546Sopenharmony_ci struct v3d_bo *tile_alloc; 344bf215546Sopenharmony_ci struct v3d_bo *tile_state; 345bf215546Sopenharmony_ci 346bf215546Sopenharmony_ci struct drm_v3d_submit_cl submit; 347bf215546Sopenharmony_ci 348bf215546Sopenharmony_ci /** 349bf215546Sopenharmony_ci * Set of all BOs referenced by the job. This will be used for making 350bf215546Sopenharmony_ci * the list of BOs that the kernel will need to have paged in to 351bf215546Sopenharmony_ci * execute our job. 352bf215546Sopenharmony_ci */ 353bf215546Sopenharmony_ci struct set *bos; 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ci /** Sum of the sizes of the BOs referenced by the job. */ 356bf215546Sopenharmony_ci uint32_t referenced_size; 357bf215546Sopenharmony_ci 358bf215546Sopenharmony_ci struct set *write_prscs; 359bf215546Sopenharmony_ci struct set *tf_write_prscs; 360bf215546Sopenharmony_ci 361bf215546Sopenharmony_ci /* Size of the submit.bo_handles array. */ 362bf215546Sopenharmony_ci uint32_t bo_handles_size; 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_ci /** @{ 365bf215546Sopenharmony_ci * Surfaces to submit rendering for. 366bf215546Sopenharmony_ci * For blit operations, bbuf is the source surface, and cbufs[0] is 367bf215546Sopenharmony_ci * the destination surface. 368bf215546Sopenharmony_ci */ 369bf215546Sopenharmony_ci uint32_t nr_cbufs; 370bf215546Sopenharmony_ci struct pipe_surface *cbufs[V3D_MAX_DRAW_BUFFERS]; 371bf215546Sopenharmony_ci struct pipe_surface *zsbuf; 372bf215546Sopenharmony_ci struct pipe_surface *bbuf; 373bf215546Sopenharmony_ci /** @} */ 374bf215546Sopenharmony_ci /** @{ 375bf215546Sopenharmony_ci * Bounding box of the scissor across all queued drawing. 376bf215546Sopenharmony_ci * 377bf215546Sopenharmony_ci * Note that the max values are exclusive. 378bf215546Sopenharmony_ci */ 379bf215546Sopenharmony_ci uint32_t draw_min_x; 380bf215546Sopenharmony_ci uint32_t draw_min_y; 381bf215546Sopenharmony_ci uint32_t draw_max_x; 382bf215546Sopenharmony_ci uint32_t draw_max_y; 383bf215546Sopenharmony_ci 384bf215546Sopenharmony_ci /** @} */ 385bf215546Sopenharmony_ci /** @{ 386bf215546Sopenharmony_ci * List of scissor rects used for all queued drawing. All scissor 387bf215546Sopenharmony_ci * rects will be contained in the draw_{min/max}_{x/y} bounding box. 388bf215546Sopenharmony_ci * 389bf215546Sopenharmony_ci * This is used as an optimization when all drawing is scissored to 390bf215546Sopenharmony_ci * limit tile flushing only to tiles that intersect a scissor rect. 391bf215546Sopenharmony_ci * If scissor is used together with non-scissored drawing, then 392bf215546Sopenharmony_ci * the optimization is disabled. 393bf215546Sopenharmony_ci */ 394bf215546Sopenharmony_ci struct { 395bf215546Sopenharmony_ci bool disabled; 396bf215546Sopenharmony_ci uint32_t count; 397bf215546Sopenharmony_ci struct { 398bf215546Sopenharmony_ci uint32_t min_x, min_y; 399bf215546Sopenharmony_ci uint32_t max_x, max_y; 400bf215546Sopenharmony_ci } rects[MAX_JOB_SCISSORS]; 401bf215546Sopenharmony_ci } scissor; 402bf215546Sopenharmony_ci 403bf215546Sopenharmony_ci /** @} */ 404bf215546Sopenharmony_ci /** @{ 405bf215546Sopenharmony_ci * Width/height of the color framebuffer being rendered to, 406bf215546Sopenharmony_ci * for V3D_TILE_RENDERING_MODE_CONFIG. 407bf215546Sopenharmony_ci */ 408bf215546Sopenharmony_ci uint32_t draw_width; 409bf215546Sopenharmony_ci uint32_t draw_height; 410bf215546Sopenharmony_ci uint32_t num_layers; 411bf215546Sopenharmony_ci 412bf215546Sopenharmony_ci /** @} */ 413bf215546Sopenharmony_ci /** @{ Tile information, depending on MSAA and float color buffer. */ 414bf215546Sopenharmony_ci uint32_t draw_tiles_x; /** @< Number of tiles wide for framebuffer. */ 415bf215546Sopenharmony_ci uint32_t draw_tiles_y; /** @< Number of tiles high for framebuffer. */ 416bf215546Sopenharmony_ci 417bf215546Sopenharmony_ci uint32_t tile_width; /** @< Width of a tile. */ 418bf215546Sopenharmony_ci uint32_t tile_height; /** @< Height of a tile. */ 419bf215546Sopenharmony_ci /** maximum internal_bpp of all color render targets. */ 420bf215546Sopenharmony_ci uint32_t internal_bpp; 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci /** Whether the current rendering is in a 4X MSAA tile buffer. */ 423bf215546Sopenharmony_ci bool msaa; 424bf215546Sopenharmony_ci /** @} */ 425bf215546Sopenharmony_ci 426bf215546Sopenharmony_ci /* Bitmask of PIPE_CLEAR_* of buffers that were cleared before the 427bf215546Sopenharmony_ci * first rendering. 428bf215546Sopenharmony_ci */ 429bf215546Sopenharmony_ci uint32_t clear; 430bf215546Sopenharmony_ci /* Bitmask of PIPE_CLEAR_* of buffers that have been read by a draw 431bf215546Sopenharmony_ci * call without having been cleared first. 432bf215546Sopenharmony_ci */ 433bf215546Sopenharmony_ci uint32_t load; 434bf215546Sopenharmony_ci /* Bitmask of PIPE_CLEAR_* of buffers that have been rendered to 435bf215546Sopenharmony_ci * (either clears or draws) and should be stored. 436bf215546Sopenharmony_ci */ 437bf215546Sopenharmony_ci uint32_t store; 438bf215546Sopenharmony_ci uint32_t clear_color[V3D_MAX_DRAW_BUFFERS][4]; 439bf215546Sopenharmony_ci float clear_z; 440bf215546Sopenharmony_ci uint8_t clear_s; 441bf215546Sopenharmony_ci 442bf215546Sopenharmony_ci /* If TLB double-buffering is enabled for this job */ 443bf215546Sopenharmony_ci bool double_buffer; 444bf215546Sopenharmony_ci 445bf215546Sopenharmony_ci /** 446bf215546Sopenharmony_ci * Set if some drawing (triangles, blits, or just a glClear()) has 447bf215546Sopenharmony_ci * been done to the FBO, meaning that we need to 448bf215546Sopenharmony_ci * DRM_IOCTL_V3D_SUBMIT_CL. 449bf215546Sopenharmony_ci */ 450bf215546Sopenharmony_ci bool needs_flush; 451bf215546Sopenharmony_ci 452bf215546Sopenharmony_ci /* Set if any shader has dirtied cachelines in the TMU that need to be 453bf215546Sopenharmony_ci * flushed before job end. 454bf215546Sopenharmony_ci */ 455bf215546Sopenharmony_ci bool tmu_dirty_rcl; 456bf215546Sopenharmony_ci 457bf215546Sopenharmony_ci /** 458bf215546Sopenharmony_ci * Set if a packet enabling TF has been emitted in the job (V3D 4.x). 459bf215546Sopenharmony_ci */ 460bf215546Sopenharmony_ci bool tf_enabled; 461bf215546Sopenharmony_ci 462bf215546Sopenharmony_ci bool needs_primitives_generated; 463bf215546Sopenharmony_ci 464bf215546Sopenharmony_ci /** 465bf215546Sopenharmony_ci * Current EZ state for drawing. Updated at the start of draw after 466bf215546Sopenharmony_ci * we've decided on the shader being rendered. 467bf215546Sopenharmony_ci */ 468bf215546Sopenharmony_ci enum v3d_ez_state ez_state; 469bf215546Sopenharmony_ci /** 470bf215546Sopenharmony_ci * The first EZ state that was used for drawing with a decided EZ 471bf215546Sopenharmony_ci * direction (so either UNDECIDED, GT, or LT). 472bf215546Sopenharmony_ci */ 473bf215546Sopenharmony_ci enum v3d_ez_state first_ez_state; 474bf215546Sopenharmony_ci 475bf215546Sopenharmony_ci /** 476bf215546Sopenharmony_ci * If we have already decided if we need to disable early Z/S 477bf215546Sopenharmony_ci * completely for this job. 478bf215546Sopenharmony_ci */ 479bf215546Sopenharmony_ci bool decided_global_ez_enable; 480bf215546Sopenharmony_ci 481bf215546Sopenharmony_ci /** 482bf215546Sopenharmony_ci * If this job has been configured to use early Z/S clear. 483bf215546Sopenharmony_ci */ 484bf215546Sopenharmony_ci bool early_zs_clear; 485bf215546Sopenharmony_ci 486bf215546Sopenharmony_ci /** 487bf215546Sopenharmony_ci * Number of draw calls (not counting full buffer clears) queued in 488bf215546Sopenharmony_ci * the current job. 489bf215546Sopenharmony_ci */ 490bf215546Sopenharmony_ci uint32_t draw_calls_queued; 491bf215546Sopenharmony_ci 492bf215546Sopenharmony_ci /** 493bf215546Sopenharmony_ci * Number of draw calls (not counting full buffer clears) queued in 494bf215546Sopenharmony_ci * the current job during active transform feedback. 495bf215546Sopenharmony_ci */ 496bf215546Sopenharmony_ci uint32_t tf_draw_calls_queued; 497bf215546Sopenharmony_ci 498bf215546Sopenharmony_ci struct v3d_job_key key; 499bf215546Sopenharmony_ci}; 500bf215546Sopenharmony_ci 501bf215546Sopenharmony_cistruct v3d_context { 502bf215546Sopenharmony_ci struct pipe_context base; 503bf215546Sopenharmony_ci 504bf215546Sopenharmony_ci int fd; 505bf215546Sopenharmony_ci struct v3d_screen *screen; 506bf215546Sopenharmony_ci 507bf215546Sopenharmony_ci /** The 3D rendering job for the currently bound FBO. */ 508bf215546Sopenharmony_ci struct v3d_job *job; 509bf215546Sopenharmony_ci 510bf215546Sopenharmony_ci /* Map from struct v3d_job_key to the job for that FBO. 511bf215546Sopenharmony_ci */ 512bf215546Sopenharmony_ci struct hash_table *jobs; 513bf215546Sopenharmony_ci 514bf215546Sopenharmony_ci /** 515bf215546Sopenharmony_ci * Map from v3d_resource to a job writing to that resource. 516bf215546Sopenharmony_ci * 517bf215546Sopenharmony_ci * Primarily for flushing jobs rendering to textures that are now 518bf215546Sopenharmony_ci * being read from. 519bf215546Sopenharmony_ci */ 520bf215546Sopenharmony_ci struct hash_table *write_jobs; 521bf215546Sopenharmony_ci 522bf215546Sopenharmony_ci struct slab_child_pool transfer_pool; 523bf215546Sopenharmony_ci struct blitter_context *blitter; 524bf215546Sopenharmony_ci 525bf215546Sopenharmony_ci /** bitfield of V3D_DIRTY_* */ 526bf215546Sopenharmony_ci uint64_t dirty; 527bf215546Sopenharmony_ci 528bf215546Sopenharmony_ci uint32_t next_uncompiled_program_id; 529bf215546Sopenharmony_ci uint64_t next_compiled_program_id; 530bf215546Sopenharmony_ci 531bf215546Sopenharmony_ci struct v3d_compiler_state *compiler_state; 532bf215546Sopenharmony_ci 533bf215546Sopenharmony_ci uint8_t prim_mode; 534bf215546Sopenharmony_ci 535bf215546Sopenharmony_ci /** Maximum index buffer valid for the current shader_rec. */ 536bf215546Sopenharmony_ci uint32_t max_index; 537bf215546Sopenharmony_ci 538bf215546Sopenharmony_ci /** Sync object that our RCL or TFU job will update as its out_sync. */ 539bf215546Sopenharmony_ci uint32_t out_sync; 540bf215546Sopenharmony_ci 541bf215546Sopenharmony_ci /* Stream uploader used by gallium internals. This could also be used 542bf215546Sopenharmony_ci * by driver internals, but we tend to use the v3d_cl.h interfaces 543bf215546Sopenharmony_ci * instead. 544bf215546Sopenharmony_ci */ 545bf215546Sopenharmony_ci struct u_upload_mgr *uploader; 546bf215546Sopenharmony_ci /* State uploader used inside the driver. This is for packing bits of 547bf215546Sopenharmony_ci * long-term state inside buffers, since the kernel interfaces 548bf215546Sopenharmony_ci * allocate a page at a time. 549bf215546Sopenharmony_ci */ 550bf215546Sopenharmony_ci struct u_upload_mgr *state_uploader; 551bf215546Sopenharmony_ci 552bf215546Sopenharmony_ci struct pipe_shader_state *sand8_blit_vs; 553bf215546Sopenharmony_ci struct pipe_shader_state *sand8_blit_fs_luma; 554bf215546Sopenharmony_ci struct pipe_shader_state *sand8_blit_fs_chroma; 555bf215546Sopenharmony_ci 556bf215546Sopenharmony_ci /** @{ Current pipeline state objects */ 557bf215546Sopenharmony_ci struct pipe_scissor_state scissor; 558bf215546Sopenharmony_ci struct v3d_blend_state *blend; 559bf215546Sopenharmony_ci struct v3d_rasterizer_state *rasterizer; 560bf215546Sopenharmony_ci struct v3d_depth_stencil_alpha_state *zsa; 561bf215546Sopenharmony_ci 562bf215546Sopenharmony_ci struct v3d_program_stateobj prog; 563bf215546Sopenharmony_ci uint32_t compute_num_workgroups[3]; 564bf215546Sopenharmony_ci struct v3d_bo *compute_shared_memory; 565bf215546Sopenharmony_ci 566bf215546Sopenharmony_ci struct v3d_vertex_stateobj *vtx; 567bf215546Sopenharmony_ci 568bf215546Sopenharmony_ci struct { 569bf215546Sopenharmony_ci struct pipe_blend_color f; 570bf215546Sopenharmony_ci uint16_t hf[4]; 571bf215546Sopenharmony_ci } blend_color; 572bf215546Sopenharmony_ci struct pipe_stencil_ref stencil_ref; 573bf215546Sopenharmony_ci unsigned sample_mask; 574bf215546Sopenharmony_ci struct pipe_framebuffer_state framebuffer; 575bf215546Sopenharmony_ci 576bf215546Sopenharmony_ci /* Per render target, whether we should swap the R and B fields in the 577bf215546Sopenharmony_ci * shader's color output and in blending. If render targets disagree 578bf215546Sopenharmony_ci * on the R/B swap and use the constant color, then we would need to 579bf215546Sopenharmony_ci * fall back to in-shader blending. 580bf215546Sopenharmony_ci */ 581bf215546Sopenharmony_ci uint8_t swap_color_rb; 582bf215546Sopenharmony_ci 583bf215546Sopenharmony_ci /* Per render target, whether we should treat the dst alpha values as 584bf215546Sopenharmony_ci * one in blending. 585bf215546Sopenharmony_ci * 586bf215546Sopenharmony_ci * For RGBX formats, the tile buffer's alpha channel will be 587bf215546Sopenharmony_ci * undefined. 588bf215546Sopenharmony_ci */ 589bf215546Sopenharmony_ci uint8_t blend_dst_alpha_one; 590bf215546Sopenharmony_ci 591bf215546Sopenharmony_ci bool active_queries; 592bf215546Sopenharmony_ci 593bf215546Sopenharmony_ci /** 594bf215546Sopenharmony_ci * If a compute job writes a resource read by a non-compute stage we 595bf215546Sopenharmony_ci * should sync on the last compute job. 596bf215546Sopenharmony_ci */ 597bf215546Sopenharmony_ci bool sync_on_last_compute_job; 598bf215546Sopenharmony_ci 599bf215546Sopenharmony_ci uint32_t tf_prims_generated; 600bf215546Sopenharmony_ci uint32_t prims_generated; 601bf215546Sopenharmony_ci 602bf215546Sopenharmony_ci uint32_t n_primitives_generated_queries_in_flight; 603bf215546Sopenharmony_ci 604bf215546Sopenharmony_ci struct pipe_poly_stipple stipple; 605bf215546Sopenharmony_ci struct pipe_clip_state clip; 606bf215546Sopenharmony_ci struct pipe_viewport_state viewport; 607bf215546Sopenharmony_ci struct v3d_ssbo_stateobj ssbo[PIPE_SHADER_TYPES]; 608bf215546Sopenharmony_ci struct v3d_shaderimg_stateobj shaderimg[PIPE_SHADER_TYPES]; 609bf215546Sopenharmony_ci struct v3d_constbuf_stateobj constbuf[PIPE_SHADER_TYPES]; 610bf215546Sopenharmony_ci struct v3d_texture_stateobj tex[PIPE_SHADER_TYPES]; 611bf215546Sopenharmony_ci struct v3d_vertexbuf_stateobj vertexbuf; 612bf215546Sopenharmony_ci struct v3d_streamout_stateobj streamout; 613bf215546Sopenharmony_ci struct v3d_bo *current_oq; 614bf215546Sopenharmony_ci struct pipe_resource *prim_counts; 615bf215546Sopenharmony_ci uint32_t prim_counts_offset; 616bf215546Sopenharmony_ci struct util_debug_callback debug; 617bf215546Sopenharmony_ci struct v3d_perfmon_state *active_perfmon; 618bf215546Sopenharmony_ci struct v3d_perfmon_state *last_perfmon; 619bf215546Sopenharmony_ci /** @} */ 620bf215546Sopenharmony_ci}; 621bf215546Sopenharmony_ci 622bf215546Sopenharmony_cistruct v3d_rasterizer_state { 623bf215546Sopenharmony_ci struct pipe_rasterizer_state base; 624bf215546Sopenharmony_ci 625bf215546Sopenharmony_ci float point_size; 626bf215546Sopenharmony_ci 627bf215546Sopenharmony_ci uint8_t depth_offset[9]; 628bf215546Sopenharmony_ci uint8_t depth_offset_z16[9]; 629bf215546Sopenharmony_ci}; 630bf215546Sopenharmony_ci 631bf215546Sopenharmony_cistruct v3d_depth_stencil_alpha_state { 632bf215546Sopenharmony_ci struct pipe_depth_stencil_alpha_state base; 633bf215546Sopenharmony_ci 634bf215546Sopenharmony_ci enum v3d_ez_state ez_state; 635bf215546Sopenharmony_ci 636bf215546Sopenharmony_ci uint8_t stencil_front[6]; 637bf215546Sopenharmony_ci uint8_t stencil_back[6]; 638bf215546Sopenharmony_ci}; 639bf215546Sopenharmony_ci 640bf215546Sopenharmony_cistruct v3d_blend_state { 641bf215546Sopenharmony_ci struct pipe_blend_state base; 642bf215546Sopenharmony_ci 643bf215546Sopenharmony_ci /* Per-RT mask of whether blending is enabled. */ 644bf215546Sopenharmony_ci uint8_t blend_enables; 645bf215546Sopenharmony_ci}; 646bf215546Sopenharmony_ci 647bf215546Sopenharmony_ci#define perf_debug(...) do { \ 648bf215546Sopenharmony_ci if (unlikely(V3D_DEBUG & V3D_DEBUG_PERF)) \ 649bf215546Sopenharmony_ci fprintf(stderr, __VA_ARGS__); \ 650bf215546Sopenharmony_ci if (unlikely(v3d->debug.debug_message)) \ 651bf215546Sopenharmony_ci util_debug_message(&v3d->debug, PERF_INFO, __VA_ARGS__); \ 652bf215546Sopenharmony_ci} while (0) 653bf215546Sopenharmony_ci 654bf215546Sopenharmony_cistatic inline struct v3d_context * 655bf215546Sopenharmony_civ3d_context(struct pipe_context *pcontext) 656bf215546Sopenharmony_ci{ 657bf215546Sopenharmony_ci return (struct v3d_context *)pcontext; 658bf215546Sopenharmony_ci} 659bf215546Sopenharmony_ci 660bf215546Sopenharmony_cistatic inline struct v3d_sampler_view * 661bf215546Sopenharmony_civ3d_sampler_view(struct pipe_sampler_view *psview) 662bf215546Sopenharmony_ci{ 663bf215546Sopenharmony_ci return (struct v3d_sampler_view *)psview; 664bf215546Sopenharmony_ci} 665bf215546Sopenharmony_ci 666bf215546Sopenharmony_cistatic inline struct v3d_sampler_state * 667bf215546Sopenharmony_civ3d_sampler_state(struct pipe_sampler_state *psampler) 668bf215546Sopenharmony_ci{ 669bf215546Sopenharmony_ci return (struct v3d_sampler_state *)psampler; 670bf215546Sopenharmony_ci} 671bf215546Sopenharmony_ci 672bf215546Sopenharmony_cistatic inline struct v3d_stream_output_target * 673bf215546Sopenharmony_civ3d_stream_output_target(struct pipe_stream_output_target *ptarget) 674bf215546Sopenharmony_ci{ 675bf215546Sopenharmony_ci return (struct v3d_stream_output_target *)ptarget; 676bf215546Sopenharmony_ci} 677bf215546Sopenharmony_ci 678bf215546Sopenharmony_cistatic inline uint32_t 679bf215546Sopenharmony_civ3d_stream_output_target_get_vertex_count(struct pipe_stream_output_target *ptarget) 680bf215546Sopenharmony_ci{ 681bf215546Sopenharmony_ci return v3d_stream_output_target(ptarget)->recorded_vertex_count; 682bf215546Sopenharmony_ci} 683bf215546Sopenharmony_ci 684bf215546Sopenharmony_ciint v3d_get_driver_query_group_info(struct pipe_screen *pscreen, 685bf215546Sopenharmony_ci unsigned index, 686bf215546Sopenharmony_ci struct pipe_driver_query_group_info *info); 687bf215546Sopenharmony_ciint v3d_get_driver_query_info(struct pipe_screen *pscreen, unsigned index, 688bf215546Sopenharmony_ci struct pipe_driver_query_info *info); 689bf215546Sopenharmony_ci 690bf215546Sopenharmony_cistruct pipe_context *v3d_context_create(struct pipe_screen *pscreen, 691bf215546Sopenharmony_ci void *priv, unsigned flags); 692bf215546Sopenharmony_civoid v3d_program_init(struct pipe_context *pctx); 693bf215546Sopenharmony_civoid v3d_program_fini(struct pipe_context *pctx); 694bf215546Sopenharmony_civoid v3d_query_init(struct pipe_context *pctx); 695bf215546Sopenharmony_ci 696bf215546Sopenharmony_cistatic inline int 697bf215546Sopenharmony_civ3d_ioctl(int fd, unsigned long request, void *arg) 698bf215546Sopenharmony_ci{ 699bf215546Sopenharmony_ci if (using_v3d_simulator) 700bf215546Sopenharmony_ci return v3d_simulator_ioctl(fd, request, arg); 701bf215546Sopenharmony_ci else 702bf215546Sopenharmony_ci return drmIoctl(fd, request, arg); 703bf215546Sopenharmony_ci} 704bf215546Sopenharmony_ci 705bf215546Sopenharmony_cistatic inline bool 706bf215546Sopenharmony_civ3d_transform_feedback_enabled(struct v3d_context *v3d) 707bf215546Sopenharmony_ci{ 708bf215546Sopenharmony_ci return (v3d->prog.bind_vs->num_tf_specs != 0 || 709bf215546Sopenharmony_ci (v3d->prog.bind_gs && v3d->prog.bind_gs->num_tf_specs != 0)) && 710bf215546Sopenharmony_ci v3d->active_queries; 711bf215546Sopenharmony_ci} 712bf215546Sopenharmony_ci 713bf215546Sopenharmony_civoid v3d_set_shader_uniform_dirty_flags(struct v3d_compiled_shader *shader); 714bf215546Sopenharmony_cistruct v3d_cl_reloc v3d_write_uniforms(struct v3d_context *v3d, 715bf215546Sopenharmony_ci struct v3d_job *job, 716bf215546Sopenharmony_ci struct v3d_compiled_shader *shader, 717bf215546Sopenharmony_ci enum pipe_shader_type stage); 718bf215546Sopenharmony_ci 719bf215546Sopenharmony_civoid v3d_flush(struct pipe_context *pctx); 720bf215546Sopenharmony_civoid v3d_job_init(struct v3d_context *v3d); 721bf215546Sopenharmony_cistruct v3d_job *v3d_job_create(struct v3d_context *v3d); 722bf215546Sopenharmony_civoid v3d_job_free(struct v3d_context *v3d, struct v3d_job *job); 723bf215546Sopenharmony_cistruct v3d_job *v3d_get_job(struct v3d_context *v3d, 724bf215546Sopenharmony_ci uint32_t nr_cbufs, 725bf215546Sopenharmony_ci struct pipe_surface **cbufs, 726bf215546Sopenharmony_ci struct pipe_surface *zsbuf, 727bf215546Sopenharmony_ci struct pipe_surface *bbuf); 728bf215546Sopenharmony_cistruct v3d_job *v3d_get_job_for_fbo(struct v3d_context *v3d); 729bf215546Sopenharmony_civoid v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo); 730bf215546Sopenharmony_civoid v3d_job_add_write_resource(struct v3d_job *job, struct pipe_resource *prsc); 731bf215546Sopenharmony_civoid v3d_job_add_tf_write_resource(struct v3d_job *job, struct pipe_resource *prsc); 732bf215546Sopenharmony_civoid v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job); 733bf215546Sopenharmony_civoid v3d_flush_jobs_using_bo(struct v3d_context *v3d, struct v3d_bo *bo); 734bf215546Sopenharmony_civoid v3d_flush_jobs_writing_resource(struct v3d_context *v3d, 735bf215546Sopenharmony_ci struct pipe_resource *prsc, 736bf215546Sopenharmony_ci enum v3d_flush_cond flush_cond, 737bf215546Sopenharmony_ci bool is_compute_pipeline); 738bf215546Sopenharmony_civoid v3d_flush_jobs_reading_resource(struct v3d_context *v3d, 739bf215546Sopenharmony_ci struct pipe_resource *prsc, 740bf215546Sopenharmony_ci enum v3d_flush_cond flush_cond, 741bf215546Sopenharmony_ci bool is_compute_pipeline); 742bf215546Sopenharmony_civoid v3d_update_compiled_shaders(struct v3d_context *v3d, uint8_t prim_mode); 743bf215546Sopenharmony_civoid v3d_update_compiled_cs(struct v3d_context *v3d); 744bf215546Sopenharmony_ci 745bf215546Sopenharmony_cibool v3d_rt_format_supported(const struct v3d_device_info *devinfo, 746bf215546Sopenharmony_ci enum pipe_format f); 747bf215546Sopenharmony_cibool v3d_tex_format_supported(const struct v3d_device_info *devinfo, 748bf215546Sopenharmony_ci enum pipe_format f); 749bf215546Sopenharmony_ciuint8_t v3d_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f); 750bf215546Sopenharmony_ciuint8_t v3d_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f); 751bf215546Sopenharmony_ciuint8_t v3d_get_tex_return_size(const struct v3d_device_info *devinfo, 752bf215546Sopenharmony_ci enum pipe_format f, 753bf215546Sopenharmony_ci enum pipe_tex_compare compare); 754bf215546Sopenharmony_ciuint8_t v3d_get_tex_return_channels(const struct v3d_device_info *devinfo, 755bf215546Sopenharmony_ci enum pipe_format f); 756bf215546Sopenharmony_ciconst uint8_t *v3d_get_format_swizzle(const struct v3d_device_info *devinfo, 757bf215546Sopenharmony_ci enum pipe_format f); 758bf215546Sopenharmony_civoid v3d_get_internal_type_bpp_for_output_format(const struct v3d_device_info *devinfo, 759bf215546Sopenharmony_ci uint32_t format, 760bf215546Sopenharmony_ci uint32_t *type, 761bf215546Sopenharmony_ci uint32_t *bpp); 762bf215546Sopenharmony_cibool v3d_tfu_supports_tex_format(const struct v3d_device_info *devinfo, 763bf215546Sopenharmony_ci uint32_t tex_format, 764bf215546Sopenharmony_ci bool for_mipmap); 765bf215546Sopenharmony_cibool v3d_format_supports_tlb_msaa_resolve(const struct v3d_device_info *devinfo, 766bf215546Sopenharmony_ci enum pipe_format f); 767bf215546Sopenharmony_ci 768bf215546Sopenharmony_civoid v3d_init_query_functions(struct v3d_context *v3d); 769bf215546Sopenharmony_civoid v3d_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info); 770bf215546Sopenharmony_civoid v3d_blitter_save(struct v3d_context *v3d, bool op_blit); 771bf215546Sopenharmony_cibool v3d_generate_mipmap(struct pipe_context *pctx, 772bf215546Sopenharmony_ci struct pipe_resource *prsc, 773bf215546Sopenharmony_ci enum pipe_format format, 774bf215546Sopenharmony_ci unsigned int base_level, 775bf215546Sopenharmony_ci unsigned int last_level, 776bf215546Sopenharmony_ci unsigned int first_layer, 777bf215546Sopenharmony_ci unsigned int last_layer); 778bf215546Sopenharmony_ci 779bf215546Sopenharmony_civoid 780bf215546Sopenharmony_civ3d_fence_unreference(struct v3d_fence **fence); 781bf215546Sopenharmony_ci 782bf215546Sopenharmony_cistruct v3d_fence *v3d_fence_create(struct v3d_context *v3d); 783bf215546Sopenharmony_ci 784bf215546Sopenharmony_cibool v3d_fence_wait(struct v3d_screen *screen, 785bf215546Sopenharmony_ci struct v3d_fence *fence, 786bf215546Sopenharmony_ci uint64_t timeout_ns); 787bf215546Sopenharmony_ci 788bf215546Sopenharmony_civoid v3d_update_primitive_counters(struct v3d_context *v3d); 789bf215546Sopenharmony_ci 790bf215546Sopenharmony_cibool v3d_line_smoothing_enabled(struct v3d_context *v3d); 791bf215546Sopenharmony_ci 792bf215546Sopenharmony_cifloat v3d_get_real_line_width(struct v3d_context *v3d); 793bf215546Sopenharmony_ci 794bf215546Sopenharmony_civoid v3d_ensure_prim_counts_allocated(struct v3d_context *ctx); 795bf215546Sopenharmony_ci 796bf215546Sopenharmony_civoid v3d_flag_dirty_sampler_state(struct v3d_context *v3d, 797bf215546Sopenharmony_ci enum pipe_shader_type shader); 798bf215546Sopenharmony_ci 799bf215546Sopenharmony_civoid v3d_create_texture_shader_state_bo(struct v3d_context *v3d, 800bf215546Sopenharmony_ci struct v3d_sampler_view *so); 801bf215546Sopenharmony_ci 802bf215546Sopenharmony_civoid v3d_get_tile_buffer_size(bool is_msaa, 803bf215546Sopenharmony_ci bool double_buffer, 804bf215546Sopenharmony_ci uint32_t nr_cbufs, 805bf215546Sopenharmony_ci struct pipe_surface **cbufs, 806bf215546Sopenharmony_ci struct pipe_surface *bbuf, 807bf215546Sopenharmony_ci uint32_t *tile_width, 808bf215546Sopenharmony_ci uint32_t *tile_height, 809bf215546Sopenharmony_ci uint32_t *max_bpp); 810bf215546Sopenharmony_ci 811bf215546Sopenharmony_ci#ifdef ENABLE_SHADER_CACHE 812bf215546Sopenharmony_cistruct v3d_compiled_shader *v3d_disk_cache_retrieve(struct v3d_context *v3d, 813bf215546Sopenharmony_ci const struct v3d_key *key); 814bf215546Sopenharmony_ci 815bf215546Sopenharmony_civoid v3d_disk_cache_store(struct v3d_context *v3d, 816bf215546Sopenharmony_ci const struct v3d_key *key, 817bf215546Sopenharmony_ci const struct v3d_compiled_shader *shader, 818bf215546Sopenharmony_ci uint64_t *qpu_insts, 819bf215546Sopenharmony_ci uint32_t qpu_size); 820bf215546Sopenharmony_ci#endif /* ENABLE_SHADER_CACHE */ 821bf215546Sopenharmony_ci 822bf215546Sopenharmony_ci#ifdef v3dX 823bf215546Sopenharmony_ci# include "v3dx_context.h" 824bf215546Sopenharmony_ci#else 825bf215546Sopenharmony_ci# define v3dX(x) v3d33_##x 826bf215546Sopenharmony_ci# include "v3dx_context.h" 827bf215546Sopenharmony_ci# undef v3dX 828bf215546Sopenharmony_ci 829bf215546Sopenharmony_ci# define v3dX(x) v3d41_##x 830bf215546Sopenharmony_ci# include "v3dx_context.h" 831bf215546Sopenharmony_ci# undef v3dX 832bf215546Sopenharmony_ci#endif 833bf215546Sopenharmony_ci 834bf215546Sopenharmony_ci#endif /* V3D_CONTEXT_H */ 835