diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-01-25 23:24:20 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-01-25 23:24:20 +0000 |
| commit | f5cc92f41904dceaa6ef7f05f1860d381443e42f (patch) | |
| tree | 1231136b6a109c9934abdfb2944734d21da6a669 /Graphics/GraphicsEngine | |
| parent | c inteface: implemented core object VTBLs (diff) | |
| download | DiligentCore-f5cc92f41904dceaa6ef7f05f1860d381443e42f.tar.gz DiligentCore-f5cc92f41904dceaa6ef7f05f1860d381443e42f.zip | |
Updated Buffer and Texture C interfaces
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/interface/Buffer.h | 28 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/BufferView.h | 6 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/DeviceObject.h | 16 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/Sampler.h | 14 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/Texture.h | 28 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/TextureView.h | 36 |
6 files changed, 76 insertions, 52 deletions
diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h index 5e3a01d2..4f1d5cd4 100644 --- a/Graphics/GraphicsEngine/interface/Buffer.h +++ b/Graphics/GraphicsEngine/interface/Buffer.h @@ -234,13 +234,15 @@ struct IBuffer; struct IBufferVtbl { - void (*CreateView)(const struct BufferViewDesc* ViewDesc, class IBufferView** ppView); - class IBufferView* (*GetDefaultView)(BUFFER_VIEW_TYPE ViewType); - void* (*GetNativeHandle)(); - void (*SetState)(RESOURCE_STATE State); - RESOURCE_STATE (*GetState)(); + void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView); + class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType); + void* (*GetNativeHandle)(struct IBuffer*); + void (*SetState) (struct IBuffer*,RESOURCE_STATE State); + RESOURCE_STATE (*GetState) (struct IBuffer*); }; +// clang-format on + struct IBuffer { struct IObjectVtbl* pObjectVtbl; @@ -248,13 +250,17 @@ struct IBuffer struct IBufferVtbl* pBufferVtbl; }; -# define IBuffer_GetDesc(This) (const struct BufferDesc*)(This)->pDeviceObjectVtbl->GetDesc(This) +// clang-format off + +# define IBuffer_GetDesc(This) (const struct BufferDesc*)IDeviceObject_GetDesc(This) + +# define IBuffer_CreateView(This, ...) (This)->pBufferVtbl->CreateView ((struct IBuffer*)(This), __VA_ARGS__) +# define IBuffer_GetDefaultView(This, ...) (This)->pBufferVtbl->GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__) +# define IBuffer_GetNativeHandle(This) (This)->pBufferVtbl->GetNativeHandle((struct IBuffer*)(This)) +# define IBuffer_SetState(This, ...) (This)->pBufferVtbl->SetState ((struct IBuffer*)(This), __VA_ARGS__) +# define IBuffer_GetState(This) (This)->pBufferVtbl->GetState ((struct IBuffer*)(This)) -# define IBuffer_CreateView(This, ...) (This)->pBufferVtbl->CreateView(This, __VA_ARGS__) -# define IBuffer_GetDefaultView(This, ...) (This)->pBufferVtbl->GetDefaultView(This, __VA_ARGS__) -# define IBuffer_GetNativeHandle(This) (This)->pBufferVtbl->(This) -# define IBuffer_SetState(This) (This)->pBufferVtbl->SetState(This, __VA_ARGS__) -# define IBuffer_GetState(This) (This)->pBufferVtbl->GetState(This, __VA_ARGS__) +// clang-format on #endif diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h index a0bb3585..48c076ab 100644 --- a/Graphics/GraphicsEngine/interface/BufferView.h +++ b/Graphics/GraphicsEngine/interface/BufferView.h @@ -166,7 +166,7 @@ class IBuffer; struct IBufferViewVtbl { - class IBuffer* (*GetBuffer)(); + class IBuffer* (*GetBuffer)(struct IBufferView*); }; struct IBufferView @@ -176,9 +176,9 @@ struct IBufferView struct IBufferViewVtbl* pBufferVtbl; }; -# define IBufferView_GetDesc(This) (const struct BufferViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This) +# define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This) -# define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer(This) +# define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer((struct IBufferView*)(This)) #endif diff --git a/Graphics/GraphicsEngine/interface/DeviceObject.h b/Graphics/GraphicsEngine/interface/DeviceObject.h index 3c74988e..fcd2025a 100644 --- a/Graphics/GraphicsEngine/interface/DeviceObject.h +++ b/Graphics/GraphicsEngine/interface/DeviceObject.h @@ -73,20 +73,28 @@ public: struct IDeviceObject; +// clang-format off + struct IDeviceObjectVtbl { - const struct DeviceObjectAttribs* (*GetDesc)(); - Int32 (*GetUniqueID)(); + const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*); + Int32 (*GetUniqueID)(struct IDeviceObject*); }; +// clang-format on + struct IDeviceObject { struct IObjectVtbl* pObjectVtbl; struct IDeviceObjectVtbl* pDeviceObjectVtbl; }; -# define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc(This) -# define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID(This) +// clang-format off + +# define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc ((struct IDeviceObject*)(This)) +# define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID((struct IDeviceObject*)(This)) + +// clang-format on #endif diff --git a/Graphics/GraphicsEngine/interface/Sampler.h b/Graphics/GraphicsEngine/interface/Sampler.h index ecab7551..4a141548 100644 --- a/Graphics/GraphicsEngine/interface/Sampler.h +++ b/Graphics/GraphicsEngine/interface/Sampler.h @@ -59,29 +59,29 @@ struct SamplerDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Texture minification filter, see Diligent::FILTER_TYPE for details. /// Default value: Diligent::FILTER_TYPE_LINEAR. - enum FILTER_TYPE MinFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR); + FILTER_TYPE MinFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR); /// Texture magnification filter, see Diligent::FILTER_TYPE for details. /// Default value: Diligent::FILTER_TYPE_LINEAR. - enum FILTER_TYPE MagFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR); + FILTER_TYPE MagFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR); /// Mip filter, see Diligent::FILTER_TYPE for details. /// Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR, FILTER_TYPE_ANISOTROPIC, and /// FILTER_TYPE_COMPARISON_ANISOTROPIC are allowed. /// Default value: Diligent::FILTER_TYPE_LINEAR. - enum FILTER_TYPE MipFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR); + FILTER_TYPE MipFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR); /// Texture address mode for U coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details /// Default value: Diligent::TEXTURE_ADDRESS_CLAMP. - enum TEXTURE_ADDRESS_MODE AddressU DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP); + TEXTURE_ADDRESS_MODE AddressU DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP); /// Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details /// Default value: Diligent::TEXTURE_ADDRESS_CLAMP. - enum TEXTURE_ADDRESS_MODE AddressV DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP); + TEXTURE_ADDRESS_MODE AddressV DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP); /// Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details /// Default value: Diligent::TEXTURE_ADDRESS_CLAMP. - enum TEXTURE_ADDRESS_MODE AddressW DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP); + TEXTURE_ADDRESS_MODE AddressW DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP); /// Offset from the calculated mipmap level. For example, if a sampler calculates that a texture /// should be sampled at mipmap level 1.2 and MipLODBias is 2.3, then the texture will be sampled at @@ -93,7 +93,7 @@ struct SamplerDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// A function that compares sampled data against existing sampled data when comparsion /// filter is used. Default value: Diligent::COMPARISON_FUNC_NEVER. - enum COMPARISON_FUNCTION ComparisonFunc DEFAULT_INITIALIZER(COMPARISON_FUNC_NEVER); + COMPARISON_FUNCTION ComparisonFunc DEFAULT_INITIALIZER(COMPARISON_FUNC_NEVER); /// Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV, or AddressW. /// Default value: {0,0,0,0} diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h index 195b487d..02664742 100644 --- a/Graphics/GraphicsEngine/interface/Texture.h +++ b/Graphics/GraphicsEngine/interface/Texture.h @@ -370,11 +370,11 @@ struct ITextureView; struct ITextureVtbl { - void (*CreateView)(const struct TextureViewDesc* ViewDesc, class ITextureView** ppView); - class ITextureView* (*GetDefaultView)(enum TEXTURE_VIEW_TYPE ViewType); - void* (*GetNativeHandle)(); - void (*SetState)(RESOURCE_STATE State); - RESOURCE_STATE (*GetState)(); + void (*CreateView) (struct ITexture*, const struct TextureViewDesc* ViewDesc, class ITextureView** ppView); + class ITextureView* (*GetDefaultView) (struct ITexture*, TEXTURE_VIEW_TYPE ViewType); + void* (*GetNativeHandle)(struct ITexture*); + void (*SetState) (struct ITexture*, RESOURCE_STATE State); + RESOURCE_STATE (*GetState) (struct ITexture*); }; // clang-format on @@ -383,16 +383,20 @@ struct ITexture { struct IObjectVtbl* pObjectVtbl; struct IDeviceObjectVtbl* pDeviceObjectVtbl; - struct ITexture* pTextureVtbl; + struct ITextureVtbl* pTextureVtbl; }; -# define ITexture_GetDesc(This) (const struct TextureDesc*)(This)->pDeviceObjectVtbl->GetDesc(This) +// clang-format off + +# define ITexture_GetDesc(This) (const struct TextureDesc*)IDeviceObject_GetDesc(This) -# define ITexture_CreateView(This, ...) (This)->pTextureVtbl->SetSampler(This, __VA_ARGS__) -# define ITexture_GetDefaultView(This, ...) (This)->pTextureVtbl->GetDefaultView(This, __VA_ARGS__) -# define ITexture_GetNativeHandle(This) (This)->pTextureVtbl->GetNativeHandle(This) -# define ITexture_SetState(This, ...) (This)->pTextureVtbl->SetState(This, __VA_ARGS__) -# define ITexture_GetState(This) (This)->pTextureVtbl->GetState(This, __VA_ARGS__) +# define ITexture_CreateView(This, ...) (This)->pTextureVtbl->CreateView ((struct ITexture*)(This), __VA_ARGS__) +# define ITexture_GetDefaultView(This, ...) (This)->pTextureVtbl->GetDefaultView ((struct ITexture*)(This), __VA_ARGS__) +# define ITexture_GetNativeHandle(This) (This)->pTextureVtbl->GetNativeHandle((struct ITexture*)(This)) +# define ITexture_SetState(This, ...) (This)->pTextureVtbl->SetState ((struct ITexture*)(This), __VA_ARGS__) +# define ITexture_GetState(This) (This)->pTextureVtbl->GetState ((struct ITexture*)(This)) + +// clang-format on #endif diff --git a/Graphics/GraphicsEngine/interface/TextureView.h b/Graphics/GraphicsEngine/interface/TextureView.h index 8cf56a3d..8cb31441 100644 --- a/Graphics/GraphicsEngine/interface/TextureView.h +++ b/Graphics/GraphicsEngine/interface/TextureView.h @@ -80,28 +80,28 @@ DEFINE_FLAG_ENUM_OPERATORS(TEXTURE_VIEW_FLAGS) struct TextureViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Describes the texture view type, see Diligent::TEXTURE_VIEW_TYPE for details. - enum TEXTURE_VIEW_TYPE ViewType DEFAULT_INITIALIZER(TEXTURE_VIEW_UNDEFINED); + TEXTURE_VIEW_TYPE ViewType DEFAULT_INITIALIZER(TEXTURE_VIEW_UNDEFINED); /// View interpretation of the original texture. For instance, /// one slice of a 2D texture array can be viewed as a 2D texture. /// See Diligent::RESOURCE_DIMENSION for a list of texture types. /// If default value Diligent::RESOURCE_DIM_UNDEFINED is provided, /// the view type will match the type of the referenced texture. - enum RESOURCE_DIMENSION TextureDim DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED); + RESOURCE_DIMENSION TextureDim DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED); /// View format. If default value Diligent::TEX_FORMAT_UNKNOWN is provided, /// the view format will match the referenced texture format. - enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); + TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); /// Most detailed mip level to use - Uint32 MostDetailedMip DEFAULT_INITIALIZER(0); + Uint32 MostDetailedMip DEFAULT_INITIALIZER(0); /// Total number of mip levels for the view of the texture. /// Render target and depth stencil views can address only one mip level. /// If 0 is provided, then for a shader resource view all mip levels will be /// referenced, and for a render target or a depth stencil view, one mip level /// will be referenced. - Uint32 NumMipLevels DEFAULT_INITIALIZER(0); + Uint32 NumMipLevels DEFAULT_INITIALIZER(0); union { @@ -125,10 +125,10 @@ struct TextureViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// For an unordered access view, allowed access flags. See Diligent::UAV_ACCESS_FLAG /// for details. - enum UAV_ACCESS_FLAG AccessFlags DEFAULT_INITIALIZER(UAV_ACCESS_UNSPECIFIED); + UAV_ACCESS_FLAG AccessFlags DEFAULT_INITIALIZER(UAV_ACCESS_UNSPECIFIED); /// Texture view flags, see Diligent::TEXTURE_VIEW_FLAGS. - enum TEXTURE_VIEW_FLAGS Flags DEFAULT_INITIALIZER(TEXTURE_VIEW_FLAG_NONE); + TEXTURE_VIEW_FLAGS Flags DEFAULT_INITIALIZER(TEXTURE_VIEW_FLAG_NONE); #if DILIGENT_CPP_INTERFACE @@ -224,11 +224,13 @@ public: struct ITextureView; struct ISampler; +// clang-format off + struct ITextureViewVtbl { - void (*SetSampler)(class ISampler* pSampler); - class ISampler* (*GetSampler)(); - class ITexture* (*GetTexture)(); + void (*SetSampler)(struct ITextureView*, class ISampler* pSampler); + class ISampler* (*GetSampler)(struct ITextureView*); + class ITexture* (*GetTexture)(struct ITextureView*); }; // clang-format on @@ -237,14 +239,18 @@ struct ITextureView { struct IObjectVtbl* pObjectVtbl; struct IDeviceObjectVtbl* pDeviceObjectVtbl; - struct ITextureView* pTextureViewVtbl; + struct ITextureViewVtbl* pTextureViewVtbl; }; -# define ITextureView_GetDesc(This) (const struct TextureViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This) +# define ITextureView_GetDesc(This) (const struct TextureViewDesc*)IDeviceObject_GetDesc(This) + +// clang-format off + +# define ITextureView_SetSampler(This, ...) (This)->pTextureViewVtbl->SetSampler((struct ITextureView*)(This), __VA_ARGS__) +# define ITextureView_GetSampler(This) (This)->pTextureViewVtbl->GetSampler((struct ITextureView*)(This)) +# define ITextureView_GetTexture(This) (This)->pTextureViewVtbl->GetTexture((struct ITextureView*)(This)) -# define ITextureView_SetSampler(This) (This)->pTextureViewVtbl->SetSampler(This) -# define ITextureView_GetSampler(This) (This)->pTextureViewVtbl->GetSampler(This) -# define ITextureView_GetTexture(This) (This)->pTextureViewVtbl->GetTexture(This) +// clang-format on #endif |
