blob: 694e67ac13f1d66d1717cc08d61c88c75ef4f7fa [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
Mike Klein52337de2019-07-25 09:00:52 -05008#include "src/gpu/dawn/GrDawnGpuCommandBuffer.h"
Stephen White985741a2019-07-18 11:43:45 -04009
Mike Klein52337de2019-07-25 09:00:52 -050010#include "include/core/SkRect.h"
Stephen White985741a2019-07-18 11:43:45 -040011#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 White985741a2019-07-18 11:43:45 -040019
20void GrDawnGpuTextureCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
21 const SkIPoint& dstPoint) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040022 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040023}
24
25void GrDawnGpuTextureCommandBuffer::insertEventMarker(const char* msg) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040026 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040027}
28
29void 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
36GrDawnGpuTextureCommandBuffer::~GrDawnGpuTextureCommandBuffer() {}
37
38////////////////////////////////////////////////////////////////////////////////
39
40dawn::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
53GrDawnGpuRTCommandBuffer::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
62void GrDawnGpuRTCommandBuffer::init() {
63}
64
65
66GrDawnGpuRTCommandBuffer::~GrDawnGpuRTCommandBuffer() {
67}
68
69GrGpu* GrDawnGpuRTCommandBuffer::gpu() { return fGpu; }
70
71void GrDawnGpuRTCommandBuffer::end() {
72}
73
74void GrDawnGpuRTCommandBuffer::submit() {
75 if (fCommandBuffer) {
76 fGpu->queue().Submit(1, &fCommandBuffer);
77 }
78}
79
80void GrDawnGpuRTCommandBuffer::insertEventMarker(const char* msg) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040081 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040082}
83
84void 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
90void GrDawnGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040091 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040092}
93
94void GrDawnGpuRTCommandBuffer::onClear(const GrFixedClip& clip, const SkPMColor4f& color) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040095 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040096}
97
98////////////////////////////////////////////////////////////////////////////////
99
100void GrDawnGpuRTCommandBuffer::inlineUpload(GrOpFlushState* state,
101 GrDeferredTextureUploadFn& upload) {
Stephen Whitec0a837f2019-07-30 11:38:22 -0400102 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -0400103}
104
105void GrDawnGpuRTCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
106 const SkIPoint& dstPoint) {
Stephen Whitec0a837f2019-07-30 11:38:22 -0400107 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -0400108}
109
110////////////////////////////////////////////////////////////////////////////////
111
112void GrDawnGpuRTCommandBuffer::bindGeometry(const GrBuffer* indexBuffer,
113 const GrBuffer* vertexBuffer,
114 const GrBuffer* instanceBuffer) {
115}
116
117void 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
135void 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
146void 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