23 auto seed = fml::HashCombine();
24 fml::HashCombineSeed(seed, label_);
25 fml::HashCombineSeed(seed, sample_count_);
26 for (
const auto& entry : entrypoints_) {
27 fml::HashCombineSeed(seed, entry.first);
28 if (
auto second = entry.second) {
29 fml::HashCombineSeed(seed, second->GetHash());
32 for (
const auto& des : color_attachment_descriptors_) {
33 fml::HashCombineSeed(seed, des.first);
34 fml::HashCombineSeed(seed, des.second.Hash());
36 if (vertex_descriptor_) {
37 fml::HashCombineSeed(seed, vertex_descriptor_->GetHash());
39 fml::HashCombineSeed(seed, depth_pixel_format_);
40 fml::HashCombineSeed(seed, stencil_pixel_format_);
41 fml::HashCombineSeed(seed, depth_attachment_descriptor_);
42 fml::HashCombineSeed(seed, front_stencil_attachment_descriptor_);
43 fml::HashCombineSeed(seed, back_stencil_attachment_descriptor_);
44 fml::HashCombineSeed(seed, winding_order_);
45 fml::HashCombineSeed(seed, cull_mode_);
46 fml::HashCombineSeed(seed, primitive_type_);
47 fml::HashCombineSeed(seed, polygon_mode_);
53 return label_ == other.label_ && sample_count_ == other.sample_count_ &&
55 color_attachment_descriptors_ == other.color_attachment_descriptors_ &&
57 stencil_pixel_format_ == other.stencil_pixel_format_ &&
58 depth_pixel_format_ == other.depth_pixel_format_ &&
59 depth_attachment_descriptor_ == other.depth_attachment_descriptor_ &&
60 front_stencil_attachment_descriptor_ ==
61 other.front_stencil_attachment_descriptor_ &&
62 back_stencil_attachment_descriptor_ ==
63 other.back_stencil_attachment_descriptor_ &&
64 winding_order_ == other.winding_order_ &&
65 cull_mode_ == other.cull_mode_ &&
66 primitive_type_ == other.primitive_type_ &&
67 polygon_mode_ == other.polygon_mode_ &&
68 specialization_constants_ == other.specialization_constants_;
72 label_ = std::move(label);
77 sample_count_ = samples;
82 std::shared_ptr<const ShaderFunction>
function) {
91 entrypoints_[
function->GetStage()] = std::move(
function);
97 std::shared_ptr<VertexDescriptor> vertex_descriptor) {
98 vertex_descriptor_ = std::move(vertex_descriptor);
104 for (
const auto& color : color_attachment_descriptors_) {
105 max = std::max(color.first, max);
113 color_attachment_descriptors_[index] = desc;
118 std::map<size_t /* index */, ColorAttachmentDescriptor> descriptors) {
119 color_attachment_descriptors_ = std::move(descriptors);
125 auto found = color_attachment_descriptors_.find(index);
126 return found == color_attachment_descriptors_.end() ? nullptr
133 if (color_attachment_descriptors_.size() != 1u) {
141 depth_pixel_format_ = format;
147 stencil_pixel_format_ = format;
152 std::optional<DepthAttachmentDescriptor> desc) {
153 depth_attachment_descriptor_ = desc;
158 std::optional<StencilAttachmentDescriptor> front_and_back) {
163 std::optional<StencilAttachmentDescriptor> front,
164 std::optional<StencilAttachmentDescriptor> back) {
165 front_stencil_attachment_descriptor_ = front;
166 back_stencil_attachment_descriptor_ = back;
171 back_stencil_attachment_descriptor_.reset();
172 front_stencil_attachment_descriptor_.reset();
177 depth_attachment_descriptor_.reset();
182 if (color_attachment_descriptors_.find(index) ==
183 color_attachment_descriptors_.end()) {
187 color_attachment_descriptors_.erase(index);
191 color_attachment_descriptors_.clear();
192 depth_attachment_descriptor_.reset();
193 front_stencil_attachment_descriptor_.reset();
194 back_stencil_attachment_descriptor_.reset();
198 return stencil_pixel_format_;
201 std::optional<StencilAttachmentDescriptor>
203 return front_stencil_attachment_descriptor_;
206 std::optional<DepthAttachmentDescriptor>
208 return depth_attachment_descriptor_;
213 return color_attachment_descriptors_;
216 const std::shared_ptr<VertexDescriptor>&
218 return vertex_descriptor_;
221 const std::map<ShaderStage, std::shared_ptr<const ShaderFunction>>&
228 if (
auto found = entrypoints_.find(stage); found != entrypoints_.end()) {
229 return found->second;
239 return depth_pixel_format_;
242 std::optional<StencilAttachmentDescriptor>
244 return back_stencil_attachment_descriptor_;
248 return front_stencil_attachment_descriptor_.has_value() ||
249 back_stencil_attachment_descriptor_.has_value();
261 winding_order_ = order;
265 return winding_order_;
269 primitive_type_ = type;
273 return primitive_type_;
277 polygon_mode_ = mode;
281 return polygon_mode_;
285 std::vector<Scalar> values) {
286 specialization_constants_ = std::move(values);
291 return specialization_constants_;