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
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-10-16 12:49:15 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-10-30 17:15:55 +0300
commit31873218b27d5cd4c5f24e4f13d211c9b347101b (patch)
treeb7d8897e7ddf3e22f8c744f40a51b9e45a5ccf9a /intern
parentb4fb3db559ccd79e06a44ee9605f969bf8ef7d57 (diff)
OpenSubdiv: Use smaller buffer sizes and strides
We currently don't support interleaved varying data, so can make some buffer smaller.
Diffstat (limited to 'intern')
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc36
1 files changed, 17 insertions, 19 deletions
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
index d2cd366ba11..6507d31480b 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
@@ -357,10 +357,8 @@ class VolatileEvalOutput {
void evalPatchCoord(const PatchCoord &patch_coord, float P[3])
{
- StackAllocatedBuffer<6, 1> vertex_data;
- // TODO(sergey): Varying data is interleaved in vertex array, so need to
- // adjust stride if there is a varying data.
- // BufferDescriptor vertex_desc(0, 3, 6);
+ StackAllocatedBuffer<3, 1> vertex_data;
+ // TODO(sergey): Support interleaved vertex-varying data.
BufferDescriptor vertex_desc(0, 3, 3);
SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
const EVALUATOR *eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
@@ -383,12 +381,13 @@ class VolatileEvalOutput {
float dPdu[3],
float dPdv[3])
{
- StackAllocatedBuffer<6, 1> vertex_data, derivatives;
- // TODO(sergey): Varying data is interleaved in vertex array, so need to
- // adjust stride if there is a varying data.
- // BufferDescriptor vertex_desc(0, 3, 6);
+ assert(dPdu);
+ assert(dPdv);
+ StackAllocatedBuffer<3, 1> vertex_data;
+ StackAllocatedBuffer<3, 1> dPdu_data, dPdv_data;
+ // TODO(sergey): Support interleaved vertex-varying data.
BufferDescriptor vertex_desc(0, 3, 3);
- BufferDescriptor du_desc(0, 3, 6), dv_desc(3, 3, 6);
+ BufferDescriptor du_desc(0, 3, 3), dv_desc(0, 3, 3);
SinglePatchCoordBuffer patch_coord_buffer(patch_coord);
const EVALUATOR *eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
evaluator_cache_, src_desc_, vertex_desc, du_desc, dv_desc, device_context_);
@@ -396,9 +395,9 @@ class VolatileEvalOutput {
src_desc_,
&vertex_data,
vertex_desc,
- &derivatives,
+ &dPdu_data,
du_desc,
- &derivatives,
+ &dPdv_data,
dv_desc,
patch_coord_buffer.GetNumVertices(),
&patch_coord_buffer,
@@ -407,14 +406,13 @@ class VolatileEvalOutput {
device_context_);
const float *refined_vertices = vertex_data.BindCpuBuffer();
memcpy(P, refined_vertices, sizeof(float) * 3);
- if (dPdu != NULL || dPdv != NULL) {
- const float *refined_derivatives = derivatives.BindCpuBuffer();
- if (dPdu != NULL) {
- memcpy(dPdu, refined_derivatives, sizeof(float) * 3);
- }
- if (dPdv != NULL) {
- memcpy(dPdv, refined_derivatives + 3, sizeof(float) * 3);
- }
+ if (dPdu != NULL) {
+ const float *refined_dPdu = dPdu_data.BindCpuBuffer();
+ memcpy(dPdu, refined_dPdu, sizeof(float) * 3);
+ }
+ if (dPdv != NULL) {
+ const float *refined_dPdv = dPdv_data.BindCpuBuffer();
+ memcpy(dPdv, refined_dPdv, sizeof(float) * 3);
}
}