mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 16:53:48 +00:00
[wgsl] Remove buffer, texture, in, out, input, output from reserved keywords
This commit is contained in:
parent
f2e7818e71
commit
f76af4e53a
@ -134,7 +134,6 @@ pub const RESERVED: &[&str] = &[
|
||||
"await",
|
||||
"become",
|
||||
"bf16",
|
||||
"buffer",
|
||||
"cast",
|
||||
"catch",
|
||||
"cbuffer",
|
||||
@ -217,10 +216,8 @@ pub const RESERVED: &[&str] = &[
|
||||
"impl",
|
||||
"implements",
|
||||
"import",
|
||||
"in",
|
||||
"inline",
|
||||
"inout",
|
||||
"input",
|
||||
"instanceof",
|
||||
"interface",
|
||||
"invariant",
|
||||
@ -276,8 +273,6 @@ pub const RESERVED: &[&str] = &[
|
||||
"nullptr",
|
||||
"of",
|
||||
"operator",
|
||||
"out",
|
||||
"output",
|
||||
"package",
|
||||
"packoffset",
|
||||
"partition",
|
||||
@ -348,7 +343,6 @@ pub const RESERVED: &[&str] = &[
|
||||
"technique10",
|
||||
"technique11",
|
||||
"template",
|
||||
"texture",
|
||||
"texture1D",
|
||||
"texture1DArray",
|
||||
"texture2D",
|
||||
|
@ -10,10 +10,10 @@ struct FragmentIn {
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main(_in: FragmentIn) -> @location(0) vec4<f32> {
|
||||
if _in.primitive_index == pc.index {
|
||||
return _in.color;
|
||||
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
|
||||
if in.primitive_index == pc.index {
|
||||
return in.color;
|
||||
} else {
|
||||
return vec4<f32>(vec3<f32>(1.0) - _in.color.rgb, _in.color.a);
|
||||
return vec4<f32>(vec3<f32>(1.0) - in.color.rgb, in.color.a);
|
||||
}
|
||||
}
|
||||
|
@ -23,17 +23,17 @@ struct FragmentOutput {
|
||||
|
||||
@fragment
|
||||
fn fragment(
|
||||
_in: VertexOutput,
|
||||
in: VertexOutput,
|
||||
@builtin(front_facing) front_facing: bool,
|
||||
@builtin(sample_index) sample_index: u32,
|
||||
@builtin(sample_mask) sample_mask: u32,
|
||||
) -> FragmentOutput {
|
||||
let mask = sample_mask & (1u << sample_index);
|
||||
let color = select(0.0, 1.0, front_facing);
|
||||
return FragmentOutput(_in._varying, mask, color);
|
||||
return FragmentOutput(in._varying, mask, color);
|
||||
}
|
||||
|
||||
var<workgroup> _output: array<u32, 1>;
|
||||
var<workgroup> output: array<u32, 1>;
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn compute(
|
||||
@ -43,7 +43,7 @@ fn compute(
|
||||
@builtin(workgroup_id) wg_id: vec3<u32>,
|
||||
@builtin(num_workgroups) num_wgs: vec3<u32>,
|
||||
) {
|
||||
_output[0] = global_id.x + local_id.x + local_index + wg_id.x + num_wgs.x;
|
||||
output[0] = global_id.x + local_id.x + local_index + wg_id.x + num_wgs.x;
|
||||
}
|
||||
|
||||
struct Input1 {
|
||||
|
@ -13,18 +13,18 @@ struct FragmentInput {
|
||||
|
||||
@vertex
|
||||
fn vert_main() -> FragmentInput {
|
||||
var _out: FragmentInput;
|
||||
var out: FragmentInput;
|
||||
|
||||
_out.position = vec4<f32>(2.0, 4.0, 5.0, 6.0);
|
||||
_out._flat = 8u;
|
||||
_out._linear = 27.0;
|
||||
_out.linear_centroid = vec2<f32>(64.0, 125.0);
|
||||
_out.linear_sample = vec3<f32>(216.0, 343.0, 512.0);
|
||||
_out.perspective = vec4<f32>(729.0, 1000.0, 1331.0, 1728.0);
|
||||
_out.perspective_centroid = 2197.0;
|
||||
_out.perspective_sample = 2744.0;
|
||||
out.position = vec4<f32>(2.0, 4.0, 5.0, 6.0);
|
||||
out._flat = 8u;
|
||||
out._linear = 27.0;
|
||||
out.linear_centroid = vec2<f32>(64.0, 125.0);
|
||||
out.linear_sample = vec3<f32>(216.0, 343.0, 512.0);
|
||||
out.perspective = vec4<f32>(729.0, 1000.0, 1331.0, 1728.0);
|
||||
out.perspective_centroid = 2197.0;
|
||||
out.perspective_sample = 2744.0;
|
||||
|
||||
return _out;
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
|
@ -8,6 +8,6 @@ struct FragmentIn {
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main(_in: FragmentIn) -> @location(0) vec4<f32> {
|
||||
return _in.color * pc.multiplier;
|
||||
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
|
||||
return in.color * pc.multiplier;
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ fn vs_main(
|
||||
) -> VertexOutput {
|
||||
let w = u_entity.world;
|
||||
let world_pos = u_entity.world * vec4<f32>(position);
|
||||
var _out: VertexOutput;
|
||||
_out.world_normal = mat3x3<f32>(w.x.xyz, w.y.xyz, w.z.xyz) * vec3<f32>(normal.xyz);
|
||||
_out.world_position = world_pos;
|
||||
_out.proj_position = u_globals.view_proj * world_pos;
|
||||
return _out;
|
||||
var out: VertexOutput;
|
||||
out.world_normal = mat3x3<f32>(w.x.xyz, w.y.xyz, w.z.xyz) * vec3<f32>(normal.xyz);
|
||||
out.world_position = world_pos;
|
||||
out.proj_position = u_globals.view_proj * world_pos;
|
||||
return out;
|
||||
}
|
||||
|
||||
// fragment shader
|
||||
@ -81,16 +81,16 @@ let c_ambient: vec3<f32> = vec3<f32>(0.05, 0.05, 0.05);
|
||||
let c_max_lights: u32 = 10u;
|
||||
|
||||
@fragment
|
||||
fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let normal = normalize(_in.world_normal);
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let normal = normalize(in.world_normal);
|
||||
// accumulate color
|
||||
var color: vec3<f32> = c_ambient;
|
||||
for(var i = 0u; i < min(u_globals.num_lights.x, c_max_lights); i++) {
|
||||
let light = s_lights[i];
|
||||
// project into the light space
|
||||
let shadow = fetch_shadow(i, light.proj * _in.world_position);
|
||||
let shadow = fetch_shadow(i, light.proj * in.world_position);
|
||||
// compute Lambertian diffuse term
|
||||
let light_dir = normalize(light.pos.xyz - _in.world_position.xyz);
|
||||
let light_dir = normalize(light.pos.xyz - in.world_position.xyz);
|
||||
let diffuse = max(0.0, dot(normal, light_dir));
|
||||
// add light contribution
|
||||
color += shadow * diffuse * light.color.xyz;
|
||||
@ -101,15 +101,15 @@ fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
|
||||
// The fragment entrypoint used when storage buffers are not available for the lights
|
||||
@fragment
|
||||
fn fs_main_without_storage(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let normal = normalize(_in.world_normal);
|
||||
fn fs_main_without_storage(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let normal = normalize(in.world_normal);
|
||||
var color: vec3<f32> = c_ambient;
|
||||
for(var i = 0u; i < min(u_globals.num_lights.x, c_max_lights); i++) {
|
||||
// This line is the only difference from the entrypoint above. It uses the lights
|
||||
// uniform instead of the lights storage buffer
|
||||
let light = u_lights[i];
|
||||
let shadow = fetch_shadow(i, light.proj * _in.world_position);
|
||||
let light_dir = normalize(light.pos.xyz - _in.world_position.xyz);
|
||||
let shadow = fetch_shadow(i, light.proj * in.world_position);
|
||||
let light_dir = normalize(light.pos.xyz - in.world_position.xyz);
|
||||
let diffuse = max(0.0, dot(normal, light_dir));
|
||||
color += shadow * diffuse * light.color.xyz;
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ var r_texture: texture_cube<f32>;
|
||||
var r_sampler: sampler;
|
||||
|
||||
@fragment
|
||||
fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return textureSample(r_texture, r_sampler, _in.uv);
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return textureSample(r_texture, r_sampler, in.uv);
|
||||
}
|
||||
|
@ -18,16 +18,16 @@ smooth centroid out float _vs2fs_location5;
|
||||
smooth sample out float _vs2fs_location6;
|
||||
|
||||
void main() {
|
||||
FragmentInput _out = FragmentInput(vec4(0.0), 0u, 0.0, vec2(0.0), vec3(0.0), vec4(0.0), 0.0, 0.0);
|
||||
_out.position = vec4(2.0, 4.0, 5.0, 6.0);
|
||||
_out._flat = 8u;
|
||||
_out._linear = 27.0;
|
||||
_out.linear_centroid = vec2(64.0, 125.0);
|
||||
_out.linear_sample = vec3(216.0, 343.0, 512.0);
|
||||
_out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0);
|
||||
_out.perspective_centroid = 2197.0;
|
||||
_out.perspective_sample = 2744.0;
|
||||
FragmentInput _e30 = _out;
|
||||
FragmentInput out_ = FragmentInput(vec4(0.0), 0u, 0.0, vec2(0.0), vec3(0.0), vec4(0.0), 0.0, 0.0);
|
||||
out_.position = vec4(2.0, 4.0, 5.0, 6.0);
|
||||
out_._flat = 8u;
|
||||
out_._linear = 27.0;
|
||||
out_.linear_centroid = vec2(64.0, 125.0);
|
||||
out_.linear_sample = vec3(216.0, 343.0, 512.0);
|
||||
out_.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0);
|
||||
out_.perspective_centroid = 2197.0;
|
||||
out_.perspective_sample = 2744.0;
|
||||
FragmentInput _e30 = out_;
|
||||
gl_Position = _e30.position;
|
||||
_vs2fs_location0 = _e30._flat;
|
||||
_vs2fs_location1 = _e30._linear;
|
||||
|
@ -15,9 +15,9 @@ layout(location = 0) smooth in vec4 _vs2fs_location0;
|
||||
layout(location = 0) out vec4 _fs2p_location0;
|
||||
|
||||
void main() {
|
||||
FragmentIn _in = FragmentIn(_vs2fs_location0);
|
||||
FragmentIn in_ = FragmentIn(_vs2fs_location0);
|
||||
float _e4 = pc.multiplier;
|
||||
_fs2p_location0 = (_in.color * _e4);
|
||||
_fs2p_location0 = (in_.color * _e4);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,10 +45,10 @@ float fetch_shadow(uint light_id, vec4 homogeneous_coords) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
VertexOutput _in = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1);
|
||||
VertexOutput in_ = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1);
|
||||
vec3 color = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
|
||||
uint i = 0u;
|
||||
vec3 normal_1 = normalize(_in.world_normal);
|
||||
vec3 normal_1 = normalize(in_.world_normal);
|
||||
bool loop_init = true;
|
||||
while(true) {
|
||||
if (!loop_init) {
|
||||
@ -65,8 +65,8 @@ void main() {
|
||||
uint _e23 = i;
|
||||
Light light = _group_0_binding_1_fs[_e23];
|
||||
uint _e26 = i;
|
||||
float _e30 = fetch_shadow(_e26, (light.proj * _in.world_position));
|
||||
vec3 light_dir = normalize((light.pos.xyz - _in.world_position.xyz));
|
||||
float _e30 = fetch_shadow(_e26, (light.proj * in_.world_position));
|
||||
vec3 light_dir = normalize((light.pos.xyz - in_.world_position.xyz));
|
||||
float diffuse = max(0.0, dot(normal_1, light_dir));
|
||||
vec3 _e40 = color;
|
||||
color = (_e40 + ((_e30 * diffuse) * light.color.xyz));
|
||||
|
@ -45,10 +45,10 @@ float fetch_shadow(uint light_id, vec4 homogeneous_coords) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
VertexOutput _in_1 = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1);
|
||||
VertexOutput in_1 = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1);
|
||||
vec3 color_1 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
|
||||
uint i_1 = 0u;
|
||||
vec3 normal_1 = normalize(_in_1.world_normal);
|
||||
vec3 normal_1 = normalize(in_1.world_normal);
|
||||
bool loop_init = true;
|
||||
while(true) {
|
||||
if (!loop_init) {
|
||||
@ -65,8 +65,8 @@ void main() {
|
||||
uint _e23 = i_1;
|
||||
Light light = _group_0_binding_1_fs[_e23];
|
||||
uint _e26 = i_1;
|
||||
float _e30 = fetch_shadow(_e26, (light.proj * _in_1.world_position));
|
||||
vec3 light_dir = normalize((light.pos.xyz - _in_1.world_position.xyz));
|
||||
float _e30 = fetch_shadow(_e26, (light.proj * in_1.world_position));
|
||||
vec3 light_dir = normalize((light.pos.xyz - in_1.world_position.xyz));
|
||||
float diffuse = max(0.0, dot(normal_1, light_dir));
|
||||
vec3 _e40 = color_1;
|
||||
color_1 = (_e40 + ((_e30 * diffuse) * light.color.xyz));
|
||||
|
@ -33,15 +33,15 @@ layout(location = 1) smooth out vec4 _vs2fs_location1;
|
||||
void main() {
|
||||
ivec4 position = _p2vs_location0;
|
||||
ivec4 normal = _p2vs_location1;
|
||||
VertexOutput _out = VertexOutput(vec4(0.0), vec3(0.0), vec4(0.0));
|
||||
VertexOutput out_ = VertexOutput(vec4(0.0), vec3(0.0), vec4(0.0));
|
||||
mat4x4 w = _group_1_binding_0_vs.world;
|
||||
mat4x4 _e7 = _group_1_binding_0_vs.world;
|
||||
vec4 world_pos = (_e7 * vec4(position));
|
||||
_out.world_normal = (mat3x3(w[0].xyz, w[1].xyz, w[2].xyz) * vec3(normal.xyz));
|
||||
_out.world_position = world_pos;
|
||||
out_.world_normal = (mat3x3(w[0].xyz, w[1].xyz, w[2].xyz) * vec3(normal.xyz));
|
||||
out_.world_position = world_pos;
|
||||
mat4x4 _e25 = _group_0_binding_0_vs.view_proj;
|
||||
_out.proj_position = (_e25 * world_pos);
|
||||
VertexOutput _e27 = _out;
|
||||
out_.proj_position = (_e25 * world_pos);
|
||||
VertexOutput _e27 = out_;
|
||||
gl_Position = _e27.proj_position;
|
||||
_vs2fs_location0 = _e27.world_normal;
|
||||
_vs2fs_location1 = _e27.world_position;
|
||||
|
@ -17,8 +17,8 @@ layout(location = 0) smooth in vec3 _vs2fs_location0;
|
||||
layout(location = 0) out vec4 _fs2p_location0;
|
||||
|
||||
void main() {
|
||||
VertexOutput _in = VertexOutput(gl_FragCoord, _vs2fs_location0);
|
||||
vec4 _e5 = texture(_group_0_binding_1_fs, vec3(_in.uv));
|
||||
VertexOutput in_ = VertexOutput(gl_FragCoord, _vs2fs_location0);
|
||||
vec4 _e5 = texture(_group_0_binding_1_fs, vec3(in_.uv));
|
||||
_fs2p_location0 = _e5;
|
||||
return;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ struct Input2_ {
|
||||
uint index : SV_InstanceID;
|
||||
};
|
||||
|
||||
groupshared uint _output[1];
|
||||
groupshared uint output[1];
|
||||
|
||||
struct VertexOutput_vertex {
|
||||
float _varying : LOC1;
|
||||
@ -64,20 +64,20 @@ FragmentOutput ConstructFragmentOutput(float arg0, uint arg1, float arg2) {
|
||||
|
||||
FragmentOutput fragment(FragmentInput_fragment fragmentinput_fragment)
|
||||
{
|
||||
VertexOutput _in = { fragmentinput_fragment.position_1, fragmentinput_fragment._varying_1 };
|
||||
VertexOutput in_ = { fragmentinput_fragment.position_1, fragmentinput_fragment._varying_1 };
|
||||
bool front_facing = fragmentinput_fragment.front_facing_1;
|
||||
uint sample_index = fragmentinput_fragment.sample_index_1;
|
||||
uint sample_mask = fragmentinput_fragment.sample_mask_1;
|
||||
uint mask = (sample_mask & (1u << sample_index));
|
||||
float color_1 = (front_facing ? 1.0 : 0.0);
|
||||
const FragmentOutput fragmentoutput = ConstructFragmentOutput(_in._varying, mask, color_1);
|
||||
const FragmentOutput fragmentoutput = ConstructFragmentOutput(in_._varying, mask, color_1);
|
||||
return fragmentoutput;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void compute(uint3 global_id : SV_DispatchThreadID, uint3 local_id : SV_GroupThreadID, uint local_index : SV_GroupIndex, uint3 wg_id : SV_GroupID, uint3 num_wgs : SV_GroupID)
|
||||
{
|
||||
_output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + uint3(_NagaConstants.base_vertex, _NagaConstants.base_instance, _NagaConstants.other).x);
|
||||
output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + uint3(_NagaConstants.base_vertex, _NagaConstants.base_instance, _NagaConstants.other).x);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,17 +34,17 @@ struct FragmentInput_frag_main {
|
||||
|
||||
VertexOutput_vert_main vert_main()
|
||||
{
|
||||
FragmentInput _out = (FragmentInput)0;
|
||||
FragmentInput out_ = (FragmentInput)0;
|
||||
|
||||
_out.position = float4(2.0, 4.0, 5.0, 6.0);
|
||||
_out._flat = 8u;
|
||||
_out._linear = 27.0;
|
||||
_out.linear_centroid = float2(64.0, 125.0);
|
||||
_out.linear_sample = float3(216.0, 343.0, 512.0);
|
||||
_out.perspective = float4(729.0, 1000.0, 1331.0, 1728.0);
|
||||
_out.perspective_centroid = 2197.0;
|
||||
_out.perspective_sample = 2744.0;
|
||||
FragmentInput _expr30 = _out;
|
||||
out_.position = float4(2.0, 4.0, 5.0, 6.0);
|
||||
out_._flat = 8u;
|
||||
out_._linear = 27.0;
|
||||
out_.linear_centroid = float2(64.0, 125.0);
|
||||
out_.linear_sample = float3(216.0, 343.0, 512.0);
|
||||
out_.perspective = float4(729.0, 1000.0, 1331.0, 1728.0);
|
||||
out_.perspective_centroid = 2197.0;
|
||||
out_.perspective_sample = 2744.0;
|
||||
FragmentInput _expr30 = out_;
|
||||
const FragmentInput fragmentinput = _expr30;
|
||||
const VertexOutput_vert_main fragmentinput_1 = { fragmentinput._flat, fragmentinput._linear, fragmentinput.linear_centroid, fragmentinput.linear_sample, fragmentinput.perspective, fragmentinput.perspective_centroid, fragmentinput.perspective_sample, fragmentinput.position };
|
||||
return fragmentinput_1;
|
||||
|
@ -62,16 +62,16 @@ float fetch_shadow(uint light_id, float4 homogeneous_coords)
|
||||
|
||||
VertexOutput_vs_main vs_main(int4 position : LOC0, int4 normal : LOC1)
|
||||
{
|
||||
VertexOutput _out = (VertexOutput)0;
|
||||
VertexOutput out_ = (VertexOutput)0;
|
||||
|
||||
float4x4 w = u_entity.world;
|
||||
float4x4 _expr7 = u_entity.world;
|
||||
float4 world_pos = mul(float4(position), _expr7);
|
||||
_out.world_normal = mul(float3(normal.xyz), float3x3(w[0].xyz, w[1].xyz, w[2].xyz));
|
||||
_out.world_position = world_pos;
|
||||
out_.world_normal = mul(float3(normal.xyz), float3x3(w[0].xyz, w[1].xyz, w[2].xyz));
|
||||
out_.world_position = world_pos;
|
||||
float4x4 _expr25 = u_globals.view_proj;
|
||||
_out.proj_position = mul(world_pos, _expr25);
|
||||
VertexOutput _expr27 = _out;
|
||||
out_.proj_position = mul(world_pos, _expr25);
|
||||
VertexOutput _expr27 = out_;
|
||||
const VertexOutput vertexoutput = _expr27;
|
||||
const VertexOutput_vs_main vertexoutput_1 = { vertexoutput.world_normal, vertexoutput.world_position, vertexoutput.proj_position };
|
||||
return vertexoutput_1;
|
||||
@ -79,11 +79,11 @@ VertexOutput_vs_main vs_main(int4 position : LOC0, int4 normal : LOC1)
|
||||
|
||||
float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0
|
||||
{
|
||||
VertexOutput _in = { fragmentinput_fs_main.proj_position_1, fragmentinput_fs_main.world_normal_1, fragmentinput_fs_main.world_position_1 };
|
||||
VertexOutput in_ = { fragmentinput_fs_main.proj_position_1, fragmentinput_fs_main.world_normal_1, fragmentinput_fs_main.world_position_1 };
|
||||
float3 color = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
|
||||
uint i = 0u;
|
||||
|
||||
float3 normal_1 = normalize(_in.world_normal);
|
||||
float3 normal_1 = normalize(in_.world_normal);
|
||||
bool loop_init = true;
|
||||
while(true) {
|
||||
if (!loop_init) {
|
||||
@ -100,8 +100,8 @@ float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0
|
||||
uint _expr23 = i;
|
||||
Light light = {float4x4(asfloat(s_lights.Load4(_expr23*96+0+0)), asfloat(s_lights.Load4(_expr23*96+0+16)), asfloat(s_lights.Load4(_expr23*96+0+32)), asfloat(s_lights.Load4(_expr23*96+0+48))), asfloat(s_lights.Load4(_expr23*96+64)), asfloat(s_lights.Load4(_expr23*96+80))};
|
||||
uint _expr26 = i;
|
||||
const float _e30 = fetch_shadow(_expr26, mul(_in.world_position, light.proj));
|
||||
float3 light_dir = normalize((light.pos.xyz - _in.world_position.xyz));
|
||||
const float _e30 = fetch_shadow(_expr26, mul(in_.world_position, light.proj));
|
||||
float3 light_dir = normalize((light.pos.xyz - in_.world_position.xyz));
|
||||
float diffuse = max(0.0, dot(normal_1, light_dir));
|
||||
float3 _expr40 = color;
|
||||
color = (_expr40 + ((_e30 * diffuse) * light.color.xyz));
|
||||
@ -113,11 +113,11 @@ float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0
|
||||
|
||||
float4 fs_main_without_storage(FragmentInput_fs_main_without_storage fragmentinput_fs_main_without_storage) : SV_Target0
|
||||
{
|
||||
VertexOutput _in_1 = { fragmentinput_fs_main_without_storage.proj_position_2, fragmentinput_fs_main_without_storage.world_normal_2, fragmentinput_fs_main_without_storage.world_position_2 };
|
||||
VertexOutput in_1 = { fragmentinput_fs_main_without_storage.proj_position_2, fragmentinput_fs_main_without_storage.world_normal_2, fragmentinput_fs_main_without_storage.world_position_2 };
|
||||
float3 color_1 = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
|
||||
uint i_1 = 0u;
|
||||
|
||||
float3 normal_2 = normalize(_in_1.world_normal);
|
||||
float3 normal_2 = normalize(in_1.world_normal);
|
||||
bool loop_init_1 = true;
|
||||
while(true) {
|
||||
if (!loop_init_1) {
|
||||
@ -134,8 +134,8 @@ float4 fs_main_without_storage(FragmentInput_fs_main_without_storage fragmentinp
|
||||
uint _expr23 = i_1;
|
||||
Light light_1 = u_lights[_expr23];
|
||||
uint _expr26 = i_1;
|
||||
const float _e30 = fetch_shadow(_expr26, mul(_in_1.world_position, light_1.proj));
|
||||
float3 light_dir_1 = normalize((light_1.pos.xyz - _in_1.world_position.xyz));
|
||||
const float _e30 = fetch_shadow(_expr26, mul(in_1.world_position, light_1.proj));
|
||||
float3 light_dir_1 = normalize((light_1.pos.xyz - in_1.world_position.xyz));
|
||||
float diffuse_1 = max(0.0, dot(normal_2, light_dir_1));
|
||||
float3 _expr40 = color_1;
|
||||
color_1 = (_expr40 + ((_e30 * diffuse_1) * light_1.color.xyz));
|
||||
|
@ -59,7 +59,7 @@ VertexOutput_vs_main vs_main(uint vertex_index : SV_VertexID)
|
||||
|
||||
float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0
|
||||
{
|
||||
VertexOutput _in = { fragmentinput_fs_main.position_1, fragmentinput_fs_main.uv_1 };
|
||||
float4 _expr5 = r_texture.Sample(r_sampler, _in.uv);
|
||||
VertexOutput in_ = { fragmentinput_fs_main.position_1, fragmentinput_fs_main.uv_1 };
|
||||
float4 _expr5 = r_texture.Sample(r_sampler, in_.uv);
|
||||
return _expr5;
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ fragment main_Output main_(
|
||||
, uint primitive_index [[primitive_id]]
|
||||
, constant PushConstants& pc [[buffer(1)]]
|
||||
) {
|
||||
const FragmentIn _in = { varyings.color, primitive_index };
|
||||
const FragmentIn in = { varyings.color, primitive_index };
|
||||
uint _e4 = pc.index;
|
||||
if (_in.primitive_index == _e4) {
|
||||
return main_Output { _in.color };
|
||||
if (in.primitive_index == _e4) {
|
||||
return main_Output { in.color };
|
||||
} else {
|
||||
return main_Output { metal::float4(metal::float3(1.0) - _in.color.xyz, _in.color.w) };
|
||||
return main_Output { metal::float4(metal::float3(1.0) - in.color.xyz, in.color.w) };
|
||||
}
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ fragment fragment_Output fragment_(
|
||||
, uint sample_index [[sample_id]]
|
||||
, uint sample_mask [[sample_mask]]
|
||||
) {
|
||||
const VertexOutput _in = { position, varyings_1._varying };
|
||||
const VertexOutput in = { position, varyings_1._varying };
|
||||
uint mask = sample_mask & (1u << sample_index);
|
||||
float color_1 = front_facing ? 1.0 : 0.0;
|
||||
const auto _tmp = FragmentOutput {_in._varying, mask, color_1};
|
||||
const auto _tmp = FragmentOutput {in._varying, mask, color_1};
|
||||
return fragment_Output { _tmp.depth, _tmp.sample_mask, _tmp.color };
|
||||
}
|
||||
|
||||
@ -74,9 +74,9 @@ kernel void compute_(
|
||||
, uint local_index [[thread_index_in_threadgroup]]
|
||||
, metal::uint3 wg_id [[threadgroup_position_in_grid]]
|
||||
, metal::uint3 num_wgs [[threadgroups_per_grid]]
|
||||
, threadgroup type_4& _output
|
||||
, threadgroup type_4& output
|
||||
) {
|
||||
_output.inner[0] = (((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x;
|
||||
output.inner[0] = (((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,16 +27,16 @@ struct vert_mainOutput {
|
||||
};
|
||||
vertex vert_mainOutput vert_main(
|
||||
) {
|
||||
FragmentInput _out;
|
||||
_out.position = metal::float4(2.0, 4.0, 5.0, 6.0);
|
||||
_out._flat = 8u;
|
||||
_out._linear = 27.0;
|
||||
_out.linear_centroid = metal::float2(64.0, 125.0);
|
||||
_out.linear_sample = metal::float3(216.0, 343.0, 512.0);
|
||||
_out.perspective = metal::float4(729.0, 1000.0, 1331.0, 1728.0);
|
||||
_out.perspective_centroid = 2197.0;
|
||||
_out.perspective_sample = 2744.0;
|
||||
FragmentInput _e30 = _out;
|
||||
FragmentInput out;
|
||||
out.position = metal::float4(2.0, 4.0, 5.0, 6.0);
|
||||
out._flat = 8u;
|
||||
out._linear = 27.0;
|
||||
out.linear_centroid = metal::float2(64.0, 125.0);
|
||||
out.linear_sample = metal::float3(216.0, 343.0, 512.0);
|
||||
out.perspective = metal::float4(729.0, 1000.0, 1331.0, 1728.0);
|
||||
out.perspective_centroid = 2197.0;
|
||||
out.perspective_sample = 2744.0;
|
||||
FragmentInput _e30 = out;
|
||||
const auto _tmp = _e30;
|
||||
return vert_mainOutput { _tmp.position, _tmp._flat, _tmp._linear, _tmp.linear_centroid, _tmp.linear_sample, _tmp.perspective, _tmp.perspective_centroid, _tmp.perspective_sample };
|
||||
}
|
||||
|
@ -65,15 +65,15 @@ vertex vs_mainOutput vs_main(
|
||||
) {
|
||||
const auto position = varyings.position;
|
||||
const auto normal = varyings.normal;
|
||||
VertexOutput _out;
|
||||
VertexOutput out;
|
||||
metal::float4x4 w = u_entity.world;
|
||||
metal::float4x4 _e7 = u_entity.world;
|
||||
metal::float4 world_pos = _e7 * static_cast<metal::float4>(position);
|
||||
_out.world_normal = metal::float3x3(w[0].xyz, w[1].xyz, w[2].xyz) * static_cast<metal::float3>(normal.xyz);
|
||||
_out.world_position = world_pos;
|
||||
out.world_normal = metal::float3x3(w[0].xyz, w[1].xyz, w[2].xyz) * static_cast<metal::float3>(normal.xyz);
|
||||
out.world_position = world_pos;
|
||||
metal::float4x4 _e25 = u_globals.view_proj;
|
||||
_out.proj_position = _e25 * world_pos;
|
||||
VertexOutput _e27 = _out;
|
||||
out.proj_position = _e25 * world_pos;
|
||||
VertexOutput _e27 = out;
|
||||
const auto _tmp = _e27;
|
||||
return vs_mainOutput { _tmp.proj_position, _tmp.world_normal, _tmp.world_position };
|
||||
}
|
||||
@ -96,10 +96,10 @@ fragment fs_mainOutput fs_main(
|
||||
, metal::sampler sampler_shadow [[user(fake0)]]
|
||||
, constant _mslBufferSizes& _buffer_sizes [[user(fake0)]]
|
||||
) {
|
||||
const VertexOutput _in = { proj_position, varyings_1.world_normal, varyings_1.world_position };
|
||||
const VertexOutput in = { proj_position, varyings_1.world_normal, varyings_1.world_position };
|
||||
metal::float3 color = c_ambient;
|
||||
uint i = 0u;
|
||||
metal::float3 normal_1 = metal::normalize(_in.world_normal);
|
||||
metal::float3 normal_1 = metal::normalize(in.world_normal);
|
||||
bool loop_init = true;
|
||||
while(true) {
|
||||
if (!loop_init) {
|
||||
@ -116,8 +116,8 @@ fragment fs_mainOutput fs_main(
|
||||
uint _e23 = i;
|
||||
Light light = s_lights[_e23];
|
||||
uint _e26 = i;
|
||||
float _e30 = fetch_shadow(_e26, light.proj * _in.world_position, t_shadow, sampler_shadow);
|
||||
metal::float3 light_dir = metal::normalize(light.pos.xyz - _in.world_position.xyz);
|
||||
float _e30 = fetch_shadow(_e26, light.proj * in.world_position, t_shadow, sampler_shadow);
|
||||
metal::float3 light_dir = metal::normalize(light.pos.xyz - in.world_position.xyz);
|
||||
float diffuse = metal::max(0.0, metal::dot(normal_1, light_dir));
|
||||
metal::float3 _e40 = color;
|
||||
color = _e40 + ((_e30 * diffuse) * light.color.xyz);
|
||||
@ -144,10 +144,10 @@ fragment fs_main_without_storageOutput fs_main_without_storage(
|
||||
, metal::depth2d_array<float, metal::access::sample> t_shadow [[user(fake0)]]
|
||||
, metal::sampler sampler_shadow [[user(fake0)]]
|
||||
) {
|
||||
const VertexOutput _in_1 = { proj_position_1, varyings_2.world_normal, varyings_2.world_position };
|
||||
const VertexOutput in_1 = { proj_position_1, varyings_2.world_normal, varyings_2.world_position };
|
||||
metal::float3 color_1 = c_ambient;
|
||||
uint i_1 = 0u;
|
||||
metal::float3 normal_2 = metal::normalize(_in_1.world_normal);
|
||||
metal::float3 normal_2 = metal::normalize(in_1.world_normal);
|
||||
bool loop_init_1 = true;
|
||||
while(true) {
|
||||
if (!loop_init_1) {
|
||||
@ -164,8 +164,8 @@ fragment fs_main_without_storageOutput fs_main_without_storage(
|
||||
uint _e23 = i_1;
|
||||
Light light_1 = u_lights.inner[_e23];
|
||||
uint _e26 = i_1;
|
||||
float _e30 = fetch_shadow(_e26, light_1.proj * _in_1.world_position, t_shadow, sampler_shadow);
|
||||
metal::float3 light_dir_1 = metal::normalize(light_1.pos.xyz - _in_1.world_position.xyz);
|
||||
float _e30 = fetch_shadow(_e26, light_1.proj * in_1.world_position, t_shadow, sampler_shadow);
|
||||
metal::float3 light_dir_1 = metal::normalize(light_1.pos.xyz - in_1.world_position.xyz);
|
||||
float diffuse_1 = metal::max(0.0, metal::dot(normal_2, light_dir_1));
|
||||
metal::float3 _e40 = color_1;
|
||||
color_1 = _e40 + ((_e30 * diffuse_1) * light_1.color.xyz);
|
||||
|
@ -60,7 +60,7 @@ fragment fs_mainOutput fs_main(
|
||||
metal::min_filter::linear,
|
||||
metal::coord::normalized
|
||||
);
|
||||
const VertexOutput _in = { position, varyings_1.uv };
|
||||
metal::float4 _e5 = r_texture.sample(r_sampler, _in.uv);
|
||||
const VertexOutput in = { position, varyings_1.uv };
|
||||
metal::float4 _e5 = r_texture.sample(r_sampler, in.uv);
|
||||
return fs_mainOutput { _e5 };
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ OpMemberName %25 5 "perspective"
|
||||
OpMemberName %25 6 "perspective_centroid"
|
||||
OpMemberName %25 7 "perspective_sample"
|
||||
OpName %25 "FragmentInput"
|
||||
OpName %26 "_out"
|
||||
OpName %26 "out"
|
||||
OpName %29 "position"
|
||||
OpName %31 "_flat"
|
||||
OpName %33 "_linear"
|
||||
|
@ -37,7 +37,7 @@ OpName %45 "sampler_shadow"
|
||||
OpName %48 "light_id"
|
||||
OpName %49 "homogeneous_coords"
|
||||
OpName %50 "fetch_shadow"
|
||||
OpName %80 "_out"
|
||||
OpName %80 "out"
|
||||
OpName %83 "position"
|
||||
OpName %86 "normal"
|
||||
OpName %88 "proj_position"
|
||||
|
@ -11,11 +11,11 @@ struct FragmentIn {
|
||||
var<push_constant> pc: PushConstants;
|
||||
|
||||
@fragment
|
||||
fn main(_in: FragmentIn) -> @location(0) vec4<f32> {
|
||||
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
|
||||
let _e4 = pc.index;
|
||||
if (_in.primitive_index == _e4) {
|
||||
return _in.color;
|
||||
if (in.primitive_index == _e4) {
|
||||
return in.color;
|
||||
} else {
|
||||
return vec4<f32>((vec3<f32>(1.0) - _in.color.xyz), _in.color.w);
|
||||
return vec4<f32>((vec3<f32>(1.0) - in.color.xyz), in.color.w);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ struct Input2_ {
|
||||
@builtin(instance_index) index: u32,
|
||||
}
|
||||
|
||||
var<workgroup> _output: array<u32,1>;
|
||||
var<workgroup> output: array<u32,1>;
|
||||
|
||||
@vertex
|
||||
fn vertex(@builtin(vertex_index) vertex_index: u32, @builtin(instance_index) instance_index: u32, @location(10) color: u32) -> VertexOutput {
|
||||
@ -26,15 +26,15 @@ fn vertex(@builtin(vertex_index) vertex_index: u32, @builtin(instance_index) ins
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fragment(_in: VertexOutput, @builtin(front_facing) front_facing: bool, @builtin(sample_index) sample_index: u32, @builtin(sample_mask) sample_mask: u32) -> FragmentOutput {
|
||||
fn fragment(in: VertexOutput, @builtin(front_facing) front_facing: bool, @builtin(sample_index) sample_index: u32, @builtin(sample_mask) sample_mask: u32) -> FragmentOutput {
|
||||
let mask: u32 = (sample_mask & (1u << sample_index));
|
||||
let color_1: f32 = select(0.0, 1.0, front_facing);
|
||||
return FragmentOutput(_in._varying, mask, color_1);
|
||||
return FragmentOutput(in._varying, mask, color_1);
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1, 1, 1)
|
||||
fn compute(@builtin(global_invocation_id) global_id: vec3<u32>, @builtin(local_invocation_id) local_id: vec3<u32>, @builtin(local_invocation_index) local_index: u32, @builtin(workgroup_id) wg_id: vec3<u32>, @builtin(num_workgroups) num_wgs: vec3<u32>) {
|
||||
_output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x);
|
||||
output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,17 +11,17 @@ struct FragmentInput {
|
||||
|
||||
@vertex
|
||||
fn vert_main() -> FragmentInput {
|
||||
var _out: FragmentInput;
|
||||
var out: FragmentInput;
|
||||
|
||||
_out.position = vec4<f32>(2.0, 4.0, 5.0, 6.0);
|
||||
_out._flat = 8u;
|
||||
_out._linear = 27.0;
|
||||
_out.linear_centroid = vec2<f32>(64.0, 125.0);
|
||||
_out.linear_sample = vec3<f32>(216.0, 343.0, 512.0);
|
||||
_out.perspective = vec4<f32>(729.0, 1000.0, 1331.0, 1728.0);
|
||||
_out.perspective_centroid = 2197.0;
|
||||
_out.perspective_sample = 2744.0;
|
||||
let _e30 = _out;
|
||||
out.position = vec4<f32>(2.0, 4.0, 5.0, 6.0);
|
||||
out._flat = 8u;
|
||||
out._linear = 27.0;
|
||||
out.linear_centroid = vec2<f32>(64.0, 125.0);
|
||||
out.linear_sample = vec3<f32>(216.0, 343.0, 512.0);
|
||||
out.perspective = vec4<f32>(729.0, 1000.0, 1331.0, 1728.0);
|
||||
out.perspective_centroid = 2197.0;
|
||||
out.perspective_sample = 2744.0;
|
||||
let _e30 = out;
|
||||
return _e30;
|
||||
}
|
||||
|
||||
|
@ -49,25 +49,25 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4<f32>) -> f32 {
|
||||
|
||||
@vertex
|
||||
fn vs_main(@location(0) position: vec4<i32>, @location(1) normal: vec4<i32>) -> VertexOutput {
|
||||
var _out: VertexOutput;
|
||||
var out: VertexOutput;
|
||||
|
||||
let w = u_entity.world;
|
||||
let _e7 = u_entity.world;
|
||||
let world_pos = (_e7 * vec4<f32>(position));
|
||||
_out.world_normal = (mat3x3<f32>(w[0].xyz, w[1].xyz, w[2].xyz) * vec3<f32>(normal.xyz));
|
||||
_out.world_position = world_pos;
|
||||
out.world_normal = (mat3x3<f32>(w[0].xyz, w[1].xyz, w[2].xyz) * vec3<f32>(normal.xyz));
|
||||
out.world_position = world_pos;
|
||||
let _e25 = u_globals.view_proj;
|
||||
_out.proj_position = (_e25 * world_pos);
|
||||
let _e27 = _out;
|
||||
out.proj_position = (_e25 * world_pos);
|
||||
let _e27 = out;
|
||||
return _e27;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
var color: vec3<f32> = vec3<f32>(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
|
||||
var i: u32 = 0u;
|
||||
|
||||
let normal_1 = normalize(_in.world_normal);
|
||||
let normal_1 = normalize(in.world_normal);
|
||||
loop {
|
||||
let _e14 = i;
|
||||
let _e17 = u_globals.num_lights.x;
|
||||
@ -78,8 +78,8 @@ fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let _e23 = i;
|
||||
let light = s_lights[_e23];
|
||||
let _e26 = i;
|
||||
let _e30 = fetch_shadow(_e26, (light.proj * _in.world_position));
|
||||
let light_dir = normalize((light.pos.xyz - _in.world_position.xyz));
|
||||
let _e30 = fetch_shadow(_e26, (light.proj * in.world_position));
|
||||
let light_dir = normalize((light.pos.xyz - in.world_position.xyz));
|
||||
let diffuse = max(0.0, dot(normal_1, light_dir));
|
||||
let _e40 = color;
|
||||
color = (_e40 + ((_e30 * diffuse) * light.color.xyz));
|
||||
@ -94,11 +94,11 @@ fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main_without_storage(_in_1: VertexOutput) -> @location(0) vec4<f32> {
|
||||
fn fs_main_without_storage(in_1: VertexOutput) -> @location(0) vec4<f32> {
|
||||
var color_1: vec3<f32> = vec3<f32>(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
|
||||
var i_1: u32 = 0u;
|
||||
|
||||
let normal_2 = normalize(_in_1.world_normal);
|
||||
let normal_2 = normalize(in_1.world_normal);
|
||||
loop {
|
||||
let _e14 = i_1;
|
||||
let _e17 = u_globals.num_lights.x;
|
||||
@ -109,8 +109,8 @@ fn fs_main_without_storage(_in_1: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let _e23 = i_1;
|
||||
let light_1 = u_lights[_e23];
|
||||
let _e26 = i_1;
|
||||
let _e30 = fetch_shadow(_e26, (light_1.proj * _in_1.world_position));
|
||||
let light_dir_1 = normalize((light_1.pos.xyz - _in_1.world_position.xyz));
|
||||
let _e30 = fetch_shadow(_e26, (light_1.proj * in_1.world_position));
|
||||
let light_dir_1 = normalize((light_1.pos.xyz - in_1.world_position.xyz));
|
||||
let diffuse_1 = max(0.0, dot(normal_2, light_dir_1));
|
||||
let _e40 = color_1;
|
||||
color_1 = (_e40 + ((_e30 * diffuse_1) * light_1.color.xyz));
|
||||
|
@ -35,7 +35,7 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(_in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let _e5 = textureSample(r_texture, r_sampler, _in.uv);
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let _e5 = textureSample(r_texture, r_sampler, in.uv);
|
||||
return _e5;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user