Handle kMatrixMultiply in ByteCode -> SkVM
Raster backend now draws the bump-mapped cube sample! Change-Id: I4ad74c50a329dcd0c9b56f2a18b1e32fd5c5eccd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297815 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
e66636c332
commit
ad43e54bfb
@ -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"); }
|
||||
|
||||
|
@ -705,6 +705,27 @@ static std::vector<skvm::F32> 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<skvm::F32> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user