// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Graphics/Shaders/GPUShaderProgram.h"
#include "../IncludeDirectXHeaders.h"
#if GRAPHICS_API_DIRECTX11
///
/// Shaders base class for DirectX 11 backend.
///
template
class GPUShaderProgramDX11 : public BaseType
{
protected:
BufferType* _buffer;
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
GPUShaderProgramDX11(const GPUShaderProgramInitializer& initializer, BufferType* buffer)
: _buffer(buffer)
{
BaseType::Init(initializer);
#if GPU_ENABLE_RESOURCE_NAMING
SetDebugObjectName(buffer, initializer.Name.Get(), initializer.Name.Length());
#endif
}
///
/// Finalizes an instance of the class.
///
~GPUShaderProgramDX11()
{
DX_SAFE_RELEASE_CHECK(_buffer, 0);
}
public:
///
/// Gets DirectX 11 buffer handle.
///
FORCE_INLINE BufferType* GetBufferHandleDX11() const
{
return _buffer;
}
public:
// [BaseType]
uint32 GetBufferSize() const override
{
return 0;
}
void* GetBufferHandle() const override
{
return _buffer;
}
};
///
/// Vertex Shader for DirectX 11 backend.
///
class GPUShaderProgramVSDX11 : public GPUShaderProgramDX11
{
private:
byte _inputLayoutSize;
ID3D11InputLayout* _inputLayout;
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
/// The input layout.
/// Size of the input layout.
GPUShaderProgramVSDX11(const GPUShaderProgramInitializer& initializer, ID3D11VertexShader* buffer, ID3D11InputLayout* inputLayout, byte inputLayoutSize)
: GPUShaderProgramDX11(initializer, buffer)
, _inputLayoutSize(inputLayoutSize)
, _inputLayout(inputLayout)
{
}
///
/// Finalizes an instance of the class.
///
~GPUShaderProgramVSDX11()
{
DX_SAFE_RELEASE_CHECK(_inputLayout, 0);
}
public:
///
/// Gets the DirectX 11 input layout handle
///
FORCE_INLINE ID3D11InputLayout* GetInputLayoutDX11() const
{
return _inputLayout;
}
public:
// [GPUShaderProgramDX11]
void* GetInputLayout() const override
{
return (void*)_inputLayout;
}
byte GetInputLayoutSize() const override
{
return _inputLayoutSize;
}
};
#if GPU_ALLOW_TESSELLATION_SHADERS
///
/// Hull Shader for DirectX 11 backend.
///
class GPUShaderProgramHSDX11 : public GPUShaderProgramDX11
{
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
/// The control points used by the hull shader for processing.
GPUShaderProgramHSDX11(const GPUShaderProgramInitializer& initializer, ID3D11HullShader* buffer, int32 controlPointsCount)
: GPUShaderProgramDX11(initializer, buffer)
{
_controlPointsCount = controlPointsCount;
}
};
///
/// Domain Shader for DirectX 11 backend.
///
class GPUShaderProgramDSDX11 : public GPUShaderProgramDX11
{
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
GPUShaderProgramDSDX11(const GPUShaderProgramInitializer& initializer, ID3D11DomainShader* buffer)
: GPUShaderProgramDX11(initializer, buffer)
{
}
};
#endif
#if GPU_ALLOW_GEOMETRY_SHADERS
///
/// Geometry Shader for DirectX 11 backend.
///
class GPUShaderProgramGSDX11 : public GPUShaderProgramDX11
{
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
GPUShaderProgramGSDX11(const GPUShaderProgramInitializer& initializer, ID3D11GeometryShader* buffer)
: GPUShaderProgramDX11(initializer, buffer)
{
}
};
#endif
///
/// Pixel Shader for DirectX 11 backend.
///
class GPUShaderProgramPSDX11 : public GPUShaderProgramDX11
{
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
GPUShaderProgramPSDX11(const GPUShaderProgramInitializer& initializer, ID3D11PixelShader* buffer)
: GPUShaderProgramDX11(initializer, buffer)
{
}
};
///
/// Compute Shader for DirectX 11 backend.
///
class GPUShaderProgramCSDX11 : public GPUShaderProgramDX11
{
public:
///
/// Initializes a new instance of the class.
///
/// The program initialization data.
/// The shader buffer object.
GPUShaderProgramCSDX11(const GPUShaderProgramInitializer& initializer, ID3D11ComputeShader* buffer)
: GPUShaderProgramDX11(initializer, buffer)
{
}
};
#endif