Rev 4075 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4075 | Rev 5078 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0])) |
36 | #define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0])) |
37 | #endif /* ARRAY_SIZE */ |
37 | #endif /* ARRAY_SIZE */ |
Line 38... | Line 38... | ||
38 | 38 | ||
39 | #define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) |
39 | #define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) |
- | 40 | #define max_t(type, x, y) ((x) > (y) ? (x) : (y)) |
|
40 | #define max_t(type, x, y) ((x) > (y) ? (x) : (y)) |
41 | #define min_t(type, x, y) ((x) < (y) ? (x) : (y)) |
41 | #define surf_size_struct SVGA3dSize |
42 | #define surf_size_struct SVGA3dSize |
- | 43 | #define u32 uint32 |
|
- | 44 | #define u64 uint64_t |
|
Line 42... | Line 45... | ||
42 | #define u32 uint32 |
45 | #define U32_MAX ((u32)~0U) |
Line 43... | Line 46... | ||
43 | 46 | ||
Line 702... | Line 705... | ||
702 | {{{0}, {24}, {0}, {0} } } }, /* SVGA3D_Z_D24S8_INT */ |
705 | {{{0}, {24}, {0}, {0} } } }, /* SVGA3D_Z_D24S8_INT */ |
703 | }; |
706 | }; |
Line 704... | Line 707... | ||
704 | 707 | ||
705 | static inline u32 clamped_umul32(u32 a, u32 b) |
708 | static inline u32 clamped_umul32(u32 a, u32 b) |
706 | { |
709 | { |
707 | uint64_t tmp = (uint64_t) a*b; |
710 | u64 tmp = (u64) a*b; |
708 | return (tmp > (uint64_t) ((u32) -1)) ? (u32) -1 : tmp; |
711 | return (tmp > (u64) U32_MAX) ? U32_MAX : tmp; |
Line 709... | Line 712... | ||
709 | } |
712 | } |
710 | 713 | ||
711 | static inline const struct svga3d_surface_desc * |
714 | static inline const struct svga3d_surface_desc * |
Line 832... | Line 835... | ||
832 | surf_size_struct base_level_size, |
835 | surf_size_struct base_level_size, |
833 | u32 num_mip_levels, |
836 | u32 num_mip_levels, |
834 | bool cubemap) |
837 | bool cubemap) |
835 | { |
838 | { |
836 | const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format); |
839 | const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format); |
837 | u32 total_size = 0; |
840 | u64 total_size = 0; |
838 | u32 mip; |
841 | u32 mip; |
Line 839... | Line 842... | ||
839 | 842 | ||
840 | for (mip = 0; mip < num_mip_levels; mip++) { |
843 | for (mip = 0; mip < num_mip_levels; mip++) { |
841 | surf_size_struct size = |
844 | surf_size_struct size = |
Line 845... | Line 848... | ||
845 | } |
848 | } |
Line 846... | Line 849... | ||
846 | 849 | ||
847 | if (cubemap) |
850 | if (cubemap) |
Line 848... | Line 851... | ||
848 | total_size *= SVGA3D_MAX_SURFACE_FACES; |
851 | total_size *= SVGA3D_MAX_SURFACE_FACES; |
849 | 852 | ||
Line 850... | Line 853... | ||
850 | return total_size; |
853 | return (u32) min_t(u64, total_size, (u64) U32_MAX); |
851 | } |
854 | } |