• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef _WIN32
30 #include <wsl/winadapter.h>
31 #endif
32 
33 #define D3D12_IGNORE_SDK_LAYERS
34 #include <directx/d3d12.h>
35 
36 struct d3d12_context;
37 struct d3d12_root_signature;
38 
39 struct d3d12_vertex_elements_state {
40    D3D12_INPUT_ELEMENT_DESC elements[PIPE_MAX_ATTRIBS];
41    enum pipe_format format_conversion[PIPE_MAX_ATTRIBS];
42    unsigned num_elements:6; // <= PIPE_MAX_ATTRIBS
43    unsigned needs_format_emulation:1;
44    unsigned unused:25;
45 };
46 
47 struct d3d12_rasterizer_state {
48    struct pipe_rasterizer_state base;
49    D3D12_RASTERIZER_DESC desc;
50    void *twoface_back;
51 };
52 
53 struct d3d12_blend_state {
54    D3D12_BLEND_DESC desc;
55    unsigned blend_factor_flags;
56    bool is_dual_src;
57 };
58 
59 struct d3d12_depth_stencil_alpha_state {
60    D3D12_DEPTH_STENCIL_DESC desc;
61 };
62 
63 struct d3d12_gfx_pipeline_state {
64    ID3D12RootSignature *root_signature;
65    struct d3d12_shader *stages[PIPE_SHADER_TYPES - 1];
66    struct pipe_stream_output_info so_info;
67 
68    struct d3d12_vertex_elements_state *ves;
69    struct d3d12_blend_state *blend;
70    struct d3d12_depth_stencil_alpha_state *zsa;
71    struct d3d12_rasterizer_state *rast;
72 
73    unsigned samples;
74    unsigned sample_mask;
75    unsigned num_cbufs;
76    unsigned num_so_targets;
77    bool has_float_rtv;
78    DXGI_FORMAT rtv_formats[8];
79    DXGI_FORMAT dsv_format;
80    D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ib_strip_cut_value;
81    enum pipe_prim_type prim_type;
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 #endif
105