1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © Microsoft Corporation 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 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * 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 NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef D3D12_PIPELINE_STATE_H 25bf215546Sopenharmony_ci#define D3D12_PIPELINE_STATE_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "pipe/p_state.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "d3d12_common.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_cistruct d3d12_context; 32bf215546Sopenharmony_cistruct d3d12_root_signature; 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_cistruct d3d12_vertex_elements_state { 35bf215546Sopenharmony_ci D3D12_INPUT_ELEMENT_DESC elements[PIPE_MAX_ATTRIBS]; 36bf215546Sopenharmony_ci enum pipe_format format_conversion[PIPE_MAX_ATTRIBS]; 37bf215546Sopenharmony_ci unsigned num_elements:6; // <= PIPE_MAX_ATTRIBS 38bf215546Sopenharmony_ci unsigned needs_format_emulation:1; 39bf215546Sopenharmony_ci unsigned unused:25; 40bf215546Sopenharmony_ci}; 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_cistruct d3d12_rasterizer_state { 43bf215546Sopenharmony_ci struct pipe_rasterizer_state base; 44bf215546Sopenharmony_ci D3D12_RASTERIZER_DESC desc; 45bf215546Sopenharmony_ci void *twoface_back; 46bf215546Sopenharmony_ci}; 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_cistruct d3d12_blend_state { 49bf215546Sopenharmony_ci D3D12_BLEND_DESC desc; 50bf215546Sopenharmony_ci unsigned blend_factor_flags; 51bf215546Sopenharmony_ci bool is_dual_src; 52bf215546Sopenharmony_ci}; 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_cistruct d3d12_depth_stencil_alpha_state { 55bf215546Sopenharmony_ci D3D12_DEPTH_STENCIL_DESC desc; 56bf215546Sopenharmony_ci}; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cistruct d3d12_gfx_pipeline_state { 59bf215546Sopenharmony_ci ID3D12RootSignature *root_signature; 60bf215546Sopenharmony_ci struct d3d12_shader *stages[PIPE_SHADER_TYPES - 1]; 61bf215546Sopenharmony_ci struct pipe_stream_output_info so_info; 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci struct d3d12_vertex_elements_state *ves; 64bf215546Sopenharmony_ci struct d3d12_blend_state *blend; 65bf215546Sopenharmony_ci struct d3d12_depth_stencil_alpha_state *zsa; 66bf215546Sopenharmony_ci struct d3d12_rasterizer_state *rast; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci unsigned samples; 69bf215546Sopenharmony_ci unsigned sample_mask; 70bf215546Sopenharmony_ci unsigned num_cbufs; 71bf215546Sopenharmony_ci unsigned num_so_targets; 72bf215546Sopenharmony_ci bool has_float_rtv; 73bf215546Sopenharmony_ci DXGI_FORMAT rtv_formats[8]; 74bf215546Sopenharmony_ci DXGI_FORMAT dsv_format; 75bf215546Sopenharmony_ci D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ib_strip_cut_value; 76bf215546Sopenharmony_ci enum pipe_prim_type prim_type; 77bf215546Sopenharmony_ci}; 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_cistruct d3d12_compute_pipeline_state { 80bf215546Sopenharmony_ci ID3D12RootSignature *root_signature; 81bf215546Sopenharmony_ci struct d3d12_shader *stage; 82bf215546Sopenharmony_ci}; 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ciDXGI_FORMAT 85bf215546Sopenharmony_cid3d12_rtv_format(struct d3d12_context *ctx, unsigned index); 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_civoid 88bf215546Sopenharmony_cid3d12_gfx_pipeline_state_cache_init(struct d3d12_context *ctx); 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_civoid 91bf215546Sopenharmony_cid3d12_gfx_pipeline_state_cache_destroy(struct d3d12_context *ctx); 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ciID3D12PipelineState * 94bf215546Sopenharmony_cid3d12_get_gfx_pipeline_state(struct d3d12_context *ctx); 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_civoid 97bf215546Sopenharmony_cid3d12_gfx_pipeline_state_cache_invalidate(struct d3d12_context *ctx, const void *state); 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_civoid 100bf215546Sopenharmony_cid3d12_gfx_pipeline_state_cache_invalidate_shader(struct d3d12_context *ctx, 101bf215546Sopenharmony_ci enum pipe_shader_type stage, 102bf215546Sopenharmony_ci struct d3d12_shader_selector *selector); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_civoid 105bf215546Sopenharmony_cid3d12_compute_pipeline_state_cache_init(struct d3d12_context *ctx); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_civoid 108bf215546Sopenharmony_cid3d12_compute_pipeline_state_cache_destroy(struct d3d12_context *ctx); 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_ciID3D12PipelineState * 111bf215546Sopenharmony_cid3d12_get_compute_pipeline_state(struct d3d12_context *ctx); 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_civoid 114bf215546Sopenharmony_cid3d12_compute_pipeline_state_cache_invalidate_shader(struct d3d12_context *ctx, 115bf215546Sopenharmony_ci struct d3d12_shader_selector *selector); 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_ci#endif 118