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