20 auto seed = fml::HashCombine();
21 fml::HashCombineSeed(seed, label_);
22 fml::HashCombineSeed(seed, sample_count_);
23 for (
const auto& entry : entrypoints_) {
24 fml::HashCombineSeed(seed, entry.first);
25 if (
auto second = entry.second) {
26 fml::HashCombineSeed(seed, second->GetHash());
29 for (
const auto& des : color_attachment_descriptors_) {
30 fml::HashCombineSeed(seed, des.first);
31 fml::HashCombineSeed(seed, des.second.Hash());
33 if (vertex_descriptor_) {
34 fml::HashCombineSeed(seed, vertex_descriptor_->GetHash());
36 fml::HashCombineSeed(seed, depth_pixel_format_);
37 fml::HashCombineSeed(seed, stencil_pixel_format_);
38 fml::HashCombineSeed(seed, depth_attachment_descriptor_);
39 fml::HashCombineSeed(seed, front_stencil_attachment_descriptor_);
40 fml::HashCombineSeed(seed, back_stencil_attachment_descriptor_);
41 fml::HashCombineSeed(seed, winding_order_);
42 fml::HashCombineSeed(seed, cull_mode_);
43 fml::HashCombineSeed(seed, primitive_type_);
44 fml::HashCombineSeed(seed, polygon_mode_);
50 return label_ == other.label_ && sample_count_ == other.sample_count_ &&
52 color_attachment_descriptors_ == other.color_attachment_descriptors_ &&
54 stencil_pixel_format_ == other.stencil_pixel_format_ &&
55 depth_pixel_format_ == other.depth_pixel_format_ &&
56 depth_attachment_descriptor_ == other.depth_attachment_descriptor_ &&
57 front_stencil_attachment_descriptor_ ==
58 other.front_stencil_attachment_descriptor_ &&
59 back_stencil_attachment_descriptor_ ==
60 other.back_stencil_attachment_descriptor_ &&
61 winding_order_ == other.winding_order_ &&
62 cull_mode_ == other.cull_mode_ &&
63 primitive_type_ == other.primitive_type_ &&
64 polygon_mode_ == other.polygon_mode_;
68 label_ = std::move(label);
73 sample_count_ = samples;
78 std::shared_ptr<const ShaderFunction>
function) {
87 entrypoints_[
function->GetStage()] = std::move(
function);
93 std::shared_ptr<VertexDescriptor> vertex_descriptor) {
94 vertex_descriptor_ = std::move(vertex_descriptor);
100 for (
const auto& color : color_attachment_descriptors_) {
101 max = std::max(color.first, max);
109 color_attachment_descriptors_[index] = desc;
114 std::map<size_t /* index */, ColorAttachmentDescriptor> descriptors) {
115 color_attachment_descriptors_ = std::move(descriptors);
121 auto found = color_attachment_descriptors_.find(index);
122 return found == color_attachment_descriptors_.end() ? nullptr
129 if (color_attachment_descriptors_.size() != 1u) {
137 depth_pixel_format_ = format;
143 stencil_pixel_format_ = format;
148 std::optional<DepthAttachmentDescriptor> desc) {
149 depth_attachment_descriptor_ = desc;
154 std::optional<StencilAttachmentDescriptor> front_and_back) {
159 std::optional<StencilAttachmentDescriptor> front,
160 std::optional<StencilAttachmentDescriptor> back) {
161 front_stencil_attachment_descriptor_ = front;
162 back_stencil_attachment_descriptor_ = back;
167 back_stencil_attachment_descriptor_.reset();
168 front_stencil_attachment_descriptor_.reset();
173 depth_attachment_descriptor_.reset();
178 if (color_attachment_descriptors_.find(index) ==
179 color_attachment_descriptors_.end()) {
183 color_attachment_descriptors_.erase(index);
187 color_attachment_descriptors_.clear();
188 depth_attachment_descriptor_.reset();
189 front_stencil_attachment_descriptor_.reset();
190 back_stencil_attachment_descriptor_.reset();
194 return stencil_pixel_format_;
197 std::optional<StencilAttachmentDescriptor>
199 return front_stencil_attachment_descriptor_;
202 std::optional<DepthAttachmentDescriptor>
204 return depth_attachment_descriptor_;
209 return color_attachment_descriptors_;
212 const std::shared_ptr<VertexDescriptor>&
214 return vertex_descriptor_;
217 const std::map<ShaderStage, std::shared_ptr<const ShaderFunction>>&
224 if (
auto found = entrypoints_.find(stage); found != entrypoints_.end()) {
225 return found->second;
235 return depth_pixel_format_;
238 std::optional<StencilAttachmentDescriptor>
240 return back_stencil_attachment_descriptor_;
244 return front_stencil_attachment_descriptor_.has_value() ||
245 back_stencil_attachment_descriptor_.has_value();
257 winding_order_ = order;
261 return winding_order_;
265 primitive_type_ = type;
269 return primitive_type_;
273 polygon_mode_ = mode;
277 return polygon_mode_;