mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 15:23:33 +00:00
hlsl-out: unlock globals.wgsl test, override skybox bindings
This commit is contained in:
parent
0d94b76d1e
commit
16206f2eb2
@ -98,7 +98,7 @@ impl<'a, W: Write> super::Writer<'a, W> {
|
||||
&mut self,
|
||||
query: WrappedImageQuery,
|
||||
) -> BackendResult {
|
||||
let dim_str = super::writer::image_dimension_str(query.dim);
|
||||
let dim_str = query.dim.to_hlsl_str();
|
||||
let class_str = match query.class {
|
||||
crate::ImageClass::Sampled { multi: true, .. } => "MS",
|
||||
crate::ImageClass::Depth => "Depth",
|
||||
|
@ -57,6 +57,17 @@ impl crate::ShaderStage {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ImageDimension {
|
||||
fn to_hlsl_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::D1 => "1D",
|
||||
Self::D2 => "2D",
|
||||
Self::D3 => "3D",
|
||||
Self::Cube => "Cube",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, thiserror::Error)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||
|
@ -343,7 +343,7 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
let (storage, register_ty) = match global.class {
|
||||
crate::StorageClass::Function => unreachable!("Function storage class"),
|
||||
crate::StorageClass::Private => ("static ", ""),
|
||||
crate::StorageClass::WorkGroup => ("shared ", ""),
|
||||
crate::StorageClass::WorkGroup => ("groupshared ", ""),
|
||||
crate::StorageClass::Uniform => ("", "b"),
|
||||
crate::StorageClass::Storage | crate::StorageClass::Handle => {
|
||||
if let TypeInner::Sampler { .. } = *inner {
|
||||
@ -359,14 +359,14 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
|
||||
write!(self.out, "{}", storage)?;
|
||||
self.write_type(module, global.ty)?;
|
||||
if let TypeInner::Array { size, .. } = module.types[global.ty].inner {
|
||||
self.write_array_size(module, size)?;
|
||||
}
|
||||
write!(
|
||||
self.out,
|
||||
" {}",
|
||||
&self.names[&NameKey::GlobalVariable(handle)]
|
||||
)?;
|
||||
if let TypeInner::Array { size, .. } = module.types[global.ty].inner {
|
||||
self.write_array_size(module, size)?;
|
||||
}
|
||||
|
||||
if let Some(ref binding) = global.binding {
|
||||
// this was already resolved earlier when we started evaluating an entry point.
|
||||
@ -604,7 +604,7 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
} => {
|
||||
use crate::ImageClass as Ic;
|
||||
|
||||
let dim_str = image_dimension_str(dim);
|
||||
let dim_str = dim.to_hlsl_str();
|
||||
let arrayed_str = if arrayed { "Array" } else { "" };
|
||||
write!(self.out, "Texture{}{}", dim_str, arrayed_str)?;
|
||||
match class {
|
||||
@ -1596,23 +1596,15 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
fn write_default_init(&mut self, module: &Module, ty: Handle<crate::Type>) -> BackendResult {
|
||||
write!(self.out, "(")?;
|
||||
self.write_type(module, ty)?;
|
||||
if let TypeInner::Array { size, .. } = module.types[ty].inner {
|
||||
self.write_array_size(module, size)?;
|
||||
}
|
||||
write!(self.out, ")0")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn image_dimension_str(dim: crate::ImageDimension) -> &'static str {
|
||||
use crate::ImageDimension as IDim;
|
||||
|
||||
match dim {
|
||||
IDim::D1 => "1D",
|
||||
IDim::D2 => "2D",
|
||||
IDim::D3 => "3D",
|
||||
IDim::Cube => "Cube",
|
||||
}
|
||||
}
|
||||
|
||||
fn builtin_str(built_in: crate::BuiltIn) -> &'static str {
|
||||
use crate::BuiltIn as Bi;
|
||||
|
||||
|
@ -45,4 +45,13 @@
|
||||
},
|
||||
),
|
||||
hlsl_custom: true,
|
||||
hlsl: (
|
||||
shader_model: V5_1,
|
||||
binding_map: {
|
||||
(group: 0, binding: 0): (space: 0, register: 0),
|
||||
(group: 0, binding: 1): (space: 0, register: 0),
|
||||
(group: 0, binding: 2): (space: 1, register: 0),
|
||||
},
|
||||
fake_missing_bindings: false,
|
||||
),
|
||||
)
|
||||
|
10
tests/out/hlsl/globals.hlsl
Normal file
10
tests/out/hlsl/globals.hlsl
Normal file
@ -0,0 +1,10 @@
|
||||
static const bool Foo = true;
|
||||
|
||||
groupshared float wg[10] = (float[10])0;
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
wg[3] = 1.0;
|
||||
return;
|
||||
}
|
2
tests/out/hlsl/globals.hlsl.config
Normal file
2
tests/out/hlsl/globals.hlsl.config
Normal file
@ -0,0 +1,2 @@
|
||||
compute=cs_5_0
|
||||
compute_name=main
|
@ -8,9 +8,9 @@ struct Data {
|
||||
float4x4 view;
|
||||
};
|
||||
|
||||
Data r_data : register(b0);
|
||||
TextureCube<float4> r_texture : register(t1);
|
||||
SamplerState r_sampler : register(s2);
|
||||
Data r_data : register(b0, space0);
|
||||
TextureCube<float4> r_texture : register(t0, space0);
|
||||
SamplerState r_sampler : register(s0, space1);
|
||||
|
||||
struct VertexInput_vs_main {
|
||||
uint vertex_index1 : SV_VertexID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
vertex=vs_5_0
|
||||
vertex=vs_5_1
|
||||
vertex_name=vs_main
|
||||
fragment=ps_5_0
|
||||
fragment=ps_5_1
|
||||
fragment_name=fs_main
|
||||
|
@ -411,7 +411,7 @@ fn convert_wgsl() {
|
||||
),
|
||||
(
|
||||
"globals",
|
||||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::WGSL,
|
||||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL,
|
||||
),
|
||||
("bounds-check-zero", Targets::SPIRV),
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user