Updated Buffer and Texture C interfaces
assiduous
3 years ago
233 | 233 | |
234 | 234 | struct IBufferVtbl |
235 | 235 | { |
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 | |
242 | 244 | |
243 | 245 | struct IBuffer |
244 | 246 | { |
247 | 249 | struct IBufferVtbl* pBufferVtbl; |
248 | 250 | }; |
249 | 251 | |
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 | |
257 | 263 | |
258 | 264 | #endif |
259 | 265 |
165 | 165 | |
166 | 166 | struct IBufferViewVtbl |
167 | 167 | { |
168 | class IBuffer* (*GetBuffer)(); | |
168 | class IBuffer* (*GetBuffer)(struct IBufferView*); | |
169 | 169 | }; |
170 | 170 | |
171 | 171 | struct IBufferView |
175 | 175 | struct IBufferViewVtbl* pBufferVtbl; |
176 | 176 | }; |
177 | 177 | |
178 | # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This) | |
178 | # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This) | |
179 | 179 | |
180 | # define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer(This) | |
180 | # define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer((struct IBufferView*)(This)) | |
181 | 181 | |
182 | 182 | #endif |
183 | 183 |
72 | 72 | |
73 | 73 | struct IDeviceObject; |
74 | 74 | |
75 | // clang-format off | |
76 | ||
75 | 77 | struct IDeviceObjectVtbl |
76 | 78 | { |
77 | const struct DeviceObjectAttribs* (*GetDesc)(); | |
78 | Int32 (*GetUniqueID)(); | |
79 | const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*); | |
80 | Int32 (*GetUniqueID)(struct IDeviceObject*); | |
79 | 81 | }; |
82 | ||
83 | // clang-format on | |
80 | 84 | |
81 | 85 | struct IDeviceObject |
82 | 86 | { |
84 | 88 | struct IDeviceObjectVtbl* pDeviceObjectVtbl; |
85 | 89 | }; |
86 | 90 | |
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 | |
89 | 97 | |
90 | 98 | #endif |
91 | 99 |
58 | 58 | |
59 | 59 | /// Texture minification filter, see Diligent::FILTER_TYPE for details. |
60 | 60 | /// 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); | |
62 | 62 | |
63 | 63 | /// Texture magnification filter, see Diligent::FILTER_TYPE for details. |
64 | 64 | /// 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); | |
66 | 66 | |
67 | 67 | /// Mip filter, see Diligent::FILTER_TYPE for details. |
68 | 68 | /// Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR, FILTER_TYPE_ANISOTROPIC, and |
69 | 69 | /// FILTER_TYPE_COMPARISON_ANISOTROPIC are allowed. |
70 | 70 | /// 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); | |
72 | 72 | |
73 | 73 | /// Texture address mode for U coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details |
74 | 74 | /// 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); | |
76 | 76 | |
77 | 77 | /// Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details |
78 | 78 | /// 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); | |
80 | 80 | |
81 | 81 | /// Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details |
82 | 82 | /// 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); | |
84 | 84 | |
85 | 85 | /// Offset from the calculated mipmap level. For example, if a sampler calculates that a texture |
86 | 86 | /// should be sampled at mipmap level 1.2 and MipLODBias is 2.3, then the texture will be sampled at |
92 | 92 | |
93 | 93 | /// A function that compares sampled data against existing sampled data when comparsion |
94 | 94 | /// 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); | |
96 | 96 | |
97 | 97 | /// Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV, or AddressW. |
98 | 98 | /// Default value: {0,0,0,0} |
369 | 369 | |
370 | 370 | struct ITextureVtbl |
371 | 371 | { |
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*); | |
377 | 377 | }; |
378 | 378 | |
379 | 379 | // clang-format on |
382 | 382 | { |
383 | 383 | struct IObjectVtbl* pObjectVtbl; |
384 | 384 | 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 | |
395 | 399 | |
396 | 400 | #endif |
397 | 401 |
79 | 79 | struct TextureViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) |
80 | 80 | |
81 | 81 | /// 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); | |
83 | 83 | |
84 | 84 | /// View interpretation of the original texture. For instance, |
85 | 85 | /// one slice of a 2D texture array can be viewed as a 2D texture. |
86 | 86 | /// See Diligent::RESOURCE_DIMENSION for a list of texture types. |
87 | 87 | /// If default value Diligent::RESOURCE_DIM_UNDEFINED is provided, |
88 | 88 | /// 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); | |
90 | 90 | |
91 | 91 | /// View format. If default value Diligent::TEX_FORMAT_UNKNOWN is provided, |
92 | 92 | /// 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); | |
94 | 94 | |
95 | 95 | /// Most detailed mip level to use |
96 | Uint32 MostDetailedMip DEFAULT_INITIALIZER(0); | |
96 | Uint32 MostDetailedMip DEFAULT_INITIALIZER(0); | |
97 | 97 | |
98 | 98 | /// Total number of mip levels for the view of the texture. |
99 | 99 | /// Render target and depth stencil views can address only one mip level. |
100 | 100 | /// If 0 is provided, then for a shader resource view all mip levels will be |
101 | 101 | /// referenced, and for a render target or a depth stencil view, one mip level |
102 | 102 | /// will be referenced. |
103 | Uint32 NumMipLevels DEFAULT_INITIALIZER(0); | |
103 | Uint32 NumMipLevels DEFAULT_INITIALIZER(0); | |
104 | 104 | |
105 | 105 | union |
106 | 106 | { |
124 | 124 | |
125 | 125 | /// For an unordered access view, allowed access flags. See Diligent::UAV_ACCESS_FLAG |
126 | 126 | /// for details. |
127 | enum UAV_ACCESS_FLAG AccessFlags DEFAULT_INITIALIZER(UAV_ACCESS_UNSPECIFIED); | |
127 | UAV_ACCESS_FLAG AccessFlags DEFAULT_INITIALIZER(UAV_ACCESS_UNSPECIFIED); | |
128 | 128 | |
129 | 129 | /// 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); | |
131 | 131 | |
132 | 132 | #if DILIGENT_CPP_INTERFACE |
133 | 133 | |
223 | 223 | struct ITextureView; |
224 | 224 | struct ISampler; |
225 | 225 | |
226 | // clang-format off | |
227 | ||
226 | 228 | struct ITextureViewVtbl |
227 | 229 | { |
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*); | |
231 | 233 | }; |
232 | 234 | |
233 | 235 | // clang-format on |
236 | 238 | { |
237 | 239 | struct IObjectVtbl* pObjectVtbl; |
238 | 240 | 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 | |
247 | 253 | |
248 | 254 | #endif |
249 | 255 |
83 | 83 | |
84 | 84 | struct IObject; |
85 | 85 | |
86 | // clang-format off | |
87 | ||
86 | 88 | struct IObjectVtbl |
87 | 89 | { |
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*); | |
92 | 94 | }; |
95 | ||
96 | // clang-format on | |
93 | 97 | |
94 | 98 | struct IObject |
95 | 99 | { |
96 | 100 | struct IObjectVtbl* pObjectVtbl; |
97 | struct IObjectVtbl* pDeviceObjectVtbl; | |
98 | 101 | }; |
99 | 102 | |
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 | |
103 | 110 | |
104 | 111 | #endif |
105 | 112 |