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 #ifdef _GAMING_XBOX 32 typedef D3D12_DEPTH_STENCIL_DESC1 d3d12_depth_stencil_desc_type; 33 #else 34 typedef D3D12_DEPTH_STENCIL_DESC2 d3d12_depth_stencil_desc_type; 35 #endif 36 37 struct d3d12_context; 38 struct d3d12_root_signature; 39 40 struct d3d12_vertex_elements_state { 41 D3D12_INPUT_ELEMENT_DESC elements[PIPE_MAX_ATTRIBS]; 42 enum pipe_format format_conversion[PIPE_MAX_ATTRIBS]; 43 uint16_t strides[PIPE_MAX_ATTRIBS]; 44 unsigned num_elements:6; // <= PIPE_MAX_ATTRIBS 45 unsigned num_buffers:6; // <= PIPE_MAX_ATTRIBS 46 unsigned needs_format_emulation:1; 47 unsigned unused:19; 48 }; 49 50 struct d3d12_rasterizer_state { 51 struct pipe_rasterizer_state base; 52 D3D12_RASTERIZER_DESC desc; 53 void *twoface_back; 54 }; 55 56 struct d3d12_blend_state { 57 D3D12_BLEND_DESC desc; 58 unsigned blend_factor_flags; 59 bool is_dual_src; 60 }; 61 62 struct d3d12_depth_stencil_alpha_state { 63 d3d12_depth_stencil_desc_type desc; 64 bool backface_enabled; 65 }; 66 67 struct d3d12_gfx_pipeline_state { 68 ID3D12RootSignature *root_signature; 69 struct d3d12_shader *stages[PIPE_SHADER_TYPES - 1]; 70 struct pipe_stream_output_info so_info; 71 72 struct d3d12_vertex_elements_state *ves; 73 struct d3d12_blend_state *blend; 74 struct d3d12_depth_stencil_alpha_state *zsa; 75 struct d3d12_rasterizer_state *rast; 76 77 unsigned samples; 78 unsigned sample_mask; 79 unsigned num_cbufs; 80 unsigned num_so_targets; 81 bool has_float_rtv; 82 DXGI_FORMAT rtv_formats[8]; 83 DXGI_FORMAT dsv_format; 84 D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ib_strip_cut_value; 85 enum mesa_prim prim_type; 86 }; 87 88 struct d3d12_compute_pipeline_state { 89 ID3D12RootSignature *root_signature; 90 struct d3d12_shader *stage; 91 }; 92 93 DXGI_FORMAT 94 d3d12_rtv_format(struct d3d12_context *ctx, unsigned index); 95 96 void 97 d3d12_gfx_pipeline_state_cache_init(struct d3d12_context *ctx); 98 99 void 100 d3d12_gfx_pipeline_state_cache_destroy(struct d3d12_context *ctx); 101 102 ID3D12PipelineState * 103 d3d12_get_gfx_pipeline_state(struct d3d12_context *ctx); 104 105 void 106 d3d12_gfx_pipeline_state_cache_invalidate(struct d3d12_context *ctx, const void *state); 107 108 void 109 d3d12_gfx_pipeline_state_cache_invalidate_shader(struct d3d12_context *ctx, 110 enum pipe_shader_type stage, 111 struct d3d12_shader_selector *selector); 112 113 void 114 d3d12_compute_pipeline_state_cache_init(struct d3d12_context *ctx); 115 116 void 117 d3d12_compute_pipeline_state_cache_destroy(struct d3d12_context *ctx); 118 119 ID3D12PipelineState * 120 d3d12_get_compute_pipeline_state(struct d3d12_context *ctx); 121 122 void 123 d3d12_compute_pipeline_state_cache_invalidate_shader(struct d3d12_context *ctx, 124 struct d3d12_shader_selector *selector); 125 126 #endif 127