Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGpuCommandBuffer_DEFINED | 8 #ifndef GrGpuCommandBuffer_DEFINED |
| 9 #define GrGpuCommandBuffer_DEFINED | 9 #define GrGpuCommandBuffer_DEFINED |
| 10 | 10 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 | 12 |
| 13 class GrGpu; | |
| 14 class GrMesh; | |
| 15 class GrPipeline; | |
| 16 class GrPrimitiveProcessor; | |
| 13 class GrRenderTarget; | 17 class GrRenderTarget; |
| 18 struct SkIRect; | |
| 14 | 19 |
| 20 /** | |
| 21 * The GrGpuCommandBuffer is a series of commands (draws, clears, and discards), which all target | |
| 22 * the same render target. It is possible that these commands execute immediatel y (GL), or get | |
| 23 * buffered up for later execution (Vulkan). Currently GrBatches will execute th eir draw commands | |
|
bsalomon
2016/06/23 02:12:55
Why "Currently"? Is this likely to change?
egdaniel
2016/06/23 13:57:08
Removed. I put currently at first, cause technical
| |
| 24 * into a GrGpuCommandBuffer. | |
| 25 */ | |
| 15 class GrGpuCommandBuffer { | 26 class GrGpuCommandBuffer { |
| 16 public: | 27 public: |
| 17 enum LoadAndStoreOp { | 28 enum LoadOp { |
|
bsalomon
2016/06/23 02:12:55
enum classes? No strong preference but it is the f
egdaniel
2016/06/23 13:57:08
Done.
| |
| 18 kLoadAndStore_LoadAndStoreOp, | 29 kLoad_LoadOp, |
| 19 kLoadAndDiscard_LoadAndStoreOp, | 30 kClear_LoadOp, |
| 20 kClearAndStore_LoadAndStoreOp, | 31 kDiscard_LoadOp, |
| 21 kClearAndDiscard_LoadAndStoreOp, | 32 }; |
| 22 kDiscardAndStore_LoadAndStoreOp, | 33 |
| 23 kDiscardAndDiscard_LoadAndStoreOp, | 34 enum StoreOp { |
| 35 kStore_StoreOp, | |
| 36 kDiscard_StoreOp, | |
| 37 }; | |
| 38 | |
| 39 struct LoadAndStoreInfo { | |
| 40 LoadOp fLoadOp; | |
| 41 StoreOp fStoreOp; | |
| 42 GrColor fClearColor; | |
| 43 | |
| 44 LoadAndStoreInfo(LoadOp loadOp, StoreOp storeOp, GrColor color = GrColor _ILLEGAL) | |
|
bsalomon
2016/06/23 02:12:55
It seems like you have this constructor in order t
egdaniel
2016/06/23 13:57:08
when with pure struct.
| |
| 45 : fLoadOp(loadOp) | |
| 46 , fStoreOp(storeOp) | |
| 47 , fClearColor(color) { | |
| 48 SkASSERT(kClear_LoadOp != fLoadOp || GrColor_ILLEGAL != fClearColor) ; | |
| 49 } | |
| 24 }; | 50 }; |
| 25 | 51 |
| 26 GrGpuCommandBuffer() {} | 52 GrGpuCommandBuffer() {} |
| 27 virtual ~GrGpuCommandBuffer() {} | 53 virtual ~GrGpuCommandBuffer() {} |
| 28 | 54 |
| 29 // Signals the end of recording to the command buffer and that it can now be submitted. | 55 // Signals the end of recording to the command buffer and that it can now be submitted. |
| 30 virtual void end() = 0; | 56 virtual void end() = 0; |
| 31 | 57 |
| 32 // Sends the command buffer off to the GPU object to execute the commands bu ilt up in the | 58 // Sends the command buffer off to the GPU object to execute the commands bu ilt up in the |
| 33 // buffer. The gpu object is allowed to defer execution of the commands unti l it is flushed. | 59 // buffer. The gpu object is allowed to defer execution of the commands unti l it is flushed. |
| 34 virtual void submit() = 0; | 60 // The bounds should represent the bounds of all the draws put into the comm and buffer. |
| 61 void submit(const SkIRect& bounds); | |
| 62 | |
| 63 // We pass in an array of meshCount GrMesh to the draw. The backend should l oop over each | |
| 64 // GrMesh object and emit a draw for it. Each draw will use the same GrPipel ine and | |
| 65 // GrPrimitiveProcessor. This may fail if the draw would exceed any resource limits (e.g. | |
| 66 // number of vertex attributes is too large). | |
| 67 bool draw(const GrPipeline&, | |
| 68 const GrPrimitiveProcessor&, | |
| 69 const GrMesh*, | |
| 70 int meshCount); | |
| 71 | |
| 72 /** | |
| 73 * Clear the passed in render target. Ignores the draw state and clip. | |
| 74 */ | |
| 75 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) ; | |
| 76 | |
| 77 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget); | |
| 78 /** | |
| 79 * Discards the contents render target. nullptr indicates that the current re nder target should | |
| 80 * be discarded. | |
| 81 **/ | |
| 82 // TODO: This should be removed in the future to favor using the load and st ore ops for discard | |
| 83 virtual void discard(GrRenderTarget* = nullptr) = 0; | |
| 84 | |
| 85 private: | |
| 86 virtual GrGpu* gpu() = 0; | |
| 87 virtual void onSubmit(const SkIRect& bounds) = 0; | |
| 88 | |
| 89 // overridden by backend-specific derived class to perform the draw call. | |
| 90 virtual void onDraw(const GrPipeline&, | |
| 91 const GrPrimitiveProcessor&, | |
| 92 const GrMesh*, | |
| 93 int meshCount) = 0; | |
| 94 | |
| 95 // overridden by backend-specific derived class to perform the clear. | |
| 96 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; | |
| 97 | |
| 98 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; | |
| 99 | |
| 35 }; | 100 }; |
| 36 | 101 |
| 37 #endif | 102 #endif |
| OLD | NEW |