This commit is contained in:
xsl
2025-09-04 10:54:47 +08:00
commit 6bc8f61b18
1808 changed files with 208268 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BLUR_COMMON_H_
#define BLUR_COMMON_H_
layout(set = 0, binding = 0) uniform sampler2D in_tex;
layout(rgba16f, set = 0, binding = 1) writeonly uniform image2D out_tex;
layout(push_constant) uniform Registers
{
uvec2 resolution;
vec2 inv_resolution;
vec2 inv_input_resolution;
}
registers;
vec2 get_uv(vec2 uv, float x, float y, float scale)
{
return uv + registers.inv_input_resolution * (vec2(x, y) * scale);
}
vec3 bloom_blur(vec2 uv, float uv_scale)
{
vec3 rgb = vec3(0.0);
const float N = -1.0;
const float Z = 0.0;
const float P = 1.0;
rgb += 0.25 * textureLod(in_tex, get_uv(uv, Z, Z, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, N, P, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, P, P, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, N, N, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, P, N, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, N, Z, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, P, Z, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, Z, N, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, Z, P, uv_scale), 0.0).rgb;
return rgb;
}
#endif
+36
View File
@@ -0,0 +1,36 @@
#version 450
/* Copyright (c) 2021-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Downscale pass. Simple and naive :)
layout(local_size_x = 8, local_size_y = 8) in;
#include "blur_common.h"
const float SCALE = 1.75;
void main()
{
if (all(lessThan(gl_GlobalInvocationID.xy, registers.resolution)))
{
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * registers.inv_resolution;
vec3 rgb = bloom_blur(uv, SCALE);
imageStore(out_tex, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1.0));
}
}
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
#version 450
/* Copyright (c) 2021-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Upscale pass. Simple and naive :)
layout(local_size_x = 8, local_size_y = 8) in;
#include "blur_common.h"
const float SCALE = 0.875;
void main()
{
if (all(lessThan(gl_GlobalInvocationID.xy, registers.resolution)))
{
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * registers.inv_resolution;
vec3 rgb = bloom_blur(uv, SCALE);
imageStore(out_tex, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1.0));
}
}
Binary file not shown.
+30
View File
@@ -0,0 +1,30 @@
#version 450
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) out vec4 o_color;
layout(location = 0) in vec2 in_uv;
layout(set = 0, binding = 0) uniform sampler2D hdr_tex;
layout(set = 0, binding = 1) uniform sampler2D bloom_tex;
void main()
{
// The most basic tonemap possible.
vec3 col = textureLod(hdr_tex, in_uv, 0.0).rgb + textureLod(bloom_tex, in_uv, 0.0).rgb;
col = col / (1.0 + col);
o_color = vec4(col, 1.0);
}
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
#version 450
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Trivial shader that blits compute result to screen.
layout(location = 0) out vec2 o_uv;
void main()
{
if (gl_VertexIndex == 0)
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
else if (gl_VertexIndex == 1)
gl_Position = vec4(-1.0, 3.0, 0.0, 1.0);
else
gl_Position = vec4(3.0, -1.0, 0.0, 1.0);
o_uv = gl_Position.xy * 0.5 + 0.5;
}
Binary file not shown.
+82
View File
@@ -0,0 +1,82 @@
#version 320 es
/* Copyright (c) 2019-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
precision highp float;
layout(set = 0, binding = 0) uniform sampler2D base_color_texture;
layout(location = 0) in vec4 in_pos;
layout(location = 1) in vec2 in_uv;
layout(location = 2) in vec3 in_normal;
layout(location = 3) in vec4 in_shadow_clip;
layout(location = 0) out vec4 o_color;
layout(set = 0, binding = 1) uniform GlobalUniform
{
mat4 model;
mat4 view_proj;
vec3 camera_position;
}
global_uniform;
// Push constants come with a limitation in the size of data.
// The standard requires at least 128 bytes
layout(push_constant, std430) uniform PBRMaterialUniform
{
vec4 base_color_factor;
float metallic_factor;
float roughness_factor;
}
pbr_material_uniform;
#include "lighting.h"
layout(set = 0, binding = 4) uniform LightsInfo
{
Light directional_light;
} lights_info;
layout(set = 0, binding = 6) uniform highp sampler2DShadow tex_shadow;
void main(void)
{
vec3 normal = normalize(in_normal);
vec3 light_contribution = apply_directional_light(lights_info.directional_light, normal);
float shadow = 0.0;
shadow += textureProjLod(tex_shadow, in_shadow_clip, 0.0) / 4.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(-1, 0)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(1, 0)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(0, -1)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(0, 1)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(-1, -1)) / 16.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(1, 1)) / 16.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(-1, 1)) / 16.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(1, -1)) / 16.0;
light_contribution *= shadow;
vec4 base_color = vec4(1.0, 0.0, 0.0, 1.0);
base_color = texture(base_color_texture, in_uv);
vec3 ambient_color = vec3(0.25) * base_color.xyz;
o_color = vec4(ambient_color + light_contribution * base_color.xyz, base_color.w);
}
Binary file not shown.
+49
View File
@@ -0,0 +1,49 @@
#version 320 es
/* Copyright (c) 2019-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) in vec3 position;
layout(location = 1) in vec2 texcoord_0;
layout(location = 2) in vec3 normal;
layout(set = 0, binding = 1) uniform GlobalUniform {
mat4 model;
mat4 view_proj;
vec3 camera_position;
} global_uniform;
layout(set = 0, binding = 5) uniform ShadowUniform {
mat4 matrix;
} shadow_uniform;
layout (location = 0) out vec4 o_pos;
layout (location = 1) out vec2 o_uv;
layout (location = 2) out vec3 o_normal;
layout (location = 3) out vec4 o_shadow_clip;
void main(void)
{
o_pos = global_uniform.model * vec4(position, 1.0);
o_uv = texcoord_0;
o_normal = mat3(global_uniform.model) * normal;
o_shadow_clip = shadow_uniform.matrix * o_pos;
gl_Position = global_uniform.view_proj * o_pos;
}
Binary file not shown.
+21
View File
@@ -0,0 +1,21 @@
#version 320 es
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
void main()
{
}
Binary file not shown.
+30
View File
@@ -0,0 +1,30 @@
#version 320 es
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) in vec3 position;
layout(set = 0, binding = 1) uniform GlobalUniform {
mat4 model;
mat4 view_proj;
} global_uniform;
void main(void)
{
vec4 o_pos = global_uniform.model * vec4(position, 1.0);
gl_Position = global_uniform.view_proj * o_pos;
}
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
#version 450
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(local_size_x = 8, local_size_y = 8) in;
layout(set = 0, binding = 0) uniform sampler2D in_tex;
layout(rgba16f, set = 0, binding = 1) writeonly uniform image2D out_tex;
layout(push_constant) uniform Registers
{
uvec2 resolution;
vec2 inv_resolution;
vec2 inv_input_resolution;
} registers;
void main()
{
if (all(lessThan(gl_GlobalInvocationID.xy, registers.resolution)))
{
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * registers.inv_resolution;
vec3 rgb = textureLod(in_tex, uv, 0.0).rgb;
rgb = 0.2 * max(rgb - 1.0, vec3(0.0));
imageStore(out_tex, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1.0));
}
}
Binary file not shown.