diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-10-07 16:19:35 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-10-07 16:19:35 +0000 |
| commit | 42b12901274c2aabee3ddbb9d3a012d28e5f5f7d (patch) | |
| tree | 8f78dfa0d2ace8192d07671da8676498c3623ded /Graphics/GraphicsEngineD3D11 | |
| parent | Fixed JNI object reference leak in AndroidFileSystem (diff) | |
| download | DiligentCore-42b12901274c2aabee3ddbb9d3a012d28e5f5f7d.tar.gz DiligentCore-42b12901274c2aabee3ddbb9d3a012d28e5f5f7d.zip | |
Completely reworked shader resource binding implementation in OpenGL backend to make it function similar to other backends
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
4 files changed, 16 insertions, 15 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h index 24274c8f..40b0cd76 100755 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceCacheD3D11.h @@ -57,7 +57,7 @@ public: ShaderResourceCacheD3D11 (ShaderResourceCacheD3D11&&) = delete;
ShaderResourceCacheD3D11& operator = (ShaderResourceCacheD3D11&&) = delete;
- /// Describes resources associated with the cached constant buffer
+ /// Describes a resource associated with a cached constant buffer
struct CachedCB
{
/// Strong reference to the buffer
@@ -68,7 +68,7 @@ public: }
};
- /// Describes resources associated with the cached sampler
+ /// Describes a resource associated with a cached sampler
struct CachedSampler
{
/// Strong reference to the sampler
@@ -79,7 +79,7 @@ public: }
};
- /// Describes resources associated with the cached SRV or UAV
+ /// Describes a resource associated with a cached SRV or a UAV
struct CachedResource
{
/// Wee keep strong reference to the view instead of the reference
@@ -305,13 +305,13 @@ private: d3d11ResArr[Slot] = pd3d11Resource;
}
- static constexpr Uint8 InvalidResourceOffset = 0xFF;
+ static constexpr const Uint16 InvalidResourceOffset = 0xFFFF;
// Resource limits in D3D11:
// Max CB count: 14
// Max SRV count: 128
// Max Sampler count: 16
// Max UAV count: 8
- static constexpr const Uint8 m_CBOffset = 0;
+ static constexpr const Uint16 m_CBOffset = 0;
Uint16 m_SRVOffset = InvalidResourceOffset;
Uint16 m_SamplerOffset = InvalidResourceOffset;
Uint16 m_UAVOffset = InvalidResourceOffset;
diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h index 48aaf8f8..beb4357d 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h @@ -306,7 +306,7 @@ private: template<typename ResourceType> ResourceType& GetResource(Uint32 ResIndex) { - VERIFY(ResIndex < GetNumResources<ResourceType>(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources<ResourceType>(), ")"); + VERIFY(ResIndex < GetNumResources<ResourceType>(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources<ResourceType>()-1, ")"); auto Offset = GetResourceOffset<ResourceType>(); return reinterpret_cast<ResourceType*>( reinterpret_cast<Uint8*>(m_ResourceBuffer.get()) + Offset)[ResIndex]; } @@ -314,7 +314,7 @@ private: template<typename ResourceType> const ResourceType& GetConstResource(Uint32 ResIndex)const { - VERIFY(ResIndex < GetNumResources<ResourceType>(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources<ResourceType>(), ")"); + VERIFY(ResIndex < GetNumResources<ResourceType>(), "Resource index (", ResIndex, ") exceeds max allowed value (", GetNumResources<ResourceType>()-1, ")"); auto Offset = GetResourceOffset<ResourceType>(); return reinterpret_cast<const ResourceType*>( reinterpret_cast<const Uint8*>(m_ResourceBuffer.get()) + Offset)[ResIndex]; } diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp index 2be5a719..68092405 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceCacheD3D11.cpp @@ -191,6 +191,7 @@ namespace Diligent if (m_pResourceData != nullptr)
MemAllocator.Free(m_pResourceData);
+ m_pResourceData = nullptr;
}
}
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp index b4843e56..c7ac7af2 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp @@ -116,12 +116,12 @@ ShaderResourceLayoutD3D11::ShaderResourceLayoutD3D11(IObject& // Initialize offsets
size_t CurrentOffset = 0;
- auto AdvanceOffset = [&CurrentOffset](size_t NumResources)
+ auto AdvanceOffset = [&CurrentOffset](size_t NumBytes)
{
constexpr size_t MaxOffset = std::numeric_limits<OffsetType>::max();
VERIFY(CurrentOffset <= MaxOffset, "Current offser (", CurrentOffset, ") exceeds max allowed value (", MaxOffset, ")");
auto Offset = static_cast<OffsetType>(CurrentOffset);
- CurrentOffset += NumResources;
+ CurrentOffset += NumBytes;
return Offset;
};
@@ -409,7 +409,7 @@ do{ void ShaderResourceLayoutD3D11::ConstBuffBindInfo::BindResource(IDeviceObject* pBuffer,
Uint32 ArrayIndex)
{
- DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount-1);
auto& ResourceCache = m_ParentResLayout.m_ResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -472,7 +472,7 @@ bool dbgVerifyViewType( const char* ViewTypeName, void ShaderResourceLayoutD3D11::TexSRVBindInfo::BindResource(IDeviceObject* pView,
Uint32 ArrayIndex)
{
- DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount-1);
auto& ResourceCache = m_ParentResLayout.m_ResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -536,7 +536,7 @@ void ShaderResourceLayoutD3D11::TexSRVBindInfo::BindResource(IDeviceObject* pVie void ShaderResourceLayoutD3D11::SamplerBindInfo::BindResource(IDeviceObject* pSampler,
Uint32 ArrayIndex)
{
- DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount-1);
auto& ResourceCache = m_ParentResLayout.m_ResourceCache;
//VERIFY(!IsStaticSampler, "Cannot bind sampler to a static sampler");
@@ -571,7 +571,7 @@ void ShaderResourceLayoutD3D11::SamplerBindInfo::BindResource(IDeviceObject* pSa void ShaderResourceLayoutD3D11::BuffSRVBindInfo::BindResource(IDeviceObject* pView,
Uint32 ArrayIndex)
{
- DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount-1);
auto& ResourceCache = m_ParentResLayout.m_ResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -601,7 +601,7 @@ void ShaderResourceLayoutD3D11::BuffSRVBindInfo::BindResource(IDeviceObject* pVi void ShaderResourceLayoutD3D11::TexUAVBindInfo::BindResource(IDeviceObject* pView,
Uint32 ArrayIndex)
{
- DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount-1);
auto& ResourceCache = m_ParentResLayout.m_ResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
@@ -631,7 +631,7 @@ void ShaderResourceLayoutD3D11::TexUAVBindInfo::BindResource(IDeviceObject* pVie void ShaderResourceLayoutD3D11::BuffUAVBindInfo::BindResource(IDeviceObject* pView,
Uint32 ArrayIndex)
{
- DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount);
+ DEV_CHECK_ERR(ArrayIndex < m_Attribs.BindCount, "Array index (", ArrayIndex, ") is out of range for variable '", m_Attribs.Name, "'. Max allowed index: ", m_Attribs.BindCount-1);
auto& ResourceCache = m_ParentResLayout.m_ResourceCache;
// We cannot use ValidatedCast<> here as the resource retrieved from the
|
