Cleanup renderer code

This commit is contained in:
Wojtek Figat
2021-06-07 11:56:04 +02:00
parent dfee74ad1f
commit cc47cb85e4
17 changed files with 92 additions and 195 deletions

View File

@@ -40,7 +40,6 @@ public:
/// <summary>
/// Gets buffer (may be null since it's using 'late init' feature)
/// </summary>
/// <returns>Buffer</returns>
FORCE_INLINE GPUBuffer* GetBuffer() const
{
return _buffer;

View File

@@ -31,6 +31,39 @@ GPUPipelineState* GPUPipelineState::New()
return GPUDevice::Instance->CreatePipelineState();
}
bool GPUPipelineState::Init(const Description& desc)
{
// Cache description in debug builds
#if BUILD_DEBUG
DebugDesc = desc;
#endif
// Cache shader stages usage flags for pipeline state
_meta.InstructionsCount = 0;
_meta.UsedCBsMask = 0;
_meta.UsedSRsMask = 0;
_meta.UsedUAsMask = 0;
#define CHECK_STAGE(stage) \
if (desc.stage) { \
_meta.UsedCBsMask |= desc.stage->GetBindings().UsedCBsMask; \
_meta.UsedSRsMask |= desc.stage->GetBindings().UsedSRsMask; \
_meta.UsedUAsMask |= desc.stage->GetBindings().UsedUAsMask; \
}
CHECK_STAGE(VS);
CHECK_STAGE(HS);
CHECK_STAGE(DS);
CHECK_STAGE(GS);
CHECK_STAGE(PS);
#undef CHECK_STAGE
return false;
}
GPUResource::ResourceType GPUPipelineState::GetResourceType() const
{
return ResourceType::PipelineState;
}
GPUPipelineState::Description GPUPipelineState::Description::Default =
{
// Enable/disable depth write
@@ -122,6 +155,33 @@ GPUPipelineState::Description GPUPipelineState::Description::DefaultFullscreenTr
BlendingMode::Opaque,
};
void GPUResource::ReleaseGPU()
{
if (_memoryUsage != 0)
{
Releasing();
OnReleaseGPU();
_memoryUsage = 0;
}
}
void GPUResource::OnDeviceDispose()
{
// By default we want to release resource data but keep it alive
ReleaseGPU();
}
void GPUResource::OnReleaseGPU()
{
}
void GPUResource::OnDeleteObject()
{
ReleaseGPU();
PersistentScriptingObject::OnDeleteObject();
}
struct GPUDevice::PrivateData
{
AssetReference<Shader> QuadShader;

View File

@@ -115,12 +115,10 @@ protected:
public:
#if BUILD_DEBUG
/// <summary>
/// The description of the pipeline state cached on creation in debug builds. Can be used to help with rendering crashes or issues and validation.
/// </summary>
Description DebugDesc;
#endif
public:
@@ -128,7 +126,6 @@ public:
/// <summary>
/// Gets constant buffers usage mask (each set bit marks usage of the constant buffer at the bit index slot). Combined from all the used shader stages.
/// </summary>
/// <returns>The constant buffers usage mask.</returns>
FORCE_INLINE uint32 GetUsedCBsMask() const
{
return _meta.UsedCBsMask;
@@ -137,7 +134,6 @@ public:
/// <summary>
/// Gets shader resources usage mask (each set bit marks usage of the shader resource slot at the bit index slot). Combined from all the used shader stages.
/// </summary>
/// <returns>The shader resource usage mask.</returns>
FORCE_INLINE uint32 GetUsedSRsMask() const
{
return _meta.UsedSRsMask;
@@ -146,7 +142,6 @@ public:
/// <summary>
/// Gets unordered access usage mask (each set bit marks usage of the unordered access slot at the bit index slot). Combined from all the used shader stages.
/// </summary>
/// <returns>The unordered access usage mask.</returns>
FORCE_INLINE uint32 GetUsedUAsMask() const
{
return _meta.UsedUAsMask;
@@ -157,7 +152,6 @@ public:
/// <summary>
/// Returns true if pipeline state is valid and ready to use
/// </summary>
/// <returns>True if is valid</returns>
API_PROPERTY() virtual bool IsValid() const = 0;
/// <summary>
@@ -165,39 +159,9 @@ public:
/// </summary>
/// <param name="desc">Full pipeline state description</param>
/// <returns>True if cannot create state, otherwise false</returns>
API_FUNCTION() virtual bool Init(API_PARAM(Ref) const Description& desc)
{
// Cache description in debug builds
#if BUILD_DEBUG
DebugDesc = desc;
#endif
// Cache shader stages usage flags for pipeline state
_meta.InstructionsCount = 0;
_meta.UsedCBsMask = 0;
_meta.UsedSRsMask = 0;
_meta.UsedUAsMask = 0;
#define CHECK_STAGE(stage) \
if(desc.stage) { \
_meta.UsedCBsMask |= desc.stage->GetBindings().UsedCBsMask; \
_meta.UsedSRsMask |= desc.stage->GetBindings().UsedSRsMask; \
_meta.UsedUAsMask |= desc.stage->GetBindings().UsedUAsMask; \
}
CHECK_STAGE(VS);
CHECK_STAGE(HS);
CHECK_STAGE(DS);
CHECK_STAGE(GS);
CHECK_STAGE(PS);
#undef CHECK_STAGE
return false;
}
API_FUNCTION() virtual bool Init(API_PARAM(Ref) const Description& desc);
public:
// [GPUResource]
ResourceType GetResourceType() const final override
{
return ResourceType::PipelineState;
}
ResourceType GetResourceType() const final override;
};

View File

@@ -75,13 +75,11 @@ public:
/// <summary>
/// Gets the resource type.
/// </summary>
/// <returns>The type.</returns>
virtual ResourceType GetResourceType() const = 0;
/// <summary>
/// Gets resource object type.
/// </summary>
/// <returns>The object type.</returns>
virtual ObjectType GetObjectType() const
{
return ObjectType::Other;
@@ -91,7 +89,6 @@ public:
/// Gets amount of GPU memory used by this resource (in bytes).
/// It's a rough estimation. GPU memory may be fragmented, compressed or sub-allocated so the actual memory pressure from this resource may vary (also depends on the current graphics backend).
/// </summary>
/// <returns>The current memory usage.</returns>
API_PROPERTY() FORCE_INLINE uint64 GetMemoryUsage() const
{
return _memoryUsage;
@@ -102,7 +99,6 @@ public:
/// <summary>
/// Gets the resource name.
/// </summary>
/// <returns>The name of the resource.</returns>
virtual String GetName() const
{
return String::Empty;
@@ -113,33 +109,19 @@ public:
/// <summary>
/// Releases GPU resource data.
/// </summary>
API_FUNCTION() void ReleaseGPU()
{
if (_memoryUsage != 0)
{
Releasing();
OnReleaseGPU();
_memoryUsage = 0;
}
}
API_FUNCTION() void ReleaseGPU();
/// <summary>
/// Action called when GPU device is disposing.
/// </summary>
virtual void OnDeviceDispose()
{
// By default we want to release resource data but keep it alive
ReleaseGPU();
}
virtual void OnDeviceDispose();
protected:
/// <summary>
/// Releases GPU resource data (implementation).
/// </summary>
virtual void OnReleaseGPU()
{
}
virtual void OnReleaseGPU();
public:
@@ -152,13 +134,7 @@ public:
return TEXT("GPU Resource");
#endif
}
void OnDeleteObject() override
{
ReleaseGPU();
PersistentScriptingObject::OnDeleteObject();
}
void OnDeleteObject() override;
};
/// <summary>

View File

@@ -98,10 +98,8 @@ GPUTexture* RenderBuffers::RequestHalfResDepth(GPUContext* context)
uint64 RenderBuffers::GetMemoryUsage() const
{
uint64 result = 0;
for (int32 i = 0; i < _resources.Count(); i++)
result += _resources[i]->GetMemoryUsage();
return result;
}

View File

@@ -37,26 +37,9 @@ public:
D3D12_CPU_DESCRIPTOR_HANDLE CPU() const;
D3D12_GPU_DESCRIPTOR_HANDLE GPU() const;
// Creates shader resource view
// @param index Descriptor index in the heap
// @param resource Shader Resource to create view for it
// @param desc View description
void CreateSRV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_SHADER_RESOURCE_VIEW_DESC* desc = nullptr);
// Creates render target view
// @param index Descriptor index in the heap
// @param resource Render Target to create view for it
void CreateRTV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_RENDER_TARGET_VIEW_DESC* desc = nullptr);
// Creates depth stencil view
// @param index Descriptor index in the heap
// @param resource Render Target Depth to create view for it
void CreateDSV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_DEPTH_STENCIL_VIEW_DESC* desc = nullptr);
// Creates unordered access view
// @param index Descriptor index in the heap
// @param resource Unordered Access to create view for it
// @param desc View description
void CreateUAV(GPUDeviceDX12* device, ID3D12Resource* resource, D3D12_UNORDERED_ACCESS_VIEW_DESC* desc = nullptr, ID3D12Resource* counterResource = nullptr);
void Release();

View File

@@ -125,13 +125,7 @@ bool GPUBufferDX12::OnInit()
// Create resource
ID3D12Resource* resource;
D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COPY_DEST;
VALIDATE_DIRECTX_RESULT(_device->GetDevice()->CreateCommittedResource(
&heapProperties,
D3D12_HEAP_FLAG_NONE,
&resourceDesc,
initialState,
nullptr,
IID_PPV_ARGS(&resource)));
VALIDATE_DIRECTX_RESULT(_device->GetDevice()->CreateCommittedResource(&heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, initialState, nullptr, IID_PPV_ARGS(&resource)));
// Set state
initResource(resource, initialState, 1);

View File

@@ -107,17 +107,14 @@ public:
{
return false;
}
D3D12_CPU_DESCRIPTOR_HANDLE SRV() const override
{
return _srv.CPU();
}
D3D12_CPU_DESCRIPTOR_HANDLE UAV() const override
{
return _uav.CPU();
}
ResourceOwnerDX12* GetResourceOwner() const override
{
return _owner;
@@ -173,19 +170,16 @@ public:
/// <summary>
/// Gets buffer size in a GPU memory in bytes.
/// </summary>
/// <returns>Size in bytes.</returns>
uint64 GetSizeInBytes() const;
/// <summary>
/// Gets buffer location in a GPU memory.
/// </summary>
/// <returns>GPU memory location.</returns>
D3D12_GPU_VIRTUAL_ADDRESS GetLocation() const;
/// <summary>
/// Gets the counter resource.
/// </summary>
/// <returns>The internal counter buffer.</returns>
FORCE_INLINE GPUBufferDX12* GetCounter() const
{
return _counter;

View File

@@ -100,18 +100,16 @@ public:
public:
/// <summary>
/// Gets DX12 device
/// Gets DX12 device.
/// </summary>
/// <returns>DirectX 12 device</returns>
FORCE_INLINE ID3D12Device* GetDevice() const
{
return _device;
}
/// <summary>
/// Gets DXGI factory
/// Gets DXGI factory.
/// </summary>
/// <returns>DXGI factory object</returns>
FORCE_INLINE IDXGIFactory4* GetDXGIFactory() const
{
return _factoryDXGI;
@@ -120,28 +118,24 @@ public:
/// <summary>
/// Gets DirectX 12 command list object
/// </summary>
/// <returns>Command list object (DirectX 12)</returns>
ID3D12GraphicsCommandList* GetCommandList() const;
/// <summary>
/// Gets command queue
/// Gets command queue.
/// </summary>
/// <returns>Command queue</returns>
FORCE_INLINE CommandQueueDX12* GetCommandQueue() const
{
return _commandQueue;
}
/// <summary>
/// Gets DirectX 12 command queue object
/// Gets DirectX 12 command queue object.
/// </summary>
/// <returns>Command queue object (DirectX 12)</returns>
ID3D12CommandQueue* GetCommandQueueDX12() const;
/// <summary>
/// Gets root signature of the graphics pipeline
/// Gets root signature of the graphics pipeline.
/// </summary>
/// <returns>Root signature</returns>
FORCE_INLINE ID3D12RootSignature* GetRootSignature() const
{
return _rootSignature;
@@ -150,7 +144,6 @@ public:
/// <summary>
/// Gets main commands context (for DirectX 12)
/// </summary>
/// <returns>Main context</returns>
FORCE_INLINE GPUContextDX12* GetMainContextDX12() const
{
return _mainContext;
@@ -171,9 +164,7 @@ public:
static FORCE_INLINE uint32 GetMaxMSAAQuality(uint32 sampleCount)
{
if (sampleCount <= 8)
{
return 0;
}
return 0xffffffff;
}
@@ -196,12 +187,10 @@ public:
{
return reinterpret_cast<GPUContext*>(_mainContext);
}
void* GetNativePtr() const override
{
return _device;
}
bool Init() override;
void DrawBegin() override;
void RenderEnd() override;

View File

@@ -22,9 +22,6 @@ private:
public:
/// <summary>
/// Initializes a new instance of the <see cref="GPUTextureViewDX12"/> class.
/// </summary>
GPUTextureViewDX12()
{
}
@@ -45,9 +42,6 @@ public:
return *this;
}
/// <summary>
/// Finalizes an instance of the <see cref="GPUTextureViewDX12"/> class.
/// </summary>
~GPUTextureViewDX12()
{
Release();
@@ -155,8 +149,7 @@ public:
/// <summary>
/// Gets the CPU handle to the render target view descriptor.
/// </summary>
/// <returns>The CPU handle to the render target view descriptor.</returns>
D3D12_CPU_DESCRIPTOR_HANDLE RTV() const
FORCE_INLINE D3D12_CPU_DESCRIPTOR_HANDLE RTV() const
{
return _rtv.CPU();
}
@@ -164,8 +157,7 @@ public:
/// <summary>
/// Gets the CPU handle to the depth stencil view descriptor.
/// </summary>
/// <returns>The CPU handle to the depth stencil view descriptor.</returns>
D3D12_CPU_DESCRIPTOR_HANDLE DSV() const
FORCE_INLINE D3D12_CPU_DESCRIPTOR_HANDLE DSV() const
{
return _dsv.CPU();
}
@@ -183,17 +175,14 @@ public:
{
return _dsv.IsValid();
}
D3D12_CPU_DESCRIPTOR_HANDLE SRV() const override
{
return _srv.CPU();
}
D3D12_CPU_DESCRIPTOR_HANDLE UAV() const override
{
return _uav.CPU();
}
ResourceOwnerDX12* GetResourceOwner() const override
{
return _owner;
@@ -223,11 +212,6 @@ private:
public:
/// <summary>
/// Initializes a new instance of the <see cref="GPUTextureDX12"/> class.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="name">The name.</param>
GPUTextureDX12(GPUDeviceDX12* device, const StringView& name)
: GPUResourceDX12<GPUTexture>(device, name)
{
@@ -244,35 +228,29 @@ public:
{
return (GPUTextureView*)&_handlesPerSlice[arrayOrDepthIndex];
}
GPUTextureView* View(int32 arrayOrDepthIndex, int32 mipMapIndex) const override
{
return (GPUTextureView*)&_handlesPerMip[arrayOrDepthIndex][mipMapIndex];
}
GPUTextureView* ViewArray() const override
{
ASSERT(ArraySize() > 1);
return (GPUTextureView*)&_handleArray;
}
GPUTextureView* ViewVolume() const override
{
ASSERT(IsVolume());
return (GPUTextureView*)&_handleVolume;
}
GPUTextureView* ViewReadOnlyDepth() const override
{
ASSERT(_desc.Flags & GPUTextureFlags::ReadOnlyDepthView);
return (GPUTextureView*)&_handleReadOnlyDepth;
}
void* GetNativePtr() const override
{
return (void*)nullptr;
return (void*)_resource;
}
bool GetData(int32 arrayOrDepthSliceIndex, int32 mipMapIndex, TextureMipData& data, uint32 mipRowPitch) override;
// [ResourceOwnerDX12]
@@ -286,17 +264,14 @@ public:
{
return (_desc.Flags & GPUTextureFlags::DepthStencil) != 0;
}
D3D12_CPU_DESCRIPTOR_HANDLE SRV() const override
{
return _srv.CPU();
}
D3D12_CPU_DESCRIPTOR_HANDLE UAV() const override
{
return _uav.CPU();
}
ResourceOwnerDX12* GetResourceOwner() const override
{
return (ResourceOwnerDX12*)this;

View File

@@ -36,25 +36,21 @@ public:
/// <summary>
/// Determines whether this resource is depth/stencil buffer.
/// </summary>
/// <returns>True if this resource is depth/stencil buffer, otherwise false.</returns>
virtual bool IsDepthStencilResource() const = 0;
/// <summary>
/// Gets CPU handle to the shader resource view descriptor.
/// </summary>
/// <returns>SRV</returns>
virtual D3D12_CPU_DESCRIPTOR_HANDLE SRV() const = 0;
/// <summary>
/// Gets CPU handle to the unordered access view descriptor.
/// </summary>
/// <returns>UAV</returns>
virtual D3D12_CPU_DESCRIPTOR_HANDLE UAV() const = 0;
/// <summary>
/// Gets the resource owner.
/// </summary>
/// <returns>Owner object.</returns>
virtual ResourceOwnerDX12* GetResourceOwner() const = 0;
};

View File

@@ -85,27 +85,15 @@ void QueryHeapDX12::Destroy()
void QueryHeapDX12::EndQueryBatchAndResolveQueryData(GPUContextDX12* context)
{
ASSERT(_currentBatch.Open);
// Skip empty batches
if (_currentBatch.Count == 0)
{
return;
}
// Close the current batch
_currentBatch.Open = false;
// Resolve the batch
const int32 offset = _currentBatch.Start * _resultSize;
const int32 size = _currentBatch.Count * _resultSize;
context->GetCommandList()->ResolveQueryData(
_queryHeap,
_queryType,
_currentBatch.Start,
_currentBatch.Count,
_resultBuffer,
offset
);
context->GetCommandList()->ResolveQueryData(_queryHeap, _queryType, _currentBatch.Start, _currentBatch.Count, _resultBuffer, offset);
_currentBatch.Sync = _device->GetCommandQueue()->GetSyncPoint();
// Begin a new query batch
@@ -199,8 +187,7 @@ void* QueryHeapDX12::ResolveQuery(ElementHandle& handle)
Platform::MemoryCopy(_resultData.Get() + range.Begin, (byte*)mapped + range.Begin, batch.Count * _resultSize);
// Unmap with an empty range to indicate nothing was written by the CPU
range.Begin = range.End = 0;
_resultBuffer->Unmap(0, &range);
_resultBuffer->Unmap(0, nullptr);
// All elements got its results so we can remove this batch
_batches.RemoveAt(i);

View File

@@ -35,7 +35,7 @@ public:
/// <param name="currentState">The current resource state.</param>
/// <param name="targetState">the destination resource state.</param>
/// <returns>True if need to perform a transition, otherwise false.</returns>
static bool IsTransitionNeeded(D3D12_RESOURCE_STATES currentState, D3D12_RESOURCE_STATES targetState)
FORCE_INLINE static bool IsTransitionNeeded(D3D12_RESOURCE_STATES currentState, D3D12_RESOURCE_STATES targetState)
{
return currentState != targetState && ((currentState | targetState) != currentState || targetState == D3D12_RESOURCE_STATE_COMMON);
}
@@ -81,7 +81,6 @@ public:
/// <summary>
/// Gets the subresources count.
/// </summary>
/// <returns>The subresources count.</returns>
FORCE_INLINE uint32 GetSubresourcesCount() const
{
return _subresourcesCount;
@@ -90,7 +89,6 @@ public:
/// <summary>
/// Gets DirectX 12 resource object handle
/// </summary>
/// <returns>DirectX 12 resource object handle</returns>
FORCE_INLINE ID3D12Resource* GetResource() const
{
return _resource;
@@ -99,7 +97,6 @@ public:
/// <summary>
/// Gets resource owner object as a GPUResource type or returns null if cannot perform cast.
/// </summary>
/// <returns>GPU Resource or null if cannot cast.</returns>
virtual GPUResource* AsGPUResource() const = 0;
protected:

View File

@@ -60,6 +60,7 @@ DynamicAllocation UploadBufferDX12::Allocate(uint64 size, uint64 align)
// Move in the page
_currentOffset += size;
ASSERT(_currentPage->GetResource());
return result;
}
@@ -67,12 +68,8 @@ bool UploadBufferDX12::UploadBuffer(GPUContextDX12* context, ID3D12Resource* buf
{
// Allocate data
const DynamicAllocation allocation = Allocate(size, 4);
// Check if allocation is invalid
if (allocation.IsInvalid())
{
return true;
}
// Copy data
Platform::MemoryCopy(allocation.CPUAddress, data, static_cast<size_t>(size));
@@ -85,10 +82,8 @@ bool UploadBufferDX12::UploadBuffer(GPUContextDX12* context, ID3D12Resource* buf
bool UploadBufferDX12::UploadTexture(GPUContextDX12* context, ID3D12Resource* texture, const void* srcData, uint32 srcRowPitch, uint32 srcSlicePitch, int32 mipIndex, int32 arrayIndex)
{
// Cache resource info
D3D12_RESOURCE_DESC resourceDesc = texture->GetDesc();
const UINT subresourceIndex = RenderToolsDX::CalcSubresourceIndex(mipIndex, arrayIndex, resourceDesc.MipLevels);
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint;
uint32 numRows;
uint64 rowPitchAligned, mipSizeAligned;
@@ -96,16 +91,8 @@ bool UploadBufferDX12::UploadTexture(GPUContextDX12* context, ID3D12Resource* te
rowPitchAligned = footprint.Footprint.RowPitch;
mipSizeAligned = rowPitchAligned * footprint.Footprint.Height;
// Destination texture copy location description
D3D12_TEXTURE_COPY_LOCATION dstLocation;
dstLocation.pResource = texture;
dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
dstLocation.SubresourceIndex = subresourceIndex;
// Allocate data
const DynamicAllocation allocation = Allocate(mipSizeAligned, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
// Check if allocation is invalid
if (allocation.Size != mipSizeAligned)
return true;
@@ -131,6 +118,12 @@ bool UploadBufferDX12::UploadTexture(GPUContextDX12* context, ID3D12Resource* te
}
}
// Destination texture copy location description
D3D12_TEXTURE_COPY_LOCATION dstLocation;
dstLocation.pResource = texture;
dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
dstLocation.SubresourceIndex = subresourceIndex;
// Source buffer copy location description
D3D12_TEXTURE_COPY_LOCATION srcLocation;
srcLocation.pResource = allocation.Page->GetResource();
@@ -235,13 +228,7 @@ UploadBufferPageDX12::UploadBufferPageDX12(GPUDeviceDX12* device, uint64 size)
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
resourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
ID3D12Resource* resource;
VALIDATE_DIRECTX_RESULT(_device->GetDevice()->CreateCommittedResource(
&heapProperties,
D3D12_HEAP_FLAG_NONE,
&resourceDesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&resource)));
VALIDATE_DIRECTX_RESULT(_device->GetDevice()->CreateCommittedResource(&heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&resource)));
// Set state
initResource(resource, D3D12_RESOURCE_STATE_GENERIC_READ, 1);
@@ -260,6 +247,8 @@ void UploadBufferPageDX12::OnReleaseGPU()
{
_resource->Unmap(0, nullptr);
}
GPUAddress = 0;
CPUAddress = nullptr;
// Release
releaseResource();

View File

@@ -183,7 +183,6 @@ public:
/// <summary>
/// Gets the current generation number.
/// </summary>
/// <returns>The current generation number.</returns>
FORCE_INLINE uint64 GetCurrentGeneration() const
{
return _currentGeneration;

View File

@@ -160,7 +160,6 @@ void GPUContextVulkan::AddImageBarrier(GPUTextureViewVulkan* handle, VkImageLayo
for (int32 i = 0; i < state.GetSubresourcesCount(); i++)
{
const VkImageLayout srcLayout = state.GetSubresourceState(i);
if (srcLayout != dstLayout)
{
VkImageSubresourceRange range;
@@ -175,13 +174,11 @@ void GPUContextVulkan::AddImageBarrier(GPUTextureViewVulkan* handle, VkImageLayo
}
ASSERT(state.CheckResourceState(dstLayout));
}
state.SetResourceState(dstLayout);
}
else
{
const VkImageLayout srcLayout = state.GetSubresourceState(subresourceIndex);
if (srcLayout != dstLayout)
{
// Transition a single subresource

View File

@@ -182,8 +182,8 @@ void MultiScaler::Filter(const FilterMode mode, GPUContext* context, const int32
// Prepare
Data data;
data.TexelSize.X = 1.0f / width;
data.TexelSize.Y = 1.0f / height;
data.TexelSize.X = 1.0f / (float)width;
data.TexelSize.Y = 1.0f / (float)height;
auto cb = _shader->GetShader()->GetCB(0);
context->UpdateCB(cb, &data);
context->BindCB(0, cb);
@@ -219,8 +219,8 @@ void MultiScaler::DownscaleDepth(GPUContext* context, int32 dstWidth, int32 dstH
// Prepare
Data data;
data.TexelSize.X = 2.0f / dstWidth;
data.TexelSize.Y = 2.0f / dstHeight;
data.TexelSize.X = 2.0f / (float)dstWidth;
data.TexelSize.Y = 2.0f / (float)dstHeight;
auto cb = _shader->GetShader()->GetCB(0);
context->UpdateCB(cb, &data);
context->BindCB(0, cb);