summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2015-05-02 12:04:26 +0800
committerChia-I Wu <[email protected]>2015-05-02 22:14:06 +0800
commitc209aa7a8f08acb89f7294328589f47a88b44703 (patch)
tree624b862372c9a855af19bcb367af8010f8fd29bd /src/gallium
parent9b72bf5bd22c14c4cc17b6945d4b74f4c0eae80a (diff)
ilo: improve readability of ilo_image
Improve docs, rename struct fields, and reorder walk types. No real changes.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/ilo/core/ilo_image.c92
-rw-r--r--src/gallium/drivers/ilo/core/ilo_image.h112
-rw-r--r--src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c18
-rw-r--r--src/gallium/drivers/ilo/core/ilo_state_3d_top.c4
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.c10
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.h2
6 files changed, 127 insertions, 111 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_image.c b/src/gallium/drivers/ilo/core/ilo_image.c
index daa2bae9412..174e2e17138 100644
--- a/src/gallium/drivers/ilo/core/ilo_image.c
+++ b/src/gallium/drivers/ilo/core/ilo_image.c
@@ -214,14 +214,14 @@ img_init_layer_height(struct ilo_image *img,
* slices. Since we use texel rows everywhere, we do not need to divide
* QPitch by 4.
*/
- img->layer_height = params->h0 + params->h1 +
+ img->walk_layer_height = params->h0 + params->h1 +
((ilo_dev_gen(params->dev) >= ILO_GEN(7)) ? 12 : 11) * img->align_j;
if (ilo_dev_gen(params->dev) == ILO_GEN(6) && templ->nr_samples > 1 &&
img->height0 % 4 == 1)
- img->layer_height += 4;
+ img->walk_layer_height += 4;
- params->max_y += img->layer_height * (num_layers - 1);
+ params->max_y += img->walk_layer_height * (num_layers - 1);
}
static void
@@ -245,6 +245,13 @@ img_init_lods(struct ilo_image *img,
img->lods[lv].slice_height = lod_h;
switch (img->walk) {
+ case ILO_IMAGE_WALK_LAYER:
+ /* MIPLAYOUT_BELOW */
+ if (lv == 1)
+ cur_x += lod_w;
+ else
+ cur_y += lod_h;
+ break;
case ILO_IMAGE_WALK_LOD:
lod_h *= img_get_num_layers(img, params);
if (lv == 1)
@@ -259,13 +266,6 @@ img_init_lods(struct ilo_image *img,
cur_y = align(cur_y, 64);
}
break;
- case ILO_IMAGE_WALK_LAYER:
- /* MIPLAYOUT_BELOW */
- if (lv == 1)
- cur_x += lod_w;
- else
- cur_y += lod_h;
- break;
case ILO_IMAGE_WALK_3D:
{
const unsigned num_slices = u_minify(templ->depth0, lv);
@@ -693,7 +693,7 @@ img_init_size_and_format(struct ilo_image *img,
if (ilo_dev_gen(params->dev) >= ILO_GEN(7))
require_separate_stencil = true;
else
- require_separate_stencil = (img->aux == ILO_IMAGE_AUX_HIZ);
+ require_separate_stencil = (img->aux.type == ILO_IMAGE_AUX_HIZ);
}
switch (format) {
@@ -824,9 +824,9 @@ img_init_aux(struct ilo_image *img,
struct ilo_image_params *params)
{
if (img_want_hiz(img, params))
- img->aux = ILO_IMAGE_AUX_HIZ;
+ img->aux.type = ILO_IMAGE_AUX_HIZ;
else if (img_want_mcs(img, params))
- img->aux = ILO_IMAGE_AUX_MCS;
+ img->aux.type = ILO_IMAGE_AUX_MCS;
}
static void
@@ -882,7 +882,7 @@ img_align(struct ilo_image *img, struct ilo_image_params *params)
* ilo_texture_can_enable_hiz(), we always return true for the first slice.
* To avoid out-of-bound access, we have to pad.
*/
- if (img->aux == ILO_IMAGE_AUX_HIZ &&
+ if (img->aux.type == ILO_IMAGE_AUX_HIZ &&
templ->last_level == 0 &&
templ->array_size == 1 &&
templ->depth0 == 1) {
@@ -901,7 +901,7 @@ img_calculate_bo_size(struct ilo_image *img,
{
assert(params->max_x % img->block_width == 0);
assert(params->max_y % img->block_height == 0);
- assert(img->layer_height % img->block_height == 0);
+ assert(img->walk_layer_height % img->block_height == 0);
img->bo_stride =
(params->max_x / img->block_width) * img->block_size;
@@ -987,9 +987,9 @@ img_calculate_bo_size(struct ilo_image *img,
if (img->valid_tilings & IMAGE_TILING_NONE) {
img->tiling = GEN6_TILING_NONE;
/* MCS support for non-MSRTs is limited to tiled RTs */
- if (img->aux == ILO_IMAGE_AUX_MCS &&
+ if (img->aux.type == ILO_IMAGE_AUX_MCS &&
params->templ->nr_samples <= 1)
- img->aux = ILO_IMAGE_AUX_NONE;
+ img->aux.type = ILO_IMAGE_AUX_NONE;
continue;
} else {
@@ -1014,7 +1014,7 @@ img_calculate_hiz_size(struct ilo_image *img,
unsigned hz_width, hz_height, lv;
unsigned hz_clear_w, hz_clear_h;
- assert(img->aux == ILO_IMAGE_AUX_HIZ);
+ assert(img->aux.type == ILO_IMAGE_AUX_HIZ);
assert(img->walk == ILO_IMAGE_WALK_LAYER ||
img->walk == ILO_IMAGE_WALK_3D);
@@ -1043,6 +1043,23 @@ img_calculate_hiz_size(struct ilo_image *img,
* memory row.
*/
switch (hz_walk) {
+ case ILO_IMAGE_WALK_LAYER:
+ {
+ const unsigned h0 = align(params->h0, hz_align_j);
+ const unsigned h1 = align(params->h1, hz_align_j);
+ const unsigned htail =
+ ((ilo_dev_gen(params->dev) >= ILO_GEN(7)) ? 12 : 11) * hz_align_j;
+ const unsigned hz_qpitch = h0 + h1 + htail;
+
+ hz_width = align(img->lods[0].slice_width, 16);
+
+ hz_height = hz_qpitch * templ->array_size / 2;
+ if (ilo_dev_gen(params->dev) >= ILO_GEN(7))
+ hz_height = align(hz_height, 8);
+
+ img->aux.walk_layer_height = hz_qpitch;
+ }
+ break;
case ILO_IMAGE_WALK_LOD:
{
unsigned lod_tx[PIPE_MAX_TEXTURE_LEVELS];
@@ -1080,30 +1097,13 @@ img_calculate_hiz_size(struct ilo_image *img,
/* convert tile offsets to memory offsets */
for (lv = 0; lv <= templ->last_level; lv++) {
- img->aux_offsets[lv] =
+ img->aux.walk_lod_offsets[lv] =
(lod_ty[lv] * hz_width + lod_tx[lv]) * 4096;
}
hz_width *= 128;
hz_height *= 32;
}
break;
- case ILO_IMAGE_WALK_LAYER:
- {
- const unsigned h0 = align(params->h0, hz_align_j);
- const unsigned h1 = align(params->h1, hz_align_j);
- const unsigned htail =
- ((ilo_dev_gen(params->dev) >= ILO_GEN(7)) ? 12 : 11) * hz_align_j;
- const unsigned hz_qpitch = h0 + h1 + htail;
-
- hz_width = align(img->lods[0].slice_width, 16);
-
- hz_height = hz_qpitch * templ->array_size / 2;
- if (ilo_dev_gen(params->dev) >= ILO_GEN(7))
- hz_height = align(hz_height, 8);
-
- img->aux_layer_height = hz_qpitch;
- }
- break;
case ILO_IMAGE_WALK_3D:
hz_width = align(img->lods[0].slice_width, 16);
@@ -1156,16 +1156,16 @@ img_calculate_hiz_size(struct ilo_image *img,
if (u_minify(img->width0, lv) % hz_clear_w ||
u_minify(img->height0, lv) % hz_clear_h)
break;
- img->aux_enables |= 1 << lv;
+ img->aux.enables |= 1 << lv;
}
/* we padded to allow this in img_align() */
if (templ->last_level == 0 && templ->array_size == 1 && templ->depth0 == 1)
- img->aux_enables |= 0x1;
+ img->aux.enables |= 0x1;
/* align to Y-tile */
- img->aux_stride = align(hz_width, 128);
- img->aux_height = align(hz_height, 32);
+ img->aux.bo_stride = align(hz_width, 128);
+ img->aux.bo_height = align(hz_height, 32);
}
static void
@@ -1176,7 +1176,7 @@ img_calculate_mcs_size(struct ilo_image *img,
int mcs_width, mcs_height, mcs_cpp;
int downscale_x, downscale_y;
- assert(img->aux == ILO_IMAGE_AUX_MCS);
+ assert(img->aux.type == ILO_IMAGE_AUX_MCS);
if (templ->nr_samples > 1) {
/*
@@ -1289,10 +1289,10 @@ img_calculate_mcs_size(struct ilo_image *img,
mcs_cpp = 16; /* an OWord */
}
- img->aux_enables = (1 << (templ->last_level + 1)) - 1;
+ img->aux.enables = (1 << (templ->last_level + 1)) - 1;
/* align to Y-tile */
- img->aux_stride = align(mcs_width * mcs_cpp, 128);
- img->aux_height = align(mcs_height, 32);
+ img->aux.bo_stride = align(mcs_width * mcs_cpp, 128);
+ img->aux.bo_height = align(mcs_height, 32);
}
/**
@@ -1311,7 +1311,7 @@ img_init_for_transfer(struct ilo_image *img,
assert(templ->last_level == 0);
assert(templ->nr_samples <= 1);
- img->aux = ILO_IMAGE_AUX_NONE;
+ img->aux.type = ILO_IMAGE_AUX_NONE;
img->width0 = templ->width0;
img->height0 = templ->height0;
img->format = templ->format;
@@ -1376,7 +1376,7 @@ void ilo_image_init(struct ilo_image *img,
img_align(img, &params);
img_calculate_bo_size(img, &params);
- switch (img->aux) {
+ switch (img->aux.type) {
case ILO_IMAGE_AUX_HIZ:
img_calculate_hiz_size(img, &params);
break;
diff --git a/src/gallium/drivers/ilo/core/ilo_image.h b/src/gallium/drivers/ilo/core/ilo_image.h
index 2ca48b7960f..50a78037575 100644
--- a/src/gallium/drivers/ilo/core/ilo_image.h
+++ b/src/gallium/drivers/ilo/core/ilo_image.h
@@ -34,44 +34,52 @@
#include "ilo_core.h"
#include "ilo_dev.h"
-struct pipe_resource;
+enum ilo_image_aux_type {
+ ILO_IMAGE_AUX_NONE,
+ ILO_IMAGE_AUX_HIZ,
+ ILO_IMAGE_AUX_MCS,
+};
enum ilo_image_walk_type {
/*
- * Array layers of an LOD are packed together vertically. This maps to
- * ARYSPC_LOD0 for non-mipmapped 2D textures, and is extended to support
- * mipmapped stencil textures and HiZ on GEN6.
+ * LODs of each array layer are first packed together in MIPLAYOUT_BELOW.
+ * Array layers are then stacked together vertically.
+ *
+ * This can be used for mipmapped 2D textures.
*/
- ILO_IMAGE_WALK_LOD,
+ ILO_IMAGE_WALK_LAYER,
/*
- * LODs of an array layer are packed together. This maps to ARYSPC_FULL
- * and is used for mipmapped 2D textures.
+ * Array layers of each LOD are first stacked together vertically and
+ * tightly. LODs are then packed together in MIPLAYOUT_BELOW with each LOD
+ * starting at page boundaries.
+ *
+ * This is usually used for non-mipmapped 2D textures, as multiple LODs are
+ * not supported natively.
*/
- ILO_IMAGE_WALK_LAYER,
+ ILO_IMAGE_WALK_LOD,
/*
- * 3D slices of an LOD are packed together, horizontally with wrapping.
- * Used for 3D textures.
+ * 3D slices of each LOD are first packed together horizontally and tightly
+ * with wrapping. LODs are then stacked together vertically and tightly.
+ *
+ * This is used for 3D textures.
*/
ILO_IMAGE_WALK_3D,
};
-enum ilo_image_aux_type {
- ILO_IMAGE_AUX_NONE,
- ILO_IMAGE_AUX_HIZ,
- ILO_IMAGE_AUX_MCS,
-};
-
+/*
+ * When the walk type is ILO_IMAGE_WALK_LAYER, there is only a slice in each
+ * LOD and this is used to describe LODs in the first array layer. Otherwise,
+ * there can be multiple slices in each LOD and this is used to describe the
+ * first slice in each LOD.
+ */
struct ilo_image_lod {
- /* physical position */
+ /* physical position in pixels */
unsigned x;
unsigned y;
- /*
- * Physical size of an LOD slice. There may be multiple slices when the
- * walk type is not ILO_IMAGE_WALK_LAYER.
- */
+ /* physical size of a slice in pixels */
unsigned slice_width;
unsigned slice_height;
};
@@ -80,17 +88,15 @@ struct ilo_image_lod {
* Texture layout.
*/
struct ilo_image {
- enum ilo_image_aux_type aux;
-
- /* physical width0, height0, and format */
+ /* size and format for programming hardware states */
unsigned width0;
unsigned height0;
enum pipe_format format;
bool separate_stencil;
/*
- * width, height, and size of pixel blocks, for conversion between 2D
- * coordinates and memory offsets
+ * width, height, and size of pixel blocks for conversion between pixel
+ * positions and memory offsets
*/
unsigned block_width;
unsigned block_height;
@@ -99,35 +105,45 @@ struct ilo_image {
enum ilo_image_walk_type walk;
bool interleaved_samples;
- /* bitmask of valid tiling modes */
+ /* bitmask of valid tilings */
unsigned valid_tilings;
enum gen_surface_tiling tiling;
- /* mipmap alignments */
+ /* physical LOD slice alignments */
unsigned align_i;
unsigned align_j;
struct ilo_image_lod lods[PIPE_MAX_TEXTURE_LEVELS];
- /* physical height of layers for ILO_IMAGE_WALK_LAYER */
- unsigned layer_height;
+ /* physical layer height for ILO_IMAGE_WALK_LAYER */
+ unsigned walk_layer_height;
/* distance in bytes between two pixel block rows */
unsigned bo_stride;
/* number of pixel block rows */
unsigned bo_height;
- /* bitmask of levels that can use aux */
- unsigned aux_enables;
- unsigned aux_offsets[PIPE_MAX_TEXTURE_LEVELS];
- unsigned aux_layer_height;
- unsigned aux_stride;
- unsigned aux_height;
-
struct intel_bo *bo;
- struct intel_bo *aux_bo;
+
+ struct {
+ enum ilo_image_aux_type type;
+
+ /* bitmask of levels that can use aux */
+ unsigned enables;
+
+ /* LOD offsets for ILO_IMAGE_WALK_LOD */
+ unsigned walk_lod_offsets[PIPE_MAX_TEXTURE_LEVELS];
+
+ unsigned walk_layer_height;
+ unsigned bo_stride;
+ unsigned bo_height;
+
+ struct intel_bo *bo;
+ } aux;
};
+struct pipe_resource;
+
void
ilo_image_init(struct ilo_image *img,
const struct ilo_dev *dev,
@@ -142,7 +158,7 @@ static inline void
ilo_image_cleanup(struct ilo_image *img)
{
intel_bo_unref(img->bo);
- intel_bo_unref(img->aux_bo);
+ intel_bo_unref(img->aux.bo);
}
static inline void
@@ -155,8 +171,8 @@ ilo_image_set_bo(struct ilo_image *img, struct intel_bo *bo)
static inline void
ilo_image_set_aux_bo(struct ilo_image *img, struct intel_bo *bo)
{
- intel_bo_unref(img->aux_bo);
- img->aux_bo = intel_bo_ref(bo);
+ intel_bo_unref(img->aux.bo);
+ img->aux.bo = intel_bo_ref(bo);
}
/**
@@ -232,12 +248,12 @@ ilo_image_get_slice_stride(const struct ilo_image *img, unsigned level)
unsigned h;
switch (img->walk) {
+ case ILO_IMAGE_WALK_LAYER:
+ h = img->walk_layer_height;
+ break;
case ILO_IMAGE_WALK_LOD:
h = img->lods[level].slice_height;
break;
- case ILO_IMAGE_WALK_LAYER:
- h = img->layer_height;
- break;
case ILO_IMAGE_WALK_3D:
if (level == 0) {
h = img->lods[0].slice_height;
@@ -280,13 +296,13 @@ ilo_image_get_slice_pos(const struct ilo_image *img,
unsigned *x, unsigned *y)
{
switch (img->walk) {
- case ILO_IMAGE_WALK_LOD:
+ case ILO_IMAGE_WALK_LAYER:
*x = img->lods[level].x;
- *y = img->lods[level].y + img->lods[level].slice_height * slice;
+ *y = img->lods[level].y + img->walk_layer_height * slice;
break;
- case ILO_IMAGE_WALK_LAYER:
+ case ILO_IMAGE_WALK_LOD:
*x = img->lods[level].x;
- *y = img->lods[level].y + img->layer_height * slice;
+ *y = img->lods[level].y + img->lods[level].slice_height * slice;
break;
case ILO_IMAGE_WALK_3D:
{
diff --git a/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c b/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c
index 291c86b3406..91c9bd2197d 100644
--- a/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c
+++ b/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c
@@ -1032,8 +1032,8 @@ zs_init_info(const struct ilo_dev *dev,
info->zs.bo = tex->image.bo;
info->zs.stride = tex->image.bo_stride;
- assert(tex->image.layer_height % 4 == 0);
- info->zs.qpitch = tex->image.layer_height / 4;
+ assert(tex->image.walk_layer_height % 4 == 0);
+ info->zs.qpitch = tex->image.walk_layer_height / 4;
info->zs.tiling = tex->image.tiling;
info->zs.offset = 0;
@@ -1056,8 +1056,8 @@ zs_init_info(const struct ilo_dev *dev,
*/
info->stencil.stride = s8_tex->image.bo_stride * 2;
- assert(s8_tex->image.layer_height % 4 == 0);
- info->stencil.qpitch = s8_tex->image.layer_height / 4;
+ assert(s8_tex->image.walk_layer_height % 4 == 0);
+ info->stencil.qpitch = s8_tex->image.walk_layer_height / 4;
info->stencil.tiling = s8_tex->image.tiling;
@@ -1074,17 +1074,17 @@ zs_init_info(const struct ilo_dev *dev,
}
if (ilo_texture_can_enable_hiz(tex, level, first_layer, num_layers)) {
- info->hiz.bo = tex->image.aux_bo;
- info->hiz.stride = tex->image.aux_stride;
+ info->hiz.bo = tex->image.aux.bo;
+ info->hiz.stride = tex->image.aux.bo_stride;
- assert(tex->image.aux_layer_height % 4 == 0);
- info->hiz.qpitch = tex->image.aux_layer_height / 4;
+ assert(tex->image.aux.walk_layer_height % 4 == 0);
+ info->hiz.qpitch = tex->image.aux.walk_layer_height / 4;
info->hiz.tiling = GEN6_TILING_Y;
/* offset to the level */
if (ilo_dev_gen(dev) == ILO_GEN(6))
- info->hiz.offset = tex->image.aux_offsets[level];
+ info->hiz.offset = tex->image.aux.walk_lod_offsets[level];
}
info->width = tex->image.width0;
diff --git a/src/gallium/drivers/ilo/core/ilo_state_3d_top.c b/src/gallium/drivers/ilo/core/ilo_state_3d_top.c
index 004656f8461..5772ec084b1 100644
--- a/src/gallium/drivers/ilo/core/ilo_state_3d_top.c
+++ b/src/gallium/drivers/ilo/core/ilo_state_3d_top.c
@@ -1117,8 +1117,8 @@ view_init_for_texture_gen7(const struct ilo_dev *dev,
dw[0] |= GEN7_SURFACE_DW0_CUBE_FACE_ENABLES__MASK;
if (ilo_dev_gen(dev) >= ILO_GEN(8)) {
- assert(tex->image.layer_height % 4 == 0);
- dw[1] = tex->image.layer_height / 4;
+ assert(tex->image.walk_layer_height % 4 == 0);
+ dw[1] = tex->image.walk_layer_height / 4;
} else {
dw[1] = 0;
}
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index ae4ae59f7ef..aafa37c4f26 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -248,14 +248,14 @@ tex_create_hiz(struct ilo_texture *tex)
unsigned lv;
bo = intel_winsys_alloc_bo(is->dev.winsys, "hiz texture",
- tex->image.aux_stride * tex->image.aux_height, false);
+ tex->image.aux.bo_stride * tex->image.aux.bo_height, false);
if (!bo)
return false;
ilo_image_set_aux_bo(&tex->image, bo);
for (lv = 0; lv <= templ->last_level; lv++) {
- if (tex->image.aux_enables & (1 << lv)) {
+ if (tex->image.aux.enables & (1 << lv)) {
const unsigned num_slices = (templ->target == PIPE_TEXTURE_3D) ?
u_minify(templ->depth0, lv) : templ->array_size;
unsigned flags = ILO_TEXTURE_HIZ;
@@ -277,10 +277,10 @@ tex_create_mcs(struct ilo_texture *tex)
struct ilo_screen *is = ilo_screen(tex->base.screen);
struct intel_bo *bo;
- assert(tex->image.aux_enables == (1 << (tex->base.last_level + 1)) - 1);
+ assert(tex->image.aux.enables == (1 << (tex->base.last_level + 1)) - 1);
bo = intel_winsys_alloc_bo(is->dev.winsys, "mcs texture",
- tex->image.aux_stride * tex->image.aux_height, false);
+ tex->image.aux.bo_stride * tex->image.aux.bo_height, false);
if (!bo)
return false;
@@ -319,7 +319,7 @@ tex_alloc_bos(struct ilo_texture *tex,
if (tex->image.separate_stencil && !tex_create_separate_stencil(tex))
return false;
- switch (tex->image.aux) {
+ switch (tex->image.aux.type) {
case ILO_IMAGE_AUX_HIZ:
if (!tex_create_hiz(tex)) {
/* Separate Stencil Buffer requires HiZ to be enabled */
diff --git a/src/gallium/drivers/ilo/ilo_resource.h b/src/gallium/drivers/ilo/ilo_resource.h
index f78f9495233..0a835d99210 100644
--- a/src/gallium/drivers/ilo/ilo_resource.h
+++ b/src/gallium/drivers/ilo/ilo_resource.h
@@ -200,7 +200,7 @@ ilo_texture_can_enable_hiz(const struct ilo_texture *tex, unsigned level,
const struct ilo_texture_slice *slice =
ilo_texture_get_slice(tex, level, 0);
- return (tex->image.aux_bo && (slice->flags & ILO_TEXTURE_HIZ));
+ return (tex->image.aux.bo && (slice->flags & ILO_TEXTURE_HIZ));
}
#endif /* ILO_RESOURCE_H */