|
|
@@ -1,77 +1,17 @@
|
|
|
#pragma once
|
|
|
|
|
|
+#include "DXBuffer.h"
|
|
|
#include "Mat4.h"
|
|
|
-#include "Plane3D.h"
|
|
|
-#include "Screen.h"
|
|
|
#include "Vec2.h"
|
|
|
|
|
|
-//! DirectX 12 Types
|
|
|
-
|
|
|
-struct ID3D12Debug;
|
|
|
-struct ID3D12Device5;
|
|
|
-struct ID3D12InfoQueue;
|
|
|
-struct ID3D12CommandQueue;
|
|
|
-struct IDXGISwapChain4;
|
|
|
-struct ID3D12DescriptorHeap;
|
|
|
-struct ID3D12Resource;
|
|
|
-struct ID3D12CommandAllocator;
|
|
|
-struct ID3D12GraphicsCommandList;
|
|
|
-struct ID3D12Fence;
|
|
|
-struct D3D12_VIEWPORT;
|
|
|
-struct D3D12_VERTEX_BUFFER_VIEW;
|
|
|
-struct D3D12_INDEX_BUFFER_VIEW;
|
|
|
-struct ID3D12RootSignature;
|
|
|
-struct ID3D12PipelineState;
|
|
|
-
|
|
|
-//! DirectX 11 Types
|
|
|
-
|
|
|
-struct ID3D11Device;
|
|
|
-struct ID3D11DeviceContext;
|
|
|
-struct IDXGISwapChain;
|
|
|
-struct ID3D11Texture2D;
|
|
|
-struct ID3D11SamplerState;
|
|
|
-struct ID3D11ShaderResourceView;
|
|
|
-struct ID3D11RenderTargetView;
|
|
|
-struct ID3D11DepthStencilView;
|
|
|
-struct ID3D11DepthStencilState;
|
|
|
-struct ID3D11RasterizerState;
|
|
|
-struct ID3D11BlendState;
|
|
|
-struct D3D11_VIEWPORT;
|
|
|
-
|
|
|
-//! DirectX 9 Types
|
|
|
-
|
|
|
-struct IDirect3D9;
|
|
|
-struct IDirect3DDevice9;
|
|
|
-struct IDirect3DSurface9;
|
|
|
-struct _D3DLOCKED_RECT;
|
|
|
-struct tagRECT;
|
|
|
-
|
|
|
namespace Framework
|
|
|
{
|
|
|
class NativeWindow;
|
|
|
class Image;
|
|
|
class Texture;
|
|
|
- class DX11PixelShader;
|
|
|
- class DX11VertexShader;
|
|
|
- class TextureModel;
|
|
|
- class Render3D;
|
|
|
- class TextureList;
|
|
|
class Cam3D;
|
|
|
- class Model3D;
|
|
|
- class DX11Buffer;
|
|
|
- class DX11StructuredBuffer;
|
|
|
- class DX12Buffer;
|
|
|
- class DX12DirectCommandQueue;
|
|
|
- class DX12CopyCommandQueue;
|
|
|
- class DX12ComputeCommandQueue;
|
|
|
- class DX12PixelShader;
|
|
|
- class DX12VertexShader;
|
|
|
- class DX12VertexBuffer;
|
|
|
- class DX12IndexBuffer;
|
|
|
class Model3DList;
|
|
|
- class DXBuffer;
|
|
|
class Model3DData;
|
|
|
- class ID3D12GraphicsCommandList4;
|
|
|
|
|
|
enum GraphicApiType;
|
|
|
|
|
|
@@ -130,160 +70,4 @@ namespace Framework
|
|
|
//! \param eSize the size of one element of the buffer in bytes
|
|
|
DLLEXPORT virtual DXBuffer* createStructuredBuffer(int eSize) = 0;
|
|
|
};
|
|
|
-
|
|
|
- class DirectX9 : public GraphicsApi
|
|
|
- {
|
|
|
- private:
|
|
|
- IDirect3D9* pDirect3D;
|
|
|
- IDirect3DDevice9* pDevice;
|
|
|
- IDirect3DSurface9* pBackBuffer;
|
|
|
- _D3DLOCKED_RECT* backRect;
|
|
|
- Image* uiImage;
|
|
|
-
|
|
|
- public:
|
|
|
- DLLEXPORT DirectX9();
|
|
|
- DLLEXPORT ~DirectX9();
|
|
|
- DLLEXPORT void initialize(NativeWindow* fenster,
|
|
|
- Vec2<int> backBufferSize,
|
|
|
- bool fullScreen) override;
|
|
|
- DLLEXPORT void beginFrame(
|
|
|
- bool fill2D, bool fill3D, int fillColor) override;
|
|
|
- DLLEXPORT void renderKamera(Cam3D* zKamera) override;
|
|
|
- DLLEXPORT void presentFrame() override;
|
|
|
- DLLEXPORT Texture* createOrGetTexture(
|
|
|
- const char* name, Image* b) override;
|
|
|
- DLLEXPORT Image* zUIRenderImage() const override;
|
|
|
-
|
|
|
- DLLEXPORT virtual DXBuffer* createStructuredBuffer(int eSize) override;
|
|
|
- };
|
|
|
-
|
|
|
- class DirectX11 : public GraphicsApi
|
|
|
- {
|
|
|
- private:
|
|
|
- ID3D11Device* d3d11Device;
|
|
|
- ID3D11DeviceContext* d3d11Context;
|
|
|
- IDXGISwapChain* d3d11SpawChain;
|
|
|
- Texture* uiTexture;
|
|
|
- DX11VertexShader* vertexShader;
|
|
|
- DX11PixelShader* pixelShader;
|
|
|
- ID3D11SamplerState* sampleState;
|
|
|
- ID3D11RenderTargetView* rtview;
|
|
|
- ID3D11DepthStencilView* dsView;
|
|
|
- ID3D11Texture2D* depthStencilBuffer;
|
|
|
- ID3D11DepthStencilState* depthStencilState;
|
|
|
- ID3D11DepthStencilState* depthDisabledStencilState;
|
|
|
- ID3D11BlendState* blendStateAlphaBlend;
|
|
|
- D3D11_VIEWPORT* vp;
|
|
|
- TextureModel* texturModel;
|
|
|
- TextureList* texturRegister;
|
|
|
- Texture* defaultTexture;
|
|
|
- DX11StructuredBuffer* diffuseLights;
|
|
|
- DX11StructuredBuffer* pointLights;
|
|
|
- Mat4<float> matrixBuffer[MAX_KNOCHEN_ANZ];
|
|
|
- Mat4<float> viewAndProj[2];
|
|
|
- Vec3<float> kamPos;
|
|
|
- Plane3D<float> frustrum[6];
|
|
|
- int lastModelId = -1;
|
|
|
- DX11Buffer** indexBuffers;
|
|
|
- DX11Buffer** vertexBuffers;
|
|
|
-
|
|
|
- void renderObject(Model3D* zObj);
|
|
|
- DX11Buffer* createIndexBuffer();
|
|
|
- DX11Buffer* createVertexBuffer();
|
|
|
-
|
|
|
- protected:
|
|
|
- Critical deviceLock;
|
|
|
- ID3D11RasterizerState* texturRS;
|
|
|
- ID3D11RasterizerState* meshRS;
|
|
|
- DLLEXPORT virtual DX11VertexShader* initializeVertexShader(
|
|
|
- unsigned char* byteCode, int size);
|
|
|
- DLLEXPORT virtual DX11PixelShader* initializePixelShader(
|
|
|
- unsigned char* byteCode, int size);
|
|
|
- DLLEXPORT ID3D11DeviceContext* zContext();
|
|
|
-
|
|
|
- public:
|
|
|
- DLLEXPORT DirectX11();
|
|
|
- DLLEXPORT ~DirectX11();
|
|
|
- DLLEXPORT void initialize(NativeWindow* fenster,
|
|
|
- Vec2<int> backBufferSize,
|
|
|
- bool fullScreen) override;
|
|
|
- DLLEXPORT void beginFrame(
|
|
|
- bool fill2D, bool fill3D, int fillColor) override;
|
|
|
- DLLEXPORT void renderKamera(Cam3D* zKamera) override;
|
|
|
- DLLEXPORT void renderKamera(Cam3D* zKamera, Texture* zTarget) override;
|
|
|
- DLLEXPORT void presentFrame() override;
|
|
|
- DLLEXPORT Texture* createOrGetTexture(
|
|
|
- const char* name, Image* b) override;
|
|
|
- DLLEXPORT Image* zUIRenderImage() const override;
|
|
|
- DLLEXPORT virtual DXBuffer* createStructuredBuffer(int eSize) override;
|
|
|
- DLLEXPORT virtual Model3DData* createModel(const char* name) override;
|
|
|
- //! Checks whether a sphere is in the visible space of the world and
|
|
|
- //! needs to be drawn \param pos The center of the sphere \param
|
|
|
- //! radius The radius of the sphere \param dist A pointer to a
|
|
|
- //! float where the square of the distance to the camera position
|
|
|
- //! is stored if this function returns true and the pointer is not 0
|
|
|
- DLLEXPORT bool isInFrustrum(
|
|
|
- const Vec3<float>& pos, float radius, float* dist = 0) const;
|
|
|
- DLLEXPORT bool isInFrustrum(
|
|
|
- const Vec3<float>& pos, Vec3<float> radius, float* dist = 0) const;
|
|
|
-
|
|
|
- DLLEXPORT static bool isAvailable();
|
|
|
- };
|
|
|
-
|
|
|
- class DirectX12 : public GraphicsApi
|
|
|
- {
|
|
|
- private:
|
|
|
- ID3D12Debug* debug;
|
|
|
- ID3D12Device5* device;
|
|
|
- ID3D12InfoQueue* infoQueue;
|
|
|
- DX12DirectCommandQueue* directCommandQueue;
|
|
|
- DX12CopyCommandQueue* copyCommandQueue;
|
|
|
- DX12ComputeCommandQueue* computeCommandQueue;
|
|
|
- IDXGISwapChain4* swapChain;
|
|
|
- ID3D12DescriptorHeap* rtvHeap;
|
|
|
- ID3D12DescriptorHeap* dsvHeap;
|
|
|
- ID3D12DescriptorHeap* shaderBufferHeap;
|
|
|
- ID3D12Resource* depthBuffer;
|
|
|
- ID3D12Resource* backBuffer[2];
|
|
|
- int backBufferIndex;
|
|
|
- int tearing;
|
|
|
- D3D12_VIEWPORT* viewPort;
|
|
|
- tagRECT* allowedRenderArea;
|
|
|
- D3D12_VERTEX_BUFFER_VIEW* vertexBufferView;
|
|
|
- D3D12_INDEX_BUFFER_VIEW* indexBufferView;
|
|
|
- ID3D12RootSignature* signature;
|
|
|
- ID3D12PipelineState* pipeline;
|
|
|
- Mat4<float> matrixBuffer[MAX_KNOCHEN_ANZ];
|
|
|
- Mat4<float> viewAndProj[2];
|
|
|
- Vec3<float> kamPos;
|
|
|
- Plane3D<float> frustrum[6];
|
|
|
- TextureModel* texturModel;
|
|
|
- Texture* uiTexture;
|
|
|
- TextureList* texturRegister;
|
|
|
- DX12VertexShader* vertexShader;
|
|
|
- DX12PixelShader* pixelShader;
|
|
|
-
|
|
|
- DLLEXPORT void updateBottomLevelAccelerationStructure();
|
|
|
-
|
|
|
- public:
|
|
|
- DLLEXPORT DirectX12();
|
|
|
- DLLEXPORT ~DirectX12();
|
|
|
- DLLEXPORT void initialize(NativeWindow* fenster,
|
|
|
- Vec2<int> backBufferSize,
|
|
|
- bool fullScreen) override;
|
|
|
- DLLEXPORT void beginFrame(
|
|
|
- bool fill2D, bool fill3D, int fillColor) override;
|
|
|
- DLLEXPORT void renderKamera(Cam3D* zKamera) override;
|
|
|
- DLLEXPORT virtual void renderKamera(
|
|
|
- Cam3D* zKamera, Texture* zTarget) override;
|
|
|
- //! TODO: DLLEXPORT void renderKamera( Cam3D* zKamera, Texture* zTarget
|
|
|
- //! ) override;
|
|
|
- DLLEXPORT void presentFrame() override;
|
|
|
- DLLEXPORT Texture* createOrGetTexture(
|
|
|
- const char* name, Image* b) override;
|
|
|
- DLLEXPORT Image* zUIRenderImage() const override;
|
|
|
- DLLEXPORT virtual DXBuffer* createStructuredBuffer(int eSize) override;
|
|
|
-
|
|
|
- DLLEXPORT static bool isAvailable();
|
|
|
- };
|
|
|
} // namespace Framework
|