RavEngine
Loading...
Searching...
No Matches
NvFlowContext.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2014-2022 NVIDIA Corporation. All rights reserved.
26
27#ifndef NV_FLOW_CONTEXT_H
28#define NV_FLOW_CONTEXT_H
29
30#include "NvFlowReflect.h"
31
33
34struct NvFlowContext;
35typedef struct NvFlowContext NvFlowContext;
36
37NV_FLOW_REFLECT_STRUCT_OPAQUE_IMPL(NvFlowContext)
38
39typedef enum NvFlowTextureBindingType
40{
41 eNvFlowTextureBindingType_separateSampler = 0,
42 eNvFlowTextureBindingType_combinedSampler = 1,
43
44 eNvFlowTextureBindingType_count = 2,
45 eNvFlowTextureBindingType_maxEnum = 0x7FFFFFFF
46}NvFlowTextureBindingType;
47
48typedef struct NvFlowContextConfig
49{
50 NvFlowContextApi api;
51 NvFlowTextureBindingType textureBinding;
53
54typedef struct NvFlowBytecode
55{
56 const void* data;
57 NvFlowUint64 sizeInBytes;
59
60struct NvFlowBuffer;
61typedef struct NvFlowBuffer NvFlowBuffer;
62
63struct NvFlowBufferTransient;
64typedef struct NvFlowBufferTransient NvFlowBufferTransient;
65
66struct NvFlowBufferAcquire;
67typedef struct NvFlowBufferAcquire NvFlowBufferAcquire;
68
69typedef enum NvFlowMemoryType
70{
71 eNvFlowMemoryType_device = 0,
72 eNvFlowMemoryType_upload = 1,
73 eNvFlowMemoryType_readback = 2,
74
75 eNvFlowMemoryType_maxEnum = 0x7FFFFFFF
76}NvFlowMemoryType;
77
78typedef NvFlowUint NvFlowBufferUsageFlags;
79
80typedef enum NvFlowBufferUsage
81{
82 eNvFlowBufferUsage_constantBuffer = 0x01,
83 eNvFlowBufferUsage_structuredBuffer = 0x02,
84 eNvFlowBufferUsage_buffer = 0x04,
85 eNvFlowBufferUsage_rwStructuredBuffer = 0x08,
86 eNvFlowBufferUsage_rwBuffer = 0x10,
87
88 eNvFlowBufferUsage_indirectBuffer = 0x20,
89 eNvFlowBufferUsage_bufferCopySrc = 0x40,
90 eNvFlowBufferUsage_bufferCopyDst = 0x80,
91
92 eNvFlowBufferUsage_maxEnum = 0x7FFFFFFF
93}NvFlowBufferUsage;
94
95typedef struct NvFlowBufferDesc
96{
97 NvFlowBufferUsageFlags usageFlags;
98 NvFlowFormat format;
99 NvFlowUint structureStride;
100 NvFlowUint64 sizeInBytes;
102
103struct NvFlowTexture;
104typedef struct NvFlowTexture NvFlowTexture;
105
106struct NvFlowTextureTransient;
107typedef struct NvFlowTextureTransient NvFlowTextureTransient;
108
109struct NvFlowTextureAcquire;
110typedef struct NvFlowTextureAcquire NvFlowTextureAcquire;
111
112struct NvFlowSampler;
113typedef struct NvFlowSampler NvFlowSampler;
114
115typedef enum NvFlowTextureType
116{
117 eNvFlowTextureType_1d = 0,
118 eNvFlowTextureType_2d = 1,
119 eNvFlowTextureType_3d = 2,
120
121 eNvFlowTextureType_maxEnum = 0x7FFFFFFF
122}NvFlowTextureType;
123
124typedef NvFlowUint NvFlowTextureUsageFlags;
125
126typedef enum NvFlowTextureUsage
127{
128 eNvFlowTextureUsage_texture = 0x01,
129 eNvFlowTextureUsage_rwTexture = 0x02,
130 eNvFlowTextureUsage_textureCopySrc = 0x04,
131 eNvFlowTextureUsage_textureCopyDst = 0x08,
132
133 eNvFlowTextureUsage_maxEnum = 0x7FFFFFFF
134}NvFlowTextureUsage;
135
136typedef struct NvFlowTextureDesc
137{
138 NvFlowTextureType textureType;
139 NvFlowTextureUsageFlags usageFlags;
140 NvFlowFormat format;
141 NvFlowUint width;
142 NvFlowUint height;
143 NvFlowUint depth;
144 NvFlowUint mipLevels;
145 NvFlowFloat4 optimizedClearValue;
147
148typedef enum NvFlowSamplerAddressMode
149{
150 eNvFlowSamplerAddressMode_wrap = 0,
151 eNvFlowSamplerAddressMode_clamp = 1,
152 eNvFlowSamplerAddressMode_mirror = 2,
153 eNvFlowSamplerAddressMode_border = 3,
154
155 eNvFlowSamplerAddressMode_count = 4,
156 eNvFlowSamplerAddressMode_maxEnum = 0x7FFFFFFF
157}NvFlowSamplerAddressMode;
158
159typedef enum NvFlowSamplerFilterMode
160{
161 eNvFlowSamplerFilterMode_point = 0,
162 eNvFlowSamplerFilterMode_linear = 1,
163
164 eNvFlowSamplerFilterMode_count = 2,
165 eNvFlowSamplerFilterMode_maxEnum = 0x7FFFFFFF
166}NvFlowSamplerFilterMode;
167
168typedef struct NvFlowSamplerDesc
169{
170 NvFlowSamplerAddressMode addressModeU;
171 NvFlowSamplerAddressMode addressModeV;
172 NvFlowSamplerAddressMode addressModeW;
173 NvFlowSamplerFilterMode filterMode;
175
176typedef enum NvFlowDescriptorType
177{
178 eNvFlowDescriptorType_unknown = 0,
179
181 eNvFlowDescriptorType_constantBuffer = 1, // HLSL register b
182 eNvFlowDescriptorType_structuredBuffer = 2, // HLSL register t
183 eNvFlowDescriptorType_buffer = 3, // HLSL register t
184 eNvFlowDescriptorType_texture = 4, // HLSL register t
185 eNvFlowDescriptorType_sampler = 5, // HLSL register s
186 eNvFlowDescriptorType_rwStructuredBuffer = 6, // HLSL register u
187 eNvFlowDescriptorType_rwBuffer = 7, // HLSL register u
188 eNvFlowDescriptorType_rwTexture = 8, // HLSL register u
189
191 eNvFlowDescriptorType_textureSampler = 9, // Vulkan only
192
194 eNvFlowDescriptorType_indirectBuffer = 10, // No register
195 eNvFlowDescriptorType_bufferCopySrc = 11, // No register
196 eNvFlowDescriptorType_bufferCopyDst = 12, // No register
197 eNvFlowDescriptorType_textureCopySrc = 13, // No register
198 eNvFlowDescriptorType_textureCopyDst = 14, // No register
199
200 eNvFlowDescriptorType_count = 15,
201 eNvFlowDescriptorType_maxEnum = 0x7FFFFFFF
202}NvFlowDescriptorType;
203
204typedef struct NvFlowResource
205{
206 NvFlowBufferTransient* bufferTransient;
207 NvFlowTextureTransient* textureTransient;
208 NvFlowSampler* sampler;
210
211typedef enum NvFlowRegisterHlsl
212{
213 eNvFlowRegisterHlsl_unknown = 0,
214 eNvFlowRegisterHlsl_b = 1,
215 eNvFlowRegisterHlsl_t = 2,
216 eNvFlowRegisterHlsl_s = 3,
217 eNvFlowRegisterHlsl_u = 4,
218
219 eNvFlowRegisterHlsl_count = 5,
220 eNvFlowRegisterHlsl_maxEnum = 0x7FFFFFFF
221}NvFlowRegisterHlsl;
222
224{
225 NvFlowRegisterHlsl registerHlsl;
226 NvFlowUint registerIndex;
227 NvFlowUint space;
229
231{
232 NvFlowUint binding;
233 NvFlowUint arrayIndex;
234 NvFlowUint set;
236
242
244{
245 NvFlowDescriptorType type;
248
250{
251 NvFlowRegisterHlsl registerHlsl;
252 NvFlowUint registerBegin;
253 NvFlowUint numRegisters;
254 NvFlowUint space;
256
258{
259 NvFlowUint binding;
260 NvFlowUint descriptorCount;
261 NvFlowUint set;
263
269
270typedef struct NvFlowBindingDesc
271{
272 NvFlowDescriptorType type;
273 NvFlowBindingDescUnion bindingDesc;
275
276struct NvFlowComputePipeline;
277typedef struct NvFlowComputePipeline NvFlowComputePipeline;
278
280{
281 NvFlowUint numBindingDescs;
282 NvFlowBindingDesc* bindingDescs;
283
284 NvFlowBytecode bytecode;
286
288{
289 NvFlowComputePipeline* pipeline;
290 NvFlowUint3 gridDim;
291
292 NvFlowUint numDescriptorWrites;
293 const NvFlowDescriptorWrite* descriptorWrites;
294 const NvFlowResource* resources;
295
296 const char* debugLabel;
298
300{
301 NvFlowUint64 srcOffset;
302 NvFlowUint64 dstOffset;
303 NvFlowUint64 numBytes;
304
305 NvFlowBufferTransient* src;
306 NvFlowBufferTransient* dst;
307
308 const char* debugLabel;
310
312{
313 NvFlowUint64 bufferOffset;
314 NvFlowUint bufferRowPitch;
315 NvFlowUint bufferDepthPitch;
316
317 NvFlowUint textureMipLevel;
318 NvFlowUint3 textureOffset;
319 NvFlowUint3 textureExtent;
320
321 NvFlowBufferTransient* src;
322 NvFlowTextureTransient* dst;
323
324 const char* debugLabel;
326
328{
329 NvFlowUint64 bufferOffset;
330 NvFlowUint bufferRowPitch;
331 NvFlowUint bufferDepthPitch;
332
333 NvFlowUint textureMipLevel;
334 NvFlowUint3 textureOffset;
335 NvFlowUint3 textureExtent;
336
337 NvFlowTextureTransient* src;
338 NvFlowBufferTransient* dst;
339
340 const char* debugLabel;
342
344{
345 NvFlowUint srcMipLevel;
346 NvFlowUint3 srcOffset;
347
348 NvFlowUint dstMipLevel;
349 NvFlowUint3 dstOffset;
350
351 NvFlowUint3 extent;
352
353 NvFlowTextureTransient* src;
354 NvFlowTextureTransient* dst;
355
356 const char* debugLabel;
358
359typedef void(*NvFlowContextThreadPoolTask_t)(NvFlowUint taskIdx, NvFlowUint threadIdx, void* sharedMem, void* userdata);
360
362{
363 NV_FLOW_REFLECT_INTERFACE();
364
365 void(NV_FLOW_ABI* getContextConfig)(NvFlowContext* context, NvFlowContextConfig* config);
366
367 NvFlowUint64(NV_FLOW_ABI* getCurrentFrame)(NvFlowContext* context);
368
369 NvFlowUint64(NV_FLOW_ABI* getLastFrameCompleted)(NvFlowContext* context);
370
371 NvFlowUint64(NV_FLOW_ABI* getCurrentGlobalFrame)(NvFlowContext* context);
372
373 NvFlowUint64(NV_FLOW_ABI* getLastGlobalFrameCompleted)(NvFlowContext* context);
374
375 NvFlowLogPrint_t(NV_FLOW_ABI* getLogPrint)(NvFlowContext* context);
376
377
378 void(NV_FLOW_ABI* executeTasks)(NvFlowContext* context, NvFlowUint taskCount, NvFlowUint taskGranularity, NvFlowContextThreadPoolTask_t task, void* userdata);
379
380
381 NvFlowBuffer*(NV_FLOW_ABI* createBuffer)(NvFlowContext* context, NvFlowMemoryType memoryType, const NvFlowBufferDesc* desc);
382
383 void(NV_FLOW_ABI* destroyBuffer)(NvFlowContext* context, NvFlowBuffer* buffer);
384
385 NvFlowBufferTransient*(NV_FLOW_ABI* getBufferTransient)(NvFlowContext* context, const NvFlowBufferDesc* desc);
386
387 NvFlowBufferTransient*(NV_FLOW_ABI* registerBufferAsTransient)(NvFlowContext* context, NvFlowBuffer* buffer);
388
389 NvFlowBufferAcquire*(NV_FLOW_ABI* enqueueAcquireBuffer)(NvFlowContext* context, NvFlowBufferTransient* buffer);
390
391 NvFlowBool32(NV_FLOW_ABI* getAcquiredBuffer)(NvFlowContext* context, NvFlowBufferAcquire* acquire, NvFlowBuffer** outBuffer);
392
393 void*(NV_FLOW_ABI* mapBuffer)(NvFlowContext* context, NvFlowBuffer* buffer);
394
395 void(NV_FLOW_ABI* unmapBuffer)(NvFlowContext* context, NvFlowBuffer* buffer);
396
397 NvFlowBufferTransient*(NV_FLOW_ABI* getBufferTransientById)(NvFlowContext* context, NvFlowUint64 bufferId);
398
399
400 NvFlowTexture*(NV_FLOW_ABI* createTexture)(NvFlowContext* context, const NvFlowTextureDesc* desc);
401
402 void(NV_FLOW_ABI* destroyTexture)(NvFlowContext* context, NvFlowTexture* texture);
403
404 NvFlowTextureTransient*(NV_FLOW_ABI* getTextureTransient)(NvFlowContext* context, const NvFlowTextureDesc* desc);
405
406 NvFlowTextureTransient*(NV_FLOW_ABI* registerTextureAsTransient)(NvFlowContext* context, NvFlowTexture* texture);
407
408 NvFlowTextureAcquire*(NV_FLOW_ABI* enqueueAcquireTexture)(NvFlowContext* context, NvFlowTextureTransient* texture);
409
410 NvFlowBool32(NV_FLOW_ABI* getAcquiredTexture)(NvFlowContext* context, NvFlowTextureAcquire* acquire, NvFlowTexture** outTexture);
411
412 NvFlowTextureTransient*(NV_FLOW_ABI* getTextureTransientById)(NvFlowContext* context, NvFlowUint64 textureId);
413
414
415 NvFlowSampler*(NV_FLOW_ABI* createSampler)(NvFlowContext* context, const NvFlowSamplerDesc* desc);
416
417 NvFlowSampler*(NV_FLOW_ABI* getDefaultSampler)(NvFlowContext* context);
418
419 void(NV_FLOW_ABI* destroySampler)(NvFlowContext* context, NvFlowSampler* sampler);
420
421
422 NvFlowComputePipeline*(NV_FLOW_ABI* createComputePipeline)(NvFlowContext* context, const NvFlowComputePipelineDesc* desc);
423
424 void(NV_FLOW_ABI* destroyComputePipeline)(NvFlowContext* context, NvFlowComputePipeline* pipeline);
425
426
427 void(NV_FLOW_ABI* addPassCompute)(NvFlowContext* context, const NvFlowPassComputeParams* params);
428
429 void(NV_FLOW_ABI* addPassCopyBuffer)(NvFlowContext* context, const NvFlowPassCopyBufferParams* params);
430
431 void(NV_FLOW_ABI* addPassCopyBufferToTexture)(NvFlowContext* context, const NvFlowPassCopyBufferToTextureParams* params);
432
433 void(NV_FLOW_ABI* addPassCopyTextureToBuffer)(NvFlowContext* context, const NvFlowPassCopyTextureToBufferParams* params);
434
435 void(NV_FLOW_ABI* addPassCopyTexture)(NvFlowContext* context, const NvFlowPassCopyTextureParams* params);
437
438#define NV_FLOW_REFLECT_TYPE NvFlowContextInterface
439NV_FLOW_REFLECT_BEGIN()
440NV_FLOW_REFLECT_FUNCTION_POINTER(getContextConfig, 0, 0)
441NV_FLOW_REFLECT_FUNCTION_POINTER(getCurrentFrame, 0, 0)
442NV_FLOW_REFLECT_FUNCTION_POINTER(getLastFrameCompleted, 0, 0)
443NV_FLOW_REFLECT_FUNCTION_POINTER(getCurrentGlobalFrame, 0, 0)
444NV_FLOW_REFLECT_FUNCTION_POINTER(getLastGlobalFrameCompleted, 0, 0)
445NV_FLOW_REFLECT_FUNCTION_POINTER(getLogPrint, 0, 0)
446NV_FLOW_REFLECT_FUNCTION_POINTER(executeTasks, 0, 0)
447NV_FLOW_REFLECT_FUNCTION_POINTER(createBuffer, 0, 0)
448NV_FLOW_REFLECT_FUNCTION_POINTER(destroyBuffer, 0, 0)
449NV_FLOW_REFLECT_FUNCTION_POINTER(getBufferTransient, 0, 0)
450NV_FLOW_REFLECT_FUNCTION_POINTER(registerBufferAsTransient, 0, 0)
451NV_FLOW_REFLECT_FUNCTION_POINTER(enqueueAcquireBuffer, 0, 0)
452NV_FLOW_REFLECT_FUNCTION_POINTER(getAcquiredBuffer, 0, 0)
453NV_FLOW_REFLECT_FUNCTION_POINTER(mapBuffer, 0, 0)
454NV_FLOW_REFLECT_FUNCTION_POINTER(unmapBuffer, 0, 0)
455NV_FLOW_REFLECT_FUNCTION_POINTER(getBufferTransientById, 0, 0)
456NV_FLOW_REFLECT_FUNCTION_POINTER(createTexture, 0, 0)
457NV_FLOW_REFLECT_FUNCTION_POINTER(destroyTexture, 0, 0)
458NV_FLOW_REFLECT_FUNCTION_POINTER(getTextureTransient, 0, 0)
459NV_FLOW_REFLECT_FUNCTION_POINTER(registerTextureAsTransient, 0, 0)
460NV_FLOW_REFLECT_FUNCTION_POINTER(enqueueAcquireTexture, 0, 0)
461NV_FLOW_REFLECT_FUNCTION_POINTER(getAcquiredTexture, 0, 0)
462NV_FLOW_REFLECT_FUNCTION_POINTER(getTextureTransientById, 0, 0)
463NV_FLOW_REFLECT_FUNCTION_POINTER(createSampler, 0, 0)
464NV_FLOW_REFLECT_FUNCTION_POINTER(getDefaultSampler, 0, 0)
465NV_FLOW_REFLECT_FUNCTION_POINTER(destroySampler, 0, 0)
466NV_FLOW_REFLECT_FUNCTION_POINTER(createComputePipeline, 0, 0)
467NV_FLOW_REFLECT_FUNCTION_POINTER(destroyComputePipeline, 0, 0)
468NV_FLOW_REFLECT_FUNCTION_POINTER(addPassCompute, 0, 0)
469NV_FLOW_REFLECT_FUNCTION_POINTER(addPassCopyBuffer, 0, 0)
470NV_FLOW_REFLECT_FUNCTION_POINTER(addPassCopyBufferToTexture, 0, 0)
471NV_FLOW_REFLECT_FUNCTION_POINTER(addPassCopyTextureToBuffer, 0, 0)
472NV_FLOW_REFLECT_FUNCTION_POINTER(addPassCopyTexture, 0, 0)
473NV_FLOW_REFLECT_END(0)
474NV_FLOW_REFLECT_INTERFACE_IMPL()
475#undef NV_FLOW_REFLECT_TYPE
476
477#endif
Definition base.h:1940
Definition NvFlowContext.h:250
Definition NvFlowContext.h:265
Definition NvFlowContext.h:258
Definition NvFlowContext.h:271
Definition NvFlowContext.h:96
Definition NvFlowContext.h:55
Definition NvFlowContext.h:280
Definition NvFlowContext.h:49
Definition NvFlowContext.h:362
Definition NvFlowContext.h:224
Definition NvFlowContext.h:238
Definition NvFlowContext.h:231
Definition NvFlowContext.h:244
Definition NvFlowContext.h:288
Definition NvFlowContext.h:300
Definition NvFlowContext.h:312
Definition NvFlowContext.h:344
Definition NvFlowContext.h:328
Definition NvFlowContext.h:205
Definition NvFlowContext.h:169
Definition NvFlowContext.h:137