From bc034568a62b12a813c0f7445cd85d00fdeda390 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 4 Dec 2018 20:28:04 -0800 Subject: Added ITextureD3D12::GetD3D12ResourceState(), IBufferD3D12::GetD3D12ResourceState(), and IBufferVk::GetAccessFlags() methods --- Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h | 2 ++ Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h | 2 ++ Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h | 5 +++++ Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h | 5 +++++ Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp | 5 +++++ Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp | 4 ++-- Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp | 5 +++++ 7 files changed, 26 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h index 6d187b53..7dfe70d3 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h @@ -77,6 +77,8 @@ public: virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state)override final; + virtual D3D12_RESOURCE_STATES GetD3D12ResourceState()const override final; + D3D12_GPU_VIRTUAL_ADDRESS GetGPUAddress(class DeviceContextD3D12Impl* pCtx); D3D12_CPU_DESCRIPTOR_HANDLE GetCBVHandle(){return m_CBVDescriptorAllocation.GetCpuHandle();} diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h index ba1c94c5..d1bf9ec6 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h @@ -68,6 +68,8 @@ public: virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state)override final; + virtual D3D12_RESOURCE_STATES GetD3D12ResourceState()const override final; + D3D12_CPU_DESCRIPTOR_HANDLE GetMipLevelUAV(Uint32 Mip) { return m_MipUAVs.GetCpuHandle(Mip); diff --git a/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h b/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h index cd33e740..71880f38 100644 --- a/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h @@ -57,6 +57,11 @@ public: /// \param [in] state - D3D12 resource state to be set for this buffer virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state) = 0; + + /// Returns current D3D12 buffer state. + /// If the state is unknown to the engine (Diligent::RESOURCE_STATE_UNKNOWN), + /// returns D3D12_RESOURCE_STATE_COMMON (0). + virtual D3D12_RESOURCE_STATES GetD3D12ResourceState()const = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h b/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h index cb3b5dfa..611ac528 100644 --- a/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h @@ -50,6 +50,11 @@ public: /// \param [in] state - D3D12 resource state to be set for this texture virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state) = 0; + + /// Returns current D3D12 texture state. + /// If the state is unknown to the engine (Diligent::RESOURCE_STATE_UNKNOWN), + /// returns D3D12_RESOURCE_STATE_COMMON (0). + virtual D3D12_RESOURCE_STATES GetD3D12ResourceState()const = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp index af521f11..e59ac73a 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp @@ -420,4 +420,9 @@ void BufferD3D12Impl::SetD3D12ResourceState(D3D12_RESOURCE_STATES state) SetState(D3D12ResourceStatesToResourceStateFlags(state)); } +D3D12_RESOURCE_STATES BufferD3D12Impl::GetD3D12ResourceState()const +{ + return ResourceStateFlagsToD3D12ResourceStates(GetState()); +} + } diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp index 0f1c2867..e90f5a72 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp @@ -363,7 +363,7 @@ D3D12_RESOURCE_STATES ResourceStateFlagsToD3D12ResourceStates(RESOURCE_STATE Sta { VERIFY(StateFlags < (RESOURCE_STATE_MAX_BIT<<1), "Resource state flags are out of range"); static const StateFlagBitPosToD3D12ResourceState BitPosToD3D12ResState; - Uint32 D3D12ResourceStates = 0; + D3D12_RESOURCE_STATES D3D12ResourceStates = static_cast(0); Uint32 Bits = StateFlags; while(Bits != 0) { @@ -371,7 +371,7 @@ D3D12_RESOURCE_STATES ResourceStateFlagsToD3D12ResourceStates(RESOURCE_STATE Sta D3D12ResourceStates |= BitPosToD3D12ResState(lsb); Bits &= ~(1<(D3D12ResourceStates); + return D3D12ResourceStates; } diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp index 173049cc..71e6be01 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp @@ -488,4 +488,9 @@ void TextureD3D12Impl::SetD3D12ResourceState(D3D12_RESOURCE_STATES state) SetState(D3D12ResourceStatesToResourceStateFlags(state)); } +D3D12_RESOURCE_STATES TextureD3D12Impl::GetD3D12ResourceState()const +{ + return ResourceStateFlagsToD3D12ResourceStates(GetState()); +} + } -- cgit v1.2.3