Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-436ca0bc8b549ace/out/composite_FAST_PATH_TEXTURE_RECT.h
Warning:line 74, column 16
Value stored to 'texture_size' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gl.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -fapprox-func -funsafe-math-optimizations -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -mrecip=none -complex-range=limited -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/gfx/wr/swgl -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/gfx/wr/swgl -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -D MOZILLA_CONFIG_H -I /var/lib/jenkins/workspace/firefox-scan-build/gfx/wr/swgl/../webrender/res -I src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-436ca0bc8b549ace/out -U MOZILLA_CONFIG_H -D _GLIBCXX_USE_CXX11_ABI=0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -std=c++17 -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-05-16-034744-15991-1 -x c++ src/gl.cc
1struct composite_FAST_PATH_TEXTURE_RECT_common {
2struct Samplers {
3 sampler2DRect_impl sColor0_impl;
4 int sColor0_slot;
5 bool set_slot(int index, int value) {
6 switch (index) {
7 case 2:
8 sColor0_slot = value;
9 return true;
10 }
11 return false;
12 }
13} samplers;
14struct AttribLocations {
15 int aPosition = NULL_ATTRIB16;
16 int aLocalRect = NULL_ATTRIB16;
17 int aDeviceClipRect = NULL_ATTRIB16;
18 int aParams = NULL_ATTRIB16;
19 int aTransform = NULL_ATTRIB16;
20 int aUvRect0 = NULL_ATTRIB16;
21 void bind_loc(const char* name, int index) {
22 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
23 if (strcmp("aLocalRect", name) == 0) { aLocalRect = index; return; }
24 if (strcmp("aDeviceClipRect", name) == 0) { aDeviceClipRect = index; return; }
25 if (strcmp("aParams", name) == 0) { aParams = index; return; }
26 if (strcmp("aTransform", name) == 0) { aTransform = index; return; }
27 if (strcmp("aUvRect0", name) == 0) { aUvRect0 = index; return; }
28 }
29 int get_loc(const char* name) const {
30 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
31 if (strcmp("aLocalRect", name) == 0) { return aLocalRect != NULL_ATTRIB16 ? aLocalRect : -1; }
32 if (strcmp("aDeviceClipRect", name) == 0) { return aDeviceClipRect != NULL_ATTRIB16 ? aDeviceClipRect : -1; }
33 if (strcmp("aParams", name) == 0) { return aParams != NULL_ATTRIB16 ? aParams : -1; }
34 if (strcmp("aTransform", name) == 0) { return aTransform != NULL_ATTRIB16 ? aTransform : -1; }
35 if (strcmp("aUvRect0", name) == 0) { return aUvRect0 != NULL_ATTRIB16 ? aUvRect0 : -1; }
36 return -1;
37 }
38} attrib_locations;
39sampler2DRect sColor0;
40mat4_scalar uTransform;
41void bind_textures() {
42 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
43}
44};
45struct composite_FAST_PATH_TEXTURE_RECT_vert : VertexShaderImpl, composite_FAST_PATH_TEXTURE_RECT_common {
46private:
47typedef composite_FAST_PATH_TEXTURE_RECT_vert Self;
48// mat4_scalar uTransform;
49vec2 aPosition;
50// sampler2DRect sColor0;
51// sampler2DRect sColor1;
52// sampler2DRect sColor2;
53vec2 vUv;
54vec4_scalar aLocalRect;
55vec4_scalar aDeviceClipRect;
56vec4_scalar aColor;
57vec4_scalar aParams;
58vec4_scalar aTransform;
59vec4_scalar aUvRect0;
60vec2_scalar apply_transform(vec2_scalar p, vec4_scalar transform) {
61 return ((p)*((transform).sel(X,Y)))+((transform).sel(Z,W));
62}
63ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
64 vec2_scalar world_p0 = apply_transform((aLocalRect).sel(X,Y), aTransform);
65 vec2_scalar world_p1 = apply_transform((aLocalRect).sel(Z,W), aTransform);
66 vec2 world_pos = mix(world_p0, world_p1, (aPosition).sel(X,Y));
67 vec2 clipped_world_pos = clamp(world_pos, (aDeviceClipRect).sel(X,Y), (aDeviceClipRect).sel(Z,W));
68 vec2 uv = ((clipped_world_pos)-(world_p0))/((world_p1)-(world_p0));
69 uv = mix((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W), uv);
70 vec4_scalar uvBounds = make_vec4(min((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W)), max((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W)));
71 int32_t rescale_uv = make_int((aParams).y);
72 if ((rescale_uv)==(1)) {
73 {
74 vec2_scalar texture_size = make_vec2(1.f, 1.f);
Value stored to 'texture_size' during its initialization is never read
75 uvBounds += make_vec4(0.5f, 0.5f, -(0.5f), -(0.5f));
76 }
77 }
78 vUv = uv;
79 gl_Position = (uTransform)*(make_vec4(clipped_world_pos, 0.f, 1.f));
80}
81static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
82 Self* self = (Self*)impl;
83 if (self->samplers.set_slot(index, value)) return;
84 switch (index) {
85 case 2:
86 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
87 break;
88 case 1:
89 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
90 break;
91 }
92}
93static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
94 Self* self = (Self*)impl;
95 switch (index) {
96 case 2:
97 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
98 break;
99 case 1:
100 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
101 break;
102 }
103}
104static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
105 Self* self = (Self*)impl;
106 switch (index) {
107 case 2:
108 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
109 break;
110 case 1:
111 self->uTransform = mat4_scalar::load_from_ptr(value);
112 break;
113 }
114}
115static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
116 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
117 load_flat_attrib(self->aLocalRect, attribs[self->attrib_locations.aLocalRect], start, instance, count);
118 load_flat_attrib(self->aDeviceClipRect, attribs[self->attrib_locations.aDeviceClipRect], start, instance, count);
119 load_flat_attrib(self->aParams, attribs[self->attrib_locations.aParams], start, instance, count);
120 load_flat_attrib(self->aTransform, attribs[self->attrib_locations.aTransform], start, instance, count);
121 load_flat_attrib(self->aUvRect0, attribs[self->attrib_locations.aUvRect0], start, instance, count);
122}
123public:
124struct InterpOutputs {
125vec2_scalar vUv;
126};
127private:
128ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
129 for(int n = 0; n < 4; n++) {
130 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
131 dest->vUv = get_nth(vUv, n);
132 dest_ptr += stride;
133 }
134}
135static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
136 Self* self = (Self*)impl;
137 self->main();
138 self->store_interp_outputs(interps, interp_stride);
139}
140static void init_batch(VertexShaderImpl* impl) {
141 Self* self = (Self*)impl; self->bind_textures(); }
142public:
143composite_FAST_PATH_TEXTURE_RECT_vert() {
144 set_uniform_1i_func = &set_uniform_1i;
145 set_uniform_4fv_func = &set_uniform_4fv;
146 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
147 init_batch_func = &init_batch;
148 load_attribs_func = &load_attribs;
149 run_primitive_func = &run;
150}
151};
152
153
154struct composite_FAST_PATH_TEXTURE_RECT_frag : FragmentShaderImpl, composite_FAST_PATH_TEXTURE_RECT_vert {
155private:
156typedef composite_FAST_PATH_TEXTURE_RECT_frag Self;
157#define oFragColorgl_FragColor gl_FragColor
158// vec4 oFragColor;
159// sampler2DRect sColor0;
160// sampler2DRect sColor1;
161// sampler2DRect sColor2;
162vec2 vUv;
163void write_output(vec4 color) {
164 oFragColorgl_FragColor = color;
165}
166ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
167 vec2 uv = vUv;
168 vec4 texel = texture(sColor0, (uv).sel(X,Y));
169 vec4 color = texel;
170 write_output(color);
171}
172void swgl_drawSpanRGBA8() {
173 vec4_scalar color = make_vec4(1.f);
174 vec4_scalar uvBounds = make_vec4(make_vec2(0.f), make_vec2(textureSize(sColor0)));
175 if ((color)!=(make_vec4(1.f))) {
176 {
177 swgl_commitTextureColorRGBA8(sColor0, vUv, uvBounds, color)do { if (sColor0->filter == TextureFilter::LINEAR) { do { auto
packed_color = packColor(swgl_OutRGBA8, color); int len = (swgl_SpanLength
); int drawn = 0; if (LinearFilter filter = needsTextureLinear
(sColor0, vUv, len)) { if (blend_key) { drawn = blendTextureLinear
<true>(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8
, filter); } else { drawn = blendTextureLinear<false>(sColor0
, vUv, len, uvBounds, packed_color, swgl_OutRGBA8, filter); }
} else if (blend_key) { drawn = blendTextureNearestFast<true
>(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8
); } else { drawn = blendTextureNearestFast<false>(sColor0
, vUv, len, uvBounds, packed_color, swgl_OutRGBA8); } swgl_OutRGBA8
+= drawn; swgl_SpanLength -= drawn; } while (0); } else { do
{ auto packed_color = packColor(swgl_OutRGBA8, color); int drawn
= 0; if (needsNearestFallback(sColor0, vUv, swgl_SpanLength)
) { if (blend_key) { drawn = blendTextureNearestRepeat<true
, false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds, packed_color
, swgl_OutRGBA8); } else { drawn = blendTextureNearestRepeat<
false, false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds
, packed_color, swgl_OutRGBA8); } } else if (blend_key) { drawn
= blendTextureNearestFast<true>(sColor0, vUv, swgl_SpanLength
, uvBounds, packed_color, swgl_OutRGBA8); } else { drawn = blendTextureNearestFast
<false>(sColor0, vUv, swgl_SpanLength, uvBounds, packed_color
, swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -=
drawn; } while (0); } } while (0)
;
178 }
179 } else {
180 swgl_commitTextureRGBA8(sColor0, vUv, uvBounds)do { if (sColor0->filter == TextureFilter::LINEAR) { do { auto
packed_color = packColor(swgl_OutRGBA8, NoColor()); int len =
(swgl_SpanLength); int drawn = 0; if (LinearFilter filter = needsTextureLinear
(sColor0, vUv, len)) { if (blend_key) { drawn = blendTextureLinear
<true>(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8
, filter); } else { drawn = blendTextureLinear<false>(sColor0
, vUv, len, uvBounds, packed_color, swgl_OutRGBA8, filter); }
} else if (blend_key) { drawn = blendTextureNearestFast<true
>(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8
); } else { drawn = blendTextureNearestFast<false>(sColor0
, vUv, len, uvBounds, packed_color, swgl_OutRGBA8); } swgl_OutRGBA8
+= drawn; swgl_SpanLength -= drawn; } while (0); } else { do
{ auto packed_color = packColor(swgl_OutRGBA8, NoColor()); int
drawn = 0; if (needsNearestFallback(sColor0, vUv, swgl_SpanLength
)) { if (blend_key) { drawn = blendTextureNearestRepeat<true
, false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds, packed_color
, swgl_OutRGBA8); } else { drawn = blendTextureNearestRepeat<
false, false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds
, packed_color, swgl_OutRGBA8); } } else if (blend_key) { drawn
= blendTextureNearestFast<true>(sColor0, vUv, swgl_SpanLength
, uvBounds, packed_color, swgl_OutRGBA8); } else { drawn = blendTextureNearestFast
<false>(sColor0, vUv, swgl_SpanLength, uvBounds, packed_color
, swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -=
drawn; } while (0); } } while (0)
;
181 }
182}
183typedef composite_FAST_PATH_TEXTURE_RECT_vert::InterpOutputs InterpInputs;
184InterpInputs interp_step;
185struct InterpPerspective {
186vec2 vUv;
187};
188InterpPerspective interp_perspective;
189static void read_interp_inputs(FragmentShaderImpl* impl, const void* init_, const void* step_) {Self* self = (Self*)impl;const InterpInputs* init = (const InterpInputs*)init_;const InterpInputs* step = (const InterpInputs*)step_;
190 self->vUv = init_interp(init->vUv, step->vUv);
191 self->interp_step.vUv = step->vUv * 4.0f;
192}
193static void read_perspective_inputs(FragmentShaderImpl* impl, const void* init_, const void* step_) {Self* self = (Self*)impl;const InterpInputs* init = (const InterpInputs*)init_;const InterpInputs* step = (const InterpInputs*)step_;
194 Float w = 1.0f / self->gl_FragCoord.w;
195 self->interp_perspective.vUv = init_interp(init->vUv, step->vUv);
196 self->vUv = self->interp_perspective.vUv * w;
197 self->interp_step.vUv = step->vUv * 4.0f;
198}
199ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
200 float chunks = steps * 0.25f;
201 vUv += interp_step.vUv * chunks;
202}
203ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
204 step_perspective(steps);
205 float chunks = steps * 0.25f;
206 Float w = 1.0f / gl_FragCoord.w;
207 interp_perspective.vUv += interp_step.vUv * chunks;
208 vUv = w * interp_perspective.vUv;
209}
210static void run(FragmentShaderImpl* impl) {
211 Self* self = (Self*)impl;
212 self->main();
213 self->step_interp_inputs();
214}
215static void skip(FragmentShaderImpl* impl, int steps) {
216 Self* self = (Self*)impl;
217 self->step_interp_inputs(steps);
218}
219static void run_perspective(FragmentShaderImpl* impl) {
220 Self* self = (Self*)impl;
221 self->main();
222 self->step_perspective_inputs();
223}
224static void skip_perspective(FragmentShaderImpl* impl, int steps) {
225 Self* self = (Self*)impl;
226 self->step_perspective_inputs(steps);
227}
228static int draw_span_RGBA8(FragmentShaderImpl* impl) {
229 Self* self = (Self*)impl; DISPATCH_DRAW_SPAN(self, RGBA8)do { int total = self->swgl_SpanLength; self->swgl_drawSpanRGBA8
(); int drawn = total - self->swgl_SpanLength; if (drawn) self
->step_interp_inputs(drawn); return drawn; } while (0)
; }
230public:
231composite_FAST_PATH_TEXTURE_RECT_frag() {
232 init_span_func = &read_interp_inputs;
233 run_func = &run;
234 skip_func = &skip;
235 draw_span_RGBA8_func = &draw_span_RGBA8;
236 enable_perspective();
237 init_span_w_func = &read_perspective_inputs;
238 run_w_func = &run_perspective;
239 skip_w_func = &skip_perspective;
240}
241};
242
243struct composite_FAST_PATH_TEXTURE_RECT_program : ProgramImpl, composite_FAST_PATH_TEXTURE_RECT_frag {
244int get_uniform(const char *name) const override {
245 if (strcmp("sColor0", name) == 0) { return 2; }
246 if (strcmp("uTransform", name) == 0) { return 1; }
247 return -1;
248}
249void bind_attrib(const char* name, int index) override {
250 attrib_locations.bind_loc(name, index);
251}
252int get_attrib(const char* name) const override {
253 return attrib_locations.get_loc(name);
254}
255size_t interpolants_size() const override { return sizeof(InterpOutputs); }
256VertexShaderImpl* get_vertex_shader() override {
257 return this;
258}
259FragmentShaderImpl* get_fragment_shader() override {
260 return this;
261}
262const char* get_name() const override { return "composite_FAST_PATH_TEXTURE_RECT"; }
263static ProgramImpl* loader() { return new composite_FAST_PATH_TEXTURE_RECT_program; }
264};
265