Fixed Buffer, BufferView, Texture, TextureView interfaces; added C interface tests
assiduous
3 years ago
231 | 231 | |
232 | 232 | struct IBuffer; |
233 | 233 | |
234 | struct IBufferVtbl | |
234 | struct IBufferMethods | |
235 | 235 | { |
236 | 236 | void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView); |
237 | 237 | class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType); |
242 | 242 | |
243 | 243 | // clang-format on |
244 | 244 | |
245 | struct IBufferVtbl | |
246 | { | |
247 | struct IObjectMethods Object; | |
248 | struct IDeviceObjectMethods DeviceObject; | |
249 | struct IBufferMethods Buffer; | |
250 | }; | |
251 | ||
245 | 252 | struct IBuffer |
246 | 253 | { |
247 | struct IObjectVtbl* pObjectVtbl; | |
248 | struct IDeviceObjectVtbl* pDeviceObjectVtbl; | |
249 | struct IBufferVtbl* pBufferVtbl; | |
254 | struct IBufferVtbl* pVtbl; | |
250 | 255 | }; |
251 | 256 | |
252 | 257 | // clang-format off |
253 | 258 | |
254 | 259 | # define IBuffer_GetDesc(This) (const struct BufferDesc*)IDeviceObject_GetDesc(This) |
255 | 260 | |
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 | # define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((struct IBuffer*)(This), __VA_ARGS__) | |
262 | # define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__) | |
263 | # define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((struct IBuffer*)(This)) | |
264 | # define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((struct IBuffer*)(This), __VA_ARGS__) | |
265 | # define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((struct IBuffer*)(This)) | |
261 | 266 | |
262 | 267 | // clang-format on |
263 | 268 |
163 | 163 | class IBufferView; |
164 | 164 | class IBuffer; |
165 | 165 | |
166 | struct IBufferViewVtbl | |
166 | struct IBufferViewMethods | |
167 | 167 | { |
168 | 168 | class IBuffer* (*GetBuffer)(struct IBufferView*); |
169 | 169 | }; |
170 | 170 | |
171 | struct IBufferViewVtbl | |
172 | { | |
173 | struct IObjectMethods Object; | |
174 | struct IDeviceObjectMethods DeviceObject; | |
175 | struct IBufferViewMethods BufferView; | |
176 | }; | |
177 | ||
171 | 178 | struct IBufferView |
172 | 179 | { |
173 | struct IObjectVtbl* pObjectVtbl; | |
174 | struct IDeviceObjectVtbl* pDeviceObjectVtbl; | |
175 | struct IBufferViewVtbl* pBufferVtbl; | |
180 | struct IBufferViewVtbl* pVtbl; | |
176 | 181 | }; |
177 | 182 | |
178 | 183 | # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This) |
179 | 184 | |
180 | # define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer((struct IBufferView*)(This)) | |
185 | # define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((struct IBufferView*)(This)) | |
181 | 186 | |
182 | 187 | #endif |
183 | 188 |
221 | 221 | |
222 | 222 | /// The type of elements in the index buffer. |
223 | 223 | /// Allowed values: VT_UINT16 and VT_UINT32. |
224 | enum VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); | |
224 | VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); | |
225 | 225 | |
226 | 226 | /// Additional flags, see Diligent::DRAW_FLAGS. |
227 | enum DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); | |
227 | DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); | |
228 | 228 | |
229 | 229 | /// Number of instances to draw. If more than one instance is specified, |
230 | 230 | /// instanced draw call will be performed. |
283 | 283 | struct DrawIndirectAttribs |
284 | 284 | { |
285 | 285 | /// Additional flags, see Diligent::DRAW_FLAGS. |
286 | enum DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); | |
286 | DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); | |
287 | 287 | |
288 | 288 | /// State transition mode for indirect draw arguments buffer. |
289 | enum RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
289 | RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
290 | 290 | |
291 | 291 | /// Offset from the beginning of the buffer to the location of draw command attributes. |
292 | Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0); | |
292 | Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0); | |
293 | 293 | |
294 | 294 | |
295 | 295 | #if DILIGENT_CPP_INTERFACE |
322 | 322 | { |
323 | 323 | /// The type of the elements in the index buffer. |
324 | 324 | /// Allowed values: VT_UINT16 and VT_UINT32. Ignored if DrawAttribs::IsIndexed is False. |
325 | enum VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); | |
325 | VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); | |
326 | 326 | |
327 | 327 | /// Additional flags, see Diligent::DRAW_FLAGS. |
328 | enum DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); | |
328 | DRAW_FLAGS Flags DEFAULT_INITIALIZER(DRAW_FLAG_NONE); | |
329 | 329 | |
330 | 330 | /// State transition mode for indirect draw arguments buffer. |
331 | enum RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
331 | RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
332 | 332 | |
333 | 333 | /// Offset from the beginning of the buffer to the location of draw command attributes. |
334 | 334 | Uint32 IndirectDrawArgsOffset DEFAULT_INITIALIZER(0); |
404 | 404 | struct DispatchComputeIndirectAttribs |
405 | 405 | { |
406 | 406 | /// State transition mode for indirect dispatch attributes buffer. |
407 | enum RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
407 | RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
408 | 408 | |
409 | 409 | /// The offset from the beginning of the buffer to the dispatch command arguments. |
410 | 410 | Uint32 DispatchArgsByteOffset DEFAULT_INITIALIZER(0); |
435 | 435 | Uint32 SrcSlice DEFAULT_INITIALIZER(0); |
436 | 436 | |
437 | 437 | /// Source texture state transition mode, see Diligent::RESOURCE_STATE_TRANSITION_MODE. |
438 | enum RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
438 | RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
439 | 439 | |
440 | 440 | /// Mip level of the destination non-multi-sampled texture. |
441 | 441 | Uint32 DstMipLevel DEFAULT_INITIALIZER(0); |
444 | 444 | Uint32 DstSlice DEFAULT_INITIALIZER(0); |
445 | 445 | |
446 | 446 | /// Destination texture state transition mode, see Diligent::RESOURCE_STATE_TRANSITION_MODE. |
447 | enum RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
447 | RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
448 | 448 | |
449 | 449 | /// If one or both textures are typeless, specifies the type of the typeless texture. |
450 | 450 | /// If both texture formats are not typeless, in which case they must be identical, this member must be |
451 | 451 | /// either TEX_FORMAT_UNKNOWN, or match this format. |
452 | enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); | |
452 | TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); | |
453 | 453 | }; |
454 | 454 | |
455 | 455 | /// Defines allowed flags for IDeviceContext::SetVertexBuffers() function. |
580 | 580 | Uint32 DstZ DEFAULT_INITIALIZER(0); |
581 | 581 | |
582 | 582 | /// Destination texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). |
583 | enum RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
583 | RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); | |
584 | 584 | |
585 | 585 | |
586 | 586 | #if DILIGENT_CPP_INTERFACE |
74 | 74 | |
75 | 75 | // clang-format off |
76 | 76 | |
77 | struct IDeviceObjectVtbl | |
77 | struct IDeviceObjectMethods | |
78 | 78 | { |
79 | 79 | const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*); |
80 | 80 | Int32 (*GetUniqueID)(struct IDeviceObject*); |
82 | 82 | |
83 | 83 | // clang-format on |
84 | 84 | |
85 | struct IDeviceObjectVtbl | |
86 | { | |
87 | struct IObjectMethods Object; | |
88 | struct IDeviceObjectMethods DeviceObject; | |
89 | }; | |
90 | ||
85 | 91 | struct IDeviceObject |
86 | 92 | { |
87 | struct IObjectVtbl* pObjectVtbl; | |
88 | struct IDeviceObjectVtbl* pDeviceObjectVtbl; | |
93 | struct IDeviceObjectVtbl* pVtbl; | |
89 | 94 | }; |
90 | 95 | |
91 | 96 | // clang-format off |
92 | 97 | |
93 | # define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc ((struct IDeviceObject*)(This)) | |
94 | # define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID((struct IDeviceObject*)(This)) | |
98 | # define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((struct IDeviceObject*)(This)) | |
99 | # define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((struct IDeviceObject*)(This)) | |
95 | 100 | |
96 | 101 | // clang-format on |
97 | 102 |
72 | 72 | struct ShaderResourceVariableDesc |
73 | 73 | { |
74 | 74 | /// Shader stages this resources variable applies to. More than one shader stage can be specified. |
75 | enum SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN); | |
75 | SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN); | |
76 | 76 | |
77 | 77 | /// Shader variable name |
78 | 78 | const Char* Name DEFAULT_INITIALIZER(nullptr); |
96 | 96 | struct StaticSamplerDesc |
97 | 97 | { |
98 | 98 | /// Shader stages that this static sampler applies to. More than one shader stage can be specified. |
99 | enum SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN); | |
99 | SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN); | |
100 | 100 | |
101 | 101 | /// The name of the sampler itself or the name of the texture variable that |
102 | 102 | /// this static sampler is assigned to if combined texture samplers are used. |
125 | 125 | /// Default shader resource variable type. This type will be used if shader |
126 | 126 | /// variable description is not found in the Variables array |
127 | 127 | /// or if Variables == nullptr |
128 | enum SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC); | |
128 | SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC); | |
129 | 129 | |
130 | 130 | /// Number of elements in Variables array |
131 | 131 | Uint32 NumVariables DEFAULT_INITIALIZER(0); |
183 | 183 | //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue; |
184 | 184 | |
185 | 185 | /// Primitive topology type |
186 | enum PRIMITIVE_TOPOLOGY PrimitiveTopology DEFAULT_INITIALIZER(PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); | |
186 | PRIMITIVE_TOPOLOGY PrimitiveTopology DEFAULT_INITIALIZER(PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); | |
187 | 187 | |
188 | 188 | /// Number of viewports used by this pipeline |
189 | Uint8 NumViewports DEFAULT_INITIALIZER(1); | |
189 | Uint8 NumViewports DEFAULT_INITIALIZER(1); | |
190 | 190 | |
191 | 191 | /// Number of render targets in the RTVFormats member |
192 | Uint8 NumRenderTargets DEFAULT_INITIALIZER(0); | |
192 | Uint8 NumRenderTargets DEFAULT_INITIALIZER(0); | |
193 | 193 | |
194 | 194 | /// Render target formats |
195 | enum TEXTURE_FORMAT RTVFormats[8] DEFAULT_INITIALIZER({}); | |
195 | TEXTURE_FORMAT RTVFormats[8] DEFAULT_INITIALIZER({}); | |
196 | 196 | |
197 | 197 | /// Depth-stencil format |
198 | enum TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); | |
198 | TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); | |
199 | 199 | |
200 | 200 | /// Multisampling parameters |
201 | 201 | struct SampleDesc SmplDesc; |
96 | 96 | { |
97 | 97 | /// Determines traingle fill mode, see Diligent::FILL_MODE for details. |
98 | 98 | /// Default value: Diligent::FILL_MODE_SOLID. |
99 | enum FILL_MODE FillMode DEFAULT_INITIALIZER(FILL_MODE_SOLID); | |
99 | FILL_MODE FillMode DEFAULT_INITIALIZER(FILL_MODE_SOLID); | |
100 | 100 | |
101 | 101 | /// Determines traingle cull mode, see Diligent::CULL_MODE for details. |
102 | 102 | /// Default value: Diligent::CULL_MODE_BACK. |
103 | enum CULL_MODE CullMode DEFAULT_INITIALIZER(CULL_MODE_BACK); | |
103 | CULL_MODE CullMode DEFAULT_INITIALIZER(CULL_MODE_BACK); | |
104 | 104 | |
105 | 105 | /// Determines if a triangle is front- or back-facing. If this parameter is True, |
106 | 106 | /// a triangle will be considered front-facing if its vertices are counter-clockwise |
367 | 367 | struct ITexture; |
368 | 368 | struct ITextureView; |
369 | 369 | |
370 | struct ITextureVtbl | |
370 | struct ITextureMethods | |
371 | 371 | { |
372 | 372 | void (*CreateView) (struct ITexture*, const struct TextureViewDesc* ViewDesc, class ITextureView** ppView); |
373 | 373 | class ITextureView* (*GetDefaultView) (struct ITexture*, TEXTURE_VIEW_TYPE ViewType); |
378 | 378 | |
379 | 379 | // clang-format on |
380 | 380 | |
381 | struct ITextureVtbl | |
382 | { | |
383 | struct IObjectMethods Object; | |
384 | struct IDeviceObjectMethods DeviceObject; | |
385 | struct ITextureMethods Texture; | |
386 | }; | |
387 | ||
381 | 388 | struct ITexture |
382 | 389 | { |
383 | struct IObjectVtbl* pObjectVtbl; | |
384 | struct IDeviceObjectVtbl* pDeviceObjectVtbl; | |
385 | struct ITextureVtbl* pTextureVtbl; | |
390 | struct ITextureVtbl* pVtbl; | |
386 | 391 | }; |
387 | 392 | |
388 | 393 | // clang-format off |
389 | 394 | |
390 | 395 | # define ITexture_GetDesc(This) (const struct TextureDesc*)IDeviceObject_GetDesc(This) |
391 | 396 | |
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 | # define ITexture_CreateView(This, ...) (This)->pVtbl->Texture.CreateView ((struct ITexture*)(This), __VA_ARGS__) | |
398 | # define ITexture_GetDefaultView(This, ...) (This)->pVtbl->Texture.GetDefaultView ((struct ITexture*)(This), __VA_ARGS__) | |
399 | # define ITexture_GetNativeHandle(This) (This)->pVtbl->Texture.GetNativeHandle((struct ITexture*)(This)) | |
400 | # define ITexture_SetState(This, ...) (This)->pVtbl->Texture.SetState ((struct ITexture*)(This), __VA_ARGS__) | |
401 | # define ITexture_GetState(This) (This)->pVtbl->Texture.GetState ((struct ITexture*)(This)) | |
397 | 402 | |
398 | 403 | // clang-format on |
399 | 404 |
225 | 225 | |
226 | 226 | // clang-format off |
227 | 227 | |
228 | struct ITextureViewVtbl | |
228 | struct ITextureViewMethods | |
229 | 229 | { |
230 | 230 | void (*SetSampler)(struct ITextureView*, class ISampler* pSampler); |
231 | 231 | class ISampler* (*GetSampler)(struct ITextureView*); |
234 | 234 | |
235 | 235 | // clang-format on |
236 | 236 | |
237 | struct ITextureViewVtbl | |
238 | { | |
239 | struct IObjectMethods Object; | |
240 | struct IDeviceObjectMethods DeviceObject; | |
241 | struct ITextureViewMethods TextureView; | |
242 | }; | |
243 | ||
237 | 244 | struct ITextureView |
238 | 245 | { |
239 | struct IObjectVtbl* pObjectVtbl; | |
240 | struct IDeviceObjectVtbl* pDeviceObjectVtbl; | |
241 | struct ITextureViewVtbl* pTextureViewVtbl; | |
246 | struct ITextureViewVtbl* pVtbl; | |
242 | 247 | }; |
243 | 248 | |
244 | 249 | # define ITextureView_GetDesc(This) (const struct TextureViewDesc*)IDeviceObject_GetDesc(This) |
245 | 250 | |
246 | 251 | // clang-format off |
247 | 252 | |
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)) | |
253 | # define ITextureView_SetSampler(This, ...) (This)->pVtbl->TextureView.SetSampler((struct ITextureView*)(This), __VA_ARGS__) | |
254 | # define ITextureView_GetSampler(This) (This)->pVtbl->TextureView.GetSampler((struct ITextureView*)(This)) | |
255 | # define ITextureView_GetTexture(This) (This)->pVtbl->TextureView.GetTexture((struct ITextureView*)(This)) | |
251 | 256 | |
252 | 257 | // clang-format on |
253 | 258 |
85 | 85 | |
86 | 86 | // clang-format off |
87 | 87 | |
88 | struct IObjectVtbl | |
88 | struct IObjectMethods | |
89 | 89 | { |
90 | 90 | void (*QueryInterface) (struct IObject*, const struct INTERFACE_ID* IID, struct IObject** ppInterface); |
91 | 91 | ReferenceCounterValueType (*AddRef) (struct IObject*); |
93 | 93 | class IReferenceCounters* (*GetReferenceCounters)(struct IObject*); |
94 | 94 | }; |
95 | 95 | |
96 | struct IObjectVtbl | |
97 | { | |
98 | struct IObjectMethods Object; | |
99 | }; | |
100 | ||
96 | 101 | // clang-format on |
97 | 102 | |
98 | 103 | struct IObject |
99 | 104 | { |
100 | struct IObjectVtbl* pObjectVtbl; | |
105 | struct IObjectVtbl* pVtbl; | |
101 | 106 | }; |
102 | 107 | |
103 | 108 | // clang-format off |
104 | 109 | |
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)) | |
110 | # define IObject_QueryInterface(This, ...) (This)->pVtbl->Object.QueryInterface((struct IObject*)(This), __VA_ARGS__) | |
111 | # define IObject_AddRef(This, ...) (This)->pVtbl->Object.AddRef ((struct IObject*)(This), __VA_ARGS__) | |
112 | # define IObject_Release(This) (This)->pVtbl->Object.Release ((struct IObject*)(This)) | |
108 | 113 | |
109 | 114 | // clang-format on |
110 | 115 |
5 | 5 | file(GLOB COMMON_INCLUDE LIST_DIRECTORIES false include/*) |
6 | 6 | file(GLOB INLINE_SHADERS LIST_DIRECTORIES false include/InlineShaders/*) |
7 | 7 | file(GLOB_RECURSE SHADERS LIST_DIRECTORIES false assets/shaders/*.*) |
8 | file(GLOB C_INTERFACE_SOURCE LIST_DIRECTORIES false src/c_interface/*) | |
8 | 9 | |
9 | 10 | set_source_files_properties(${SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None") |
10 | 11 | |
11 | set(SOURCE ${COMMON_SOURCE}) | |
12 | set(SOURCE ${COMMON_SOURCE} ${C_INTERFACE_SOURCE}) | |
12 | 13 | set(INCLUDE ${COMMON_INCLUDE}) |
13 | 14 | |
14 | 15 | if(NOT GL_SUPPORTED AND NOT GLES_SUPPORTED) |
46 | 46 | |
47 | 47 | #include "gtest/gtest.h" |
48 | 48 | |
49 | extern "C" | |
50 | { | |
51 | int TestBufferCInterface(void* pBuffer); | |
52 | int TestBufferViewCInterface(void* pView); | |
53 | } | |
54 | ||
49 | 55 | using namespace Diligent; |
50 | 56 | using namespace Diligent::Testing; |
51 | 57 | |
176 | 182 | pBuffer->CreateView(ViewDesc, &pBufferSRV); |
177 | 183 | EXPECT_NE(pBufferSRV, nullptr) << GetObjectDescString(BuffDesc); |
178 | 184 | |
185 | EXPECT_EQ(TestBufferViewCInterface(pBufferSRV.RawPtr()), 0); | |
186 | ||
179 | 187 | ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; |
180 | 188 | RefCntAutoPtr<IBufferView> pBufferUAV; |
181 | 189 | pBuffer->CreateView(ViewDesc, &pBufferUAV); |
182 | 190 | EXPECT_NE(pBufferUAV, nullptr) << GetObjectDescString(BuffDesc); |
183 | 191 | |
184 | 192 | pCreateObjFromNativeRes->CreateBuffer(pBuffer); |
193 | ||
194 | EXPECT_EQ(TestBufferCInterface(pBuffer.RawPtr()), 0); | |
185 | 195 | } |
186 | 196 | |
187 | 197 | TEST_F(BufferCreationTest, CreateStructuedBuffer) |
52 | 52 | using namespace Diligent; |
53 | 53 | using namespace Diligent::Testing; |
54 | 54 | |
55 | extern "C" | |
56 | { | |
57 | int TestTextureCInterface(void* pTexture); | |
58 | int TestTextureViewCInterface(void* pView, void* pSampler); | |
59 | } | |
60 | ||
55 | 61 | namespace |
56 | 62 | { |
57 | 63 | |
102 | 108 | |
103 | 109 | default: UNEXPECTED("Unexpected device type"); |
104 | 110 | } |
111 | ||
112 | pDevice->CreateSampler(SamplerDesc{}, &pSampler); | |
105 | 113 | } |
106 | 114 | |
107 | 115 | static void TearDownTestSuite() |
108 | 116 | { |
109 | 117 | pCreateObjFromNativeRes.reset(); |
118 | pSampler.Release(); | |
110 | 119 | TestingEnvironment::GetInstance()->Reset(); |
111 | 120 | } |
112 | 121 | |
295 | 304 | RefCntAutoPtr<ITextureView> pSRV; |
296 | 305 | pTestTex->CreateView(ViewDesc, &pSRV); |
297 | 306 | EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); |
307 | ||
308 | EXPECT_EQ(TestTextureCInterface(pTestTex), 0); | |
309 | EXPECT_EQ(TestTextureViewCInterface(pSRV.RawPtr(), pSampler.RawPtr()), 0); | |
298 | 310 | } |
299 | 311 | |
300 | 312 | // RTV, DSV & UAV can reference only one mip level |
518 | 530 | } |
519 | 531 | |
520 | 532 | static std::unique_ptr<CreateObjFromNativeResTestBase> pCreateObjFromNativeRes; |
533 | static RefCntAutoPtr<ISampler> pSampler; | |
521 | 534 | }; |
522 | 535 | |
523 | 536 | std::unique_ptr<CreateObjFromNativeResTestBase> TextureCreationTest::pCreateObjFromNativeRes; |
537 | RefCntAutoPtr<ISampler> TextureCreationTest::pSampler; | |
524 | 538 | |
525 | 539 | TEST_P(TextureCreationTest, CreateTexture) |
526 | 540 | { |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #include "BufferView.h" | |
28 | ||
29 | int TestObjectCInterface(struct IObject* pObject); | |
30 | int TestDeviceObjectCInterface(struct IDeviceObject* pDeviceObject); | |
31 | ||
32 | int TestBufferViewCInterface(struct IBufferView* pView) | |
33 | { | |
34 | struct IObject* pObject = NULL; | |
35 | ReferenceCounterValueType RefCnt1 = 0, RefCnt2 = 0; | |
36 | ||
37 | struct DeviceObjectAttribs Desc; | |
38 | Int32 UniqueId = 0; | |
39 | ||
40 | struct BufferViewDesc ViewDesc; | |
41 | class IBuffer* pBuffer = NULL; | |
42 | ||
43 | int num_errors = | |
44 | TestObjectCInterface((struct IObject*)pView) + | |
45 | TestDeviceObjectCInterface((struct IDeviceObject*)pView); | |
46 | ||
47 | IObject_QueryInterface(pView, &IID_Unknown, &pObject); | |
48 | if (pObject != NULL) | |
49 | IObject_Release(pObject); | |
50 | else | |
51 | ++num_errors; | |
52 | ||
53 | RefCnt1 = IObject_AddRef(pView); | |
54 | if (RefCnt1 <= 0) | |
55 | ++num_errors; | |
56 | RefCnt2 = IObject_Release(pView); | |
57 | if (RefCnt2 <= 0) | |
58 | ++num_errors; | |
59 | if (RefCnt2 != RefCnt1 - 1) | |
60 | ++num_errors; | |
61 | ||
62 | Desc = *IDeviceObject_GetDesc(pView); | |
63 | if (Desc.Name == NULL) | |
64 | ++num_errors; | |
65 | ||
66 | UniqueId = IDeviceObject_GetUniqueID(pView); | |
67 | if (UniqueId == 0) | |
68 | ++num_errors; | |
69 | ||
70 | ||
71 | pBuffer = IBufferView_GetBuffer(pView); | |
72 | if (pBuffer == NULL) | |
73 | ++num_errors; | |
74 | ||
75 | ViewDesc = *IBufferView_GetDesc(pView); | |
76 | if (ViewDesc.ByteWidth == 0) | |
77 | ++num_errors; | |
78 | ||
79 | return num_errors; | |
80 | } |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #include "Buffer.h" | |
28 | ||
29 | int TestObjectCInterface(struct IObject* pObject); | |
30 | int TestDeviceObjectCInterface(struct IDeviceObject* pDeviceObject); | |
31 | ||
32 | int TestBufferCInterface(struct IBuffer* pBuffer) | |
33 | { | |
34 | struct IObject* pObject = NULL; | |
35 | ReferenceCounterValueType RefCnt1 = 0, RefCnt2 = 0; | |
36 | ||
37 | struct DeviceObjectAttribs Desc; | |
38 | Int32 UniqueId = 0; | |
39 | ||
40 | struct BufferDesc BuffDesc; | |
41 | struct IBufferView * pView0 = NULL, *pView1 = NULL; | |
42 | struct BufferViewDesc ViewDesc; | |
43 | void* NativeHanlde; | |
44 | RESOURCE_STATE State = RESOURCE_STATE_CONSTANT_BUFFER; | |
45 | ||
46 | int num_errors = | |
47 | TestObjectCInterface((struct IObject*)pBuffer) + | |
48 | TestDeviceObjectCInterface((struct IDeviceObject*)pBuffer); | |
49 | ||
50 | IObject_QueryInterface(pBuffer, &IID_Unknown, &pObject); | |
51 | if (pObject != NULL) | |
52 | IObject_Release(pObject); | |
53 | else | |
54 | ++num_errors; | |
55 | ||
56 | RefCnt1 = IObject_AddRef(pBuffer); | |
57 | if (RefCnt1 <= 0) | |
58 | ++num_errors; | |
59 | RefCnt2 = IObject_Release(pBuffer); | |
60 | if (RefCnt2 <= 0) | |
61 | ++num_errors; | |
62 | if (RefCnt2 != RefCnt1 - 1) | |
63 | ++num_errors; | |
64 | ||
65 | Desc = *IDeviceObject_GetDesc(pBuffer); | |
66 | if (Desc.Name == NULL) | |
67 | ++num_errors; | |
68 | ||
69 | UniqueId = IDeviceObject_GetUniqueID(pBuffer); | |
70 | if (UniqueId == 0) | |
71 | ++num_errors; | |
72 | ||
73 | BuffDesc = *IBuffer_GetDesc(pBuffer); | |
74 | if (BuffDesc._DeviceObjectAttribs.Name == NULL) | |
75 | ++num_errors; | |
76 | ||
77 | ViewDesc._DeviceObjectAttribs.Name = "Test SRV"; | |
78 | ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; | |
79 | ViewDesc.ByteOffset = 32; | |
80 | ViewDesc.ByteWidth = 0; | |
81 | ViewDesc.Format.NumComponents = 4; | |
82 | ViewDesc.Format.ValueType = VT_FLOAT32; | |
83 | ViewDesc.Format.IsNormalized = false; | |
84 | IBuffer_CreateView(pBuffer, &ViewDesc, &pView0); | |
85 | if (pView0 != NULL) | |
86 | IObject_Release(pView0); | |
87 | else | |
88 | ++num_errors; | |
89 | ||
90 | pView1 = IBuffer_GetDefaultView(pBuffer, BUFFER_VIEW_SHADER_RESOURCE); | |
91 | ||
92 | NativeHanlde = IBuffer_GetNativeHandle(pBuffer); | |
93 | if (NativeHanlde == NULL) | |
94 | ++num_errors; | |
95 | ||
96 | State = IBuffer_GetState(pBuffer); | |
97 | IBuffer_SetState(pBuffer, State); | |
98 | ||
99 | return num_errors; | |
100 | } |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #include "DeviceObject.h" | |
28 | ||
29 | int TestDeviceObjectCInterface(struct IDeviceObject* pDeviceObject) | |
30 | { | |
31 | struct DeviceObjectAttribs Desc; | |
32 | Int32 UniqueId = 0; | |
33 | ||
34 | int num_errors = 0; | |
35 | ||
36 | Desc = *IDeviceObject_GetDesc(pDeviceObject); | |
37 | if (Desc.Name == NULL) | |
38 | ++num_errors; | |
39 | ||
40 | UniqueId = IDeviceObject_GetUniqueID(pDeviceObject); | |
41 | if (UniqueId == 0) | |
42 | ++num_errors; | |
43 | ||
44 | return num_errors; | |
45 | } |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #include "Object.h" | |
28 | ||
29 | int TestObjectCInterface(struct IObject* pObject) | |
30 | { | |
31 | struct IObject* pObject1 = NULL; | |
32 | ReferenceCounterValueType RefCnt1 = 0, RefCnt2 = 0; | |
33 | ||
34 | int num_errors = 0; | |
35 | ||
36 | IObject_QueryInterface(pObject, &IID_Unknown, &pObject1); | |
37 | if (pObject1 != NULL) | |
38 | IObject_Release(pObject1); | |
39 | else | |
40 | ++num_errors; | |
41 | ||
42 | RefCnt1 = IObject_AddRef(pObject); | |
43 | if (RefCnt1 <= 0) | |
44 | ++num_errors; | |
45 | RefCnt2 = IObject_Release(pObject); | |
46 | if (RefCnt2 <= 0) | |
47 | ++num_errors; | |
48 | if (RefCnt2 != RefCnt1 - 1) | |
49 | ++num_errors; | |
50 | ||
51 | return num_errors; | |
52 | } |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #include "TextureView.h" | |
28 | ||
29 | int TestObjectCInterface(struct IObject* pObject); | |
30 | int TestDeviceObjectCInterface(struct IDeviceObject* pDeviceObject); | |
31 | ||
32 | int TestTextureViewCInterface(struct ITextureView* pView, struct ISampler* pSampler) | |
33 | { | |
34 | struct IObject* pObject = NULL; | |
35 | ReferenceCounterValueType RefCnt1 = 0, RefCnt2 = 0; | |
36 | ||
37 | struct DeviceObjectAttribs Desc; | |
38 | Int32 UniqueId = 0; | |
39 | ||
40 | struct TextureViewDesc ViewDesc; | |
41 | class ITexture* pTexture = NULL; | |
42 | ||
43 | int num_errors = | |
44 | TestObjectCInterface((struct IObject*)pView) + | |
45 | TestDeviceObjectCInterface((struct IDeviceObject*)pView); | |
46 | ||
47 | IObject_QueryInterface(pView, &IID_Unknown, &pObject); | |
48 | if (pObject != NULL) | |
49 | IObject_Release(pObject); | |
50 | else | |
51 | ++num_errors; | |
52 | ||
53 | RefCnt1 = IObject_AddRef(pView); | |
54 | if (RefCnt1 <= 0) | |
55 | ++num_errors; | |
56 | RefCnt2 = IObject_Release(pView); | |
57 | if (RefCnt2 <= 0) | |
58 | ++num_errors; | |
59 | if (RefCnt2 != RefCnt1 - 1) | |
60 | ++num_errors; | |
61 | ||
62 | Desc = *IDeviceObject_GetDesc(pView); | |
63 | if (Desc.Name == NULL) | |
64 | ++num_errors; | |
65 | ||
66 | UniqueId = IDeviceObject_GetUniqueID(pView); | |
67 | if (UniqueId == 0) | |
68 | ++num_errors; | |
69 | ||
70 | ||
71 | pTexture = ITextureView_GetTexture(pView); | |
72 | if (pTexture == NULL) | |
73 | ++num_errors; | |
74 | ||
75 | ViewDesc = *ITextureView_GetDesc(pView); | |
76 | if (ViewDesc.ViewType != TEXTURE_VIEW_SHADER_RESOURCE) | |
77 | ++num_errors; | |
78 | ||
79 | ITextureView_SetSampler(pView, pSampler); | |
80 | ||
81 | return num_errors; | |
82 | } |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #include "Texture.h" | |
28 | ||
29 | int TestObjectCInterface(struct IObject* pObject); | |
30 | int TestDeviceObjectCInterface(struct IDeviceObject* pDeviceObject); | |
31 | ||
32 | struct ISampler; | |
33 | ||
34 | int TestTextureCInterface(struct ITexture* pTexture) | |
35 | { | |
36 | struct IObject* pObject = NULL; | |
37 | ReferenceCounterValueType RefCnt1 = 0, RefCnt2 = 0; | |
38 | ||
39 | struct DeviceObjectAttribs Desc; | |
40 | Int32 UniqueId = 0; | |
41 | ||
42 | struct TextureDesc TexDesc; | |
43 | struct ITextureView * pView0 = NULL, *pView1 = NULL; | |
44 | struct TextureViewDesc ViewDesc; | |
45 | void* NativeHanlde; | |
46 | RESOURCE_STATE State = RESOURCE_STATE_SHADER_RESOURCE; | |
47 | ||
48 | int num_errors = | |
49 | TestObjectCInterface((struct IObject*)pTexture) + | |
50 | TestDeviceObjectCInterface((struct IDeviceObject*)pTexture); | |
51 | ||
52 | IObject_QueryInterface(pTexture, &IID_Unknown, &pObject); | |
53 | if (pObject != NULL) | |
54 | IObject_Release(pObject); | |
55 | else | |
56 | ++num_errors; | |
57 | ||
58 | RefCnt1 = IObject_AddRef(pTexture); | |
59 | if (RefCnt1 <= 0) | |
60 | ++num_errors; | |
61 | RefCnt2 = IObject_Release(pTexture); | |
62 | if (RefCnt2 <= 0) | |
63 | ++num_errors; | |
64 | if (RefCnt2 != RefCnt1 - 1) | |
65 | ++num_errors; | |
66 | ||
67 | Desc = *IDeviceObject_GetDesc(pTexture); | |
68 | if (Desc.Name == NULL) | |
69 | ++num_errors; | |
70 | ||
71 | UniqueId = IDeviceObject_GetUniqueID(pTexture); | |
72 | if (UniqueId == 0) | |
73 | ++num_errors; | |
74 | ||
75 | TexDesc = *ITexture_GetDesc(pTexture); | |
76 | if (TexDesc._DeviceObjectAttribs.Name == NULL) | |
77 | ++num_errors; | |
78 | ||
79 | memset(&ViewDesc, 0, sizeof(ViewDesc)); | |
80 | ViewDesc._DeviceObjectAttribs.Name = "Test SRV"; | |
81 | ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; | |
82 | ITexture_CreateView(pTexture, &ViewDesc, &pView0); | |
83 | if (pView0 != NULL) | |
84 | IObject_Release(pView0); | |
85 | else | |
86 | ++num_errors; | |
87 | ||
88 | pView1 = ITexture_GetDefaultView(pTexture, TEXTURE_VIEW_SHADER_RESOURCE); | |
89 | if (pView1 == NULL) | |
90 | ++num_errors; | |
91 | ||
92 | NativeHanlde = ITexture_GetNativeHandle(pTexture); | |
93 | if (NativeHanlde == NULL) | |
94 | ++num_errors; | |
95 | ||
96 | State = ITexture_GetState(pTexture); | |
97 | ITexture_SetState(pTexture, State); | |
98 | ||
99 | return num_errors; | |
100 | } |