1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2018 Collabora Ltd. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef ZINK_PROGRAM_H 25bf215546Sopenharmony_ci#define ZINK_PROGRAM_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <vulkan/vulkan.h> 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 30bf215546Sopenharmony_ci#include "pipe/p_state.h" 31bf215546Sopenharmony_ci#include "util/u_inlines.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#include "zink_context.h" 34bf215546Sopenharmony_ci#include "zink_compiler.h" 35bf215546Sopenharmony_ci#include "zink_shader_keys.h" 36bf215546Sopenharmony_ci#ifdef __cplusplus 37bf215546Sopenharmony_ciextern "C" { 38bf215546Sopenharmony_ci#endif 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cistruct zink_screen; 41bf215546Sopenharmony_cistruct zink_shader; 42bf215546Sopenharmony_cistruct zink_gfx_pipeline_state; 43bf215546Sopenharmony_cistruct zink_descriptor_set; 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_cistruct hash_table; 46bf215546Sopenharmony_cistruct set; 47bf215546Sopenharmony_cistruct util_dynarray; 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_cistruct zink_program; 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_cistruct zink_gfx_push_constant { 52bf215546Sopenharmony_ci unsigned draw_mode_is_indexed; 53bf215546Sopenharmony_ci unsigned draw_id; 54bf215546Sopenharmony_ci float default_inner_level[2]; 55bf215546Sopenharmony_ci float default_outer_level[4]; 56bf215546Sopenharmony_ci}; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cistruct zink_cs_push_constant { 59bf215546Sopenharmony_ci unsigned work_dim; 60bf215546Sopenharmony_ci}; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci/* a shader module is used for directly reusing a shader module between programs, 63bf215546Sopenharmony_ci * e.g., in the case where we're swapping out only one shader, 64bf215546Sopenharmony_ci * allowing us to skip going through shader keys 65bf215546Sopenharmony_ci */ 66bf215546Sopenharmony_cistruct zink_shader_module { 67bf215546Sopenharmony_ci struct list_head list; 68bf215546Sopenharmony_ci VkShaderModule shader; 69bf215546Sopenharmony_ci uint32_t hash; 70bf215546Sopenharmony_ci bool default_variant; 71bf215546Sopenharmony_ci bool has_nonseamless; 72bf215546Sopenharmony_ci uint8_t num_uniforms; 73bf215546Sopenharmony_ci uint8_t key_size; 74bf215546Sopenharmony_ci uint8_t key[0]; /* | key | uniforms | */ 75bf215546Sopenharmony_ci}; 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_cistruct zink_program { 78bf215546Sopenharmony_ci struct pipe_reference reference; 79bf215546Sopenharmony_ci unsigned char sha1[20]; 80bf215546Sopenharmony_ci struct util_queue_fence cache_fence; 81bf215546Sopenharmony_ci VkPipelineCache pipeline_cache; 82bf215546Sopenharmony_ci size_t pipeline_cache_size; 83bf215546Sopenharmony_ci struct zink_batch_usage *batch_uses; 84bf215546Sopenharmony_ci bool is_compute; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci struct zink_program_descriptor_data *dd; 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci uint32_t compat_id; 89bf215546Sopenharmony_ci VkPipelineLayout layout; 90bf215546Sopenharmony_ci VkDescriptorSetLayout dsl[ZINK_DESCRIPTOR_TYPES + 2]; // one for each type + push + bindless 91bf215546Sopenharmony_ci unsigned num_dsl; 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ci bool removed; 94bf215546Sopenharmony_ci}; 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_ci#define ZINK_MAX_INLINED_VARIANTS 5 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_cistruct zink_gfx_program { 99bf215546Sopenharmony_ci struct zink_program base; 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci uint32_t stages_present; //mask of stages present in this program 102bf215546Sopenharmony_ci struct nir_shader *nir[ZINK_SHADER_COUNT]; 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci struct zink_shader_module *modules[ZINK_SHADER_COUNT]; // compute stage doesn't belong here 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_ci struct zink_shader *last_vertex_stage; 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci struct list_head shader_cache[ZINK_SHADER_COUNT][2][2]; //normal, nonseamless cubes, inline uniforms 109bf215546Sopenharmony_ci unsigned inlined_variant_count[ZINK_SHADER_COUNT]; 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ci struct zink_shader *shaders[ZINK_SHADER_COUNT]; 112bf215546Sopenharmony_ci struct hash_table pipelines[11]; // number of draw modes we support 113bf215546Sopenharmony_ci uint32_t default_variant_hash; 114bf215546Sopenharmony_ci uint32_t last_variant_hash; 115bf215546Sopenharmony_ci}; 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_cistruct zink_compute_program { 118bf215546Sopenharmony_ci struct zink_program base; 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci struct zink_shader_module *curr; 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_ci struct zink_shader_module *module; //base 123bf215546Sopenharmony_ci struct list_head shader_cache[2]; //nonseamless cubes, inline uniforms 124bf215546Sopenharmony_ci unsigned inlined_variant_count; 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci struct zink_shader *shader; 127bf215546Sopenharmony_ci struct hash_table *pipelines; 128bf215546Sopenharmony_ci}; 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_cistatic inline enum zink_descriptor_type 131bf215546Sopenharmony_cizink_desc_type_from_vktype(VkDescriptorType type) 132bf215546Sopenharmony_ci{ 133bf215546Sopenharmony_ci switch (type) { 134bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: 135bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: 136bf215546Sopenharmony_ci return ZINK_DESCRIPTOR_TYPE_UBO; 137bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: 138bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: 139bf215546Sopenharmony_ci return ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW; 140bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: 141bf215546Sopenharmony_ci return ZINK_DESCRIPTOR_TYPE_SSBO; 142bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: 143bf215546Sopenharmony_ci case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: 144bf215546Sopenharmony_ci return ZINK_DESCRIPTOR_TYPE_IMAGE; 145bf215546Sopenharmony_ci default: 146bf215546Sopenharmony_ci unreachable("unhandled descriptor type"); 147bf215546Sopenharmony_ci } 148bf215546Sopenharmony_ci} 149bf215546Sopenharmony_ci 150bf215546Sopenharmony_cistatic inline VkPrimitiveTopology 151bf215546Sopenharmony_cizink_primitive_topology(enum pipe_prim_type mode) 152bf215546Sopenharmony_ci{ 153bf215546Sopenharmony_ci switch (mode) { 154bf215546Sopenharmony_ci case PIPE_PRIM_POINTS: 155bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; 156bf215546Sopenharmony_ci 157bf215546Sopenharmony_ci case PIPE_PRIM_LINES: 158bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_LINE_LIST; 159bf215546Sopenharmony_ci 160bf215546Sopenharmony_ci case PIPE_PRIM_LINE_STRIP: 161bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci case PIPE_PRIM_TRIANGLES: 164bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; 165bf215546Sopenharmony_ci 166bf215546Sopenharmony_ci case PIPE_PRIM_TRIANGLE_STRIP: 167bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_ci case PIPE_PRIM_TRIANGLE_FAN: 170bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN; 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_ci case PIPE_PRIM_LINE_STRIP_ADJACENCY: 173bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY; 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_ci case PIPE_PRIM_LINES_ADJACENCY: 176bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY; 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_ci case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: 179bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY; 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ci case PIPE_PRIM_TRIANGLES_ADJACENCY: 182bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY; 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci case PIPE_PRIM_PATCHES: 185bf215546Sopenharmony_ci return VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_ci default: 188bf215546Sopenharmony_ci unreachable("unexpected enum pipe_prim_type"); 189bf215546Sopenharmony_ci } 190bf215546Sopenharmony_ci} 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_civoid 193bf215546Sopenharmony_cizink_delete_shader_state(struct pipe_context *pctx, void *cso); 194bf215546Sopenharmony_civoid * 195bf215546Sopenharmony_cizink_create_gfx_shader_state(struct pipe_context *pctx, const struct pipe_shader_state *shader); 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ciunsigned 198bf215546Sopenharmony_cizink_program_num_bindings_typed(const struct zink_program *pg, enum zink_descriptor_type type, bool is_compute); 199bf215546Sopenharmony_ci 200bf215546Sopenharmony_ciunsigned 201bf215546Sopenharmony_cizink_program_num_bindings(const struct zink_program *pg, bool is_compute); 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_cibool 204bf215546Sopenharmony_cizink_program_descriptor_is_buffer(struct zink_context *ctx, enum pipe_shader_type stage, enum zink_descriptor_type type, unsigned i); 205bf215546Sopenharmony_ci 206bf215546Sopenharmony_civoid 207bf215546Sopenharmony_cizink_update_gfx_program(struct zink_context *ctx, struct zink_gfx_program *prog); 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_cistruct zink_gfx_program * 210bf215546Sopenharmony_cizink_create_gfx_program(struct zink_context *ctx, 211bf215546Sopenharmony_ci struct zink_shader *stages[ZINK_SHADER_COUNT], 212bf215546Sopenharmony_ci unsigned vertices_per_patch); 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_civoid 215bf215546Sopenharmony_cizink_destroy_gfx_program(struct zink_context *ctx, 216bf215546Sopenharmony_ci struct zink_gfx_program *prog); 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ciVkPipeline 219bf215546Sopenharmony_cizink_get_gfx_pipeline(struct zink_context *ctx, 220bf215546Sopenharmony_ci struct zink_gfx_program *prog, 221bf215546Sopenharmony_ci struct zink_gfx_pipeline_state *state, 222bf215546Sopenharmony_ci enum pipe_prim_type mode); 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_civoid 225bf215546Sopenharmony_cizink_program_init(struct zink_context *ctx); 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ciuint32_t 228bf215546Sopenharmony_cizink_program_get_descriptor_usage(struct zink_context *ctx, enum pipe_shader_type stage, enum zink_descriptor_type type); 229bf215546Sopenharmony_ci 230bf215546Sopenharmony_civoid 231bf215546Sopenharmony_cidebug_describe_zink_gfx_program(char* buf, const struct zink_gfx_program *ptr); 232bf215546Sopenharmony_ci 233bf215546Sopenharmony_cistatic inline bool 234bf215546Sopenharmony_cizink_gfx_program_reference(struct zink_context *ctx, 235bf215546Sopenharmony_ci struct zink_gfx_program **dst, 236bf215546Sopenharmony_ci struct zink_gfx_program *src) 237bf215546Sopenharmony_ci{ 238bf215546Sopenharmony_ci struct zink_gfx_program *old_dst = dst ? *dst : NULL; 239bf215546Sopenharmony_ci bool ret = false; 240bf215546Sopenharmony_ci 241bf215546Sopenharmony_ci if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL, &src->base.reference, 242bf215546Sopenharmony_ci (debug_reference_descriptor)debug_describe_zink_gfx_program)) { 243bf215546Sopenharmony_ci zink_destroy_gfx_program(ctx, old_dst); 244bf215546Sopenharmony_ci ret = true; 245bf215546Sopenharmony_ci } 246bf215546Sopenharmony_ci if (dst) *dst = src; 247bf215546Sopenharmony_ci return ret; 248bf215546Sopenharmony_ci} 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_cistruct zink_compute_program * 251bf215546Sopenharmony_cizink_create_compute_program(struct zink_context *ctx, struct zink_shader *shader); 252bf215546Sopenharmony_civoid 253bf215546Sopenharmony_cizink_destroy_compute_program(struct zink_context *ctx, 254bf215546Sopenharmony_ci struct zink_compute_program *comp); 255bf215546Sopenharmony_ci 256bf215546Sopenharmony_civoid 257bf215546Sopenharmony_cidebug_describe_zink_compute_program(char* buf, const struct zink_compute_program *ptr); 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_cistatic inline bool 260bf215546Sopenharmony_cizink_compute_program_reference(struct zink_context *ctx, 261bf215546Sopenharmony_ci struct zink_compute_program **dst, 262bf215546Sopenharmony_ci struct zink_compute_program *src) 263bf215546Sopenharmony_ci{ 264bf215546Sopenharmony_ci struct zink_compute_program *old_dst = dst ? *dst : NULL; 265bf215546Sopenharmony_ci bool ret = false; 266bf215546Sopenharmony_ci 267bf215546Sopenharmony_ci if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL, &src->base.reference, 268bf215546Sopenharmony_ci (debug_reference_descriptor)debug_describe_zink_compute_program)) { 269bf215546Sopenharmony_ci zink_destroy_compute_program(ctx, old_dst); 270bf215546Sopenharmony_ci ret = true; 271bf215546Sopenharmony_ci } 272bf215546Sopenharmony_ci if (dst) *dst = src; 273bf215546Sopenharmony_ci return ret; 274bf215546Sopenharmony_ci} 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_cistatic inline bool 277bf215546Sopenharmony_cizink_program_reference(struct zink_context *ctx, 278bf215546Sopenharmony_ci struct zink_program **dst, 279bf215546Sopenharmony_ci struct zink_program *src) 280bf215546Sopenharmony_ci{ 281bf215546Sopenharmony_ci struct zink_program *pg = src ? src : dst ? *dst : NULL; 282bf215546Sopenharmony_ci if (!pg) 283bf215546Sopenharmony_ci return false; 284bf215546Sopenharmony_ci if (pg->is_compute) { 285bf215546Sopenharmony_ci struct zink_compute_program *comp = (struct zink_compute_program*)pg; 286bf215546Sopenharmony_ci return zink_compute_program_reference(ctx, &comp, NULL); 287bf215546Sopenharmony_ci } else { 288bf215546Sopenharmony_ci struct zink_gfx_program *prog = (struct zink_gfx_program*)pg; 289bf215546Sopenharmony_ci return zink_gfx_program_reference(ctx, &prog, NULL); 290bf215546Sopenharmony_ci } 291bf215546Sopenharmony_ci} 292bf215546Sopenharmony_ci 293bf215546Sopenharmony_ciVkPipelineLayout 294bf215546Sopenharmony_cizink_pipeline_layout_create(struct zink_screen *screen, struct zink_program *pg, uint32_t *compat); 295bf215546Sopenharmony_ci 296bf215546Sopenharmony_civoid 297bf215546Sopenharmony_cizink_program_update_compute_pipeline_state(struct zink_context *ctx, struct zink_compute_program *comp, const uint block[3]); 298bf215546Sopenharmony_civoid 299bf215546Sopenharmony_cizink_update_compute_program(struct zink_context *ctx); 300bf215546Sopenharmony_ciVkPipeline 301bf215546Sopenharmony_cizink_get_compute_pipeline(struct zink_screen *screen, 302bf215546Sopenharmony_ci struct zink_compute_program *comp, 303bf215546Sopenharmony_ci struct zink_compute_pipeline_state *state); 304bf215546Sopenharmony_ci 305bf215546Sopenharmony_cistatic inline bool 306bf215546Sopenharmony_cizink_program_has_descriptors(const struct zink_program *pg) 307bf215546Sopenharmony_ci{ 308bf215546Sopenharmony_ci return pg->num_dsl > 0; 309bf215546Sopenharmony_ci} 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_cistatic inline struct zink_fs_key * 312bf215546Sopenharmony_cizink_set_fs_key(struct zink_context *ctx) 313bf215546Sopenharmony_ci{ 314bf215546Sopenharmony_ci ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_FRAGMENT); 315bf215546Sopenharmony_ci return (struct zink_fs_key *)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_FRAGMENT]; 316bf215546Sopenharmony_ci} 317bf215546Sopenharmony_ci 318bf215546Sopenharmony_cistatic inline const struct zink_fs_key * 319bf215546Sopenharmony_cizink_get_fs_key(struct zink_context *ctx) 320bf215546Sopenharmony_ci{ 321bf215546Sopenharmony_ci return (const struct zink_fs_key *)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_FRAGMENT]; 322bf215546Sopenharmony_ci} 323bf215546Sopenharmony_ci 324bf215546Sopenharmony_cistatic inline bool 325bf215546Sopenharmony_cizink_set_tcs_key_patches(struct zink_context *ctx, uint8_t patch_vertices) 326bf215546Sopenharmony_ci{ 327bf215546Sopenharmony_ci struct zink_tcs_key *tcs = (struct zink_tcs_key*)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_TESS_CTRL]; 328bf215546Sopenharmony_ci if (tcs->patch_vertices == patch_vertices) 329bf215546Sopenharmony_ci return false; 330bf215546Sopenharmony_ci ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_TESS_CTRL); 331bf215546Sopenharmony_ci tcs->patch_vertices = patch_vertices; 332bf215546Sopenharmony_ci return true; 333bf215546Sopenharmony_ci} 334bf215546Sopenharmony_ci 335bf215546Sopenharmony_cistatic inline const struct zink_tcs_key * 336bf215546Sopenharmony_cizink_get_tcs_key(struct zink_context *ctx) 337bf215546Sopenharmony_ci{ 338bf215546Sopenharmony_ci return (const struct zink_tcs_key *)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_TESS_CTRL]; 339bf215546Sopenharmony_ci} 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_civoid 342bf215546Sopenharmony_cizink_update_fs_key_samples(struct zink_context *ctx); 343bf215546Sopenharmony_ci 344bf215546Sopenharmony_cistatic inline struct zink_vs_key * 345bf215546Sopenharmony_cizink_set_vs_key(struct zink_context *ctx) 346bf215546Sopenharmony_ci{ 347bf215546Sopenharmony_ci ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_VERTEX); 348bf215546Sopenharmony_ci return (struct zink_vs_key *)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_VERTEX]; 349bf215546Sopenharmony_ci} 350bf215546Sopenharmony_ci 351bf215546Sopenharmony_cistatic inline const struct zink_vs_key * 352bf215546Sopenharmony_cizink_get_vs_key(struct zink_context *ctx) 353bf215546Sopenharmony_ci{ 354bf215546Sopenharmony_ci return (const struct zink_vs_key *)&ctx->gfx_pipeline_state.shader_keys.key[PIPE_SHADER_VERTEX]; 355bf215546Sopenharmony_ci} 356bf215546Sopenharmony_ci 357bf215546Sopenharmony_cistatic inline struct zink_vs_key_base * 358bf215546Sopenharmony_cizink_set_last_vertex_key(struct zink_context *ctx) 359bf215546Sopenharmony_ci{ 360bf215546Sopenharmony_ci ctx->last_vertex_stage_dirty = true; 361bf215546Sopenharmony_ci return (struct zink_vs_key_base *)&ctx->gfx_pipeline_state.shader_keys.last_vertex; 362bf215546Sopenharmony_ci} 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_cistatic inline const struct zink_vs_key_base * 365bf215546Sopenharmony_cizink_get_last_vertex_key(struct zink_context *ctx) 366bf215546Sopenharmony_ci{ 367bf215546Sopenharmony_ci return (const struct zink_vs_key_base *)&ctx->gfx_pipeline_state.shader_keys.last_vertex; 368bf215546Sopenharmony_ci} 369bf215546Sopenharmony_ci 370bf215546Sopenharmony_cistatic inline void 371bf215546Sopenharmony_cizink_set_fs_point_coord_key(struct zink_context *ctx) 372bf215546Sopenharmony_ci{ 373bf215546Sopenharmony_ci const struct zink_fs_key *fs = zink_get_fs_key(ctx); 374bf215546Sopenharmony_ci bool disable = !ctx->gfx_pipeline_state.has_points || !ctx->rast_state->base.sprite_coord_enable; 375bf215546Sopenharmony_ci uint8_t coord_replace_bits = disable ? 0 : ctx->rast_state->base.sprite_coord_enable; 376bf215546Sopenharmony_ci bool coord_replace_yinvert = disable ? false : !!ctx->rast_state->base.sprite_coord_mode; 377bf215546Sopenharmony_ci if (fs->coord_replace_bits != coord_replace_bits || fs->coord_replace_yinvert != coord_replace_yinvert) { 378bf215546Sopenharmony_ci zink_set_fs_key(ctx)->coord_replace_bits = coord_replace_bits; 379bf215546Sopenharmony_ci zink_set_fs_key(ctx)->coord_replace_yinvert = coord_replace_yinvert; 380bf215546Sopenharmony_ci } 381bf215546Sopenharmony_ci} 382bf215546Sopenharmony_ci 383bf215546Sopenharmony_cibool 384bf215546Sopenharmony_cizink_set_rasterizer_discard(struct zink_context *ctx, bool disable); 385bf215546Sopenharmony_ci 386bf215546Sopenharmony_ci#ifdef __cplusplus 387bf215546Sopenharmony_ci} 388bf215546Sopenharmony_ci#endif 389bf215546Sopenharmony_ci 390bf215546Sopenharmony_ci#endif 391