1 /* 2 * Copyright © Microsoft Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef D3D12_PIPELINE_STATE_H 25 #define D3D12_PIPELINE_STATE_H 26 27 #include "pipe/p_state.h" 28 29 #include "d3d12_common.h" 30 31 struct d3d12_context; 32 struct d3d12_root_signature; 33 34 struct d3d12_vertex_elements_state { 35 D3D12_INPUT_ELEMENT_DESC elements[PIPE_MAX_ATTRIBS]; 36 enum pipe_format format_conversion[PIPE_MAX_ATTRIBS]; 37 unsigned num_elements:6; // <= PIPE_MAX_ATTRIBS 38 unsigned needs_format_emulation:1; 39 unsigned unused:25; 40 }; 41 42 struct d3d12_rasterizer_state { 43 struct pipe_rasterizer_state base; 44 D3D12_RASTERIZER_DESC desc; 45 void *twoface_back; 46 }; 47 48 struct d3d12_blend_state { 49 D3D12_BLEND_DESC desc; 50 unsigned blend_factor_flags; 51 bool is_dual_src; 52 }; 53 54 struct d3d12_depth_stencil_alpha_state { 55 D3D12_DEPTH_STENCIL_DESC desc; 56 }; 57 58 struct d3d12_gfx_pipeline_state { 59 ID3D12RootSignature *root_signature; 60 struct d3d12_shader *stages[PIPE_SHADER_TYPES - 1]; 61 struct pipe_stream_output_info so_info; 62 63 struct d3d12_vertex_elements_state *ves; 64 struct d3d12_blend_state *blend; 65 struct d3d12_depth_stencil_alpha_state *zsa; 66 struct d3d12_rasterizer_state *rast; 67 68 unsigned samples; 69 unsigned sample_mask; 70 unsigned num_cbufs; 71 unsigned num_so_targets; 72 bool has_float_rtv; 73 DXGI_FORMAT rtv_formats[8]; 74 DXGI_FORMAT dsv_format; 75 D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ib_strip_cut_value; 76 enum pipe_prim_type prim_type; 77 }; 78 79 struct d3d12_compute_pipeline_state { 80 ID3D12RootSignature *root_signature; 81 struct d3d12_shader *stage; 82 }; 83 84 DXGI_FORMAT 85 d3d12_rtv_format(struct d3d12_context *ctx, unsigned index); 86 87 void 88 d3d12_gfx_pipeline_state_cache_init(struct d3d12_context *ctx); 89 90 void 91 d3d12_gfx_pipeline_state_cache_destroy(struct d3d12_context *ctx); 92 93 ID3D12PipelineState * 94 d3d12_get_gfx_pipeline_state(struct d3d12_context *ctx); 95 96 void 97 d3d12_gfx_pipeline_state_cache_invalidate(struct d3d12_context *ctx, const void *state); 98 99 void 100 d3d12_gfx_pipeline_state_cache_invalidate_shader(struct d3d12_context *ctx, 101 enum pipe_shader_type stage, 102 struct d3d12_shader_selector *selector); 103 104 void 105 d3d12_compute_pipeline_state_cache_init(struct d3d12_context *ctx); 106 107 void 108 d3d12_compute_pipeline_state_cache_destroy(struct d3d12_context *ctx); 109 110 ID3D12PipelineState * 111 d3d12_get_compute_pipeline_state(struct d3d12_context *ctx); 112 113 void 114 d3d12_compute_pipeline_state_cache_invalidate_shader(struct d3d12_context *ctx, 115 struct d3d12_shader_selector *selector); 116 117 #endif 118