17ec681f3Smrg/* 27ec681f3Smrg * Copyright 2018 Collabora Ltd. 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub 87ec681f3Smrg * license, and/or sell copies of the Software, and to permit persons to whom 97ec681f3Smrg * the Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 197ec681f3Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 207ec681f3Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 217ec681f3Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef ZINK_PIPELINE_H 257ec681f3Smrg#define ZINK_PIPELINE_H 267ec681f3Smrg 277ec681f3Smrg#include <vulkan/vulkan.h> 287ec681f3Smrg 297ec681f3Smrg#include "pipe/p_state.h" 307ec681f3Smrg#include "zink_shader_keys.h" 317ec681f3Smrg#include "zink_state.h" 327ec681f3Smrg 337ec681f3Smrgstruct zink_blend_state; 347ec681f3Smrgstruct zink_depth_stencil_alpha_state; 357ec681f3Smrgstruct zink_gfx_program; 367ec681f3Smrgstruct zink_compute_program; 377ec681f3Smrgstruct zink_rasterizer_state; 387ec681f3Smrgstruct zink_render_pass; 397ec681f3Smrgstruct zink_screen; 407ec681f3Smrgstruct zink_vertex_elements_state; 417ec681f3Smrg 427ec681f3Smrgstruct zink_gfx_pipeline_state { 437ec681f3Smrg uint32_t rast_state : ZINK_RAST_HW_STATE_SIZE; //zink_rasterizer_hw_state 447ec681f3Smrg uint32_t vertices_per_patch:5; 457ec681f3Smrg uint32_t rast_samples:7; 467ec681f3Smrg uint32_t void_alpha_attachments:PIPE_MAX_COLOR_BUFS; 477ec681f3Smrg VkSampleMask sample_mask; 487ec681f3Smrg 497ec681f3Smrg unsigned rp_state; 507ec681f3Smrg uint32_t blend_id; 517ec681f3Smrg 527ec681f3Smrg /* Pre-hashed value for table lookup, invalid when zero. 537ec681f3Smrg * Members after this point are not included in pipeline state hash key */ 547ec681f3Smrg uint32_t hash; 557ec681f3Smrg bool dirty; 567ec681f3Smrg 577ec681f3Smrg struct { 587ec681f3Smrg struct zink_depth_stencil_alpha_hw_state *depth_stencil_alpha_state; //non-dynamic state 597ec681f3Smrg VkFrontFace front_face; 607ec681f3Smrg unsigned num_viewports; 617ec681f3Smrg } dyn_state1; 627ec681f3Smrg 637ec681f3Smrg bool primitive_restart; //dynamic state2 647ec681f3Smrg 657ec681f3Smrg VkShaderModule modules[PIPE_SHADER_TYPES - 1]; 667ec681f3Smrg bool modules_changed; 677ec681f3Smrg 687ec681f3Smrg struct zink_vertex_elements_hw_state *element_state; 697ec681f3Smrg uint32_t vertex_hash; 707ec681f3Smrg 717ec681f3Smrg uint32_t final_hash; 727ec681f3Smrg 737ec681f3Smrg uint32_t vertex_buffers_enabled_mask; 747ec681f3Smrg uint32_t vertex_strides[PIPE_MAX_ATTRIBS]; 757ec681f3Smrg bool sample_locations_enabled; 767ec681f3Smrg bool have_EXT_extended_dynamic_state; 777ec681f3Smrg bool have_EXT_extended_dynamic_state2; 787ec681f3Smrg uint8_t has_points; //either gs outputs points or prim type is points 797ec681f3Smrg struct { 807ec681f3Smrg struct zink_shader_key key[5]; 817ec681f3Smrg struct zink_shader_key last_vertex; 827ec681f3Smrg } shader_keys; 837ec681f3Smrg struct zink_blend_state *blend_state; 847ec681f3Smrg struct zink_render_pass *render_pass; 857ec681f3Smrg VkPipeline pipeline; 867ec681f3Smrg uint8_t patch_vertices; 877ec681f3Smrg unsigned idx : 8; 887ec681f3Smrg enum pipe_prim_type gfx_prim_mode; //pending mode 897ec681f3Smrg}; 907ec681f3Smrg 917ec681f3Smrgstruct zink_compute_pipeline_state { 927ec681f3Smrg /* Pre-hashed value for table lookup, invalid when zero. 937ec681f3Smrg * Members after this point are not included in pipeline state hash key */ 947ec681f3Smrg uint32_t hash; 957ec681f3Smrg bool dirty; 967ec681f3Smrg bool use_local_size; 977ec681f3Smrg uint32_t local_size[3]; 987ec681f3Smrg 997ec681f3Smrg VkPipeline pipeline; 1007ec681f3Smrg}; 1017ec681f3Smrg 1027ec681f3SmrgVkPipeline 1037ec681f3Smrgzink_create_gfx_pipeline(struct zink_screen *screen, 1047ec681f3Smrg struct zink_gfx_program *prog, 1057ec681f3Smrg struct zink_gfx_pipeline_state *state, 1067ec681f3Smrg VkPrimitiveTopology primitive_topology); 1077ec681f3Smrg 1087ec681f3SmrgVkPipeline 1097ec681f3Smrgzink_create_compute_pipeline(struct zink_screen *screen, struct zink_compute_program *comp, struct zink_compute_pipeline_state *state); 1107ec681f3Smrg#endif 111