ndspy-sys 0.2.3

Auto-generated Rust bindings for the RenderMan/3Delight|NSI display driver API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502

#ifndef ndspy_h
#define ndspy_h

#include <stdio.h>
#include <stdlib.h>
#include <uparam.h>

#ifdef _WIN32
#	define ALWAYS_IMPORT __declspec(dllimport)
#	define ALWAYS_EXPORT __declspec(dllexport)
#else
#	define ALWAYS_IMPORT
#	if __GNUC__ >= 4
#		define ALWAYS_EXPORT __attribute__ ((visibility("default")))
#	else
#		define ALWAYS_EXPORT
#	endif
#endif

#define INTERFACE ALWAYS_IMPORT

#ifdef  __cplusplus
#   define EXTERN_C extern "C"
#else
#   define EXTERN_C
#endif

#define PkDspyMaxMsgSize 32760

#define PkDspyServerMsgOpen  (65 + 1)
#define PkDspyServerMsgImage (65 + 2)
#define PkDspyServerMsgData  (65 + 3)
#define PkDspyServerMsgQuery (65 + 4)
#define PkDspyServerMsgClose (65 + 5)

/*
PtDspyUnsigned64
PtDspySigned64
*/
typedef double PtDspyFloat64;
typedef float PtDspyFloat32;

#if defined(__mips)
#define PkDspyByteOrderNative	PkDspyByteOrderHiLo
#elif defined(__mips64)
#define PkDspyByteOrderNative	PkDspyByteOrderHiLo
#elif defined(__sparc)
#define PkDspyByteOrderNative	PkDspyByteOrderHiLo
#elif defined(__alpha)
#define PkDspyByteOrderNative	PkDspyByteOrderLoHi
#else
#define PkDspyByteOrderNative	PkDspyByteOrderLoHi
#endif

#if defined(__mips64) || defined(__alpha)
typedef unsigned int PtDspyUnsigned32;
typedef int PtDspySigned32;
#else
typedef unsigned long PtDspyUnsigned32;
typedef long PtDspySigned32;
#endif

typedef unsigned short PtDspyUnsigned16;
typedef short PtDspySigned16;

typedef unsigned char PtDspyUnsigned8;
typedef char PtDspySigned8;

typedef PtDspyUnsigned32 PtDspyMsgLen;
typedef PtDspyUnsigned32 PtDspyServerMessage;

#define PkDspyClassFloat 1
#define PkDspyClassInt 2

#define PkDspyNone          0

#define PkDspyFloat32		1
#define PkDspyFloat16       12  /* 3Delight addition */
#define PkDspyUnsigned32	2
#define PkDspySigned32		3
#define PkDspyUnsigned16	4
#define PkDspySigned16		5
#define PkDspyUnsigned8		6
#define PkDspySigned8		7

#define PkDspyString		8
#define PkDspyMatrix		9
#define PkDspyArrayBegin	10
#define PkDspyArrayEnd      11

#define PkDspyMaskType		8191

#define PkDspyMaskOrder (PkDspyByteOrderHiLo | PkDspyByteOrderLoHi)
#define PkDspyShiftOrder	13
#define PkDspyByteOrderHiLo	8192
#define PkDspyByteOrderLoHi	16384

/* #define PkDspyOpenPortCount 8 */

/* Convenient struct to access the channels of deep samples. */
struct PtDspyDeepSample
{
	/* front and back depth */
	float Z, ZBack;
	/* opacity RGB */
	float A[3];
	/* user channels (actual number is variable) */
	float U[1];

#ifdef  __cplusplus
private:
	PtDspyDeepSample();
	PtDspyDeepSample( const PtDspyDeepSample& );
	void operator=( const PtDspyDeepSample& );
#endif
};

typedef struct
{
	/* "DEEP0". To validate struct version. */
	char ID[8];

	/* Subpixels per pixel in x and y. */
	int xSPP, ySPP;

	/*
		Coordinates of the bucket, in pixels. After filtering, the bucket
		covers [xBegin,xEnd) x [yBegin,yEnd) .
	*/
	int xBegin, yBegin;
	int xEnd, yEnd;

	/*
		Extra pixels given for filtering around the bucket. Always whole extra
		pixels even if only half a pixel's samples are needed. However, the
		unused samples may be left empty by the renderer.
	*/
	int xFilterExtraPixels, yFilterExtraPixels;

	/*
		Filter coefficients. There are (1 + 2 * xFilterExtraPixels) * xSPP
		values in xFilterCoefficients. Same for y.
	*/
	float *xFilterCoefficients, *yFilterCoefficients;

	/*
		Includes mandatory Z, ZBack, AR, AG, RB followed by user channels.
		See PtDspyDeepSample.
	*/
	unsigned numChannels;

	/*
		Total number of deep pixels sent. Extra data is sent around the display
		area for filtering so this is always equal to:
		((xEnd - xBegin) + 2 * xFilterExtraPixels) * xSPP *
		((yEnd - yBegin) + 2 * yFilterExtraPixels) * ySPP
	*/
	unsigned numDeepPixels;

	/* numDeepPixels + 1 offsets (in samples) for the deep pixels. */
	unsigned *deepPixelOffsets;

	/*
		Packed deep pixel data in row-major order. Pixel i starts at:
		deepData + deepPixelOffsets[i] * numChannels
		It ends where pixel i+1 starts.
	*/
	float *deepData;
} PtDspyDeepData;

