Refactor Vertex Shader input vertex layout to use GPUVertexLayout defined on Vertex Buffer rather than Vertex Shader
#3044 #2667
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Graphics/Shaders/GPUShaderProgram.h"
|
||||
#include "Engine/Core/Types/DataContainer.h"
|
||||
#include "../IncludeDirectXHeaders.h"
|
||||
|
||||
#if GRAPHICS_API_DIRECTX11
|
||||
@@ -17,11 +18,6 @@ protected:
|
||||
BufferType* _buffer;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
GPUShaderProgramDX11(const GPUShaderProgramInitializer& initializer, BufferType* buffer)
|
||||
: _buffer(buffer)
|
||||
{
|
||||
@@ -31,18 +27,11 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes an instance of the <see cref="GPUShaderProgramDX11"/> class.
|
||||
/// </summary>
|
||||
~GPUShaderProgramDX11()
|
||||
{
|
||||
DX_SAFE_RELEASE_CHECK(_buffer, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Gets DirectX 11 buffer handle.
|
||||
/// </summary>
|
||||
FORCE_INLINE BufferType* GetBufferHandleDX11() const
|
||||
{
|
||||
return _buffer;
|
||||
@@ -66,51 +55,21 @@ public:
|
||||
class GPUShaderProgramVSDX11 : public GPUShaderProgramDX11<GPUShaderProgramVS, ID3D11VertexShader>
|
||||
{
|
||||
private:
|
||||
byte _inputLayoutSize;
|
||||
ID3D11InputLayout* _inputLayout;
|
||||
Dictionary<class GPUVertexLayoutDX11*, ID3D11InputLayout*> _cache;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramVSDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
/// <param name="inputLayout">The input layout.</param>
|
||||
/// <param name="inputLayoutSize">Size of the input layout.</param>
|
||||
GPUShaderProgramVSDX11(const GPUShaderProgramInitializer& initializer, ID3D11VertexShader* buffer, ID3D11InputLayout* inputLayout, byte inputLayoutSize)
|
||||
GPUShaderProgramVSDX11(const GPUShaderProgramInitializer& initializer, ID3D11VertexShader* buffer, GPUVertexLayout* vertexLayout, Span<byte> bytecode)
|
||||
: GPUShaderProgramDX11(initializer, buffer)
|
||||
, _inputLayoutSize(inputLayoutSize)
|
||||
, _inputLayout(inputLayout)
|
||||
{
|
||||
Layout = vertexLayout;
|
||||
Bytecode.Copy(bytecode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes an instance of the <see cref="GPUShaderProgramVSDX11"/> class.
|
||||
/// </summary>
|
||||
~GPUShaderProgramVSDX11()
|
||||
{
|
||||
DX_SAFE_RELEASE_CHECK(_inputLayout, 0);
|
||||
}
|
||||
~GPUShaderProgramVSDX11();
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Gets the DirectX 11 input layout handle
|
||||
/// </summary>
|
||||
FORCE_INLINE ID3D11InputLayout* GetInputLayoutDX11() const
|
||||
{
|
||||
return _inputLayout;
|
||||
}
|
||||
BytesContainer Bytecode;
|
||||
|
||||
public:
|
||||
// [GPUShaderProgramDX11]
|
||||
void* GetInputLayout() const override
|
||||
{
|
||||
return (void*)_inputLayout;
|
||||
}
|
||||
byte GetInputLayoutSize() const override
|
||||
{
|
||||
return _inputLayoutSize;
|
||||
}
|
||||
ID3D11InputLayout* GetInputLayout(class GPUVertexLayoutDX11* vertexLayout);
|
||||
};
|
||||
|
||||
#if GPU_ALLOW_TESSELLATION_SHADERS
|
||||
@@ -120,12 +79,6 @@ public:
|
||||
class GPUShaderProgramHSDX11 : public GPUShaderProgramDX11<GPUShaderProgramHS, ID3D11HullShader>
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramHSDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
/// <param name="controlPointsCount">The control points used by the hull shader for processing.</param>
|
||||
GPUShaderProgramHSDX11(const GPUShaderProgramInitializer& initializer, ID3D11HullShader* buffer, int32 controlPointsCount)
|
||||
: GPUShaderProgramDX11(initializer, buffer)
|
||||
{
|
||||
@@ -139,11 +92,6 @@ public:
|
||||
class GPUShaderProgramDSDX11 : public GPUShaderProgramDX11<GPUShaderProgramDS, ID3D11DomainShader>
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramDSDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
GPUShaderProgramDSDX11(const GPUShaderProgramInitializer& initializer, ID3D11DomainShader* buffer)
|
||||
: GPUShaderProgramDX11(initializer, buffer)
|
||||
{
|
||||
@@ -158,11 +106,6 @@ public:
|
||||
class GPUShaderProgramGSDX11 : public GPUShaderProgramDX11<GPUShaderProgramGS, ID3D11GeometryShader>
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramGSDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
GPUShaderProgramGSDX11(const GPUShaderProgramInitializer& initializer, ID3D11GeometryShader* buffer)
|
||||
: GPUShaderProgramDX11(initializer, buffer)
|
||||
{
|
||||
@@ -176,11 +119,6 @@ public:
|
||||
class GPUShaderProgramPSDX11 : public GPUShaderProgramDX11<GPUShaderProgramPS, ID3D11PixelShader>
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramPSDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
GPUShaderProgramPSDX11(const GPUShaderProgramInitializer& initializer, ID3D11PixelShader* buffer)
|
||||
: GPUShaderProgramDX11(initializer, buffer)
|
||||
{
|
||||
@@ -193,11 +131,6 @@ public:
|
||||
class GPUShaderProgramCSDX11 : public GPUShaderProgramDX11<GPUShaderProgramCS, ID3D11ComputeShader>
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUShaderProgramCSDX11"/> class.
|
||||
/// </summary>
|
||||
/// <param name="initializer">The program initialization data.</param>
|
||||
/// <param name="buffer">The shader buffer object.</param>
|
||||
GPUShaderProgramCSDX11(const GPUShaderProgramInitializer& initializer, ID3D11ComputeShader* buffer)
|
||||
: GPUShaderProgramDX11(initializer, buffer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user