2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
- use crate :: { binding_model, command, pipeline, resource, Color , Extent3d , Features , Origin3d } ;
5
+ use crate :: { binding_model, command, resource, Color , Extent3d , Features , Origin3d } ;
6
+ use wgt:: { BlendDescriptor , BlendFactor , ColorStateDescriptor , ColorWrite , CompareFunction , CullMode , DepthStencilStateDescriptor , FrontFace , IndexFormat , PrimitiveTopology , StencilOperation , StencilStateFaceDescriptor , TextureFormat , RasterizationStateDescriptor , VertexFormat } ;
6
7
7
8
pub fn map_buffer_usage (
8
9
usage : resource:: BufferUsage ,
@@ -104,9 +105,9 @@ pub fn map_binding_type(
104
105
}
105
106
106
107
pub fn map_shader_stage_flags (
107
- shader_stage_flags : binding_model :: ShaderStage ,
108
+ shader_stage_flags : wgt :: ShaderStage ,
108
109
) -> hal:: pso:: ShaderStageFlags {
109
- use crate :: binding_model :: ShaderStage as Ss ;
110
+ use wgt :: ShaderStage as Ss ;
110
111
use hal:: pso:: ShaderStageFlags as H ;
111
112
112
113
let mut value = H :: empty ( ) ;
@@ -139,9 +140,9 @@ pub fn map_extent(extent: Extent3d) -> hal::image::Extent {
139
140
}
140
141
141
142
pub fn map_primitive_topology (
142
- primitive_topology : pipeline :: PrimitiveTopology ,
143
+ primitive_topology : PrimitiveTopology ,
143
144
) -> hal:: pso:: Primitive {
144
- use crate :: pipeline :: PrimitiveTopology as Pt ;
145
+ use wgt :: PrimitiveTopology as Pt ;
145
146
use hal:: pso:: Primitive as H ;
146
147
match primitive_topology {
147
148
Pt :: PointList => H :: PointList ,
@@ -153,11 +154,11 @@ pub fn map_primitive_topology(
153
154
}
154
155
155
156
pub fn map_color_state_descriptor (
156
- desc : & pipeline :: ColorStateDescriptor ,
157
+ desc : & ColorStateDescriptor ,
157
158
) -> hal:: pso:: ColorBlendDesc {
158
159
let color_mask = desc. write_mask ;
159
- let blend_state = if desc. color_blend != pipeline :: BlendDescriptor :: REPLACE
160
- || desc. alpha_blend != pipeline :: BlendDescriptor :: REPLACE
160
+ let blend_state = if desc. color_blend != BlendDescriptor :: REPLACE
161
+ || desc. alpha_blend != BlendDescriptor :: REPLACE
161
162
{
162
163
Some ( hal:: pso:: BlendState {
163
164
color : map_blend_descriptor ( & desc. color_blend ) ,
@@ -172,8 +173,8 @@ pub fn map_color_state_descriptor(
172
173
}
173
174
}
174
175
175
- fn map_color_write_flags ( flags : pipeline :: ColorWrite ) -> hal:: pso:: ColorMask {
176
- use crate :: pipeline :: ColorWrite as Cw ;
176
+ fn map_color_write_flags ( flags : ColorWrite ) -> hal:: pso:: ColorMask {
177
+ use wgt :: ColorWrite as Cw ;
177
178
use hal:: pso:: ColorMask as H ;
178
179
179
180
let mut value = H :: empty ( ) ;
@@ -192,8 +193,8 @@ fn map_color_write_flags(flags: pipeline::ColorWrite) -> hal::pso::ColorMask {
192
193
value
193
194
}
194
195
195
- fn map_blend_descriptor ( blend_desc : & pipeline :: BlendDescriptor ) -> hal:: pso:: BlendOp {
196
- use crate :: pipeline :: BlendOperation as Bo ;
196
+ fn map_blend_descriptor ( blend_desc : & BlendDescriptor ) -> hal:: pso:: BlendOp {
197
+ use wgt :: BlendOperation as Bo ;
197
198
use hal:: pso:: BlendOp as H ;
198
199
match blend_desc. operation {
199
200
Bo :: Add => H :: Add {
@@ -213,8 +214,8 @@ fn map_blend_descriptor(blend_desc: &pipeline::BlendDescriptor) -> hal::pso::Ble
213
214
}
214
215
}
215
216
216
- fn map_blend_factor ( blend_factor : pipeline :: BlendFactor ) -> hal:: pso:: Factor {
217
- use crate :: pipeline :: BlendFactor as Bf ;
217
+ fn map_blend_factor ( blend_factor : BlendFactor ) -> hal:: pso:: Factor {
218
+ use wgt :: BlendFactor as Bf ;
218
219
use hal:: pso:: Factor as H ;
219
220
match blend_factor {
220
221
Bf :: Zero => H :: Zero ,
@@ -234,11 +235,11 @@ fn map_blend_factor(blend_factor: pipeline::BlendFactor) -> hal::pso::Factor {
234
235
}
235
236
236
237
pub fn map_depth_stencil_state_descriptor (
237
- desc : & pipeline :: DepthStencilStateDescriptor ,
238
+ desc : & DepthStencilStateDescriptor ,
238
239
) -> hal:: pso:: DepthStencilDesc {
239
240
hal:: pso:: DepthStencilDesc {
240
241
depth : if desc. depth_write_enabled
241
- || desc. depth_compare != resource :: CompareFunction :: Always
242
+ || desc. depth_compare != CompareFunction :: Always
242
243
{
243
244
Some ( hal:: pso:: DepthTest {
244
245
fun : map_compare_function ( desc. depth_compare ) ,
@@ -250,8 +251,8 @@ pub fn map_depth_stencil_state_descriptor(
250
251
depth_bounds : false , // TODO
251
252
stencil : if desc. stencil_read_mask != !0
252
253
|| desc. stencil_write_mask != !0
253
- || desc. stencil_front != pipeline :: StencilStateFaceDescriptor :: IGNORE
254
- || desc. stencil_back != pipeline :: StencilStateFaceDescriptor :: IGNORE
254
+ || desc. stencil_front != StencilStateFaceDescriptor :: IGNORE
255
+ || desc. stencil_back != StencilStateFaceDescriptor :: IGNORE
255
256
{
256
257
Some ( hal:: pso:: StencilTest {
257
258
faces : hal:: pso:: Sided {
@@ -273,7 +274,7 @@ pub fn map_depth_stencil_state_descriptor(
273
274
}
274
275
275
276
fn map_stencil_face (
276
- stencil_state_face_desc : & pipeline :: StencilStateFaceDescriptor ,
277
+ stencil_state_face_desc : & StencilStateFaceDescriptor ,
277
278
) -> hal:: pso:: StencilFace {
278
279
hal:: pso:: StencilFace {
279
280
fun : map_compare_function ( stencil_state_face_desc. compare ) ,
@@ -283,8 +284,8 @@ fn map_stencil_face(
283
284
}
284
285
}
285
286
286
- pub fn map_compare_function ( compare_function : resource :: CompareFunction ) -> hal:: pso:: Comparison {
287
- use crate :: resource :: CompareFunction as Cf ;
287
+ pub fn map_compare_function ( compare_function : CompareFunction ) -> hal:: pso:: Comparison {
288
+ use wgt :: CompareFunction as Cf ;
288
289
use hal:: pso:: Comparison as H ;
289
290
match compare_function {
290
291
Cf :: Never => H :: Never ,
@@ -298,8 +299,8 @@ pub fn map_compare_function(compare_function: resource::CompareFunction) -> hal:
298
299
}
299
300
}
300
301
301
- fn map_stencil_operation ( stencil_operation : pipeline :: StencilOperation ) -> hal:: pso:: StencilOp {
302
- use crate :: pipeline :: StencilOperation as So ;
302
+ fn map_stencil_operation ( stencil_operation : StencilOperation ) -> hal:: pso:: StencilOp {
303
+ use wgt :: StencilOperation as So ;
303
304
use hal:: pso:: StencilOp as H ;
304
305
match stencil_operation {
305
306
So :: Keep => H :: Keep ,
@@ -314,10 +315,10 @@ fn map_stencil_operation(stencil_operation: pipeline::StencilOperation) -> hal::
314
315
}
315
316
316
317
pub ( crate ) fn map_texture_format (
317
- texture_format : resource :: TextureFormat ,
318
+ texture_format : TextureFormat ,
318
319
features : Features ,
319
320
) -> hal:: format:: Format {
320
- use crate :: resource :: TextureFormat as Tf ;
321
+ use wgt :: TextureFormat as Tf ;
321
322
use hal:: format:: Format as H ;
322
323
match texture_format {
323
324
// Normal 8 bit formats
@@ -393,8 +394,8 @@ pub(crate) fn map_texture_format(
393
394
}
394
395
}
395
396
396
- pub fn map_vertex_format ( vertex_format : pipeline :: VertexFormat ) -> hal:: format:: Format {
397
- use crate :: pipeline :: VertexFormat as Vf ;
397
+ pub fn map_vertex_format ( vertex_format : VertexFormat ) -> hal:: format:: Format {
398
+ use wgt :: VertexFormat as Vf ;
398
399
use hal:: format:: Format as H ;
399
400
match vertex_format {
400
401
Vf :: Uchar2 => H :: Rg8Uint ,
@@ -482,9 +483,9 @@ pub fn map_texture_dimension_size(
482
483
}
483
484
484
485
pub fn map_texture_view_dimension (
485
- dimension : resource :: TextureViewDimension ,
486
+ dimension : wgt :: TextureViewDimension ,
486
487
) -> hal:: image:: ViewKind {
487
- use crate :: resource :: TextureViewDimension :: * ;
488
+ use wgt :: TextureViewDimension :: * ;
488
489
use hal:: image:: ViewKind as H ;
489
490
match dimension {
490
491
D1 => H :: D1 ,
@@ -628,19 +629,19 @@ pub fn map_wrap(address: resource::AddressMode) -> hal::image::WrapMode {
628
629
}
629
630
630
631
pub fn map_rasterization_state_descriptor (
631
- desc : & pipeline :: RasterizationStateDescriptor ,
632
+ desc : & RasterizationStateDescriptor ,
632
633
) -> hal:: pso:: Rasterizer {
633
634
hal:: pso:: Rasterizer {
634
635
depth_clamping : false ,
635
636
polygon_mode : hal:: pso:: PolygonMode :: Fill ,
636
637
cull_face : match desc. cull_mode {
637
- pipeline :: CullMode :: None => hal:: pso:: Face :: empty ( ) ,
638
- pipeline :: CullMode :: Front => hal:: pso:: Face :: FRONT ,
639
- pipeline :: CullMode :: Back => hal:: pso:: Face :: BACK ,
638
+ CullMode :: None => hal:: pso:: Face :: empty ( ) ,
639
+ CullMode :: Front => hal:: pso:: Face :: FRONT ,
640
+ CullMode :: Back => hal:: pso:: Face :: BACK ,
640
641
} ,
641
642
front_face : match desc. front_face {
642
- pipeline :: FrontFace :: Ccw => hal:: pso:: FrontFace :: CounterClockwise ,
643
- pipeline :: FrontFace :: Cw => hal:: pso:: FrontFace :: Clockwise ,
643
+ FrontFace :: Ccw => hal:: pso:: FrontFace :: CounterClockwise ,
644
+ FrontFace :: Cw => hal:: pso:: FrontFace :: Clockwise ,
644
645
} ,
645
646
depth_bias : if desc. depth_bias != 0
646
647
|| desc. depth_bias_slope_scale != 0.0
@@ -658,9 +659,9 @@ pub fn map_rasterization_state_descriptor(
658
659
}
659
660
}
660
661
661
- pub fn map_index_format ( index_format : pipeline :: IndexFormat ) -> hal:: IndexType {
662
+ pub fn map_index_format ( index_format : IndexFormat ) -> hal:: IndexType {
662
663
match index_format {
663
- pipeline :: IndexFormat :: Uint16 => hal:: IndexType :: U16 ,
664
- pipeline :: IndexFormat :: Uint32 => hal:: IndexType :: U32 ,
664
+ IndexFormat :: Uint16 => hal:: IndexType :: U16 ,
665
+ IndexFormat :: Uint32 => hal:: IndexType :: U32 ,
665
666
}
666
667
}
0 commit comments