Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-63ae0a99caba1c8a/out/composite_TEXTURE_RECT.h
Warning:line 77, 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-63ae0a99caba1c8a/out -U MOZILLA_CONFIG_H -D _GLIBCXX_USE_CXX11_ABI=0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../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-07-30-004816-4182763-1 -x c++ src/gl.cc
1struct composite_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 aDeviceRect = NULL_ATTRIB16;
17 int aDeviceClipRect = NULL_ATTRIB16;
18 int aColor = NULL_ATTRIB16;
19 int aParams = NULL_ATTRIB16;
20 int aFlip = NULL_ATTRIB16;
21 int aUvRect0 = NULL_ATTRIB16;
22 void bind_loc(const char* name, int index) {
23 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
24 if (strcmp("aDeviceRect", name) == 0) { aDeviceRect = index; return; }
25 if (strcmp("aDeviceClipRect", name) == 0) { aDeviceClipRect = index; return; }
26 if (strcmp("aColor", name) == 0) { aColor = index; return; }
27 if (strcmp("aParams", name) == 0) { aParams = index; return; }
28 if (strcmp("aFlip", name) == 0) { aFlip = index; return; }
29 if (strcmp("aUvRect0", name) == 0) { aUvRect0 = index; return; }
30 }
31 int get_loc(const char* name) const {
32 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
33 if (strcmp("aDeviceRect", name) == 0) { return aDeviceRect != NULL_ATTRIB16 ? aDeviceRect : -1; }
34 if (strcmp("aDeviceClipRect", name) == 0) { return aDeviceClipRect != NULL_ATTRIB16 ? aDeviceClipRect : -1; }
35 if (strcmp("aColor", name) == 0) { return aColor != NULL_ATTRIB16 ? aColor : -1; }
36 if (strcmp("aParams", name) == 0) { return aParams != NULL_ATTRIB16 ? aParams : -1; }
37 if (strcmp("aFlip", name) == 0) { return aFlip != NULL_ATTRIB16 ? aFlip : -1; }
38 if (strcmp("aUvRect0", name) == 0) { return aUvRect0 != NULL_ATTRIB16 ? aUvRect0 : -1; }
39 return -1;
40 }
41} attrib_locations;
42vec4_scalar vColor;
43vec4_scalar vUVBounds;
44sampler2DRect sColor0;
45mat4_scalar uTransform;
46void bind_textures() {
47 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
48}
49};
50struct composite_TEXTURE_RECT_vert : VertexShaderImpl, composite_TEXTURE_RECT_common {
51private:
52typedef composite_TEXTURE_RECT_vert Self;
53// mat4_scalar uTransform;
54vec2 aPosition;
55// sampler2DRect sColor0;
56// sampler2DRect sColor1;
57// sampler2DRect sColor2;
58vec2 vUv;
59// vec4_scalar vColor;
60// vec4_scalar vUVBounds;
61vec4_scalar aDeviceRect;
62vec4_scalar aDeviceClipRect;
63vec4_scalar aColor;
64vec4_scalar aParams;
65vec2_scalar aFlip;
66vec4_scalar aUvRect0;
67ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
68 vec4_scalar device_rect = mix((aDeviceRect).sel(X,Y,Z,W), (aDeviceRect).sel(Z,W,X,Y), (aFlip).sel(X,Y,X,Y));
69 vec2 world_pos = mix((device_rect).sel(X,Y), (device_rect).sel(Z,W), (aPosition).sel(X,Y));
70 vec2 clipped_world_pos = clamp(world_pos, (aDeviceClipRect).sel(X,Y), (aDeviceClipRect).sel(Z,W));
71 vec2 uv = ((clipped_world_pos)-((device_rect).sel(X,Y)))/(((device_rect).sel(Z,W))-((device_rect).sel(X,Y)));
72 uv = mix((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W), uv);
73 vec4_scalar uvBounds = make_vec4(min((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W)), max((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W)));
74 int32_t rescale_uv = make_int((aParams).y);
75 if ((rescale_uv)==(1)) {
76 {
77 vec2_scalar texture_size = make_vec2(1.f, 1.f);
Value stored to 'texture_size' during its initialization is never read
78 uvBounds += make_vec4(0.5f, 0.5f, -(0.5f), -(0.5f));
79 }
80 }
81 vUv = uv;
82 vUVBounds = uvBounds;
83 vColor = aColor;
84 gl_Position = (uTransform)*(make_vec4(clipped_world_pos, 0.f, 1.f));
85}
86static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
87 Self* self = (Self*)impl;
88 if (self->samplers.set_slot(index, value)) return;
89 switch (index) {
90 case 2:
91 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
92 break;
93 case 1:
94 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
95 break;
96 }
97}
98static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
99 Self* self = (Self*)impl;
100 switch (index) {
101 case 2:
102 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
103 break;
104 case 1:
105 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
106 break;
107 }
108}
109static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
110 Self* self = (Self*)impl;
111 switch (index) {
112 case 2:
113 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
114 break;
115 case 1:
116 self->uTransform = mat4_scalar::load_from_ptr(value);
117 break;
118 }
119}
120static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
121 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
122 load_flat_attrib(self->aDeviceRect, attribs[self->attrib_locations.aDeviceRect], start, instance, count);
123 load_flat_attrib(self->aDeviceClipRect, attribs[self->attrib_locations.aDeviceClipRect], start, instance, count);
124 load_flat_attrib(self->aColor, attribs[self->attrib_locations.aColor], start, instance, count);
125 load_flat_attrib(self->aParams, attribs[self->attrib_locations.aParams], start, instance, count);
126 load_flat_attrib(self->aFlip, attribs[self->attrib_locations.aFlip], start, instance, count);
127 load_flat_attrib(self->aUvRect0, attribs[self->attrib_locations.aUvRect0], start, instance, count);
128}
129public:
130struct InterpOutputs {
131vec2_scalar vUv;
132};
133private:
134ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
135 for(int n = 0; n < 4; n++) {
136 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
137 dest->vUv = get_nth(vUv, n);
138 dest_ptr += stride;
139 }
140}
141static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
142 Self* self = (Self*)impl;
143 self->main();
144 self->store_interp_outputs(interps, interp_stride);
145}
146static void init_batch(VertexShaderImpl* impl) {
147 Self* self = (Self*)impl; self->bind_textures(); }
148public:
149composite_TEXTURE_RECT_vert() {
150 set_uniform_1i_func = &set_uniform_1i;
151 set_uniform_4fv_func = &set_uniform_4fv;
152 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
153 init_batch_func = &init_batch;
154 load_attribs_func = &load_attribs;
155 run_primitive_func = &run;
156}
157};
158
159
160struct composite_TEXTURE_RECT_frag : FragmentShaderImpl, composite_TEXTURE_RECT_vert {
161private:
162typedef composite_TEXTURE_RECT_frag Self;
163#define oFragColorgl_FragColor gl_FragColor
164// vec4 oFragColor;
165// sampler2DRect sColor0;
166// sampler2DRect sColor1;
167// sampler2DRect sColor2;
168vec2 vUv;
169// vec4_scalar vColor;
170// vec4_scalar vUVBounds;
171void write_output(vec4 color) {
172 oFragColorgl_FragColor = color;
173}
174ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
175 vec2 uv = clamp(vUv, (vUVBounds).sel(X,Y), (vUVBounds).sel(Z,W));
176 vec4 texel = texture(sColor0, (uv).sel(X,Y));
177 vec4 color = (vColor)*(texel);
178 write_output(color);
179}
180void swgl_drawSpanRGBA8() {
181 vec4_scalar color = vColor;
182 vec4_scalar uvBounds = vUVBounds;
183 if ((color)!=(make_vec4(1.f))) {
184 {
185 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)
;
186 }
187 } else {
188 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)
;
189 }
190}
191typedef composite_TEXTURE_RECT_vert::InterpOutputs InterpInputs;
192InterpInputs interp_step;
193struct InterpPerspective {
194vec2 vUv;
195};
196InterpPerspective interp_perspective;
197static 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_;
198 self->vUv = init_interp(init->vUv, step->vUv);
199 self->interp_step.vUv = step->vUv * 4.0f;
200}
201static 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_;
202 Float w = 1.0f / self->gl_FragCoord.w;
203 self->interp_perspective.vUv = init_interp(init->vUv, step->vUv);
204 self->vUv = self->interp_perspective.vUv * w;
205 self->interp_step.vUv = step->vUv * 4.0f;
206}
207ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
208 float chunks = steps * 0.25f;
209 vUv += interp_step.vUv * chunks;
210}
211ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
212 step_perspective(steps);
213 float chunks = steps * 0.25f;
214 Float w = 1.0f / gl_FragCoord.w;
215 interp_perspective.vUv += interp_step.vUv * chunks;
216 vUv = w * interp_perspective.vUv;
217}
218static void run(FragmentShaderImpl* impl) {
219 Self* self = (Self*)impl;
220 self->main();
221 self->step_interp_inputs();
222}
223static void skip(FragmentShaderImpl* impl, int steps) {
224 Self* self = (Self*)impl;
225 self->step_interp_inputs(steps);
226}
227static void run_perspective(FragmentShaderImpl* impl) {
228 Self* self = (Self*)impl;
229 self->main();
230 self->step_perspective_inputs();
231}
232static void skip_perspective(FragmentShaderImpl* impl, int steps) {
233 Self* self = (Self*)impl;
234 self->step_perspective_inputs(steps);
235}
236static int draw_span_RGBA8(FragmentShaderImpl* impl) {
237 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)
; }
238public:
239composite_TEXTURE_RECT_frag() {
240 init_span_func = &read_interp_inputs;
241 run_func = &run;
242 skip_func = &skip;
243 draw_span_RGBA8_func = &draw_span_RGBA8;
244 enable_perspective();
245 init_span_w_func = &read_perspective_inputs;
246 run_w_func = &run_perspective;
247 skip_w_func = &skip_perspective;
248}
249};
250
251struct composite_TEXTURE_RECT_program : ProgramImpl, composite_TEXTURE_RECT_frag {
252int get_uniform(const char *name) const override {
253 if (strcmp("sColor0", name) == 0) { return 2; }
254 if (strcmp("uTransform", name) == 0) { return 1; }
255 return -1;
256}
257void bind_attrib(const char* name, int index) override {
258 attrib_locations.bind_loc(name, index);
259}
260int get_attrib(const char* name) const override {
261 return attrib_locations.get_loc(name);
262}
263size_t interpolants_size() const override { return sizeof(InterpOutputs); }
264VertexShaderImpl* get_vertex_shader() override {
265 return this;
266}
267FragmentShaderImpl* get_fragment_shader() override {
268 return this;
269}
270const char* get_name() const override { return "composite_TEXTURE_RECT"; }
271static ProgramImpl* loader() { return new composite_TEXTURE_RECT_program; }
272};
273