diff --git a/HelloTexturedCube/HelloTexturedCube.vcxproj b/HelloTexturedCube/HelloTexturedCube.vcxproj
index e0896e5..fd78064 100644
--- a/HelloTexturedCube/HelloTexturedCube.vcxproj
+++ b/HelloTexturedCube/HelloTexturedCube.vcxproj
@@ -45,23 +45,23 @@
- 16.0
+ 17.0
Win32Proj
{26bd6e61-e36d-464a-a312-4110adf10083}
HelloTexturedCube
- 10.0.20348.0
+ 10.0.22000.0
Application
true
- v142
+ v143
Unicode
Application
false
- v142
+ v143
true
Unicode
@@ -79,12 +79,6 @@
-
- true
-
-
- false
-
Level3
@@ -93,6 +87,7 @@
true
Use
pch.h
+ stdcpp20
Windows
@@ -113,6 +108,7 @@ xcopy /y $(ProjectDir)src\HelloTexturedCube.dds $(OutDir)Data\Textures\true
Use
pch.h
+ stdcpp20
Windows
diff --git a/HelloTexturedCube/src/HelloTexturedCubeGame.h b/HelloTexturedCube/src/HelloTexturedCubeGame.h
index 1318372..9409771 100644
--- a/HelloTexturedCube/src/HelloTexturedCubeGame.h
+++ b/HelloTexturedCube/src/HelloTexturedCubeGame.h
@@ -1,55 +1,52 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::Game
{
- namespace Game
+ class HelloTexturedCubeGame : public Singleton, public BaseGame
{
- class HelloTexturedCubeGame : public Singleton, public BaseGame
+ struct Vertex
{
- struct Vertex
- {
- float _x, _y, _z;
- UINT32 _color;
- };
- VERUS_TYPEDEFS(Vertex);
-
- VERUS_UBUFFER_STRUCT UB_ShaderVS
- {
- mataff _matW;
- matrix _matVP;
- };
-
- VERUS_UBUFFER_STRUCT UB_ShaderFS
- {
- float _phase;
- };
-
- Vector3 _rotation = Vector3(0);
- CGI::GeometryPwn _geo;
- CGI::ShaderPwn _shader;
- CGI::PipelinePwn _pipe;
- CGI::TexturePwn _tex;
- CSZ _shaderCode;
- CGI::CSHandle _csh; // Complex set handle. Simple set has one uniform buffer. Complex set additionally has textures.
- UB_ShaderVS _ubShaderVS;
- UB_ShaderFS _ubShaderFS;
- int _vertCount = 0;
- int _indexCount = 0;
-
- public:
- HelloTexturedCubeGame();
- ~HelloTexturedCubeGame();
-
- virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) override;
- virtual void BaseGame_LoadContent() override;
- virtual void BaseGame_UnloadContent() override;
- virtual void BaseGame_Update() override;
- virtual void BaseGame_Draw() override;
- virtual void BaseGame_DrawView(CGI::RcViewDesc viewDesc) override;
+ float _x, _y, _z;
+ UINT32 _color;
};
- VERUS_TYPEDEFS(HelloTexturedCubeGame);
- }
+ VERUS_TYPEDEFS(Vertex);
+
+ VERUS_UBUFFER_STRUCT UB_ShaderVS
+ {
+ mataff _matW;
+ matrix _matVP;
+ };
+
+ VERUS_UBUFFER_STRUCT UB_ShaderFS
+ {
+ float _phase;
+ };
+
+ Vector3 _rotation = Vector3(0);
+ CGI::GeometryPwn _geo;
+ CGI::ShaderPwn _shader;
+ CGI::PipelinePwn _pipe;
+ CGI::TexturePwn _tex;
+ CSZ _shaderCode;
+ CGI::CSHandle _csh; // Complex set handle. Simple set has one uniform buffer. Complex set additionally has textures.
+ UB_ShaderVS _ubShaderVS;
+ UB_ShaderFS _ubShaderFS;
+ int _vertCount = 0;
+ int _indexCount = 0;
+
+ public:
+ HelloTexturedCubeGame();
+ ~HelloTexturedCubeGame();
+
+ virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) override;
+ virtual void BaseGame_LoadContent() override;
+ virtual void BaseGame_UnloadContent() override;
+ virtual void BaseGame_Update() override;
+ virtual void BaseGame_Draw() override;
+ virtual void BaseGame_DrawView(CGI::RcViewDesc viewDesc) override;
+ };
+ VERUS_TYPEDEFS(HelloTexturedCubeGame);
}
#define VERUS_QREF_GAME Game::RHelloTexturedCubeGame game = Game::HelloTexturedCubeGame::I()
diff --git a/HelloTriangle/HelloTriangle.vcxproj b/HelloTriangle/HelloTriangle.vcxproj
index 38b5e84..ff2a6a8 100644
--- a/HelloTriangle/HelloTriangle.vcxproj
+++ b/HelloTriangle/HelloTriangle.vcxproj
@@ -45,23 +45,23 @@
- 16.0
+ 17.0
Win32Proj
{bc17acd3-97eb-4d5c-a2c9-574cdaa7576b}
HelloTriangle
- 10.0.20348.0
+ 10.0.22000.0
Application
true
- v142
+ v143
Unicode
Application
false
- v142
+ v143
true
Unicode
@@ -79,12 +79,6 @@
-
- true
-
-
- false
-
Level3
@@ -93,6 +87,7 @@
true
Use
pch.h
+ stdcpp20
Windows
@@ -109,6 +104,7 @@
true
Use
pch.h
+ stdcpp20
Windows
diff --git a/HelloTriangle/src/HelloTriangleGame.h b/HelloTriangle/src/HelloTriangleGame.h
index 8787cba..39d9ccd 100644
--- a/HelloTriangle/src/HelloTriangleGame.h
+++ b/HelloTriangle/src/HelloTriangleGame.h
@@ -1,55 +1,52 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::Game
{
- namespace Game
+ // Epigraph
+ // "Vulkan – (it takes) 1000 lines to draw a triangle"
+ // "- I thought you only needed 3 lines to draw a triangle"
+ // https://www.reddit.com/r/linux/comments/58fyqn/vulkan_1000_lines_to_draw_a_triangle/
+
+ class HelloTriangleGame : public Singleton, public BaseGame
{
- // Epigraph
- // "Vulkan – (it takes) 1000 lines to draw a triangle"
- // "- I thought you only needed 3 lines to draw a triangle"
- // https://www.reddit.com/r/linux/comments/58fyqn/vulkan_1000_lines_to_draw_a_triangle/
-
- class HelloTriangleGame : public Singleton, public BaseGame
+ struct Vertex
{
- struct Vertex
- {
- float _x, _y, _z;
- UINT32 _color;
- };
- VERUS_TYPEDEFS(Vertex);
-
- VERUS_UBUFFER_STRUCT UB_ShaderVS
- {
- matrix _matWVP;
- };
-
- VERUS_UBUFFER_STRUCT UB_ShaderFS
- {
- float _phase;
- };
-
- CGI::GeometryPwn _geo;
- CGI::ShaderPwn _shader;
- CGI::PipelinePwn _pipe;
- CSZ _shaderCode;
- UB_ShaderVS _ubShaderVS;
- UB_ShaderFS _ubShaderFS;
- int _vertCount = 0;
-
- public:
- HelloTriangleGame();
- ~HelloTriangleGame();
-
- virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) override;
- virtual void BaseGame_LoadContent() override;
- virtual void BaseGame_UnloadContent() override;
- virtual void BaseGame_Update() override;
- virtual void BaseGame_Draw() override;
- virtual void BaseGame_DrawView(CGI::RcViewDesc viewDesc) override;
+ float _x, _y, _z;
+ UINT32 _color;
};
- VERUS_TYPEDEFS(HelloTriangleGame);
- }
+ VERUS_TYPEDEFS(Vertex);
+
+ VERUS_UBUFFER_STRUCT UB_ShaderVS
+ {
+ matrix _matWVP;
+ };
+
+ VERUS_UBUFFER_STRUCT UB_ShaderFS
+ {
+ float _phase;
+ };
+
+ CGI::GeometryPwn _geo;
+ CGI::ShaderPwn _shader;
+ CGI::PipelinePwn _pipe;
+ CSZ _shaderCode;
+ UB_ShaderVS _ubShaderVS;
+ UB_ShaderFS _ubShaderFS;
+ int _vertCount = 0;
+
+ public:
+ HelloTriangleGame();
+ ~HelloTriangleGame();
+
+ virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) override;
+ virtual void BaseGame_LoadContent() override;
+ virtual void BaseGame_UnloadContent() override;
+ virtual void BaseGame_Update() override;
+ virtual void BaseGame_Draw() override;
+ virtual void BaseGame_DrawView(CGI::RcViewDesc viewDesc) override;
+ };
+ VERUS_TYPEDEFS(HelloTriangleGame);
}
#define VERUS_QREF_GAME Game::RHelloTriangleGame game = Game::HelloTriangleGame::I()
diff --git a/PAKBuilder/PAKBuilder.vcxproj b/PAKBuilder/PAKBuilder.vcxproj
index 6c1b5ac..b8e12c8 100644
--- a/PAKBuilder/PAKBuilder.vcxproj
+++ b/PAKBuilder/PAKBuilder.vcxproj
@@ -11,23 +11,23 @@
- 16.0
+ 17.0
Win32Proj
{EBF1E2F9-65AA-419D-A3D3-AD66EB086E57}
PAKBuilder
- 10.0.20348.0
+ 10.0.22000.0
Application
true
- v142
+ v143
Unicode
Application
false
- v142
+ v143
true
Unicode
@@ -45,18 +45,13 @@
-
- true
-
-
- false
-
Level3
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
+ stdcpp20
Console
@@ -71,6 +66,7 @@
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
+ stdcpp20
Console
diff --git a/RendererDirect3D11/RendererDirect3D11.vcxproj b/RendererDirect3D11/RendererDirect3D11.vcxproj
index 87d0d84..a818c74 100644
--- a/RendererDirect3D11/RendererDirect3D11.vcxproj
+++ b/RendererDirect3D11/RendererDirect3D11.vcxproj
@@ -11,23 +11,23 @@
- 16.0
+ 17.0
Win32Proj
{8269dcce-e226-46e4-b9f6-290ab5df2678}
RendererDirect3D11
- 10.0.20348.0
+ 10.0.22000.0
DynamicLibrary
true
- v142
+ v143
Unicode
DynamicLibrary
false
- v142
+ v143
true
Unicode
@@ -45,12 +45,6 @@
-
- true
-
-
- false
-
Level3
@@ -61,6 +55,7 @@
pch.h
Fast
$(ProjectDir)src;%(AdditionalIncludeDirectories)
+ stdcpp20
Windows
@@ -80,6 +75,7 @@
pch.h
Fast
$(ProjectDir)src;%(AdditionalIncludeDirectories)
+ stdcpp20
Windows
diff --git a/RendererDirect3D11/src/CGI/CommandBufferD3D11.h b/RendererDirect3D11/src/CGI/CommandBufferD3D11.h
index 8af1185..ba58ffa 100644
--- a/RendererDirect3D11/src/CGI/CommandBufferD3D11.h
+++ b/RendererDirect3D11/src/CGI/CommandBufferD3D11.h
@@ -1,65 +1,62 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class CommandBufferD3D11 : public BaseCommandBuffer
{
- class CommandBufferD3D11 : public BaseCommandBuffer
- {
- ComPtr _pDeviceContext;
- RP::PcD3DRenderPass _pRenderPass = nullptr;
- RP::PcD3DFramebuffer _pFramebuffer = nullptr;
- Vector _vClearValues;
- int _subpassIndex = 0;
- float _blendFactor[4];
+ ComPtr _pDeviceContext;
+ RP::PcD3DRenderPass _pRenderPass = nullptr;
+ RP::PcD3DFramebuffer _pFramebuffer = nullptr;
+ Vector _vClearValues;
+ int _subpassIndex = 0;
+ float _blendFactor[4];
- public:
- CommandBufferD3D11();
- virtual ~CommandBufferD3D11() override;
+ public:
+ CommandBufferD3D11();
+ virtual ~CommandBufferD3D11() override;
- virtual void Init() override;
- virtual void Done() override;
+ virtual void Init() override;
+ virtual void Done() override;
- virtual void InitOneTimeSubmit() override;
- virtual void DoneOneTimeSubmit() override;
+ virtual void InitOneTimeSubmit() override;
+ virtual void DoneOneTimeSubmit() override;
- virtual void Begin() override;
- virtual void End() override;
+ virtual void Begin() override;
+ virtual void End() override;
- virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, Range arrayLayers) override;
+ virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, Range arrayLayers) override;
- virtual void BeginRenderPass(RPHandle renderPassHandle, FBHandle framebufferHandle,
- std::initializer_list ilClearValues, ViewportScissorFlags vsf) override;
- virtual void NextSubpass() override;
- virtual void EndRenderPass() override;
+ virtual void BeginRenderPass(RPHandle renderPassHandle, FBHandle framebufferHandle,
+ std::initializer_list ilClearValues, ViewportScissorFlags vsf) override;
+ virtual void NextSubpass() override;
+ virtual void EndRenderPass() override;
- virtual void BindPipeline(PipelinePtr pipe) override;
- virtual void SetViewport(std::initializer_list il, float minDepth, float maxDepth) override;
- virtual void SetScissor(std::initializer_list il) override;
- virtual void SetBlendConstants(const float* p) override;
+ virtual void BindPipeline(PipelinePtr pipe) override;
+ virtual void SetViewport(std::initializer_list il, float minDepth, float maxDepth) override;
+ virtual void SetScissor(std::initializer_list il) override;
+ virtual void SetBlendConstants(const float* p) override;
- virtual void BindVertexBuffers(GeometryPtr geo, UINT32 bindingsFilter) override;
- virtual void BindIndexBuffer(GeometryPtr geo) override;
+ virtual void BindVertexBuffers(GeometryPtr geo, UINT32 bindingsFilter) override;
+ virtual void BindIndexBuffer(GeometryPtr geo) override;
- virtual bool BindDescriptors(ShaderPtr shader, int setNumber, CSHandle complexSetHandle) override;
- virtual bool BindDescriptors(ShaderPtr shader, int setNumber, GeometryPtr geo, int sbIndex) override;
- virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags) override;
+ virtual bool BindDescriptors(ShaderPtr shader, int setNumber, CSHandle complexSetHandle) override;
+ virtual bool BindDescriptors(ShaderPtr shader, int setNumber, GeometryPtr geo, int sbIndex) override;
+ virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags) override;
- virtual void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) override;
- virtual void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance) override;
- virtual void Dispatch(int groupCountX, int groupCountY, int groupCountZ) override;
- virtual void DispatchMesh(int groupCountX, int groupCountY, int groupCountZ) override;
- virtual void TraceRays(int width, int height, int depth) override;
+ virtual void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) override;
+ virtual void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance) override;
+ virtual void Dispatch(int groupCountX, int groupCountY, int groupCountZ) override;
+ virtual void DispatchMesh(int groupCountX, int groupCountY, int groupCountZ) override;
+ virtual void TraceRays(int width, int height, int depth) override;
- //
- // D3D11
- //
+ //
+ // D3D11
+ //
- ID3D11DeviceContext* GetD3DDeviceContext() const;
+ ID3D11DeviceContext* GetD3DDeviceContext() const;
- void PrepareSubpass();
- };
- VERUS_TYPEDEFS(CommandBufferD3D11);
- }
+ void PrepareSubpass();
+ };
+ VERUS_TYPEDEFS(CommandBufferD3D11);
}
diff --git a/RendererDirect3D11/src/CGI/ExtRealityD3D11.h b/RendererDirect3D11/src/CGI/ExtRealityD3D11.h
index 434e420..dc0ca82 100644
--- a/RendererDirect3D11/src/CGI/ExtRealityD3D11.h
+++ b/RendererDirect3D11/src/CGI/ExtRealityD3D11.h
@@ -1,66 +1,63 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class RendererD3D11;
+
+ class ExtRealityD3D11 : public BaseExtReality
{
- class RendererD3D11;
-
- class ExtRealityD3D11 : public BaseExtReality
+ struct SwapChainEx
{
- struct SwapChainEx
- {
- XrSwapchain _handle = XR_NULL_HANDLE;
- int32_t _width = 0;
- int32_t _height = 0;
- Vector _vImages;
- Vector> _vImageViews;
- };
-
- Vector _vSwapChains;
- LUID _adapterLuid;
- D3D_FEATURE_LEVEL _minFeatureLevel = D3D_FEATURE_LEVEL_11_0;
-
- public:
- ExtRealityD3D11();
- virtual ~ExtRealityD3D11() override;
-
- virtual void Init() override;
- virtual void Done() override;
-
- void InitByRenderer(RendererD3D11* pRenderer);
-
- private:
- void GetSystem();
- void CreateSwapChains(ID3D11Device* pDevice, int64_t format);
- ComPtr CreateImageView(ID3D11Device* pDevice, int64_t format, XrSwapchainImageD3D11KHR& image);
- virtual XrSwapchain GetSwapChain(int viewIndex) override;
- virtual void GetSwapChainSize(int viewIndex, int32_t& w, int32_t& h) override;
-
- public:
- LUID GetAdapterLuid() const { return _adapterLuid; }
- D3D_FEATURE_LEVEL GetMinFeatureLevel() const { return _minFeatureLevel; }
- ID3D11RenderTargetView* GetRTV(int viewIndex, int imageIndex) const;
-
- virtual void CreateActions() override;
- virtual void PollEvents() override;
- virtual void SyncActions(UINT32 activeActionSetsMask) override;
-
- virtual bool GetActionStateBoolean(int actionIndex, bool& currentState, bool* pChangedState, int subaction) override;
- virtual bool GetActionStateFloat(int actionIndex, float& currentState, bool* pChangedState, int subaction) override;
- virtual bool GetActionStatePose(int actionIndex, bool& currentState, Math::RPose pose, int subaction) override;
-
- virtual void BeginFrame() override;
- virtual int LocateViews() override;
- virtual void BeginView(int viewIndex, RViewDesc viewDesc) override;
- virtual void AcquireSwapChainImage() override;
- virtual void EndView(int viewIndex) override;
- virtual void EndFrame() override;
-
- virtual void BeginAreaUpdate() override;
- virtual void EndAreaUpdate(PcVector4 pUserOffset) override;
+ XrSwapchain _handle = XR_NULL_HANDLE;
+ int32_t _width = 0;
+ int32_t _height = 0;
+ Vector _vImages;
+ Vector> _vImageViews;
};
- VERUS_TYPEDEFS(ExtRealityD3D11);
- }
+
+ Vector _vSwapChains;
+ LUID _adapterLuid;
+ D3D_FEATURE_LEVEL _minFeatureLevel = D3D_FEATURE_LEVEL_11_0;
+
+ public:
+ ExtRealityD3D11();
+ virtual ~ExtRealityD3D11() override;
+
+ virtual void Init() override;
+ virtual void Done() override;
+
+ void InitByRenderer(RendererD3D11* pRenderer);
+
+ private:
+ void GetSystem();
+ void CreateSwapChains(ID3D11Device* pDevice, int64_t format);
+ ComPtr CreateImageView(ID3D11Device* pDevice, int64_t format, XrSwapchainImageD3D11KHR& image);
+ virtual XrSwapchain GetSwapChain(int viewIndex) override;
+ virtual void GetSwapChainSize(int viewIndex, int32_t& w, int32_t& h) override;
+
+ public:
+ LUID GetAdapterLuid() const { return _adapterLuid; }
+ D3D_FEATURE_LEVEL GetMinFeatureLevel() const { return _minFeatureLevel; }
+ ID3D11RenderTargetView* GetRTV(int viewIndex, int imageIndex) const;
+
+ virtual void CreateActions() override;
+ virtual void PollEvents() override;
+ virtual void SyncActions(UINT32 activeActionSetsMask) override;
+
+ virtual bool GetActionStateBoolean(int actionIndex, bool& currentState, bool* pChangedState, int subaction) override;
+ virtual bool GetActionStateFloat(int actionIndex, float& currentState, bool* pChangedState, int subaction) override;
+ virtual bool GetActionStatePose(int actionIndex, bool& currentState, Math::RPose pose, int subaction) override;
+
+ virtual void BeginFrame() override;
+ virtual int LocateViews() override;
+ virtual void BeginView(int viewIndex, RViewDesc viewDesc) override;
+ virtual void AcquireSwapChainImage() override;
+ virtual void EndView(int viewIndex) override;
+ virtual void EndFrame() override;
+
+ virtual void BeginAreaUpdate() override;
+ virtual void EndAreaUpdate(PcVector4 pUserOffset) override;
+ };
+ VERUS_TYPEDEFS(ExtRealityD3D11);
}
diff --git a/RendererDirect3D11/src/CGI/GeometryD3D11.h b/RendererDirect3D11/src/CGI/GeometryD3D11.h
index bff91e3..2a79f4d 100644
--- a/RendererDirect3D11/src/CGI/GeometryD3D11.h
+++ b/RendererDirect3D11/src/CGI/GeometryD3D11.h
@@ -1,61 +1,58 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class GeometryD3D11 : public BaseGeometry
{
- class GeometryD3D11 : public BaseGeometry
+ struct BufferEx
{
- struct BufferEx
- {
- ComPtr _pBuffer;
- UINT64 _bufferSize = 0;
- };
-
- struct StructuredBufferEx : BufferEx
- {
- ComPtr _pSRV;
- int _structSize = 0;
- };
-
- Vector _vVertexBuffers;
- BufferEx _indexBuffer;
- Vector _vStructuredBuffers;
- Vector _vInputElementDescs;
- Vector _vStrides;
-
- public:
- GeometryD3D11();
- virtual ~GeometryD3D11() override;
-
- virtual void Init(RcGeometryDesc desc) override;
- virtual void Done() override;
-
- virtual void CreateVertexBuffer(int count, int binding) override;
- virtual void UpdateVertexBuffer(const void* p, int binding, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
-
- virtual void CreateIndexBuffer(int count) override;
- virtual void UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
-
- virtual void CreateStorageBuffer(int count, int structSize, int sbIndex, ShaderStageFlags stageFlags) override;
- virtual void UpdateStorageBuffer(const void* p, int sbIndex, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
- virtual int GetStorageBufferStructSize(int sbIndex) const override;
-
- virtual Continue Scheduled_Update() override;
-
- //
- // D3D11
- //
-
- void GetD3DInputElementDescs(UINT32 bindingsFilter, Vector& vInputElementDescs) const;
- int GetStride(int binding) const { return _vStrides[binding]; }
-
- int GetVertexBufferCount() const { return Utils::Cast32(_vVertexBuffers.size()); }
- ID3D11Buffer* GetD3DVertexBuffer(int binding) const { return _vVertexBuffers[binding]._pBuffer.Get(); }
- ID3D11Buffer* GetD3DIndexBuffer() const { return _indexBuffer._pBuffer.Get(); }
- ID3D11ShaderResourceView* GetD3DStructuredBufferSRV(int sbIndex) const { return _vStructuredBuffers[sbIndex]._pSRV.Get(); }
+ ComPtr _pBuffer;
+ UINT64 _bufferSize = 0;
};
- VERUS_TYPEDEFS(GeometryD3D11);
- }
+
+ struct StructuredBufferEx : BufferEx
+ {
+ ComPtr _pSRV;
+ int _structSize = 0;
+ };
+
+ Vector _vVertexBuffers;
+ BufferEx _indexBuffer;
+ Vector _vStructuredBuffers;
+ Vector _vInputElementDescs;
+ Vector _vStrides;
+
+ public:
+ GeometryD3D11();
+ virtual ~GeometryD3D11() override;
+
+ virtual void Init(RcGeometryDesc desc) override;
+ virtual void Done() override;
+
+ virtual void CreateVertexBuffer(int count, int binding) override;
+ virtual void UpdateVertexBuffer(const void* p, int binding, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
+
+ virtual void CreateIndexBuffer(int count) override;
+ virtual void UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
+
+ virtual void CreateStorageBuffer(int count, int structSize, int sbIndex, ShaderStageFlags stageFlags) override;
+ virtual void UpdateStorageBuffer(const void* p, int sbIndex, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
+ virtual int GetStorageBufferStructSize(int sbIndex) const override;
+
+ virtual Continue Scheduled_Update() override;
+
+ //
+ // D3D11
+ //
+
+ void GetD3DInputElementDescs(UINT32 bindingsFilter, Vector& vInputElementDescs) const;
+ int GetStride(int binding) const { return _vStrides[binding]; }
+
+ int GetVertexBufferCount() const { return Utils::Cast32(_vVertexBuffers.size()); }
+ ID3D11Buffer* GetD3DVertexBuffer(int binding) const { return _vVertexBuffers[binding]._pBuffer.Get(); }
+ ID3D11Buffer* GetD3DIndexBuffer() const { return _indexBuffer._pBuffer.Get(); }
+ ID3D11ShaderResourceView* GetD3DStructuredBufferSRV(int sbIndex) const { return _vStructuredBuffers[sbIndex]._pSRV.Get(); }
+ };
+ VERUS_TYPEDEFS(GeometryD3D11);
}
diff --git a/RendererDirect3D11/src/CGI/Native.h b/RendererDirect3D11/src/CGI/Native.h
index eb30bc8..2b62394 100644
--- a/RendererDirect3D11/src/CGI/Native.h
+++ b/RendererDirect3D11/src/CGI/Native.h
@@ -1,24 +1,21 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
- {
- D3D11_COMPARISON_FUNC ToNativeCompareOp(CompareOp compareOp);
+ D3D11_COMPARISON_FUNC ToNativeCompareOp(CompareOp compareOp);
- UINT ToNativeCubeMapFace(CubeMapFace face);
+ UINT ToNativeCubeMapFace(CubeMapFace face);
- D3D11_FILL_MODE ToNativePolygonMode(PolygonMode polygonMode);
+ D3D11_FILL_MODE ToNativePolygonMode(PolygonMode polygonMode);
- D3D11_CULL_MODE ToNativeCullMode(CullMode cullMode);
+ D3D11_CULL_MODE ToNativeCullMode(CullMode cullMode);
- D3D_PRIMITIVE_TOPOLOGY ToNativePrimitiveTopology(PrimitiveTopology primitiveTopology);
+ D3D_PRIMITIVE_TOPOLOGY ToNativePrimitiveTopology(PrimitiveTopology primitiveTopology);
- DXGI_FORMAT ToNativeFormat(Format format, bool typeless);
- DXGI_FORMAT ToNativeSampledDepthFormat(Format format);
+ DXGI_FORMAT ToNativeFormat(Format format, bool typeless);
+ DXGI_FORMAT ToNativeSampledDepthFormat(Format format);
- CSZ ToNativeSemanticName(ViaUsage usage);
- DXGI_FORMAT ToNativeFormat(ViaUsage usage, ViaType type, int components);
- }
+ CSZ ToNativeSemanticName(ViaUsage usage);
+ DXGI_FORMAT ToNativeFormat(ViaUsage usage, ViaType type, int components);
}
diff --git a/RendererDirect3D11/src/CGI/PipelineD3D11.h b/RendererDirect3D11/src/CGI/PipelineD3D11.h
index f14ccb5..d3fbc1d 100644
--- a/RendererDirect3D11/src/CGI/PipelineD3D11.h
+++ b/RendererDirect3D11/src/CGI/PipelineD3D11.h
@@ -1,55 +1,52 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class PipelineD3D11 : public BasePipeline
{
- class PipelineD3D11 : public BasePipeline
- {
- ComPtr _pVS;
- ComPtr _pHS;
- ComPtr _pDS;
- ComPtr _pGS;
- ComPtr _pPS;
- ComPtr _pCS;
- ComPtr _pBlendState;
- ComPtr _pRasterizerState;
- ComPtr _pDepthStencilState;
- ComPtr _pInputLayout;
- UINT _sampleMask = UINT_MAX;
- UINT _stencilRef = 0;
- D3D_PRIMITIVE_TOPOLOGY _topology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
- bool _compute = false;
+ ComPtr _pVS;
+ ComPtr _pHS;
+ ComPtr _pDS;
+ ComPtr _pGS;
+ ComPtr _pPS;
+ ComPtr _pCS;
+ ComPtr _pBlendState;
+ ComPtr _pRasterizerState;
+ ComPtr _pDepthStencilState;
+ ComPtr _pInputLayout;
+ UINT _sampleMask = UINT_MAX;
+ UINT _stencilRef = 0;
+ D3D_PRIMITIVE_TOPOLOGY _topology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
+ bool _compute = false;
- public:
- PipelineD3D11();
- virtual ~PipelineD3D11() override;
+ public:
+ PipelineD3D11();
+ virtual ~PipelineD3D11() override;
- virtual void Init(RcPipelineDesc desc) override;
- virtual void Done() override;
+ virtual void Init(RcPipelineDesc desc) override;
+ virtual void Done() override;
- //
- // D3D11
- //
+ //
+ // D3D11
+ //
- VERUS_P(void InitCompute(RcPipelineDesc desc));
- bool IsCompute() const { return _compute; }
- ID3D11VertexShader* GetD3DVS() const { return _pVS.Get(); }
- ID3D11HullShader* GetD3DHS() const { return _pHS.Get(); }
- ID3D11DomainShader* GetD3DDS() const { return _pDS.Get(); }
- ID3D11GeometryShader* GetD3DGS() const { return _pGS.Get(); }
- ID3D11PixelShader* GetD3DPS() const { return _pPS.Get(); }
- ID3D11ComputeShader* GetD3DCS() const { return _pCS.Get(); }
- ID3D11BlendState* GetD3DBlendState() const { return _pBlendState.Get(); }
- ID3D11RasterizerState* GetD3DRasterizerState() const { return _pRasterizerState.Get(); }
- ID3D11DepthStencilState* GetD3DDepthStencilState() const { return _pDepthStencilState.Get(); }
- ID3D11InputLayout* GetD3DInputLayout() const { return _pInputLayout.Get(); }
- UINT GetSampleMask() const { return _sampleMask; }
- UINT GetStencilRef() const { return _stencilRef; }
- D3D_PRIMITIVE_TOPOLOGY GetD3DPrimitiveTopology() const { return _topology; }
- void FillBlendStateRenderTargets(RcPipelineDesc desc, int attachmentCount, D3D11_BLEND_DESC& blendDesc);
- };
- VERUS_TYPEDEFS(PipelineD3D11);
- }
+ VERUS_P(void InitCompute(RcPipelineDesc desc));
+ bool IsCompute() const { return _compute; }
+ ID3D11VertexShader* GetD3DVS() const { return _pVS.Get(); }
+ ID3D11HullShader* GetD3DHS() const { return _pHS.Get(); }
+ ID3D11DomainShader* GetD3DDS() const { return _pDS.Get(); }
+ ID3D11GeometryShader* GetD3DGS() const { return _pGS.Get(); }
+ ID3D11PixelShader* GetD3DPS() const { return _pPS.Get(); }
+ ID3D11ComputeShader* GetD3DCS() const { return _pCS.Get(); }
+ ID3D11BlendState* GetD3DBlendState() const { return _pBlendState.Get(); }
+ ID3D11RasterizerState* GetD3DRasterizerState() const { return _pRasterizerState.Get(); }
+ ID3D11DepthStencilState* GetD3DDepthStencilState() const { return _pDepthStencilState.Get(); }
+ ID3D11InputLayout* GetD3DInputLayout() const { return _pInputLayout.Get(); }
+ UINT GetSampleMask() const { return _sampleMask; }
+ UINT GetStencilRef() const { return _stencilRef; }
+ D3D_PRIMITIVE_TOPOLOGY GetD3DPrimitiveTopology() const { return _topology; }
+ void FillBlendStateRenderTargets(RcPipelineDesc desc, int attachmentCount, D3D11_BLEND_DESC& blendDesc);
+ };
+ VERUS_TYPEDEFS(PipelineD3D11);
}
diff --git a/RendererDirect3D11/src/CGI/RenderPass.h b/RendererDirect3D11/src/CGI/RenderPass.h
index 27b3391..3e7d232 100644
--- a/RendererDirect3D11/src/CGI/RenderPass.h
+++ b/RendererDirect3D11/src/CGI/RenderPass.h
@@ -1,76 +1,70 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI::RP
{
- namespace CGI
+ class D3DAttachment
{
- namespace RP
- {
- class D3DAttachment
- {
- public:
- Format _format = Format::unormR8G8B8A8;
- int _sampleCount = 1;
- Attachment::LoadOp _loadOp = Attachment::LoadOp::load;
- Attachment::StoreOp _storeOp = Attachment::StoreOp::store;
- Attachment::LoadOp _stencilLoadOp = Attachment::LoadOp::dontCare;
- Attachment::StoreOp _stencilStoreOp = Attachment::StoreOp::dontCare;
- int _clearSubpassIndex = -1;
- };
- VERUS_TYPEDEFS(D3DAttachment);
+ public:
+ Format _format = Format::unormR8G8B8A8;
+ int _sampleCount = 1;
+ Attachment::LoadOp _loadOp = Attachment::LoadOp::load;
+ Attachment::StoreOp _storeOp = Attachment::StoreOp::store;
+ Attachment::LoadOp _stencilLoadOp = Attachment::LoadOp::dontCare;
+ Attachment::StoreOp _stencilStoreOp = Attachment::StoreOp::dontCare;
+ int _clearSubpassIndex = -1;
+ };
+ VERUS_TYPEDEFS(D3DAttachment);
- class D3DRef
- {
- public:
- int _index = -1;
- };
- VERUS_TYPEDEFS(D3DRef);
+ class D3DRef
+ {
+ public:
+ int _index = -1;
+ };
+ VERUS_TYPEDEFS(D3DRef);
- class D3DSubpass
- {
- public:
- Vector _vInput;
- Vector _vColor;
- Vector _vResolve;
- Vector _vPreserve;
- D3DRef _depthStencil;
- bool _depthStencilReadOnly = false;
- };
- VERUS_TYPEDEFS(D3DSubpass);
+ class D3DSubpass
+ {
+ public:
+ Vector _vInput;
+ Vector _vColor;
+ Vector _vResolve;
+ Vector _vPreserve;
+ D3DRef _depthStencil;
+ bool _depthStencilReadOnly = false;
+ };
+ VERUS_TYPEDEFS(D3DSubpass);
- class D3DDependency
- {
- public:
- };
- VERUS_TYPEDEFS(D3DDependency);
+ class D3DDependency
+ {
+ public:
+ };
+ VERUS_TYPEDEFS(D3DDependency);
- class D3DRenderPass
- {
- public:
- Vector _vAttachments;
- Vector _vSubpasses;
- };
- VERUS_TYPEDEFS(D3DRenderPass);
+ class D3DRenderPass
+ {
+ public:
+ Vector _vAttachments;
+ Vector _vSubpasses;
+ };
+ VERUS_TYPEDEFS(D3DRenderPass);
- class D3DFramebufferSubpass
- {
- public:
- Vector _vRTVs;
- ID3D11DepthStencilView* _pDSV = nullptr;
- };
- VERUS_TYPEDEFS(D3DFramebufferSubpass);
+ class D3DFramebufferSubpass
+ {
+ public:
+ Vector _vRTVs;
+ ID3D11DepthStencilView* _pDSV = nullptr;
+ };
+ VERUS_TYPEDEFS(D3DFramebufferSubpass);
- class D3DFramebuffer
- {
- public:
- Vector _vSubpasses;
- int _width = 0;
- int _height = 0;
- int _mipLevels = 1;
- CubeMapFace _cubeMapFace = CubeMapFace::none;
- };
- VERUS_TYPEDEFS(D3DFramebuffer);
- }
- }
+ class D3DFramebuffer
+ {
+ public:
+ Vector _vSubpasses;
+ int _width = 0;
+ int _height = 0;
+ int _mipLevels = 1;
+ CubeMapFace _cubeMapFace = CubeMapFace::none;
+ };
+ VERUS_TYPEDEFS(D3DFramebuffer);
}
diff --git a/RendererDirect3D11/src/CGI/RendererD3D11.h b/RendererDirect3D11/src/CGI/RendererD3D11.h
index b691a69..4590bfc 100644
--- a/RendererDirect3D11/src/CGI/RendererD3D11.h
+++ b/RendererDirect3D11/src/CGI/RendererD3D11.h
@@ -1,99 +1,96 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ typedef Store TStoreCommandBuffers;
+ typedef Store TStoreGeometry;
+ typedef Store TStorePipelines;
+ typedef Store TStoreShaders;
+ typedef Store TStoreTextures;
+ class RendererD3D11 : public Singleton, public BaseRenderer,
+ private TStoreCommandBuffers, private TStoreGeometry, private TStorePipelines, private TStoreShaders, private TStoreTextures
{
- typedef Store TStoreCommandBuffers;
- typedef Store TStoreGeometry;
- typedef Store TStorePipelines;
- typedef Store TStoreShaders;
- typedef Store TStoreTextures;
- class RendererD3D11 : public Singleton, public BaseRenderer,
- private TStoreCommandBuffers, private TStoreGeometry, private TStorePipelines, private TStoreShaders, private TStoreTextures
- {
- ExtRealityD3D11 _extReality;
- ComPtr _pDevice;
- ComPtr _pDeviceContext;
- ComPtr _pSwapChain;
- ComPtr _pSwapChainBuffer;
- ComPtr _pSwapChainBufferRTV;
+ ExtRealityD3D11 _extReality;
+ ComPtr _pDevice;
+ ComPtr _pDeviceContext;
+ ComPtr _pSwapChain;
+ ComPtr _pSwapChainBuffer;
+ ComPtr _pSwapChainBufferRTV;
- Vector> _vSamplers;
- Vector _vRenderPasses;
- Vector _vFramebuffers;
- D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
- DXGI_SWAP_CHAIN_DESC _swapChainDesc = {};
+ Vector> _vSamplers;
+ Vector _vRenderPasses;
+ Vector _vFramebuffers;
+ D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
+ DXGI_SWAP_CHAIN_DESC _swapChainDesc = {};
- public:
- RendererD3D11();
- ~RendererD3D11();
+ public:
+ RendererD3D11();
+ ~RendererD3D11();
- virtual void ReleaseMe() override;
+ virtual void ReleaseMe() override;
- void Init();
- void Done();
+ void Init();
+ void Done();
- private:
- static ComPtr CreateFactory();
- ComPtr GetAdapter(ComPtr pFactory) const;
- void CreateSwapChainBufferRTV();
- void InitD3D();
+ private:
+ static ComPtr CreateFactory();
+ ComPtr GetAdapter(ComPtr pFactory) const;
+ void CreateSwapChainBufferRTV();
+ void InitD3D();
- public:
- //
- void CreateSamplers();
+ public:
+ //
+ void CreateSamplers();
- ID3D11Device* GetD3DDevice() const { return _pDevice.Get(); }
- ID3D11DeviceContext* GetD3DDeviceContext() const { return _pDeviceContext.Get(); }
- ID3D11SamplerState* GetD3DSamplerState(Sampler s) const;
- //
+ ID3D11Device* GetD3DDevice() const { return _pDevice.Get(); }
+ ID3D11DeviceContext* GetD3DDeviceContext() const { return _pDeviceContext.Get(); }
+ ID3D11SamplerState* GetD3DSamplerState(Sampler s) const;
+ //
- virtual void ImGuiInit(RPHandle renderPassHandle) override;
- virtual void ImGuiRenderDrawData() override;
+ virtual void ImGuiInit(RPHandle renderPassHandle) override;
+ virtual void ImGuiRenderDrawData() override;
- virtual void ResizeSwapChain() override;
+ virtual void ResizeSwapChain() override;
- virtual PBaseExtReality GetExtReality() override;
+ virtual PBaseExtReality GetExtReality() override;
- // Which graphics API?
- virtual Gapi GetGapi() override { return Gapi::direct3D11; }
+ // Which graphics API?
+ virtual Gapi GetGapi() override { return Gapi::direct3D11; }
- //
- virtual void BeginFrame() override;
- virtual void AcquireSwapChainImage() override;
- virtual void EndFrame() override;
- virtual void WaitIdle() override;
- virtual void OnMinimized() override;
- //
+ //
+ virtual void BeginFrame() override;
+ virtual void AcquireSwapChainImage() override;
+ virtual void EndFrame() override;
+ virtual void WaitIdle() override;
+ virtual void OnMinimized() override;
+ //
- //
- virtual PBaseCommandBuffer InsertCommandBuffer() override;
- virtual PBaseGeometry InsertGeometry() override;
- virtual PBasePipeline InsertPipeline() override;
- virtual PBaseShader InsertShader() override;
- virtual PBaseTexture InsertTexture() override;
+ //
+ virtual PBaseCommandBuffer InsertCommandBuffer() override;
+ virtual PBaseGeometry InsertGeometry() override;
+ virtual PBasePipeline InsertPipeline() override;
+ virtual PBaseShader InsertShader() override;
+ virtual PBaseTexture InsertTexture() override;
- virtual void DeleteCommandBuffer(PBaseCommandBuffer p) override;
- virtual void DeleteGeometry(PBaseGeometry p) override;
- virtual void DeletePipeline(PBasePipeline p) override;
- virtual void DeleteShader(PBaseShader p) override;
- virtual void DeleteTexture(PBaseTexture p) override;
+ virtual void DeleteCommandBuffer(PBaseCommandBuffer p) override;
+ virtual void DeleteGeometry(PBaseGeometry p) override;
+ virtual void DeletePipeline(PBasePipeline p) override;
+ virtual void DeleteShader(PBaseShader p) override;
+ virtual void DeleteTexture(PBaseTexture p) override;
- virtual RPHandle CreateRenderPass(std::initializer_list ilA, std::initializer_list ilS, std::initializer_list ilD) override;
- virtual FBHandle CreateFramebuffer(RPHandle renderPassHandle, std::initializer_list il, int w, int h,
- int swapChainBufferIndex = -1, CubeMapFace cubeMapFace = CubeMapFace::none) override;
- virtual void DeleteRenderPass(RPHandle handle) override;
- virtual void DeleteFramebuffer(FBHandle handle) override;
- int GetNextRenderPassIndex() const;
- int GetNextFramebufferIndex() const;
- RP::RcD3DRenderPass GetRenderPass(RPHandle handle) const;
- RP::RcD3DFramebuffer GetFramebuffer(FBHandle handle) const;
- //
- };
- VERUS_TYPEDEFS(RendererD3D11);
- }
+ virtual RPHandle CreateRenderPass(std::initializer_list ilA, std::initializer_list ilS, std::initializer_list ilD) override;
+ virtual FBHandle CreateFramebuffer(RPHandle renderPassHandle, std::initializer_list il, int w, int h,
+ int swapChainBufferIndex = -1, CubeMapFace cubeMapFace = CubeMapFace::none) override;
+ virtual void DeleteRenderPass(RPHandle handle) override;
+ virtual void DeleteFramebuffer(FBHandle handle) override;
+ int GetNextRenderPassIndex() const;
+ int GetNextFramebufferIndex() const;
+ RP::RcD3DRenderPass GetRenderPass(RPHandle handle) const;
+ RP::RcD3DFramebuffer GetFramebuffer(FBHandle handle) const;
+ //
+ };
+ VERUS_TYPEDEFS(RendererD3D11);
}
#define VERUS_QREF_RENDERER_D3D11 CGI::PRendererD3D11 pRendererD3D11 = CGI::RendererD3D11::P()
diff --git a/RendererDirect3D11/src/CGI/ShaderD3D11.cpp b/RendererDirect3D11/src/CGI/ShaderD3D11.cpp
index afec405..c1f9e11 100644
--- a/RendererDirect3D11/src/CGI/ShaderD3D11.cpp
+++ b/RendererDirect3D11/src/CGI/ShaderD3D11.cpp
@@ -59,13 +59,13 @@ void ShaderD3D11::Init(CSZ source, CSZ sourceName, CSZ* branches)
ComPtr pBlob;
auto CheckErrorMsgs = [this](ComPtr& pErrorMsgs)
- {
- if (pErrorMsgs)
{
- OnError(static_cast(pErrorMsgs->GetBufferPointer()));
- pErrorMsgs.Reset();
- }
- };
+ if (pErrorMsgs)
+ {
+ OnError(static_cast(pErrorMsgs->GetBufferPointer()));
+ pErrorMsgs.Reset();
+ }
+ };
while (*branches)
{
@@ -191,10 +191,10 @@ void ShaderD3D11::Done()
for (auto& dsd : _vDescriptorSetDesc)
dsd._pConstantBuffer.Reset();
- for (auto& x : _mapCompiled)
+ for (auto& [key, value] : _mapCompiled)
{
VERUS_FOR(i, +Stage::count)
- x.second._pBlobs[i].Reset();
+ value._pBlobs[i].Reset();
}
VERUS_DONE(ShaderD3D11);
diff --git a/RendererDirect3D11/src/CGI/ShaderD3D11.h b/RendererDirect3D11/src/CGI/ShaderD3D11.h
index e48ed25..dd272d6 100644
--- a/RendererDirect3D11/src/CGI/ShaderD3D11.h
+++ b/RendererDirect3D11/src/CGI/ShaderD3D11.h
@@ -1,108 +1,105 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ struct ShaderInclude : public ID3DInclude
{
- struct ShaderInclude : public ID3DInclude
+ public:
+ virtual HRESULT STDMETHODCALLTYPE Open(
+ D3D_INCLUDE_TYPE IncludeType,
+ LPCSTR pFileName,
+ LPCVOID pParentData,
+ LPCVOID* ppData,
+ UINT* pBytes) override;
+ virtual HRESULT STDMETHODCALLTYPE Close(LPCVOID pData) override;
+ };
+ VERUS_TYPEDEFS(ShaderInclude);
+
+ struct ShaderResources
+ {
+ UINT _srvCount = 0;
+ UINT _uavCount = 0;
+ UINT _srvStartSlot = 0;
+ UINT _uavStartSlot = 0;
+ ID3D11ShaderResourceView* _srvs[VERUS_MAX_FB_ATTACH];
+ ID3D11UnorderedAccessView* _uavs[VERUS_MAX_FB_ATTACH];
+ ID3D11SamplerState* _samplers[VERUS_MAX_FB_ATTACH];
+ };
+ VERUS_TYPEDEFS(ShaderResources);
+
+ class ShaderD3D11 : public BaseShader
+ {
+ public:
+ struct Compiled
{
- public:
- virtual HRESULT STDMETHODCALLTYPE Open(
- D3D_INCLUDE_TYPE IncludeType,
- LPCSTR pFileName,
- LPCVOID pParentData,
- LPCVOID* ppData,
- UINT* pBytes) override;
- virtual HRESULT STDMETHODCALLTYPE Close(LPCVOID pData) override;
+ ComPtr _pBlobs[+Stage::count];
+ String _entry;
+ int _stageCount = 0;
};
- VERUS_TYPEDEFS(ShaderInclude);
+ VERUS_TYPEDEFS(Compiled);
- struct ShaderResources
+ private:
+ typedef Map TMapCompiled;
+
+ struct DescriptorSetDesc
{
- UINT _srvCount = 0;
- UINT _uavCount = 0;
- UINT _srvStartSlot = 0;
- UINT _uavStartSlot = 0;
- ID3D11ShaderResourceView* _srvs[VERUS_MAX_FB_ATTACH];
- ID3D11UnorderedAccessView* _uavs[VERUS_MAX_FB_ATTACH];
- ID3D11SamplerState* _samplers[VERUS_MAX_FB_ATTACH];
+ Vector _vSamplers;
+ ComPtr _pConstantBuffer;
+ const void* _pSrc = nullptr;
+ int _size = 0;
+ int _alignedSize = 0;
+ int _capacity = 1;
+ int _capacityInBytes = 0;
+ UINT _srvCount = 0;
+ UINT _uavCount = 0;
+ UINT _srvStartSlot = 0;
+ UINT _uavStartSlot = 0;
+ ShaderStageFlags _stageFlags = ShaderStageFlags::vs_fs;
};
- VERUS_TYPEDEFS(ShaderResources);
- class ShaderD3D11 : public BaseShader
+ struct ComplexSet
{
- public:
- struct Compiled
- {
- ComPtr _pBlobs[+Stage::count];
- String _entry;
- int _stageCount = 0;
- };
- VERUS_TYPEDEFS(Compiled);
-
- private:
- typedef Map TMapCompiled;
-
- struct DescriptorSetDesc
- {
- Vector _vSamplers;
- ComPtr _pConstantBuffer;
- const void* _pSrc = nullptr;
- int _size = 0;
- int _alignedSize = 0;
- int _capacity = 1;
- int _capacityInBytes = 0;
- UINT _srvCount = 0;
- UINT _uavCount = 0;
- UINT _srvStartSlot = 0;
- UINT _uavStartSlot = 0;
- ShaderStageFlags _stageFlags = ShaderStageFlags::vs_fs;
- };
-
- struct ComplexSet
- {
- Vector _vTextures;
- Vector _vSRVs;
- Vector _vUAVs;
- };
- VERUS_TYPEDEFS(ComplexSet);
-
- TMapCompiled _mapCompiled;
- Vector _vDescriptorSetDesc;
- Vector _vComplexSets;
- bool _compute = false;
-
- public:
- ShaderD3D11();
- virtual ~ShaderD3D11() override;
-
- virtual void Init(CSZ source, CSZ sourceName, CSZ* branches) override;
- virtual void Done() override;
-
- virtual void CreateDescriptorSet(int setNumber, const void* pSrc, int size, int capacity, std::initializer_list il, ShaderStageFlags stageFlags) override;
- virtual void CreatePipelineLayout() override;
- virtual CSHandle BindDescriptorSetTextures(int setNumber, std::initializer_list il, const int* pMipLevels, const int* pArrayLayers) override;
- virtual void FreeDescriptorSet(CSHandle& complexSetHandle) override;
-
- virtual void BeginBindDescriptors() override;
- virtual void EndBindDescriptors() override;
-
- //
- // D3D11
- //
-
- RcCompiled GetCompiled(CSZ branch) const { return _mapCompiled.at(branch); }
-
- ID3D11Buffer* UpdateConstantBuffer(int setNumber) const;
- ShaderStageFlags GetShaderStageFlags(int setNumber) const;
- void GetShaderResources(int setNumber, int complexSetHandle, RShaderResources shaderResources) const;
- void GetSamplers(int setNumber, int complexSetHandle, RShaderResources shaderResources) const;
- int GetDescriptorSetCount() const { return static_cast(_vDescriptorSetDesc.size()); }
- bool IsCompute() const { return _compute; }
-
- void OnError(CSZ s) const;
+ Vector _vTextures;
+ Vector _vSRVs;
+ Vector _vUAVs;
};
- VERUS_TYPEDEFS(ShaderD3D11);
- }
+ VERUS_TYPEDEFS(ComplexSet);
+
+ TMapCompiled _mapCompiled;
+ Vector _vDescriptorSetDesc;
+ Vector _vComplexSets;
+ bool _compute = false;
+
+ public:
+ ShaderD3D11();
+ virtual ~ShaderD3D11() override;
+
+ virtual void Init(CSZ source, CSZ sourceName, CSZ* branches) override;
+ virtual void Done() override;
+
+ virtual void CreateDescriptorSet(int setNumber, const void* pSrc, int size, int capacity, std::initializer_list il, ShaderStageFlags stageFlags) override;
+ virtual void CreatePipelineLayout() override;
+ virtual CSHandle BindDescriptorSetTextures(int setNumber, std::initializer_list il, const int* pMipLevels, const int* pArrayLayers) override;
+ virtual void FreeDescriptorSet(CSHandle& complexSetHandle) override;
+
+ virtual void BeginBindDescriptors() override;
+ virtual void EndBindDescriptors() override;
+
+ //
+ // D3D11
+ //
+
+ RcCompiled GetCompiled(CSZ branch) const { return _mapCompiled.at(branch); }
+
+ ID3D11Buffer* UpdateConstantBuffer(int setNumber) const;
+ ShaderStageFlags GetShaderStageFlags(int setNumber) const;
+ void GetShaderResources(int setNumber, int complexSetHandle, RShaderResources shaderResources) const;
+ void GetSamplers(int setNumber, int complexSetHandle, RShaderResources shaderResources) const;
+ int GetDescriptorSetCount() const { return static_cast(_vDescriptorSetDesc.size()); }
+ bool IsCompute() const { return _compute; }
+
+ void OnError(CSZ s) const;
+ };
+ VERUS_TYPEDEFS(ShaderD3D11);
}
diff --git a/RendererDirect3D11/src/CGI/TextureD3D11.h b/RendererDirect3D11/src/CGI/TextureD3D11.h
index c758e22..44f1a31 100644
--- a/RendererDirect3D11/src/CGI/TextureD3D11.h
+++ b/RendererDirect3D11/src/CGI/TextureD3D11.h
@@ -1,56 +1,53 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class TextureD3D11 : public BaseTexture
{
- class TextureD3D11 : public BaseTexture
- {
- ComPtr _pTexture2D;
- ComPtr _pTexture3D;
- ComPtr _pUaTexture;
- Vector> _vReadbackTextures;
- Vector _vCshGenerateMips;
- ComPtr _pSRV;
- Vector> _vUAVs;
- Vector> _vRTVs;
- ComPtr _pDSV[2];
- ComPtr _pSamplerState;
+ ComPtr _pTexture2D;
+ ComPtr _pTexture3D;
+ ComPtr _pUaTexture;
+ Vector> _vReadbackTextures;
+ Vector _vCshGenerateMips;
+ ComPtr _pSRV;
+ Vector> _vUAVs;
+ Vector> _vRTVs;
+ ComPtr _pDSV[2];
+ ComPtr _pSamplerState;
- public:
- TextureD3D11();
- virtual ~TextureD3D11() override;
+ public:
+ TextureD3D11();
+ virtual ~TextureD3D11() override;
- virtual void Init(RcTextureDesc desc) override;
- virtual void Done() override;
+ virtual void Init(RcTextureDesc desc) override;
+ virtual void Done() override;
- virtual void UpdateSubresource(const void* p, int mipLevel, int arrayLayer, PBaseCommandBuffer pCB) override;
- virtual bool ReadbackSubresource(void* p, bool recordCopyCommand, PBaseCommandBuffer pCB) override;
+ virtual void UpdateSubresource(const void* p, int mipLevel, int arrayLayer, PBaseCommandBuffer pCB) override;
+ virtual bool ReadbackSubresource(void* p, bool recordCopyCommand, PBaseCommandBuffer pCB) override;
- virtual void GenerateMips(PBaseCommandBuffer pCB) override;
- void GenerateCubeMapMips(PBaseCommandBuffer pCB);
+ virtual void GenerateMips(PBaseCommandBuffer pCB) override;
+ void GenerateCubeMapMips(PBaseCommandBuffer pCB);
- virtual Continue Scheduled_Update() override;
+ virtual Continue Scheduled_Update() override;
- //
- // D3D11
- //
+ //
+ // D3D11
+ //
- void ClearCshGenerateMips();
+ void ClearCshGenerateMips();
- void CreateSampler();
+ void CreateSampler();
- ID3D11Resource* GetD3DResource() const;
+ ID3D11Resource* GetD3DResource() const;
- ID3D11ShaderResourceView* GetSRV() const { return _pSRV.Get(); }
- ID3D11UnorderedAccessView* GetUAV(int index = 0) const { return _vUAVs[index].Get(); }
- ID3D11RenderTargetView* GetRTV(int index = 0) const { return _vRTVs[index].Get(); }
- ID3D11DepthStencilView* GetDSV(bool readOnly = false) const { return readOnly ? _pDSV[1].Get() : _pDSV[0].Get(); }
- ID3D11SamplerState* GetD3DSamplerState() const { return _pSamplerState.Get(); }
+ ID3D11ShaderResourceView* GetSRV() const { return _pSRV.Get(); }
+ ID3D11UnorderedAccessView* GetUAV(int index = 0) const { return _vUAVs[index].Get(); }
+ ID3D11RenderTargetView* GetRTV(int index = 0) const { return _vRTVs[index].Get(); }
+ ID3D11DepthStencilView* GetDSV(bool readOnly = false) const { return readOnly ? _pDSV[1].Get() : _pDSV[0].Get(); }
+ ID3D11SamplerState* GetD3DSamplerState() const { return _pSamplerState.Get(); }
- static DXGI_FORMAT RemoveSRGB(DXGI_FORMAT format);
- };
- VERUS_TYPEDEFS(TextureD3D11);
- }
+ static DXGI_FORMAT RemoveSRGB(DXGI_FORMAT format);
+ };
+ VERUS_TYPEDEFS(TextureD3D11);
}
diff --git a/RendererDirect3D12/RendererDirect3D12.vcxproj b/RendererDirect3D12/RendererDirect3D12.vcxproj
index 7d88163..56a2abd 100644
--- a/RendererDirect3D12/RendererDirect3D12.vcxproj
+++ b/RendererDirect3D12/RendererDirect3D12.vcxproj
@@ -11,23 +11,23 @@
- 16.0
+ 17.0
Win32Proj
{53923514-84B2-4B78-889A-8709C6BFA3A5}
RendererDirect3D12
- 10.0.20348.0
+ 10.0.22000.0
DynamicLibrary
true
- v142
+ v143
Unicode
DynamicLibrary
false
- v142
+ v143
true
Unicode
@@ -45,12 +45,6 @@
-
- true
-
-
- false
-
Level3
@@ -61,6 +55,7 @@
pch.h
Fast
$(ProjectDir)src;%(AdditionalIncludeDirectories)
+ stdcpp20
Windows
@@ -80,6 +75,7 @@
pch.h
Fast
$(ProjectDir)src;%(AdditionalIncludeDirectories)
+ stdcpp20
Windows
diff --git a/RendererDirect3D12/src/CGI/CommandBufferD3D12.h b/RendererDirect3D12/src/CGI/CommandBufferD3D12.h
index 7bbf5a1..3f5ba0b 100644
--- a/RendererDirect3D12/src/CGI/CommandBufferD3D12.h
+++ b/RendererDirect3D12/src/CGI/CommandBufferD3D12.h
@@ -1,71 +1,68 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class CommandBufferD3D12 : public BaseCommandBuffer
{
- class CommandBufferD3D12 : public BaseCommandBuffer
- {
- ComPtr _pOneTimeCommandAllocator;
- ComPtr _pCommandLists[BaseRenderer::s_ringBufferSize];
- RP::PcD3DRenderPass _pRenderPass = nullptr;
- RP::PcD3DFramebuffer _pFramebuffer = nullptr;
- Vector _vClearValues;
- Vector _vAttachmentStates;
- Vector _vBarriers;
- int _subpassIndex = 0;
+ ComPtr _pOneTimeCommandAllocator;
+ ComPtr _pCommandLists[BaseRenderer::s_ringBufferSize];
+ RP::PcD3DRenderPass _pRenderPass = nullptr;
+ RP::PcD3DFramebuffer _pFramebuffer = nullptr;
+ Vector _vClearValues;
+ Vector _vAttachmentStates;
+ Vector _vBarriers;
+ int _subpassIndex = 0;
- public:
- CommandBufferD3D12();
- virtual ~CommandBufferD3D12() override;
+ public:
+ CommandBufferD3D12();
+ virtual ~CommandBufferD3D12() override;
- virtual void Init() override;
- virtual void Done() override;
+ virtual void Init() override;
+ virtual void Done() override;
- virtual void InitOneTimeSubmit() override;
- virtual void DoneOneTimeSubmit() override;
+ virtual void InitOneTimeSubmit() override;
+ virtual void DoneOneTimeSubmit() override;
- virtual void Begin() override;
- virtual void End() override;
+ virtual void Begin() override;
+ virtual void End() override;
- virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, Range arrayLayers) override;
+ virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, Range arrayLayers) override;
- virtual void BeginRenderPass(RPHandle renderPassHandle, FBHandle framebufferHandle,
- std::initializer_list ilClearValues, ViewportScissorFlags vsf) override;
- virtual void NextSubpass() override;
- virtual void EndRenderPass() override;
+ virtual void BeginRenderPass(RPHandle renderPassHandle, FBHandle framebufferHandle,
+ std::initializer_list ilClearValues, ViewportScissorFlags vsf) override;
+ virtual void NextSubpass() override;
+ virtual void EndRenderPass() override;
- virtual void BindPipeline(PipelinePtr pipe) override;
- virtual void SetViewport(std::initializer_list il, float minDepth, float maxDepth) override;
- virtual void SetScissor(std::initializer_list il) override;
- virtual void SetBlendConstants(const float* p) override;
+ virtual void BindPipeline(PipelinePtr pipe) override;
+ virtual void SetViewport(std::initializer_list il, float minDepth, float maxDepth) override;
+ virtual void SetScissor(std::initializer_list il) override;
+ virtual void SetBlendConstants(const float* p) override;
- virtual void BindVertexBuffers(GeometryPtr geo, UINT32 bindingsFilter) override;
- virtual void BindIndexBuffer(GeometryPtr geo) override;
+ virtual void BindVertexBuffers(GeometryPtr geo, UINT32 bindingsFilter) override;
+ virtual void BindIndexBuffer(GeometryPtr geo) override;
- virtual bool BindDescriptors(ShaderPtr shader, int setNumber, CSHandle complexSetHandle) override;
- virtual bool BindDescriptors(ShaderPtr shader, int setNumber, GeometryPtr geo, int sbIndex) override;
- virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags) override;
+ virtual bool BindDescriptors(ShaderPtr shader, int setNumber, CSHandle complexSetHandle) override;
+ virtual bool BindDescriptors(ShaderPtr shader, int setNumber, GeometryPtr geo, int sbIndex) override;
+ virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags) override;
- virtual void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) override;
- virtual void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance) override;
- virtual void Dispatch(int groupCountX, int groupCountY, int groupCountZ) override;
- virtual void DispatchMesh(int groupCountX, int groupCountY, int groupCountZ) override;
- virtual void TraceRays(int width, int height, int depth) override;
+ virtual void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) override;
+ virtual void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance) override;
+ virtual void Dispatch(int groupCountX, int groupCountY, int groupCountZ) override;
+ virtual void DispatchMesh(int groupCountX, int groupCountY, int groupCountZ) override;
+ virtual void TraceRays(int width, int height, int depth) override;
- virtual void ProfilerBeginEvent(UINT32 color, CSZ text) override;
- virtual void ProfilerEndEvent() override;
- virtual void ProfilerSetMarker(UINT32 color, CSZ text) override;
+ virtual void ProfilerBeginEvent(UINT32 color, CSZ text) override;
+ virtual void ProfilerEndEvent() override;
+ virtual void ProfilerSetMarker(UINT32 color, CSZ text) override;
- //
- // D3D12
- //
+ //
+ // D3D12
+ //
- ID3D12GraphicsCommandList3* GetD3DGraphicsCommandList() const;
+ ID3D12GraphicsCommandList3* GetD3DGraphicsCommandList() const;
- void PrepareSubpass();
- };
- VERUS_TYPEDEFS(CommandBufferD3D12);
- }
+ void PrepareSubpass();
+ };
+ VERUS_TYPEDEFS(CommandBufferD3D12);
}
diff --git a/RendererDirect3D12/src/CGI/DescriptorHeap.h b/RendererDirect3D12/src/CGI/DescriptorHeap.h
index 41bb70b..5bb3c76 100644
--- a/RendererDirect3D12/src/CGI/DescriptorHeap.h
+++ b/RendererDirect3D12/src/CGI/DescriptorHeap.h
@@ -1,61 +1,58 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class DescriptorHeap
{
- class DescriptorHeap
- {
- ComPtr _pDescriptorHeap;
- CD3DX12_CPU_DESCRIPTOR_HANDLE _hCPUHandleForHeapStart;
- CD3DX12_GPU_DESCRIPTOR_HANDLE _hGPUHandleForHeapStart;
- D3D12_DESCRIPTOR_HEAP_TYPE _type = D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES;
- UINT _handleIncrementSize = 0;
+ ComPtr _pDescriptorHeap;
+ CD3DX12_CPU_DESCRIPTOR_HANDLE _hCPUHandleForHeapStart;
+ CD3DX12_GPU_DESCRIPTOR_HANDLE _hGPUHandleForHeapStart;
+ D3D12_DESCRIPTOR_HEAP_TYPE _type = D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES;
+ UINT _handleIncrementSize = 0;
- public:
- void Reset() { VERUS_COM_RELEASE_CHECK(_pDescriptorHeap.Get()); _pDescriptorHeap.Reset(); }
+ public:
+ void Reset() { VERUS_COM_RELEASE_CHECK(_pDescriptorHeap.Get()); _pDescriptorHeap.Reset(); }
- ID3D12DescriptorHeap* GetD3DDescriptorHeap() const { return _pDescriptorHeap.Get(); }
+ ID3D12DescriptorHeap* GetD3DDescriptorHeap() const { return _pDescriptorHeap.Get(); }
- void Create(ID3D12Device* pDevice, D3D12_DESCRIPTOR_HEAP_TYPE type, int count, bool shaderVisible = false);
+ void Create(ID3D12Device* pDevice, D3D12_DESCRIPTOR_HEAP_TYPE type, int count, bool shaderVisible = false);
- CD3DX12_CPU_DESCRIPTOR_HANDLE AtCPU(int index) const;
- CD3DX12_GPU_DESCRIPTOR_HANDLE AtGPU(int index) const;
+ CD3DX12_CPU_DESCRIPTOR_HANDLE AtCPU(int index) const;
+ CD3DX12_GPU_DESCRIPTOR_HANDLE AtGPU(int index) const;
- D3D12_DESCRIPTOR_HEAP_TYPE GetType() const { return _type; }
- UINT GetHandleIncrementSize() const { return _handleIncrementSize; }
- };
- VERUS_TYPEDEFS(DescriptorHeap);
+ D3D12_DESCRIPTOR_HEAP_TYPE GetType() const { return _type; }
+ UINT GetHandleIncrementSize() const { return _handleIncrementSize; }
+ };
+ VERUS_TYPEDEFS(DescriptorHeap);
- struct HandlePair
- {
- CD3DX12_CPU_DESCRIPTOR_HANDLE _hCPU;
- CD3DX12_GPU_DESCRIPTOR_HANDLE _hGPU;
+ struct HandlePair
+ {
+ CD3DX12_CPU_DESCRIPTOR_HANDLE _hCPU;
+ CD3DX12_GPU_DESCRIPTOR_HANDLE _hGPU;
- HandlePair(
- CD3DX12_CPU_DESCRIPTOR_HANDLE hCPU = D3D12_DEFAULT,
- CD3DX12_GPU_DESCRIPTOR_HANDLE hGPU = D3D12_DEFAULT) : _hCPU(hCPU), _hGPU(hGPU) {}
- };
- VERUS_TYPEDEFS(HandlePair);
+ HandlePair(
+ CD3DX12_CPU_DESCRIPTOR_HANDLE hCPU = D3D12_DEFAULT,
+ CD3DX12_GPU_DESCRIPTOR_HANDLE hGPU = D3D12_DEFAULT) : _hCPU(hCPU), _hGPU(hGPU) {}
+ };
+ VERUS_TYPEDEFS(HandlePair);
- // This descriptor heap should be refilled every frame:
- class DynamicDescriptorHeap : public DescriptorHeap
- {
- int _capacity = 0;
- int _offset = 0;
- UINT64 _currentFrame = UINT64_MAX;
- UINT64 _peakLoad = 0;
+ // This descriptor heap should be refilled every frame:
+ class DynamicDescriptorHeap : public DescriptorHeap
+ {
+ int _capacity = 0;
+ int _offset = 0;
+ UINT64 _currentFrame = UINT64_MAX;
+ UINT64 _peakLoad = 0;
- public:
- void Create(ID3D12Device* pDevice, D3D12_DESCRIPTOR_HEAP_TYPE type, int count, int staticCount = 0, bool shaderVisible = false);
+ public:
+ void Create(ID3D12Device* pDevice, D3D12_DESCRIPTOR_HEAP_TYPE type, int count, int staticCount = 0, bool shaderVisible = false);
- HandlePair GetNextHandlePair(int count = 1);
- HandlePair GetStaticHandlePair(int index);
+ HandlePair GetNextHandlePair(int count = 1);
+ HandlePair GetStaticHandlePair(int index);
- int GetCapacity() const { return _capacity; }
- int GetOffset() const { return _offset; }
- };
- VERUS_TYPEDEFS(DynamicDescriptorHeap);
- }
+ int GetCapacity() const { return _capacity; }
+ int GetOffset() const { return _offset; }
+ };
+ VERUS_TYPEDEFS(DynamicDescriptorHeap);
}
diff --git a/RendererDirect3D12/src/CGI/ExtRealityD3D12.h b/RendererDirect3D12/src/CGI/ExtRealityD3D12.h
index 5998f08..29beae0 100644
--- a/RendererDirect3D12/src/CGI/ExtRealityD3D12.h
+++ b/RendererDirect3D12/src/CGI/ExtRealityD3D12.h
@@ -1,67 +1,64 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class RendererD3D12;
+
+ class ExtRealityD3D12 : public BaseExtReality
{
- class RendererD3D12;
-
- class ExtRealityD3D12 : public BaseExtReality
+ struct SwapChainEx
{
- struct SwapChainEx
- {
- XrSwapchain _handle = XR_NULL_HANDLE;
- int32_t _width = 0;
- int32_t _height = 0;
- Vector _vImages;
- DescriptorHeap _dhImageViews;
- };
-
- Vector _vSwapChains;
- LUID _adapterLuid;
- D3D_FEATURE_LEVEL _minFeatureLevel = D3D_FEATURE_LEVEL_11_0;
-
- public:
- ExtRealityD3D12();
- virtual ~ExtRealityD3D12() override;
-
- virtual void Init() override;
- virtual void Done() override;
-
- void InitByRenderer(RendererD3D12* pRenderer);
-
- private:
- void GetSystem();
- void CreateSwapChains(ID3D12Device* pDevice, int64_t format);
- void CreateImageView(ID3D12Device* pDevice, int64_t format, XrSwapchainImageD3D12KHR& image, D3D12_CPU_DESCRIPTOR_HANDLE handle);
- virtual XrSwapchain GetSwapChain(int viewIndex) override;
- virtual void GetSwapChainSize(int viewIndex, int32_t& w, int32_t& h) override;
-
- public:
- LUID GetAdapterLuid() const { return _adapterLuid; }
- D3D_FEATURE_LEVEL GetMinFeatureLevel() const { return _minFeatureLevel; }
- ID3D12Resource* GetD3DResource(int viewIndex, int imageIndex) const;
- D3D12_CPU_DESCRIPTOR_HANDLE GetRTV(int viewIndex, int imageIndex) const;
-
- virtual void CreateActions() override;
- virtual void PollEvents() override;
- virtual void SyncActions(UINT32 activeActionSetsMask) override;
-
- virtual bool GetActionStateBoolean(int actionIndex, bool& currentState, bool* pChangedState, int subaction) override;
- virtual bool GetActionStateFloat(int actionIndex, float& currentState, bool* pChangedState, int subaction) override;
- virtual bool GetActionStatePose(int actionIndex, bool& currentState, Math::RPose pose, int subaction) override;
-
- virtual void BeginFrame() override;
- virtual int LocateViews() override;
- virtual void BeginView(int viewIndex, RViewDesc viewDesc) override;
- virtual void AcquireSwapChainImage() override;
- virtual void EndView(int viewIndex) override;
- virtual void EndFrame() override;
-
- virtual void BeginAreaUpdate() override;
- virtual void EndAreaUpdate(PcVector4 pUserOffset) override;
+ XrSwapchain _handle = XR_NULL_HANDLE;
+ int32_t _width = 0;
+ int32_t _height = 0;
+ Vector _vImages;
+ DescriptorHeap _dhImageViews;
};
- VERUS_TYPEDEFS(ExtRealityD3D12);
- }
+
+ Vector _vSwapChains;
+ LUID _adapterLuid;
+ D3D_FEATURE_LEVEL _minFeatureLevel = D3D_FEATURE_LEVEL_11_0;
+
+ public:
+ ExtRealityD3D12();
+ virtual ~ExtRealityD3D12() override;
+
+ virtual void Init() override;
+ virtual void Done() override;
+
+ void InitByRenderer(RendererD3D12* pRenderer);
+
+ private:
+ void GetSystem();
+ void CreateSwapChains(ID3D12Device* pDevice, int64_t format);
+ void CreateImageView(ID3D12Device* pDevice, int64_t format, XrSwapchainImageD3D12KHR& image, D3D12_CPU_DESCRIPTOR_HANDLE handle);
+ virtual XrSwapchain GetSwapChain(int viewIndex) override;
+ virtual void GetSwapChainSize(int viewIndex, int32_t& w, int32_t& h) override;
+
+ public:
+ LUID GetAdapterLuid() const { return _adapterLuid; }
+ D3D_FEATURE_LEVEL GetMinFeatureLevel() const { return _minFeatureLevel; }
+ ID3D12Resource* GetD3DResource(int viewIndex, int imageIndex) const;
+ D3D12_CPU_DESCRIPTOR_HANDLE GetRTV(int viewIndex, int imageIndex) const;
+
+ virtual void CreateActions() override;
+ virtual void PollEvents() override;
+ virtual void SyncActions(UINT32 activeActionSetsMask) override;
+
+ virtual bool GetActionStateBoolean(int actionIndex, bool& currentState, bool* pChangedState, int subaction) override;
+ virtual bool GetActionStateFloat(int actionIndex, float& currentState, bool* pChangedState, int subaction) override;
+ virtual bool GetActionStatePose(int actionIndex, bool& currentState, Math::RPose pose, int subaction) override;
+
+ virtual void BeginFrame() override;
+ virtual int LocateViews() override;
+ virtual void BeginView(int viewIndex, RViewDesc viewDesc) override;
+ virtual void AcquireSwapChainImage() override;
+ virtual void EndView(int viewIndex) override;
+ virtual void EndFrame() override;
+
+ virtual void BeginAreaUpdate() override;
+ virtual void EndAreaUpdate(PcVector4 pUserOffset) override;
+ };
+ VERUS_TYPEDEFS(ExtRealityD3D12);
}
diff --git a/RendererDirect3D12/src/CGI/GeometryD3D12.h b/RendererDirect3D12/src/CGI/GeometryD3D12.h
index 0e2b067..2ce658a 100644
--- a/RendererDirect3D12/src/CGI/GeometryD3D12.h
+++ b/RendererDirect3D12/src/CGI/GeometryD3D12.h
@@ -1,72 +1,69 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class GeometryD3D12 : public BaseGeometry
{
- class GeometryD3D12 : public BaseGeometry
+ struct BufferEx
{
- struct BufferEx
- {
- D3D12MA::Allocation* _pMaAllocation = nullptr;
- ComPtr _pBuffer;
- UINT64 _bufferSize = 0;
- INT64 _utilization = -1;
- };
-
- struct VertexBufferEx : BufferEx
- {
- D3D12_VERTEX_BUFFER_VIEW _bufferView[BaseRenderer::s_ringBufferSize] = {};
- };
-
- struct StructuredBufferEx : BufferEx
- {
- DescriptorHeap _dhDynamicOffsets;
- int _structSize = 0;
- };
-
- Vector _vVertexBuffers;
- BufferEx _indexBuffer;
- Vector _vStagingVertexBuffers;
- BufferEx _stagingIndexBuffer;
- Vector _vStructuredBuffers;
- D3D12_INDEX_BUFFER_VIEW _indexBufferView[BaseRenderer::s_ringBufferSize] = {};
- Vector _vInputElementDescs;
- Vector _vStrides;
-
- public:
- GeometryD3D12();
- virtual ~GeometryD3D12() override;
-
- virtual void Init(RcGeometryDesc desc) override;
- virtual void Done() override;
-
- virtual void CreateVertexBuffer(int count, int binding) override;
- virtual void UpdateVertexBuffer(const void* p, int binding, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
-
- virtual void CreateIndexBuffer(int count) override;
- virtual void UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
-
- virtual void CreateStorageBuffer(int count, int structSize, int sbIndex, ShaderStageFlags stageFlags) override;
- virtual void UpdateStorageBuffer(const void* p, int sbIndex, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
- virtual int GetStorageBufferStructSize(int sbIndex) const override;
-
- virtual Continue Scheduled_Update() override;
-
- //
- // D3D12
- //
-
- D3D12_INPUT_LAYOUT_DESC GetD3DInputLayoutDesc(UINT32 bindingsFilter, Vector& vInputElementDescs) const;
-
- int GetVertexBufferCount() const { return Utils::Cast32(_vVertexBuffers.size()); }
- const D3D12_VERTEX_BUFFER_VIEW* GetD3DVertexBufferView(int binding) const;
- const D3D12_INDEX_BUFFER_VIEW* GetD3DIndexBufferView() const;
- CD3DX12_GPU_DESCRIPTOR_HANDLE CopyStructuredBufferView(int sbIndex) const;
-
- void UpdateUtilization() const;
+ D3D12MA::Allocation* _pMaAllocation = nullptr;
+ ComPtr _pBuffer;
+ UINT64 _bufferSize = 0;
+ INT64 _utilization = -1;
};
- VERUS_TYPEDEFS(GeometryD3D12);
- }
+
+ struct VertexBufferEx : BufferEx
+ {
+ D3D12_VERTEX_BUFFER_VIEW _bufferView[BaseRenderer::s_ringBufferSize] = {};
+ };
+
+ struct StructuredBufferEx : BufferEx
+ {
+ DescriptorHeap _dhDynamicOffsets;
+ int _structSize = 0;
+ };
+
+ Vector _vVertexBuffers;
+ BufferEx _indexBuffer;
+ Vector _vStagingVertexBuffers;
+ BufferEx _stagingIndexBuffer;
+ Vector _vStructuredBuffers;
+ D3D12_INDEX_BUFFER_VIEW _indexBufferView[BaseRenderer::s_ringBufferSize] = {};
+ Vector _vInputElementDescs;
+ Vector _vStrides;
+
+ public:
+ GeometryD3D12();
+ virtual ~GeometryD3D12() override;
+
+ virtual void Init(RcGeometryDesc desc) override;
+ virtual void Done() override;
+
+ virtual void CreateVertexBuffer(int count, int binding) override;
+ virtual void UpdateVertexBuffer(const void* p, int binding, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
+
+ virtual void CreateIndexBuffer(int count) override;
+ virtual void UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
+
+ virtual void CreateStorageBuffer(int count, int structSize, int sbIndex, ShaderStageFlags stageFlags) override;
+ virtual void UpdateStorageBuffer(const void* p, int sbIndex, PBaseCommandBuffer pCB, INT64 size, INT64 offset) override;
+ virtual int GetStorageBufferStructSize(int sbIndex) const override;
+
+ virtual Continue Scheduled_Update() override;
+
+ //
+ // D3D12
+ //
+
+ D3D12_INPUT_LAYOUT_DESC GetD3DInputLayoutDesc(UINT32 bindingsFilter, Vector& vInputElementDescs) const;
+
+ int GetVertexBufferCount() const { return Utils::Cast32(_vVertexBuffers.size()); }
+ const D3D12_VERTEX_BUFFER_VIEW* GetD3DVertexBufferView(int binding) const;
+ const D3D12_INDEX_BUFFER_VIEW* GetD3DIndexBufferView() const;
+ CD3DX12_GPU_DESCRIPTOR_HANDLE CopyStructuredBufferView(int sbIndex) const;
+
+ void UpdateUtilization() const;
+ };
+ VERUS_TYPEDEFS(GeometryD3D12);
}
diff --git a/RendererDirect3D12/src/CGI/Native.h b/RendererDirect3D12/src/CGI/Native.h
index 5a0155b..685d026 100644
--- a/RendererDirect3D12/src/CGI/Native.h
+++ b/RendererDirect3D12/src/CGI/Native.h
@@ -1,27 +1,24 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
- {
- D3D12_COMPARISON_FUNC ToNativeCompareOp(CompareOp compareOp);
+ D3D12_COMPARISON_FUNC ToNativeCompareOp(CompareOp compareOp);
- UINT ToNativeCubeMapFace(CubeMapFace face);
+ UINT ToNativeCubeMapFace(CubeMapFace face);
- D3D12_FILL_MODE ToNativePolygonMode(PolygonMode polygonMode);
+ D3D12_FILL_MODE ToNativePolygonMode(PolygonMode polygonMode);
- D3D12_CULL_MODE ToNativeCullMode(CullMode cullMode);
+ D3D12_CULL_MODE ToNativeCullMode(CullMode cullMode);
- D3D_PRIMITIVE_TOPOLOGY ToNativePrimitiveTopology(PrimitiveTopology primitiveTopology);
- D3D12_PRIMITIVE_TOPOLOGY_TYPE ToNativePrimitiveTopologyType(PrimitiveTopology primitiveTopology);
+ D3D_PRIMITIVE_TOPOLOGY ToNativePrimitiveTopology(PrimitiveTopology primitiveTopology);
+ D3D12_PRIMITIVE_TOPOLOGY_TYPE ToNativePrimitiveTopologyType(PrimitiveTopology primitiveTopology);
- D3D12_RESOURCE_STATES ToNativeImageLayout(ImageLayout layout);
+ D3D12_RESOURCE_STATES ToNativeImageLayout(ImageLayout layout);
- DXGI_FORMAT ToNativeFormat(Format format, bool typeless);
- DXGI_FORMAT ToNativeSampledDepthFormat(Format format);
+ DXGI_FORMAT ToNativeFormat(Format format, bool typeless);
+ DXGI_FORMAT ToNativeSampledDepthFormat(Format format);
- CSZ ToNativeSemanticName(ViaUsage usage);
- DXGI_FORMAT ToNativeFormat(ViaUsage usage, ViaType type, int components);
- }
+ CSZ ToNativeSemanticName(ViaUsage usage);
+ DXGI_FORMAT ToNativeFormat(ViaUsage usage, ViaType type, int components);
}
diff --git a/RendererDirect3D12/src/CGI/PipelineD3D12.h b/RendererDirect3D12/src/CGI/PipelineD3D12.h
index 28bf067..ff8344b 100644
--- a/RendererDirect3D12/src/CGI/PipelineD3D12.h
+++ b/RendererDirect3D12/src/CGI/PipelineD3D12.h
@@ -1,37 +1,34 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ class PipelineD3D12 : public BasePipeline
{
- class PipelineD3D12 : public BasePipeline
- {
- ComPtr _pPipelineState;
- ID3D12RootSignature* _pRootSignature = nullptr;
- D3D_PRIMITIVE_TOPOLOGY _topology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
- bool _compute = false;
+ ComPtr _pPipelineState;
+ ID3D12RootSignature* _pRootSignature = nullptr;
+ D3D_PRIMITIVE_TOPOLOGY _topology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
+ bool _compute = false;
- public:
- PipelineD3D12();
- virtual ~PipelineD3D12() override;
+ public:
+ PipelineD3D12();
+ virtual ~PipelineD3D12() override;
- virtual void Init(RcPipelineDesc desc) override;
- virtual void Done() override;
+ virtual void Init(RcPipelineDesc desc) override;
+ virtual void Done() override;
- //
- // D3D12
- //
+ //
+ // D3D12
+ //
- VERUS_P(void InitCompute(RcPipelineDesc desc));
- VERUS_P(void InitMeshShading(RcPipelineDesc desc));
- D3D12_SHADER_BYTECODE ToBytecode(ID3DBlob* pBlob);
- bool IsCompute() const { return _compute; }
- ID3D12PipelineState* GetD3DPipelineState() const { return _pPipelineState.Get(); }
- ID3D12RootSignature* GetD3DRootSignature() const { return _pRootSignature; }
- D3D_PRIMITIVE_TOPOLOGY GetD3DPrimitiveTopology() const { return _topology; }
- void FillBlendStateRenderTargets(RcPipelineDesc desc, int attachmentCount, D3D12_BLEND_DESC& blendDesc);
- };
- VERUS_TYPEDEFS(PipelineD3D12);
- }
+ VERUS_P(void InitCompute(RcPipelineDesc desc));
+ VERUS_P(void InitMeshShading(RcPipelineDesc desc));
+ D3D12_SHADER_BYTECODE ToBytecode(ID3DBlob* pBlob);
+ bool IsCompute() const { return _compute; }
+ ID3D12PipelineState* GetD3DPipelineState() const { return _pPipelineState.Get(); }
+ ID3D12RootSignature* GetD3DRootSignature() const { return _pRootSignature; }
+ D3D_PRIMITIVE_TOPOLOGY GetD3DPrimitiveTopology() const { return _topology; }
+ void FillBlendStateRenderTargets(RcPipelineDesc desc, int attachmentCount, D3D12_BLEND_DESC& blendDesc);
+ };
+ VERUS_TYPEDEFS(PipelineD3D12);
}
diff --git a/RendererDirect3D12/src/CGI/RenderPass.h b/RendererDirect3D12/src/CGI/RenderPass.h
index e30b204..1e42977 100644
--- a/RendererDirect3D12/src/CGI/RenderPass.h
+++ b/RendererDirect3D12/src/CGI/RenderPass.h
@@ -1,80 +1,74 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI::RP
{
- namespace CGI
+ class D3DAttachment
{
- namespace RP
- {
- class D3DAttachment
- {
- public:
- Format _format = Format::unormR8G8B8A8;
- int _sampleCount = 1;
- Attachment::LoadOp _loadOp = Attachment::LoadOp::load;
- Attachment::StoreOp _storeOp = Attachment::StoreOp::store;
- Attachment::LoadOp _stencilLoadOp = Attachment::LoadOp::dontCare;
- Attachment::StoreOp _stencilStoreOp = Attachment::StoreOp::dontCare;
- D3D12_RESOURCE_STATES _initialState = D3D12_RESOURCE_STATE_COMMON;
- D3D12_RESOURCE_STATES _finalState = D3D12_RESOURCE_STATE_COMMON;
- int _clearSubpassIndex = -1;
- };
- VERUS_TYPEDEFS(D3DAttachment);
+ public:
+ Format _format = Format::unormR8G8B8A8;
+ int _sampleCount = 1;
+ Attachment::LoadOp _loadOp = Attachment::LoadOp::load;
+ Attachment::StoreOp _storeOp = Attachment::StoreOp::store;
+ Attachment::LoadOp _stencilLoadOp = Attachment::LoadOp::dontCare;
+ Attachment::StoreOp _stencilStoreOp = Attachment::StoreOp::dontCare;
+ D3D12_RESOURCE_STATES _initialState = D3D12_RESOURCE_STATE_COMMON;
+ D3D12_RESOURCE_STATES _finalState = D3D12_RESOURCE_STATE_COMMON;
+ int _clearSubpassIndex = -1;
+ };
+ VERUS_TYPEDEFS(D3DAttachment);
- class D3DRef
- {
- public:
- int _index = -1;
- D3D12_RESOURCE_STATES _state = D3D12_RESOURCE_STATE_COMMON;
- };
- VERUS_TYPEDEFS(D3DRef);
+ class D3DRef
+ {
+ public:
+ int _index = -1;
+ D3D12_RESOURCE_STATES _state = D3D12_RESOURCE_STATE_COMMON;
+ };
+ VERUS_TYPEDEFS(D3DRef);
- class D3DSubpass
- {
- public:
- Vector _vInput;
- Vector _vColor;
- Vector _vResolve;
- Vector _vPreserve;
- D3DRef _depthStencil;
- };
- VERUS_TYPEDEFS(D3DSubpass);
+ class D3DSubpass
+ {
+ public:
+ Vector _vInput;
+ Vector _vColor;
+ Vector _vResolve;
+ Vector _vPreserve;
+ D3DRef _depthStencil;
+ };
+ VERUS_TYPEDEFS(D3DSubpass);
- class D3DDependency
- {
- public:
- };
- VERUS_TYPEDEFS(D3DDependency);
+ class D3DDependency
+ {
+ public:
+ };
+ VERUS_TYPEDEFS(D3DDependency);
- class D3DRenderPass
- {
- public:
- Vector _vAttachments;
- Vector _vSubpasses;
- };
- VERUS_TYPEDEFS(D3DRenderPass);
+ class D3DRenderPass
+ {
+ public:
+ Vector _vAttachments;
+ Vector _vSubpasses;
+ };
+ VERUS_TYPEDEFS(D3DRenderPass);
- class D3DFramebufferSubpass
- {
- public:
- Vector _vResources;
- DescriptorHeap _dhRTVs;
- DescriptorHeap _dhDSV;
- };
- VERUS_TYPEDEFS(D3DFramebufferSubpass);
+ class D3DFramebufferSubpass
+ {
+ public:
+ Vector _vResources;
+ DescriptorHeap _dhRTVs;
+ DescriptorHeap _dhDSV;
+ };
+ VERUS_TYPEDEFS(D3DFramebufferSubpass);
- class D3DFramebuffer
- {
- public:
- Vector _vResources;
- Vector _vSubpasses;
- int _width = 0;
- int _height = 0;
- int _mipLevels = 1;
- CubeMapFace _cubeMapFace = CubeMapFace::none;
- };
- VERUS_TYPEDEFS(D3DFramebuffer);
- }
- }
+ class D3DFramebuffer
+ {
+ public:
+ Vector _vResources;
+ Vector _vSubpasses;
+ int _width = 0;
+ int _height = 0;
+ int _mipLevels = 1;
+ CubeMapFace _cubeMapFace = CubeMapFace::none;
+ };
+ VERUS_TYPEDEFS(D3DFramebuffer);
}
diff --git a/RendererDirect3D12/src/CGI/RendererD3D12.h b/RendererDirect3D12/src/CGI/RendererD3D12.h
index c42efc5..d49ee77 100644
--- a/RendererDirect3D12/src/CGI/RendererD3D12.h
+++ b/RendererDirect3D12/src/CGI/RendererD3D12.h
@@ -1,129 +1,126 @@
// Copyright (C) 2021-2022, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
#pragma once
-namespace verus
+namespace verus::CGI
{
- namespace CGI
+ typedef Store TStoreCommandBuffers;
+ typedef Store TStoreGeometry;
+ typedef Store TStorePipelines;
+ typedef Store TStoreShaders;
+ typedef Store TStoreTextures;
+ class RendererD3D12 : public Singleton, public BaseRenderer,
+ private TStoreCommandBuffers, private TStoreGeometry, private TStorePipelines, private TStoreShaders, private TStoreTextures
{
- typedef Store TStoreCommandBuffers;
- typedef Store TStoreGeometry;
- typedef Store TStorePipelines;
- typedef Store TStoreShaders;
- typedef Store TStoreTextures;
- class RendererD3D12 : public Singleton, public BaseRenderer,
- private TStoreCommandBuffers, private TStoreGeometry, private TStorePipelines, private TStoreShaders, private TStoreTextures
- {
- typedef Map> TMapCommandAllocators;
+ typedef Map> TMapCommandAllocators;
- D3D12MA::Allocator* _pMaAllocator = nullptr;
- ExtRealityD3D12 _extReality;
- ComPtr _pDevice;
- ComPtr _pCommandQueue;
- ComPtr _pSwapChain;
- Vector> _vSwapChainBuffers;
- DescriptorHeap _dhSwapChainBuffersRTVs;
+ D3D12MA::Allocator* _pMaAllocator = nullptr;
+ ExtRealityD3D12 _extReality;
+ ComPtr _pDevice;
+ ComPtr _pCommandQueue;
+ ComPtr _pSwapChain;
+ Vector> _vSwapChainBuffers;
+ DescriptorHeap _dhSwapChainBuffersRTVs;
- DynamicDescriptorHeap _dhViews;
- DynamicDescriptorHeap _dhSamplers;
- TMapCommandAllocators _mapCommandAllocators[s_ringBufferSize];
- ComPtr _pFence;
- HANDLE _hFence = INVALID_HANDLE_VALUE;
- HANDLE _hFrameLatencyWaitableObject = INVALID_HANDLE_VALUE;
- UINT64 _nextFenceValue = 1;
- UINT64 _fenceValues[s_ringBufferSize] = {};
+ DynamicDescriptorHeap _dhViews;
+ DynamicDescriptorHeap _dhSamplers;
+ TMapCommandAllocators _mapCommandAllocators[s_ringBufferSize];
+ ComPtr _pFence;
+ HANDLE _hFence = INVALID_HANDLE_VALUE;
+ HANDLE _hFrameLatencyWaitableObject = INVALID_HANDLE_VALUE;
+ UINT64 _nextFenceValue = 1;
+ UINT64 _fenceValues[s_ringBufferSize] = {};
- Vector _vSamplers;
- Vector _vRenderPasses;
- Vector _vFramebuffers;
- D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
- DXGI_SWAP_CHAIN_DESC1 _swapChainDesc = {};
+ Vector _vSamplers;
+ Vector _vRenderPasses;
+ Vector _vFramebuffers;
+ D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
+ DXGI_SWAP_CHAIN_DESC1 _swapChainDesc = {};
- public:
- RendererD3D12();
- ~RendererD3D12();
+ public:
+ RendererD3D12();
+ ~RendererD3D12();
- virtual void ReleaseMe() override;
+ virtual void ReleaseMe() override;
- void Init();
- void Done();
+ void Init();
+ void Done();
- private:
- static void EnableDebugLayer();
- static ComPtr CreateFactory();
- ComPtr GetAdapter(ComPtr pFactory, D3D_FEATURE_LEVEL featureLevel) const;
- static bool CheckFeatureSupportAllowTearing(ComPtr pFactory);
- void CreateSwapChainBuffersRTVs();
- void InitD3D();
- void WaitForFrameLatencyWaitableObject();
+ private:
+ static void EnableDebugLayer();
+ static ComPtr CreateFactory();
+ ComPtr GetAdapter(ComPtr pFactory, D3D_FEATURE_LEVEL featureLevel) const;
+ static bool CheckFeatureSupportAllowTearing(ComPtr pFactory);
+ void CreateSwapChainBuffersRTVs();
+ void InitD3D();
+ void WaitForFrameLatencyWaitableObject();
- public:
- //
- ComPtr