git.s-ol.nu forks/DiligentCore / 2a0f9a6
Fixed class vs struct issues. Implemented HLSL2GLSL Convertor C interfaces assiduous 3 years ago
28 changed file(s) with 115 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
3636
3737 namespace Diligent
3838 {
39
40 class IRenderDevice;
41 class IBuffer;
4239
4340 /// Template class implementing base functionality for a buffer view object
4441
3636 namespace Diligent
3737 {
3838
39 class IRenderDevice;
40 class IFence;
41
4239 /// Template class implementing base functionality for a Fence object
4340
4441 /// \tparam BaseInterface - base interface that this class will inheret
3737 namespace Diligent
3838 {
3939
40 class IDeviceContext;
41
4240 /// Template class implementing base functionality for a Query object
4341
4442 /// \tparam BaseInterface - base interface that this class will inheret
6262 TextureViewBase(IReferenceCounters* pRefCounters,
6363 RenderDeviceImplType* pDevice,
6464 const TextureViewDesc& ViewDesc,
65 class ITexture* pTexture,
65 ITexture* pTexture,
6666 bool bIsDefaultView) :
6767 // Default views are created as part of the texture, so we cannot not keep strong
6868 // reference to the texture to avoid cyclic links. Instead, we will attach to the
7676 IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_TextureView, TDeviceObjectBase)
7777
7878 /// Implementation of ITextureView::SetSampler()
79 virtual void SetSampler(class ISampler* pSampler) override final
79 virtual void SetSampler(ISampler* pSampler) override final
8080 {
8181 #ifdef DEVELOPMENT
8282 if (this->m_Desc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE)
4848 BufferViewD3D11Impl(IReferenceCounters* pRefCounters,
4949 RenderDeviceD3D11Impl* pDevice,
5050 const BufferViewDesc& ViewDesc,
51 class IBuffer* pBuffer,
51 IBuffer* pBuffer,
5252 ID3D11View* pD3D11View,
5353 bool bIsDefaultView);
5454
2929 /// \file
3030 /// Declaration of Diligent::ShaderResourceCacheD3D11 class
3131
32 #include "MemoryAllocator.h"
3233 #include "TextureBaseD3D11.hpp"
3334 #include "BufferD3D11Impl.hpp"
3435 #include "SamplerD3D11Impl.hpp"
125126
126127 static size_t GetRequriedMemorySize(const class ShaderResourcesD3D11& Resources);
127128
128 void Initialize(const class ShaderResourcesD3D11& Resources, class IMemoryAllocator& MemAllocator);
129 void Initialize(Uint32 CBCount, Uint32 SRVCount, Uint32 SamplerCount, Uint32 UAVCount, class IMemoryAllocator& MemAllocator);
130 void Destroy(class IMemoryAllocator& MemAllocator);
129 void Initialize(const class ShaderResourcesD3D11& Resources, IMemoryAllocator& MemAllocator);
130 void Initialize(Uint32 CBCount, Uint32 SRVCount, Uint32 SamplerCount, Uint32 UAVCount, IMemoryAllocator& MemAllocator);
131 void Destroy(IMemoryAllocator& MemAllocator);
131132
132133
133134 __forceinline void SetCB(Uint32 Slot, RefCntAutoPtr<BufferD3D11Impl>&& pBuffD3D11Impl)
4040 namespace Diligent
4141 {
4242
43 class IMemoryAllocator;
44
4543 /// Diligent::ShaderResourceLayoutD3D11 class
4644 /// http://diligentgraphics.com/diligent-engine/architecture/d3d11/shader-resource-layout/
4745 // sizeof(ShaderResourceLayoutD3D11) == 64 (x64)
3434
3535 namespace Diligent
3636 {
37
38 class IMemoryAllocator;
3937
4038 /// Swap chain implementation in Direct3D11 backend.
4139 class SwapChainD3D11Impl final : public SwapChainD3DBase<ISwapChainD3D11, IDXGISwapChain>
4848 TextureViewD3D11Impl(IReferenceCounters* pRefCounters,
4949 RenderDeviceD3D11Impl* pDevice,
5050 const TextureViewDesc& ViewDesc,
51 class ITexture* pTexture,
51 ITexture* pTexture,
5252 ID3D11View* pD3D11View,
5353 bool bIsDefaultView);
5454
4949 BufferViewD3D12Impl(IReferenceCounters* pRefCounters,
5050 RenderDeviceD3D12Impl* pDevice,
5151 const BufferViewDesc& ViewDesc,
52 class IBuffer* pBuffer,
52 IBuffer* pBuffer,
5353 DescriptorHeapAllocation&& HandleAlloc,
5454 bool bIsDefaultView);
5555
3535
3636 namespace Diligent
3737 {
38
39 class ITextureViewD3D12;
40 class IMemoryAllocator;
4138
4239 /// Swap chain implementation in Direct3D12 backend.
4340 class SwapChainD3D12Impl final : public SwapChainD3DBase<ISwapChainD3D12, IDXGISwapChain3>
4949 TextureViewD3D12Impl(IReferenceCounters* pRefCounters,
5050 RenderDeviceD3D12Impl* pDevice,
5151 const TextureViewDesc& ViewDesc,
52 class ITexture* pTexture,
52 ITexture* pTexture,
5353 DescriptorHeapAllocation&& Descriptor,
5454 DescriptorHeapAllocation&& TexArraySRVDescriptor,
5555 DescriptorHeapAllocation&& MipLevelUAVDescriptors,
3030 /// Definition of the Diligent::IBufferD3D12 interface
3131
3232 #include "../../GraphicsEngine/interface/Buffer.h"
33 #include "../../GraphicsEngine/interface/DeviceContext.h"
3334
3435 namespace Diligent
3536 {
36
37 class IDeviceContext;
3837
3938 // {3E9B15ED-A289-48DC-8214-C6E3E6177378}
4039 static constexpr INTERFACE_ID IID_BufferD3D12 =
8484 virtual void* GetNativeHandle() override final { return reinterpret_cast<void*>(static_cast<size_t>(GetGLBufferHandle())); }
8585
8686 private:
87 virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, class IBufferView** ppView, bool bIsDefaultView) override;
87 virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, IBufferView** ppView, bool bIsDefaultView) override;
8888
8989 friend class DeviceContextGLImpl;
9090 friend class VAOCache;
3636 namespace Diligent
3737 {
3838
39 class FixedBlockMemoryAllocator;
40 class IRenderDevice;
41 class IDeviceContext;
42 class BufferGLImpl;
43 struct BufferViewDesc;
44
4539 /// Buffer view implementation in OpenGL backend.
4640 class BufferViewGLImpl final : public BufferViewBase<IBufferViewGL, RenderDeviceGLImpl>
4741 {
7676 namespace Diligent
7777 {
7878
79 class IMemoryAllocator;
80
8179 class GLPipelineResourceLayout
8280 {
8381 public:
114114
115115 static size_t GetRequriedMemorySize(Uint32 UBCount, Uint32 SamplerCount, Uint32 ImageCount, Uint32 SSBOCount);
116116
117 void Initialize(Uint32 UBCount, Uint32 SamplerCount, Uint32 ImageCount, Uint32 SSBOCount, class IMemoryAllocator& MemAllocator);
118 void Destroy(class IMemoryAllocator& MemAllocator);
117 void Initialize(Uint32 UBCount, Uint32 SamplerCount, Uint32 ImageCount, Uint32 SSBOCount, IMemoryAllocator& MemAllocator);
118 void Destroy(IMemoryAllocator& MemAllocator);
119119
120120 void SetUniformBuffer(Uint32 Binding, RefCntAutoPtr<BufferGLImpl>&& pBuff)
121121 {
3131
3232 namespace Diligent
3333 {
34
35 class IMemoryAllocator;
3634
3735 /// Base implementation of a swap chain for OpenGL.
3836 template <class BaseInterface>
3333 namespace Diligent
3434 {
3535
36 class IMemoryAllocator;
37
3836 /// Swap chain implementation in OpenGL backend.
3937 class SwapChainGLImpl final : public SwapChainGLBase<ISwapChainGL>
4038 {
122122
123123 protected:
124124 virtual void CreateViewInternal(const struct TextureViewDesc& ViewDesc,
125 class ITextureView** ppView,
125 ITextureView** ppView,
126126 bool bIsDefaultView) override;
127127
128128 void SetDefaultGLParameters();
364364 #endif
365365 }
366366
367 void BufferGLImpl::CreateViewInternal(const BufferViewDesc& OrigViewDesc, class IBufferView** ppView, bool bIsDefaultView)
367 void BufferGLImpl::CreateViewInternal(const BufferViewDesc& OrigViewDesc, IBufferView** ppView, bool bIsDefaultView)
368368 {
369369 VERIFY(ppView != nullptr, "Buffer view pointer address is null");
370370 if (!ppView) return;
4242 return MemSize;
4343 }
4444
45 void GLProgramResourceCache::Initialize(Uint32 UBCount, Uint32 SamplerCount, Uint32 ImageCount, Uint32 SSBOCount, class IMemoryAllocator& MemAllocator)
45 void GLProgramResourceCache::Initialize(Uint32 UBCount, Uint32 SamplerCount, Uint32 ImageCount, Uint32 SSBOCount, IMemoryAllocator& MemAllocator)
4646 {
4747 // clang-format off
4848 m_SmplrsOffset = static_cast<Uint16>(m_UBsOffset + sizeof(CachedUB) * UBCount);
8989 VERIFY(!IsInitialized(), "Shader resource cache memory must be released with GLProgramResourceCache::Destroy()");
9090 }
9191
92 void GLProgramResourceCache::Destroy(class IMemoryAllocator& MemAllocator)
92 void GLProgramResourceCache::Destroy(IMemoryAllocator& MemAllocator)
9393 {
9494 VERIFY(IsInitialized(), "Resource cache is not initialized");
9595 VERIFY(m_pdbgMemoryAllocator == &MemAllocator, "The allocator does not match the one used to create resources");
282282 IMPLEMENT_QUERY_INTERFACE(TextureBaseGL, IID_TextureGL, TTextureBase)
283283
284284
285 void TextureBaseGL::CreateViewInternal(const struct TextureViewDesc& OrigViewDesc, class ITextureView** ppView, bool bIsDefaultView)
285 void TextureBaseGL::CreateViewInternal(const struct TextureViewDesc& OrigViewDesc, ITextureView** ppView, bool bIsDefaultView)
286286 {
287287 VERIFY(ppView != nullptr, "Null pointer provided");
288288 if (!ppView) return;
5050 BufferViewVkImpl(IReferenceCounters* pRefCounters,
5151 RenderDeviceVkImpl* pDevice,
5252 const BufferViewDesc& ViewDesc,
53 class IBuffer* pBuffer,
53 IBuffer* pBuffer,
5454 VulkanUtilities::BufferViewWrapper&& BuffView,
5555 bool bIsDefaultView);
5656 ~BufferViewVkImpl();
3737
3838 namespace Diligent
3939 {
40
41 class ITextureViewVk;
42 class IMemoryAllocator;
4340
4441 /// Swap chain implementation in Vulkan backend.
4542 class SwapChainVkImpl final : public SwapChainBase<ISwapChainVk>
4949 TextureViewVkImpl(IReferenceCounters* pRefCounters,
5050 RenderDeviceVkImpl* pDevice,
5151 const TextureViewDesc& ViewDesc,
52 class ITexture* pTexture,
52 ITexture* pTexture,
5353 VulkanUtilities::ImageViewWrapper&& ImgView,
5454 bool bIsDefaultView);
5555 ~TextureViewVkImpl();
3838 static constexpr INTERFACE_ID IID_HLSL2GLSLConversionStream =
3939 {0x1fde020a, 0x9c73, 0x4a76, {0x8a, 0xef, 0xc2, 0xc6, 0xc2, 0xcf, 0xe, 0xa5}};
4040
41 #if DILIGENT_CPP_INTERFACE
4241
43 class IHLSL2GLSLConversionStream : public IObject
42 #define DILIGENT_INTERFACE_NAME IHLSL2GLSLConversionStream
43 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
44
45 // clang-format off
46
47 DILIGENT_INTERFACE(IHLSL2GLSLConversionStream, IObject)
4448 {
45 public:
46 virtual void Convert(const Char* EntryPoint,
47 SHADER_TYPE ShaderType,
48 bool IncludeDefintions,
49 const char* SamplerSuffix,
50 bool UseInOutLocationQualifiers,
51 IDataBlob** ppGLSLSource) = 0;
49 VIRTUAL void METHOD(Convert)(THIS_
50 const Char* EntryPoint,
51 SHADER_TYPE ShaderType,
52 bool IncludeDefintions,
53 const char* SamplerSuffix,
54 bool UseInOutLocationQualifiers,
55 IDataBlob** ppGLSLSource) PURE;
5256 };
5357
54 #else
58 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
59
60 #if DILIGENT_C_INTERFACE
61
62 // clang-format on
63
64 struct IHLSL2GLSLConversionStreamVtbl
65 {
66 struct IObjectMethods Object;
67 struct IHLSL2GLSLConversionStreamMethods HLSL2GLSLConversionStream;
68 };
69
70 typedef struct IHLSL2GLSLConversionStream
71 {
72 struct IHLSL2GLSLConversionStreamVtbl* pVtbl;
73 } IHLSL2GLSLConversionStream;
74
75 // clang-format off
76
77 # define IHLSL2GLSLConversionStream_Convert(This) (This)->pVtbl->HLSL2GLSLConversionStream.Convert((IHLSL2GLSLConversionStream*)(This), __VA_ARGS__)
78
79 // clang-format on
5580
5681 #endif
5782
6085 static constexpr INTERFACE_ID IID_HLSL2GLSLConverter =
6186 {0x44a21160, 0x77e0, 0x4ddc, {0xa5, 0x7e, 0xb8, 0xb8, 0xb6, 0x5b, 0x53, 0x42}};
6287
63 #if DILIGENT_CPP_INTERFACE
88 #define DILIGENT_INTERFACE_NAME IHLSL2GLSLConversionStream
89 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
90
91 // clang-format off
6492
6593 /// Interface to the buffer object implemented in OpenGL
66 class IHLSL2GLSLConverter : public IObject
94 DILIGENT_INTERFACE(IHLSL2GLSLConverter, IObject)
6795 {
68 public:
69 virtual void CreateStream(const Char* InputFileName,
70 IShaderSourceInputStreamFactory* pSourceStreamFactory,
71 const Char* HLSLSource,
72 size_t NumSymbols,
73 IHLSL2GLSLConversionStream** ppStream) const = 0;
96 VIRTUAL void METHOD(CreateStream)(THIS_
97 const Char* InputFileName,
98 IShaderSourceInputStreamFactory* pSourceStreamFactory,
99 const Char* HLSLSource,
100 size_t NumSymbols,
101 IHLSL2GLSLConversionStream** ppStream) CONST PURE;
74102 };
75103
76 #else
104 #if DILIGENT_C_INTERFACE
105
106 // clang-format on
107
108 struct IHLSL2GLSLConverterVtbl
109 {
110 struct IObjectMethods Object;
111 struct IHLSL2GLSLConverterMethods HLSL2GLSLConverter;
112 };
113
114 typedef struct IHLSL2GLSLConverter
115 {
116 struct IHLSL2GLSLConverterVtbl* pVtbl;
117 } IHLSL2GLSLConverter;
118
119 // clang-format off
120
121 # define IHLSL2GLSLConverter_CreateStream(This) (This)->pVtbl->HLSL2GLSLConverter.CreateStream((IHLSL2GLSLConverter*)(This), __VA_ARGS__)
122
123 // clang-format on
77124
78125 #endif
79126
3737 #if DILIGENT_CPP_INTERFACE
3838
3939 /// Base interface for a raw memory allocator
40 class IMemoryAllocator
40 struct IMemoryAllocator
4141 {
42 public:
4342 /// Allocates block of memory
4443 virtual void* Allocate(size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber) = 0;
4544
4948
5049 #else
5150
51 struct IMemoryAllocator;
52
53 // clang-format off
54
55 struct IMemoryAllocatorMethods
56 {
57 void* (*Allocate) (struct IMemoryAllocator*, size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber);
58 void (*Free) (struct IMemoryAllocator*, void* Ptr);
59 };
60
61 struct IMemoryAllocatorVtbl
62 {
63 struct IMemoryAllocatorMethods MemoryAllocator;
64 };
65
66 // clang-format on
67
68 typedef struct IMemoryAllocator
69 {
70 struct IMemoryAllocatorVtbl* pVtbl;
71 } IMemoryAllocator;
72
73 // clang-format off
74
75 # define IMemoryAllocator_Allocate(This, ...) (This)->pVtbl->MemoryAllocator.Allocate((IMemoryAllocator*)(This), __VA_ARGS__)
76 # define IMemoryAllocator_Free(This, ...) (This)->pVtbl->MemoryAllocator.Free ((IMemoryAllocator*)(This), __VA_ARGS__)
77
5278 #endif
5379
5480 DILIGENT_END_NAMESPACE // namespace Diligent