// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#if GRAPHICS_API_DIRECTX12
#include "Engine/Graphics/Shaders/GPUShader.h"
#include "Engine/Graphics/Shaders/GPUConstantBuffer.h"
#include "GPUDeviceDX12.h"
///
/// Constant Buffer for DirectX 12 backend.
///
class GPUConstantBufferDX12 : public GPUResourceDX12
{
public:
///
/// Initializes a new instance of the class.
///
/// The graphics device.
/// The buffer size (in bytes).
GPUConstantBufferDX12(GPUDeviceDX12* device, uint32 size) noexcept
: GPUResourceDX12(device, String::Empty)
, GPUAddress(0)
{
_size = size;
}
public:
///
/// Last uploaded data address.
///
D3D12_GPU_VIRTUAL_ADDRESS GPUAddress;
};
///
/// Shader for DirectX 12 backend.
///
class GPUShaderDX12 : public GPUResourceDX12
{
private:
Array> _cbs;
public:
///
/// Initializes a new instance of the class.
///
/// The device.
/// The resource name.
GPUShaderDX12(GPUDeviceDX12* device, const StringView& name)
: GPUResourceDX12(device, name)
{
}
protected:
// [GPUShader]
GPUShaderProgram* CreateGPUShaderProgram(ShaderStage type, const GPUShaderProgramInitializer& initializer, byte* cacheBytes, uint32 cacheSize, MemoryReadStream& stream) override;
GPUConstantBuffer* CreateCB(const String& name, uint32 size, MemoryReadStream& stream) override;
void OnReleaseGPU() override;
};
#endif