swr: Correct texture allocation and limit max size to 2GB
authorBruce Cherniak <bruce.cherniak@intel.com>
Mon, 20 Nov 2017 17:32:55 +0000 (11:32 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 13 Dec 2017 20:44:04 +0000 (14:44 -0600)
commitea2ee9cd199f598c7f3b28e2bd61ad299199a587
treea9af7a9de741b6910ccd2751296a29af9dec7080
parent709f5bdc4a2bf31f422f5cf60797224c0463c10a
swr: Correct texture allocation and limit max size to 2GB

This patch fixes piglit tex3d-maxsize by correcting 4 things:

The total_size calculation was using 32-bit math, therefore a >4GB
allocation request overflowed and was not returning false (unsupported).

Changed AlignedMalloc arguments from "unsigned int" to size_t, to handle
>4GB allocations.

Added error checking on texture allocations to fail gracefully.

Finally, temporarily decreased supported max texture size from 4GB to 2GB.
The gallivm texture-sampler needs some additional work to correctly handle
larger than 2GB textures (offsets to LLVMBuildGEP are signed).

I'm working on a follow-on patch to allow up to 4GB textures, as this is
useful in HPC visualization applications.

Fixes piglit tex3d-maxsize.

v2: Updated patch description to clarify ">4GB".

Reviewed-By: George Kyriazis <george.kyriazis@intel.com>
src/gallium/drivers/swr/rasterizer/common/os.h
src/gallium/drivers/swr/swr_screen.cpp