blob: d2db9a624ec26c1761b515177ecb1b2ac200f1ee [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
Stephen Whited7325182019-08-02 17:22:59 -040084void GrDawnGpuRTCommandBuffer::transferFrom(const SkIRect& srcRect, GrColorType surfaceColorType,
85 GrColorType bufferColorType,
Stephen White985741a2019-07-18 11:43:45 -040086 GrGpuBuffer* transferBuffer, size_t offset) {
87 fGpu->transferPixelsFrom(fRenderTarget, srcRect.fLeft, srcRect.fTop, srcRect.width(),
Stephen Whited7325182019-08-02 17:22:59 -040088 srcRect.height(), surfaceColorType, bufferColorType, transferBuffer,
89 offset);
Stephen White985741a2019-07-18 11:43:45 -040090}
91
92void GrDawnGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040093 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040094}
95
96void GrDawnGpuRTCommandBuffer::onClear(const GrFixedClip& clip, const SkPMColor4f& color) {
Stephen Whitec0a837f2019-07-30 11:38:22 -040097 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -040098}
99
100////////////////////////////////////////////////////////////////////////////////
101
102void GrDawnGpuRTCommandBuffer::inlineUpload(GrOpFlushState* state,
103 GrDeferredTextureUploadFn& upload) {
Stephen Whitec0a837f2019-07-30 11:38:22 -0400104 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -0400105}
106
107void GrDawnGpuRTCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
108 const SkIPoint& dstPoint) {
Stephen Whitec0a837f2019-07-30 11:38:22 -0400109 SkASSERT(!"unimplemented");
Stephen White985741a2019-07-18 11:43:45 -0400110}
111
112////////////////////////////////////////////////////////////////////////////////
113
114void GrDawnGpuRTCommandBuffer::bindGeometry(const GrBuffer* indexBuffer,
115 const GrBuffer* vertexBuffer,
116 const GrBuffer* instanceBuffer) {
117}
118
119void GrDawnGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
120 const GrPipeline& pipeline,
121 const GrPipeline::FixedDynamicState* fixedDynamicState,
122 const GrPipeline::DynamicStateArrays* dynamicStateArrays,
123 const GrMesh meshes[],
124 int meshCount,
125 const SkRect& bounds) {
126 if (!meshCount) {
127 return;
128 }
129 GrFragmentProcessor::Iter iter(pipeline);
130
131 for (int i = 0; i < meshCount; ++i) {
132 const GrMesh& mesh = meshes[i];
133 mesh.sendToGpu(this);
134 }
135}
136
137void GrDawnGpuRTCommandBuffer::sendInstancedMeshToGpu(GrPrimitiveType,
138 const GrBuffer* vertexBuffer,
139 int vertexCount,
140 int baseVertex,
141 const GrBuffer* instanceBuffer,
142 int instanceCount,
143 int baseInstance) {
144 this->bindGeometry(nullptr, vertexBuffer, instanceBuffer);
145 fGpu->stats()->incNumDraws();
146}
147
148void GrDawnGpuRTCommandBuffer::sendIndexedInstancedMeshToGpu(GrPrimitiveType,
149 const GrBuffer* indexBuffer,
150 int indexCount,
151 int baseIndex,
152 const GrBuffer* vertexBuffer,
153 int baseVertex,
154 const GrBuffer* instanceBuffer,
155 int instanceCount,
156 int baseInstance,
157 GrPrimitiveRestart restart) {
158 this->bindGeometry(indexBuffer, vertexBuffer, instanceBuffer);
159 fGpu->stats()->incNumDraws();
160}
161