struct u_transfer_helper {
const struct u_transfer_vtbl *vtbl;
- bool separate_z32s8;
+ bool separate_z32s8; /**< separate z32 and s8 */
+ bool separate_stencil; /**< separate stencil for all formats */
bool fake_rgtc;
bool msaa_map;
};
enum pipe_format format = templ->format;
struct pipe_resource *prsc;
- if ((format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) && helper->separate_z32s8) {
+ if ((helper->separate_stencil && util_format_is_depth_and_stencil(format)) ||
+ (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT && helper->separate_z32s8)) {
struct pipe_resource t = *templ;
struct pipe_resource *stencil;
- t.format = PIPE_FORMAT_Z32_FLOAT;
+ t.format = util_format_get_depth_only(format);
prsc = helper->vtbl->resource_create(pscreen, &t);
if (!prsc)
if (!trans->ptr)
goto fail;
- if (prsc->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
+ if (util_format_is_depth_and_stencil(prsc->format)) {
struct pipe_resource *stencil = helper->vtbl->get_stencil(prsc);
trans->ptr2 = helper->vtbl->transfer_map(pctx, stencil, level,
usage, box, &trans->trans2);
if (needs_pack(usage)) {
- util_format_z32_float_s8x24_uint_pack_z_float(trans->staging,
- ptrans->stride,
- trans->ptr,
- trans->trans->stride,
- width, height);
- util_format_z32_float_s8x24_uint_pack_s_8uint(trans->staging,
- ptrans->stride,
- trans->ptr2,
- trans->trans2->stride,
- width, height);
+ switch (prsc->format) {
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+ util_format_z32_float_s8x24_uint_pack_z_float(trans->staging,
+ ptrans->stride,
+ trans->ptr,
+ trans->trans->stride,
+ width, height);
+ util_format_z32_float_s8x24_uint_pack_s_8uint(trans->staging,
+ ptrans->stride,
+ trans->ptr2,
+ trans->trans2->stride,
+ width, height);
+ break;
+ case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+ util_format_z24_unorm_s8_uint_pack_separate(trans->staging,
+ ptrans->stride,
+ trans->ptr,
+ trans->trans->stride,
+ trans->ptr2,
+ trans->trans2->stride,
+ width, height);
+ break;
+ default:
+ unreachable("Unexpected format");
+ }
}
} else if (needs_pack(usage) &&
util_format_description(prsc->format)->layout == UTIL_FORMAT_LAYOUT_RGTC) {
ptrans->stride,
width, height);
break;
+ case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+ /* just do a strided 32-bit copy for depth; s8 can become garbage x8 */
+ util_format_z32_unorm_unpack_z_32unorm(dst, trans->trans->stride,
+ src, ptrans->stride,
+ width, height);
+ /* fallthru */
+ case PIPE_FORMAT_X24S8_UINT:
+ dst = (uint8_t *)trans->ptr2 +
+ (box->y * trans->trans2->stride) +
+ (box->x * util_format_get_blocksize(PIPE_FORMAT_S8_UINT));
+
+ util_format_z24_unorm_s8_uint_unpack_s_8uint(dst, trans->trans2->stride,
+ src, ptrans->stride,
+ width, height);
+ break;
+
case PIPE_FORMAT_RGTC1_UNORM:
case PIPE_FORMAT_RGTC1_SNORM:
case PIPE_FORMAT_LATC1_UNORM:
struct u_transfer_helper *
u_transfer_helper_create(const struct u_transfer_vtbl *vtbl,
bool separate_z32s8,
+ bool separate_stencil,
bool fake_rgtc,
bool msaa_map)
{
helper->vtbl = vtbl;
helper->separate_z32s8 = separate_z32s8;
+ helper->separate_stencil = separate_stencil;
helper->fake_rgtc = fake_rgtc;
helper->msaa_map = msaa_map;
/* A helper to implement various "lowering" for transfers:
*
- * - exposing separate z32 and s8 as z32x24s8
+ * - exposing separate depth and stencil resources as packed depth-stencil
* - fake RGTC support for GLES class hardware which needs it to expose GL3+
* - MSAA resolves
*
*/
/**
- * Must be implemented if separate_z32s8 or fake_rgtc is used. The
+ * Must be implemented if separate stencil or fake_rgtc is used. The
* internal_format is the format the resource was created with. In
- * the case of separate_z32s8 or fake_rgtc, prsc->format is set back
- * to the state tracker visible format (Z32_FLOAT_S8X24_UINT or
+ * the case of separate stencil or fake_rgtc, prsc->format is set back
+ * to the state tracker visible format (e.g. Z32_FLOAT_S8X24_UINT or
* PIPE_FORMAT_{RTGC,LATC}* after the resource is created.
*/
enum pipe_format (*get_internal_format)(struct pipe_resource *prsc);
/**
- * Must be implemented if separate_z32s8 is used. Used to set/get
+ * Must be implemented if separate stencil is lowered. Used to set/get
* the separate s8 stencil buffer.
*
* These two do not get/put references to the pipe_resource. The
struct u_transfer_helper * u_transfer_helper_create(const struct u_transfer_vtbl *vtbl,
bool separate_z32s8,
+ bool separate_stencil,
bool fake_rgtc,
bool msaa_map);