summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-26 03:06:12 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-26 03:06:12 +0000
commit7cc1c475e5822da8bad790b66d3ddbd5f8afddd5 (patch)
treeb51ebaaa670242532134bf4958d2dc8b5ec1ea03 /Graphics/GraphicsEngine
parentFixed few C issues in platform definitions (diff)
downloadDiligentCore-7cc1c475e5822da8bad790b66d3ddbd5f8afddd5.tar.gz
DiligentCore-7cc1c475e5822da8bad790b66d3ddbd5f8afddd5.zip
Fixed Buffer, BufferView, Texture, TextureView interfaces; added C interface tests
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/interface/Buffer.h23
-rw-r--r--Graphics/GraphicsEngine/interface/BufferView.h15
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h26
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceObject.h15
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h16
-rw-r--r--Graphics/GraphicsEngine/interface/RasterizerState.h4
-rw-r--r--Graphics/GraphicsEngine/interface/Texture.h23
-rw-r--r--Graphics/GraphicsEngine/interface/TextureView.h19
8 files changed, 83 insertions, 58 deletions
diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h
index 4f1d5cd4..8c13d652 100644
--- a/Graphics/GraphicsEngine/interface/Buffer.h
+++ b/Graphics/GraphicsEngine/interface/Buffer.h
@@ -232,7 +232,7 @@ public:
struct IBuffer;
-struct IBufferVtbl
+struct IBufferMethods
{
void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView);
class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType);
@@ -243,22 +243,27 @@ struct IBufferVtbl
// clang-format on
+struct IBufferVtbl
+{
+ struct IObjectMethods Object;
+ struct IDeviceObjectMethods DeviceObject;
+ struct IBufferMethods Buffer;
+};
+
struct IBuffer
{
- struct IObjectVtbl* pObjectVtbl;
- struct IDeviceObjectVtbl* pDeviceObjectVtbl;
- struct IBufferVtbl* pBufferVtbl;
+ struct IBufferVtbl* pVtbl;
};
// 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)->pVtbl->Buffer.CreateView ((struct IBuffer*)(This), __VA_ARGS__)
+# define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__)
+# define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((struct IBuffer*)(This))
+# define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((struct IBuffer*)(This), __VA_ARGS__)
+# define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((struct IBuffer*)(This))
// clang-format on
diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h
index 48c076ab..6daf555f 100644
--- a/Graphics/GraphicsEngine/interface/BufferView.h
+++ b/Graphics/GraphicsEngine/interface/BufferView.h
@@ -164,21 +164,26 @@ public:
class IBufferView;
class IBuffer;
-struct IBufferViewVtbl
+struct IBufferViewMethods
{
class IBuffer* (*GetBuffer)(struct IBufferView*);
};
+struct IBufferViewVtbl
+{
+ struct IObjectMethods Object;
+ struct IDeviceObjectMethods DeviceObject;
+ struct IBufferViewMethods BufferView;
+};
+
struct IBufferView
{
- struct IObjectVtbl* pObjectVtbl;
- struct IDeviceObjectVtbl* pDeviceObjectVtbl;
- struct IBufferViewVtbl* pBufferVtbl;
+ struct IBufferViewVtbl* pVtbl;
};
# define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This)
-# define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer((struct IBufferView*)(This))
+# define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((struct IBufferView*)(This))
#endif
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index ebe8d401..73fc12c6 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -222,10 +222,10 @@ struct DrawIndexedAttribs
/// The type of elements in the index buffer.
/// Allowed values: VT_UINT16 and VT_UINT32.
- enum VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED);
+ VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED);
/// Additional flags, see Diligent::DRAW_FLAGS.
- enum DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
+ DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
/// Number of instances to draw. If more than one instance is specified,
/// instanced draw call will be performed.
@@ -284,13 +284,13 @@ struct DrawIndexedAttribs
struct DrawIndirectAttribs
{
/// Additional flags, see Diligent::DRAW_FLAGS.
- enum DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
+ DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
/// State transition mode for indirect draw arguments buffer.
- enum RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+ RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
/// Offset from the beginning of the buffer to the location of draw command attributes.
- Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0);
+ Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0);
#if DILIGENT_CPP_INTERFACE
@@ -323,13 +323,13 @@ struct DrawIndexedIndirectAttribs
{
/// The type of the elements in the index buffer.
/// Allowed values: VT_UINT16 and VT_UINT32. Ignored if DrawAttribs::IsIndexed is False.
- enum VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED);
+ VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED);
/// Additional flags, see Diligent::DRAW_FLAGS.
- enum DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
+ DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
/// State transition mode for indirect draw arguments buffer.
- enum RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+ RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
/// Offset from the beginning of the buffer to the location of draw command attributes.
Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0);
@@ -405,7 +405,7 @@ struct DispatchComputeAttribs
struct DispatchComputeIndirectAttribs
{
/// State transition mode for indirect dispatch attributes buffer.
- enum RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+ RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
/// The offset from the beginning of the buffer to the dispatch command arguments.
Uint32 DispatchArgsByteOffset DEFAULT_INITIALIZER(0);
@@ -436,7 +436,7 @@ struct ResolveTextureSubresourceAttribs
Uint32 SrcSlice DEFAULT_INITIALIZER(0);
/// Source texture state transition mode, see Diligent::RESOURCE_STATE_TRANSITION_MODE.
- enum RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+ RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
/// Mip level of the destination non-multi-sampled texture.
Uint32 DstMipLevel DEFAULT_INITIALIZER(0);
@@ -445,12 +445,12 @@ struct ResolveTextureSubresourceAttribs
Uint32 DstSlice DEFAULT_INITIALIZER(0);
/// Destination texture state transition mode, see Diligent::RESOURCE_STATE_TRANSITION_MODE.
- enum RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+ RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
/// If one or both textures are typeless, specifies the type of the typeless texture.
/// If both texture formats are not typeless, in which case they must be identical, this member must be
/// either TEX_FORMAT_UNKNOWN, or match this format.
- enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
+ TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
};
/// Defines allowed flags for IDeviceContext::SetVertexBuffers() function.
@@ -581,7 +581,7 @@ struct CopyTextureAttribs
Uint32 DstZ DEFAULT_INITIALIZER(0);
/// Destination texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
- enum RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+ RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
#if DILIGENT_CPP_INTERFACE
diff --git a/Graphics/GraphicsEngine/interface/DeviceObject.h b/Graphics/GraphicsEngine/interface/DeviceObject.h
index fcd2025a..98c90c07 100644
--- a/Graphics/GraphicsEngine/interface/DeviceObject.h
+++ b/Graphics/GraphicsEngine/interface/DeviceObject.h
@@ -75,7 +75,7 @@ struct IDeviceObject;
// clang-format off
-struct IDeviceObjectVtbl
+struct IDeviceObjectMethods
{
const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*);
Int32 (*GetUniqueID)(struct IDeviceObject*);
@@ -83,16 +83,21 @@ struct IDeviceObjectVtbl
// clang-format on
+struct IDeviceObjectVtbl
+{
+ struct IObjectMethods Object;
+ struct IDeviceObjectMethods DeviceObject;
+};
+
struct IDeviceObject
{
- struct IObjectVtbl* pObjectVtbl;
- struct IDeviceObjectVtbl* pDeviceObjectVtbl;
+ struct IDeviceObjectVtbl* pVtbl;
};
// clang-format off
-# define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc ((struct IDeviceObject*)(This))
-# define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID((struct IDeviceObject*)(This))
+# define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((struct IDeviceObject*)(This))
+# define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((struct IDeviceObject*)(This))
// clang-format on
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index a9a0ef56..dee9e9e7 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -73,7 +73,7 @@ struct SampleDesc
struct ShaderResourceVariableDesc
{
/// Shader stages this resources variable applies to. More than one shader stage can be specified.
- enum SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
+ SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
/// Shader variable name
const Char* Name DEFAULT_INITIALIZER(nullptr);
@@ -97,7 +97,7 @@ struct ShaderResourceVariableDesc
struct StaticSamplerDesc
{
/// Shader stages that this static sampler applies to. More than one shader stage can be specified.
- enum SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
+ SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
/// The name of the sampler itself or the name of the texture variable that
/// this static sampler is assigned to if combined texture samplers are used.
@@ -126,7 +126,7 @@ struct PipelineResourceLayoutDesc
/// Default shader resource variable type. This type will be used if shader
/// variable description is not found in the Variables array
/// or if Variables == nullptr
- enum SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
+ SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
/// Number of elements in Variables array
Uint32 NumVariables DEFAULT_INITIALIZER(0);
@@ -184,19 +184,19 @@ struct GraphicsPipelineDesc
//D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue;
/// Primitive topology type
- enum PRIMITIVE_TOPOLOGY PrimitiveTopology DEFAULT_INITIALIZER(PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
+ PRIMITIVE_TOPOLOGY PrimitiveTopology DEFAULT_INITIALIZER(PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
/// Number of viewports used by this pipeline
- Uint8 NumViewports DEFAULT_INITIALIZER(1);
+ Uint8 NumViewports DEFAULT_INITIALIZER(1);
/// Number of render targets in the RTVFormats member
- Uint8 NumRenderTargets DEFAULT_INITIALIZER(0);
+ Uint8 NumRenderTargets DEFAULT_INITIALIZER(0);
/// Render target formats
- enum TEXTURE_FORMAT RTVFormats[8] DEFAULT_INITIALIZER({});
+ TEXTURE_FORMAT RTVFormats[8] DEFAULT_INITIALIZER({});
/// Depth-stencil format
- enum TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
+ TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
/// Multisampling parameters
struct SampleDesc SmplDesc;
diff --git a/Graphics/GraphicsEngine/interface/RasterizerState.h b/Graphics/GraphicsEngine/interface/RasterizerState.h
index 3d63cb07..08a74933 100644
--- a/Graphics/GraphicsEngine/interface/RasterizerState.h
+++ b/Graphics/GraphicsEngine/interface/RasterizerState.h
@@ -97,11 +97,11 @@ struct RasterizerStateDesc
{
/// Determines traingle fill mode, see Diligent::FILL_MODE for details.
/// Default value: Diligent::FILL_MODE_SOLID.
- enum FILL_MODE FillMode DEFAULT_INITIALIZER(FILL_MODE_SOLID);
+ FILL_MODE FillMode DEFAULT_INITIALIZER(FILL_MODE_SOLID);
/// Determines traingle cull mode, see Diligent::CULL_MODE for details.
/// Default value: Diligent::CULL_MODE_BACK.
- enum CULL_MODE CullMode DEFAULT_INITIALIZER(CULL_MODE_BACK);
+ CULL_MODE CullMode DEFAULT_INITIALIZER(CULL_MODE_BACK);
/// Determines if a triangle is front- or back-facing. If this parameter is True,
/// a triangle will be considered front-facing if its vertices are counter-clockwise
diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h
index 02664742..598210fd 100644
--- a/Graphics/GraphicsEngine/interface/Texture.h
+++ b/Graphics/GraphicsEngine/interface/Texture.h
@@ -368,7 +368,7 @@ public:
struct ITexture;
struct ITextureView;
-struct ITextureVtbl
+struct ITextureMethods
{
void (*CreateView) (struct ITexture*, const struct TextureViewDesc* ViewDesc, class ITextureView** ppView);
class ITextureView* (*GetDefaultView) (struct ITexture*, TEXTURE_VIEW_TYPE ViewType);
@@ -379,22 +379,27 @@ struct ITextureVtbl
// clang-format on
+struct ITextureVtbl
+{
+ struct IObjectMethods Object;
+ struct IDeviceObjectMethods DeviceObject;
+ struct ITextureMethods Texture;
+};
+
struct ITexture
{
- struct IObjectVtbl* pObjectVtbl;
- struct IDeviceObjectVtbl* pDeviceObjectVtbl;
- struct ITextureVtbl* pTextureVtbl;
+ struct ITextureVtbl* pVtbl;
};
// clang-format off
# define ITexture_GetDesc(This) (const struct TextureDesc*)IDeviceObject_GetDesc(This)
-# 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))
+# define ITexture_CreateView(This, ...) (This)->pVtbl->Texture.CreateView ((struct ITexture*)(This), __VA_ARGS__)
+# define ITexture_GetDefaultView(This, ...) (This)->pVtbl->Texture.GetDefaultView ((struct ITexture*)(This), __VA_ARGS__)
+# define ITexture_GetNativeHandle(This) (This)->pVtbl->Texture.GetNativeHandle((struct ITexture*)(This))
+# define ITexture_SetState(This, ...) (This)->pVtbl->Texture.SetState ((struct ITexture*)(This), __VA_ARGS__)
+# define ITexture_GetState(This) (This)->pVtbl->Texture.GetState ((struct ITexture*)(This))
// clang-format on
diff --git a/Graphics/GraphicsEngine/interface/TextureView.h b/Graphics/GraphicsEngine/interface/TextureView.h
index 8cb31441..e79a23a8 100644
--- a/Graphics/GraphicsEngine/interface/TextureView.h
+++ b/Graphics/GraphicsEngine/interface/TextureView.h
@@ -226,7 +226,7 @@ struct ISampler;
// clang-format off
-struct ITextureViewVtbl
+struct ITextureViewMethods
{
void (*SetSampler)(struct ITextureView*, class ISampler* pSampler);
class ISampler* (*GetSampler)(struct ITextureView*);
@@ -235,20 +235,25 @@ struct ITextureViewVtbl
// clang-format on
+struct ITextureViewVtbl
+{
+ struct IObjectMethods Object;
+ struct IDeviceObjectMethods DeviceObject;
+ struct ITextureViewMethods TextureView;
+};
+
struct ITextureView
{
- struct IObjectVtbl* pObjectVtbl;
- struct IDeviceObjectVtbl* pDeviceObjectVtbl;
- struct ITextureViewVtbl* pTextureViewVtbl;
+ struct ITextureViewVtbl* pVtbl;
};
# 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)->pVtbl->TextureView.SetSampler((struct ITextureView*)(This), __VA_ARGS__)
+# define ITextureView_GetSampler(This) (This)->pVtbl->TextureView.GetSampler((struct ITextureView*)(This))
+# define ITextureView_GetTexture(This) (This)->pVtbl->TextureView.GetTexture((struct ITextureView*)(This))
// clang-format on