mirror of https://gitlab.freedesktop.org/mesa/mesa
util: import pipe_box and its helpers
We'll use them. There are also new helpers that we'll use. Reviewed-by: Yonggang Luo <luoyonggang@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28733>
This commit is contained in:
parent
959891e33f
commit
e5f133ccc4
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "util/u_box.h" /* FIXME: avoid include this */
|
||||
#include "util/box.h" /* FIXME: avoid include this */
|
||||
#include "v3d_tiling.h"
|
||||
#include "broadcom/common/v3d_cpu_tiling.h"
|
||||
|
||||
|
|
|
@ -211,7 +211,6 @@ files_libgallium = files(
|
|||
'util/u_blend.h',
|
||||
'util/u_blitter.c',
|
||||
'util/u_blitter.h',
|
||||
'util/u_box.h',
|
||||
'util/u_cache.c',
|
||||
'util/u_cache.h',
|
||||
'util/u_compute.c',
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "postprocess/pp_filters.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_sampler.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_memory.h"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "util/u_debug_describe.h"
|
||||
#include "util/u_debug_refcnt.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
#include "u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "u_surface.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "pipe/p_screen.h"
|
||||
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/format/u_format_zs.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
#include "lima_util.h"
|
||||
#include "lima_parser.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "util/u_memory.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
|
||||
struct r300_transfer {
|
||||
/* Parent class */
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
#include "virtio-gpu/virgl_protocol.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "util/format/u_format.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
#include "frontend/drisw_api.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "util/format/u_format.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/log.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "util/format/u_format.h"
|
||||
#include "util/u_surface.h"
|
||||
#include "util/u_sampler.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "pipe/p_state.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/format/u_formats.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
#define DBG_CHANNEL (DBG_INDEXBUFFER|DBG_VERTEXBUFFER)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/list.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
|
||||
struct pipe_screen;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "pipe/p_state.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/format/u_formats.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
|
||||
#define DBG_CHANNEL DBG_INDEXBUFFER
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "tgsi/tgsi_ureg.h"
|
||||
#include "tgsi/tgsi_dump.h"
|
||||
#include "util/bitscan.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_hash_table.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "util/u_atomic.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_simple_shaders.h"
|
||||
#include "util/u_gen_mipmap.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "pipe/p_state.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/format/u_formats.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
|
||||
#define DBG_CHANNEL DBG_VERTEXBUFFER
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#include "pipe/p_state.h"
|
||||
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "util/compiler.h"
|
||||
#include "p_defines.h"
|
||||
#include "util/format/u_formats.h"
|
||||
#include "util/box.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -547,23 +548,6 @@ struct pipe_image_view
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Subregion of 1D/2D/3D image resource.
|
||||
*/
|
||||
struct pipe_box
|
||||
{
|
||||
/* Only "x" and "width" are used to represent buffer ranges.
|
||||
* The maximum representable texture size is ANY x ANY x 16K.
|
||||
*/
|
||||
int32_t x;
|
||||
int32_t width;
|
||||
int32_t y;
|
||||
int32_t height;
|
||||
int16_t z;
|
||||
int16_t depth;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A memory object/resource such as a vertex buffer or texture.
|
||||
*/
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "state_tracker/st_texture.h"
|
||||
#include "state_tracker/st_util.h"
|
||||
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
#include "util/u_surface.h"
|
||||
#include "util/u_sampler.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_box.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_simple_shaders.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
#ifndef UTIL_BOX_INLINES_H
|
||||
#define UTIL_BOX_INLINES_H
|
||||
#ifndef UTIL_BOX_H
|
||||
#define UTIL_BOX_H
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/format/u_format.h"
|
||||
|
||||
/**
|
||||
* Subregion of 1D/2D/3D image resource.
|
||||
*/
|
||||
struct pipe_box
|
||||
{
|
||||
/* Only "x" and "width" are used to represent buffer ranges.
|
||||
* The maximum representable texture size is ANY x ANY x 16K.
|
||||
*/
|
||||
int32_t x;
|
||||
int32_t width;
|
||||
int32_t y;
|
||||
int32_t height;
|
||||
int16_t z;
|
||||
int16_t depth;
|
||||
};
|
||||
|
||||
static inline void
|
||||
u_box_1d(unsigned x, unsigned w, struct pipe_box *box)
|
||||
{
|
||||
|
@ -298,4 +313,47 @@ u_box_pixels_to_blocks(struct pipe_box *blocks,
|
|||
blocks);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
util_is_box_sint16(const struct pipe_box *box)
|
||||
{
|
||||
return util_is_sint16(box->x) && util_is_sint16(box->y) &&
|
||||
util_is_sint16(box->z) && util_is_sint16(box->width) &&
|
||||
util_is_sint16(box->height) && util_is_sint16(box->depth) &&
|
||||
util_is_sint16(box->x + box->width) &&
|
||||
util_is_sint16(box->y + box->height) &&
|
||||
util_is_sint16(box->z + box->depth);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
util_is_box_out_of_bounds(const struct pipe_box *src_box, unsigned coord_mask,
|
||||
unsigned width, unsigned height, unsigned mip_level)
|
||||
{
|
||||
int src_width = u_minify(width, mip_level);
|
||||
int src_height = u_minify(height, mip_level);
|
||||
struct pipe_box box = *src_box;
|
||||
|
||||
/* Eliminate negative width/height/depth. */
|
||||
if (box.width < 0) {
|
||||
box.x += box.width;
|
||||
box.width *= -1;
|
||||
}
|
||||
if (box.height < 0) {
|
||||
box.y += box.height;
|
||||
box.height *= -1;
|
||||
}
|
||||
|
||||
bool x_in_bounds = box.x >= 0 && box.x < src_width &&
|
||||
box.x + box.width > 0 && box.x + box.width <= src_width;
|
||||
bool y_in_bounds = box.y >= 0 && box.y < src_height &&
|
||||
box.y + box.height > 0 && box.y + box.height <= src_height;
|
||||
|
||||
/* Return if the box is not in bounds. */
|
||||
if (coord_mask & BITFIELD_BIT(0) && !x_in_bounds)
|
||||
return true;
|
||||
if (coord_mask & BITFIELD_BIT(1) && !y_in_bounds)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -39,6 +39,7 @@ files_mesa_util = files(
|
|||
'blend.h',
|
||||
'blob.c',
|
||||
'blob.h',
|
||||
'box.h',
|
||||
'build_id.c',
|
||||
'build_id.h',
|
||||
'cnd_monotonic.h',
|
||||
|
|
|
@ -819,6 +819,12 @@ util_is_aligned(uintmax_t n, uintmax_t a)
|
|||
return (n & (a - 1)) == 0;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
util_is_sint16(int x)
|
||||
{
|
||||
return x >= INT16_MIN && x <= INT16_MAX;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue