• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DAWNNATIVE_RENDERPASSENCODER_H_
16 #define DAWNNATIVE_RENDERPASSENCODER_H_
17 
18 #include "dawn_native/Error.h"
19 #include "dawn_native/ProgrammablePassEncoder.h"
20 
21 namespace dawn_native {
22 
23     // This is called RenderPassEncoderBase to match the code generator expectations. Note that it
24     // is a pure frontend type to record in its parent CommandEncoder and never has a backend
25     // implementation.
26     // TODO(cwallez@chromium.org): Remove that generator limitation and rename to ComputePassEncoder
27     class RenderPassEncoderBase : public ProgrammablePassEncoder {
28       public:
29         RenderPassEncoderBase(DeviceBase* device,
30                               CommandEncoderBase* topLevelEncoder,
31                               CommandAllocator* allocator);
32 
33         static RenderPassEncoderBase* MakeError(DeviceBase* device,
34                                                 CommandEncoderBase* topLevelEncoder);
35 
36         void Draw(uint32_t vertexCount,
37                   uint32_t instanceCount,
38                   uint32_t firstVertex,
39                   uint32_t firstInstance);
40         void DrawIndexed(uint32_t vertexCount,
41                          uint32_t instanceCount,
42                          uint32_t firstIndex,
43                          int32_t baseVertex,
44                          uint32_t firstInstance);
45 
46         void DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
47         void DrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
48 
49         void SetPipeline(RenderPipelineBase* pipeline);
50 
51         void SetStencilReference(uint32_t reference);
52         void SetBlendColor(const Color* color);
53         void SetViewport(float x,
54                          float y,
55                          float width,
56                          float height,
57                          float minDepth,
58                          float maxDepth);
59         void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
60 
61         template <typename T>
SetVertexBuffers(uint32_t startSlot,uint32_t count,T * const * buffers,uint64_t const * offsets)62         void SetVertexBuffers(uint32_t startSlot,
63                               uint32_t count,
64                               T* const* buffers,
65                               uint64_t const* offsets) {
66             static_assert(std::is_base_of<BufferBase, T>::value, "");
67             SetVertexBuffers(startSlot, count, buffers, offsets);
68         }
69         void SetVertexBuffers(uint32_t startSlot,
70                               uint32_t count,
71                               BufferBase* const* buffers,
72                               uint64_t const* offsets);
73         void SetIndexBuffer(BufferBase* buffer, uint64_t offset);
74 
75       protected:
76         RenderPassEncoderBase(DeviceBase* device,
77                               CommandEncoderBase* topLevelEncoder,
78                               ErrorTag errorTag);
79     };
80 
81 }  // namespace dawn_native
82 
83 #endif  // DAWNNATIVE_RENDERPASSENCODER_H_
84