First pass graphics pipeline. Not functional
This commit is contained in:
@@ -144,6 +144,7 @@
|
||||
<ClInclude Include="include\Graphics\Colors.h"/>
|
||||
<ClInclude Include="include\Graphics\Graphics.h"/>
|
||||
<ClInclude Include="include\Graphics\GraphicsConfig.h"/>
|
||||
<ClInclude Include="include\Graphics\GraphicsPipeline.h" />
|
||||
<ClInclude Include="include\Graphics\RenderPass.h"/>
|
||||
<ClInclude Include="include\Graphics\Shader.h" />
|
||||
<ClInclude Include="include\Graphics\Texture.h"/>
|
||||
@@ -165,6 +166,7 @@
|
||||
<ClInclude Include="src\Core\Networking\SocketPlatformImpl.h"/>
|
||||
<ClInclude Include="src\Core\HAL\Win32.h"/>
|
||||
<ClInclude Include="src\Graphics\D3D12\D3D12Common.h"/>
|
||||
<ClInclude Include="src\Graphics\D3D12\D3D12GraphicsPipeline.h" />
|
||||
<ClInclude Include="src\Graphics\D3D12\D3D12RenderPass.h"/>
|
||||
<ClInclude Include="src\Graphics\D3D12\D3D12Shader.h"/>
|
||||
<ClInclude Include="src\Graphics\D3D12\D3D12Synchronization.h"/>
|
||||
@@ -206,6 +208,7 @@
|
||||
<ClCompile Include="src\Core\Networking\Win32\Win32SocketPlatformImpl.cpp"/>
|
||||
<ClCompile Include="src\Engine\Engine.cpp"/>
|
||||
<ClCompile Include="src\Graphics\D3D12\D3D12Common.cpp"/>
|
||||
<ClCompile Include="src\Graphics\D3D12\D3D12GraphicsPipeline.cpp" />
|
||||
<ClCompile Include="src\Graphics\D3D12\D3D12RenderPass.cpp"/>
|
||||
<ClCompile Include="src\Graphics\D3D12\D3D12Shader.cpp"/>
|
||||
<ClCompile Include="src\Graphics\D3D12\D3D12Synchronization.cpp"/>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Core/HAL/Display/Display.h>
|
||||
#include <Core/Math/Shape.h>
|
||||
#include <Graphics/GraphicsConfig.h>
|
||||
#include <Graphics/GraphicsPipeline.h>
|
||||
#include <Graphics/RenderPass.h>
|
||||
#include <Graphics/Shader.h>
|
||||
#include <Juliet.h>
|
||||
@@ -12,6 +13,7 @@
|
||||
// Graphics Interface
|
||||
namespace Juliet
|
||||
{
|
||||
|
||||
// Opaque types
|
||||
struct CommandList;
|
||||
struct GraphicsDevice;
|
||||
@@ -91,6 +93,7 @@ namespace Juliet
|
||||
// SwapChain
|
||||
extern JULIET_API bool AcquireSwapChainTexture(NonNullPtr<CommandList> commandList, NonNullPtr<Window> window,
|
||||
Texture** swapChainTexture);
|
||||
extern JULIET_API TextureFormat GetSwapChainTextureFormat(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window);
|
||||
|
||||
// Command List
|
||||
extern JULIET_API CommandList* AcquireCommandList(NonNullPtr<GraphicsDevice> device, QueueType queueType = QueueType::Graphics);
|
||||
@@ -109,5 +112,10 @@ namespace Juliet
|
||||
|
||||
// Shaders
|
||||
extern JULIET_API Shader* CreateShader(NonNullPtr<GraphicsDevice> device, String filename, ShaderCreateInfo& shaderCreateInfo);
|
||||
extern JULIET_API void DestroyShader(NonNullPtr<GraphicsDevice> driver, NonNullPtr<Shader> shader);
|
||||
extern JULIET_API void DestroyShader(NonNullPtr<GraphicsDevice> device, NonNullPtr<Shader> shader);
|
||||
|
||||
// Pipelines
|
||||
extern JULIET_API GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GraphicsDevice> device,
|
||||
GraphicsPipelineCreateInfo& createInfo);
|
||||
|
||||
} // namespace Juliet
|
||||
|
||||
61
Juliet/include/Graphics/GraphicsPipeline.h
Normal file
61
Juliet/include/Graphics/GraphicsPipeline.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
#include <Graphics/Shader.h>
|
||||
|
||||
namespace Juliet
|
||||
{
|
||||
// Forward Declare
|
||||
struct ColorTargetDescription;
|
||||
|
||||
enum class FillMode : uint8
|
||||
{
|
||||
Wireframe,
|
||||
Solid
|
||||
};
|
||||
|
||||
enum class CullMode : uint8
|
||||
{
|
||||
None,
|
||||
Front,
|
||||
Back
|
||||
};
|
||||
|
||||
enum class FrontFace : uint8
|
||||
{
|
||||
CounterClockwise,
|
||||
Clockwise
|
||||
};
|
||||
|
||||
enum class PrimitiveType : uint8
|
||||
{
|
||||
TriangleList,
|
||||
TriangleStrip,
|
||||
LineList,
|
||||
LineStrip,
|
||||
PointList,
|
||||
};
|
||||
|
||||
struct RasterizerState
|
||||
{
|
||||
FillMode FillMode;
|
||||
CullMode CullMode;
|
||||
FrontFace FrontFace;
|
||||
};
|
||||
|
||||
struct GraphicsPipelineTargetInfo
|
||||
{
|
||||
const ColorTargetDescription* ColorTargetDescriptions;
|
||||
size_t NumColorTargets;
|
||||
};
|
||||
|
||||
struct GraphicsPipelineCreateInfo
|
||||
{
|
||||
Shader* VertexShader;
|
||||
Shader* FragmentShader;
|
||||
RasterizerState RasterizerState;
|
||||
PrimitiveType PrimitiveType;
|
||||
GraphicsPipelineTargetInfo TargetInfo;
|
||||
};
|
||||
|
||||
// Opaque type
|
||||
struct GraphicsPipeline;
|
||||
} // namespace Juliet
|
||||
@@ -41,6 +41,17 @@ namespace Juliet
|
||||
StoreOperation StoreOperation;
|
||||
};
|
||||
|
||||
struct ColorTargetBlendState
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
struct ColorTargetDescription
|
||||
{
|
||||
TextureFormat Format;
|
||||
ColorTargetBlendState BlendState;
|
||||
};
|
||||
|
||||
// Opaque Type
|
||||
struct RenderPass;
|
||||
} // namespace Juliet
|
||||
|
||||
14
Juliet/src/Graphics/D3D12/D3D12GraphicsPipeline.cpp
Normal file
14
Juliet/src/Graphics/D3D12/D3D12GraphicsPipeline.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <pch.h>
|
||||
|
||||
#include <Graphics/D3D12/D3D12GraphicsPipeline.h>
|
||||
|
||||
#include <Core/Common/NonNullPtr.h>
|
||||
#include <Graphics/GraphicsDevice.h>
|
||||
|
||||
namespace Juliet::D3D12
|
||||
{
|
||||
GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GPUDriver> driver, GraphicsPipelineCreateInfo& createInfo)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace Juliet::D3D12
|
||||
15
Juliet/src/Graphics/D3D12/D3D12GraphicsPipeline.h
Normal file
15
Juliet/src/Graphics/D3D12/D3D12GraphicsPipeline.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <Core/Common/NonNullPtr.h>
|
||||
|
||||
namespace Juliet
|
||||
{
|
||||
struct GraphicsPipelineCreateInfo;
|
||||
struct GPUDriver;
|
||||
struct GraphicsPipeline;
|
||||
} // namespace Juliet
|
||||
|
||||
namespace Juliet::D3D12
|
||||
{
|
||||
extern GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GPUDriver> driver, GraphicsPipelineCreateInfo& createInfo);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Core/Common/NonNullPtr.h>
|
||||
#include <Core/HAL/DynLib/DynamicLibrary.h>
|
||||
#include <Core/Memory/Allocator.h>
|
||||
#include <Graphics/D3D12/D3D12GraphicsPipeline.h>
|
||||
#include <Graphics/D3D12/D3D12RenderPass.h>
|
||||
#include <Graphics/D3D12/D3D12Synchronization.h>
|
||||
#include <Graphics/D3D12/DX12CommandList.h>
|
||||
@@ -596,30 +597,25 @@ namespace Juliet::D3D12
|
||||
}
|
||||
|
||||
// Assign Functions to the device
|
||||
device->DestroyDevice = DestroyGraphicsDevice;
|
||||
|
||||
device->AttachToWindow = AttachToWindow;
|
||||
device->DetachFromWindow = DetachFromWindow;
|
||||
|
||||
device->AcquireSwapChainTexture = AcquireSwapChainTexture;
|
||||
|
||||
device->AcquireCommandList = AcquireCommandList;
|
||||
device->SubmitCommandLists = SubmitCommandLists;
|
||||
|
||||
device->BeginRenderPass = BeginRenderPass;
|
||||
device->EndRenderPass = EndRenderPass;
|
||||
|
||||
device->SetViewPort = SetViewPort;
|
||||
device->SetScissorRect = SetScissorRect;
|
||||
device->SetBlendConstants = SetBlendConstants;
|
||||
device->SetStencilReference = SetStencilReference;
|
||||
|
||||
device->Wait = Wait;
|
||||
device->QueryFence = QueryFence;
|
||||
device->ReleaseFence = ReleaseFence;
|
||||
|
||||
device->CreateShader = CreateShader;
|
||||
device->DestroyShader = DestroyShader;
|
||||
device->DestroyDevice = DestroyGraphicsDevice;
|
||||
device->AttachToWindow = AttachToWindow;
|
||||
device->DetachFromWindow = DetachFromWindow;
|
||||
device->AcquireSwapChainTexture = AcquireSwapChainTexture;
|
||||
device->GetSwapChainTextureFormat = GetSwapChainTextureFormat;
|
||||
device->AcquireCommandList = AcquireCommandList;
|
||||
device->SubmitCommandLists = SubmitCommandLists;
|
||||
device->BeginRenderPass = BeginRenderPass;
|
||||
device->EndRenderPass = EndRenderPass;
|
||||
device->SetViewPort = SetViewPort;
|
||||
device->SetScissorRect = SetScissorRect;
|
||||
device->SetBlendConstants = SetBlendConstants;
|
||||
device->SetStencilReference = SetStencilReference;
|
||||
device->Wait = Wait;
|
||||
device->QueryFence = QueryFence;
|
||||
device->ReleaseFence = ReleaseFence;
|
||||
device->CreateShader = CreateShader;
|
||||
device->DestroyShader = DestroyShader;
|
||||
device->CreateGraphicsPipeline = CreateGraphicsPipeline;
|
||||
|
||||
device->Driver = driver;
|
||||
driver->GraphicsDevice = device;
|
||||
|
||||
@@ -192,6 +192,21 @@ namespace Juliet::D3D12
|
||||
return AcquireSwapChainTexture(false, commandList, window, swapChainTexture);
|
||||
}
|
||||
|
||||
TextureFormat GetSwapChainTextureFormat(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> window)
|
||||
{
|
||||
auto* d3d12Driver = static_cast<D3D12Driver*>(driver.Get());
|
||||
|
||||
auto* windowData = d3d12Driver->WindowData;
|
||||
if (!windowData)
|
||||
{
|
||||
LogError(LogCategory::Graphics, "Cannot get swapchain format. Window has no Swapchain");
|
||||
return TextureFormat::Invalid;
|
||||
}
|
||||
|
||||
Assert(windowData->Window == window.Get());
|
||||
return windowData->SwapChainTextureContainers[windowData->WindowFrameCounter].Header.CreateInfo.Format;
|
||||
}
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
bool CreateSwapChain(NonNullPtr<D3D12Driver> driver, NonNullPtr<D3D12WindowData> windowData,
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Juliet::D3D12
|
||||
struct D3D12WindowData;
|
||||
|
||||
extern bool AcquireSwapChainTexture(NonNullPtr<CommandList> commandList, NonNullPtr<Window> window, Texture** swapChainTexture);
|
||||
extern TextureFormat GetSwapChainTextureFormat(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> window);
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
|
||||
@@ -88,6 +88,11 @@ namespace Juliet
|
||||
return true;
|
||||
}
|
||||
|
||||
TextureFormat GetSwapChainTextureFormat(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window)
|
||||
{
|
||||
return device->GetSwapChainTextureFormat(device->Driver, window);
|
||||
}
|
||||
|
||||
CommandList* AcquireCommandList(NonNullPtr<GraphicsDevice> device, QueueType queueType /* = QueueType::Graphics */)
|
||||
{
|
||||
GPUDriver* driver = device->Driver;
|
||||
@@ -213,4 +218,8 @@ namespace Juliet
|
||||
device->DestroyShader(device->Driver, shader);
|
||||
}
|
||||
|
||||
GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GraphicsDevice> device, GraphicsPipelineCreateInfo& createInfo)
|
||||
{
|
||||
device->CreateGraphicsPipeline(device->Driver, createInfo);
|
||||
}
|
||||
} // namespace Juliet
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Core/Common/NonNullPtr.h>
|
||||
#include <Graphics/Graphics.h>
|
||||
#include <Graphics/GraphicsConfig.h>
|
||||
#include <Graphics/GraphicsPipeline.h>
|
||||
#include <Graphics/Texture.h>
|
||||
|
||||
namespace Juliet
|
||||
@@ -44,6 +45,7 @@ namespace Juliet
|
||||
|
||||
// SwapChain
|
||||
bool (*AcquireSwapChainTexture)(NonNullPtr<CommandList> commandList, NonNullPtr<Window> window, Texture** swapChainTexture);
|
||||
TextureFormat (*GetSwapChainTextureFormat)(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> window);
|
||||
|
||||
// CommandLists
|
||||
CommandList* (*AcquireCommandList)(NonNullPtr<GPUDriver> driver, QueueType queueType);
|
||||
@@ -68,6 +70,9 @@ namespace Juliet
|
||||
Shader* (*CreateShader)(NonNullPtr<GPUDriver> driver, ByteBuffer shaderByteCode, ShaderCreateInfo& shaderCreateInfo);
|
||||
void (*DestroyShader)(NonNullPtr<GPUDriver> driver, NonNullPtr<Shader> shader);
|
||||
|
||||
// Pipeline
|
||||
GraphicsPipeline* (*CreateGraphicsPipeline)(NonNullPtr<GPUDriver> driver, GraphicsPipelineCreateInfo& createInfo);
|
||||
|
||||
const char* Name = "Unknown";
|
||||
GPUDriver* Driver = nullptr;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Core/Common/String.h>
|
||||
#include <Core/Memory/Utils.h>
|
||||
#include <cstdlib>
|
||||
#include <Graphics/GraphicsPipeline.h>
|
||||
|
||||
// TODO : Replace with message box from framework + call main and not winmain + subsystem
|
||||
// TODO : Think how to do the draw pipeline.
|
||||
@@ -60,15 +61,38 @@ void JulietApplication::Init()
|
||||
|
||||
{
|
||||
// Create graphics pipeline
|
||||
// TODO: Assets management that handles path to assets or something.
|
||||
String shaderPath = WrapString("../../../Assets/compiled/Triangle.vert.dxil");
|
||||
String entryPoint = WrapString("main");
|
||||
ShaderCreateInfo shaderCI = {};
|
||||
shaderCI.Stage = ShaderStage::Vertex;
|
||||
shaderCI.EntryPoint = WrapString("main");
|
||||
Shader* shader = CreateShader(GraphicsDevice, shaderPath, shaderCI);
|
||||
if (shader)
|
||||
shaderCI.EntryPoint = entryPoint;
|
||||
|
||||
// TODO: Assets management that handles path to assets or something.
|
||||
String shaderPath = WrapString("../../../Assets/compiled/Triangle.vert.dxil");
|
||||
shaderCI.Stage = ShaderStage::Vertex;
|
||||
Shader* vertexShader = CreateShader(GraphicsDevice, shaderPath, shaderCI);
|
||||
|
||||
shaderPath = WrapString("../../../Assets/compiled/SolidColor.frag.dxil");
|
||||
shaderCI.Stage = ShaderStage::Fragment;
|
||||
Shader* fragmentShader = CreateShader(GraphicsDevice, shaderPath, shaderCI);
|
||||
|
||||
ColorTargetDescription colorTargetDescription = { .Format = GetSwapChainTextureFormat(GraphicsDevice, MainWindow) };
|
||||
GraphicsPipelineCreateInfo pipelineCI = {
|
||||
.VertexShader = vertexShader,
|
||||
.FragmentShader = fragmentShader,
|
||||
.PrimitiveType = PrimitiveType::TriangleList,
|
||||
.TargetInfo = {
|
||||
.ColorTargetDescriptions = &colorTargetDescription,
|
||||
.NumColorTargets = 1,
|
||||
},
|
||||
};
|
||||
pipelineCI.RasterizerState.FillMode = FillMode::Solid;
|
||||
|
||||
if (vertexShader)
|
||||
{
|
||||
DestroyShader(GraphicsDevice, shader);
|
||||
DestroyShader(GraphicsDevice, vertexShader);
|
||||
}
|
||||
if (fragmentShader)
|
||||
{
|
||||
DestroyShader(GraphicsDevice, fragmentShader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user