Merge remote-tracking branch 'origin/master' into 1.10

# Conflicts:
#	Source/Engine/Graphics/Materials/MaterialShader.h
This commit is contained in:
Wojtek Figat
2025-02-18 09:19:59 +01:00
133 changed files with 2253 additions and 654 deletions

View File

@@ -10,6 +10,7 @@
GPUBufferDX11::GPUBufferDX11(GPUDeviceDX11* device, const StringView& name)
: GPUResourceDX11(device, name)
{
_view.SetParnet(this);
}
GPUBufferView* GPUBufferDX11::View() const

View File

@@ -40,6 +40,11 @@ public:
public:
void SetParnet(GPUBuffer* parent)
{
_parent = parent;
}
/// <summary>
/// Release the view.
/// </summary>

View File

@@ -358,7 +358,11 @@ void GPUContextDX11::BindCB(int32 slot, GPUConstantBuffer* cb)
void GPUContextDX11::BindSR(int32 slot, GPUResourceView* view)
{
#if !BUILD_RELEASE
ASSERT(slot >= 0 && slot < GPU_MAX_SR_BINDED);
if (view && ((IShaderResourceDX11*)view->GetNativePtr())->SRV() == nullptr)
LogInvalidResourceUsage(slot, view, InvalidBindPoint::SRV);
#endif
auto handle = view ? ((IShaderResourceDX11*)view->GetNativePtr())->SRV() : nullptr;
if (_srHandles[slot] != handle)
{
@@ -372,7 +376,11 @@ void GPUContextDX11::BindSR(int32 slot, GPUResourceView* view)
void GPUContextDX11::BindUA(int32 slot, GPUResourceView* view)
{
#if !BUILD_RELEASE
ASSERT(slot >= 0 && slot < GPU_MAX_UA_BINDED);
if (view && ((IShaderResourceDX11*)view->GetNativePtr())->UAV() == nullptr)
LogInvalidResourceUsage(slot, view, InvalidBindPoint::UAV);
#endif
auto handle = view ? ((IShaderResourceDX11*)view->GetNativePtr())->UAV() : nullptr;
if (_uaHandles[slot] != handle)
{

View File

@@ -12,13 +12,11 @@
class IShaderResourceDX11
{
public:
IShaderResourceDX11()
{
}
public:
/// <summary>
/// Gets handle to the shader resource view object.
/// </summary>
@@ -28,7 +26,6 @@ public:
/// <summary>
/// Gets CPU to the unordered access view object.
/// </summary>
/// <returns>UAV</returns>
virtual ID3D11UnorderedAccessView* UAV() const = 0;
};

View File

@@ -6,18 +6,6 @@
#include "GPUDeviceDX12.h"
#include "Engine/GraphicsDevice/DirectX/RenderToolsDX.h"
D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeapWithSlotsDX12::Slot::CPU() const
{
ASSERT_LOW_LAYER(Heap);
return Heap->CPU(Index);
}
D3D12_GPU_DESCRIPTOR_HANDLE DescriptorHeapWithSlotsDX12::Slot::GPU() const
{
ASSERT_LOW_LAYER(Heap);
return Heap->GPU(Index);
}
void DescriptorHeapWithSlotsDX12::Slot::CreateSRV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_SHADER_RESOURCE_VIEW_DESC* desc)
{
if (Heap == nullptr)

View File

@@ -35,8 +35,15 @@ public:
}
#endif
D3D12_CPU_DESCRIPTOR_HANDLE CPU() const;
D3D12_GPU_DESCRIPTOR_HANDLE GPU() const;
FORCE_INLINE D3D12_CPU_DESCRIPTOR_HANDLE CPU() const
{
return Heap ? Heap->CPU(Index) : D3D12_CPU_DESCRIPTOR_HANDLE {};
}
FORCE_INLINE D3D12_GPU_DESCRIPTOR_HANDLE GPU() const
{
return Heap ? Heap->GPU(Index) : D3D12_GPU_DESCRIPTOR_HANDLE {};
}
void CreateSRV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_SHADER_RESOURCE_VIEW_DESC* desc = nullptr);
void CreateRTV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_RENDER_TARGET_VIEW_DESC* desc = nullptr);

View File

@@ -120,6 +120,7 @@ bool GPUBufferDX12::OnInit()
switch (_desc.Usage)
{
case GPUResourceUsage::StagingUpload:
case GPUResourceUsage::Staging:
heapProperties.Type = D3D12_HEAP_TYPE_UPLOAD;
break;
case GPUResourceUsage::StagingReadback:
@@ -152,7 +153,7 @@ bool GPUBufferDX12::OnInit()
// But if we are doing it during update or from the other thread we have to register resource data upload job.
// In both cases options.InitData data have to exist for a few next frames.
if (_desc.Usage == GPUResourceUsage::StagingUpload)
if (_desc.Usage == GPUResourceUsage::StagingUpload || _desc.Usage == GPUResourceUsage::Staging)
{
// Modify staging resource data now
SetData(_desc.InitData, _desc.Size);
@@ -188,7 +189,7 @@ bool GPUBufferDX12::OnInit()
}
// Create views
_view.Init(_device, this);
_view.Init(_device, this, this);
if (useSRV)
{
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;

View File

@@ -46,10 +46,12 @@ public:
/// </summary>
/// <param name="device">The graphics device.</param>
/// <param name="owner">The resource owner.</param>
void Init(GPUDeviceDX12* device, ResourceOwnerDX12* owner)
/// <param name="parent">The parent resource.</param>
void Init(GPUDeviceDX12* device, ResourceOwnerDX12* owner, GPUResource* parent)
{
_device = device;
_owner = owner;
_parent = parent;
}
/// <summary>

View File

@@ -934,9 +934,13 @@ void GPUContextDX12::BindCB(int32 slot, GPUConstantBuffer* cb)
void GPUContextDX12::BindSR(int32 slot, GPUResourceView* view)
{
#if !BUILD_RELEASE
ASSERT(slot >= 0 && slot < GPU_MAX_SR_BINDED);
if (view && ((IShaderResourceDX12*)view->GetNativePtr())->SRV().ptr == 0)
LogInvalidResourceUsage(slot, view, InvalidBindPoint::SRV);
#endif
auto handle = view ? (IShaderResourceDX12*)view->GetNativePtr() : nullptr;
if (_srHandles[slot] != handle || !handle)
if (_srHandles[slot] != handle)
{
_srMaskDirtyGraphics |= 1 << slot;
_srMaskDirtyCompute |= 1 << slot;
@@ -948,7 +952,11 @@ void GPUContextDX12::BindSR(int32 slot, GPUResourceView* view)
void GPUContextDX12::BindUA(int32 slot, GPUResourceView* view)
{
#if !BUILD_RELEASE
ASSERT(slot >= 0 && slot < GPU_MAX_UA_BINDED);
if (view && ((IShaderResourceDX12*)view->GetNativePtr())->UAV().ptr == 0)
LogInvalidResourceUsage(slot, view, InvalidBindPoint::UAV);
#endif
_uaHandles[slot] = view ? (IShaderResourceDX12*)view->GetNativePtr() : nullptr;
if (view)
*view->LastRenderTime = _lastRenderTime;

View File

@@ -23,6 +23,7 @@ namespace RenderToolsDX
{
case GPUResourceUsage::Dynamic:
return D3D11_USAGE_DYNAMIC;
case GPUResourceUsage::Staging:
case GPUResourceUsage::StagingUpload:
case GPUResourceUsage::StagingReadback:
return D3D11_USAGE_STAGING;
@@ -37,6 +38,8 @@ namespace RenderToolsDX
{
case GPUResourceUsage::Dynamic:
return D3D11_CPU_ACCESS_WRITE;
case GPUResourceUsage::Staging:
return D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
case GPUResourceUsage::StagingReadback:
return D3D11_CPU_ACCESS_READ;
case GPUResourceUsage::StagingUpload: