From 8e24a0919d30f939140e776bc5e64bd77767e99c Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 12 Nov 2017 18:54:50 -0800 Subject: Updated to Diligent Engine 2.1 --- .../include/D3DShaderResourceLoader.h | 4 +-- .../include/D3DTypeConversionImpl.h | 34 +++++++++++++++++++++- .../include/D3DViewDescConversionImpl.h | 4 +-- .../include/DXGITypeConversions.h | 1 + .../include/RenderDeviceD3DBase.h | 5 ++-- .../src/DXGITypeConversions.cpp | 34 ++++++++++++++++++++++ .../GraphicsEngineD3DBase/src/ShaderD3DBase.cpp | 6 ++-- 7 files changed, 79 insertions(+), 9 deletions(-) (limited to 'Graphics/GraphicsEngineD3DBase') diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h index b21d4692..16e1022b 100644 --- a/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h +++ b/Graphics/GraphicsEngineD3DBase/include/D3DShaderResourceLoader.h @@ -172,7 +172,7 @@ namespace Diligent case D3D_SIT_TEXTURE: ++(BindingDesc.Dimension == D3D_SRV_DIMENSION_BUFFER ? NumBufSRVs : NumTexSRVs); break; case D3D_SIT_SAMPLER: ++NumSamplers; break; case D3D_SIT_UAV_RWTYPED: ++(BindingDesc.Dimension == D3D_SRV_DIMENSION_BUFFER ? NumBufUAVs : NumTexUAVs); break; - case D3D_SIT_STRUCTURED: UNSUPPORTED( "Structured buffers are not supported" ); break; + case D3D_SIT_STRUCTURED: ++NumBufSRVs; break; case D3D_SIT_UAV_RWSTRUCTURED: ++NumBufUAVs; break; case D3D_SIT_BYTEADDRESS: UNSUPPORTED( "Byte address buffers are not supported" ); break; case D3D_SIT_UAV_RWBYTEADDRESS: ++NumBufUAVs; break; @@ -284,7 +284,7 @@ namespace Diligent case D3D_SIT_STRUCTURED: { - UNSUPPORTED( "Structured buffers are not supported" ); + OnNewBuffSRV( std::move(Res) ); break; } diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h b/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h index b855019a..db5beda7 100644 --- a/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h +++ b/Graphics/GraphicsEngineD3DBase/include/D3DTypeConversionImpl.h @@ -78,7 +78,39 @@ namespace Diligent d3dPrimTopology[PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; d3dPrimTopology[PRIMITIVE_TOPOLOGY_POINT_LIST] = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; d3dPrimTopology[PRIMITIVE_TOPOLOGY_LINE_LIST] = D3D_PRIMITIVE_TOPOLOGY_LINELIST; - + d3dPrimTopology[PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST; + d3dPrimTopology[PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST] = D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST; + bIsInit = true; } diff --git a/Graphics/GraphicsEngineD3DBase/include/D3DViewDescConversionImpl.h b/Graphics/GraphicsEngineD3DBase/include/D3DViewDescConversionImpl.h index ef7a2b3a..6f570db0 100644 --- a/Graphics/GraphicsEngineD3DBase/include/D3DViewDescConversionImpl.h +++ b/Graphics/GraphicsEngineD3DBase/include/D3DViewDescConversionImpl.h @@ -285,7 +285,7 @@ namespace Diligent memset( &d3dSRVDesc, 0, sizeof( d3dSRVDesc ) ); const auto &BuffFmt = BuffDesc.Format; - if( BuffDesc.Mode == BUFFER_MODE_FORMATED ) + if( BuffDesc.Mode == BUFFER_MODE_FORMATTED ) d3dSRVDesc.Format = TypeToDXGI_Format( BuffFmt.ValueType, BuffFmt.NumComponents, BuffFmt.IsNormalized ); VERIFY( SRVDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Incorrect view type: shader resource is expected" ); @@ -306,7 +306,7 @@ namespace Diligent memset( &d3dUAVDesc, 0, sizeof(d3dUAVDesc) ); const auto &BuffFmt = BuffDesc.Format; - if( BuffDesc.Mode == BUFFER_MODE_FORMATED ) + if( BuffDesc.Mode == BUFFER_MODE_FORMATTED ) d3dUAVDesc.Format = TypeToDXGI_Format( BuffFmt.ValueType, BuffFmt.NumComponents, BuffFmt.IsNormalized ); VERIFY( UAVDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Incorrect view type: unordered access is expected" ); diff --git a/Graphics/GraphicsEngineD3DBase/include/DXGITypeConversions.h b/Graphics/GraphicsEngineD3DBase/include/DXGITypeConversions.h index c705ca13..2d2dbef1 100644 --- a/Graphics/GraphicsEngineD3DBase/include/DXGITypeConversions.h +++ b/Graphics/GraphicsEngineD3DBase/include/DXGITypeConversions.h @@ -32,6 +32,7 @@ namespace Diligent { DXGI_FORMAT TexFormatToDXGI_Format(TEXTURE_FORMAT TexFormat, Uint32 BindFlags = 0); + TEXTURE_FORMAT DXGI_FormatToTexFormat(DXGI_FORMAT DXGIFormat); DXGI_FORMAT TypeToDXGI_Format(VALUE_TYPE ValType, Uint32 NumComponents, Bool bIsNormalized); } diff --git a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h index 25028925..3186eedd 100644 --- a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h +++ b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h @@ -37,7 +37,8 @@ template class RenderDeviceD3DBase : public RenderDeviceBase { public: - RenderDeviceD3DBase(IMemoryAllocator &RawMemAllocator, + RenderDeviceD3DBase(IReferenceCounters *pRefCounters, + IMemoryAllocator &RawMemAllocator, Uint32 NumDeferredContexts, size_t TextureObjSize, size_t TexViewObjSize, @@ -47,7 +48,7 @@ public: size_t SamplerObjSize, size_t PSOSize, size_t SRBSize) : - RenderDeviceBase(RawMemAllocator, NumDeferredContexts, TextureObjSize, TexViewObjSize, BufferObjSize, BuffViewObjSize, ShaderObjSize, SamplerObjSize, PSOSize, SRBSize) + RenderDeviceBase(pRefCounters, RawMemAllocator, NumDeferredContexts, TextureObjSize, TexViewObjSize, BufferObjSize, BuffViewObjSize, ShaderObjSize, SamplerObjSize, PSOSize, SRBSize) { // Flag texture formats always supported in D3D11 and D3D12 diff --git a/Graphics/GraphicsEngineD3DBase/src/DXGITypeConversions.cpp b/Graphics/GraphicsEngineD3DBase/src/DXGITypeConversions.cpp index 29087ed6..20f24dac 100644 --- a/Graphics/GraphicsEngineD3DBase/src/DXGITypeConversions.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/DXGITypeConversions.cpp @@ -403,4 +403,38 @@ DXGI_FORMAT TexFormatToDXGI_Format(TEXTURE_FORMAT TexFormat, Uint32 BindFlags) } } +class DXGIFmtToFmtMapInitializer +{ +public: + DXGIFmtToFmtMapInitializer(TEXTURE_FORMAT DXGIFmtToFmtMap[]) + { + for (TEXTURE_FORMAT fmt = TEX_FORMAT_UNKNOWN; fmt < TEX_FORMAT_NUM_FORMATS; fmt = static_cast(fmt +1)) + { + auto DXGIFmt = TexFormatToDXGI_Format(fmt); + VERIFY_EXPR(DXGIFmt <= DXGI_FORMAT_B4G4R4A4_UNORM); + DXGIFmtToFmtMap[DXGIFmt] = fmt; + } + } +}; + +TEXTURE_FORMAT DXGI_FormatToTexFormat(DXGI_FORMAT DXGIFormat) +{ + static_assert(DXGI_FORMAT_B4G4R4A4_UNORM == 115, "Unexpected DXGI format value"); + static TEXTURE_FORMAT DXGIFmtToFmtMap[DXGI_FORMAT_B4G4R4A4_UNORM+1]; + static DXGIFmtToFmtMapInitializer Initializer(DXGIFmtToFmtMap); + + if( DXGIFormat >= DXGI_FORMAT_UNKNOWN && DXGIFormat <= DXGI_FORMAT_BC7_UNORM_SRGB ) + { + auto Format = DXGIFmtToFmtMap[DXGIFormat]; + VERIFY( DXGIFormat == DXGI_FORMAT_UNKNOWN || Format != TEX_FORMAT_UNKNOWN, "Unsupported texture format" ); + VERIFY_EXPR(DXGIFormat == TexFormatToDXGI_Format(Format)); + return Format; + } + else + { + UNEXPECTED( "DXGI texture format (", DXGIFormat, ") is out of allowed range [0, ", DXGI_FORMAT_BC7_UNORM_SRGB, "]" ); + return TEX_FORMAT_UNKNOWN; + } +} + } diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp index bf975a22..a637b6eb 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp @@ -57,7 +57,7 @@ public: return E_FAIL; } - RefCntAutoPtr pFileData( new Diligent::DataBlobImpl ); + RefCntAutoPtr pFileData( MakeNewRCObj()(0) ); pSourceStream->Read( pFileData ); *ppData = pFileData->GetDataPtr(); *pBytes = static_cast( pFileData->GetSize() ); @@ -171,7 +171,9 @@ ShaderD3DBase::ShaderD3DBase(const ShaderCreationAttribs &CreationAttribs) VERIFY(CreationAttribs.FilePath, "File path is null. Either shader source or source file path must be specified."); RefCntAutoPtr pSourceStream; CreationAttribs.pShaderSourceStreamFactory->CreateInputStream( CreationAttribs.FilePath, &pSourceStream ); - RefCntAutoPtr pFileData( new Diligent::DataBlobImpl ); + RefCntAutoPtr pFileData( MakeNewRCObj()(0) ); + if (pSourceStream == nullptr) + LOG_ERROR_AND_THROW("Failed to open shader source file") pSourceStream->Read( pFileData ); // Null terminator is not read from the stream! auto* FileDataPtr = reinterpret_cast( pFileData->GetDataPtr() ); -- cgit v1.2.3