diff options
| author | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
| commit | 8c4603c73675958efc960fbd4bb599a2909d106a (patch) | |
| tree | 714dc6fc9a1672d5fd7f89676b97e10959662abc /Whisper/ML/TensorGpuViews.cpp | |
| parent | 990a8d0dbaefc996244097397259e92758b15cce (diff) | |
Source codes
Diffstat (limited to 'Whisper/ML/TensorGpuViews.cpp')
| -rw-r--r-- | Whisper/ML/TensorGpuViews.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Whisper/ML/TensorGpuViews.cpp b/Whisper/ML/TensorGpuViews.cpp new file mode 100644 index 0000000..2788153 --- /dev/null +++ b/Whisper/ML/TensorGpuViews.cpp @@ -0,0 +1,23 @@ +#include "stdafx.h" +#include "TensorGpuViews.h" +using namespace DirectCompute; + +HRESULT TensorGpuViews::create( ID3D11Buffer* gpuBuffer, DXGI_FORMAT format, size_t countElements, bool makeUav ) +{ + srv = nullptr; + uav = nullptr; + + if( countElements > UINT_MAX ) + return DISP_E_OVERFLOW; + + CD3D11_SHADER_RESOURCE_VIEW_DESC viewDesc{ D3D11_SRV_DIMENSION_BUFFER, format, 0, (UINT)countElements }; + CHECK( device()->CreateShaderResourceView( gpuBuffer, &viewDesc, &srv ) ); + + if( makeUav ) + { + CD3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc{ D3D11_UAV_DIMENSION_BUFFER, format , 0, (UINT)countElements }; + CHECK( device()->CreateUnorderedAccessView( gpuBuffer, &uavDesc, &uav ) ); + } + + return S_OK; +}
\ No newline at end of file |