typedef struct
{
   const char *name;
   unsigned type;
} PtDspyDevFormat;


typedef struct
{
	PtDspyUnsigned32 width;
	PtDspyUnsigned32 height;
	PtDspyFloat32 aspectRatio;
} PtDspySizeInfo;

typedef struct
{
  PtDspyUnsigned8 overwrite;
  PtDspyUnsigned8 unused; /* 'interactive' in prman */
} PtDspyOverwriteInfo;

typedef struct
{
  PtDspyUnsigned8 redraw;
} PtDspyRedrawInfo;

/* added by AK */
typedef struct
{
	/* See PtDspyCookedQueryValue below. */
	PtDspyUnsigned8 cooked;
} PtDspyCookedInfo;

typedef enum
{
	/* 1 = default behavior (filtered pixel data) */
	PkDspyCQDefault = 1,
	/* 3 = Deep data (PtDspyDeepData) */
	PkDspyCQDeep = 3
} PtDspyCookedQueryValue;

/* added by OP */
typedef struct
{
	PtDspyUnsigned8 multithread;
} PtDspyThreadInfo;

/* added by OP */
typedef struct
{
	PtDspyUnsigned8 acceptProgressive;
} PtDspyProgressiveInfo;

typedef enum
{
	PkSizeQuery,
	PkOverwriteQuery,
	PkNextDataQuery,
	PkRedrawQuery,
	PkCookedQuery = 100, /* this one is not a standard prman query, AK */
	PkThreadQuery,       /* another 3Delight extension, PtDspyThreadInfo */
	PkProgressiveQuery,  /* same, PtDspyProgressiveInfo */
	PkStopQuery,         /* no infos, simply return ErrorNone or ErrorStop */
	PkPreBucketFunctionQuery,  /* returns pointer to PtDspyPreBucketFuncPtr */
	PkRenderStatistics, /* returns pointer to PtDspyRenderStatisticsFuncPtr */
	PkRenderProgress,    /* returns pointer to PtDspyRenderProgressFuncPtr */
	PkBucketVersion, /* returns pointer to PtDspyVersionFuncPtr */
	PkPreRenderProgress,    /* returns pointer to PtDspyRenderProgressFuncPtr */
	PkPreRenderAutoProgress /* returns pointer to PtDspyRenderAutoProgressFuncPtr */
} PtDspyQueryType;

typedef enum
{
	PkDspyErrorNone = 0,
	PkDspyErrorNoMemory,
	PkDspyErrorUnsupported,
	PkDspyErrorBadParams,
	PkDspyErrorNoResource,
	PkDspyErrorUndefined,
	PkDspyErrorStop
} PtDspyError;

#define PkDspyFlagsWantsScanLineOrder 1
#define PkDspyFlagsWantsEmptyBuckets 2
#define PkDspyFlagsWantsNullEmptyBuckets 4

typedef struct
{
	int flags;
} PtFlagStuff;

typedef void * PtDspyImageHandle;
typedef void * PtDspyChannel;
typedef void * PtDspyOutput;

EXTERN_C ALWAYS_EXPORT PtDspyError
DspyImageOpen(PtDspyImageHandle * image,
		const char *drivername,
		const char *filename,
		int width,
		int height,
		int paramCount,
		const UserParameter *parameters,
		int iFormatCount,
		PtDspyDevFormat *format,
		PtFlagStuff *flagstuff);

EXTERN_C ALWAYS_EXPORT PtDspyError
DspyImageData(PtDspyImageHandle image,
		int xmin,
		int xmax,
		int ymin,
		int ymax,
		int entrysize,
		const unsigned char *data);

EXTERN_C ALWAYS_EXPORT PtDspyError
DspyImageClose(PtDspyImageHandle);

EXTERN_C ALWAYS_EXPORT  PtDspyError
DspyImageReopen(PtDspyImageHandle image,
		const char *drivername,
		const char *filename,
		int width,
		int height,
		int paramCount,
		const UserParameter *parameters,
		int iFormatCount,
		PtDspyDevFormat *format,
		PtFlagStuff *flagstuff);

EXTERN_C ALWAYS_EXPORT PtDspyError
DspyImageDelayClose(PtDspyImageHandle);

EXTERN_C ALWAYS_EXPORT PtDspyError
DspyImageQuery(PtDspyImageHandle,
	   PtDspyQueryType,
	   int,
	   void *);


typedef PtDspyError
	(*PtDspyOpenFuncPtr)(
		PtDspyImageHandle * image,
		const char *drivername,
		const char *filename,
		int width,
		int height,
		int paramCount,
		const UserParameter *parameters,
		int iFormatCount,
		PtDspyDevFormat *format,
		PtFlagStuff *flagstuff);

