-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[msl-out] Introduce a per-entry-point resource binding map option
The existing `per_stage_map` field of MSL backend options specifies resource binding maps that apply to all entry points of each stage type. It is useful to have the ability to provide a separate binding index map for each entry point, especially when the same shader module defines multiple entry points of the same stage kind. This patch introduces a new per-entry-point mapping option. When fields are missing in the per-entry-point map, the code falls back to the existing `per_stage_map` option as before.
- Loading branch information
Showing
6 changed files
with
184 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
( | ||
god_mode: true, | ||
msl: ( | ||
lang_version: (2, 0), | ||
per_stage_map: ( | ||
fs: ( | ||
resources: { | ||
(group: 0, binding: 0): (texture: Some(0)), | ||
(group: 0, binding: 1): (sampler: Some(Inline(0))), | ||
}, | ||
) | ||
), | ||
per_entry_point_map: Some({ | ||
"entry_point_two": ( | ||
resources: { | ||
(group: 0, binding: 0): (texture: Some(1)), | ||
(group: 0, binding: 1): (sampler: Some(Resource(1))), | ||
(group: 0, binding: 2): (buffer: Some(0)), | ||
} | ||
), | ||
"entry_point_three": ( | ||
resources: { | ||
(group: 0, binding: 2): (buffer: Some(0)), | ||
(group: 1, binding: 0): (buffer: Some(1)), | ||
} | ||
) | ||
}), | ||
inline_samplers: [ | ||
( | ||
coord: Normalized, | ||
address: (ClampToEdge, ClampToEdge, ClampToEdge), | ||
mag_filter: Linear, | ||
min_filter: Linear, | ||
mip_filter: None, | ||
border_color: TransparentBlack, | ||
compare_func: Never, | ||
lod_clamp: Some((start: 0.5, end: 10.0)), | ||
max_anisotropy: Some(8), | ||
), | ||
], | ||
spirv_cross_compatibility: false, | ||
fake_missing_bindings: false, | ||
zero_initialize_workgroup_memory: true, | ||
), | ||
bounds_check_policies: ( | ||
index: ReadZeroSkipWrite, | ||
buffer: ReadZeroSkipWrite, | ||
image: ReadZeroSkipWrite, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@group(0) @binding(0) var t: texture_2d<f32>; | ||
@group(0) @binding(1) var s: sampler; | ||
|
||
@group(0) @binding(2) var<uniform> uniformOne: vec2<f32>; | ||
@group(1) @binding(0) var<uniform> uniformTwo: vec2<f32>; | ||
|
||
@fragment | ||
fn entry_point_one(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> { | ||
return textureSample(t, s, pos.xy); | ||
} | ||
|
||
@fragment | ||
fn entry_point_two() -> @location(0) vec4<f32> { | ||
return textureSample(t, s, uniformOne); | ||
} | ||
|
||
@fragment | ||
fn entry_point_three() -> @location(0) vec4<f32> { | ||
return textureSample(t, s, uniformTwo + uniformOne); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// language: metal2.0 | ||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using metal::uint; | ||
|
||
struct DefaultConstructible { | ||
template<typename T> | ||
operator T() && { | ||
return T {}; | ||
} | ||
}; | ||
|
||
struct entry_point_oneInput { | ||
}; | ||
struct entry_point_oneOutput { | ||
metal::float4 member [[color(0)]]; | ||
}; | ||
fragment entry_point_oneOutput entry_point_one( | ||
metal::float4 pos [[position]] | ||
, metal::texture2d<float, metal::access::sample> t [[texture(0)]] | ||
) { | ||
constexpr metal::sampler s( | ||
metal::s_address::clamp_to_edge, | ||
metal::t_address::clamp_to_edge, | ||
metal::r_address::clamp_to_edge, | ||
metal::mag_filter::linear, | ||
metal::min_filter::linear, | ||
metal::coord::normalized | ||
); | ||
metal::float4 _e4 = t.sample(s, pos.xy); | ||
return entry_point_oneOutput { _e4 }; | ||
} | ||
|
||
|
||
struct entry_point_twoOutput { | ||
metal::float4 member_1 [[color(0)]]; | ||
}; | ||
fragment entry_point_twoOutput entry_point_two( | ||
metal::texture2d<float, metal::access::sample> t [[texture(1)]] | ||
, metal::sampler s [[sampler(1)]] | ||
, constant metal::float2& uniformOne [[buffer(0)]] | ||
) { | ||
metal::float2 _e3 = uniformOne; | ||
metal::float4 _e4 = t.sample(s, _e3); | ||
return entry_point_twoOutput { _e4 }; | ||
} | ||
|
||
|
||
struct entry_point_threeOutput { | ||
metal::float4 member_2 [[color(0)]]; | ||
}; | ||
fragment entry_point_threeOutput entry_point_three( | ||
metal::texture2d<float, metal::access::sample> t [[texture(0)]] | ||
, constant metal::float2& uniformOne [[buffer(0)]] | ||
, constant metal::float2& uniformTwo [[buffer(1)]] | ||
) { | ||
constexpr metal::sampler s( | ||
metal::s_address::clamp_to_edge, | ||
metal::t_address::clamp_to_edge, | ||
metal::r_address::clamp_to_edge, | ||
metal::mag_filter::linear, | ||
metal::min_filter::linear, | ||
metal::coord::normalized | ||
); | ||
metal::float2 _e3 = uniformTwo; | ||
metal::float2 _e5 = uniformOne; | ||
metal::float4 _e7 = t.sample(s, _e3 + _e5); | ||
return entry_point_threeOutput { _e7 }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters