Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/opensubdiv/internal/evaluator/eval_output.h')
-rw-r--r--intern/opensubdiv/internal/evaluator/eval_output.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/intern/opensubdiv/internal/evaluator/eval_output.h b/intern/opensubdiv/internal/evaluator/eval_output.h
index 9ca09f011a1..bc5494bfe41 100644
--- a/intern/opensubdiv/internal/evaluator/eval_output.h
+++ b/intern/opensubdiv/internal/evaluator/eval_output.h
@@ -46,6 +46,8 @@ class EvalOutputAPI::EvalOutput {
virtual void updateVaryingData(const float *src, int start_vertex, int num_vertices) = 0;
+ virtual void updateVertexData(const float *src, int start_vertex, int num_vertices) = 0;
+
virtual void updateFaceVaryingData(const int face_varying_channel,
const float *src,
int start_vertex,
@@ -70,6 +72,11 @@ class EvalOutputAPI::EvalOutput {
const int num_patch_coords,
float *varying) = 0;
+ // NOTE: vertex_data must point to a memory of at least float*num_vertex_data.
+ virtual void evalPatchesVertexData(const PatchCoord *patch_coord,
+ const int num_patch_coords,
+ float *vertex_data) = 0;
+
virtual void evalPatchesFaceVarying(const int face_varying_channel,
const PatchCoord *patch_coord,
const int num_patch_coords,
@@ -331,11 +338,13 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
const StencilTable *varying_stencils,
const vector<const StencilTable *> &all_face_varying_stencils,
const int face_varying_width,
+ const int vertex_data_width,
const PatchTable *patch_table,
EvaluatorCache *evaluator_cache = NULL,
DEVICE_CONTEXT *device_context = NULL)
: src_desc_(0, 3, 3),
src_varying_desc_(0, 3, 3),
+ src_vertex_data_desc_(0, vertex_data_width, vertex_data_width),
face_varying_width_(face_varying_width),
evaluator_cache_(evaluator_cache),
device_context_(device_context)
@@ -352,6 +361,16 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
device_context_);
varying_stencils_ = convertToCompatibleStencilTable<STENCIL_TABLE>(varying_stencils,
device_context_);
+
+ // Optionally allocate additional data to be subdivided like vertex coordinates.
+ if (vertex_data_width > 0) {
+ src_vertex_data_ = SRC_VERTEX_BUFFER::Create(
+ vertex_data_width, num_total_vertices, device_context_);
+ }
+ else {
+ src_vertex_data_ = NULL;
+ }
+
// Create evaluators for every face varying channel.
face_varying_evaluators_.reserve(all_face_varying_stencils.size());
int face_varying_channel = 0;
@@ -370,6 +389,7 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
{
delete src_data_;
delete src_varying_data_;
+ delete src_vertex_data_;
delete patch_table_;
delete vertex_stencils_;
delete varying_stencils_;
@@ -390,6 +410,11 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
src_varying_data_->UpdateData(src, start_vertex, num_vertices, device_context_);
}
+ void updateVertexData(const float *src, int start_vertex, int num_vertices) override
+ {
+ src_vertex_data_->UpdateData(src, start_vertex, num_vertices, device_context_);
+ }
+
void updateFaceVaryingData(const int face_varying_channel,
const float *src,
int start_vertex,
@@ -426,6 +451,22 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
vertex_stencils_,
eval_instance,
device_context_);
+
+ // Evaluate smoothly interpolated vertex data.
+ if (src_vertex_data_) {
+ BufferDescriptor dst_vertex_data_desc = src_vertex_data_desc_;
+ dst_vertex_data_desc.offset += num_coarse_vertices_ * src_vertex_data_desc_.stride;
+ const EVALUATOR *eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
+ evaluator_cache_, src_vertex_data_desc_, dst_vertex_data_desc, device_context_);
+ EVALUATOR::EvalStencils(src_vertex_data_,
+ src_vertex_data_desc_,
+ src_vertex_data_,
+ dst_vertex_data_desc,
+ vertex_stencils_,
+ eval_instance,
+ device_context_);
+ }
+
// Evaluate varying data.
if (hasVaryingData()) {
BufferDescriptor dst_varying_desc = src_varying_desc_;
@@ -521,6 +562,27 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
device_context_);
}
+ // NOTE: data must point to a memory of at least float*num_vertex_data.
+ void evalPatchesVertexData(const PatchCoord *patch_coord,
+ const int num_patch_coords,
+ float *data) override
+ {
+ RawDataWrapperBuffer<float> vertex_data(data);
+ BufferDescriptor vertex_desc(0, src_vertex_data_desc_.length, src_vertex_data_desc_.length);
+ ConstPatchCoordWrapperBuffer patch_coord_buffer(patch_coord, num_patch_coords);
+ const EVALUATOR *eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
+ evaluator_cache_, src_vertex_data_desc_, vertex_desc, device_context_);
+ EVALUATOR::EvalPatches(src_vertex_data_,
+ src_vertex_data_desc_,
+ &vertex_data,
+ vertex_desc,
+ patch_coord_buffer.GetNumVertices(),
+ &patch_coord_buffer,
+ patch_table_,
+ eval_instance,
+ device_context_);
+ }
+
void evalPatchesFaceVarying(const int face_varying_channel,
const PatchCoord *patch_coord,
const int num_patch_coords,
@@ -560,9 +622,11 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
private:
SRC_VERTEX_BUFFER *src_data_;
SRC_VERTEX_BUFFER *src_varying_data_;
+ SRC_VERTEX_BUFFER *src_vertex_data_;
PATCH_TABLE *patch_table_;
BufferDescriptor src_desc_;
BufferDescriptor src_varying_desc_;
+ BufferDescriptor src_vertex_data_desc_;
int num_coarse_vertices_;