diff --git a/samplecode/Sample3D.cpp b/samplecode/Sample3D.cpp index e54fc9fb54..0ee2c4cb5b 100644 --- a/samplecode/Sample3D.cpp +++ b/samplecode/Sample3D.cpp @@ -356,7 +356,7 @@ class SampleBump3D : public SampleCubeBase { SkRRect fRR; public: - SampleBump3D() : SampleCubeBase(kShowLightDome) {} + SampleBump3D() : SampleCubeBase(Flags(kCanRunOnCPU | kShowLightDome)) {} SkString name() override { return SkString("bump3d"); } diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp index dea730d296..acab69c8d5 100644 --- a/src/core/SkRuntimeEffect.cpp +++ b/src/core/SkRuntimeEffect.cpp @@ -705,6 +705,27 @@ static std::vector program_fn(skvm::Builder* p, case Inst::kSin3: case Inst::kSin4: unary(Inst::kSin, skvm::approx_sin); break; + case Inst::kMatrixMultiply: { + // Computes M = A*B (all stored column major) + int aCols = u8(), + aRows = u8(), + bCols = u8(), + bRows = aCols; + std::vector A(aCols*aRows), + B(bCols*bRows); + for (auto i = B.size(); i --> 0;) { B[i] = pop(); } + for (auto i = A.size(); i --> 0;) { A[i] = pop(); } + + for (int c = 0; c < bCols; ++c) + for (int r = 0; r < aRows; ++r) { + skvm::F32 sum = p->splat(0.0f); + for (int j = 0; j < aCols; ++j) { + sum += A[j*aRows + r] * B[c*bRows + j]; + } + push(sum); + } + } break; + // Baby steps... just leaving test conditions on the stack for now. case Inst::kMaskPush: break; case Inst::kMaskNegate: break;