| Flutter Impeller |

pass_bindings_cache.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/renderer/backend/vulkan/pass_bindings_cache.h"
6
7 namespace impeller {
8 void PassBindingsCache::BindPipeline(vk::CommandBuffer command_buffer,
9 vk::PipelineBindPoint pipeline_bind_point,
10 vk::Pipeline pipeline) {
11 switch (pipeline_bind_point) {
12 case vk::PipelineBindPoint::eGraphics:
13 if (graphics_pipeline_.has_value() &&
14 graphics_pipeline_.value() == pipeline) {
15 return;
16 }
17 graphics_pipeline_ = pipeline;
18 break;
19 case vk::PipelineBindPoint::eCompute:
20 if (compute_pipeline_.has_value() &&
21 compute_pipeline_.value() == pipeline) {
22 return;
23 }
24 compute_pipeline_ = pipeline;
25 break;
26 default:
27 break;
28 }
29 command_buffer.bindPipeline(pipeline_bind_point, pipeline);
30 }
31
32 void PassBindingsCache::SetStencilReference(vk::CommandBuffer command_buffer,
33 vk::StencilFaceFlags face_mask,
34 uint32_t reference) {
35 if (stencil_face_flags_.has_value() &&
36 face_mask == stencil_face_flags_.value() &&
37 reference == stencil_reference_) {
38 return;
39 }
40 stencil_face_flags_ = face_mask;
41 stencil_reference_ = reference;
42 command_buffer.setStencilReference(face_mask, reference);
43 }
44
45 void PassBindingsCache::SetScissor(vk::CommandBuffer command_buffer,
46 uint32_t first_scissor,
47 uint32_t scissor_count,
48 const vk::Rect2D* scissors) {
49 if (first_scissor == 0 && scissor_count == 1) {
50 if (scissors_.has_value() && scissors_.value() == scissors[0]) {
51 return;
52 }
53 scissors_ = scissors[0];
54 }
55 command_buffer.setScissor(first_scissor, scissor_count, scissors);
56 }
57
58 void PassBindingsCache::SetViewport(vk::CommandBuffer command_buffer,
59 uint32_t first_viewport,
60 uint32_t viewport_count,
61 const vk::Viewport* viewports) {
62 if (first_viewport == 0 && viewport_count == 1) {
63 // Note that this is doing equality checks on floating point numbers.
64 if (viewport_.has_value() && viewport_.value() == viewports[0]) {
65 return;
66 }
67 viewport_ = viewports[0];
68 }
69 command_buffer.setViewport(first_viewport, viewport_count, viewports);
70 }
71
72 } // namespace impeller
impeller::PassBindingsCache::SetStencilReference
void SetStencilReference(vk::CommandBuffer command_buffer, vk::StencilFaceFlags face_mask, uint32_t reference)
Definition: pass_bindings_cache.cc:32
impeller::PassBindingsCache::SetScissor
void SetScissor(const IRect &scissor)
Definition: render_pass_mtl.mm:323
pass_bindings_cache.h
impeller::PassBindingsCache::SetViewport
void SetViewport(const Viewport &viewport)
Definition: render_pass_mtl.mm:308
impeller
Definition: aiks_context.cc:10
impeller::PassBindingsCache::BindPipeline
void BindPipeline(vk::CommandBuffer command_buffer, vk::PipelineBindPoint pipeline_bind_point, vk::Pipeline pipeline)
Definition: pass_bindings_cache.cc:8