mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[hlsl-out] Don't output interpolation modifier if it's the default (#1809)
* hlsl-out: don't output interpolation modifier if it's the default (linear/`Interpolation::Perspective`) * Remove linear interpolation modifiers from HLSL output tests
This commit is contained in:
@@ -111,12 +111,14 @@ impl crate::BuiltIn {
|
||||
}
|
||||
|
||||
impl crate::Interpolation {
|
||||
/// Helper function that returns the string corresponding to the HLSL interpolation qualifier
|
||||
pub(super) fn to_hlsl_str(self) -> &'static str {
|
||||
/// Return the string corresponding to the HLSL interpolation qualifier.
|
||||
pub(super) fn to_hlsl_str(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::Perspective => "linear",
|
||||
Self::Linear => "noperspective",
|
||||
Self::Flat => "nointerpolation",
|
||||
// Would be "linear", but it's the default interpolation in SM4 and up
|
||||
// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-struct#interpolation-modifiers-introduced-in-shader-model-4
|
||||
Self::Perspective => None,
|
||||
Self::Linear => Some("noperspective"),
|
||||
Self::Flat => Some("nointerpolation"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -758,7 +758,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
||||
}) = member.binding
|
||||
{
|
||||
if let Some(interpolation) = interpolation {
|
||||
write!(self.out, "{} ", interpolation.to_hlsl_str())?
|
||||
if let Some(string) = interpolation.to_hlsl_str() {
|
||||
write!(self.out, "{} ", string)?
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(sampling) = sampling {
|
||||
|
||||
@@ -7,13 +7,13 @@ ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1);
|
||||
|
||||
struct VertexOutput {
|
||||
float4 position : SV_Position;
|
||||
linear float varying : LOC1;
|
||||
float varying : LOC1;
|
||||
};
|
||||
|
||||
struct FragmentOutput {
|
||||
float depth : SV_Depth;
|
||||
uint sample_mask : SV_Coverage;
|
||||
linear float color : SV_Target0;
|
||||
float color : SV_Target0;
|
||||
};
|
||||
|
||||
struct Input1_ {
|
||||
|
||||
@@ -5,9 +5,9 @@ struct FragmentInput {
|
||||
noperspective float linear_ : LOC1;
|
||||
noperspective centroid float2 linear_centroid : LOC2;
|
||||
noperspective sample float3 linear_sample : LOC3;
|
||||
linear float4 perspective : LOC4;
|
||||
linear centroid float perspective_centroid : LOC5;
|
||||
linear sample float perspective_sample : LOC6;
|
||||
float4 perspective : LOC4;
|
||||
centroid float perspective_centroid : LOC5;
|
||||
sample float perspective_sample : LOC6;
|
||||
};
|
||||
|
||||
struct VertexOutput_vert_main {
|
||||
|
||||
@@ -7,7 +7,7 @@ struct gl_PerVertex {
|
||||
};
|
||||
|
||||
struct type_9 {
|
||||
linear float2 member : LOC0;
|
||||
float2 member : LOC0;
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
static const float c_scale = 1.2000000476837158;
|
||||
|
||||
struct VertexOutput {
|
||||
linear float2 uv : LOC0;
|
||||
float2 uv : LOC0;
|
||||
float4 position : SV_Position;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ struct Entity {
|
||||
|
||||
struct VertexOutput {
|
||||
float4 proj_position : SV_Position;
|
||||
linear float3 world_normal : LOC0;
|
||||
linear float4 world_position : LOC1;
|
||||
float3 world_normal : LOC0;
|
||||
float4 world_position : LOC1;
|
||||
};
|
||||
|
||||
struct Light {
|
||||
|
||||
@@ -7,7 +7,7 @@ ConstantBuffer<NagaConstants> _NagaConstants: register(b1);
|
||||
|
||||
struct VertexOutput {
|
||||
float4 position : SV_Position;
|
||||
linear float3 uv : LOC0;
|
||||
float3 uv : LOC0;
|
||||
};
|
||||
|
||||
struct Data {
|
||||
|
||||
Reference in New Issue
Block a user