Add warnings on incorrect GPUBuffer or GPUTexture usage when binding to GPUContext (in non-release builds)
This commit is contained in:
@@ -13,6 +13,7 @@ void GPUBufferViewVulkan::Init(GPUDeviceVulkan* device, GPUBufferVulkan* owner,
|
||||
{
|
||||
ASSERT(View == VK_NULL_HANDLE);
|
||||
|
||||
_parent = owner;
|
||||
Device = device;
|
||||
Owner = owner;
|
||||
Buffer = buffer;
|
||||
|
||||
@@ -46,6 +46,10 @@ public:
|
||||
void DescriptorAsUniformTexelBuffer(GPUContextVulkan* context, VkBufferView& bufferView) override;
|
||||
void DescriptorAsStorageBuffer(GPUContextVulkan* context, VkBuffer& buffer, VkDeviceSize& offset, VkDeviceSize& range) override;
|
||||
void DescriptorAsStorageTexelBuffer(GPUContextVulkan* context, VkBufferView& bufferView) override;
|
||||
#if !BUILD_RELEASE
|
||||
bool HasSRV() const override { return ((GPUBuffer*)_parent)->IsShaderResource(); }
|
||||
bool HasUAV() const override { return ((GPUBuffer*)_parent)->IsUnorderedAccess(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1001,7 +1001,11 @@ void GPUContextVulkan::BindCB(int32 slot, GPUConstantBuffer* cb)
|
||||
|
||||
void GPUContextVulkan::BindSR(int32 slot, GPUResourceView* view)
|
||||
{
|
||||
#if !BUILD_RELEASE
|
||||
ASSERT(slot >= 0 && slot < GPU_MAX_SR_BINDED);
|
||||
if (view && ((DescriptorOwnerResourceVulkan*)view->GetNativePtr())->HasSRV() == false)
|
||||
LogInvalidResourceUsage(slot, view, InvalidBindPoint::SRV);
|
||||
#endif
|
||||
const auto handle = view ? (DescriptorOwnerResourceVulkan*)view->GetNativePtr() : nullptr;
|
||||
if (_srHandles[slot] != handle)
|
||||
{
|
||||
@@ -1013,7 +1017,11 @@ void GPUContextVulkan::BindSR(int32 slot, GPUResourceView* view)
|
||||
|
||||
void GPUContextVulkan::BindUA(int32 slot, GPUResourceView* view)
|
||||
{
|
||||
#if !BUILD_RELEASE
|
||||
ASSERT(slot >= 0 && slot < GPU_MAX_UA_BINDED);
|
||||
if (view && ((DescriptorOwnerResourceVulkan*)view->GetNativePtr())->HasUAV() == false)
|
||||
LogInvalidResourceUsage(slot, view, InvalidBindPoint::UAV);
|
||||
#endif
|
||||
const auto handle = view ? (DescriptorOwnerResourceVulkan*)view->GetNativePtr() : nullptr;
|
||||
if (_uaHandles[slot] != handle)
|
||||
{
|
||||
|
||||
@@ -722,6 +722,12 @@ public:
|
||||
{
|
||||
CRASH;
|
||||
}
|
||||
|
||||
#if !BUILD_RELEASE
|
||||
// Utilities for incorrect resource usage.
|
||||
virtual bool HasSRV() const { return false; }
|
||||
virtual bool HasUAV() const { return false; }
|
||||
#endif
|
||||
};
|
||||
|
||||
extern GPUDevice* CreateGPUDeviceVulkan();
|
||||
|
||||
@@ -77,6 +77,10 @@ public:
|
||||
// [DescriptorOwnerResourceVulkan]
|
||||
void DescriptorAsImage(GPUContextVulkan* context, VkImageView& imageView, VkImageLayout& layout) override;
|
||||
void DescriptorAsStorageImage(GPUContextVulkan* context, VkImageView& imageView, VkImageLayout& layout) override;
|
||||
#if !BUILD_RELEASE
|
||||
bool HasSRV() const override { return ((GPUTexture*)_parent)->IsShaderResource(); }
|
||||
bool HasUAV() const override { return ((GPUTexture*)_parent)->IsUnorderedAccess(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user