Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2019 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Gui module |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | |
37 | #ifndef QRHID3D11_P_H |
38 | #define QRHID3D11_P_H |
39 | |
40 | // |
41 | // W A R N I N G |
42 | // ------------- |
43 | // |
44 | // This file is not part of the Qt API. It exists purely as an |
45 | // implementation detail. This header file may change from version to |
46 | // version without notice, or even be removed. |
47 | // |
48 | // We mean it. |
49 | // |
50 | |
51 | #include "qrhid3d11_p.h" |
52 | #include "qrhi_p_p.h" |
53 | #include "qshaderdescription_p.h" |
54 | #include <QWindow> |
55 | |
56 | #include <d3d11_1.h> |
57 | #include <dxgi1_3.h> |
58 | |
59 | QT_BEGIN_NAMESPACE |
60 | |
61 | struct QD3D11Buffer : public QRhiBuffer |
62 | { |
63 | QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, int size); |
64 | ~QD3D11Buffer(); |
65 | void release() override; |
66 | bool build() override; |
67 | |
68 | ID3D11UnorderedAccessView *unorderedAccessView(); |
69 | |
70 | ID3D11Buffer *buffer = nullptr; |
71 | QByteArray dynBuf; |
72 | bool hasPendingDynamicUpdates = false; |
73 | ID3D11UnorderedAccessView *uav = nullptr; |
74 | uint generation = 0; |
75 | friend class QRhiD3D11; |
76 | }; |
77 | |
78 | struct QD3D11RenderBuffer : public QRhiRenderBuffer |
79 | { |
80 | QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, |
81 | int sampleCount, QRhiRenderBuffer::Flags flags); |
82 | ~QD3D11RenderBuffer(); |
83 | void release() override; |
84 | bool build() override; |
85 | QRhiTexture::Format backingFormat() const override; |
86 | |
87 | ID3D11Texture2D *tex = nullptr; |
88 | ID3D11DepthStencilView *dsv = nullptr; |
89 | ID3D11RenderTargetView *rtv = nullptr; |
90 | DXGI_FORMAT dxgiFormat; |
91 | DXGI_SAMPLE_DESC sampleDesc; |
92 | friend class QRhiD3D11; |
93 | }; |
94 | |
95 | struct QD3D11Texture : public QRhiTexture |
96 | { |
97 | QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, |
98 | int sampleCount, Flags flags); |
99 | ~QD3D11Texture(); |
100 | void release() override; |
101 | bool build() override; |
102 | bool buildFrom(const QRhiNativeHandles *src) override; |
103 | const QRhiNativeHandles *nativeHandles() override; |
104 | |
105 | bool prepareBuild(QSize *adjustedSize = nullptr); |
106 | bool finishBuild(); |
107 | ID3D11UnorderedAccessView *unorderedAccessViewForLevel(int level); |
108 | |
109 | ID3D11Texture2D *tex = nullptr; |
110 | bool owns = true; |
111 | ID3D11ShaderResourceView *srv = nullptr; |
112 | DXGI_FORMAT dxgiFormat; |
113 | uint mipLevelCount = 0; |
114 | DXGI_SAMPLE_DESC sampleDesc; |
115 | QRhiD3D11TextureNativeHandles nativeHandlesStruct; |
116 | ID3D11UnorderedAccessView *perLevelViews[QRhi::MAX_LEVELS]; |
117 | uint generation = 0; |
118 | friend class QRhiD3D11; |
119 | }; |
120 | |
121 | struct QD3D11Sampler : public QRhiSampler |
122 | { |
123 | QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, |
124 | AddressMode u, AddressMode v); |
125 | ~QD3D11Sampler(); |
126 | void release() override; |
127 | bool build() override; |
128 | |
129 | ID3D11SamplerState *samplerState = nullptr; |
130 | uint generation = 0; |
131 | friend class QRhiD3D11; |
132 | }; |
133 | |
134 | struct QD3D11RenderPassDescriptor : public QRhiRenderPassDescriptor |
135 | { |
136 | QD3D11RenderPassDescriptor(QRhiImplementation *rhi); |
137 | ~QD3D11RenderPassDescriptor(); |
138 | void release() override; |
139 | }; |
140 | |
141 | struct QD3D11RenderTargetData |
142 | { |
143 | QD3D11RenderTargetData(QRhiImplementation *) |
144 | { |
145 | for (int i = 0; i < MAX_COLOR_ATTACHMENTS; ++i) |
146 | rtv[i] = nullptr; |
147 | } |
148 | |
149 | QD3D11RenderPassDescriptor *rp = nullptr; |
150 | QSize pixelSize; |
151 | float dpr = 1; |
152 | int sampleCount = 1; |
153 | int colorAttCount = 0; |
154 | int dsAttCount = 0; |
155 | |
156 | static const int MAX_COLOR_ATTACHMENTS = 8; |
157 | ID3D11RenderTargetView *rtv[MAX_COLOR_ATTACHMENTS]; |
158 | ID3D11DepthStencilView *dsv = nullptr; |
159 | }; |
160 | |
161 | struct QD3D11ReferenceRenderTarget : public QRhiRenderTarget |
162 | { |
163 | QD3D11ReferenceRenderTarget(QRhiImplementation *rhi); |
164 | ~QD3D11ReferenceRenderTarget(); |
165 | void release() override; |
166 | |
167 | QSize pixelSize() const override; |
168 | float devicePixelRatio() const override; |
169 | int sampleCount() const override; |
170 | |
171 | QD3D11RenderTargetData d; |
172 | }; |
173 | |
174 | struct QD3D11TextureRenderTarget : public QRhiTextureRenderTarget |
175 | { |
176 | QD3D11TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags); |
177 | ~QD3D11TextureRenderTarget(); |
178 | void release() override; |
179 | |
180 | QSize pixelSize() const override; |
181 | float devicePixelRatio() const override; |
182 | int sampleCount() const override; |
183 | |
184 | QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; |
185 | bool build() override; |
186 | |
187 | QD3D11RenderTargetData d; |
188 | bool ownsRtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]; |
189 | ID3D11RenderTargetView *rtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]; |
190 | bool ownsDsv = false; |
191 | ID3D11DepthStencilView *dsv = nullptr; |
192 | friend class QRhiD3D11; |
193 | }; |
194 | |
195 | struct QD3D11ShaderResourceBindings : public QRhiShaderResourceBindings |
196 | { |
197 | QD3D11ShaderResourceBindings(QRhiImplementation *rhi); |
198 | ~QD3D11ShaderResourceBindings(); |
199 | void release() override; |
200 | bool build() override; |
201 | |
202 | QVector<QRhiShaderResourceBinding> sortedBindings; |
203 | uint generation = 0; |
204 | |
205 | // Keep track of the generation number of each referenced QRhi* to be able |
206 | // to detect that the batched bindings are out of date. |
207 | struct BoundUniformBufferData { |
208 | quint64 id; |
209 | uint generation; |
210 | }; |
211 | struct BoundSampledTextureData { |
212 | quint64 texId; |
213 | uint texGeneration; |
214 | quint64 samplerId; |
215 | uint samplerGeneration; |
216 | }; |
217 | struct BoundStorageImageData { |
218 | quint64 id; |
219 | uint generation; |
220 | }; |
221 | struct BoundStorageBufferData { |
222 | quint64 id; |
223 | uint generation; |
224 | }; |
225 | struct BoundResourceData { |
226 | union { |
227 | BoundUniformBufferData ubuf; |
228 | BoundSampledTextureData stex; |
229 | BoundStorageImageData simage; |
230 | BoundStorageBufferData sbuf; |
231 | }; |
232 | }; |
233 | QVector<BoundResourceData> boundResourceData; |
234 | |
235 | QRhiBatchedBindings<ID3D11Buffer *> vsubufs; |
236 | QRhiBatchedBindings<UINT> vsubufoffsets; |
237 | QRhiBatchedBindings<UINT> vsubufsizes; |
238 | |
239 | QRhiBatchedBindings<ID3D11Buffer *> fsubufs; |
240 | QRhiBatchedBindings<UINT> fsubufoffsets; |
241 | QRhiBatchedBindings<UINT> fsubufsizes; |
242 | |
243 | QRhiBatchedBindings<ID3D11Buffer *> csubufs; |
244 | QRhiBatchedBindings<UINT> csubufoffsets; |
245 | QRhiBatchedBindings<UINT> csubufsizes; |
246 | |
247 | QRhiBatchedBindings<ID3D11SamplerState *> vssamplers; |
248 | QRhiBatchedBindings<ID3D11ShaderResourceView *> vsshaderresources; |
249 | |
250 | QRhiBatchedBindings<ID3D11SamplerState *> fssamplers; |
251 | QRhiBatchedBindings<ID3D11ShaderResourceView *> fsshaderresources; |
252 | |
253 | QRhiBatchedBindings<ID3D11SamplerState *> cssamplers; |
254 | QRhiBatchedBindings<ID3D11ShaderResourceView *> csshaderresources; |
255 | |
256 | QRhiBatchedBindings<ID3D11UnorderedAccessView *> csUAVs; |
257 | |
258 | friend class QRhiD3D11; |
259 | }; |
260 | |
261 | Q_DECLARE_TYPEINFO(QD3D11ShaderResourceBindings::BoundResourceData, Q_MOVABLE_TYPE); |
262 | |
263 | struct QD3D11GraphicsPipeline : public QRhiGraphicsPipeline |
264 | { |
265 | QD3D11GraphicsPipeline(QRhiImplementation *rhi); |
266 | ~QD3D11GraphicsPipeline(); |
267 | void release() override; |
268 | bool build() override; |
269 | |
270 | ID3D11DepthStencilState *dsState = nullptr; |
271 | ID3D11BlendState *blendState = nullptr; |
272 | ID3D11VertexShader *vs = nullptr; |
273 | ID3D11PixelShader *fs = nullptr; |
274 | ID3D11InputLayout *inputLayout = nullptr; |
275 | D3D11_PRIMITIVE_TOPOLOGY d3dTopology = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; |
276 | ID3D11RasterizerState *rastState = nullptr; |
277 | uint generation = 0; |
278 | friend class QRhiD3D11; |
279 | }; |
280 | |
281 | struct QD3D11ComputePipeline : public QRhiComputePipeline |
282 | { |
283 | QD3D11ComputePipeline(QRhiImplementation *rhi); |
284 | ~QD3D11ComputePipeline(); |
285 | void release() override; |
286 | bool build() override; |
287 | |
288 | ID3D11ComputeShader *cs = nullptr; |
289 | uint generation = 0; |
290 | friend class QRhiD3D11; |
291 | }; |
292 | |
293 | struct QD3D11SwapChain; |
294 | |
295 | struct QD3D11CommandBuffer : public QRhiCommandBuffer |
296 | { |
297 | QD3D11CommandBuffer(QRhiImplementation *rhi); |
298 | ~QD3D11CommandBuffer(); |
299 | void release() override; |
300 | |
301 | struct Command { |
302 | enum Cmd { |
303 | ResetShaderResources, |
304 | SetRenderTarget, |
305 | Clear, |
306 | Viewport, |
307 | Scissor, |
308 | BindVertexBuffers, |
309 | BindIndexBuffer, |
310 | BindGraphicsPipeline, |
311 | BindShaderResources, |
312 | StencilRef, |
313 | BlendConstants, |
314 | Draw, |
315 | DrawIndexed, |
316 | UpdateSubRes, |
317 | CopySubRes, |
318 | ResolveSubRes, |
319 | GenMip, |
320 | DebugMarkBegin, |
321 | DebugMarkEnd, |
322 | DebugMarkMsg, |
323 | BindComputePipeline, |
324 | Dispatch |
325 | }; |
326 | enum ClearFlag { Color = 1, Depth = 2, Stencil = 4 }; |
327 | Cmd cmd; |
328 | |
329 | static const int MAX_UBUF_BINDINGS = 32; // should be D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT but 128 is a waste of space for our purposes |
330 | |
331 | // QRhi*/QD3D11* references should be kept at minimum (so no |
332 | // QRhiTexture/Buffer/etc. pointers). |
333 | union { |
334 | struct { |
335 | QRhiRenderTarget *rt; |
336 | } setRenderTarget; |
337 | struct { |
338 | QRhiRenderTarget *rt; |
339 | int mask; |
340 | float c[4]; |
341 | float d; |
342 | quint32 s; |
343 | } clear; |
344 | struct { |
345 | float x, y, w, h; |
346 | float d0, d1; |
347 | } viewport; |
348 | struct { |
349 | int x, y, w, h; |
350 | } scissor; |
351 | struct { |
352 | int startSlot; |
353 | int slotCount; |
354 | ID3D11Buffer *buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; |
355 | UINT offsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; |
356 | UINT strides[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; |
357 | } bindVertexBuffers; |
358 | struct { |
359 | ID3D11Buffer *buffer; |
360 | quint32 offset; |
361 | DXGI_FORMAT format; |
362 | } bindIndexBuffer; |
363 | struct { |
364 | QD3D11GraphicsPipeline *ps; |
365 | } bindGraphicsPipeline; |
366 | struct { |
367 | QD3D11ShaderResourceBindings *srb; |
368 | bool offsetOnlyChange; |
369 | int dynamicOffsetCount; |
370 | uint dynamicOffsetPairs[MAX_UBUF_BINDINGS * 2]; // binding, offsetInConstants |
371 | } bindShaderResources; |
372 | struct { |
373 | QD3D11GraphicsPipeline *ps; |
374 | quint32 ref; |
375 | } stencilRef; |
376 | struct { |
377 | QD3D11GraphicsPipeline *ps; |
378 | float c[4]; |
379 | } blendConstants; |
380 | struct { |
381 | QD3D11GraphicsPipeline *ps; |
382 | quint32 vertexCount; |
383 | quint32 instanceCount; |
384 | quint32 firstVertex; |
385 | quint32 firstInstance; |
386 | } draw; |
387 | struct { |
388 | QD3D11GraphicsPipeline *ps; |
389 | quint32 indexCount; |
390 | quint32 instanceCount; |
391 | quint32 firstIndex; |
392 | qint32 vertexOffset; |
393 | quint32 firstInstance; |
394 | } drawIndexed; |
395 | struct { |
396 | ID3D11Resource *dst; |
397 | UINT dstSubRes; |
398 | bool hasDstBox; |
399 | D3D11_BOX dstBox; |
400 | const void *src; // must come from retain*() |
401 | UINT srcRowPitch; |
402 | } updateSubRes; |
403 | struct { |
404 | ID3D11Resource *dst; |
405 | UINT dstSubRes; |
406 | UINT dstX; |
407 | UINT dstY; |
408 | ID3D11Resource *src; |
409 | UINT srcSubRes; |
410 | bool hasSrcBox; |
411 | D3D11_BOX srcBox; |
412 | } copySubRes; |
413 | struct { |
414 | ID3D11Resource *dst; |
415 | UINT dstSubRes; |
416 | ID3D11Resource *src; |
417 | UINT srcSubRes; |
418 | DXGI_FORMAT format; |
419 | } resolveSubRes; |
420 | struct { |
421 | ID3D11ShaderResourceView *srv; |
422 | } genMip; |
423 | struct { |
424 | char s[64]; |
425 | } debugMark; |
426 | struct { |
427 | QD3D11ComputePipeline *ps; |
428 | } bindComputePipeline; |
429 | struct { |
430 | UINT x; |
431 | UINT y; |
432 | UINT z; |
433 | } dispatch; |
434 | } args; |
435 | }; |
436 | |
437 | enum PassType { |
438 | NoPass, |
439 | RenderPass, |
440 | ComputePass |
441 | }; |
442 | |
443 | QVector<Command> commands; |
444 | PassType recordingPass; |
445 | QRhiRenderTarget *currentTarget; |
446 | QRhiGraphicsPipeline *currentGraphicsPipeline; |
447 | QRhiComputePipeline *currentComputePipeline; |
448 | uint currentPipelineGeneration; |
449 | QRhiShaderResourceBindings *currentGraphicsSrb; |
450 | QRhiShaderResourceBindings *currentComputeSrb; |
451 | uint currentSrbGeneration; |
452 | ID3D11Buffer *currentIndexBuffer; |
453 | quint32 currentIndexOffset; |
454 | DXGI_FORMAT currentIndexFormat; |
455 | ID3D11Buffer *currentVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; |
456 | quint32 currentVertexOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; |
457 | |
458 | QVector<QByteArray> dataRetainPool; |
459 | QVector<QImage> imageRetainPool; |
460 | |
461 | // relies heavily on implicit sharing (no copies of the actual data will be made) |
462 | const uchar *retainData(const QByteArray &data) { |
463 | dataRetainPool.append(data); |
464 | return reinterpret_cast<const uchar *>(dataRetainPool.constLast().constData()); |
465 | } |
466 | const uchar *retainImage(const QImage &image) { |
467 | imageRetainPool.append(image); |
468 | return imageRetainPool.constLast().constBits(); |
469 | } |
470 | void resetCommands() { |
471 | commands.clear(); |
472 | dataRetainPool.clear(); |
473 | imageRetainPool.clear(); |
474 | } |
475 | void resetState() { |
476 | resetCommands(); |
477 | recordingPass = NoPass; |
478 | currentTarget = nullptr; |
479 | resetCachedState(); |
480 | } |
481 | void resetCachedState() { |
482 | currentGraphicsPipeline = nullptr; |
483 | currentComputePipeline = nullptr; |
484 | currentPipelineGeneration = 0; |
485 | resetCachedShaderResourceState(); |
486 | } |
487 | void resetCachedShaderResourceState() { |
488 | currentGraphicsSrb = nullptr; |
489 | currentComputeSrb = nullptr; |
490 | currentSrbGeneration = 0; |
491 | currentIndexBuffer = nullptr; |
492 | currentIndexOffset = 0; |
493 | currentIndexFormat = DXGI_FORMAT_R16_UINT; |
494 | memset(currentVertexBuffers, 0, sizeof(currentVertexBuffers)); |
495 | memset(currentVertexOffsets, 0, sizeof(currentVertexOffsets)); |
496 | } |
497 | }; |
498 | |
499 | Q_DECLARE_TYPEINFO(QD3D11CommandBuffer::Command, Q_MOVABLE_TYPE); |
500 | |
501 | struct QD3D11SwapChain : public QRhiSwapChain |
502 | { |
503 | QD3D11SwapChain(QRhiImplementation *rhi); |
504 | ~QD3D11SwapChain(); |
505 | void release() override; |
506 | |
507 | QRhiCommandBuffer *currentFrameCommandBuffer() override; |
508 | QRhiRenderTarget *currentFrameRenderTarget() override; |
509 | |
510 | QSize surfacePixelSize() override; |
511 | |
512 | QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; |
513 | bool buildOrResize() override; |
514 | |
515 | void releaseBuffers(); |
516 | bool newColorBuffer(const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc, |
517 | ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const; |
518 | |
519 | QWindow *window = nullptr; |
520 | QSize pixelSize; |
521 | QD3D11ReferenceRenderTarget rt; |
522 | QD3D11CommandBuffer cb; |
523 | DXGI_FORMAT colorFormat; |
524 | IDXGISwapChain *swapChain = nullptr; |
525 | static const int BUFFER_COUNT = 2; |
526 | ID3D11Texture2D *tex[BUFFER_COUNT]; |
527 | ID3D11RenderTargetView *rtv[BUFFER_COUNT]; |
528 | ID3D11Texture2D *msaaTex[BUFFER_COUNT]; |
529 | ID3D11RenderTargetView *msaaRtv[BUFFER_COUNT]; |
530 | DXGI_SAMPLE_DESC sampleDesc; |
531 | int currentFrameSlot = 0; |
532 | int frameCount = 0; |
533 | QD3D11RenderBuffer *ds = nullptr; |
534 | bool timestampActive[BUFFER_COUNT]; |
535 | ID3D11Query *timestampDisjointQuery[BUFFER_COUNT]; |
536 | ID3D11Query *timestampQuery[BUFFER_COUNT * 2]; |
537 | UINT swapInterval = 1; |
538 | }; |
539 | |
540 | class QRhiD3D11 : public QRhiImplementation |
541 | { |
542 | public: |
543 | QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice = nullptr); |
544 | |
545 | bool create(QRhi::Flags flags) override; |
546 | void destroy() override; |
547 | |
548 | QRhiGraphicsPipeline *createGraphicsPipeline() override; |
549 | QRhiComputePipeline *createComputePipeline() override; |
550 | QRhiShaderResourceBindings *createShaderResourceBindings() override; |
551 | QRhiBuffer *createBuffer(QRhiBuffer::Type type, |
552 | QRhiBuffer::UsageFlags usage, |
553 | int size) override; |
554 | QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, |
555 | const QSize &pixelSize, |
556 | int sampleCount, |
557 | QRhiRenderBuffer::Flags flags) override; |
558 | QRhiTexture *createTexture(QRhiTexture::Format format, |
559 | const QSize &pixelSize, |
560 | int sampleCount, |
561 | QRhiTexture::Flags flags) override; |
562 | QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, |
563 | QRhiSampler::Filter mipmapMode, |
564 | QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) override; |
565 | |
566 | QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, |
567 | QRhiTextureRenderTarget::Flags flags) override; |
568 | |
569 | QRhiSwapChain *createSwapChain() override; |
570 | QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override; |
571 | QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override; |
572 | QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb) override; |
573 | QRhi::FrameOpResult endOffscreenFrame() override; |
574 | QRhi::FrameOpResult finish() override; |
575 | |
576 | void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; |
577 | |
578 | void beginPass(QRhiCommandBuffer *cb, |
579 | QRhiRenderTarget *rt, |
580 | const QColor &colorClearValue, |
581 | const QRhiDepthStencilClearValue &depthStencilClearValue, |
582 | QRhiResourceUpdateBatch *resourceUpdates) override; |
583 | void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; |
584 | |
585 | void setGraphicsPipeline(QRhiCommandBuffer *cb, |
586 | QRhiGraphicsPipeline *ps) override; |
587 | |
588 | void setShaderResources(QRhiCommandBuffer *cb, |
589 | QRhiShaderResourceBindings *srb, |
590 | int dynamicOffsetCount, |
591 | const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override; |
592 | |
593 | void setVertexInput(QRhiCommandBuffer *cb, |
594 | int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, |
595 | QRhiBuffer *indexBuf, quint32 indexOffset, |
596 | QRhiCommandBuffer::IndexFormat indexFormat) override; |
597 | |
598 | void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override; |
599 | void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override; |
600 | void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override; |
601 | void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override; |
602 | |
603 | void draw(QRhiCommandBuffer *cb, quint32 vertexCount, |
604 | quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override; |
605 | |
606 | void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, |
607 | quint32 instanceCount, quint32 firstIndex, |
608 | qint32 vertexOffset, quint32 firstInstance) override; |
609 | |
610 | void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override; |
611 | void debugMarkEnd(QRhiCommandBuffer *cb) override; |
612 | void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override; |
613 | |
614 | void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; |
615 | void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; |
616 | void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override; |
617 | void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override; |
618 | |
619 | const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override; |
620 | void beginExternal(QRhiCommandBuffer *cb) override; |
621 | void endExternal(QRhiCommandBuffer *cb) override; |
622 | |
623 | QVector<int> supportedSampleCounts() const override; |
624 | int ubufAlignment() const override; |
625 | bool isYUpInFramebuffer() const override; |
626 | bool isYUpInNDC() const override; |
627 | bool isClipDepthZeroToOne() const override; |
628 | QMatrix4x4 clipSpaceCorrMatrix() const override; |
629 | bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; |
630 | bool isFeatureSupported(QRhi::Feature feature) const override; |
631 | int resourceLimit(QRhi::ResourceLimit limit) const override; |
632 | const QRhiNativeHandles *nativeHandles() override; |
633 | void sendVMemStatsToProfiler() override; |
634 | void makeThreadLocalNativeContextCurrent() override; |
635 | |
636 | void flushCommandBuffer(); |
637 | void enqueueSubresUpload(QD3D11Texture *texD, QD3D11CommandBuffer *cbD, |
638 | int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc); |
639 | void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates); |
640 | void updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD); |
641 | void executeBufferHostWritesForCurrentFrame(QD3D11Buffer *bufD); |
642 | void bindShaderResources(QD3D11ShaderResourceBindings *srbD, |
643 | const uint *dynOfsPairs, int dynOfsPairCount, |
644 | bool offsetOnlyChange); |
645 | void resetShaderResources(); |
646 | void executeCommandBuffer(QD3D11CommandBuffer *cbD, QD3D11SwapChain *timestampSwapChain = nullptr); |
647 | DXGI_SAMPLE_DESC effectiveSampleCount(int sampleCount) const; |
648 | void finishActiveReadbacks(); |
649 | void reportLiveObjects(ID3D11Device *device); |
650 | |
651 | bool debugLayer = false; |
652 | bool importedDevice = false; |
653 | ID3D11Device *dev = nullptr; |
654 | ID3D11DeviceContext1 *context = nullptr; |
655 | D3D_FEATURE_LEVEL featureLevel; |
656 | ID3DUserDefinedAnnotation *annotations = nullptr; |
657 | IDXGIFactory1 *dxgiFactory = nullptr; |
658 | bool hasDxgi2 = false; |
659 | QRhiD3D11NativeHandles nativeHandlesStruct; |
660 | |
661 | struct { |
662 | int vsHighestActiveVertexBufferBinding = -1; |
663 | bool vsHasIndexBufferBound = false; |
664 | int vsHighestActiveSrvBinding = -1; |
665 | int fsHighestActiveSrvBinding = -1; |
666 | int csHighestActiveSrvBinding = -1; |
667 | int csHighestActiveUavBinding = -1; |
668 | QD3D11SwapChain *currentSwapChain = nullptr; |
669 | } contextState; |
670 | |
671 | struct OffscreenFrame { |
672 | OffscreenFrame(QRhiImplementation *rhi) : cbWrapper(rhi) { } |
673 | bool active = false; |
674 | QD3D11CommandBuffer cbWrapper; |
675 | } ofr; |
676 | |
677 | struct ActiveReadback { |
678 | QRhiReadbackDescription desc; |
679 | QRhiReadbackResult *result; |
680 | ID3D11Texture2D *stagingTex; |
681 | quint32 bufSize; |
682 | quint32 bpl; |
683 | QSize pixelSize; |
684 | QRhiTexture::Format format; |
685 | }; |
686 | QVector<ActiveReadback> activeReadbacks; |
687 | }; |
688 | |
689 | Q_DECLARE_TYPEINFO(QRhiD3D11::ActiveReadback, Q_MOVABLE_TYPE); |
690 | |
691 | QT_END_NAMESPACE |
692 | |
693 | #endif |
694 |
Warning: That file was not part of the compilation database. It may have many parsing errors.