File indexing completed on 2024-05-05 04:53:35
0001 /* 0002 SPDX-FileCopyrightText: 2023 Meltytech, LLC 0003 SPDX-License-Identifier: GPL-3.0-or-later 0004 */ 0005 0006 #pragma once 0007 0008 #include "videowidget.h" 0009 0010 #include <d3d11.h> 0011 #include <directxmath.h> 0012 0013 class D3DVideoWidget : public VideoWidget 0014 { 0015 Q_OBJECT 0016 public: 0017 explicit D3DVideoWidget(int id, QObject *parent = nullptr); 0018 virtual ~D3DVideoWidget(); 0019 0020 public Q_SLOTS: 0021 virtual void initialize() override; 0022 virtual void beforeRendering() override; 0023 virtual void renderVideo() override; 0024 0025 private: 0026 enum Stage { VertexStage, FragmentStage }; 0027 void prepareShader(Stage stage); 0028 QByteArray compileShader(Stage stage, const QByteArray &source, const QByteArray &entryPoint); 0029 ID3D11ShaderResourceView *initTexture(const void *p, int width, int height); 0030 0031 ID3D11Device *m_device = nullptr; 0032 ID3D11DeviceContext *m_context = nullptr; 0033 QByteArray m_vert; 0034 QByteArray m_vertEntryPoint; 0035 QByteArray m_frag; 0036 QByteArray m_fragEntryPoint; 0037 0038 bool m_initialized = false; 0039 ID3D11Buffer *m_vbuf = nullptr; 0040 ID3D11Buffer *m_cbuf = nullptr; 0041 ID3D11VertexShader *m_vs = nullptr; 0042 ID3D11PixelShader *m_ps = nullptr; 0043 ID3D11InputLayout *m_inputLayout = nullptr; 0044 ID3D11RasterizerState *m_rastState = nullptr; 0045 ID3D11DepthStencilState *m_dsState = nullptr; 0046 ID3D11ShaderResourceView *m_texture[3] = {nullptr, nullptr, nullptr}; 0047 0048 struct ConstantBuffer 0049 { 0050 int32_t colorspace; 0051 }; 0052 0053 ConstantBuffer m_constants; 0054 };