Stephen White | 985741a | 2019-07-18 11:43:45 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | 52337de | 2019-07-25 09:00:52 -0500 | [diff] [blame^] | 8 | #include "src/gpu/dawn/GrDawnGpuCommandBuffer.h" |
Stephen White | 985741a | 2019-07-18 11:43:45 -0400 | [diff] [blame] | 9 | |
Mike Klein | 52337de | 2019-07-25 09:00:52 -0500 | [diff] [blame^] | 10 | #include "include/core/SkRect.h" |
Stephen White | 985741a | 2019-07-18 11:43:45 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrFixedClip.h" |
| 12 | #include "src/gpu/GrMesh.h" |
| 13 | #include "src/gpu/GrOpFlushState.h" |
| 14 | #include "src/gpu/GrPipeline.h" |
| 15 | #include "src/gpu/GrRenderTargetPriv.h" |
| 16 | #include "src/gpu/GrTexturePriv.h" |
| 17 | #include "src/gpu/dawn/GrDawnGpu.h" |
| 18 | #include "src/gpu/dawn/GrDawnRenderTarget.h" |
Stephen White | 985741a | 2019-07-18 11:43:45 -0400 | [diff] [blame] | 19 | |
| 20 | void GrDawnGpuTextureCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect, |
| 21 | const SkIPoint& dstPoint) { |
| 22 | } |
| 23 | |
| 24 | void GrDawnGpuTextureCommandBuffer::insertEventMarker(const char* msg) { |
| 25 | } |
| 26 | |
| 27 | void GrDawnGpuTextureCommandBuffer::submit() { |
| 28 | for (int i = 0; i < fCopies.count(); ++i) { |
| 29 | CopyInfo& copyInfo = fCopies[i]; |
| 30 | fGpu->copySurface(fTexture, copyInfo.fSrc, copyInfo.fSrcRect, copyInfo.fDstPoint); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | GrDawnGpuTextureCommandBuffer::~GrDawnGpuTextureCommandBuffer() {} |
| 35 | |
| 36 | //////////////////////////////////////////////////////////////////////////////// |
| 37 | |
| 38 | dawn::LoadOp to_dawn_load_op(GrLoadOp loadOp) { |
| 39 | switch (loadOp) { |
| 40 | case GrLoadOp::kLoad: |
| 41 | return dawn::LoadOp::Load; |
| 42 | case GrLoadOp::kClear: |
| 43 | return dawn::LoadOp::Clear; |
| 44 | case GrLoadOp::kDiscard: |
| 45 | default: |
| 46 | SK_ABORT("Invalid LoadOp"); |
| 47 | return dawn::LoadOp::Load; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | GrDawnGpuRTCommandBuffer::GrDawnGpuRTCommandBuffer(GrDawnGpu* gpu, |
| 52 | GrRenderTarget* rt, GrSurfaceOrigin origin, |
| 53 | const LoadAndStoreInfo& colorInfo, |
| 54 | const StencilLoadAndStoreInfo& stencilInfo) |
| 55 | : INHERITED(rt, origin) |
| 56 | , fGpu(gpu) { |
| 57 | this->init(); |
| 58 | } |
| 59 | |
| 60 | void GrDawnGpuRTCommandBuffer::init() { |
| 61 | } |
| 62 | |
| 63 | |
| 64 | GrDawnGpuRTCommandBuffer::~GrDawnGpuRTCommandBuffer() { |
| 65 | } |
| 66 | |
| 67 | GrGpu* GrDawnGpuRTCommandBuffer::gpu() { return fGpu; } |
| 68 | |
| 69 | void GrDawnGpuRTCommandBuffer::end() { |
| 70 | } |
| 71 | |
| 72 | void GrDawnGpuRTCommandBuffer::submit() { |
| 73 | if (fCommandBuffer) { |
| 74 | fGpu->queue().Submit(1, &fCommandBuffer); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void GrDawnGpuRTCommandBuffer::insertEventMarker(const char* msg) { |
| 79 | } |
| 80 | |
| 81 | void GrDawnGpuRTCommandBuffer::transferFrom(const SkIRect& srcRect, GrColorType bufferColorType, |
| 82 | GrGpuBuffer* transferBuffer, size_t offset) { |
| 83 | fGpu->transferPixelsFrom(fRenderTarget, srcRect.fLeft, srcRect.fTop, srcRect.width(), |
| 84 | srcRect.height(), bufferColorType, transferBuffer, offset); |
| 85 | } |
| 86 | |
| 87 | void GrDawnGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) { |
| 88 | } |
| 89 | |
| 90 | void GrDawnGpuRTCommandBuffer::onClear(const GrFixedClip& clip, const SkPMColor4f& color) { |
| 91 | } |
| 92 | |
| 93 | //////////////////////////////////////////////////////////////////////////////// |
| 94 | |
| 95 | void GrDawnGpuRTCommandBuffer::inlineUpload(GrOpFlushState* state, |
| 96 | GrDeferredTextureUploadFn& upload) { |
| 97 | } |
| 98 | |
| 99 | void GrDawnGpuRTCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect, |
| 100 | const SkIPoint& dstPoint) { |
| 101 | } |
| 102 | |
| 103 | //////////////////////////////////////////////////////////////////////////////// |
| 104 | |
| 105 | void GrDawnGpuRTCommandBuffer::bindGeometry(const GrBuffer* indexBuffer, |
| 106 | const GrBuffer* vertexBuffer, |
| 107 | const GrBuffer* instanceBuffer) { |
| 108 | } |
| 109 | |
| 110 | void GrDawnGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc, |
| 111 | const GrPipeline& pipeline, |
| 112 | const GrPipeline::FixedDynamicState* fixedDynamicState, |
| 113 | const GrPipeline::DynamicStateArrays* dynamicStateArrays, |
| 114 | const GrMesh meshes[], |
| 115 | int meshCount, |
| 116 | const SkRect& bounds) { |
| 117 | if (!meshCount) { |
| 118 | return; |
| 119 | } |
| 120 | GrFragmentProcessor::Iter iter(pipeline); |
| 121 | |
| 122 | for (int i = 0; i < meshCount; ++i) { |
| 123 | const GrMesh& mesh = meshes[i]; |
| 124 | mesh.sendToGpu(this); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | void GrDawnGpuRTCommandBuffer::sendInstancedMeshToGpu(GrPrimitiveType, |
| 129 | const GrBuffer* vertexBuffer, |
| 130 | int vertexCount, |
| 131 | int baseVertex, |
| 132 | const GrBuffer* instanceBuffer, |
| 133 | int instanceCount, |
| 134 | int baseInstance) { |
| 135 | this->bindGeometry(nullptr, vertexBuffer, instanceBuffer); |
| 136 | fGpu->stats()->incNumDraws(); |
| 137 | } |
| 138 | |
| 139 | void GrDawnGpuRTCommandBuffer::sendIndexedInstancedMeshToGpu(GrPrimitiveType, |
| 140 | const GrBuffer* indexBuffer, |
| 141 | int indexCount, |
| 142 | int baseIndex, |
| 143 | const GrBuffer* vertexBuffer, |
| 144 | int baseVertex, |
| 145 | const GrBuffer* instanceBuffer, |
| 146 | int instanceCount, |
| 147 | int baseInstance, |
| 148 | GrPrimitiveRestart restart) { |
| 149 | this->bindGeometry(indexBuffer, vertexBuffer, instanceBuffer); |
| 150 | fGpu->stats()->incNumDraws(); |
| 151 | } |
| 152 | |