@@ -23,6 +23,18 @@ pub enum ColorLoadOp {
2323 Clear ( [ f64 ; 4 ] ) ,
2424}
2525
26+ impl ColorLoadOp {
27+ /// Convert to the platform color load operation.
28+ pub ( crate ) fn to_platform ( self ) -> platform:: render_pass:: ColorLoadOp {
29+ return match self {
30+ ColorLoadOp :: Load => platform:: render_pass:: ColorLoadOp :: Load ,
31+ ColorLoadOp :: Clear ( color) => {
32+ platform:: render_pass:: ColorLoadOp :: Clear ( color)
33+ }
34+ } ;
35+ }
36+ }
37+
2638/// Store operation for the first color attachment.
2739#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
2840pub enum StoreOp {
@@ -32,6 +44,16 @@ pub enum StoreOp {
3244 Discard ,
3345}
3446
47+ impl StoreOp {
48+ /// Convert to the platform store operation.
49+ pub ( crate ) fn to_platform ( self ) -> platform:: render_pass:: StoreOp {
50+ return match self {
51+ StoreOp :: Store => platform:: render_pass:: StoreOp :: Store ,
52+ StoreOp :: Discard => platform:: render_pass:: StoreOp :: Discard ,
53+ } ;
54+ }
55+ }
56+
3557/// Combined color operations for the first color attachment.
3658#[ derive( Debug , Clone , Copy , PartialEq ) ]
3759pub struct ColorOperations {
@@ -48,6 +70,18 @@ impl Default for ColorOperations {
4870 }
4971}
5072
73+ impl ColorOperations {
74+ /// Convert to the platform color load and store operations.
75+ pub ( crate ) fn to_platform (
76+ self ,
77+ ) -> (
78+ platform:: render_pass:: ColorLoadOp ,
79+ platform:: render_pass:: StoreOp ,
80+ ) {
81+ return ( self . load . to_platform ( ) , self . store . to_platform ( ) ) ;
82+ }
83+ }
84+
5185/// Depth load operation for the depth attachment.
5286#[ derive( Debug , Clone , Copy , PartialEq ) ]
5387pub enum DepthLoadOp {
@@ -57,6 +91,18 @@ pub enum DepthLoadOp {
5791 Clear ( f64 ) ,
5892}
5993
94+ impl DepthLoadOp {
95+ /// Convert to the platform depth load operation.
96+ pub ( crate ) fn to_platform ( self ) -> platform:: render_pass:: DepthLoadOp {
97+ return match self {
98+ DepthLoadOp :: Load => platform:: render_pass:: DepthLoadOp :: Load ,
99+ DepthLoadOp :: Clear ( value) => {
100+ platform:: render_pass:: DepthLoadOp :: Clear ( value as f32 )
101+ }
102+ } ;
103+ }
104+ }
105+
60106/// Depth operations for the first depth attachment.
61107#[ derive( Debug , Clone , Copy , PartialEq ) ]
62108pub struct DepthOperations {
@@ -73,6 +119,16 @@ impl Default for DepthOperations {
73119 }
74120}
75121
122+ impl DepthOperations {
123+ /// Convert to the platform depth operations.
124+ pub ( crate ) fn to_platform ( self ) -> platform:: render_pass:: DepthOperations {
125+ return platform:: render_pass:: DepthOperations {
126+ load : self . load . to_platform ( ) ,
127+ store : self . store . to_platform ( ) ,
128+ } ;
129+ }
130+ }
131+
76132/// Immutable parameters used when beginning a render pass.
77133#[ derive( Debug , Clone ) ]
78134///
@@ -361,6 +417,18 @@ pub enum StencilLoadOp {
361417 Clear ( u32 ) ,
362418}
363419
420+ impl StencilLoadOp {
421+ /// Convert to the platform stencil load operation.
422+ pub ( crate ) fn to_platform ( self ) -> platform:: render_pass:: StencilLoadOp {
423+ return match self {
424+ StencilLoadOp :: Load => platform:: render_pass:: StencilLoadOp :: Load ,
425+ StencilLoadOp :: Clear ( value) => {
426+ platform:: render_pass:: StencilLoadOp :: Clear ( value)
427+ }
428+ } ;
429+ }
430+ }
431+
364432/// Stencil operations for the first stencil attachment.
365433#[ derive( Debug , Clone , Copy , PartialEq ) ]
366434pub struct StencilOperations {
@@ -377,6 +445,16 @@ impl Default for StencilOperations {
377445 }
378446}
379447
448+ impl StencilOperations {
449+ /// Convert to the platform stencil operations.
450+ pub ( crate ) fn to_platform ( self ) -> platform:: render_pass:: StencilOperations {
451+ return platform:: render_pass:: StencilOperations {
452+ load : self . load . to_platform ( ) ,
453+ store : self . store . to_platform ( ) ,
454+ } ;
455+ }
456+ }
457+
380458#[ cfg( test) ]
381459mod tests {
382460 use std:: cell:: RefCell ;
0 commit comments