Last active
October 23, 2023 11:23
-
-
Save Wumpf/84e3cd726ae68259208d5332a416bd88 to your computer and use it in GitHub Desktop.
Repro case for shader crash on Linux Chrome Intel
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
<!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Compiling & linking a large shader</title> | |
<script src="main.js" type="module"></script> | |
<script id="vertexShader" type="x-shader/x-vertex">#version 300 es | |
precision highp float; | |
precision highp int; | |
struct UniformBuffer { | |
vec3 top_left_corner_position; | |
uint colormap_function; | |
vec3 extent_u; | |
uint sample_type; | |
vec3 extent_v; | |
float depth_offset; | |
vec4 multiplicative_tint; | |
uvec2 outline_mask; | |
vec2 range_min_max; | |
uint color_mapper; | |
float gamma; | |
uint minification_filter; | |
uint magnification_filter; | |
uint decode_srgb; | |
uint multiply_rgb_with_alpha; | |
}; | |
struct VertexOut { | |
vec4 position; | |
vec2 texcoord; | |
}; | |
struct FrameUniformBuffer { | |
mat4x3 view_from_world; | |
mat4x4 projection_from_view; | |
mat4x4 projection_from_world; | |
vec3 camera_position; | |
float pixel_world_size_from_camera_distance; | |
vec3 camera_forward; | |
float pixels_from_point; | |
vec2 tan_half_fov; | |
float auto_size_points; | |
float auto_size_lines; | |
uint device_tier; | |
}; | |
const float f32max = 3.40282e38; | |
const float f32min = -1.7014116e38; | |
const float f32min_normal = 1.1754944e-38; | |
const int i32min = -2147483648; | |
const int i32max = 2147483647; | |
const uint u32min = 0u; | |
const uint u32max = 4294967295u; | |
const float f32eps = 1.1920929e-7; | |
const vec3 X = vec3(1.0, 0.0, 0.0); | |
const vec3 Y = vec3(0.0, 1.0, 0.0); | |
const vec3 Z = vec3(0.0, 0.0, 1.0); | |
const vec4 ZERO = vec4(0.0, 0.0, 0.0, 0.0); | |
const vec4 ONE = vec4(1.0, 1.0, 1.0, 1.0); | |
const vec4 ERROR_RGBA = vec4(1.0, 0.0, 1.0, 1.0); | |
const uint SAMPLE_TYPE_FLOAT = 1u; | |
const uint SAMPLE_TYPE_SINT = 2u; | |
const uint SAMPLE_TYPE_UINT = 3u; | |
const uint SAMPLE_TYPE_NV12_ = 4u; | |
const uint COLOR_MAPPER_OFF = 1u; | |
const uint COLOR_MAPPER_FUNCTION = 2u; | |
const uint COLOR_MAPPER_TEXTURE = 3u; | |
const uint FILTER_NEAREST = 1u; | |
const uint FILTER_BILINEAR = 2u; | |
const uint DEVICE_TIER_GLES = 0u; | |
const uint DEVICE_TIER_WEBGPU = 1u; | |
uniform UniformBuffer_block_0Vertex { UniformBuffer _group_1_binding_0_vs; }; | |
uniform FrameUniformBuffer_block_1Vertex { | |
FrameUniformBuffer _group_0_binding_0_vs; | |
}; | |
smooth out vec2 _vs2fs_location0; | |
vec4 apply_depth_offset(vec4 position, float offset) { | |
float w_scale_bias = 0.0; | |
w_scale_bias = (f32eps * offset); | |
uint _e7 = _group_0_binding_0_vs.device_tier; | |
if ((_e7 == DEVICE_TIER_GLES)) { | |
float _e11 = w_scale_bias; | |
w_scale_bias = (_e11 * 5120.0); | |
} | |
float _e14 = w_scale_bias; | |
float w_scale = (1.0 - _e14); | |
return vec4(position.xyz, (position.w * w_scale)); | |
} | |
void main() { | |
uint v_idx = uint(gl_VertexID); | |
VertexOut out_ = VertexOut(vec4(0.0), vec2(0.0)); | |
vec2 texcoord = vec2(float((v_idx / 2u)), float((v_idx % 2u))); | |
vec3 _e11 = _group_1_binding_0_vs.extent_u; | |
vec3 _e16 = _group_1_binding_0_vs.extent_v; | |
vec3 _e21 = _group_1_binding_0_vs.top_left_corner_position; | |
vec3 pos = (((texcoord.x * _e11) + (texcoord.y * _e16)) + _e21); | |
mat4x4 _e27 = _group_0_binding_0_vs.projection_from_world; | |
float _e33 = _group_1_binding_0_vs.depth_offset; | |
vec4 _e34 = apply_depth_offset((_e27 * vec4(pos, 1.0)), _e33); | |
out_.position = _e34; | |
out_.texcoord = texcoord; | |
uint _e38 = _group_1_binding_0_vs.sample_type; | |
if ((_e38 == SAMPLE_TYPE_NV12_)) { | |
float _e44 = out_.texcoord.y; | |
out_.texcoord.y = (_e44 / 1.5); | |
} | |
VertexOut _e46 = out_; | |
gl_Position = _e46.position; | |
_vs2fs_location0 = _e46.texcoord; | |
gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w); | |
return; | |
} | |
</script> | |
<script id="fragmentShader" type="x-shader/x-fragment">#version 300 es | |
precision highp float; | |
precision highp int; | |
struct UniformBuffer { | |
vec3 top_left_corner_position; | |
uint colormap_function; | |
vec3 extent_u; | |
uint sample_type; | |
vec3 extent_v; | |
float depth_offset; | |
vec4 multiplicative_tint; | |
uvec2 outline_mask; | |
vec2 range_min_max; | |
uint color_mapper; | |
float gamma; | |
uint minification_filter; | |
uint magnification_filter; | |
uint decode_srgb; | |
uint multiply_rgb_with_alpha; | |
}; | |
struct VertexOut { | |
vec4 position; | |
vec2 texcoord; | |
}; | |
const float f32max = 3.40282e38; | |
const float f32min = -1.7014116e38; | |
const float f32min_normal = 1.1754944e-38; | |
const int i32min = -2147483648; | |
const int i32max = 2147483647; | |
const uint u32min = 0u; | |
const uint u32max = 4294967295u; | |
const float f32eps = 1.1920929e-7; | |
const vec3 X = vec3(1.0, 0.0, 0.0); | |
const vec3 Y = vec3(0.0, 1.0, 0.0); | |
const vec3 Z = vec3(0.0, 0.0, 1.0); | |
const vec4 ZERO = vec4(0.0, 0.0, 0.0, 0.0); | |
const vec4 ONE = vec4(1.0, 1.0, 1.0, 1.0); | |
const vec4 ERROR_RGBA = vec4(1.0, 0.0, 1.0, 1.0); | |
const uint COLORMAP_GRAYSCALE = 1u; | |
const uint COLORMAP_INFERNO = 2u; | |
const uint COLORMAP_MAGMA = 3u; | |
const uint COLORMAP_PLASMA = 4u; | |
const uint COLORMAP_TURBO = 5u; | |
const uint COLORMAP_VIRIDIS = 6u; | |
const uint SAMPLE_TYPE_FLOAT = 1u; | |
const uint SAMPLE_TYPE_SINT = 2u; | |
const uint SAMPLE_TYPE_UINT = 3u; | |
const uint SAMPLE_TYPE_NV12_ = 4u; | |
const uint COLOR_MAPPER_OFF = 1u; | |
const uint COLOR_MAPPER_FUNCTION = 2u; | |
const uint COLOR_MAPPER_TEXTURE = 3u; | |
const uint FILTER_NEAREST = 1u; | |
const uint FILTER_BILINEAR = 2u; | |
uniform UniformBuffer_block_0Fragment { UniformBuffer _group_1_binding_0_fs; }; | |
uniform highp sampler2D _group_1_binding_1_fs; | |
uniform highp isampler2D _group_1_binding_2_fs; | |
uniform highp usampler2D _group_1_binding_3_fs; | |
uniform highp sampler2D _group_1_binding_4_fs; | |
smooth in vec2 _vs2fs_location0; | |
layout(location = 0) out vec4 _fs2p_location0; | |
vec3 linear_from_srgb(vec3 srgb) { | |
vec3 cutoff = ceil((srgb - vec3(0.04045))); | |
vec3 under = (srgb / vec3(12.92)); | |
vec3 over = pow(((srgb + vec3(0.055)) / vec3(1.055)), vec3(2.4)); | |
return mix(under, over, cutoff); | |
} | |
vec4 linear_from_srgba(vec4 srgb_a) { | |
vec3 _e2 = linear_from_srgb(srgb_a.xyz); | |
return vec4(_e2, srgb_a.w); | |
} | |
vec3 srgb_from_linear(vec3 color_linear) { | |
vec3 selector = ceil((color_linear - vec3(0.0031308))); | |
vec3 under_1 = (12.92 * color_linear); | |
vec3 over_1 = ((1.055 * pow(color_linear, vec3(0.41666))) - vec3(0.055)); | |
return mix(under_1, over_1, selector); | |
} | |
vec4 srgba_from_linear(vec4 srgb_a_1) { | |
vec3 _e2 = srgb_from_linear(srgb_a_1.xyz); | |
return vec4(_e2, srgb_a_1.w); | |
} | |
vec3 colormap_viridis_srgb(float t) { | |
vec3 c0_ = vec3(0.27772734, 0.0054073445, 0.3340998); | |
vec3 c1_ = vec3(0.10509304, 1.4046135, 1.3845901); | |
vec3 c2_ = vec3(-0.33086184, 0.21484756, 0.095095165); | |
vec3 c3_ = vec3(-4.6342306, -5.799101, -19.332441); | |
vec3 c4_ = vec3(6.22827, 14.179934, 56.69055); | |
vec3 c5_ = vec3(4.776385, -13.745146, -65.353035); | |
vec3 c6_ = vec3(-5.435456, 4.6458526, 26.312435); | |
return (c0_ + (t * (c1_ + (t * (c2_ + (t * (c3_ + (t * (c4_ + (t * (c5_ + (t * c6_)))))))))))); | |
} | |
vec3 colormap_inferno_srgb(float t_1) { | |
vec3 c0_1 = vec3(0.00021894037, 0.0016510047, -0.019480899); | |
vec3 c1_1 = vec3(0.10651342, 0.56395644, 3.9327123); | |
vec3 c2_1 = vec3(11.602493, -3.972854, -15.942394); | |
vec3 c3_1 = vec3(-41.703995, 17.4364, 44.354145); | |
vec3 c4_1 = vec3(77.16293, -33.40236, -81.80731); | |
vec3 c5_1 = vec3(-71.31943, 32.626064, 73.20952); | |
vec3 c6_1 = vec3(25.131126, -12.242669, -23.070326); | |
return (c0_1 + (t_1 * (c1_1 + (t_1 * (c2_1 + (t_1 * (c3_1 + (t_1 * (c4_1 + (t_1 * (c5_1 + (t_1 * c6_1)))))))))))); | |
} | |
vec3 colormap_turbo_srgb(float t_2) { | |
vec4 r4_ = vec4(0.13572139, 4.6153927, -42.660324, 132.13109); | |
vec4 g4_ = vec4(0.09140261, 2.1941884, 4.8429666, -14.185034); | |
vec4 b4_ = vec4(0.1066733, 12.641946, -60.582047, 110.36277); | |
vec2 r2_ = vec2(-152.9424, 59.28638); | |
vec2 g2_ = vec2(4.2772985, 2.829566); | |
vec2 b2_ = vec2(-89.90311, 27.34825); | |
vec4 v4_ = vec4(1.0, t_2, (t_2 * t_2), ((t_2 * t_2) * t_2)); | |
vec2 v2_ = (v4_.zw * v4_.z); | |
return vec3((dot(v4_, r4_) + dot(v2_, r2_)), (dot(v4_, g4_) + dot(v2_, g2_)), (dot(v4_, b4_) + dot(v2_, b2_))); | |
} | |
vec3 colormap_plasma_srgb(float t_3) { | |
vec3 c0_2 = vec3(0.058732346, 0.023336709, 0.5433402); | |
vec3 c1_2 = vec3(2.1765146, 0.23838341, 0.75396043); | |
vec3 c2_2 = vec3(-2.6894605, -7.455851, 3.1108); | |
vec3 c3_2 = vec3(6.130348, 42.346188, -28.518854); | |
vec3 c4_2 = vec3(-11.107436, -82.66631, 60.139847); | |
vec3 c5_2 = vec3(10.023066, 71.41362, -54.072186); | |
vec3 c6_2 = vec3(-3.6587138, -22.931534, 18.191908); | |
return (c0_2 + (t_3 * (c1_2 + (t_3 * (c2_2 + (t_3 * (c3_2 + (t_3 * (c4_2 + (t_3 * (c5_2 + (t_3 * c6_2)))))))))))); | |
} | |
vec3 colormap_magma_srgb(float t_4) { | |
vec3 c0_3 = vec3(-0.002136485, -0.00074965507, -0.0053861276); | |
vec3 c1_3 = vec3(0.25166056, 0.67752326, 2.4940267); | |
vec3 c2_3 = vec3(8.353717, -3.5777194, 0.3144679); | |
vec3 c3_3 = vec3(-27.668734, 14.26473, -13.649213); | |
vec3 c4_3 = vec3(52.17614, -27.943605, 12.944169); | |
vec3 c5_3 = vec3(-50.768524, 29.046583, 4.234153); | |
vec3 c6_3 = vec3(18.655704, -11.489774, -5.6019616); | |
return (c0_3 + (t_4 * (c1_3 + (t_4 * (c2_3 + (t_4 * (c3_3 + (t_4 * (c4_3 + (t_4 * (c5_3 + (t_4 * c6_3)))))))))))); | |
} | |
vec3 colormap_srgb(uint which, float t_unsaturated) { | |
float t_6 = clamp(t_unsaturated, 0.0, 1.0); | |
if ((which == COLORMAP_GRAYSCALE)) { | |
return vec3(t_6); | |
} else { | |
if ((which == COLORMAP_INFERNO)) { | |
vec3 _e8 = colormap_inferno_srgb(t_6); | |
return _e8; | |
} else { | |
if ((which == COLORMAP_MAGMA)) { | |
vec3 _e11 = colormap_magma_srgb(t_6); | |
return _e11; | |
} else { | |
if ((which == COLORMAP_PLASMA)) { | |
vec3 _e14 = colormap_plasma_srgb(t_6); | |
return _e14; | |
} else { | |
if ((which == COLORMAP_TURBO)) { | |
vec3 _e17 = colormap_turbo_srgb(t_6); | |
return _e17; | |
} else { | |
if ((which == COLORMAP_VIRIDIS)) { | |
vec3 _e20 = colormap_viridis_srgb(t_6); | |
return _e20; | |
} else { | |
return ERROR_RGBA.xyz; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
vec3 colormap_linear(uint which_1, float t_5) { | |
vec3 _e2 = colormap_srgb(which_1, t_5); | |
vec3 _e3 = linear_from_srgb(_e2); | |
return _e3; | |
} | |
vec4 decode_nv12_(highp usampler2D texture, ivec2 coords) { | |
uint uv_col = 0u; | |
vec2 texture_dim = vec2(uvec2(textureSize(texture, 0).xy).xy); | |
uint uv_offset = uint(floor((texture_dim.y / 1.5))); | |
uint uv_row = uint((coords.y / 2)); | |
uv_col = (uint((coords.x / 2)) * 2u); | |
uvec4 _e24 = texelFetch(texture, ivec2(uvec2(coords)), 0); | |
float y = (max(0.0, (float(_e24.x) - 16.0)) / 219.0); | |
uint _e32 = uv_col; | |
uvec4 _e37 = texelFetch(texture, ivec2(uvec2(uint(_e32), (uv_offset + uv_row))), 0); | |
float u = ((float(_e37.x) - 128.0) / 224.0); | |
uint _e44 = uv_col; | |
uvec4 _e51 = texelFetch(texture, ivec2(uvec2((uint(_e44) + 1u), (uv_offset + uv_row))), 0); | |
float v = ((float(_e51.x) - 128.0) / 224.0); | |
float r = clamp((y + (1.402 * v)), 0.0, 1.0); | |
float g = clamp((y - ((0.344 * u) + (0.714 * v))), 0.0, 1.0); | |
float b = clamp((y + (1.772 * u)), 0.0, 1.0); | |
return vec4(r, g, b, 1.0); | |
} | |
bool is_magnifying(vec2 pixel_coord) { | |
float _e2 = fwidth(pixel_coord.x); | |
return (_e2 < 1.0); | |
} | |
uint tex_filter(vec2 pixel_coord_1) { | |
bool _e1 = is_magnifying(pixel_coord_1); | |
if (_e1) { | |
uint _e4 = _group_1_binding_0_fs.magnification_filter; | |
return _e4; | |
} else { | |
uint _e7 = _group_1_binding_0_fs.minification_filter; | |
return _e7; | |
} | |
} | |
vec4 normalize_range(vec4 sampled_value) { | |
vec2 range = _group_1_binding_0_fs.range_min_max; | |
return ((sampled_value - vec4(range.x)) / vec4((range.y - range.x))); | |
} | |
vec4 decode_color(vec4 sampled_value_1) { | |
vec4 rgba = vec4(0.0); | |
vec4 _e1 = normalize_range(sampled_value_1); | |
rgba = _e1; | |
uint _e5 = _group_1_binding_0_fs.decode_srgb; | |
if ((_e5 != 0u)) { | |
vec4 _e10 = rgba; | |
vec4 _e14 = rgba; | |
if ((all(lessThanEqual(vec3(0.0), _e10.xyz)) && all(lessThanEqual(_e14.xyz, vec3(1.0))))) { | |
vec4 _e21 = rgba; | |
vec4 _e22 = linear_from_srgba(_e21); | |
rgba = _e22; | |
} else { | |
rgba = ERROR_RGBA; | |
} | |
} | |
uint _e26 = _group_1_binding_0_fs.multiply_rgb_with_alpha; | |
if ((_e26 != 0u)) { | |
vec4 _e29 = rgba; | |
float _e32 = rgba.w; | |
float _e35 = rgba.w; | |
rgba = vec4((_e29.xyz * _e32), _e35); | |
} | |
vec4 _e37 = rgba; | |
return _e37; | |
} | |
ivec2 clamp_to_edge_nearest_neighbor(vec2 coord, vec2 texture_dimension) { | |
return ivec2(clamp(floor(coord), vec2(0.0), (texture_dimension - vec2(1.0)))); | |
} | |
vec4 filter_bilinear(vec2 coord_1, vec4 v00_, vec4 v01_, vec4 v10_, vec4 v11_) { | |
vec4 top = mix(v00_, v10_, fract((coord_1.x - 0.5))); | |
vec4 bottom = mix(v01_, v11_, fract((coord_1.x - 0.5))); | |
return mix(top, bottom, fract((coord_1.y - 0.5))); | |
} | |
void main() { | |
VertexOut in_ = VertexOut(gl_FragCoord, _vs2fs_location0); | |
vec4 normalized_value = vec4(0.0); | |
vec4 texture_color = vec4(0.0); | |
uint _e4 = _group_1_binding_0_fs.sample_type; | |
if ((_e4 == SAMPLE_TYPE_FLOAT)) { | |
vec2 texture_dimensions = vec2(uvec2(textureSize(_group_1_binding_1_fs, 0).xy).xy); | |
vec2 coord_2 = (in_.texcoord * texture_dimensions); | |
uint _e13 = tex_filter(coord_2); | |
if ((_e13 == FILTER_NEAREST)) { | |
ivec2 _e17 = clamp_to_edge_nearest_neighbor(coord_2, texture_dimensions); | |
vec4 _e19 = texelFetch(_group_1_binding_1_fs, _e17, 0); | |
vec4 _e20 = decode_color(_e19); | |
normalized_value = _e20; | |
} else { | |
ivec2 _e26 = clamp_to_edge_nearest_neighbor((coord_2 + vec2(-0.5, -0.5)), texture_dimensions); | |
vec4 _e28 = texelFetch(_group_1_binding_1_fs, _e26, 0); | |
vec4 _e29 = decode_color(_e28); | |
ivec2 _e35 = clamp_to_edge_nearest_neighbor((coord_2 + vec2(-0.5, 0.5)), texture_dimensions); | |
vec4 _e37 = texelFetch(_group_1_binding_1_fs, _e35, 0); | |
vec4 _e38 = decode_color(_e37); | |
ivec2 _e44 = clamp_to_edge_nearest_neighbor((coord_2 + vec2(0.5, -0.5)), texture_dimensions); | |
vec4 _e46 = texelFetch(_group_1_binding_1_fs, _e44, 0); | |
vec4 _e47 = decode_color(_e46); | |
ivec2 _e53 = clamp_to_edge_nearest_neighbor((coord_2 + vec2(0.5, 0.5)), texture_dimensions); | |
vec4 _e55 = texelFetch(_group_1_binding_1_fs, _e53, 0); | |
vec4 _e56 = decode_color(_e55); | |
vec4 _e57 = filter_bilinear(coord_2, _e29, _e38, _e47, _e56); | |
normalized_value = _e57; | |
} | |
} else { | |
uint _e60 = _group_1_binding_0_fs.sample_type; | |
if ((_e60 == SAMPLE_TYPE_SINT)) { | |
vec2 texture_dimensions_1 = vec2(uvec2(textureSize(_group_1_binding_2_fs, 0).xy).xy); | |
vec2 coord_3 = (in_.texcoord * texture_dimensions_1); | |
uint _e69 = tex_filter(coord_3); | |
if ((_e69 == FILTER_NEAREST)) { | |
ivec2 _e73 = clamp_to_edge_nearest_neighbor(coord_3, texture_dimensions_1); | |
ivec4 _e75 = texelFetch(_group_1_binding_2_fs, _e73, 0); | |
vec4 _e77 = decode_color(vec4(_e75)); | |
normalized_value = _e77; | |
} else { | |
ivec2 _e83 = clamp_to_edge_nearest_neighbor((coord_3 + vec2(-0.5, -0.5)), texture_dimensions_1); | |
ivec4 _e85 = texelFetch(_group_1_binding_2_fs, _e83, 0); | |
vec4 _e87 = decode_color(vec4(_e85)); | |
ivec2 _e93 = clamp_to_edge_nearest_neighbor((coord_3 + vec2(-0.5, 0.5)), texture_dimensions_1); | |
ivec4 _e95 = texelFetch(_group_1_binding_2_fs, _e93, 0); | |
vec4 _e97 = decode_color(vec4(_e95)); | |
ivec2 _e103 = clamp_to_edge_nearest_neighbor((coord_3 + vec2(0.5, -0.5)), texture_dimensions_1); | |
ivec4 _e105 = texelFetch(_group_1_binding_2_fs, _e103, 0); | |
vec4 _e107 = decode_color(vec4(_e105)); | |
ivec2 _e113 = clamp_to_edge_nearest_neighbor((coord_3 + vec2(0.5, 0.5)), texture_dimensions_1); | |
ivec4 _e115 = texelFetch(_group_1_binding_2_fs, _e113, 0); | |
vec4 _e117 = decode_color(vec4(_e115)); | |
vec4 _e118 = filter_bilinear(coord_3, _e87, _e97, _e107, _e117); | |
normalized_value = _e118; | |
} | |
} else { | |
uint _e121 = _group_1_binding_0_fs.sample_type; | |
if ((_e121 == SAMPLE_TYPE_UINT)) { | |
vec2 texture_dimensions_2 = vec2(uvec2(textureSize(_group_1_binding_3_fs, 0).xy).xy); | |
vec2 coord_4 = (in_.texcoord * texture_dimensions_2); | |
uint _e130 = tex_filter(coord_4); | |
if ((_e130 == FILTER_NEAREST)) { | |
ivec2 _e134 = clamp_to_edge_nearest_neighbor(coord_4, texture_dimensions_2); | |
uvec4 _e136 = texelFetch(_group_1_binding_3_fs, _e134, 0); | |
vec4 _e138 = decode_color(vec4(_e136)); | |
normalized_value = _e138; | |
} else { | |
ivec2 _e144 = clamp_to_edge_nearest_neighbor((coord_4 + vec2(-0.5, -0.5)), texture_dimensions_2); | |
uvec4 _e146 = texelFetch(_group_1_binding_3_fs, _e144, 0); | |
vec4 _e148 = decode_color(vec4(_e146)); | |
ivec2 _e154 = clamp_to_edge_nearest_neighbor((coord_4 + vec2(-0.5, 0.5)), texture_dimensions_2); | |
uvec4 _e156 = texelFetch(_group_1_binding_3_fs, _e154, 0); | |
vec4 _e158 = decode_color(vec4(_e156)); | |
ivec2 _e164 = clamp_to_edge_nearest_neighbor((coord_4 + vec2(0.5, -0.5)), texture_dimensions_2); | |
uvec4 _e166 = texelFetch(_group_1_binding_3_fs, _e164, 0); | |
vec4 _e168 = decode_color(vec4(_e166)); | |
ivec2 _e174 = clamp_to_edge_nearest_neighbor((coord_4 + vec2(0.5, 0.5)), texture_dimensions_2); | |
uvec4 _e176 = texelFetch(_group_1_binding_3_fs, _e174, 0); | |
vec4 _e178 = decode_color(vec4(_e176)); | |
vec4 _e179 = filter_bilinear(coord_4, _e148, _e158, _e168, _e178); | |
normalized_value = _e179; | |
} | |
} else { | |
uint _e182 = _group_1_binding_0_fs.sample_type; | |
if ((_e182 == SAMPLE_TYPE_NV12_)) { | |
vec2 texture_dimensions_3 = vec2(uvec2(textureSize(_group_1_binding_3_fs, 0).xy).xy); | |
vec2 coord_5 = (in_.texcoord * texture_dimensions_3); | |
uint _e191 = tex_filter(coord_5); | |
if ((_e191 == FILTER_NEAREST)) { | |
ivec2 _e195 = clamp_to_edge_nearest_neighbor(coord_5, texture_dimensions_3); | |
vec4 _e196 = decode_nv12_(_group_1_binding_3_fs, _e195); | |
vec4 _e198 = decode_color(vec4(_e196)); | |
normalized_value = _e198; | |
} else { | |
ivec2 _e204 = clamp_to_edge_nearest_neighbor((coord_5 + vec2(-0.5, -0.5)), texture_dimensions_3); | |
vec4 _e205 = decode_nv12_(_group_1_binding_3_fs, _e204); | |
vec4 _e207 = decode_color(vec4(_e205)); | |
ivec2 _e213 = clamp_to_edge_nearest_neighbor((coord_5 + vec2(-0.5, 0.5)), texture_dimensions_3); | |
vec4 _e214 = decode_nv12_(_group_1_binding_3_fs, _e213); | |
vec4 _e216 = decode_color(vec4(_e214)); | |
ivec2 _e222 = clamp_to_edge_nearest_neighbor((coord_5 + vec2(0.5, -0.5)), texture_dimensions_3); | |
vec4 _e223 = decode_nv12_(_group_1_binding_3_fs, _e222); | |
vec4 _e225 = decode_color(vec4(_e223)); | |
ivec2 _e231 = clamp_to_edge_nearest_neighbor((coord_5 + vec2(0.5, 0.5)), texture_dimensions_3); | |
vec4 _e232 = decode_nv12_(_group_1_binding_3_fs, _e231); | |
vec4 _e234 = decode_color(vec4(_e232)); | |
vec4 _e235 = filter_bilinear(coord_5, _e207, _e216, _e225, _e234); | |
normalized_value = _e235; | |
} | |
} else { | |
_fs2p_location0 = ERROR_RGBA; | |
return; | |
} | |
} | |
} | |
} | |
vec4 _e237 = normalized_value; | |
float _e241 = _group_1_binding_0_fs.gamma; | |
float _e245 = normalized_value.w; | |
normalized_value = vec4(pow(_e237.xyz, vec3(_e241)), _e245); | |
uint _e250 = _group_1_binding_0_fs.color_mapper; | |
if ((_e250 == COLOR_MAPPER_OFF)) { | |
vec4 _e253 = normalized_value; | |
texture_color = _e253; | |
} else { | |
uint _e256 = _group_1_binding_0_fs.color_mapper; | |
if ((_e256 == COLOR_MAPPER_FUNCTION)) { | |
uint _e261 = _group_1_binding_0_fs.colormap_function; | |
float _e263 = normalized_value.x; | |
vec3 _e264 = colormap_linear(_e261, _e263); | |
texture_color = vec4(_e264, 1.0); | |
} else { | |
uint _e269 = _group_1_binding_0_fs.color_mapper; | |
if ((_e269 == COLOR_MAPPER_TEXTURE)) { | |
uvec2 colormap_size = uvec2(textureSize(_group_1_binding_4_fs, 0).xy).xy; | |
float _e276 = normalized_value.x; | |
float color_index = (_e276 * float((colormap_size.x * colormap_size.y))); | |
uint color_index_u32_ = uint(roundEven(color_index)); | |
uint x = (color_index_u32_ % colormap_size.x); | |
uint y_1 = (color_index_u32_ / colormap_size.x); | |
vec4 _e291 = texelFetch(_group_1_binding_4_fs, ivec2(uvec2(x, y_1)), 0); | |
texture_color = _e291; | |
} else { | |
_fs2p_location0 = ERROR_RGBA; | |
return; | |
} | |
} | |
} | |
vec4 _e293 = texture_color; | |
vec4 _e296 = _group_1_binding_0_fs.multiplicative_tint; | |
_fs2p_location0 = (_e293 * _e296); | |
return; | |
} | |
</script> | |
</head> | |
<body> | |
<canvas id="glcanvas" width="640" height="480"></canvas> | |
</body> | |
</html> |
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
function compileShader(gl, shaderSource, shaderType) { | |
// Create the shader object | |
var shader = gl.createShader(shaderType); | |
// Set the shader source code. | |
gl.shaderSource(shader, shaderSource); | |
// Compile the shader | |
gl.compileShader(shader); | |
// Check if it compiled | |
var success = gl.getShaderParameter(shader, gl.COMPILE_STATUS); | |
if (!success) { | |
// Something went wrong during compilation; get the error | |
throw "could not compile shader:" + gl.getShaderInfoLog(shader); | |
} | |
return shader; | |
} | |
function createProgram(gl, vertexShader, fragmentShader) { | |
// create a program. | |
var program = gl.createProgram(); | |
// attach the shaders. | |
gl.attachShader(program, vertexShader); | |
gl.attachShader(program, fragmentShader); | |
// link the program. | |
gl.linkProgram(program); | |
// Check if it linked. | |
var success = gl.getProgramParameter(program, gl.LINK_STATUS); | |
if (!success) { | |
// something went wrong with the link | |
throw "program failed to link:" + gl.getProgramInfoLog(program); | |
} | |
return program; | |
} | |
function createShaderFromScript(gl, scriptId, opt_shaderType) { | |
// look up the script tag by id. | |
var shaderScript = document.getElementById(scriptId); | |
if (!shaderScript) { | |
throw "*** Error: unknown script element" + scriptId; | |
} | |
// extract the contents of the script tag. | |
var shaderSource = shaderScript.text; | |
// If we didn't pass in a type, use the 'type' from | |
// the script tag. | |
if (!opt_shaderType) { | |
if (shaderScript.type == "x-shader/x-vertex") { | |
opt_shaderType = gl.VERTEX_SHADER; | |
} else if (shaderScript.type == "x-shader/x-fragment") { | |
opt_shaderType = gl.FRAGMENT_SHADER; | |
} else if (!opt_shaderType) { | |
throw "*** Error: shader type not set"; | |
} | |
} | |
return compileShader(gl, shaderSource, opt_shaderType); | |
} | |
function createProgramFromScripts(gl, shaderScriptIds) { | |
var vertexShader = createShaderFromScript( | |
gl, | |
shaderScriptIds[0], | |
gl.VERTEX_SHADER | |
); | |
var fragmentShader = createShaderFromScript( | |
gl, | |
shaderScriptIds[1], | |
gl.FRAGMENT_SHADER | |
); | |
return createProgram(gl, vertexShader, fragmentShader); | |
} | |
console.log("creating webgl context"); | |
const canvas = document.querySelector("#glcanvas"); | |
const gl = canvas.getContext("webgl2"); | |
if (gl === null) { | |
throw "Unable to initialize WebGL. Your browser or machine may not support it."; | |
} | |
gl.clearColor(0.0, 0.0, 0.0, 1.0); | |
gl.clear(gl.COLOR_BUFFER_BIT); | |
for (var i = 0; i < 1000; ++i) { | |
console.log("compiling shader"); | |
var program = createProgramFromScripts(gl, ["vertexShader", "fragmentShader"]); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment