if (src->dxgi_format != dst->dxgi_format)
return false;
- if (util_format_is_pure_integer(src->base.format))
+ if (util_format_is_pure_integer(src->base.b.format))
return false;
// sizes needs to match
d3d12_batch_reference_resource(batch, src);
d3d12_batch_reference_resource(batch, dst);
- DXGI_FORMAT dxgi_format = d3d12_get_resource_srv_format(src->base.format, src->base.target);
+ DXGI_FORMAT dxgi_format = d3d12_get_resource_srv_format(src->base.b.format, src->base.b.target);
assert(src->dxgi_format == dst->dxgi_format);
ctx->cmdlist->ResolveSubresource(
D3D12_TEXTURE_COPY_LOCATION src_loc, dst_loc;
unsigned src_z = psrc_box->z;
- int src_subres_stride = src->base.last_level + 1;
- int dst_subres_stride = dst->base.last_level + 1;
+ int src_subres_stride = src->base.b.last_level + 1;
+ int dst_subres_stride = dst->base.b.last_level + 1;
- int src_array_size = src->base.array_size;
- int dst_array_size = dst->base.array_size;
+ int src_array_size = src->base.b.array_size;
+ int dst_array_size = dst->base.b.array_size;
- if (dst->base.target == PIPE_TEXTURE_CUBE)
+ if (dst->base.b.target == PIPE_TEXTURE_CUBE)
dst_array_size *= 6;
- if (src->base.target == PIPE_TEXTURE_CUBE)
+ if (src->base.b.target == PIPE_TEXTURE_CUBE)
src_array_size *= 6;
int stencil_src_res_offset = 1;
int src_nres = 1;
int dst_nres = 1;
- if (dst->base.format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
- dst->base.format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
- dst->base.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+ if (dst->base.b.format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
+ dst->base.b.format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
+ dst->base.b.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
stencil_dst_res_offset = dst_subres_stride * dst_array_size;
src_nres = 2;
}
- if (src->base.format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
- src->base.format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
- dst->base.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+ if (src->base.b.format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
+ src->base.b.format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
+ dst->base.b.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
stencil_src_res_offset = src_subres_stride * src_array_size;
dst_nres = 2;
}
continue;
src_loc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
- src_loc.SubresourceIndex = get_subresource_id(src->base.target, src_level, src_subres_stride, src_z, &src_z) +
+ src_loc.SubresourceIndex = get_subresource_id(src->base.b.target, src_level, src_subres_stride, src_z, &src_z) +
subres * stencil_src_res_offset;
src_loc.pResource = d3d12_resource_resource(src);
dst_loc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
- dst_loc.SubresourceIndex = get_subresource_id(dst->base.target, dst_level, dst_subres_stride, dstz, &dstz) +
+ dst_loc.SubresourceIndex = get_subresource_id(dst->base.b.target, dst_level, dst_subres_stride, dstz, &dstz) +
subres * stencil_dst_res_offset;
dst_loc.pResource = d3d12_resource_resource(dst);
if (psrc_box->x == 0 && psrc_box->y == 0 && psrc_box->z == 0 &&
- psrc_box->width == (int)u_minify(src->base.width0, src_level) &&
- psrc_box->height == (int)u_minify(src->base.height0, src_level) &&
- psrc_box->depth == (int)u_minify(src->base.depth0, src_level)) {
+ psrc_box->width == (int)u_minify(src->base.b.width0, src_level) &&
+ psrc_box->height == (int)u_minify(src->base.b.height0, src_level) &&
+ psrc_box->depth == (int)u_minify(src->base.b.depth0, src_level)) {
assert((dstx == 0 && dsty == 0 && dstz == 0) ||
screen->opts2.ProgrammableSamplePositionsTier !=
D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED ||
- (!util_format_is_depth_or_stencil(dst->base.format) &&
- !util_format_is_depth_or_stencil(src->base.format) &&
- dst->base.nr_samples <= 1 &&
- src->base.nr_samples <= 1));
+ (!util_format_is_depth_or_stencil(dst->base.b.format) &&
+ !util_format_is_depth_or_stencil(src->base.b.format) &&
+ dst->base.b.nr_samples <= 1 &&
+ src->base.b.nr_samples <= 1));
ctx->cmdlist->CopyTextureRegion(&dst_loc, dstx, dsty, dstz,
&src_loc, NULL);
} else {
D3D12_BOX src_box;
src_box.left = psrc_box->x;
- src_box.right = MIN2(psrc_box->x + psrc_box->width, (int)u_minify(src->base.width0, src_level));
+ src_box.right = MIN2(psrc_box->x + psrc_box->width, (int)u_minify(src->base.b.width0, src_level));
src_box.top = psrc_box->y;
- src_box.bottom = MIN2(psrc_box->y + psrc_box->height, (int)u_minify(src->base.height0, src_level));
+ src_box.bottom = MIN2(psrc_box->y + psrc_box->height, (int)u_minify(src->base.b.height0, src_level));
src_box.front = src_z;
src_box.back = src_z + psrc_box->depth;
assert((screen->opts2.ProgrammableSamplePositionsTier !=
D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED ||
- (!util_format_is_depth_or_stencil(dst->base.format) &&
- !util_format_is_depth_or_stencil(src->base.format))) &&
- dst->base.nr_samples <= 1 &&
- src->base.nr_samples <= 1);
+ (!util_format_is_depth_or_stencil(dst->base.b.format) &&
+ !util_format_is_depth_or_stencil(src->base.b.format))) &&
+ dst->base.b.nr_samples <= 1 &&
+ src->base.b.nr_samples <= 1);
ctx->cmdlist->CopyTextureRegion(&dst_loc, dstx, dsty, dstz,
&src_loc, &src_box);
{
if (D3D12_DEBUG_BLIT & d3d12_debug) {
debug_printf("D3D12 BLIT as COPY: from %s@%d %dx%dx%d + %dx%dx%d\n",
- util_format_name(src->base.format), src_level,
+ util_format_name(src->base.b.format), src_level,
psrc_box->x, psrc_box->y, psrc_box->z,
psrc_box->width, psrc_box->height, psrc_box->depth);
debug_printf(" to %s@%d %dx%dx%d\n",
- util_format_name(dst->base.format), dst_level,
+ util_format_name(dst->base.b.format), dst_level,
pdst_box->x, pdst_box->y, pdst_box->z);
}
{
struct d3d12_batch *batch = d3d12_current_batch(ctx);
- unsigned src_subres = get_subresource_id(src->base.target, src_level, src->base.last_level + 1,
+ unsigned src_subres = get_subresource_id(src->base.b.target, src_level, src->base.b.last_level + 1,
psrc_box->z, nullptr);
- unsigned dst_subres = get_subresource_id(dst->base.target, dst_level, dst->base.last_level + 1,
+ unsigned dst_subres = get_subresource_id(dst->base.b.target, dst_level, dst->base.b.last_level + 1,
pdst_box->z, nullptr);
if (D3D12_DEBUG_BLIT & d3d12_debug)
src_subres, dst_subres);
d3d12_transition_subresources_state(ctx, src, src_subres, 1, 0, 1,
- d3d12_get_format_start_plane(src->base.format),
- d3d12_get_format_num_planes(src->base.format),
+ d3d12_get_format_start_plane(src->base.b.format),
+ d3d12_get_format_num_planes(src->base.b.format),
D3D12_RESOURCE_STATE_COPY_SOURCE,
D3D12_BIND_INVALIDATE_FULL);
d3d12_transition_subresources_state(ctx, dst, dst_subres, 1, 0, 1,
- d3d12_get_format_start_plane(dst->base.format),
- d3d12_get_format_num_planes(dst->base.format),
+ d3d12_get_format_start_plane(dst->base.b.format),
+ d3d12_get_format_num_planes(dst->base.b.format),
D3D12_RESOURCE_STATE_COPY_DEST,
D3D12_BIND_INVALIDATE_FULL);
d3d12_batch_reference_resource(batch, src);
d3d12_batch_reference_resource(batch, dst);
- if (src->base.target == PIPE_BUFFER) {
+ if (src->base.b.target == PIPE_BUFFER) {
copy_buffer_region_no_barriers(ctx, dst, pdst_box->x,
src, psrc_box->x, psrc_box->width);
} else if (psrc_box->height == pdst_box->height) {
abs(src_box->width), abs(src_box->height), abs(src_box->depth),
©_src);
- templ.format = src->base.format;
+ templ.format = src->base.b.format;
templ.width0 = copy_src.width;
templ.height0 = copy_src.height;
templ.depth0 = copy_src.depth;
templ.nr_storage_samples = 1;
templ.usage = PIPE_USAGE_STAGING;
templ.bind = util_format_is_depth_or_stencil(templ.format) ? PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET;
- templ.target = src->base.target;
+ templ.target = src->base.b.target;
staging_res = ctx->base.screen->resource_create(ctx->base.screen, &templ);
static void
init_valid_range(struct d3d12_resource *res)
{
- if (can_map_directly(&res->base))
+ if (can_map_directly(&res->base.b))
util_range_init(&res->valid_buffer_range);
}
struct pipe_resource *presource)
{
struct d3d12_resource *resource = d3d12_resource(presource);
+ threaded_resource_deinit(presource);
if (can_map_directly(presource))
util_range_destroy(&resource->valid_buffer_range);
if (resource->bo)
if (screen->winsys && (templ->bind & PIPE_BIND_DISPLAY_TARGET)) {
struct sw_winsys *winsys = screen->winsys;
res->dt = winsys->displaytarget_create(screen->winsys,
- res->base.bind,
- res->base.format,
+ res->base.b.bind,
+ res->base.b.format,
templ->width0,
templ->height0,
64, NULL,
struct d3d12_resource *res = CALLOC_STRUCT(d3d12_resource);
bool ret;
- res->base = *templ;
+ res->base.b = *templ;
if (D3D12_DEBUG_RESOURCE & d3d12_debug) {
debug_printf("D3D12: Create %sresource %s@%d %dx%dx%d as:%d mip:%d\n",
templ->array_size, templ->last_level);
}
- pipe_reference_init(&res->base.reference, 1);
- res->base.screen = pscreen;
+ pipe_reference_init(&res->base.b.reference, 1);
+ res->base.b.screen = pscreen;
if (templ->target == PIPE_BUFFER) {
ret = init_buffer(screen, res, templ);
}
init_valid_range(res);
+ threaded_resource_init(&res->base.b, false, 0);
memset(&res->bind_counts, 0, sizeof(d3d12_resource::bind_counts));
- return &res->base;
+ return &res->base.b;
}
static struct pipe_resource *
if (!res)
return NULL;
- res->base = *templ;
- pipe_reference_init(&res->base.reference, 1);
- res->base.screen = pscreen;
+ res->base.b = *templ;
+ pipe_reference_init(&res->base.b.reference, 1);
+ res->base.b.screen = pscreen;
res->dxgi_format = templ->target == PIPE_BUFFER ? DXGI_FORMAT_UNKNOWN :
d3d12_get_format(templ->format);
res->bo = d3d12_bo_wrap_res((ID3D12Resource *)handle->com_obj, templ->format);
init_valid_range(res);
- return &res->base;
+ threaded_resource_init(&res->base.b, false, 0);
+ return &res->base.b;
}
static bool
get_subresource_id(struct d3d12_resource *res, unsigned resid,
unsigned z, unsigned base_level)
{
- unsigned resource_stride = res->base.last_level + 1;
- if (res->base.target == PIPE_TEXTURE_1D_ARRAY ||
- res->base.target == PIPE_TEXTURE_2D_ARRAY)
- resource_stride *= res->base.array_size;
+ unsigned resource_stride = res->base.b.last_level + 1;
+ if (res->base.b.target == PIPE_TEXTURE_1D_ARRAY ||
+ res->base.b.target == PIPE_TEXTURE_2D_ARRAY)
+ resource_stride *= res->base.b.array_size;
- if (res->base.target == PIPE_TEXTURE_CUBE)
+ if (res->base.b.target == PIPE_TEXTURE_CUBE)
resource_stride *= 6;
- if (res->base.target == PIPE_TEXTURE_CUBE_ARRAY)
- resource_stride *= 6 * res->base.array_size;
+ if (res->base.b.target == PIPE_TEXTURE_CUBE_ARRAY)
+ resource_stride *= 6 * res->base.b.array_size;
- unsigned layer_stride = res->base.last_level + 1;
+ unsigned layer_stride = res->base.b.last_level + 1;
return resid * resource_stride + z * layer_stride +
base_level;
buf_loc.PlacedFootprint.Offset += offset;
buf_loc.PlacedFootprint.Footprint.Width = ALIGN(trans->base.box.width,
- util_format_get_blockwidth(res->base.format));
+ util_format_get_blockwidth(res->base.b.format));
buf_loc.PlacedFootprint.Footprint.Height = ALIGN(trans->base.box.height,
- util_format_get_blockheight(res->base.format));
+ util_format_get_blockheight(res->base.b.format));
buf_loc.PlacedFootprint.Footprint.Depth = ALIGN(depth,
- util_format_get_blockdepth(res->base.format));
+ util_format_get_blockdepth(res->base.b.format));
buf_loc.PlacedFootprint.Footprint.RowPitch = trans->base.stride;
debug_printf("D3D12: Copy %dx%dx%d + %dx%dx%d from buffer %s to image %s\n",
trans->base.box.x, trans->base.box.y, trans->base.box.z,
trans->base.box.width, trans->base.box.height, trans->base.box.depth,
- util_format_name(staging_res->base.format),
- util_format_name(res->base.format));
+ util_format_name(staging_res->base.b.format),
+ util_format_name(res->base.b.format));
}
struct copy_info copy_info;
copy_info.dst_loc = fill_texture_location(res, trans, resid, z);
copy_info.dst_x = trans->base.box.x;
copy_info.dst_y = trans->base.box.y;
- copy_info.dst_z = res->base.target == PIPE_TEXTURE_CUBE ? 0 : dest_z;
+ copy_info.dst_z = res->base.b.target == PIPE_TEXTURE_CUBE ? 0 : dest_z;
copy_info.src_box = nullptr;
copy_texture_region(ctx, copy_info);
struct d3d12_resource *staging_res,
struct d3d12_transfer *trans, int resid)
{
- if (res->base.target == PIPE_TEXTURE_3D) {
+ if (res->base.b.target == PIPE_TEXTURE_3D) {
assert(resid == 0);
transfer_buf_to_image_part(ctx, res, staging_res, trans,
0, trans->base.box.depth, 0,
copy_info.dst_loc.PlacedFootprint.Offset = (z - start_layer) * trans->base.layer_stride;
copy_info.dst_x = copy_info.dst_y = copy_info.dst_z = 0;
- if (!util_texrange_covers_whole_level(&res->base, trans->base.level,
+ if (!util_texrange_covers_whole_level(&res->base.b, trans->base.level,
box->x, box->y, start_box_z,
box->width, box->height, depth)) {
src_box.left = box->x;
debug_printf("D3D12: Copy %dx%dx%d + %dx%dx%d from %s@%d to %s\n",
trans->base.box.x, trans->base.box.y, trans->base.box.z,
trans->base.box.width, trans->base.box.height, trans->base.box.depth,
- util_format_name(res->base.format), resid,
- util_format_name(staging_res->base.format));
+ util_format_name(res->base.b.format), resid,
+ util_format_name(staging_res->base.b.format));
}
struct pipe_resource *resolved_resource = nullptr;
- if (res->base.nr_samples > 1) {
- struct pipe_resource tmpl = res->base;
+ if (res->base.b.nr_samples > 1) {
+ struct pipe_resource tmpl = res->base.b;
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.width0, (int16_t)res->base.height0, (int16_t)res->base.depth0};
+ struct pipe_box box = {0,0,0, (int)res->base.b.width0, (int16_t)res->base.b.height0, (int16_t)res->base.b.depth0};
resolve_info.dst.resource = resolved_resource;
resolve_info.dst.box = box;
- resolve_info.dst.format = res->base.format;
- resolve_info.src.resource = &res->base;
+ resolve_info.dst.format = res->base.b.format;
+ resolve_info.src.resource = &res->base.b;
resolve_info.src.box = box;
- resolve_info.src.format = res->base.format;
+ resolve_info.src.format = res->base.b.format;
resolve_info.filter = PIPE_TEX_FILTER_NEAREST;
resolve_info.mask = util_format_get_mask(tmpl.format);
}
- if (res->base.target == PIPE_TEXTURE_3D) {
+ if (res->base.b.target == PIPE_TEXTURE_3D) {
transfer_image_part_to_buf(ctx, res, staging_res, trans, resid,
0, 0, trans->base.box.z, trans->base.box.depth);
} else {
unsigned usage,
D3D12_RANGE *range)
{
- assert(can_map_directly(&res->base));
+ assert(can_map_directly(&res->base.b));
/* Check whether that range contains valid data; if not, we might not need to sync */
if (!(usage & PIPE_MAP_UNSYNCHRONIZED) &&
}
if (usage & PIPE_MAP_WRITE)
- util_range_add(&res->base, &res->valid_buffer_range,
+ util_range_add(&res->base.b, &res->valid_buffer_range,
range->Begin, range->End);
return true;
const struct pipe_box *box,
struct d3d12_transfer *trans)
{
- trans->base.stride = align(util_format_get_stride(res->base.format, box->width),
+ trans->base.stride = align(util_format_get_stride(res->base.b.format, box->width),
D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
- trans->base.layer_stride = util_format_get_2d_size(res->base.format,
+ trans->base.layer_stride = util_format_get_2d_size(res->base.b.format,
trans->base.stride,
box->height);
}
trans->data = buf;
- switch (res->base.format) {
+ switch (res->base.b.format) {
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
util_format_z24_unorm_s8_uint_pack_separate(buf, trans->base.stride,
(uint32_t *)depth_ptr, trans->base.stride,
return;
}
- switch (res->base.format) {
+ switch (res->base.b.format) {
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
util_format_z32_unorm_unpack_z_32unorm((uint32_t *)depth_ptr, trans->base.stride, (uint8_t*)trans->data,
trans->base.stride, trans->base.box.width,
range.Begin = 0;
void *ptr;
- if (can_map_directly(&res->base)) {
+ if (can_map_directly(&res->base.b)) {
if (pres->target == PIPE_BUFFER) {
ptrans->stride = 0;
ptrans->layer_stride = 0;
ptrans->stride,
box->height);
- if (res->base.target != PIPE_TEXTURE_3D)
+ if (res->base.b.target != PIPE_TEXTURE_3D)
ptrans->layer_stride = align(ptrans->layer_stride,
D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
unsigned staging_res_size = ptrans->layer_stride * box->depth;
- if (res->base.target == PIPE_BUFFER) {
+ if (res->base.b.target == PIPE_BUFFER) {
/* To properly support ARB_map_buffer_alignment, we need to return a pointer
* that's appropriately offset from a 64-byte-aligned base address.
*/
if (trans->base.usage & PIPE_MAP_WRITE) {
assert(ptrans->box.x >= 0);
- range.Begin = res->base.target == PIPE_BUFFER ?
+ range.Begin = res->base.b.target == PIPE_BUFFER ?
(unsigned)ptrans->box.x % BUFFER_MAP_ALIGNMENT : 0;
- range.End = staging_res->base.width0 - range.Begin;
+ range.End = staging_res->base.b.width0 - range.Begin;
}
d3d12_bo_unmap(staging_res->bo, &range);
if (trans->base.usage & PIPE_MAP_WRITE) {
struct d3d12_context *ctx = d3d12_context(pctx);
- if (res->base.target == PIPE_BUFFER) {
+ if (res->base.b.target == PIPE_BUFFER) {
uint64_t dst_offset = trans->base.box.x;
uint64_t src_offset = dst_offset % BUFFER_MAP_ALIGNMENT;
transfer_buf_to_buf(ctx, staging_res, res, src_offset, dst_offset, ptrans->box.width);
res->bo = dup_res->bo;
d3d12_bo_reference(res->bo);
- d3d12_resource_destroy(dup_res->base.screen, &dup_res->base);
+ d3d12_resource_destroy(dup_res->base.b.screen, &dup_res->base.b);
}
void