gallium: use u_box_3d to initialize pipe_box instead of non-designated initializers
This is the original utility for initializing pipe_box. It prevents breakage when pipe_box fields are reordered. Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27953>
This commit is contained in:
@@ -594,7 +594,8 @@ vl_mpeg12_begin_frame(struct pipe_video_codec *decoder,
|
||||
struct vl_mpeg12_buffer *buf;
|
||||
|
||||
struct pipe_resource *tex;
|
||||
struct pipe_box rect = { 0, 0, 0, 1, 1, 1 };
|
||||
struct pipe_box rect;
|
||||
u_box_3d(0, 0, 0, 1, 1, 1, &rect);
|
||||
|
||||
uint8_t intra_matrix[64];
|
||||
uint8_t non_intra_matrix[64];
|
||||
|
@@ -314,13 +314,11 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
|
||||
unsigned x, y, i, pitch;
|
||||
float *f;
|
||||
|
||||
struct pipe_box rect =
|
||||
{
|
||||
0, 0, 0,
|
||||
VL_BLOCK_WIDTH * blocks_per_line,
|
||||
VL_BLOCK_HEIGHT,
|
||||
1
|
||||
};
|
||||
struct pipe_box rect;
|
||||
u_box_3d(0, 0, 0,
|
||||
VL_BLOCK_WIDTH * blocks_per_line,
|
||||
VL_BLOCK_HEIGHT,
|
||||
1, &rect);
|
||||
|
||||
assert(pipe && layout && blocks_per_line);
|
||||
|
||||
@@ -496,13 +494,11 @@ vl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
|
||||
unsigned x, y, i, pitch;
|
||||
uint8_t *data;
|
||||
|
||||
struct pipe_box rect =
|
||||
{
|
||||
0, 0, intra ? 1 : 0,
|
||||
VL_BLOCK_WIDTH,
|
||||
VL_BLOCK_HEIGHT,
|
||||
1
|
||||
};
|
||||
struct pipe_box rect;
|
||||
u_box_3d(0, 0, intra ? 1 : 0,
|
||||
VL_BLOCK_WIDTH,
|
||||
VL_BLOCK_HEIGHT,
|
||||
1, &rect);
|
||||
|
||||
assert(buffer);
|
||||
assert(matrix);
|
||||
|
@@ -1309,7 +1309,8 @@ update_dispatch_indirect_with_sysvals(struct d3d12_context *ctx,
|
||||
output_buf_templ.usage = PIPE_USAGE_DEFAULT;
|
||||
*indirect_out = ctx->base.screen->resource_create(ctx->base.screen, &output_buf_templ);
|
||||
|
||||
struct pipe_box src_box = { (int)*indirect_offset_inout, 0, 0, sizeof(uint32_t) * 3, 1, 1 };
|
||||
struct pipe_box src_box;
|
||||
u_box_3d((int)*indirect_offset_inout, 0, 0, sizeof(uint32_t) * 3, 1, 1, &src_box);
|
||||
ctx->base.resource_copy_region(&ctx->base, *indirect_out, 0, 0, 0, 0, indirect_in, 0, &src_box);
|
||||
ctx->base.resource_copy_region(&ctx->base, *indirect_out, 0, src_box.width, 0, 0, indirect_in, 0, &src_box);
|
||||
|
||||
|
@@ -1313,7 +1313,8 @@ transfer_image_to_buf(struct d3d12_context *ctx,
|
||||
tmpl.nr_samples = 0;
|
||||
resolved_resource = d3d12_resource_create(ctx->base.screen, &tmpl);
|
||||
struct pipe_blit_info resolve_info = {};
|
||||
struct pipe_box box = {0,0,0, (int)res->base.b.width0, (int16_t)res->base.b.height0, (int16_t)res->base.b.depth0};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0,0,0, (int)res->base.b.width0, (int16_t)res->base.b.height0, (int16_t)res->base.b.depth0, &box);
|
||||
resolve_info.dst.resource = resolved_resource;
|
||||
resolve_info.dst.box = box;
|
||||
resolve_info.dst.format = res->base.b.format;
|
||||
|
@@ -705,13 +705,14 @@ d3d12_video_decoder_end_frame(struct pipe_video_codec *codec,
|
||||
// Copy all format subresources/texture planes
|
||||
for (PlaneSlice = 0; PlaneSlice < pD3D12Dec->m_decodeFormatInfo.PlaneCount; PlaneSlice++) {
|
||||
assert(d3d12OutputArguments.OutputSubresource < INT16_MAX);
|
||||
struct pipe_box box = { 0,
|
||||
0,
|
||||
// src array slice, taken as Z for TEXTURE_2D_ARRAY
|
||||
static_cast<int16_t>(d3d12OutputArguments.OutputSubresource),
|
||||
static_cast<int>(pPipeDstViews[PlaneSlice]->texture->width0),
|
||||
static_cast<int16_t>(pPipeDstViews[PlaneSlice]->texture->height0),
|
||||
1 };
|
||||
struct pipe_box box;
|
||||
u_box_3d(0,
|
||||
0,
|
||||
// src array slice, taken as Z for TEXTURE_2D_ARRAY
|
||||
static_cast<int16_t>(d3d12OutputArguments.OutputSubresource),
|
||||
static_cast<int>(pPipeDstViews[PlaneSlice]->texture->width0),
|
||||
static_cast<int16_t>(pPipeDstViews[PlaneSlice]->texture->height0),
|
||||
1, &box);
|
||||
|
||||
pD3D12Dec->base.context->resource_copy_region(pD3D12Dec->base.context,
|
||||
pPipeDstViews[PlaneSlice]->texture, // dst
|
||||
|
@@ -2510,14 +2510,14 @@ d3d12_video_encoder_extract_encode_metadata(
|
||||
d3d12_resource_from_resource(&pD3D12Screen->base, pResolvedMetadataBuffer);
|
||||
assert(pPipeResolvedMetadataBuffer);
|
||||
assert(resourceMetadataSize < INT_MAX);
|
||||
struct pipe_box box = {
|
||||
0, // x
|
||||
0, // y
|
||||
0, // z
|
||||
static_cast<int>(resourceMetadataSize), // width
|
||||
1, // height
|
||||
1 // depth
|
||||
};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, // x
|
||||
0, // y
|
||||
0, // z
|
||||
static_cast<int>(resourceMetadataSize), // width
|
||||
1, // height
|
||||
1, // depth
|
||||
&box);
|
||||
struct pipe_transfer *mapTransfer;
|
||||
unsigned mapUsage = PIPE_MAP_READ;
|
||||
void * pMetadataBufferSrc = pD3D12Enc->base.context->buffer_map(pD3D12Enc->base.context,
|
||||
|
@@ -2147,14 +2147,14 @@ d3d12_video_encoder_build_post_encode_codec_bitstream_av1(struct d3d12_video_enc
|
||||
pipe_resource *pPipeResolvedMetadataBuffer =
|
||||
d3d12_resource_from_resource(&pD3D12Screen->base, pResolvedMetadataBuffer);
|
||||
assert(resourceMetadataSize < INT_MAX);
|
||||
struct pipe_box box = {
|
||||
0, // x
|
||||
0, // y
|
||||
0, // z
|
||||
static_cast<int>(resourceMetadataSize), // width
|
||||
1, // height
|
||||
1 // depth
|
||||
};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, // x
|
||||
0, // y
|
||||
0, // z
|
||||
static_cast<int>(resourceMetadataSize), // width
|
||||
1, // height
|
||||
1, // depth
|
||||
&box);
|
||||
struct pipe_transfer *mapTransferMetadata;
|
||||
uint8_t *pMetadataBufferSrc =
|
||||
reinterpret_cast<uint8_t *>(pD3D12Enc->base.context->buffer_map(pD3D12Enc->base.context,
|
||||
@@ -2859,14 +2859,14 @@ upload_tile_group_obu(struct d3d12_video_encoder *pD3D12Enc,
|
||||
|
||||
// Now copy the decode_tile() element from the driver staging GPU buffer onto the finalized GPU buffer
|
||||
|
||||
struct pipe_box src_box = {
|
||||
static_cast<int>(src_buf_tile_position), // x
|
||||
0, // y
|
||||
0, // z
|
||||
static_cast<int>(tile_size), // width
|
||||
1, // height
|
||||
1 // depth
|
||||
};
|
||||
struct pipe_box src_box;
|
||||
u_box_3d(static_cast<int>(src_buf_tile_position), // x
|
||||
0, // y
|
||||
0, // z
|
||||
static_cast<int>(tile_size), // width
|
||||
1, // height
|
||||
1, // depth
|
||||
&src_box);
|
||||
|
||||
pD3D12Enc->base.context->resource_copy_region(pD3D12Enc->base.context, // ctx
|
||||
comp_bit_destination, // dst
|
||||
|
@@ -4518,7 +4518,8 @@ zink_copy_buffer(struct zink_context *ctx, struct zink_resource *dst, struct zin
|
||||
|
||||
struct zink_batch *batch = &ctx->batch;
|
||||
|
||||
struct pipe_box box = {(int)src_offset, 0, 0, (int)size, 0, 0};
|
||||
struct pipe_box box;
|
||||
u_box_3d((int)src_offset, 0, 0, (int)size, 0, 0, &box);
|
||||
/* must barrier if something wrote the valid buffer range */
|
||||
bool valid_write = zink_check_valid_buffer_src_access(ctx, src, src_offset, size);
|
||||
bool unordered_src = !valid_write && !zink_check_unordered_transfer_access(src, 0, &box);
|
||||
|
@@ -1012,7 +1012,8 @@ zink_kopper_readback_update(struct zink_context *ctx, struct zink_resource *res)
|
||||
struct kopper_swapchain *cswap = cdt->swapchain;
|
||||
assert(res->obj->dt_idx != UINT32_MAX);
|
||||
struct pipe_resource *readback = cswap->images[res->obj->dt_idx].readback;
|
||||
struct pipe_box box = {0, 0, 0, res->base.b.width0, res->base.b.height0, res->base.b.depth0};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, 0, 0, res->base.b.width0, res->base.b.height0, res->base.b.depth0, &box);
|
||||
|
||||
if (cswap->images[res->obj->dt_idx].readback_needs_update && readback)
|
||||
ctx->base.resource_copy_region(&ctx->base, readback, 0, 0, 0, 0, &res->base.b, 0, &box);
|
||||
|
@@ -1754,9 +1754,10 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
|
||||
res->obj = new_obj;
|
||||
res->queue = VK_QUEUE_FAMILY_IGNORED;
|
||||
for (unsigned i = 0; i <= res->base.b.last_level; i++) {
|
||||
struct pipe_box box = {0, 0, 0,
|
||||
u_minify(res->base.b.width0, i),
|
||||
u_minify(res->base.b.height0, i), res->base.b.array_size};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, 0, 0,
|
||||
u_minify(res->base.b.width0, i),
|
||||
u_minify(res->base.b.height0, i), res->base.b.array_size, &box);
|
||||
box.depth = util_num_layers(&res->base.b, i);
|
||||
ctx->base.resource_copy_region(&ctx->base, &res->base.b, i, 0, 0, 0, &staging.base.b, i, &box);
|
||||
}
|
||||
@@ -2113,7 +2114,8 @@ invalidate_buffer(struct zink_context *ctx, struct zink_resource *res)
|
||||
if (res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE)
|
||||
return false;
|
||||
|
||||
struct pipe_box box = {0, 0, 0, res->base.b.width0, 0, 0};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, 0, 0, res->base.b.width0, 0, 0, &box);
|
||||
if (res->valid_buffer_range.start > res->valid_buffer_range.end &&
|
||||
!zink_resource_copy_box_intersects(res, 0, &box))
|
||||
return false;
|
||||
|
@@ -615,7 +615,8 @@ zink_resource_buffer_transfer_dst_barrier(struct zink_context *ctx, struct zink_
|
||||
if (res->obj->copies_need_reset)
|
||||
zink_resource_copies_reset(res);
|
||||
bool unordered = true;
|
||||
struct pipe_box box = {(int)offset, 0, 0, (int)size, 0, 0};
|
||||
struct pipe_box box;
|
||||
u_box_3d((int)offset, 0, 0, (int)size, 0, 0, &box);
|
||||
bool can_unordered_write = unordered_res_exec(ctx, res, true);
|
||||
/* must barrier if something read the valid buffer range */
|
||||
bool valid_read = (res->obj->access || res->obj->unordered_access) &&
|
||||
|
@@ -135,7 +135,8 @@ void vid_dec_FillOutput(vid_dec_PrivateType *priv, struct pipe_video_buffer *buf
|
||||
pipe_format_to_chroma_format(buf->buffer_format),
|
||||
buf->interlaced);
|
||||
for (j = 0; j < views[i]->texture->array_size; ++j) {
|
||||
struct pipe_box box = {0, 0, j, width, height, 1};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, 0, j, width, height, 1, &box);
|
||||
struct pipe_transfer *transfer;
|
||||
uint8_t *map, *dst;
|
||||
map = priv->pipe->texture_map(priv->pipe, views[i]->texture, 0,
|
||||
|
@@ -600,7 +600,8 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y,
|
||||
pipe_format_to_chroma_format(surf->templat.buffer_format),
|
||||
surf->templat.interlaced);
|
||||
for (j = 0; j < view_resources[i]->array_size; ++j) {
|
||||
struct pipe_box box = {box_x, box_y, j, box_w, box_h, 1};
|
||||
struct pipe_box box;
|
||||
u_box_3d(box_x, box_y, j, box_w, box_h, 1, &box);
|
||||
struct pipe_transfer *transfer;
|
||||
uint8_t *map;
|
||||
map = drv->pipe->texture_map(drv->pipe, view_resources[i], 0,
|
||||
@@ -727,7 +728,8 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image,
|
||||
|
||||
vlVaVideoSurfaceSize(surf, i, &width, &height);
|
||||
for (j = 0; j < tex->array_size; ++j) {
|
||||
struct pipe_box dst_box = {0, 0, j, width, height, 1};
|
||||
struct pipe_box dst_box;
|
||||
u_box_3d(0, 0, j, width, height, 1, &dst_box);
|
||||
|
||||
if (((format == PIPE_FORMAT_YV12) || (format == PIPE_FORMAT_IYUV))
|
||||
&& (surf->buffer->buffer_format == PIPE_FORMAT_NV12)
|
||||
|
@@ -497,10 +497,9 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
|
||||
struct pipe_sampler_view *sv = sampler_views[i];
|
||||
if (!sv) continue;
|
||||
|
||||
struct pipe_box dst_box = {
|
||||
0, 0, 0,
|
||||
sv->texture->width0, sv->texture->height0, 1
|
||||
};
|
||||
struct pipe_box dst_box;
|
||||
u_box_3d(0, 0, 0,
|
||||
sv->texture->width0, sv->texture->height0, 1, &dst_box);
|
||||
|
||||
pipe->texture_subdata(pipe, sv->texture, 0, PIPE_MAP_WRITE, &dst_box,
|
||||
source_data[i], source_pitches[i], 0);
|
||||
|
@@ -253,10 +253,8 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
|
||||
vlVdpVideoSurfaceSize(vlsurface, i, &width, &height);
|
||||
|
||||
for (j = 0; j < sv->texture->array_size; ++j) {
|
||||
struct pipe_box box = {
|
||||
0, 0, j,
|
||||
width, height, 1
|
||||
};
|
||||
struct pipe_box box;
|
||||
u_box_3d(0, 0, j, width, height, 1, &box);
|
||||
struct pipe_transfer *transfer;
|
||||
uint8_t *map;
|
||||
|
||||
@@ -391,10 +389,8 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
|
||||
vlVdpVideoSurfaceSize(p_surf, i, &width, &height);
|
||||
|
||||
for (j = 0; j < tex->array_size; ++j) {
|
||||
struct pipe_box dst_box = {
|
||||
0, 0, j,
|
||||
width, height, 1
|
||||
};
|
||||
struct pipe_box dst_box;
|
||||
u_box_3d(0, 0, j, width, height, 1, &dst_box);
|
||||
|
||||
if (conversion == CONVERSION_YV12_TO_NV12 && i == 1) {
|
||||
struct pipe_transfer *transfer;
|
||||
|
Reference in New Issue
Block a user