blob: 39e3169b6530ab184ed848126f7036306a4487ee [file] [log] [blame]
Stephen White985741a2019-07-18 11:43:45 -04001/*
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
8#include "GrDawnGpuCommandBuffer.h"
9
10#include "src/gpu/GrFixedClip.h"
11#include "src/gpu/GrMesh.h"
12#include "src/gpu/GrOpFlushState.h"
13#include "src/gpu/GrPipeline.h"
14#include "src/gpu/GrRenderTargetPriv.h"
15#include "src/gpu/GrTexturePriv.h"
16#include "src/gpu/dawn/GrDawnGpu.h"
17#include "src/gpu/dawn/GrDawnRenderTarget.h"
18#include "include/core/SkRect.h"
19
20void GrDawnGpuTextureCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
21 const SkIPoint& dstPoint) {
22}
23
24void GrDawnGpuTextureCommandBuffer::insertEventMarker(const char* msg) {
25}
26
27void 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
34GrDawnGpuTextureCommandBuffer::~GrDawnGpuTextureCommandBuffer() {}
35
36////////////////////////////////////////////////////////////////////////////////
37
38dawn::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
51GrDawnGpuRTCommandBuffer::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
60void GrDawnGpuRTCommandBuffer::init() {
61}
62
63
64GrDawnGpuRTCommandBuffer::~GrDawnGpuRTCommandBuffer() {
65}
66
67GrGpu* GrDawnGpuRTCommandBuffer::gpu() { return fGpu; }
68
69void GrDawnGpuRTCommandBuffer::end() {
70}
71
72void GrDawnGpuRTCommandBuffer::submit() {
73 if (fCommandBuffer) {
74 fGpu->queue().Submit(1, &fCommandBuffer);
75 }
76}
77
78void GrDawnGpuRTCommandBuffer::insertEventMarker(const char* msg) {
79}
80
81void 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
87void GrDawnGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
88}
89
90void GrDawnGpuRTCommandBuffer::onClear(const GrFixedClip& clip, const SkPMColor4f& color) {
91}
92
93////////////////////////////////////////////////////////////////////////////////
94
95void GrDawnGpuRTCommandBuffer::inlineUpload(GrOpFlushState* state,
96 GrDeferredTextureUploadFn& upload) {
97}
98
99void GrDawnGpuRTCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
100 const SkIPoint& dstPoint) {
101}
102
103////////////////////////////////////////////////////////////////////////////////
104
105void GrDawnGpuRTCommandBuffer::bindGeometry(const GrBuffer* indexBuffer,
106 const GrBuffer* vertexBuffer,
107 const GrBuffer* instanceBuffer) {
108}
109
110void 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
128void 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
139void 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