assert(surf->aux_usage == ISL_AUX_USAGE_NONE);
}
-static enum isl_format
-iris_get_blorp_format(enum pipe_format pf)
-{
- switch (pf) {
- case PIPE_FORMAT_Z24_UNORM_S8_UINT:
- return ISL_FORMAT_R24_UNORM_X8_TYPELESS;
- case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
- return ISL_FORMAT_R32_FLOAT;
- default:
- return iris_isl_format_for_pipe_format(pf);
- }
-}
-
/**
* The pipe->blit() driver hook.
*
iris_blit(struct pipe_context *ctx, const struct pipe_blit_info *info)
{
struct iris_context *ice = (void *) ctx;
+ struct iris_screen *screen = (struct iris_screen *)ctx->screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
+
struct blorp_surf src_surf, dst_surf;
iris_blorp_surf_for_resource(&src_surf, info->src.resource,
ISL_AUX_USAGE_NONE, false);
iris_blorp_surf_for_resource(&dst_surf, info->dst.resource,
ISL_AUX_USAGE_NONE, true);
- enum isl_format src_isl_format = iris_get_blorp_format(info->src.format);
- enum isl_format dst_isl_format = iris_get_blorp_format(info->dst.format);
-
- struct isl_swizzle src_isl_swizzle = ISL_SWIZZLE_IDENTITY;
+ struct iris_format_info src_fmt =
+ iris_format_for_usage(devinfo, info->src.format,
+ ISL_SURF_USAGE_TEXTURE_BIT);
+ struct iris_format_info dst_fmt =
+ iris_format_for_usage(devinfo, info->dst.format,
+ ISL_SURF_USAGE_RENDER_TARGET_BIT);
int src_x0 = info->src.box.x;
int src_x1 = info->src.box.x + info->src.box.width;
blorp_blit(&blorp_batch,
&src_surf, info->src.level, info->src.box.z + slice,
- src_isl_format, src_isl_swizzle,
+ src_fmt.fmt, src_fmt.swizzle,
&dst_surf, info->dst.level, info->dst.box.z + slice,
- dst_isl_format, ISL_SWIZZLE_IDENTITY,
+ dst_fmt.fmt, ISL_SWIZZLE_IDENTITY,
src_x0, src_y0, src_x1, src_y1,
dst_x0, dst_y0, dst_x1, dst_y1,
filter, mirror_x, mirror_y);
blorp_blit(&blorp_batch,
&src_surf, info->src.level, info->src.box.z + slice,
- ISL_FORMAT_R8_UINT, src_isl_swizzle,
+ ISL_FORMAT_R8_UINT, ISL_SWIZZLE_IDENTITY,
&dst_surf, info->dst.level, info->dst.box.z + slice,
ISL_FORMAT_R8_UINT, ISL_SWIZZLE_IDENTITY,
src_x0, src_y0, src_x1, src_y1,
#include "iris_resource.h"
#include "iris_screen.h"
-enum isl_format
+static enum isl_format
iris_isl_format_for_pipe_format(enum pipe_format pf)
{
static const enum isl_format table[PIPE_FORMAT_COUNT] = {
return table[pf];
}
-enum isl_format
-iris_isl_format_for_usage(const struct gen_device_info *devinfo,
- enum pipe_format pformat,
- isl_surf_usage_flags_t usage)
+struct iris_format_info
+iris_format_for_usage(const struct gen_device_info *devinfo,
+ enum pipe_format pformat,
+ isl_surf_usage_flags_t usage)
{
+ struct isl_swizzle swizzle = ISL_SWIZZLE_IDENTITY;
+
enum isl_format format = iris_isl_format_for_pipe_format(pformat);
/* Convert RGBX into RGBA for rendering or typed image access. */
format = isl_format_rgbx_to_rgba(format);
}
- return format;
+ return (struct iris_format_info) { .fmt = format, .swizzle = swizzle };
}
/**
/* Should be handled by u_transfer_helper */
assert(!util_format_is_depth_and_stencil(pfmt));
- enum isl_format isl_format = iris_isl_format_for_pipe_format(pfmt);
- assert(isl_format != ISL_FORMAT_UNSUPPORTED);
+ struct iris_format_info fmt = iris_format_for_usage(devinfo, pfmt, usage);
+ assert(fmt.fmt != ISL_FORMAT_UNSUPPORTED);
UNUSED const bool isl_surf_created_successfully =
isl_surf_init(&screen->isl_dev, &res->surf,
.dim = target_to_isl_surf_dim(templ->target),
- .format = isl_format,
+ .format = fmt.fmt,
.width = templ->width0,
.height = templ->height0,
.depth = templ->depth0,
void *user_memory)
{
struct iris_screen *screen = (struct iris_screen *)pscreen;
+ struct gen_device_info *devinfo = &screen->devinfo;
struct iris_bufmgr *bufmgr = screen->bufmgr;
struct iris_resource *res = iris_alloc_resource(pscreen, templ);
if (!res)
// XXX: usage...
isl_surf_usage_flags_t isl_usage = 0;
+ const struct iris_format_info fmt =
+ iris_format_for_usage(devinfo, templ->format, isl_usage);
+
isl_surf_init(&screen->isl_dev, &res->surf,
.dim = target_to_isl_surf_dim(templ->target),
- .format = iris_isl_format_for_pipe_format(templ->format),
+ .format = fmt.fmt,
.width = templ->width0,
.height = templ->height0,
.depth = templ->depth0,
unsigned usage)
{
struct iris_screen *screen = (struct iris_screen *)pscreen;
+ struct gen_device_info *devinfo = &screen->devinfo;
struct iris_bufmgr *bufmgr = screen->bufmgr;
struct iris_resource *res = iris_alloc_resource(pscreen, templ);
if (!res)
// XXX: usage...
isl_surf_usage_flags_t isl_usage = ISL_SURF_USAGE_DISPLAY_BIT;
+ const struct iris_format_info fmt =
+ iris_format_for_usage(devinfo, templ->format, isl_usage);
+
isl_surf_init(&screen->isl_dev, &res->surf,
.dim = target_to_isl_surf_dim(templ->target),
- .format = iris_isl_format_for_pipe_format(templ->format),
+ .format = fmt.fmt,
.width = templ->width0,
.height = templ->height0,
.depth = templ->depth0,
#include "util/u_inlines.h"
#include "intel/isl/isl.h"
+struct iris_format_info {
+ enum isl_format fmt;
+ struct isl_swizzle swizzle;
+};
+
#define IRIS_RESOURCE_FLAG_SHADER_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
#define IRIS_RESOURCE_FLAG_SURFACE_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
#define IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
return res->bo;
}
-enum isl_format iris_isl_format_for_pipe_format(enum pipe_format pf);
-enum isl_format iris_isl_format_for_usage(const struct gen_device_info *,
- enum pipe_format,
- isl_surf_usage_flags_t usage);
+struct iris_format_info iris_format_for_usage(const struct gen_device_info *,
+ enum pipe_format pf,
+ isl_surf_usage_flags_t usage);
struct pipe_resource *iris_resource_get_separate_stencil(struct pipe_resource *);
ice->state.dirty |= IRIS_DIRTY_SAMPLER_STATES_VS << stage;
}
+static enum isl_channel_select
+fmt_swizzle(const struct iris_format_info *fmt, enum pipe_swizzle swz)
+{
+ switch (swz) {
+ case PIPE_SWIZZLE_X: return fmt->swizzle.r;
+ case PIPE_SWIZZLE_Y: return fmt->swizzle.g;
+ case PIPE_SWIZZLE_Z: return fmt->swizzle.b;
+ case PIPE_SWIZZLE_W: return fmt->swizzle.a;
+ case PIPE_SWIZZLE_1: return SCS_ONE;
+ case PIPE_SWIZZLE_0: return SCS_ZERO;
+ default: unreachable("invalid swizzle");
+ }
+}
+
/**
* The pipe->create_sampler_view() driver hook.
*/
{
struct iris_context *ice = (struct iris_context *) ctx;
struct iris_screen *screen = (struct iris_screen *)ctx->screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
struct iris_sampler_view *isv = calloc(1, sizeof(struct iris_sampler_view));
if (!isv)
isv->res = (struct iris_resource *) tex;
- /* XXX: do we need brw_get_texture_swizzle hacks here? */
+ isl_surf_usage_flags_t usage =
+ ISL_SURF_USAGE_TEXTURE_BIT |
+ (isv->res->surf.usage & ISL_SURF_USAGE_CUBE_BIT);
+
+ const struct iris_format_info fmt =
+ iris_format_for_usage(devinfo, tmpl->format, usage);
+
isv->view = (struct isl_view) {
- .format = iris_isl_format_for_pipe_format(tmpl->format),
+ .format = fmt.fmt,
.swizzle = (struct isl_swizzle) {
- .r = pipe_swizzle_to_isl_channel(tmpl->swizzle_r),
- .g = pipe_swizzle_to_isl_channel(tmpl->swizzle_g),
- .b = pipe_swizzle_to_isl_channel(tmpl->swizzle_b),
- .a = pipe_swizzle_to_isl_channel(tmpl->swizzle_a),
+ .r = fmt_swizzle(&fmt, tmpl->swizzle_r),
+ .g = fmt_swizzle(&fmt, tmpl->swizzle_g),
+ .b = fmt_swizzle(&fmt, tmpl->swizzle_b),
+ .a = fmt_swizzle(&fmt, tmpl->swizzle_a),
},
- .usage = ISL_SURF_USAGE_TEXTURE_BIT |
- (isv->res->surf.usage & ISL_SURF_USAGE_CUBE_BIT),
+ .usage = usage,
};
/* Fill out SURFACE_STATE for this view. */
else
usage = ISL_SURF_USAGE_RENDER_TARGET_BIT;
- enum isl_format isl_format =
- iris_isl_format_for_usage(devinfo, psurf->format, usage);
+ const struct iris_format_info fmt =
+ iris_format_for_usage(devinfo, psurf->format, usage);
if ((usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
- !isl_format_supports_rendering(devinfo, isl_format)) {
+ !isl_format_supports_rendering(devinfo, fmt.fmt)) {
/* Framebuffer validation will reject this invalid case, but it
* hasn't had the opportunity yet. In the meantime, we need to
* avoid hitting ISL asserts about unsupported formats below.
}
surf->view = (struct isl_view) {
- .format = isl_format,
+ .format = fmt.fmt,
.base_level = tmpl->u.tex.level,
.levels = 1,
.base_array_layer = tmpl->u.tex.first_layer,
unsigned count,
const struct pipe_vertex_element *state)
{
+ struct iris_screen *screen = (struct iris_screen *)ctx->screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
struct iris_vertex_element_state *cso =
malloc(sizeof(struct iris_vertex_element_state));
}
for (int i = 0; i < count; i++) {
- enum isl_format isl_format =
- iris_isl_format_for_pipe_format(state[i].src_format);
+ const struct iris_format_info fmt =
+ iris_format_for_usage(devinfo, state[i].src_format, 0);
unsigned comp[4] = { VFCOMP_STORE_SRC, VFCOMP_STORE_SRC,
VFCOMP_STORE_SRC, VFCOMP_STORE_SRC };
- switch (isl_format_get_num_channels(isl_format)) {
+ switch (isl_format_get_num_channels(fmt.fmt)) {
case 0: comp[0] = VFCOMP_STORE_0;
case 1: comp[1] = VFCOMP_STORE_0;
case 2: comp[2] = VFCOMP_STORE_0;
case 3:
- comp[3] = isl_format_has_int_channel(isl_format) ? VFCOMP_STORE_1_INT
- : VFCOMP_STORE_1_FP;
+ comp[3] = isl_format_has_int_channel(fmt.fmt) ? VFCOMP_STORE_1_INT
+ : VFCOMP_STORE_1_FP;
break;
}
iris_pack_state(GENX(VERTEX_ELEMENT_STATE), ve_pack_dest, ve) {
ve.VertexBufferIndex = state[i].vertex_buffer_index;
ve.Valid = true;
ve.SourceElementOffset = state[i].src_offset;
- ve.SourceElementFormat = isl_format;
+ ve.SourceElementFormat = fmt.fmt;
ve.Component0Control = comp[0];
ve.Component1Control = comp[1];
ve.Component2Control = comp[2];