diff options
5 files changed, 269 insertions, 198 deletions
diff --git a/intern/opensubdiv/internal/evaluator/shaders/glsl_compute_kernel.glsl b/intern/opensubdiv/internal/evaluator/shaders/glsl_compute_kernel.glsl index 2a58fa10ea0..2f60aee0999 100644 --- a/intern/opensubdiv/internal/evaluator/shaders/glsl_compute_kernel.glsl +++ b/intern/opensubdiv/internal/evaluator/shaders/glsl_compute_kernel.glsl @@ -24,56 +24,103 @@ //------------------------------------------------------------------------------ - -layout(local_size_x=WORK_GROUP_SIZE, local_size_y=1, local_size_z=1) in; +layout(local_size_x = WORK_GROUP_SIZE, local_size_y = 1, local_size_z = 1) in; layout(std430) buffer; // source and destination buffers uniform int srcOffset = 0; uniform int dstOffset = 0; -layout(binding=0) buffer src_buffer { float srcVertexBuffer[]; }; -layout(binding=1) buffer dst_buffer { float dstVertexBuffer[]; }; +layout(binding = 0) buffer src_buffer +{ + float srcVertexBuffer[]; +}; +layout(binding = 1) buffer dst_buffer +{ + float dstVertexBuffer[]; +}; -// derivative buffers (if needed) + // derivative buffers (if needed) #if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) uniform ivec3 duDesc; uniform ivec3 dvDesc; -layout(binding=2) buffer du_buffer { float duBuffer[]; }; -layout(binding=3) buffer dv_buffer { float dvBuffer[]; }; +layout(binding = 2) buffer du_buffer +{ + float duBuffer[]; +}; +layout(binding = 3) buffer dv_buffer +{ + float dvBuffer[]; +}; #endif #if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) uniform ivec3 duuDesc; uniform ivec3 duvDesc; uniform ivec3 dvvDesc; -layout(binding=10) buffer duu_buffer { float duuBuffer[]; }; -layout(binding=11) buffer duv_buffer { float duvBuffer[]; }; -layout(binding=12) buffer dvv_buffer { float dvvBuffer[]; }; +layout(binding = 10) buffer duu_buffer +{ + float duuBuffer[]; +}; +layout(binding = 11) buffer duv_buffer +{ + float duvBuffer[]; +}; +layout(binding = 12) buffer dvv_buffer +{ + float dvvBuffer[]; +}; #endif -// stencil buffers + // stencil buffers #if defined(OPENSUBDIV_GLSL_COMPUTE_KERNEL_EVAL_STENCILS) uniform int batchStart = 0; uniform int batchEnd = 0; -layout(binding=4) buffer stencilSizes { int _sizes[]; }; -layout(binding=5) buffer stencilOffsets { int _offsets[]; }; -layout(binding=6) buffer stencilIndices { int _indices[]; }; -layout(binding=7) buffer stencilWeights { float _weights[]; }; +layout(binding = 4) buffer stencilSizes +{ + int _sizes[]; +}; +layout(binding = 5) buffer stencilOffsets +{ + int _offsets[]; +}; +layout(binding = 6) buffer stencilIndices +{ + int _indices[]; +}; +layout(binding = 7) buffer stencilWeights +{ + float _weights[]; +}; -#if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) -layout(binding=8) buffer stencilDuWeights { float _duWeights[]; }; -layout(binding=9) buffer stencilDvWeights { float _dvWeights[]; }; -#endif +# if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) +layout(binding = 8) buffer stencilDuWeights +{ + float _duWeights[]; +}; +layout(binding = 9) buffer stencilDvWeights +{ + float _dvWeights[]; +}; +# endif -#if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) -layout(binding=13) buffer stencilDuuWeights { float _duuWeights[]; }; -layout(binding=14) buffer stencilDuvWeights { float _duvWeights[]; }; -layout(binding=15) buffer stencilDvvWeights { float _dvvWeights[]; }; -#endif +# if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) +layout(binding = 13) buffer stencilDuuWeights +{ + float _duuWeights[]; +}; +layout(binding = 14) buffer stencilDuvWeights +{ + float _duvWeights[]; +}; +layout(binding = 15) buffer stencilDvvWeights +{ + float _dvvWeights[]; +}; +# endif uint getGlobalInvocationIndex() { @@ -87,24 +134,36 @@ uint getGlobalInvocationIndex() #if defined(OPENSUBDIV_GLSL_COMPUTE_KERNEL_EVAL_PATCHES) -layout(binding=4) buffer patchArray_buffer { OsdPatchArray patchArrayBuffer[]; }; -layout(binding=5) buffer patchCoord_buffer { OsdPatchCoord patchCoords[]; }; -layout(binding=6) buffer patchIndex_buffer { int patchIndexBuffer[]; }; -layout(binding=7) buffer patchParam_buffer { OsdPatchParam patchParamBuffer[]; }; +layout(binding = 4) buffer patchArray_buffer +{ + OsdPatchArray patchArrayBuffer[]; +}; +layout(binding = 5) buffer patchCoord_buffer +{ + OsdPatchCoord patchCoords[]; +}; +layout(binding = 6) buffer patchIndex_buffer +{ + int patchIndexBuffer[]; +}; +layout(binding = 7) buffer patchParam_buffer +{ + OsdPatchParam patchParamBuffer[]; +}; OsdPatchCoord GetPatchCoord(int coordIndex) { - return patchCoords[coordIndex]; + return patchCoords[coordIndex]; } OsdPatchArray GetPatchArray(int arrayIndex) { - return patchArrayBuffer[arrayIndex]; + return patchArrayBuffer[arrayIndex]; } OsdPatchParam GetPatchParam(int patchIndex) { - return patchParamBuffer[patchIndex]; + return patchParamBuffer[patchIndex]; } #endif @@ -112,141 +171,149 @@ OsdPatchParam GetPatchParam(int patchIndex) //------------------------------------------------------------------------------ struct Vertex { - float vertexData[LENGTH]; + float vertexData[LENGTH]; }; -void clear(out Vertex v) { - for (int i = 0; i < LENGTH; ++i) { - v.vertexData[i] = 0; - } +void clear(out Vertex v) +{ + for (int i = 0; i < LENGTH; ++i) { + v.vertexData[i] = 0; + } } -Vertex readVertex(int index) { - Vertex v; - int vertexIndex = srcOffset + index * SRC_STRIDE; - for (int i = 0; i < LENGTH; ++i) { - v.vertexData[i] = srcVertexBuffer[vertexIndex + i]; - } - return v; +Vertex readVertex(int index) +{ + Vertex v; + int vertexIndex = srcOffset + index * SRC_STRIDE; + for (int i = 0; i < LENGTH; ++i) { + v.vertexData[i] = srcVertexBuffer[vertexIndex + i]; + } + return v; } -void writeVertex(int index, Vertex v) { - int vertexIndex = dstOffset + index * DST_STRIDE; - for (int i = 0; i < LENGTH; ++i) { - dstVertexBuffer[vertexIndex + i] = v.vertexData[i]; - } +void writeVertex(int index, Vertex v) +{ + int vertexIndex = dstOffset + index * DST_STRIDE; + for (int i = 0; i < LENGTH; ++i) { + dstVertexBuffer[vertexIndex + i] = v.vertexData[i]; + } } -void addWithWeight(inout Vertex v, const Vertex src, float weight) { - for (int i = 0; i < LENGTH; ++i) { - v.vertexData[i] += weight * src.vertexData[i]; - } +void addWithWeight(inout Vertex v, const Vertex src, float weight) +{ + for (int i = 0; i < LENGTH; ++i) { + v.vertexData[i] += weight * src.vertexData[i]; + } } #if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) -void writeDu(int index, Vertex du) { - int duIndex = duDesc.x + index * duDesc.z; - for (int i = 0; i < LENGTH; ++i) { - duBuffer[duIndex + i] = du.vertexData[i]; - } +void writeDu(int index, Vertex du) +{ + int duIndex = duDesc.x + index * duDesc.z; + for (int i = 0; i < LENGTH; ++i) { + duBuffer[duIndex + i] = du.vertexData[i]; + } } -void writeDv(int index, Vertex dv) { - int dvIndex = dvDesc.x + index * dvDesc.z; - for (int i = 0; i < LENGTH; ++i) { - dvBuffer[dvIndex + i] = dv.vertexData[i]; - } +void writeDv(int index, Vertex dv) +{ + int dvIndex = dvDesc.x + index * dvDesc.z; + for (int i = 0; i < LENGTH; ++i) { + dvBuffer[dvIndex + i] = dv.vertexData[i]; + } } #endif #if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) -void writeDuu(int index, Vertex duu) { - int duuIndex = duuDesc.x + index * duuDesc.z; - for (int i = 0; i < LENGTH; ++i) { - duuBuffer[duuIndex + i] = duu.vertexData[i]; - } +void writeDuu(int index, Vertex duu) +{ + int duuIndex = duuDesc.x + index * duuDesc.z; + for (int i = 0; i < LENGTH; ++i) { + duuBuffer[duuIndex + i] = duu.vertexData[i]; + } } -void writeDuv(int index, Vertex duv) { - int duvIndex = duvDesc.x + index * duvDesc.z; - for (int i = 0; i < LENGTH; ++i) { - duvBuffer[duvIndex + i] = duv.vertexData[i]; - } +void writeDuv(int index, Vertex duv) +{ + int duvIndex = duvDesc.x + index * duvDesc.z; + for (int i = 0; i < LENGTH; ++i) { + duvBuffer[duvIndex + i] = duv.vertexData[i]; + } } -void writeDvv(int index, Vertex dvv) { - int dvvIndex = dvvDesc.x + index * dvvDesc.z; - for (int i = 0; i < LENGTH; ++i) { - dvvBuffer[dvvIndex + i] = dvv.vertexData[i]; - } +void writeDvv(int index, Vertex dvv) +{ + int dvvIndex = dvvDesc.x + index * dvvDesc.z; + for (int i = 0; i < LENGTH; ++i) { + dvvBuffer[dvvIndex + i] = dvv.vertexData[i]; + } } #endif //------------------------------------------------------------------------------ #if defined(OPENSUBDIV_GLSL_COMPUTE_KERNEL_EVAL_STENCILS) -void main() { - int current = int(getGlobalInvocationIndex()) + batchStart; - - if (current>=batchEnd) { - return; - } - - Vertex dst; - clear(dst); - - int offset = _offsets[current], - size = _sizes[current]; - - for (int stencil = 0; stencil < size; ++stencil) { - int vindex = offset + stencil; - addWithWeight( - dst, readVertex(_indices[vindex]), _weights[vindex]); - } - - writeVertex(current, dst); - -#if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) - Vertex du, dv; - clear(du); - clear(dv); - for (int i=0; i<size; ++i) { - // expects the compiler optimizes readVertex out here. - Vertex src = readVertex(_indices[offset+i]); - addWithWeight(du, src, _duWeights[offset+i]); - addWithWeight(dv, src, _dvWeights[offset+i]); - } - - if (duDesc.y > 0) { // length - writeDu(current, du); - } - if (dvDesc.y > 0) { - writeDv(current, dv); - } -#endif -#if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) - Vertex duu, duv, dvv; - clear(duu); - clear(duv); - clear(dvv); - for (int i=0; i<size; ++i) { - // expects the compiler optimizes readVertex out here. - Vertex src = readVertex(_indices[offset+i]); - addWithWeight(duu, src, _duuWeights[offset+i]); - addWithWeight(duv, src, _duvWeights[offset+i]); - addWithWeight(dvv, src, _dvvWeights[offset+i]); - } - - if (duuDesc.y > 0) { // length - writeDuu(current, duu); - } - if (duvDesc.y > 0) { - writeDuv(current, duv); - } - if (dvvDesc.y > 0) { - writeDvv(current, dvv); - } -#endif +void main() +{ + int current = int(getGlobalInvocationIndex()) + batchStart; + + if (current >= batchEnd) { + return; + } + + Vertex dst; + clear(dst); + + int offset = _offsets[current], size = _sizes[current]; + + for (int stencil = 0; stencil < size; ++stencil) { + int vindex = offset + stencil; + addWithWeight(dst, readVertex(_indices[vindex]), _weights[vindex]); + } + + writeVertex(current, dst); + +# if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) + Vertex du, dv; + clear(du); + clear(dv); + for (int i = 0; i < size; ++i) { + // expects the compiler optimizes readVertex out here. + Vertex src = readVertex(_indices[offset + i]); + addWithWeight(du, src, _duWeights[offset + i]); + addWithWeight(dv, src, _dvWeights[offset + i]); + } + + if (duDesc.y > 0) { // length + writeDu(current, du); + } + if (dvDesc.y > 0) { + writeDv(current, dv); + } +# endif +# if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) + Vertex duu, duv, dvv; + clear(duu); + clear(duv); + clear(dvv); + for (int i = 0; i < size; ++i) { + // expects the compiler optimizes readVertex out here. + Vertex src = readVertex(_indices[offset + i]); + addWithWeight(duu, src, _duuWeights[offset + i]); + addWithWeight(duv, src, _duvWeights[offset + i]); + addWithWeight(dvv, src, _dvvWeights[offset + i]); + } + + if (duuDesc.y > 0) { // length + writeDuu(current, duu); + } + if (duvDesc.y > 0) { + writeDuv(current, duv); + } + if (dvvDesc.y > 0) { + writeDvv(current, dvv); + } +# endif } #endif @@ -256,61 +323,61 @@ void main() { // PERFORMANCE: stride could be constant, but not as significant as length -void main() { - - int current = int(gl_GlobalInvocationID.x); - - OsdPatchCoord coord = GetPatchCoord(current); - OsdPatchArray array = GetPatchArray(coord.arrayIndex); - OsdPatchParam param = GetPatchParam(coord.patchIndex); - - int patchType = OsdPatchParamIsRegular(param) ? array.regDesc : array.desc; - - float wP[20], wDu[20], wDv[20], wDuu[20], wDuv[20], wDvv[20]; - int nPoints = OsdEvaluatePatchBasis(patchType, param, - coord.s, coord.t, wP, wDu, wDv, wDuu, wDuv, wDvv); - - Vertex dst, du, dv, duu, duv, dvv; - clear(dst); - clear(du); - clear(dv); - clear(duu); - clear(duv); - clear(dvv); - - int indexBase = array.indexBase + array.stride * - (coord.patchIndex - array.primitiveIdBase); - - for (int cv = 0; cv < nPoints; ++cv) { - int index = patchIndexBuffer[indexBase + cv]; - addWithWeight(dst, readVertex(index), wP[cv]); - addWithWeight(du, readVertex(index), wDu[cv]); - addWithWeight(dv, readVertex(index), wDv[cv]); - addWithWeight(duu, readVertex(index), wDuu[cv]); - addWithWeight(duv, readVertex(index), wDuv[cv]); - addWithWeight(dvv, readVertex(index), wDvv[cv]); - } - writeVertex(current, dst); +void main() +{ -#if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) - if (duDesc.y > 0) { // length - writeDu(current, du); - } - if (dvDesc.y > 0) { - writeDv(current, dv); - } -#endif -#if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) - if (duuDesc.y > 0) { // length - writeDuu(current, duu); - } - if (duvDesc.y > 0) { // length - writeDuv(current, duv); - } - if (dvvDesc.y > 0) { - writeDvv(current, dvv); - } -#endif + int current = int(gl_GlobalInvocationID.x); + + OsdPatchCoord coord = GetPatchCoord(current); + OsdPatchArray array = GetPatchArray(coord.arrayIndex); + OsdPatchParam param = GetPatchParam(coord.patchIndex); + + int patchType = OsdPatchParamIsRegular(param) ? array.regDesc : array.desc; + + float wP[20], wDu[20], wDv[20], wDuu[20], wDuv[20], wDvv[20]; + int nPoints = OsdEvaluatePatchBasis( + patchType, param, coord.s, coord.t, wP, wDu, wDv, wDuu, wDuv, wDvv); + + Vertex dst, du, dv, duu, duv, dvv; + clear(dst); + clear(du); + clear(dv); + clear(duu); + clear(duv); + clear(dvv); + + int indexBase = array.indexBase + array.stride * (coord.patchIndex - array.primitiveIdBase); + + for (int cv = 0; cv < nPoints; ++cv) { + int index = patchIndexBuffer[indexBase + cv]; + addWithWeight(dst, readVertex(index), wP[cv]); + addWithWeight(du, readVertex(index), wDu[cv]); + addWithWeight(dv, readVertex(index), wDv[cv]); + addWithWeight(duu, readVertex(index), wDuu[cv]); + addWithWeight(duv, readVertex(index), wDuv[cv]); + addWithWeight(dvv, readVertex(index), wDvv[cv]); + } + writeVertex(current, dst); + +# if defined(OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES) + if (duDesc.y > 0) { // length + writeDu(current, du); + } + if (dvDesc.y > 0) { + writeDv(current, dv); + } +# endif +# if defined(OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES) + if (duuDesc.y > 0) { // length + writeDuu(current, duu); + } + if (duvDesc.y > 0) { // length + writeDuv(current, duv); + } + if (dvvDesc.y > 0) { + writeDvv(current, dvv); + } +# endif } #endif diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 77e0de611d3..958029a7453 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -104,7 +104,8 @@ struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list); /** Process the ID pointers inside a scene's keyingsets, in see `BKE_lib_query.h` for details. */ -void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, const struct ListBase *keyingsets); +void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, + const struct ListBase *keyingsets); /* Free the given Keying Set path */ void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp); diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc index 49e761d6221..78b707ee1ea 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cc @@ -44,7 +44,7 @@ void GaussianBokehBlurOperation::init_data() const float width = this->get_width(); const float height = this->get_height(); - if(execution_model_ == eExecutionModel::FullFrame) { + if (execution_model_ == eExecutionModel::FullFrame) { if (!sizeavailable_) { update_size(); } diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index 3635ceb8f13..38dd0dfc55e 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -381,7 +381,8 @@ static void gizmo_cage3d_draw_intern( } if (show) { - cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, gz->highlight_part, size_real, margin); + cage3d_draw_box_interaction( + rv3d, matrix_final, gz->color, gz->highlight_part, size_real, margin); } } else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc index dbadc33906d..48340b9eea8 100644 --- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc @@ -391,8 +391,10 @@ TEST_F(obj_exporter_regression_test, nurbs_curves_as_nurbs) _export.params.up_axis = OBJ_AXIS_Z_UP; _export.params.export_materials = false; _export.params.export_curves_as_nurbs = true; - compare_obj_export_to_golden( - "io_tests/blend_geometry/nurbs_curves.blend", "io_tests/obj/nurbs_curves.obj", "", _export.params); + compare_obj_export_to_golden("io_tests/blend_geometry/nurbs_curves.blend", + "io_tests/obj/nurbs_curves.obj", + "", + _export.params); } TEST_F(obj_exporter_regression_test, nurbs_as_mesh) |