2016-08-22 18:26:36 +00:00
|
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
// BCDirectCompute.h
|
|
|
|
//
|
|
|
|
// Direct3D 11 Compute Shader BC Compressor
|
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
2018-02-24 06:24:46 +00:00
|
|
|
// Licensed under the MIT License.
|
2016-08-22 18:26:36 +00:00
|
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace DirectX
|
|
|
|
{
|
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
class GPUCompressBC
|
|
|
|
{
|
|
|
|
public:
|
2018-05-02 00:34:54 +00:00
|
|
|
GPUCompressBC() noexcept;
|
2018-03-16 19:52:21 +00:00
|
|
|
|
|
|
|
HRESULT Initialize(_In_ ID3D11Device* pDevice);
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
HRESULT Prepare(size_t width, size_t height, DWORD flags, DXGI_FORMAT format, float alphaWeight);
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
HRESULT Compress(const Image& srcImage, const Image& destImage);
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
DXGI_FORMAT GetSourceFormat() const { return m_srcformat; }
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
private:
|
|
|
|
DXGI_FORMAT m_bcformat;
|
|
|
|
DXGI_FORMAT m_srcformat;
|
|
|
|
float m_alphaWeight;
|
|
|
|
bool m_bc7_mode02;
|
|
|
|
bool m_bc7_mode137;
|
|
|
|
size_t m_width;
|
|
|
|
size_t m_height;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
Microsoft::WRL::ComPtr<ID3D11Device> m_device;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_context;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
Microsoft::WRL::ComPtr<ID3D11Buffer> m_err1;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11UnorderedAccessView> m_err1UAV;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_err1SRV;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
Microsoft::WRL::ComPtr<ID3D11Buffer> m_err2;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11UnorderedAccessView> m_err2UAV;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_err2SRV;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
Microsoft::WRL::ComPtr<ID3D11Buffer> m_output;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11Buffer> m_outputCPU;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11UnorderedAccessView> m_outputUAV;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constBuffer;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
// Compute shader library
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC6H_tryModeG10CS;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC6H_tryModeLE10CS;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC6H_encodeBlockCS;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-03-16 19:52:21 +00:00
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC7_tryMode456CS;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC7_tryMode137CS;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC7_tryMode02CS;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11ComputeShader> m_BC7_encodeBlockCS;
|
|
|
|
};
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2018-02-24 06:42:26 +00:00
|
|
|
} // namespace
|