mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-09-22 05:15:50 +00:00
Try to utilize the default destructor
Might need to stall the destruction due to resources being in use by the GPU
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include <misc/IdentifyGpu.h>
|
||||
#include <NvApiDriverSettings.h>
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
LowLatency* LowLatencyCtx::lowlatency_ctx = nullptr;
|
||||
static auto init_mutex = std::mutex {};
|
||||
|
||||
|
||||
@@ -6,30 +6,6 @@ using Microsoft::WRL::ComPtr;
|
||||
|
||||
Shader_Dx12::Shader_Dx12(std::string InName, ID3D12Device* InDevice) : _name(InName), _device(InDevice) {}
|
||||
|
||||
Shader_Dx12::~Shader_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
if (_pipelineState != nullptr)
|
||||
{
|
||||
_pipelineState->Release();
|
||||
_pipelineState = nullptr;
|
||||
}
|
||||
|
||||
if (_rootSignature != nullptr)
|
||||
{
|
||||
_rootSignature->Release();
|
||||
_rootSignature = nullptr;
|
||||
}
|
||||
|
||||
if (_constantBuffer != nullptr)
|
||||
{
|
||||
_constantBuffer->Release();
|
||||
_constantBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
DXGI_FORMAT Shader_Dx12::TranslateTypelessFormats(DXGI_FORMAT format)
|
||||
{
|
||||
switch (format)
|
||||
@@ -112,7 +88,7 @@ bool Shader_Dx12::CreateComputePipeline(ID3D12Device* device, ID3D12PipelineStat
|
||||
if (!Config::Instance()->UsePrecompiledShaders.value_or_default() && source)
|
||||
shaderBlob = CompileShader(source, "CSMain", "cs_5_0");
|
||||
|
||||
return CreateComputeShader(device, _rootSignature, pipelineState, shaderBlob.Get(),
|
||||
return CreateComputeShader(device, _rootSignature.Get(), pipelineState, shaderBlob.Get(),
|
||||
CD3DX12_SHADER_BYTECODE(bytecode, bytecodeSize));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ class Shader_Dx12
|
||||
bool _init = false;
|
||||
int _counter = 0;
|
||||
|
||||
ID3D12RootSignature* _rootSignature = nullptr;
|
||||
ID3D12PipelineState* _pipelineState = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12RootSignature> _rootSignature;
|
||||
Microsoft::WRL::ComPtr<ID3D12PipelineState> _pipelineState;
|
||||
|
||||
ID3D12Device* _device = nullptr;
|
||||
ID3D12Resource* _constantBuffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _constantBuffer;
|
||||
|
||||
std::vector<CD3DX12_DESCRIPTOR_RANGE1> _descriptorRanges;
|
||||
|
||||
@@ -56,6 +56,4 @@ class Shader_Dx12
|
||||
bool IsInit() const { return _init; }
|
||||
|
||||
Shader_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~Shader_Dx12();
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ bool Bias_Dx12::CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InS
|
||||
|
||||
void Bias_Dx12::SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState)
|
||||
{
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer, &_bufferState);
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer.Get(), &_bufferState);
|
||||
}
|
||||
|
||||
bool Bias_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, float InBias,
|
||||
@@ -45,7 +45,7 @@ bool Bias_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* I
|
||||
InternalConstants constants {};
|
||||
constants.Bias = std::clamp(InBias, 0.0f, 0.9f);
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -54,8 +54,8 @@ bool Bias_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* I
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -108,20 +108,3 @@ Bias_Dx12::Bias_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(I
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, BIAS_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
Bias_Dx12::~Bias_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < BIAS_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class Bias_Dx12 : public Shader_Dx12
|
||||
|
||||
FrameDescriptorHeap _frameHeaps[BIAS_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON;
|
||||
|
||||
UINT InNumThreadsX = 16;
|
||||
@@ -28,10 +28,8 @@ class Bias_Dx12 : public Shader_Dx12
|
||||
bool Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, float InBias,
|
||||
ID3D12Resource* OutResource);
|
||||
|
||||
ID3D12Resource* Buffer() { return _buffer; }
|
||||
ID3D12Resource* Buffer() { return _buffer.Get(); }
|
||||
bool CanRender() const { return _init && _buffer != nullptr; }
|
||||
|
||||
Bias_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~Bias_Dx12();
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ bool DI_Dx12::CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InSou
|
||||
|
||||
void DI_Dx12::SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState)
|
||||
{
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer, &_bufferState);
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer.Get(), &_bufferState);
|
||||
}
|
||||
|
||||
bool DI_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource)
|
||||
@@ -49,8 +49,8 @@ bool DI_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -90,20 +90,3 @@ DI_Dx12::DI_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(InNam
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, DI_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
DI_Dx12::~DI_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < DI_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class DI_Dx12 : public Shader_Dx12
|
||||
private:
|
||||
FrameDescriptorHeap _frameHeaps[DI_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON;
|
||||
|
||||
uint32_t InNumThreadsX = 16;
|
||||
@@ -26,10 +26,8 @@ class DI_Dx12 : public Shader_Dx12
|
||||
void SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState);
|
||||
bool Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource);
|
||||
|
||||
ID3D12Resource* Buffer() { return _buffer; }
|
||||
ID3D12Resource* Buffer() { return _buffer.Get(); }
|
||||
bool CanRender() const { return _init && _buffer != nullptr; }
|
||||
|
||||
DI_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~DI_Dx12();
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ bool DS_Dx12::CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InSou
|
||||
|
||||
void DS_Dx12::SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState)
|
||||
{
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer, &_bufferState);
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer.Get(), &_bufferState);
|
||||
}
|
||||
|
||||
bool DS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource)
|
||||
@@ -52,7 +52,7 @@ bool DS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
DSConstants constants {};
|
||||
constants.DepthScale = Config::Instance()->FGDepthScaleMax.value_or_default();
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -61,8 +61,8 @@ bool DS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -124,20 +124,3 @@ DS_Dx12::DS_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(InNam
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, DS_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
DS_Dx12::~DS_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < DS_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class DS_Dx12 : public Shader_Dx12
|
||||
private:
|
||||
FrameDescriptorHeap _frameHeaps[DS_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON;
|
||||
|
||||
uint32_t InNumThreadsX = 16;
|
||||
@@ -26,10 +26,8 @@ class DS_Dx12 : public Shader_Dx12
|
||||
void SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState);
|
||||
bool Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource);
|
||||
|
||||
ID3D12Resource* Buffer() { return _buffer; }
|
||||
ID3D12Resource* Buffer() { return _buffer.Get(); }
|
||||
bool CanRender() const { return _init && _buffer != nullptr; }
|
||||
|
||||
DS_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~DS_Dx12();
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ bool FT_Dx12::CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InSou
|
||||
|
||||
void FT_Dx12::SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState)
|
||||
{
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer, &_bufferState);
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer.Get(), &_bufferState);
|
||||
}
|
||||
|
||||
bool FT_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource)
|
||||
@@ -80,8 +80,8 @@ bool FT_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -128,20 +128,3 @@ bool FT_Dx12::IsFormatCompatible(DXGI_FORMAT InFormat)
|
||||
// Bold move: accept all formats
|
||||
return true;
|
||||
}
|
||||
|
||||
FT_Dx12::~FT_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < FT_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class FT_Dx12 : public Shader_Dx12
|
||||
private:
|
||||
FrameDescriptorHeap _frameHeaps[FT_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON;
|
||||
DXGI_FORMAT format;
|
||||
|
||||
@@ -29,13 +29,11 @@ class FT_Dx12 : public Shader_Dx12
|
||||
void SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState);
|
||||
bool Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource);
|
||||
|
||||
ID3D12Resource* Buffer() { return _buffer; }
|
||||
ID3D12Resource* Buffer() { return _buffer.Get(); }
|
||||
bool CanRender() const { return _init && _buffer != nullptr; }
|
||||
DXGI_FORMAT Format() const { return format; }
|
||||
|
||||
FT_Dx12(std::string InName, ID3D12Device* InDevice, DXGI_FORMAT InFormat);
|
||||
|
||||
bool IsFormatCompatible(DXGI_FORMAT InFormat);
|
||||
|
||||
~FT_Dx12();
|
||||
};
|
||||
|
||||
@@ -50,23 +50,23 @@ bool HudCopy_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource*
|
||||
|
||||
ResourceBarrier(cmdList, present, presentState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
|
||||
cmdList->CopyResource(_buffer, present);
|
||||
cmdList->CopyResource(_buffer.Get(), present);
|
||||
|
||||
// Make sure present is in D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE
|
||||
ResourceBarrier(cmdList, present, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
ResourceBarrier(cmdList, _buffer, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
ResourceBarrier(cmdList, _buffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
ResourceBarrier(cmdList, hudless, hudlessState, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
// Create views
|
||||
CreateShaderResourceView(_device, hudless, currentHeap.GetSrvCPU(0));
|
||||
CreateShaderResourceView(_device, present, currentHeap.GetSrvCPU(1));
|
||||
CreateUnorderedAccessView(_device, _buffer, currentHeap.GetUavCPU(0), 0);
|
||||
CreateUnorderedAccessView(_device, _buffer.Get(), currentHeap.GetUavCPU(0), 0);
|
||||
|
||||
InternalCompareParams constants {};
|
||||
constants.DiffThreshold = hudDetectionThreshold;
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -75,8 +75,8 @@ bool HudCopy_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource*
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
cmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
cmdList->SetComputeRootSignature(_rootSignature);
|
||||
cmdList->SetPipelineState(_pipelineState);
|
||||
cmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
cmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
cmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -86,15 +86,15 @@ bool HudCopy_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource*
|
||||
|
||||
cmdList->Dispatch(dispatchWidth, dispatchHeight, 1);
|
||||
|
||||
ResourceBarrier(cmdList, _buffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
ResourceBarrier(cmdList, _buffer.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
ResourceBarrier(cmdList, present, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
|
||||
cmdList->CopyResource(present, _buffer);
|
||||
cmdList->CopyResource(present, _buffer.Get());
|
||||
|
||||
// Restore resource states
|
||||
ResourceBarrier(cmdList, present, D3D12_RESOURCE_STATE_COPY_DEST, presentState);
|
||||
ResourceBarrier(cmdList, hudless, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, hudlessState);
|
||||
ResourceBarrier(cmdList, _buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
ResourceBarrier(cmdList, _buffer.Get(), D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -136,20 +136,3 @@ HudCopy_Dx12::HudCopy_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, HudCopy_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
HudCopy_Dx12::~HudCopy_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < HudCopy_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class HudCopy_Dx12 : public Shader_Dx12
|
||||
|
||||
FrameDescriptorHeap _frameHeaps[HudCopy_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
|
||||
uint32_t InNumThreadsX = 16;
|
||||
uint32_t InNumThreadsY = 16;
|
||||
@@ -33,6 +33,4 @@ class HudCopy_Dx12 : public Shader_Dx12
|
||||
D3D12_RESOURCE_STATES hudlessState, D3D12_RESOURCE_STATES presentState, float hudDetectionThreshold);
|
||||
|
||||
HudCopy_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~HudCopy_Dx12();
|
||||
};
|
||||
|
||||
@@ -76,7 +76,7 @@ HC_Dx12::HC_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(InNam
|
||||
ID3DBlob *vs, *ps;
|
||||
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC graphicsPsoDesc {};
|
||||
graphicsPsoDesc.pRootSignature = _rootSignature;
|
||||
graphicsPsoDesc.pRootSignature = _rootSignature.Get();
|
||||
|
||||
if (Config::Instance()->UsePrecompiledShaders.value_or_default())
|
||||
{
|
||||
@@ -209,7 +209,7 @@ bool HC_Dx12::Dispatch(IDXGISwapChain3* sc, ID3D12GraphicsCommandList* cmdList,
|
||||
constants.DiffThreshold = 0.003f;
|
||||
constants.PinkAmount = 0.6f;
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -218,8 +218,8 @@ bool HC_Dx12::Dispatch(IDXGISwapChain3* sc, ID3D12GraphicsCommandList* cmdList,
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
cmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
cmdList->SetGraphicsRootSignature(_rootSignature);
|
||||
cmdList->SetPipelineState(_pipelineState);
|
||||
cmdList->SetGraphicsRootSignature(_rootSignature.Get());
|
||||
cmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
cmdList->SetGraphicsRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -250,26 +250,3 @@ bool HC_Dx12::Dispatch(IDXGISwapChain3* sc, ID3D12GraphicsCommandList* cmdList,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HC_Dx12::~HC_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
if (_rootSignature != nullptr)
|
||||
{
|
||||
_rootSignature->Release();
|
||||
_rootSignature = nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < HC_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_constantBuffer != nullptr)
|
||||
{
|
||||
_constantBuffer->Release();
|
||||
_constantBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,4 @@ class HC_Dx12 : public Shader_Dx12
|
||||
D3D12_RESOURCE_STATES state);
|
||||
|
||||
HC_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~HC_Dx12();
|
||||
};
|
||||
|
||||
@@ -49,24 +49,24 @@ bool HCC_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* hudl
|
||||
|
||||
ResourceBarrier(cmdList, present, presentState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
|
||||
cmdList->CopyResource(_buffer, present);
|
||||
cmdList->CopyResource(_buffer.Get(), present);
|
||||
|
||||
// Make sure present is in D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE
|
||||
ResourceBarrier(cmdList, present, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
ResourceBarrier(cmdList, _buffer, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
ResourceBarrier(cmdList, _buffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
ResourceBarrier(cmdList, hudless, hudlessState, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
// Create views
|
||||
CreateShaderResourceView(_device, hudless, currentHeap.GetSrvCPU(0));
|
||||
CreateShaderResourceView(_device, present, currentHeap.GetSrvCPU(1));
|
||||
CreateUnorderedAccessView(_device, _buffer, currentHeap.GetUavCPU(0), 0);
|
||||
CreateUnorderedAccessView(_device, _buffer.Get(), currentHeap.GetUavCPU(0), 0);
|
||||
|
||||
InternalCompareParams constants {};
|
||||
constants.DiffThreshold = 0.003f;
|
||||
constants.PinkAmount = 0.6f;
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -75,8 +75,8 @@ bool HCC_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* hudl
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
cmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
cmdList->SetComputeRootSignature(_rootSignature);
|
||||
cmdList->SetPipelineState(_pipelineState);
|
||||
cmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
cmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
cmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -86,15 +86,15 @@ bool HCC_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* hudl
|
||||
|
||||
cmdList->Dispatch(dispatchWidth, dispatchHeight, 1);
|
||||
|
||||
ResourceBarrier(cmdList, _buffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
ResourceBarrier(cmdList, _buffer.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
ResourceBarrier(cmdList, present, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
|
||||
cmdList->CopyResource(present, _buffer);
|
||||
cmdList->CopyResource(present, _buffer.Get());
|
||||
|
||||
// Restore resource states
|
||||
ResourceBarrier(cmdList, present, D3D12_RESOURCE_STATE_COPY_DEST, presentState);
|
||||
ResourceBarrier(cmdList, hudless, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, hudlessState);
|
||||
ResourceBarrier(cmdList, _buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
ResourceBarrier(cmdList, _buffer.Get(), D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -136,20 +136,3 @@ HCC_Dx12::HCC_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(InN
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, HCC_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
HCC_Dx12::~HCC_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < HCC_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class HCC_Dx12 : public Shader_Dx12
|
||||
|
||||
FrameDescriptorHeap _frameHeaps[HCC_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
|
||||
uint32_t InNumThreadsX = 16;
|
||||
uint32_t InNumThreadsY = 16;
|
||||
@@ -34,6 +34,4 @@ class HCC_Dx12 : public Shader_Dx12
|
||||
D3D12_RESOURCE_STATES hudlessState, D3D12_RESOURCE_STATES presentState);
|
||||
|
||||
HCC_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~HCC_Dx12();
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ bool OS_Dx12::CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InSou
|
||||
|
||||
void OS_Dx12::SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState)
|
||||
{
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer, &_bufferState);
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer.Get(), &_bufferState);
|
||||
}
|
||||
|
||||
bool OS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource)
|
||||
@@ -78,11 +78,12 @@ bool OS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
if (Config::Instance()->OutputScalingDownscaler.value_or_default() == Scaler::FSR1)
|
||||
{
|
||||
createdConstantsBuffer =
|
||||
CreateConstantsBuffer(_device, _constantBuffer, fsr1Constants, currentHeap.GetCbvCPU(0));
|
||||
CreateConstantsBuffer(_device, _constantBuffer.Get(), fsr1Constants, currentHeap.GetCbvCPU(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
createdConstantsBuffer = CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0));
|
||||
createdConstantsBuffer =
|
||||
CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0));
|
||||
}
|
||||
|
||||
if (!createdConstantsBuffer)
|
||||
@@ -94,8 +95,8 @@ bool OS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -142,7 +143,7 @@ OS_Dx12::OS_Dx12(std::string InName, ID3D12Device* InDevice, bool InUpsample)
|
||||
Config::Instance()->OutputScalingDownscaler.value_or_default() == Scaler::FSR1)
|
||||
{
|
||||
D3D12_COMPUTE_PIPELINE_STATE_DESC computePsoDesc = {};
|
||||
computePsoDesc.pRootSignature = _rootSignature;
|
||||
computePsoDesc.pRootSignature = _rootSignature.Get();
|
||||
computePsoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
|
||||
|
||||
// fsr upscaling
|
||||
@@ -295,7 +296,8 @@ OS_Dx12::OS_Dx12(std::string InName, ID3D12Device* InDevice, bool InUpsample)
|
||||
LOG_ERROR("[{0}] CompileShader error!", _name);
|
||||
|
||||
// create pso objects
|
||||
if (!Shader_Dx12::CreateComputeShader(InDevice, _rootSignature, &_pipelineState, _recEncodeShader, byteCode))
|
||||
if (!Shader_Dx12::CreateComputeShader(InDevice, _rootSignature.Get(), &_pipelineState, _recEncodeShader,
|
||||
byteCode))
|
||||
{
|
||||
LOG_ERROR("[{0}] CreateComputeShader error!", _name);
|
||||
return;
|
||||
@@ -310,20 +312,3 @@ OS_Dx12::OS_Dx12(std::string InName, ID3D12Device* InDevice, bool InUpsample)
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, OS_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
OS_Dx12::~OS_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < OS_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class OS_Dx12 : public Shader_Dx12
|
||||
|
||||
FrameDescriptorHeap _frameHeaps[OS_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON;
|
||||
|
||||
uint32_t InNumThreadsX = 16;
|
||||
@@ -26,11 +26,9 @@ class OS_Dx12 : public Shader_Dx12
|
||||
void SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState);
|
||||
bool Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* OutResource);
|
||||
|
||||
ID3D12Resource* Buffer() { return _buffer; }
|
||||
ID3D12Resource* Buffer() { return _buffer.Get(); }
|
||||
bool IsUpsampling() { return _upsample; }
|
||||
bool CanRender() const { return _init && _buffer != nullptr; }
|
||||
|
||||
OS_Dx12(std::string InName, ID3D12Device* InDevice, bool InUpsample);
|
||||
|
||||
~OS_Dx12();
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ bool RCAS_Dx12::DispatchRCAS(ID3D12GraphicsCommandList* InCmdList, ID3D12Resourc
|
||||
|
||||
FillMotionConstants(constants, InConstants);
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -38,8 +38,8 @@ bool RCAS_Dx12::DispatchRCAS(ID3D12GraphicsCommandList* InCmdList, ID3D12Resourc
|
||||
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
auto inDesc = InResource->GetDesc();
|
||||
@@ -78,7 +78,7 @@ bool RCAS_Dx12::DispatchDepthAdaptive(ID3D12GraphicsCommandList* InCmdList, ID3D
|
||||
|
||||
FillMotionConstants(constants, InConstants);
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -86,8 +86,8 @@ bool RCAS_Dx12::DispatchDepthAdaptive(ID3D12GraphicsCommandList* InCmdList, ID3D
|
||||
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineStateDA);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineStateDA.Get());
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
UINT dispatchWidth = static_cast<UINT>((constants.OutputWidth + InNumThreadsX - 1) / InNumThreadsX);
|
||||
@@ -115,7 +115,7 @@ bool RCAS_Dx12::CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InS
|
||||
|
||||
void RCAS_Dx12::SetBufferState(ID3D12GraphicsCommandList* InCommandList, D3D12_RESOURCE_STATES InState)
|
||||
{
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer, &_bufferState);
|
||||
return Shader_Dx12::SetBufferState(InCommandList, InState, _buffer.Get(), &_bufferState);
|
||||
}
|
||||
|
||||
bool RCAS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource,
|
||||
@@ -185,26 +185,3 @@ RCAS_Dx12::RCAS_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(I
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, RCAS_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
RCAS_Dx12::~RCAS_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
if (_pipelineStateDA != nullptr)
|
||||
{
|
||||
_pipelineStateDA->Release();
|
||||
_pipelineStateDA = nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < RCAS_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_buffer != nullptr)
|
||||
{
|
||||
_buffer->Release();
|
||||
_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class RCAS_Dx12 : public Shader_Dx12, public RCAS_Common
|
||||
|
||||
FrameDescriptorHeap _frameHeaps[RCAS_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer = nullptr;
|
||||
D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON;
|
||||
|
||||
ID3D12PipelineState* _pipelineStateDA = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D12PipelineState> _pipelineStateDA = nullptr;
|
||||
|
||||
uint32_t InNumThreadsX = 16;
|
||||
uint32_t InNumThreadsY = 16;
|
||||
@@ -39,10 +39,8 @@ class RCAS_Dx12 : public Shader_Dx12, public RCAS_Common
|
||||
bool Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InResource, ID3D12Resource* InMotionVectors,
|
||||
RcasConstants InConstants, ID3D12Resource* OutResource, ID3D12Resource* InDepth = nullptr);
|
||||
|
||||
ID3D12Resource* Buffer() { return _buffer; }
|
||||
ID3D12Resource* Buffer() { return _buffer.Get(); }
|
||||
bool CanRender() const { return _init && _buffer != nullptr; }
|
||||
|
||||
RCAS_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~RCAS_Dx12();
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ void RUI_Dx12::SetBufferState(UINT index, ID3D12GraphicsCommandList* InCommandLi
|
||||
if (_bufferState[index] == InState)
|
||||
return;
|
||||
|
||||
ResourceBarrier(InCommandList, _buffer[index], _bufferState[index], InState);
|
||||
ResourceBarrier(InCommandList, _buffer[index].Get(), _bufferState[index], InState);
|
||||
|
||||
_bufferState[index] = InState;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ RUI_Dx12::RUI_Dx12(std::string InName, ID3D12Device* InDevice, bool preMultiplie
|
||||
ID3DBlob *vs, *ps;
|
||||
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC graphicsPsoDesc {};
|
||||
graphicsPsoDesc.pRootSignature = _rootSignature;
|
||||
graphicsPsoDesc.pRootSignature = _rootSignature.Get();
|
||||
|
||||
if (Config::Instance()->UsePrecompiledShaders.value_or_default())
|
||||
{
|
||||
@@ -204,7 +204,7 @@ bool RUI_Dx12::Dispatch(IDXGISwapChain3* sc, ID3D12GraphicsCommandList* cmdList,
|
||||
ResourceBarrier(cmdList, scBuffer, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
|
||||
if (_buffer[_counter] != nullptr)
|
||||
cmdList->CopyResource(_buffer[_counter], scBuffer);
|
||||
cmdList->CopyResource(_buffer[_counter].Get(), scBuffer);
|
||||
|
||||
ResourceBarrier(cmdList, scBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||
SetBufferState(_counter, cmdList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
@@ -220,14 +220,14 @@ bool RUI_Dx12::Dispatch(IDXGISwapChain3* sc, ID3D12GraphicsCommandList* cmdList,
|
||||
|
||||
// Create views
|
||||
CreateShaderResourceView(_device, hudless, currentHeap.GetSrvCPU(0));
|
||||
CreateShaderResourceView(_device, _buffer[_counter], currentHeap.GetSrvCPU(1));
|
||||
CreateShaderResourceView(_device, _buffer[_counter].Get(), currentHeap.GetSrvCPU(1));
|
||||
CreateRenderTargetView(_device, scBuffer, currentHeap.GetRtvCPU(0), 0);
|
||||
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
cmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
cmdList->SetGraphicsRootSignature(_rootSignature);
|
||||
cmdList->SetPipelineState(_pipelineState);
|
||||
cmdList->SetGraphicsRootSignature(_rootSignature.Get());
|
||||
cmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
cmdList->SetGraphicsRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -258,26 +258,3 @@ bool RUI_Dx12::Dispatch(IDXGISwapChain3* sc, ID3D12GraphicsCommandList* cmdList,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RUI_Dx12::~RUI_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
if (_rootSignature != nullptr)
|
||||
{
|
||||
_rootSignature->Release();
|
||||
_rootSignature = nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < HC_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
|
||||
if (_constantBuffer != nullptr)
|
||||
{
|
||||
_constantBuffer->Release();
|
||||
_constantBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class RUI_Dx12 : public Shader_Dx12
|
||||
bool _pm = false;
|
||||
FrameDescriptorHeap _frameHeaps[HC_NUM_OF_HEAPS];
|
||||
|
||||
ID3D12Resource* _buffer[HC_NUM_OF_HEAPS] = {};
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> _buffer[HC_NUM_OF_HEAPS] = {};
|
||||
D3D12_RESOURCE_STATES _bufferState[HC_NUM_OF_HEAPS] = { D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_COMMON };
|
||||
|
||||
static void ResourceBarrier(ID3D12GraphicsCommandList* InCommandList, ID3D12Resource* InResource,
|
||||
@@ -32,6 +32,4 @@ class RUI_Dx12 : public Shader_Dx12
|
||||
bool IsPreMultipliedAlpha() const { return _pm; }
|
||||
|
||||
RUI_Dx12(std::string InName, ID3D12Device* InDevice, bool preMultipliedAlpha);
|
||||
|
||||
~RUI_Dx12();
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ bool RF_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
|
||||
LOG_DEBUG("Width: {}, Height: {}, Offset", constants.width, constants.height, constants.offset);
|
||||
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer, constants, currentHeap.GetCbvCPU(0)))
|
||||
if (!CreateConstantsBuffer(_device, _constantBuffer.Get(), constants, currentHeap.GetCbvCPU(0)))
|
||||
{
|
||||
LOG_ERROR("[{0}] Failed to create a constants buffer", _name);
|
||||
return false;
|
||||
@@ -42,8 +42,8 @@ bool RF_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* InR
|
||||
ID3D12DescriptorHeap* heaps[] = { currentHeap.GetHeapCSU() };
|
||||
InCmdList->SetDescriptorHeaps(_countof(heaps), heaps);
|
||||
|
||||
InCmdList->SetComputeRootSignature(_rootSignature);
|
||||
InCmdList->SetPipelineState(_pipelineState);
|
||||
InCmdList->SetComputeRootSignature(_rootSignature.Get());
|
||||
InCmdList->SetPipelineState(_pipelineState.Get());
|
||||
|
||||
InCmdList->SetComputeRootDescriptorTable(0, currentHeap.GetTableGPUStart());
|
||||
|
||||
@@ -105,14 +105,3 @@ RF_Dx12::RF_Dx12(std::string InName, ID3D12Device* InDevice) : Shader_Dx12(InNam
|
||||
|
||||
_init = InitHeaps(InDevice, _frameHeaps, RF_NUM_OF_HEAPS);
|
||||
}
|
||||
|
||||
RF_Dx12::~RF_Dx12()
|
||||
{
|
||||
if (!_init || State::Instance().isShuttingDown)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < RF_NUM_OF_HEAPS; i++)
|
||||
{
|
||||
_frameHeaps[i].ReleaseHeaps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,4 @@ class RF_Dx12 : public Shader_Dx12
|
||||
UINT64 width, UINT height, bool velocity);
|
||||
|
||||
RF_Dx12(std::string InName, ID3D12Device* InDevice);
|
||||
|
||||
~RF_Dx12();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user