commit c62d5148c5d21b938c1353baf8b44d5d71d3c67b
parent eb328563a8692f6760227c6ca30a3d219b9531e0
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 26 Feb 2018 08:51:48 +0100
Add the sdis_accum_buffer API
Diffstat:
| M | src/sdis.h | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ |
1 file changed, 62 insertions(+), 6 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -51,6 +51,7 @@ struct mem_allocator;
* a reference on the data, i.e. they increment or decrement the reference
* counter, respectively. When this counter reaches 0, the object is silently
* destroyed and cannot be used anymore. */
+struct sdis_accum_buffer;
struct sdis_camera;
struct sdis_data;
struct sdis_device;
@@ -92,6 +93,13 @@ struct sdis_interface_fragment {
static const struct sdis_interface_fragment SDIS_INTERFACE_FRAGMENT_NULL =
SDIS_INTERFACE_FRAGMENT_NULL__;
+/* Monte-Carlo accumulator */
+struct sdis_accum {
+ double sum_weights; /* Sum of Monte-Carlo weight */
+ double sum_weights_sqr; /* Sum of Monte-Carlo square weights */
+ size_t nweights; /* #accumulated weights */
+};
+
/* Monte-Carlo estimation */
struct sdis_mc {
double E; /* Expected value */
@@ -154,13 +162,21 @@ struct sdis_interface_shader {
static const struct sdis_interface_shader SDIS_INTERFACE_SHADER_NULL =
SDIS_INTERFACE_SHADER_NULL__;
-/* Functor use to write estimations performed by sdis_solve_camera */
+struct sdis_accum_buffer_layout {
+ size_t width;
+ size_t height;
+};
+#define SDIS_ACCUM_BUFFER_LAYOUT_NULL__ {0, 0}
+static const struct sdis_accum_buffer_layout SDIS_ACCUM_BUFFER_LAYOUT_NULL =
+ SDIS_ACCUM_BUFFER_LAYOUT_NULL__;
+
+/* Functor use to write accumulations performed by sdis_solve_camera */
typedef res_T
-(*sdis_write_estimations_T)
+(*sdis_write_accums_T)
(void* context, /* User data */
- const size_t origin[2], /* Coordinates of the 1st estimation in image plane */
- const size_t nestimations[2], /* #estimations in X and Y */
- const struct sdis_mc* estimations); /* List of row ordered estimations */
+ const size_t origin[2], /* Coordinates of the 1st accumulation in image plane */
+ const size_t naccums[2], /* #accumulations in X and Y */
+ const struct sdis_accum* accums); /* List of row ordered accumulations */
BEGIN_DECLS
@@ -247,6 +263,46 @@ sdis_camera_look_at
const double up[3]);
/*******************************************************************************
+ * A buffer of accumulations
+ ******************************************************************************/
+SDIS_API res_T
+sdis_accum_buffer_create
+ (struct sdis_device* dev,
+ const size_t width,
+ const size_t height,
+ struct sdis_accum_buffer** buf);
+
+SDIS_API res_T
+sdis_accum_buffer_ref_get
+ (struct sdis_accum_buffer* buf);
+
+SDIS_API res_T
+sdis_accum_buffer_ref_put
+ (struct sdis_accum_buffer* buf);
+
+SDIS_API res_T
+sdis_accum_buffer_get_layout
+ (const struct sdis_accum_buffer* buf,
+ struct sdis_accum_buffer_layout* layout);
+
+SDIS_API res_T
+sdis_accum_buffer_map
+ (const struct sdis_accum_buffer* buf,
+ const struct sdis_accum** accums);
+
+SDIS_API res_T
+sdis_accum_buffer_unmap
+ (const struct sdis_accum_buffer* buf);
+
+/* Helper function that matches the `sdis_write_accums_T' functor type */
+SDIS_API res_T
+sdis_accum_buffer_write
+ (void* buf, /* User data */
+ const size_t origin[2], /* Coordinates of the 1st accum in image plane */
+ const size_t naccum[2], /* #accum in X and Y */
+ const struct sdis_accum* accums); /* List of row ordered accum */
+
+/*******************************************************************************
* A medium encapsulates the properties of either a fluid or a solid.
******************************************************************************/
SDIS_API res_T
@@ -393,7 +449,7 @@ sdis_solve_camera
const size_t width, /* Image definition in in X */
const size_t height, /* Image definition in Y */
const size_t spp, /* #samples per pixel */
- sdis_write_estimations_T writer,
+ sdis_write_accums_T writer,
void* writer_data);
END_DECLS