765: Update naga to gfx-11 r=cwfitzgerald a=kvark

Gets us https://github.com/gfx-rs/wgpu/pull/1220

Note that "cross" feature is not optional here. We could lift it up and add to `default = []` but that would make the Web backend to always unconditionally depend on `wgpu-core` (since enabling a feature on it automatically enables it). So we ideally need a way for Cargo to allow platform-specific default features...

About the shadow example - the experimental translation works on the main pipeline, but fails on the baking pipeline because of https://github.com/gfx-rs/naga/issues/483. Fortunately, it falls back to SPIRV-Cross gracefully here.

The new validation detected a flaw in our shader (comparison sampler mismatch), yay!

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot] 2021-02-19 05:03:27 +00:00 committed by GitHub
commit b75f6118bb
6 changed files with 31 additions and 20 deletions

View File

@ -26,20 +26,20 @@ webgl = ["wgc"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "05a531191d4ce2927f2157e5dd54b7aa5d779406"
features = ["raw-window-handle"]
rev = "5afe832c3c8e3417e4ad4d95f92a3f65379467ff"
features = ["raw-window-handle", "cross"]
[target.'cfg(target_arch = "wasm32")'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "05a531191d4ce2927f2157e5dd54b7aa5d779406"
features = ["raw-window-handle"]
rev = "5afe832c3c8e3417e4ad4d95f92a3f65379467ff"
features = ["raw-window-handle", "cross"]
optional = true
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "05a531191d4ce2927f2157e5dd54b7aa5d779406"
rev = "5afe832c3c8e3417e4ad4d95f92a3f65379467ff"
[dependencies]
arrayvec = "0.5"
@ -54,7 +54,7 @@ bytemuck = { version = "1.4", features = ["derive"] }
cgmath = "0.18"
ddsfile = "0.4"
log = "0.4"
naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-10", features = ["wgsl-in"] }
naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-11", features = ["wgsl-in"] }
noise = "0.7"
obj = "0.10"
png = "0.16"
@ -68,7 +68,7 @@ wgpu-subscriber = "0.1"
[target.'cfg(target_arch = "wasm32")'.dependencies.naga]
git = "https://github.com/gfx-rs/naga"
tag = "gfx-10"
tag = "gfx-11"
features = ["wgsl-in", "spv-out"]
[[example]]

View File

@ -421,7 +421,7 @@ impl framework::Example for Example {
let mut flags = wgpu::ShaderFlags::VALIDATION;
match adapter.get_info().backend {
wgpu::Backend::Vulkan => {
wgpu::Backend::Metal | wgpu::Backend::Vulkan => {
flags |= wgpu::ShaderFlags::EXPERIMENTAL_TRANSLATION;
}
_ => (), //TODO

View File

@ -62,7 +62,7 @@ var<storage> s_lights: [[access(read)]] Lights;
[[group(0), binding(2)]]
var t_shadow: texture_depth_2d_array;
[[group(0), binding(3)]]
var sampler_shadow: sampler;
var sampler_shadow: sampler_comparison;
fn fetch_shadow(light_id: u32, homogeneous_coords: vec4<f32>) -> f32 {
if (homogeneous_coords.w <= 0.0) {

View File

@ -1050,7 +1050,12 @@ impl crate::Context for Context {
let module = wgsl::parse_str(code).unwrap();
let mut capabilities = HashSet::default();
capabilities.insert(spv::Capability::Shader);
let words = spv::write_vec(&module, spv::WriterFlags::NONE, capabilities).unwrap();
let options = spv::Options {
lang_version: (1, 0),
flags: spv::WriterFlags::empty(),
capabilities,
};
let words = spv::write_vec(&module, &options).unwrap();
web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&words[..]))
}
};

View File

@ -27,12 +27,12 @@ use parking_lot::Mutex;
pub use wgt::{
AdapterInfo, AddressMode, Backend, BackendBit, BindGroupLayoutEntry, BindingType, BlendFactor,
BlendOperation, BlendState, BufferAddress, BufferBindingType, BufferSize, BufferUsage, Color,
ColorTargetState, ColorWrite, CommandBufferDescriptor, CompareFunction, Face,
DepthBiasState, DepthStencilState, DeviceType, DynamicOffset, Extent3d, Features, FilterMode,
FrontFace, IndexFormat, InputStepMode, Limits, MultisampleState, Origin3d,
PipelineStatisticsTypes, PolygonMode, PowerPreference, PresentMode, PrimitiveState,
PrimitiveTopology, PushConstantRange, QuerySetDescriptor, QueryType, SamplerBorderColor,
ShaderFlags, ShaderLocation, ShaderStage, StencilFaceState, StencilOperation, StencilState,
ColorTargetState, ColorWrite, CommandBufferDescriptor, CompareFunction, DepthBiasState,
DepthStencilState, DeviceType, DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace,
IndexFormat, InputStepMode, Limits, MultisampleState, Origin3d, PipelineStatisticsTypes,
PolygonMode, PowerPreference, PresentMode, PrimitiveState, PrimitiveTopology,
PushConstantRange, QuerySetDescriptor, QueryType, SamplerBorderColor, ShaderFlags,
ShaderLocation, ShaderStage, StencilFaceState, StencilOperation, StencilState,
StorageTextureAccess, SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureDataLayout,
TextureDimension, TextureFormat, TextureSampleType, TextureUsage, TextureViewDimension,
VertexAttribute, VertexFormat, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT,

View File

@ -61,7 +61,11 @@ pub struct DownloadBuffer(super::Buffer, super::BufferMappedRange);
impl DownloadBuffer {
/// Asynchronously read the contents of a buffer.
pub fn read_buffer(device: &super::Device, queue: &super::Queue, buffer: &super::BufferSlice) -> impl Future<Output=Result<Self, super::BufferAsyncError>> + Send {
pub fn read_buffer(
device: &super::Device,
queue: &super::Queue,
buffer: &super::BufferSlice,
) -> impl Future<Output = Result<Self, super::BufferAsyncError>> + Send {
let size = match buffer.size {
Some(size) => size.into(),
None => buffer.buffer.map_context.lock().total_size - buffer.offset,
@ -74,7 +78,8 @@ impl DownloadBuffer {
label: None,
});
let mut encoder = device.create_command_encoder(&super::CommandEncoderDescriptor { label: None });
let mut encoder =
device.create_command_encoder(&super::CommandEncoderDescriptor { label: None });
encoder.copy_buffer_to_buffer(buffer.buffer, buffer.offset, &download, 0, size);
let command_buffer: super::CommandBuffer = encoder.finish();
queue.submit(Some(command_buffer));
@ -82,13 +87,14 @@ impl DownloadBuffer {
let fut = download.slice(..).map_async(super::MapMode::Read);
async move {
fut.await?;
let mapped_range = super::Context::buffer_get_mapped_range(&*download.context, &download.id, 0..size);
let mapped_range =
super::Context::buffer_get_mapped_range(&*download.context, &download.id, 0..size);
Ok(Self(download, mapped_range))
}
}
}
impl std::ops::Deref for DownloadBuffer{
impl std::ops::Deref for DownloadBuffer {
type Target = [u8];
fn deref(&self) -> &[u8] {
super::BufferMappedRangeSlice::slice(&self.1)