git.s-ol.nu forks/DiligentCore / f5cc92f
Updated Buffer and Texture C interfaces assiduous 3 years ago
7 changed file(s) with 99 addition(s) and 68 deletion(s). Raw diff Collapse all Expand all
233233
234234 struct IBufferVtbl
235235 {
236 void (*CreateView)(const struct BufferViewDesc* ViewDesc, class IBufferView** ppView);
237 class IBufferView* (*GetDefaultView)(BUFFER_VIEW_TYPE ViewType);
238 void* (*GetNativeHandle)();
239 void (*SetState)(RESOURCE_STATE State);
240 RESOURCE_STATE (*GetState)();
241 };
236 void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView);
237 class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType);
238 void* (*GetNativeHandle)(struct IBuffer*);
239 void (*SetState) (struct IBuffer*,RESOURCE_STATE State);
240 RESOURCE_STATE (*GetState) (struct IBuffer*);
241 };
242
243 // clang-format on
242244
243245 struct IBuffer
244246 {
247249 struct IBufferVtbl* pBufferVtbl;
248250 };
249251
250 # define IBuffer_GetDesc(This) (const struct BufferDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
251
252 # define IBuffer_CreateView(This, ...) (This)->pBufferVtbl->CreateView(This, __VA_ARGS__)
253 # define IBuffer_GetDefaultView(This, ...) (This)->pBufferVtbl->GetDefaultView(This, __VA_ARGS__)
254 # define IBuffer_GetNativeHandle(This) (This)->pBufferVtbl->(This)
255 # define IBuffer_SetState(This) (This)->pBufferVtbl->SetState(This, __VA_ARGS__)
256 # define IBuffer_GetState(This) (This)->pBufferVtbl->GetState(This, __VA_ARGS__)
252 // clang-format off
253
254 # define IBuffer_GetDesc(This) (const struct BufferDesc*)IDeviceObject_GetDesc(This)
255
256 # define IBuffer_CreateView(This, ...) (This)->pBufferVtbl->CreateView ((struct IBuffer*)(This), __VA_ARGS__)
257 # define IBuffer_GetDefaultView(This, ...) (This)->pBufferVtbl->GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__)
258 # define IBuffer_GetNativeHandle(This) (This)->pBufferVtbl->GetNativeHandle((struct IBuffer*)(This))
259 # define IBuffer_SetState(This, ...) (This)->pBufferVtbl->SetState ((struct IBuffer*)(This), __VA_ARGS__)
260 # define IBuffer_GetState(This) (This)->pBufferVtbl->GetState ((struct IBuffer*)(This))
261
262 // clang-format on
257263
258264 #endif
259265
165165
166166 struct IBufferViewVtbl
167167 {
168 class IBuffer* (*GetBuffer)();
168 class IBuffer* (*GetBuffer)(struct IBufferView*);
169169 };
170170
171171 struct IBufferView
175175 struct IBufferViewVtbl* pBufferVtbl;
176176 };
177177
178 # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
178 # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This)
179179
180 # define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer(This)
180 # define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer((struct IBufferView*)(This))
181181
182182 #endif
183183
7272
7373 struct IDeviceObject;
7474
75 // clang-format off
76
7577 struct IDeviceObjectVtbl
7678 {
77 const struct DeviceObjectAttribs* (*GetDesc)();
78 Int32 (*GetUniqueID)();
79 const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*);
80 Int32 (*GetUniqueID)(struct IDeviceObject*);
7981 };
82
83 // clang-format on
8084
8185 struct IDeviceObject
8286 {
8488 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
8589 };
8690
87 # define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc(This)
88 # define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID(This)
91 // clang-format off
92
93 # define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc ((struct IDeviceObject*)(This))
94 # define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID((struct IDeviceObject*)(This))
95
96 // clang-format on
8997
9098 #endif
9199
5858
5959 /// Texture minification filter, see Diligent::FILTER_TYPE for details.
6060 /// Default value: Diligent::FILTER_TYPE_LINEAR.
61 enum FILTER_TYPE MinFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
61 FILTER_TYPE MinFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
6262
6363 /// Texture magnification filter, see Diligent::FILTER_TYPE for details.
6464 /// Default value: Diligent::FILTER_TYPE_LINEAR.
65 enum FILTER_TYPE MagFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
65 FILTER_TYPE MagFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
6666
6767 /// Mip filter, see Diligent::FILTER_TYPE for details.
6868 /// Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR, FILTER_TYPE_ANISOTROPIC, and
6969 /// FILTER_TYPE_COMPARISON_ANISOTROPIC are allowed.
7070 /// Default value: Diligent::FILTER_TYPE_LINEAR.
71 enum FILTER_TYPE MipFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
71 FILTER_TYPE MipFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
7272
7373 /// Texture address mode for U coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
7474 /// Default value: Diligent::TEXTURE_ADDRESS_CLAMP.
75 enum TEXTURE_ADDRESS_MODE AddressU DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
75 TEXTURE_ADDRESS_MODE AddressU DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
7676
7777 /// Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
7878 /// Default value: Diligent::TEXTURE_ADDRESS_CLAMP.
79 enum TEXTURE_ADDRESS_MODE AddressV DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
79 TEXTURE_ADDRESS_MODE AddressV DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
8080
8181 /// Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
8282 /// Default value: Diligent::TEXTURE_ADDRESS_CLAMP.
83 enum TEXTURE_ADDRESS_MODE AddressW DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
83 TEXTURE_ADDRESS_MODE AddressW DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
8484
8585 /// Offset from the calculated mipmap level. For example, if a sampler calculates that a texture
8686 /// should be sampled at mipmap level 1.2 and MipLODBias is 2.3, then the texture will be sampled at
9292
9393 /// A function that compares sampled data against existing sampled data when comparsion
9494 /// filter is used. Default value: Diligent::COMPARISON_FUNC_NEVER.
95 enum COMPARISON_FUNCTION ComparisonFunc DEFAULT_INITIALIZER(COMPARISON_FUNC_NEVER);
95 COMPARISON_FUNCTION ComparisonFunc DEFAULT_INITIALIZER(COMPARISON_FUNC_NEVER);
9696
9797 /// Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV, or AddressW.
9898 /// Default value: {0,0,0,0}
369369
370370 struct ITextureVtbl
371371 {
372 void (*CreateView)(const struct TextureViewDesc* ViewDesc, class ITextureView** ppView);
373 class ITextureView* (*GetDefaultView)(enum TEXTURE_VIEW_TYPE ViewType);
374 void* (*GetNativeHandle)();
375 void (*SetState)(RESOURCE_STATE State);
376 RESOURCE_STATE (*GetState)();
372 void (*CreateView) (struct ITexture*, const struct TextureViewDesc* ViewDesc, class ITextureView** ppView);
373 class ITextureView* (*GetDefaultView) (struct ITexture*, TEXTURE_VIEW_TYPE ViewType);
374 void* (*GetNativeHandle)(struct ITexture*);
375 void (*SetState) (struct ITexture*, RESOURCE_STATE State);
376 RESOURCE_STATE (*GetState) (struct ITexture*);
377377 };
378378
379379 // clang-format on
382382 {
383383 struct IObjectVtbl* pObjectVtbl;
384384 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
385 struct ITexture* pTextureVtbl;
386 };
387
388 # define ITexture_GetDesc(This) (const struct TextureDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
389
390 # define ITexture_CreateView(This, ...) (This)->pTextureVtbl->SetSampler(This, __VA_ARGS__)
391 # define ITexture_GetDefaultView(This, ...) (This)->pTextureVtbl->GetDefaultView(This, __VA_ARGS__)
392 # define ITexture_GetNativeHandle(This) (This)->pTextureVtbl->GetNativeHandle(This)
393 # define ITexture_SetState(This, ...) (This)->pTextureVtbl->SetState(This, __VA_ARGS__)
394 # define ITexture_GetState(This) (This)->pTextureVtbl->GetState(This, __VA_ARGS__)
385 struct ITextureVtbl* pTextureVtbl;
386 };
387
388 // clang-format off
389
390 # define ITexture_GetDesc(This) (const struct TextureDesc*)IDeviceObject_GetDesc(This)
391
392 # define ITexture_CreateView(This, ...) (This)->pTextureVtbl->CreateView ((struct ITexture*)(This), __VA_ARGS__)
393 # define ITexture_GetDefaultView(This, ...) (This)->pTextureVtbl->GetDefaultView ((struct ITexture*)(This), __VA_ARGS__)
394 # define ITexture_GetNativeHandle(This) (This)->pTextureVtbl->GetNativeHandle((struct ITexture*)(This))
395 # define ITexture_SetState(This, ...) (This)->pTextureVtbl->SetState ((struct ITexture*)(This), __VA_ARGS__)
396 # define ITexture_GetState(This) (This)->pTextureVtbl->GetState ((struct ITexture*)(This))
397
398 // clang-format on
395399
396400 #endif
397401
7979 struct TextureViewDesc DILIGENT_DERIVE(DeviceObjectAttribs)
8080
8181 /// Describes the texture view type, see Diligent::TEXTURE_VIEW_TYPE for details.
82 enum TEXTURE_VIEW_TYPE ViewType DEFAULT_INITIALIZER(TEXTURE_VIEW_UNDEFINED);
82 TEXTURE_VIEW_TYPE ViewType DEFAULT_INITIALIZER(TEXTURE_VIEW_UNDEFINED);
8383
8484 /// View interpretation of the original texture. For instance,
8585 /// one slice of a 2D texture array can be viewed as a 2D texture.
8686 /// See Diligent::RESOURCE_DIMENSION for a list of texture types.
8787 /// If default value Diligent::RESOURCE_DIM_UNDEFINED is provided,
8888 /// the view type will match the type of the referenced texture.
89 enum RESOURCE_DIMENSION TextureDim DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED);
89 RESOURCE_DIMENSION TextureDim DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED);
9090
9191 /// View format. If default value Diligent::TEX_FORMAT_UNKNOWN is provided,
9292 /// the view format will match the referenced texture format.
93 enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
93 TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
9494
9595 /// Most detailed mip level to use
96 Uint32 MostDetailedMip DEFAULT_INITIALIZER(0);
96 Uint32 MostDetailedMip DEFAULT_INITIALIZER(0);
9797
9898 /// Total number of mip levels for the view of the texture.
9999 /// Render target and depth stencil views can address only one mip level.
100100 /// If 0 is provided, then for a shader resource view all mip levels will be
101101 /// referenced, and for a render target or a depth stencil view, one mip level
102102 /// will be referenced.
103 Uint32 NumMipLevels DEFAULT_INITIALIZER(0);
103 Uint32 NumMipLevels DEFAULT_INITIALIZER(0);
104104
105105 union
106106 {
124124
125125 /// For an unordered access view, allowed access flags. See Diligent::UAV_ACCESS_FLAG
126126 /// for details.
127 enum UAV_ACCESS_FLAG AccessFlags DEFAULT_INITIALIZER(UAV_ACCESS_UNSPECIFIED);
127 UAV_ACCESS_FLAG AccessFlags DEFAULT_INITIALIZER(UAV_ACCESS_UNSPECIFIED);
128128
129129 /// Texture view flags, see Diligent::TEXTURE_VIEW_FLAGS.
130 enum TEXTURE_VIEW_FLAGS Flags DEFAULT_INITIALIZER(TEXTURE_VIEW_FLAG_NONE);
130 TEXTURE_VIEW_FLAGS Flags DEFAULT_INITIALIZER(TEXTURE_VIEW_FLAG_NONE);
131131
132132 #if DILIGENT_CPP_INTERFACE
133133
223223 struct ITextureView;
224224 struct ISampler;
225225
226 // clang-format off
227
226228 struct ITextureViewVtbl
227229 {
228 void (*SetSampler)(class ISampler* pSampler);
229 class ISampler* (*GetSampler)();
230 class ITexture* (*GetTexture)();
230 void (*SetSampler)(struct ITextureView*, class ISampler* pSampler);
231 class ISampler* (*GetSampler)(struct ITextureView*);
232 class ITexture* (*GetTexture)(struct ITextureView*);
231233 };
232234
233235 // clang-format on
236238 {
237239 struct IObjectVtbl* pObjectVtbl;
238240 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
239 struct ITextureView* pTextureViewVtbl;
240 };
241
242 # define ITextureView_GetDesc(This) (const struct TextureViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
243
244 # define ITextureView_SetSampler(This) (This)->pTextureViewVtbl->SetSampler(This)
245 # define ITextureView_GetSampler(This) (This)->pTextureViewVtbl->GetSampler(This)
246 # define ITextureView_GetTexture(This) (This)->pTextureViewVtbl->GetTexture(This)
241 struct ITextureViewVtbl* pTextureViewVtbl;
242 };
243
244 # define ITextureView_GetDesc(This) (const struct TextureViewDesc*)IDeviceObject_GetDesc(This)
245
246 // clang-format off
247
248 # define ITextureView_SetSampler(This, ...) (This)->pTextureViewVtbl->SetSampler((struct ITextureView*)(This), __VA_ARGS__)
249 # define ITextureView_GetSampler(This) (This)->pTextureViewVtbl->GetSampler((struct ITextureView*)(This))
250 # define ITextureView_GetTexture(This) (This)->pTextureViewVtbl->GetTexture((struct ITextureView*)(This))
251
252 // clang-format on
247253
248254 #endif
249255
8383
8484 struct IObject;
8585
86 // clang-format off
87
8688 struct IObjectVtbl
8789 {
88 void (*QueryInterface)(const struct INTERFACE_ID* IID, struct IObject** ppInterface);
89 ReferenceCounterValueType (*AddRef)();
90 ReferenceCounterValueType (*Release)();
91 class IReferenceCounters* (*GetReferenceCounters)();
90 void (*QueryInterface) (struct IObject*, const struct INTERFACE_ID* IID, struct IObject** ppInterface);
91 ReferenceCounterValueType (*AddRef) (struct IObject*);
92 ReferenceCounterValueType (*Release) (struct IObject*);
93 class IReferenceCounters* (*GetReferenceCounters)(struct IObject*);
9294 };
95
96 // clang-format on
9397
9498 struct IObject
9599 {
96100 struct IObjectVtbl* pObjectVtbl;
97 struct IObjectVtbl* pDeviceObjectVtbl;
98101 };
99102
100 # define IObject_QueryInterface(This, ...) (This)->pDeviceObjectVtbl->QueryInterface(This, __VA_ARGS__)
101 # define IObject_AddRef(This, ...) (This)->pDeviceObjectVtbl->AddRef(This, __VA_ARGS__)
102 # define IObject_Release(This) (This)->pDeviceObjectVtbl->Release()
103 // clang-format off
104
105 # define IObject_QueryInterface(This, ...) (This)->pObjectVtbl->QueryInterface((struct IObject*)(This), __VA_ARGS__)
106 # define IObject_AddRef(This, ...) (This)->pObjectVtbl->AddRef ((struct IObject*)(This), __VA_ARGS__)
107 # define IObject_Release(This) (This)->pObjectVtbl->Release ((struct IObject*)(This))
108
109 // clang-format on
103110
104111 #endif
105112