Fix depth clamping semantics

This commit is contained in:
Dzmitry Malyshau 2019-02-26 22:36:58 -05:00
parent cdc9d65395
commit d631b2c6f2
7 changed files with 12 additions and 15 deletions

View File

@ -40,7 +40,7 @@ fn main() {
cull_mode: wgpu::CullMode::None,
depth_bias: 0,
depth_bias_slope_scale: 0.0,
depth_bias_clamp: wgpu::MAX_DEPTH_BIAS_CLAMP,
depth_bias_clamp: 0.0,
},
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[

View File

@ -280,7 +280,7 @@ impl framework::Example for Example {
cull_mode: wgpu::CullMode::Back,
depth_bias: 0,
depth_bias_slope_scale: 0.0,
depth_bias_clamp: wgpu::MAX_DEPTH_BIAS_CLAMP,
depth_bias_clamp: 0.0,
},
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[

View File

@ -219,7 +219,7 @@ impl framework::Example for Example {
});
let local_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
bindings: &[
bindings: &[
wgpu::BindGroupLayoutBinding {
binding: 0,
visibility: wgpu::ShaderStageFlags::VERTEX | wgpu::ShaderStageFlags::FRAGMENT,
@ -380,7 +380,7 @@ impl framework::Example for Example {
let light_uniform_size = (Self::MAX_LIGHTS * mem::size_of::<LightRaw>()) as u32;
let light_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
size: light_uniform_size,
usage: wgpu::BufferUsageFlags::UNIFORM | wgpu::BufferUsageFlags::TRANSFER_DST,
usage: wgpu::BufferUsageFlags::UNIFORM | wgpu::BufferUsageFlags::TRANSFER_SRC | wgpu::BufferUsageFlags::TRANSFER_DST,
});
let vb_desc = wgpu::VertexBufferDescriptor {
@ -459,7 +459,7 @@ impl framework::Example for Example {
cull_mode: wgpu::CullMode::Back,
depth_bias: 2, // corresponds to bilinear filtering
depth_bias_slope_scale: 2.0,
depth_bias_clamp: wgpu::MAX_DEPTH_BIAS_CLAMP,
depth_bias_clamp: 0.0,
},
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[],
@ -579,7 +579,7 @@ impl framework::Example for Example {
cull_mode: wgpu::CullMode::Back,
depth_bias: 0,
depth_bias_slope_scale: 0.0,
depth_bias_clamp: wgpu::MAX_DEPTH_BIAS_CLAMP,
depth_bias_clamp: 0.0,
},
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[

View File

@ -5,8 +5,6 @@
#define WGPUBITS_PER_BYTE 8
#define WGPUMAX_DEPTH_BIAS_CLAMP 16
typedef enum {
WGPUAddressMode_ClampToEdge = 0,
WGPUAddressMode_Repeat = 1,
@ -169,6 +167,8 @@ typedef struct {
WGPUExtensions extensions;
} WGPUDeviceDescriptor;
typedef WGPUId WGPUBindGroupId;
typedef WGPUId WGPUBufferId;
typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, const uint8_t *data, uint8_t *userdata);
@ -243,8 +243,6 @@ typedef struct {
const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment;
} WGPURenderPassDescriptor;
typedef WGPUId WGPUBindGroupId;
typedef WGPUId WGPUComputePipelineId;
typedef WGPUId WGPUInstanceId;
@ -557,6 +555,8 @@ typedef struct {
WGPUDeviceId wgpu_adapter_create_device(WGPUAdapterId adapter_id, const WGPUDeviceDescriptor *desc);
void wgpu_bind_group_destroy(WGPUBindGroupId bind_group_id);
void wgpu_buffer_destroy(WGPUBufferId buffer_id);
void wgpu_buffer_map_read_async(WGPUBufferId buffer_id,

View File

@ -1,7 +1,6 @@
use crate::{
binding_model, command, pipeline, resource, Color,
Extent3d, Origin3d,
MAX_DEPTH_BIAS_CLAMP,
};
@ -491,7 +490,7 @@ pub fn map_rasterization_state_descriptor(
pipeline::FrontFace::Ccw => hal::pso::FrontFace::CounterClockwise,
pipeline::FrontFace::Cw => hal::pso::FrontFace::Clockwise,
},
depth_bias: if desc.depth_bias != 0 || desc.depth_bias_slope_scale != 0.0 || desc.depth_bias_clamp < MAX_DEPTH_BIAS_CLAMP {
depth_bias: if desc.depth_bias != 0 || desc.depth_bias_slope_scale != 0.0 || desc.depth_bias_clamp != 0.0 {
Some(hal::pso::State::Static(hal::pso::DepthBias {
const_factor: desc.depth_bias as f32,
slope_factor: desc.depth_bias_slope_scale,

View File

@ -44,7 +44,6 @@ pub use self::hub::{HUB, Id, IdentityManager, Registry};
use std::ptr;
use std::sync::atomic::{AtomicUsize, Ordering};
pub const MAX_DEPTH_BIAS_CLAMP: f32 = 16.0;
type SubmissionIndex = usize;
//TODO: make it private. Currently used for swapchain creation impl.

View File

@ -10,7 +10,6 @@ use std::slice;
pub use wgn::winit;
pub use wgn::{
MAX_DEPTH_BIAS_CLAMP,
AdapterDescriptor, BindGroupLayoutBinding, BindingType,
BlendDescriptor, BlendOperation, BlendFactor, BufferMapAsyncStatus, ColorWriteFlags,
RasterizationStateDescriptor, CullMode, FrontFace,
@ -253,7 +252,7 @@ impl Instance {
id: wgn::wgpu_instance_create_surface_from_winit(self.id, window),
}
}
#[cfg(feature = "metal")]
pub fn create_surface_with_metal_layer(&self, window: *mut std::ffi::c_void) -> Surface {
Surface {