| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #pragma once
- #include "DX12Buffer.h"
- #include "Shader.h"
- struct ID3D12Device;
- struct ID3D12GraphicsCommandList;
- struct D3D12_INPUT_ELEMENT_DESC;
- struct D3D12_ROOT_PARAMETER1;
- struct D3D12_CONSTANT_BUFFER_VIEW_DESC;
- namespace Framework
- {
- class DX12Shader : public Shader
- {
- protected:
- ID3D12Device* device;
- DX12CopyCommandQueue* copy;
- DX12DirectCommandQueue* direct;
- unsigned char* shaderByteBuffer;
- int byteBufferSize;
- public:
- DX12Shader(ID3D12Device* device,
- DX12CopyCommandQueue* copy,
- DX12DirectCommandQueue* direct);
- virtual ~DX12Shader();
- //! Creates a constant buffer that passes constant data to the shader.
- //! A maximum of 14 buffers can be created.
- //! zD3d11Device: The device with which the buffer should be created
- //! \param size The size of the buffer in bytes
- //! \param index The position of the buffer in the buffer array. An
- //! existing buffer will be replaced. Buffer 1 cannot be created
- //! if buffer 0 has not been created yet, etc.
- virtual bool createConstBuffer(int size, int index) override;
- //! Sets the compiled shader
- //! zD3d11Device: The device with which the shader should be created
- //! \param bytes The bytes of the compiled code
- //! \param length The length of the byte array
- //! \return true if bytes is valid, false otherwise
- bool setCompiledByteArray(unsigned char* bytes, int length) override;
- //! After calling this function, this shader is used as a pixel shader
- //! zD3d11Context: The context object with which the shader should
- //! be used
- void useShader() override;
- //! Returns the compiled bytes
- unsigned char* getCompiledShader() const;
- //! Returns the number of compiled bytes
- int getCompiledLength() const;
- //! Creates the RootParameter for a constant buffer
- //! \param index The index of the buffer
- //! \param view Contains the position and size of the buffer
- //! in memory after the call
- virtual void getViewDesc(
- int index, D3D12_CONSTANT_BUFFER_VIEW_DESC& view);
- };
- class DX12PixelShader : public DX12Shader
- {
- public:
- DX12PixelShader(ID3D12Device* device,
- DX12CopyCommandQueue* copy,
- DX12DirectCommandQueue* direct);
- };
- class DX12VertexShader : public DX12Shader
- {
- private:
- D3D12_INPUT_ELEMENT_DESC* inputLayout;
- int inputLayoutSize;
- public:
- //! Constructor
- DX12VertexShader(ID3D12Device* device,
- DX12CopyCommandQueue* copy,
- DX12DirectCommandQueue* direct);
- //! Destructor
- ~DX12VertexShader();
- //! Creates an input layout for the shader.
- //! May only be called after compile.
- //! zD3d11Device: The device with which the layout should be created
- //! \param descArray An array with initialization data
- //! \param anz The number of elements in the array
- bool createInputLayout(D3D12_INPUT_ELEMENT_DESC* descArray, int anz);
- //! Returns the number of input parameters of the shader
- int getInputLayoutSize() const;
- //! Returns a list of formats for each input value
- D3D12_INPUT_ELEMENT_DESC* zInputLayout() const;
- };
- } // namespace Framework
|