mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 01:23:57 +01:00
Add Undefined variant to CompareFunction
This commit is contained in:
1 parent
98e18c5ac8
commit
1702a54c5c
4 files changed
+35
-65
No files matched your search
+11
-10
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* Generated with cbindgen:0.13.1 */
|
||||
/* Generated with cbindgen:0.13.2 */
|
||||
|
||||
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
|
||||
* To generate this file:
|
||||
@@ -80,14 +80,15 @@ typedef enum {
|
||||
} WGPUBufferMapAsyncStatus;
|
||||
|
||||
typedef enum {
|
||||
WGPUCompareFunction_Never = 0,
|
||||
WGPUCompareFunction_Less = 1,
|
||||
WGPUCompareFunction_Equal = 2,
|
||||
WGPUCompareFunction_LessEqual = 3,
|
||||
WGPUCompareFunction_Greater = 4,
|
||||
WGPUCompareFunction_NotEqual = 5,
|
||||
WGPUCompareFunction_GreaterEqual = 6,
|
||||
WGPUCompareFunction_Always = 7,
|
||||
WGPUCompareFunction_Undefined = 0,
|
||||
WGPUCompareFunction_Never = 1,
|
||||
WGPUCompareFunction_Less = 2,
|
||||
WGPUCompareFunction_Equal = 3,
|
||||
WGPUCompareFunction_LessEqual = 4,
|
||||
WGPUCompareFunction_Greater = 5,
|
||||
WGPUCompareFunction_NotEqual = 6,
|
||||
WGPUCompareFunction_GreaterEqual = 7,
|
||||
WGPUCompareFunction_Always = 8,
|
||||
} WGPUCompareFunction;
|
||||
|
||||
typedef enum {
|
||||
@@ -640,7 +641,7 @@ typedef struct {
|
||||
WGPUFilterMode mipmap_filter;
|
||||
float lod_min_clamp;
|
||||
float lod_max_clamp;
|
||||
const WGPUCompareFunction *compare;
|
||||
WGPUCompareFunction compare;
|
||||
} WGPUSamplerDescriptor;
|
||||
|
||||
typedef struct {
|
||||
|
||||
+12
-11
@@ -297,7 +297,7 @@ pub fn map_depth_stencil_state_descriptor(
|
||||
|| desc.depth_compare != CompareFunction::Always
|
||||
{
|
||||
Some(hal::pso::DepthTest {
|
||||
fun: map_compare_function(desc.depth_compare),
|
||||
fun: map_compare_function(desc.depth_compare).expect("DepthStencilStateDescriptor has undefined compare function"),
|
||||
write: desc.depth_write_enabled,
|
||||
})
|
||||
} else {
|
||||
@@ -332,25 +332,26 @@ fn map_stencil_face(
|
||||
stencil_state_face_desc: &StencilStateFaceDescriptor,
|
||||
) -> hal::pso::StencilFace {
|
||||
hal::pso::StencilFace {
|
||||
fun: map_compare_function(stencil_state_face_desc.compare),
|
||||
fun: map_compare_function(stencil_state_face_desc.compare).expect("StencilStateFaceDescriptor has undefined compare function"),
|
||||
op_fail: map_stencil_operation(stencil_state_face_desc.fail_op),
|
||||
op_depth_fail: map_stencil_operation(stencil_state_face_desc.depth_fail_op),
|
||||
op_pass: map_stencil_operation(stencil_state_face_desc.pass_op),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_compare_function(compare_function: CompareFunction) -> hal::pso::Comparison {
|
||||
pub fn map_compare_function(compare_function: CompareFunction) -> Option<hal::pso::Comparison> {
|
||||
use wgt::CompareFunction as Cf;
|
||||
use hal::pso::Comparison as H;
|
||||
match compare_function {
|
||||
Cf::Never => H::Never,
|
||||
Cf::Less => H::Less,
|
||||
Cf::Equal => H::Equal,
|
||||
Cf::LessEqual => H::LessEqual,
|
||||
Cf::Greater => H::Greater,
|
||||
Cf::NotEqual => H::NotEqual,
|
||||
Cf::GreaterEqual => H::GreaterEqual,
|
||||
Cf::Always => H::Always,
|
||||
Cf::Undefined => None,
|
||||
Cf::Never => Some(H::Never),
|
||||
Cf::Less => Some(H::Less),
|
||||
Cf::Equal => Some(H::Equal),
|
||||
Cf::LessEqual => Some(H::LessEqual),
|
||||
Cf::Greater => Some(H::Greater),
|
||||
Cf::NotEqual => Some(H::NotEqual),
|
||||
Cf::GreaterEqual => Some(H::GreaterEqual),
|
||||
Cf::Always => Some(H::Always),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -846,7 +846,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
),
|
||||
lod_bias: hal::image::Lod(0.0),
|
||||
lod_range: hal::image::Lod(desc.lod_min_clamp) .. hal::image::Lod(desc.lod_max_clamp),
|
||||
comparison: desc.compare.cloned().map(conv::map_compare_function),
|
||||
comparison: conv::map_compare_function(desc.compare),
|
||||
border: hal::image::PackedColor(0),
|
||||
normalized: true,
|
||||
anisotropy_clamp: None, //TODO
|
||||
|
||||
+11
-43
@@ -450,14 +450,15 @@ impl Default for StencilStateFaceDescriptor {
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum CompareFunction {
|
||||
Never = 0,
|
||||
Less = 1,
|
||||
Equal = 2,
|
||||
LessEqual = 3,
|
||||
Greater = 4,
|
||||
NotEqual = 5,
|
||||
GreaterEqual = 6,
|
||||
Always = 7,
|
||||
Undefined = 0,
|
||||
Never = 1,
|
||||
Less = 2,
|
||||
Equal = 3,
|
||||
LessEqual = 4,
|
||||
Greater = 5,
|
||||
NotEqual = 6,
|
||||
GreaterEqual = 7,
|
||||
Always = 8,
|
||||
}
|
||||
|
||||
impl CompareFunction {
|
||||
@@ -841,7 +842,7 @@ impl Default for FilterMode {
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct SamplerDescriptor<'a> {
|
||||
pub struct SamplerDescriptor {
|
||||
pub address_mode_u: AddressMode,
|
||||
pub address_mode_v: AddressMode,
|
||||
pub address_mode_w: AddressMode,
|
||||
@@ -850,40 +851,7 @@ pub struct SamplerDescriptor<'a> {
|
||||
pub mipmap_filter: FilterMode,
|
||||
pub lod_min_clamp: f32,
|
||||
pub lod_max_clamp: f32,
|
||||
#[cfg_attr(feature = "serde", serde(deserialize_with="deserialise_sampler_compare_function::deserialize"))]
|
||||
pub compare: Option<&'a CompareFunction>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
mod deserialise_sampler_compare_function {
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use super::CompareFunction;
|
||||
|
||||
static NEVER: CompareFunction = CompareFunction::Never;
|
||||
static LESS: CompareFunction = CompareFunction::Less;
|
||||
static EQUAL: CompareFunction = CompareFunction::Equal;
|
||||
static LESS_EQUAL: CompareFunction = CompareFunction::LessEqual;
|
||||
static GREATER: CompareFunction = CompareFunction::Greater;
|
||||
static NOT_EQUAL: CompareFunction = CompareFunction::NotEqual;
|
||||
static GREATER_EQUAL: CompareFunction = CompareFunction::GreaterEqual;
|
||||
static ALWAYS: CompareFunction = CompareFunction::Always;
|
||||
|
||||
pub fn deserialize<'de, D>(d: D) -> Result<Option<&'static CompareFunction>, D::Error> where D: Deserializer<'de> {
|
||||
let compare = Option::<CompareFunction>::deserialize(d)?;
|
||||
let static_compare = compare.map(|compare| {
|
||||
match compare {
|
||||
CompareFunction::Never => &NEVER,
|
||||
CompareFunction::Less => &LESS,
|
||||
CompareFunction::Equal => &EQUAL,
|
||||
CompareFunction::LessEqual => &LESS_EQUAL,
|
||||
CompareFunction::Greater => &GREATER,
|
||||
CompareFunction::NotEqual => &NOT_EQUAL,
|
||||
CompareFunction::GreaterEqual => &GREATER_EQUAL,
|
||||
CompareFunction::Always => &ALWAYS,
|
||||
}
|
||||
});
|
||||
Ok(static_compare)
|
||||
}
|
||||
pub compare: CompareFunction,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
||||
Reference in new issue
Block a user