panfrost: Don't lose bits!
UBSAN complained that when alpha was 255 and we shifted it 24 positions
to the left, it didn't fit in a signed int. That's because bitwise
operations automatically promote to signed int.
../src/gallium/drivers/panfrost/pan_job.c:1130:64: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'"}
#0 0xacf953d6 in pan_pack_color ../src/gallium/drivers/panfrost/pan_job.c:1130"}
#1 0xacf953d6 in panfrost_batch_clear ../src/gallium/drivers/panfrost/pan_job.c:1204"}
#2 0xaae3226a in st_Clear ../src/mesa/state_tracker/st_cb_clear.c:513"}
#3 0x4c3d0e in deqp::gles2::TestCaseWrapper::iterate(tcu::TestCase*) (/deqp/modules/gles2/deqp-gles2+0x2ad0e)"}
#4 0x828cf2 in tcu::TestSessionExecutor::iterateTestCase(tcu::TestCase*) (/deqp/modules/gles2/deqp-gles2+0x38fcf2)"}
#5 0x8295f0 in tcu::TestSessionExecutor::iterate() (/deqp/modules/gles2/deqp-gles2+0x3905f0)"}
#6 0x810aac in tcu::App::iterate() (/deqp/modules/gles2/deqp-gles2+0x377aac)"}
#7 0x4c1d4c in main (/deqp/modules/gles2/deqp-gles2+0x28d4c)"}
#8 0xb64b6aa8 in __libc_start_main (/lib/arm-linux-gnueabihf/libc.so.6+0x1aaa8)"}
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
@@ -1134,10 +1134,10 @@ pan_pack_color(uint32_t *packed, const union pipe_color_union *color, enum pipe_
|
||||
|
||||
if (util_format_is_rgba8_variant(desc)) {
|
||||
pan_pack_color_32(packed,
|
||||
(float_to_ubyte(clear_alpha) << 24) |
|
||||
(float_to_ubyte(color->f[2]) << 16) |
|
||||
(float_to_ubyte(color->f[1]) << 8) |
|
||||
(float_to_ubyte(color->f[0]) << 0));
|
||||
((uint32_t) float_to_ubyte(clear_alpha) << 24) |
|
||||
((uint32_t) float_to_ubyte(color->f[2]) << 16) |
|
||||
((uint32_t) float_to_ubyte(color->f[1]) << 8) |
|
||||
((uint32_t) float_to_ubyte(color->f[0]) << 0));
|
||||
} else if (format == PIPE_FORMAT_B5G6R5_UNORM) {
|
||||
/* First, we convert the components to R5, G6, B5 separately */
|
||||
unsigned r5 = CLAMP(color->f[0], 0.0, 1.0) * 31.0;
|
||||
|
||||
Reference in New Issue
Block a user