typedef PtDspyError
	(*PtDspyWriteFuncPtr)(
		PtDspyImageHandle image,
		int xmin,
		int xmax_plus_one,
		int ymin,
		int ymax_plus_one,
		int entrysize,
		const unsigned char *data);

typedef PtDspyError
	(*PtDspyCloseFuncPtr)(PtDspyImageHandle);
typedef PtDspyError
	(*PtDspyFlushFuncPtr)(PtDspyImageHandle);

typedef PtDspyError
	(*PtDspyReopenFuncPtr)(
		PtDspyImageHandle image,
		const char *drivername,
		const char *filename,
		int width,
		int height,
		int paramCount,
		const UserParameter *parameters,
		int iFormatCount,
		PtDspyDevFormat *format,
		PtFlagStuff *flagstuff);

typedef PtDspyError
	(*PtDspyDelayCloseFuncPtr)(PtDspyImageHandle);

typedef PtDspyError
	(*PtDspyQueryFuncPtr)(
		PtDspyImageHandle,
		PtDspyQueryType,
		int ,
		void * );

typedef PtDspyError
	(*PtDspyActiveRegionFuncPtr)(PtDspyImageHandle image,
		int xmin,
		int xmax_plus_one,
		int ymin,
		int ymax_plus_one );

typedef PtDspyError
	(*PtDspyPreBucketFuncPtr)(PtDspyImageHandle image,
		int xmin,
		int xmax_plus_one,
		int ymin,
		int ymax_plus_one,
		int pass,
		int flags );

typedef PtDspyError (*PtDspyVersionFuncPtr)(PtDspyImageHandle, int);

typedef PtDspyError
	(*PtDspyRenderStatisticsFuncPtr)(PtDspyImageHandle image, void * );

typedef PtDspyError
	(*PtDspyRenderProgressFuncPtr)(PtDspyImageHandle image, float progress);

typedef PtDspyError
	(*PtDspyRenderAutoProgressFuncPtr)(
		PtDspyImageHandle image,
		float progress_from,
		float progress_to,
		float duration,
		const char* step);


typedef enum
{
	k_PtDriverUnknownVersion = 0,
	k_PtDriverCurrentVersion = 1
} PtDriverVersion;

typedef struct
{
	int Version;
	PtDspyOpenFuncPtr pOpen;
	PtDspyWriteFuncPtr pWrite;
	PtDspyCloseFuncPtr pClose;
	PtDspyQueryFuncPtr pQuery;
	PtDspyActiveRegionFuncPtr pActiveRegion;
} PtDspyDriverFunctionTable;

/* Utilities, for PrMan compatibility. */

EXTERN_C INTERFACE void
DspyMemReverseCopy(
	unsigned char *t,
	const unsigned char *s,
	int len );

EXTERN_C INTERFACE void
DspyMemReverse(
	unsigned char *t,
	int len );

EXTERN_C INTERFACE PtDspyError
DspyFindStringInParamList(
	const char *name,
	char **result,
	int paramCount,
	const UserParameter *parameters );

EXTERN_C INTERFACE PtDspyError
DspyFindMatrixInParamList(
	const char *name,
	float *result,
	int paramCount,
	const UserParameter *parameters );

EXTERN_C INTERFACE PtDspyError
DspyFindFloatInParamList(
	const char *name,
	float *result,
	int paramCount,
	const UserParameter *parameters );

EXTERN_C INTERFACE PtDspyError
DspyFindFloatsInParamList(
	const char *name,
	int *resultCount,
	float *result,
	int paramCount,
	const UserParameter *parameters );

EXTERN_C INTERFACE PtDspyError
DspyFindIntInParamList(
	const char *name,
	int *result,
	int paramCount,
	const UserParameter *parameters );

EXTERN_C INTERFACE PtDspyError
DspyFindIntsInParamList(
	const char *name,
	int *resultCount,
	int *result,
	int paramCount,
	const UserParameter *parameters );

EXTERN_C INTERFACE PtDspyError
DspyReorderFormatting(
	int formatCount,
	PtDspyDevFormat *format,
	int outFormatCount,
	const PtDspyDevFormat *outFormat );

EXTERN_C INTERFACE void
DspyError(
	const char *module,
	const char *fmt,
	... );

/* Deprecated. Use DspyRegisterDriverTable instead. */
EXTERN_C INTERFACE PtDspyError
DspyRegisterDriver(
	const char *driver_name,
	const PtDspyOpenFuncPtr pOpen,
	const PtDspyWriteFuncPtr pWrite,
	const PtDspyCloseFuncPtr pClose,
	const PtDspyQueryFuncPtr pQuery );

/*
	Registers a display driver by giving pointers to the entry points directly.

	NOTES
	- If pTable is null, the driver is unregistered.
*/
EXTERN_C INTERFACE PtDspyError
DspyRegisterDriverTable(
	const char *driver_name,
	const PtDspyDriverFunctionTable *pTable );

#endif /* ifdef ndspy_h */