• 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_VIDEO_PROC_H
25 #define D3D12_VIDEO_PROC_H
26 #include "d3d12_video_types.h"
27 
28 
29 ///
30 /// Pipe video interface starts
31 ///
32 
33 /**
34  * creates a video processor
35  */
36 struct pipe_video_codec *
37 d3d12_video_create_processor(struct pipe_context *context, const struct pipe_video_codec *templ);
38 
39 /**
40  * destroy this video processor
41  */
42 void
43 d3d12_video_processor_destroy(struct pipe_video_codec *codec);
44 
45 /**
46  * start processing of a new frame
47  */
48 void
49 d3d12_video_processor_begin_frame(struct pipe_video_codec * codec,
50                                 struct pipe_video_buffer *target,
51                                 struct pipe_picture_desc *picture);
52 
53 /**
54  * Perform post-process effect
55  */
56 void
57 d3d12_video_processor_process_frame(struct pipe_video_codec *codec,
58                         struct pipe_video_buffer *input_texture,
59                         const struct pipe_vpp_desc *process_properties);
60 /**
61  * end processing of the current frame
62  */
63 void
64 d3d12_video_processor_end_frame(struct pipe_video_codec * codec,
65                               struct pipe_video_buffer *target,
66                               struct pipe_picture_desc *picture);
67 /**
68 
69  * flush any outstanding command buffers to the hardware
70  * should be called before a video_buffer is acessed by the gallium frontend again
71  */
72 void
73 d3d12_video_processor_flush(struct pipe_video_codec *codec);
74 
75 ///
76 /// Pipe video interface ends
77 ///
78 
79 ///
80 /// d3d12_video_processor functions starts
81 ///
82 
83 struct d3d12_video_processor
84 {
85    struct pipe_video_codec base;
86    struct d3d12_screen  *m_pD3D12Screen;
87    struct d3d12_context *m_pD3D12Context;
88 
89    ///
90    /// D3D12 objects and context info
91    ///
92 
93    const uint m_NodeMask  = 0u;
94    const uint m_NodeIndex = 0u;
95 
96    ComPtr<ID3D12Fence> m_spFence;
97    uint                m_fenceValue = 1u;
98 
99    ComPtr<ID3D12VideoDevice>             m_spD3D12VideoDevice;
100 
101    D3D12_FEATURE_DATA_VIDEO_PROCESS_SUPPORT           m_SupportCaps;
102    D3D12_VIDEO_PROCESS_OUTPUT_STREAM_DESC             m_outputStreamDesc;
103    std::vector<D3D12_VIDEO_PROCESS_INPUT_STREAM_DESC> m_inputStreamDescs;
104    ComPtr<ID3D12VideoProcessor1>                      m_spVideoProcessor;
105    ComPtr<ID3D12CommandQueue>                         m_spCommandQueue;
106    ComPtr<ID3D12CommandAllocator>                     m_spCommandAllocator;
107    ComPtr<ID3D12VideoProcessCommandList1>             m_spCommandList;
108 
109    std::vector<D3D12_RESOURCE_BARRIER> m_transitionsBeforeCloseCmdList;
110 
111    // Current state between begin and end frame
112    D3D12_VIDEO_PROCESS_OUTPUT_STREAM_ARGUMENTS m_OutputArguments;
113    std::vector<D3D12_VIDEO_PROCESS_INPUT_STREAM_ARGUMENTS1> m_ProcessInputs;
114 
115    // Indicates if GPU commands have not been flushed and are pending.
116    bool m_needsGPUFlush = false;
117 };
118 
119 struct pipe_video_codec *
120 d3d12_video_processor_create(struct pipe_context *context, const struct pipe_video_codec *codec);
121 
122 bool
123 d3d12_video_processor_check_caps_and_create_processor(struct d3d12_video_processor *pD3D12Proc,
124                                                         std::vector<DXGI_FORMAT> InputFormats,
125                                                         DXGI_COLOR_SPACE_TYPE InputColorSpace,
126                                                         DXGI_FORMAT OutputFormat,
127                                                         DXGI_COLOR_SPACE_TYPE OutputColorSpace);
128 
129 bool
130 d3d12_video_processor_create_command_objects(struct d3d12_video_processor *pD3D12Proc);
131 
132 D3D12_VIDEO_PROCESS_ORIENTATION
133 d3d12_video_processor_convert_pipe_rotation(enum pipe_video_vpp_orientation orientation);
134 
135 ///
136 /// d3d12_video_processor functions ends
137 ///
138 
139 #endif
140